All files / libs/plan-agreements/components/src/lib/buttons/agreements/plan-agreement-create-button PlanAgreementCreateButton.tsx

100% Statements 27/27
100% Branches 2/2
100% Functions 0/0
100% Lines 27/27

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 281x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 2x 2x 1x  
import { IconPlus } from '@tabler/icons-react';
import { memo } from 'react';
import { FormattedMessage } from 'react-intl';
 
import { Button } from '@allshares/studio-design-system';
import { canCreatePlanAgreements } from '@amalia/kernel/auth/shared';
import { useAbilityContext } from '@amalia/kernel/auth/state';
 
import { usePlanAgreementsModalsContext } from '../../../modals';
 
export const PlanAgreementCreateButton = memo(function PlanAgreementCreateButton() {
  const ability = useAbilityContext();
 
  const { openCreatePlanAgreementModal } = usePlanAgreementsModalsContext();
 
  return (
    canCreatePlanAgreements(ability) && (
      <Button
        icon={<IconPlus />}
        variant="primary"
        onClick={openCreatePlanAgreementModal}
      >
        <FormattedMessage defaultMessage="Create a plan agreement" />
      </Button>
    )
  );
});