import { Input } from '@ballerine/ui'; import { CheckIcon, Loader2 } from 'lucide-react'; import { Button } from '@/common/components/atoms/Button/Button'; import { Dialog } from '@/common/components/organisms/Dialog/Dialog'; import { DialogContent } from '@/common/components/organisms/Dialog/Dialog.Content'; import { DialogHeader } from '@/common/components/organisms/Dialog/Dialog.Header'; import { DialogTrigger } from '@/common/components/organisms/Dialog/Dialog.Trigger'; import { Form } from '@/common/components/organisms/Form/Form'; import { FormControl } from '@/common/components/organisms/Form/Form.Control'; import { FormField } from '@/common/components/organisms/Form/Form.Field'; import { FormItem } from '@/common/components/organisms/Form/Form.Item'; import { FormLabel } from '@/common/components/organisms/Form/Form.Label'; import { FormMessage } from '@/common/components/organisms/Form/Form.Message'; import { BusinessReportsLeftCard } from '@/domains/business-reports/components/BusinessReportsLeftCard/BusinessReportsLeftCard'; import { useCreateMerchantReportDialogLogic } from './hooks/useCreateMerchantReportDialogLogic'; import { useCustomerQuery } from '@/domains/customer/hooks/queries/useCustomerQuery/useCustomerQuery'; type CreateMerchantReportDialogProps = { open: boolean; toggleOpen: (val?: boolean) => void; disabled?: boolean; children: React.ReactNode; }; export const CreateMerchantReportDialog = ({ disabled, children, open, toggleOpen: toggleOpenProps, }: CreateMerchantReportDialogProps) => { const { form, showSuccess, isSubmitting, onSubmit, reportsLeft, demoDaysLeft, toggleOpen } = useCreateMerchantReportDialogLogic({ toggleOpen: toggleOpenProps }); const { data: customer } = useCustomerQuery(); const isDemoAccount = customer?.config?.isDemoAccount; return ( {children}

Create a Web Presence Report

{isDemoAccount &&

Try out Ballerine's Web Presence Report!

}
{showSuccess ? ( ) : ( )}
); }; const CreateMerchantReportDialogSuccessContent = () => { const { data: customer } = useCustomerQuery(); const isDemoAccount = customer?.config?.isDemoAccount; return (

Your report is being generated.

{isDemoAccount &&

Ready in up to 24 hours

} You will receive an email alert once the report is ready.
); }; type CreateMerchantReportDialogFormContentProps = Pick< ReturnType, 'form' | 'onSubmit' | 'isSubmitting' | 'demoDaysLeft' | 'reportsLeft' >; const CreateMerchantReportDialogFormContent = ({ form, onSubmit, isSubmitting, demoDaysLeft, reportsLeft, }: CreateMerchantReportDialogFormContentProps) => { const shouldDisableForm = (reportsLeft && reportsLeft <= 0) || (demoDaysLeft && demoDaysLeft <= 0); const { data: customer } = useCustomerQuery(); const isDemoAccount = customer?.config?.isDemoAccount; return (
{isDemoAccount && ( )}
{shouldDisableForm && (
)}
( Website URL )} /> ( Company Name (Optional) )} /> ( Merchant ID (Optional) )} />
); };