import { MERCHANT_REPORT_STATUSES_MAP, UPDATEABLE_REPORT_STATUSES } from '@ballerine/common'; import { Dialog, DialogContent, DialogTrigger, DropdownMenuItem, Skeleton, TextWithNAFallback, } from '@ballerine/ui'; import dayjs from 'dayjs'; import { ArrowLeft, ArrowRightIcon, ChevronLeft, FileQuestion } from 'lucide-react'; import React, { forwardRef, FunctionComponent } from 'react'; import { Link } from 'react-router-dom'; import { Button } from '@/common/components/atoms/Button/Button'; import { Card } from '@/common/components/atoms/Card/Card'; import { CardContent } from '@/common/components/atoms/Card/Card.Content'; import { CardFooter } from '@/common/components/atoms/Card/Card.Footer'; import { CardHeader } from '@/common/components/atoms/Card/Card.Header'; import { CardTitle } from '@/common/components/atoms/Card/Card.Title'; import { Separator } from '@/common/components/atoms/Separator/Separator'; import { BALLERINE_CALENDLY_LINK } from '@/common/constants'; import { ctw } from '@/common/utils/ctw/ctw'; import { BusinessReport } from '@/domains/business-reports/components/BusinessReport/BusinessReport'; import { NotesButton } from '@/domains/notes/NotesButton'; import { NotesSheet } from '@/domains/notes/NotesSheet'; import { MerchantMonitoringReportStatus } from '@/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringReportStatus'; import { useMerchantMonitoringBusinessReportLogic } from '@/pages/MerchantMonitoringBusinessReport/hooks/useMerchantMonitoringBusinessReportLogic/useMerchantMonitoringBusinessReportLogic'; import { BusinessReportOptionsDropdown } from './BusinessReportOptionsDropdown'; import { ReportPDFContainer } from '@/pages/MerchantMonitoringBusinessReport/ReportPDFContainer'; export const DialogDropdownItem = forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & { triggerChildren: React.ReactNode; open?: boolean; onOpenChange?: (open: boolean) => void; } >(({ className, ...props }, ref) => { const { triggerChildren, children, open, onOpenChange, ...itemProps } = props; return ( { event.preventDefault(); }} > {triggerChildren} e.preventDefault()}>{children} ); }); DialogDropdownItem.displayName = 'DialogDropdownItem'; export const MerchantMonitoringBusinessReport: FunctionComponent = () => { const { onNavigateBack, websiteWithNoProtocol, businessReport, notes, isNotesOpen, setIsNotesOpen, isFetchingBusinessReport, locale, isDemoAccount, reportRef, reportPDFContainerRef, ...dropdownProps } = useMerchantMonitoringBusinessReportLogic(); // User should never really get in here, unless he manually sets the id in the URL. // We don't want to prevent backend from sending data for reports that have not been completed yet, // so instead we show a fallback UI. if ( !isFetchingBusinessReport && businessReport?.status && !UPDATEABLE_REPORT_STATUSES.includes(businessReport?.status) ) { let supplementalText = ''; if ( [ MERCHANT_REPORT_STATUSES_MAP['in-progress'], MERCHANT_REPORT_STATUSES_MAP['quality-control'], ].includes(businessReport.status) ) { supplementalText = 'It is currently being processed by our system.'; } return (
Report Not Ready

This report is not available yet. {supplementalText}

); } return (
{isDemoAccount ? (
Get a guided walkthrough of the report
) : ( )}
{/* This ignores parent's padding and covers the whole width. Since we know that padding-x is 6 (1.5rem * 2), we can easily determine negative margin and width required to properly display the separator. */} {isFetchingBusinessReport ? ( ) : (
{websiteWithNoProtocol} {isDemoAccount && ( )}
)} {isFetchingBusinessReport ? ( ) : (
Status
Created at {businessReport?.displayDate && dayjs(new Date(businessReport?.displayDate)).format('MMM Do, YYYY HH:mm')}
Monitoring Status  
)} {isFetchingBusinessReport || !businessReport ? ( <>
) : ( )}
); };