'use client'; import * as React from 'react'; import Box from '@mui/material/Box'; import Card from '@mui/material/Card'; import CardContent from '@mui/material/CardContent'; import CardHeader from '@mui/material/CardHeader'; import Divider from '@mui/material/Divider'; import Paper from '@mui/material/Paper'; import Stack from '@mui/material/Stack'; import Typography from '@mui/material/Typography'; import { useTranslation } from 'react-i18next'; import { Bar, BarChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'; import { NoSsr } from '@/components/core/no-ssr'; const bars = [ { name: 'This year', dataKey: 'v1', color: 'var(--mui-palette-primary-400)' }, { name: 'Last year', dataKey: 'v2', color: 'var(--mui-palette-primary-600)' }, ] satisfies { name: string; dataKey: string; color: string }[]; export interface AppUsageProps { data: { name: string; v1: number; v2: number }[]; } export function AppUsage({ data }: AppUsageProps): React.JSX.Element { const { t } = useTranslation(); const chartHeight = 300; return ( +28% {t('increase_in_app_usage_with')}{' '} 6,521 {' '} {t('new_products_purchased')} This year {' '} {t('is_forecasted_to_increase_in_your_traffic_by_the_end_of_the_current_month')} } spacing={2} sx={{ flex: '1 1 auto' }}> }> {bars.map( (bar, index): React.JSX.Element => ( ) )} } cursor={false} /> ); } function Legend(): React.JSX.Element { return ( {bars.map((bar) => ( {bar.name} ))} ); } interface TooltipContentProps { active?: boolean; payload?: { fill: string; name: string; dataKey: string; value: number }[]; label?: string; } function TooltipContent({ active, payload }: TooltipContentProps): React.JSX.Element | null { const { t } = useTranslation(); if (!active) { return null; } return ( {payload?.map( (entry): React.JSX.Element => ( {entry.name} {new Intl.NumberFormat('en-US').format(entry.value)} ) )} ); }