import * as React from "react"; import { Box, Container, Grid, Typography, ToggleButton, ToggleButtonGroup } from "@mui/material"; import { useTheme, alpha } from "@mui/material/styles"; import { GroupKey } from "../../features/report"; import { DashboardProps, DashboardState } from "./Dashboard.models"; interface ViewProps extends DashboardProps { state: DashboardState; setState: React.Dispatch>; toggleMode: () => void; togglePeriodType: () => void; setSelectedPeriodId: (id: string | null) => void; setSelectedGroupKey: (groupKey: GroupKey | null) => void; toggleComparison: () => void; } export default function DashboardView({ config, data, state, setState, toggleMode, togglePeriodType, toggleComparison, setSelectedPeriodId, setSelectedGroupKey, }: ViewProps) { const theme = useTheme(); const themeMode = theme.palette.mode; const { mode, periodType, comparison, selectedPeriodId, selectedGroupKey } = state; // Resolve colors with fallbacks const colors = React.useMemo(() => { const palette = config.style?.palette?.[mode]; const modeColors = palette ? palette[themeMode] : null; if (modeColors) { return { primary: modeColors.primary, light: modeColors.background || alpha(modeColors.primary, 0.1), text: modeColors.text || (themeMode === 'light' ? theme.palette.text.primary : '#fff') }; } // Fallback to standard theme colors const themeColor = mode === 'expense' ? theme.palette.error : theme.palette.success; return { primary: themeColor.main, light: alpha(themeColor.main, themeMode === 'light' ? 0.08 : 0.15), text: themeColor.main }; }, [config.style?.palette, mode, themeMode, theme.palette]); return ( Expenses Income {config.sections.map((section) => { const Component = section.component; return ( {section.title && !section.isList && ( {section.title} )} ); })} ); }