diff --git a/frontend/src/lib/store/lastMonthPaymentsStore.ts b/frontend/src/lib/store/lastMonthPaymentsStore.ts index 939952f..b7d3836 100644 --- a/frontend/src/lib/store/lastMonthPaymentsStore.ts +++ b/frontend/src/lib/store/lastMonthPaymentsStore.ts @@ -21,4 +21,14 @@ async function createStore(): Promise> { }; } -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 }; diff --git a/frontend/src/lib/store/thisMonthPaymentsStore.ts b/frontend/src/lib/store/thisMonthPaymentsStore.ts index ecf9f2b..7caebb0 100644 --- a/frontend/src/lib/store/thisMonthPaymentsStore.ts +++ b/frontend/src/lib/store/thisMonthPaymentsStore.ts @@ -21,4 +21,14 @@ async function createStore(): Promise> { }; } -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 };