soft reload
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
import { useQuery, useMutation, useQueryClient, keepPreviousData } from "@tanstack/react-query";
|
||||||
import { api } from "../api/client";
|
import { api } from "../api/client";
|
||||||
import { ResourceConfig } from "../types/config";
|
import { ResourceConfig } from "../types/config";
|
||||||
import { ConfigContext } from "../providers/ConfigContext";
|
import { ConfigContext } from "../providers/ConfigContext";
|
||||||
@@ -26,6 +26,7 @@ export function useResource<T = any>(config: ResourceConfig | undefined) {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
enabled: !!endpoint,
|
enabled: !!endpoint,
|
||||||
|
placeholderData: keepPreviousData,
|
||||||
});
|
});
|
||||||
|
|
||||||
// --- READ ONE ---
|
// --- READ ONE ---
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ export default function Dashboard() {
|
|||||||
<ConfigurableDashboard
|
<ConfigurableDashboard
|
||||||
config={configuration}
|
config={configuration}
|
||||||
data={data}
|
data={data}
|
||||||
|
isFetching={report.isFetching}
|
||||||
onModeChange={handleModeChange}
|
onModeChange={handleModeChange}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -50,5 +50,6 @@ export interface DashboardConfig {
|
|||||||
export interface DashboardProps {
|
export interface DashboardProps {
|
||||||
config: DashboardConfig;
|
config: DashboardConfig;
|
||||||
data: ReportData;
|
data: ReportData;
|
||||||
|
isFetching?: boolean;
|
||||||
onModeChange?: (state: DashboardState) => void;
|
onModeChange?: (state: DashboardState) => void;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ export default function DashboardView({
|
|||||||
toggleComparison={toggleComparison}
|
toggleComparison={toggleComparison}
|
||||||
setSelectedPeriodId={setSelectedPeriodId}
|
setSelectedPeriodId={setSelectedPeriodId}
|
||||||
setSelectedGroupKey={setSelectedGroupKey}
|
setSelectedGroupKey={setSelectedGroupKey}
|
||||||
|
isFetching={arguments[0].isFetching}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -37,4 +37,6 @@ export interface HistoryChartProps {
|
|||||||
togglePeriodType: () => void;
|
togglePeriodType: () => void;
|
||||||
setSelectedPeriodId: (id: string | null) => void;
|
setSelectedPeriodId: (id: string | null) => void;
|
||||||
toggleComparison: () => void;
|
toggleComparison: () => void;
|
||||||
|
|
||||||
|
isFetching?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,9 @@ export default function HistoryChartView(props: ViewProps) {
|
|||||||
border: "1px solid",
|
border: "1px solid",
|
||||||
borderColor: "divider",
|
borderColor: "divider",
|
||||||
bgcolor: isDark ? "background.paper" : colorScheme.light,
|
bgcolor: isDark ? "background.paper" : colorScheme.light,
|
||||||
|
opacity: props.isFetching ? 0.6 : 1,
|
||||||
|
transition: "opacity 0.3s ease",
|
||||||
|
pointerEvents: props.isFetching ? "none" : "auto",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography variant="h6" fontWeight={700} gutterBottom>
|
<Typography variant="h6" fontWeight={700} gutterBottom>
|
||||||
|
|||||||
@@ -11,4 +11,5 @@ export interface LatestItemsViewProps {
|
|||||||
accentColor: string;
|
accentColor: string;
|
||||||
canExpand: boolean;
|
canExpand: boolean;
|
||||||
onExpand: () => void;
|
onExpand: () => void;
|
||||||
|
isFetching?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ type Props = {
|
|||||||
selectedPeriodId: string | null;
|
selectedPeriodId: string | null;
|
||||||
selectedGroupKey?: GroupKey | null;
|
selectedGroupKey?: GroupKey | null;
|
||||||
accentColor: string;
|
accentColor: string;
|
||||||
|
isFetching?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function LatestItems({
|
export default function LatestItems({
|
||||||
@@ -17,6 +18,7 @@ export default function LatestItems({
|
|||||||
selectedPeriodId,
|
selectedPeriodId,
|
||||||
selectedGroupKey = null,
|
selectedGroupKey = null,
|
||||||
accentColor,
|
accentColor,
|
||||||
|
isFetching,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const [visibleCount, setVisibleCount] = React.useState(5);
|
const [visibleCount, setVisibleCount] = React.useState(5);
|
||||||
|
|
||||||
@@ -38,6 +40,7 @@ export default function LatestItems({
|
|||||||
items={visibleItems}
|
items={visibleItems}
|
||||||
accentColor={accentColor}
|
accentColor={accentColor}
|
||||||
canExpand={canExpand}
|
canExpand={canExpand}
|
||||||
|
isFetching={isFetching}
|
||||||
onExpand={() => setVisibleCount((prev) => prev + 5)}
|
onExpand={() => setVisibleCount((prev) => prev + 5)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,9 +17,10 @@ export default function LatestItemsView({
|
|||||||
accentColor,
|
accentColor,
|
||||||
canExpand,
|
canExpand,
|
||||||
onExpand,
|
onExpand,
|
||||||
|
isFetching,
|
||||||
}: LatestItemsViewProps) {
|
}: LatestItemsViewProps) {
|
||||||
return (
|
return (
|
||||||
<Box sx={{ width: "100%", bgcolor: "background.paper", borderRadius: 4, p: 2 }}>
|
<Box sx={{ width: "100%", bgcolor: "background.paper", borderRadius: 4, p: 2, opacity: isFetching ? 0.6 : 1, transition: "opacity 0.3s ease", pointerEvents: isFetching ? "none" : "auto" }}>
|
||||||
<Box sx={{ mb: 2, px: 2 }}>
|
<Box sx={{ mb: 2, px: 2 }}>
|
||||||
<Typography variant="h6" fontWeight="bold">
|
<Typography variant="h6" fontWeight="bold">
|
||||||
Recent Transactions
|
Recent Transactions
|
||||||
|
|||||||
@@ -7,4 +7,5 @@ export interface ProgressCardProps {
|
|||||||
compact?: boolean;
|
compact?: boolean;
|
||||||
selected?: boolean;
|
selected?: boolean;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
|
isFetching?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ export default function ProgressCardView({
|
|||||||
? `${baseShadow}, 0 0 0 2px ${theme.palette.background.paper}, 0 0 0 4px ${theme.palette[colorTheme]?.main || theme.palette.primary.main}`
|
? `${baseShadow}, 0 0 0 2px ${theme.palette.background.paper}, 0 0 0 4px ${theme.palette[colorTheme]?.main || theme.palette.primary.main}`
|
||||||
: baseShadow;
|
: baseShadow;
|
||||||
},
|
},
|
||||||
|
opacity: arguments[0].isFetching ? 0.6 : 1,
|
||||||
|
pointerEvents: arguments[0].isFetching ? "none" : "auto",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography
|
<Typography
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ type Props = {
|
|||||||
selectedGroupKey?: GroupKey | null;
|
selectedGroupKey?: GroupKey | null;
|
||||||
setSelectedGroupKey?: (key: GroupKey | null) => void;
|
setSelectedGroupKey?: (key: GroupKey | null) => void;
|
||||||
compact?: boolean;
|
compact?: boolean;
|
||||||
|
isFetching?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function TopTags({
|
export default function TopTags({
|
||||||
@@ -20,6 +21,7 @@ export default function TopTags({
|
|||||||
selectedGroupKey,
|
selectedGroupKey,
|
||||||
setSelectedGroupKey,
|
setSelectedGroupKey,
|
||||||
compact = true,
|
compact = true,
|
||||||
|
isFetching,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const { items, total } = React.useMemo(() => {
|
const { items, total } = React.useMemo(() => {
|
||||||
return extractTopTags(reportData, mode, selectedPeriodId);
|
return extractTopTags(reportData, mode, selectedPeriodId);
|
||||||
@@ -48,6 +50,7 @@ export default function TopTags({
|
|||||||
compact={compact}
|
compact={compact}
|
||||||
colorTheme={mode === "expense" ? "error" : "success"}
|
colorTheme={mode === "expense" ? "error" : "success"}
|
||||||
selected={isSelected}
|
selected={isSelected}
|
||||||
|
isFetching={isFetching}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (setSelectedGroupKey) {
|
if (setSelectedGroupKey) {
|
||||||
setSelectedGroupKey(isSelected ? null : { tags: [item.tag] });
|
setSelectedGroupKey(isSelected ? null : { tags: [item.tag] });
|
||||||
|
|||||||
Reference in New Issue
Block a user