removed expense and income vs outflow and inflow
This commit is contained in:
@@ -18,13 +18,8 @@ import {
|
||||
prepareReport,
|
||||
} from "./features/report";
|
||||
|
||||
/** Map the internal UI mode to the API flow param */
|
||||
function modeToFlow(mode: "expense" | "income"): "outflows" | "inflows" {
|
||||
return mode === "expense" ? "outflows" : "inflows";
|
||||
}
|
||||
|
||||
export default function Dashboard() {
|
||||
const [mode, setMode] = React.useState<"expense" | "income">("expense");
|
||||
const [flow, setFlow] = React.useState<"outflows" | "inflows">("outflows");
|
||||
|
||||
const [appliedPayees, setAppliedPayees] = React.useState<string[]>([]);
|
||||
const [appliedTags, setAppliedTags] = React.useState<string[]>([]);
|
||||
@@ -37,7 +32,7 @@ export default function Dashboard() {
|
||||
|
||||
const report = useReport({
|
||||
periods: ["daily", "weekly", "monthly", "all"],
|
||||
flow: modeToFlow(mode),
|
||||
flow: flow,
|
||||
payee: appliedPayees.length > 0 ? appliedPayees : undefined,
|
||||
tags: appliedTags.length > 0 ? appliedTags : undefined,
|
||||
});
|
||||
@@ -77,9 +72,9 @@ export default function Dashboard() {
|
||||
const isLoading = report.isLoading;
|
||||
const error = report.error;
|
||||
|
||||
/** Callback for the ConfigurableDashboard's mode toggle */
|
||||
const handleModeChange = React.useCallback((newState: DashboardState) => {
|
||||
setMode(newState.mode);
|
||||
/** Callback for the ConfigurableDashboard's flow toggle */
|
||||
const handleFlowChange = React.useCallback((newState: DashboardState) => {
|
||||
setFlow(newState.flow);
|
||||
}, []);
|
||||
|
||||
if (isLoading && !report.data) {
|
||||
@@ -166,7 +161,7 @@ export default function Dashboard() {
|
||||
config={configuration}
|
||||
data={data}
|
||||
isFetching={report.isFetching}
|
||||
onModeChange={handleModeChange}
|
||||
onFlowChange={handleFlowChange}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user