import { Badge } from '@ballerine/ui'; import { titleCase } from 'string-ts'; import { MERCHANT_REPORT_STATUSES_MAP } from '@ballerine/common'; import { ctw } from '@/common/utils/ctw/ctw'; import { useEllipsesWithTitle } from '@/common/hooks/useEllipsesWithTitle/useEllipsesWithTitle'; import { captureSentryError } from '@/sentry/capture-exception'; const reportInProgressData = { variant: 'gray', title: 'Scan in progress', text: '', }; export const statusToData = { [MERCHANT_REPORT_STATUSES_MAP['in-progress']]: reportInProgressData, [MERCHANT_REPORT_STATUSES_MAP['quality-control']]: reportInProgressData, [MERCHANT_REPORT_STATUSES_MAP['pending-review']]: { variant: 'gray', title: 'Pending Review', text: 'The review process has not yet started', }, [MERCHANT_REPORT_STATUSES_MAP['under-review']]: { variant: 'info', title: 'Under Review', text: 'The merchant is currently being assessed', }, [MERCHANT_REPORT_STATUSES_MAP['conditionally-approved']]: { variant: 'warning', title: 'Conditionally Approved', text: 'Merchant reviewed with minor or borderline issues', }, [MERCHANT_REPORT_STATUSES_MAP['cleared']]: { variant: 'success', title: 'Cleared', text: 'Merchant reviewed and found compliant or low risk', }, [MERCHANT_REPORT_STATUSES_MAP['terminated']]: { variant: 'destructive', title: 'Terminated', text: 'Merchant reviewed and confirmed non-compliant or high risk', }, // TODO: remove completed: { variant: 'success', title: 'Completed', text: 'Merchant review has been completed', }, } as const; export const MerchantMonitoringStatusBadge = ({ status, disabled = false, ...props }: { status: keyof typeof statusToData; disabled?: boolean; }) => { const { ref, styles } = useEllipsesWithTitle(); // TODO: Can be removed when we get rid of records that have this status if ((status as string) === MERCHANT_REPORT_STATUSES_MAP['completed']) { status = MERCHANT_REPORT_STATUSES_MAP['conditionally-approved']; } if (!statusToData[status]) { captureSentryError( new Error(`MerchantMonitoringStatusBadge: status "${status}" not found in statusToData.`), { componentName: 'MerchantMonitoringStatusBadge' }, ); return null; } const isReportInProgress = [ MERCHANT_REPORT_STATUSES_MAP['in-progress'], MERCHANT_REPORT_STATUSES_MAP['quality-control'], ].includes(status); return (   {statusToData[status].title ?? titleCase(status ?? '')} ); }; MerchantMonitoringStatusBadge.displayName = 'MerchantMonitoringStatusBadge';