generated from dave/wails-template
	Add payment stores
This commit is contained in:
		| @@ -1,17 +1,17 @@ | ||||
| import { type Writable, writable } from "svelte/store"; | ||||
| import {GetBills} from '$wails/main/App' | ||||
| import { GetBills } from "$wails/main/App"; | ||||
| import { main } from "$wails/models"; | ||||
| import { toast } from "svelte-sonner"; | ||||
|  | ||||
| async function createStore(): Promise<Writable<Map<number, main.Bill>>> { | ||||
| async function createStore(): Promise<Writable<Map<number, main.Bill>> & { refresh: Function }> { | ||||
| 	const bills: Map<number, main.Bill> = new Map<number, main.Bill>(); | ||||
| 	const res = await GetBills() | ||||
| 	const res = await GetBills(); | ||||
| 	if (!res.success) { | ||||
| 		toast.error("Error getting bills " + res.error); | ||||
| 	} else { | ||||
| 		for (let i = 0; i < res.data.length; i++) { | ||||
| 			const bill = res.data[i]; | ||||
| 			bills.set(bill.id, bill) | ||||
| 			bills.set(bill.id, bill); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -20,15 +20,14 @@ async function createStore(): Promise<Writable<Map<number, main.Bill>>> { | ||||
| 		subscribe, | ||||
| 		update, | ||||
| 		set, | ||||
| 		// @ts-ignore | ||||
| 		refresh: async () => { | ||||
| 			const res = await GetBills() | ||||
| 			const res = await GetBills(); | ||||
| 			if (!res.success) { | ||||
| 				toast.error("Error getting bills " + res.error); | ||||
| 			} else { | ||||
| 				for (let i = 0; i < res.data.length; i++) { | ||||
| 					const bill = res.data[i]; | ||||
| 					bills.set(bill.id, bill) | ||||
| 					bills.set(bill.id, bill); | ||||
| 				} | ||||
| 			} | ||||
| 		}, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user