Refresh payment stores on time frame change

This commit is contained in:
2024-08-19 13:09:14 +02:00
parent 37a0c52464
commit 79b89a01e5
2 changed files with 22 additions and 2 deletions

View File

@@ -21,4 +21,14 @@ async function createStore(): Promise<Writable<main.Payment[]>> {
}; };
} }
export const lastMonthPaymentsStore = await createStore(); const lastMonthPaymentsStore = await createStore();
scrollingTimeFrameStore.subscribe(async (timeframe) => {
const res = await GetPaymentsForMonth(timeframe.from);
if (!res.success) {
toast.error("Error getting payments " + res.error);
return;
}
lastMonthPaymentsStore.set(res.data);
});
export { lastMonthPaymentsStore };

View File

@@ -21,4 +21,14 @@ async function createStore(): Promise<Writable<main.Payment[]>> {
}; };
} }
export const thisMonthPaymentsStore = await createStore(); const thisMonthPaymentsStore = await createStore();
scrollingTimeFrameStore.subscribe(async (timeframe) => {
const res = await GetPaymentsForMonth(timeframe.to);
if (!res.success) {
toast.error("Error getting payments " + res.error);
return;
}
thisMonthPaymentsStore.set(res.data);
});
export { thisMonthPaymentsStore };