state controlled by Dashboard.models.ts

This commit is contained in:
2026-05-05 12:26:02 +05:30
parent a0e62b1bc4
commit 30cf227050
5 changed files with 51 additions and 32 deletions

View File

@@ -18,16 +18,15 @@ interface ViewProps extends DashboardProps {
export default function DashboardView({
config,
data,
latest,
state,
setState,
onModeChange,
selectedPeriodId,
onSelectPeriodId,
toggleMode,
togglePeriodType,
setSelectedPeriodId,
}: ViewProps) {
const theme = useTheme();
const themeMode = theme.palette.mode;
const { mode, periodType, comparison } = state;
const { mode, periodType, selectedPeriodId, comparison } = state;
// Resolve colors with fallbacks
const colors = React.useMemo(() => {
@@ -51,13 +50,6 @@ export default function DashboardView({
};
}, [config.style?.palette, mode, themeMode, theme.palette]);
const handleModeChange = (_: any, newMode: any) => {
if (newMode && onModeChange) {
onModeChange(newMode);
setState(prev => ({ ...prev, mode: newMode }));
}
};
return (
<Container
sx={{
@@ -73,7 +65,7 @@ export default function DashboardView({
<ToggleButtonGroup
value={mode}
exclusive
onChange={handleModeChange}
onChange={toggleMode}
sx={{
borderRadius: 3,
overflow: "hidden",
@@ -137,7 +129,6 @@ export default function DashboardView({
header={section.title}
summary={section.summary}
data={section.dataKey ? data[section.dataKey] : data.chartData}
items={section.dataKey === 'latest' ? latest : (data[section.dataKey || ''] || [])}
title={section.title}
accentColor={colors.primary}
colorScheme={colors}
@@ -146,7 +137,7 @@ export default function DashboardView({
comparison={comparison}
setComparison={(c: any) => setState(prev => ({ ...prev, comparison: c }))}
selectedPeriodId={selectedPeriodId}
onSelectPeriodId={onSelectPeriodId}
onSelectPeriodId={setSelectedPeriodId}
/>
)}
</Grid>