Dashboard Refactor #5
@@ -161,6 +161,7 @@ export default function Dashboard() {
|
|||||||
config={configuration}
|
config={configuration}
|
||||||
data={data}
|
data={data}
|
||||||
isFetching={report.isFetching}
|
isFetching={report.isFetching}
|
||||||
|
onFlowChange={handleFlowChange}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ export interface DashboardProps {
|
|||||||
config: DashboardConfig;
|
config: DashboardConfig;
|
||||||
data: ReportData;
|
data: ReportData;
|
||||||
isFetching: boolean;
|
isFetching: boolean;
|
||||||
|
onFlowChange?: (state: DashboardState) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,12 +8,13 @@ import {
|
|||||||
Button
|
Button
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useTheme, alpha } from "@mui/material/styles";
|
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({
|
export default function Dashboard({
|
||||||
config,
|
config,
|
||||||
data,
|
data,
|
||||||
isFetching,
|
isFetching,
|
||||||
|
onFlowChange,
|
||||||
}: DashboardProps) {
|
}: DashboardProps) {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const themeMode = theme.palette.mode;
|
const themeMode = theme.palette.mode;
|
||||||
@@ -27,10 +28,35 @@ export default function Dashboard({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const toggleFlow = () => {
|
const toggleFlow = () => {
|
||||||
setState(prev => ({
|
setState(prev => {
|
||||||
|
const nextFlow: DashboardFlow = prev.flow === "outflows" ? "inflows" : "outflows";
|
||||||
|
const nextState: DashboardState = {
|
||||||
...prev,
|
...prev,
|
||||||
flow: prev.flow === "outflows" ? "inflows" : "outflows",
|
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 = () => {
|
const togglePeriodType = () => {
|
||||||
@@ -119,7 +145,7 @@ export default function Dashboard({
|
|||||||
<ToggleButtonGroup
|
<ToggleButtonGroup
|
||||||
value={flow}
|
value={flow}
|
||||||
exclusive
|
exclusive
|
||||||
onChange={toggleFlow}
|
onChange={handleFlowChange}
|
||||||
sx={{
|
sx={{
|
||||||
borderRadius: 3,
|
borderRadius: 3,
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
|
|||||||
10
src/components/LatestItems/LatestItems.props.ts
Normal file
10
src/components/LatestItems/LatestItems.props.ts
Normal 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;
|
||||||
|
}
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
export { default } from "./ProgressCard";
|
export { default } from "./ProgressCard.view";
|
||||||
export * from "./ProgressCard.models";
|
export * from "./ProgressCard.props";
|
||||||
|
|||||||
Reference in New Issue
Block a user