import type { CardProps } from '@mui/material/Card'; import Card from '@mui/material/Card'; import CardHeader from '@mui/material/CardHeader'; import { alpha as hexAlpha, useTheme } from '@mui/material/styles'; import { useCallback, useState } from 'react'; import type { ChartOptions } from 'src/components/chart'; import { Chart, ChartLegends, ChartSelect, useChart } from 'src/components/chart'; import { fShortenNumber } from 'src/utils/format-number'; // ---------------------------------------------------------------------- type Props = CardProps & { title?: string; subheader?: string; chart: { colors?: string[]; series: { name: string; categories: string[]; data: { name: string; data: number[]; }[]; }[]; options?: ChartOptions; }; }; export function BookingStatistics({ title, subheader, chart, sx, ...other }: Props) { const theme = useTheme(); const [selectedSeries, setSelectedSeries] = useState('Yearly'); const currentSeries = chart.series.find((i) => i.name === selectedSeries); const chartColors = [theme.palette.primary.dark, hexAlpha(theme.palette.error.main, 0.48)]; const chartOptions = useChart({ colors: chartColors, stroke: { width: 2, colors: ['transparent'] }, xaxis: { categories: currentSeries?.categories }, tooltip: { y: { formatter: (value: number) => `${value}` } }, ...chart.options, }); const handleChangeSeries = useCallback((newValue: string) => { setSelectedSeries(newValue); }, []); return ( item.name)} value={selectedSeries} onChange={handleChangeSeries} /> } sx={{ mb: 3 }} /> item.name)} values={[fShortenNumber(6789), fShortenNumber(1234)]} sx={{ px: 3, gap: 3 }} /> ); }