import { Button, CircularProgress } from '@mui/material';
import { primaryContrastColor } from '../../utils/format';

interface SubmitButtonProps {
  canSubmit: boolean;
  isProcessing: boolean;
  isWaitingStripe: boolean;
  label: string;
  processingLabel: string;
  onSubmit: () => Promise<void>;
}

export default function SubmitButton({
  canSubmit,
  isProcessing,
  isWaitingStripe,
  label,
  processingLabel,
  onSubmit,
}: SubmitButtonProps) {
  return (
    <Button
      variant="contained"
      size="large"
      fullWidth
      disabled={!canSubmit || isWaitingStripe}
      onClick={onSubmit}
      startIcon={isProcessing ? <CircularProgress size={20} color="inherit" /> : null}
      sx={{
        py: 1.5,
        fontSize: '1.3rem',
        fontWeight: 600,
        textTransform: 'none',
        color: (theme) => primaryContrastColor(theme),
      }}>
      {isProcessing ? processingLabel : label}
    </Button>
  );
}
