All files / libs/plan-agreements/components/src/lib/modals PlanAgreementsArchiveModal.tsx

96.36% Statements 53/55
100% Branches 2/2
100% Functions 1/1
96.36% Lines 53/55

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 561x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import { IconArchive } from '@tabler/icons-react';
import { memo, useCallback } from 'react';
import { FormattedMessage } from 'react-intl';
 
import { Modal, Typography } from '@allshares/studio-design-system';
import { useArchivePlanAgreement } from '@amalia/plan-agreements/state';
 
import { usePlanAgreementsModalsContext } from './PlanAgreementsModals.context';
 
export const PlanAgreementsArchiveModal = memo(function PlanAgreementsArchiveModal() {
  const { closeModal, planAgreementForModal } = usePlanAgreementsModalsContext();
  const { mutate: archivePlanAgreement, isPending } = useArchivePlanAgreement(planAgreementForModal?.id);
 
  const handleClickArchive = useCallback(() => {
    archivePlanAgreement();
    closeModal();
  }, [archivePlanAgreement, closeModal]);
 
  return (
    <Modal
      isOpen
      onClose={closeModal}
    >
      <Modal.Content>
        <Modal.Header>
          <Modal.Title>
            <FormattedMessage defaultMessage="Archive plan agreement" />
          </Modal.Title>
        </Modal.Header>
 
        <Modal.Body>
          <FormattedMessage
            defaultMessage="Are you sure you want to archive <strong>{planAgreementName}</strong>?{br}You won't be able to do any actions with this agreement."
            values={{
              strong: (chunks) => <Typography variant="bodyBaseBold">{chunks}</Typography>,
              planAgreementName: planAgreementForModal?.name,
            }}
          />
        </Modal.Body>
      </Modal.Content>
 
      <Modal.Actions>
        <Modal.CancelAction disabled={isPending} />
 
        <Modal.MainAction
          icon={<IconArchive />}
          isLoading={isPending}
          onClick={handleClickArchive}
        >
          <FormattedMessage defaultMessage="Archive" />
        </Modal.MainAction>
      </Modal.Actions>
    </Modal>
  );
});