import { buttonVariants, WarningFilledSvg } from '@ballerine/ui'; import qs from 'qs'; import { FunctionComponent } from 'react'; import { Link } from 'react-router-dom'; import { Cell, Pie, PieChart } from 'recharts'; import { titleCase } from 'string-ts'; import { z } from 'zod'; import { Card } from '@/common/components/atoms/Card/Card'; import { CardContent } from '@/common/components/atoms/Card/Card.Content'; import { CardHeader } from '@/common/components/atoms/Card/Card.Header'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/common/components/atoms/Table'; import type { useHomeLogic } from '@/common/hooks/useHomeLogic/useHomeLogic'; import { ctw } from '@/common/utils/ctw/ctw'; import { MetricsResponseSchema } from '@/domains/business-reports/hooks/queries/useBusinessReportMetricsQuery/useBusinessReportMetricsQuery'; import { usePortfolioRiskStatisticsLogic } from './hooks/usePortfolioRiskStatisticsLogic/usePortfolioRiskStatisticsLogic'; export const PortfolioRiskStatistics: FunctionComponent< Pick, 'riskLevelCounts' | 'violationCounts'> & { from: ReturnType['mmFrom']; to: ReturnType['mmTo']; } > = ({ from, to, riskLevelCounts, violationCounts }) => { const { riskLevelToFillColor, parent, widths, riskLevelToBackgroundColor, filteredRiskIndicators, locale, navigate, alertedReports, isOngoingMonitoringEnabled, } = usePortfolioRiskStatisticsLogic({ from, to, violationCounts }); return (
Merchant Monitoring Risk

Risk levels of all merchant monitoring reports.

{Object.values(riskLevelCounts).reduce((acc, curr) => acc + curr, 0)} Reports ({ name: `${titleCase(riskLevel)} Risk`, value, }))} cx={87} cy={87} innerRadius={78} outerRadius={92} fill="#8884d8" paddingAngle={5} dataKey="value" cornerRadius={9999} > {Object.keys(riskLevelToFillColor).map(riskLevel => ( { navigate( `/${locale}/merchant-monitoring?${qs.stringify({ allowAllDates: !from && !to, 'riskLevels[0]': riskLevel, from: from ?? undefined, to: to ?? undefined, })}`, ); }} /> ))}
    {Object.entries(riskLevelCounts) .reverse() .map(([riskLevel, value]) => (
  • {titleCase(riskLevel)} Risk {value}
  • ))}
Top 10 Content Violations {filteredRiskIndicators.length ? ( Indicator Amount {filteredRiskIndicators.map(({ name, count, id }, index) => ( {titleCase(name ?? '')} {Intl.NumberFormat().format(count)} ))}
) : (
No Data Available
)}
{isOngoingMonitoringEnabled && (
Unresolved Monitoring Alerts
{Intl.NumberFormat().format(alertedReports)}
View
)}
); };