Rework "nowStore" to scrollingTimeFrameStore that contains both from and to dates

This commit is contained in:
2024-08-19 12:45:37 +02:00
parent c5613ee0cc
commit f018459818
8 changed files with 49 additions and 42 deletions

View File

@@ -2,13 +2,11 @@ import { get, type Writable, writable } from "svelte/store";
import { GetPaymentsForMonth } from "$wails/main/App";
import { main } from "$wails/models";
import { toast } from "svelte-sonner";
import { nowStore } from "$lib/store/nowStore";
import { scrollingTimeFrameStore } from "$lib/store/scrollingTimeFrameStore";
async function createStore(): Promise<Writable<main.Payment[]>> {
const payments: main.Payment[] = [];
const now = new Date();
now.setMonth(get(nowStore).getMonth() - 1)
const res = await GetPaymentsForMonth(now);
const res = await GetPaymentsForMonth(get(scrollingTimeFrameStore).from);
if (!res.success) {
toast.error("Error getting payments " + res.error);
} else {