All files / src/components/pages/create-group/post-button index.tsx

0% Statements 0/23
0% Branches 0/1
0% Functions 0/1
0% Lines 0/23

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                                               
import { AnyFormState } from '@tanstack/react-form';

import { Button } from '@/components/ui';

interface Props {
  submitName: string;
  state: AnyFormState;
  onSubmitClick: () => void;
}

export const GroupSubmitButton = ({ submitName, state, onSubmitClick }: Props) => {
  const { canSubmit, isSubmitted, isPristine } = state;

  const isSubmitDisabled = !canSubmit || isSubmitted || isPristine;

  return (
    <div className='mt-6 border-t-1 border-gray-200 bg-white px-4 py-3'>
      <Button disabled={isSubmitDisabled} type='button' onClick={onSubmitClick}>
        {submitName}
      </Button>
    </div>
  );
};