Add Toast errors

This commit is contained in:
2024-08-09 19:52:00 +02:00
parent 97a3868a4f
commit 27f8d2bd29

View File

@@ -1,12 +1,13 @@
import { type Writable, writable } from "svelte/store";
import { main } from "$wails/models";
import { GetFood } from "$wails/main/App";
import { toast } from "svelte-sonner";
async function createStore(): Promise<Writable<main.Food[]>> {
let foods: main.Food[] = [];
let res: main.WailsFood = await GetFood();
if (!res.success) {
console.error("failed to get foods with error" + res.error);
toast.error(`Failed to get foods with error: ${res.error}`);
} else {
foods = res.data;
}
@@ -20,7 +21,7 @@ async function createStore(): Promise<Writable<main.Food[]>> {
refresh: async () => {
const res = await GetFood();
if (!res.success) {
console.error("failed to get foods with error" + res.error);
toast.error(`Failed to get foods with error: ${res.error}`);
return;
}
set(res.data);