flow fixes

This commit is contained in:
2026-05-18 16:10:01 +05:30
parent eb45304207
commit 980dd6c111
6 changed files with 46 additions and 19 deletions

View File

@@ -161,6 +161,7 @@ export default function Dashboard() {
config={configuration}
data={data}
isFetching={report.isFetching}
onFlowChange={handleFlowChange}
/>
</Box>
);

View File

@@ -54,6 +54,7 @@ export interface DashboardProps {
config: DashboardConfig;
data: ReportData;
isFetching: boolean;
onFlowChange?: (state: DashboardState) => void;
}

View File

@@ -8,12 +8,13 @@ import {
Button
} from "@mui/material";
import { useTheme, alpha } from "@mui/material/styles";
import { DashboardProps, DashboardState, DashboardStateSetters } from "./Dashboard.models";
import { DashboardProps, DashboardState, DashboardStateSetters, DashboardFlow } from "./Dashboard.models";
export default function Dashboard({
config,
data,
isFetching,
onFlowChange,
}: DashboardProps) {
const theme = useTheme();
const themeMode = theme.palette.mode;
@@ -27,10 +28,35 @@ export default function Dashboard({
});
const toggleFlow = () => {
setState(prev => ({
...prev,
flow: prev.flow === "outflows" ? "inflows" : "outflows",
}));
setState(prev => {
const nextFlow: DashboardFlow = prev.flow === "outflows" ? "inflows" : "outflows";
const nextState: DashboardState = {
...prev,
flow: nextFlow,
selectedGroupKey: null,
selectedPeriodId: null,
};
onFlowChange?.(nextState);
return nextState;
});
};
const handleFlowChange = (
_event: React.MouseEvent<HTMLElement>,
newFlow: DashboardFlow | null
) => {
if (newFlow !== null && newFlow !== state.flow) {
setState(prev => {
const nextState: DashboardState = {
...prev,
flow: newFlow,
selectedGroupKey: null,
selectedPeriodId: null,
};
onFlowChange?.(nextState);
return nextState;
});
}
};
const togglePeriodType = () => {
@@ -119,7 +145,7 @@ export default function Dashboard({
<ToggleButtonGroup
value={flow}
exclusive
onChange={toggleFlow}
onChange={handleFlowChange}
sx={{
borderRadius: 3,
overflow: "hidden",

View File

@@ -0,0 +1,10 @@
import { ComponentProps } from "../Dashboard";
import { LatestItem } from "./LatestItems.models";
export interface LatestItemsProps extends ComponentProps {}
export interface LatestItemsViewProps extends LatestItemsProps {
items: LatestItem[];
canExpand: boolean;
onExpand: () => void;
}

View File

@@ -1,11 +0,0 @@
export interface ProgressCardProps {
header: string;
summary?: string;
progressAmount: number;
totalAmount: number;
colorTheme?: "primary" | "secondary" | "error" | "info" | "success" | "warning";
compact?: boolean;
selected?: boolean;
onClick?: () => void;
isFetching?: boolean;
}

View File

@@ -1,2 +1,2 @@
export { default } from "./ProgressCard";
export * from "./ProgressCard.models";
export { default } from "./ProgressCard.view";
export * from "./ProgressCard.props";