diff --git a/src/lib/ToastService/Toast.svelte b/src/lib/ToastService/Toast.svelte
new file mode 100644
index 0000000..bae42a7
--- /dev/null
+++ b/src/lib/ToastService/Toast.svelte
@@ -0,0 +1,49 @@
+
+
+
+
+
+ {toast.content}
+
+
\ No newline at end of file
diff --git a/src/lib/ToastService/ToastProvider.svelte b/src/lib/ToastService/ToastProvider.svelte
new file mode 100644
index 0000000..30db773
--- /dev/null
+++ b/src/lib/ToastService/ToastProvider.svelte
@@ -0,0 +1,27 @@
+
+
+{@render children()}
+
+ {#each Object.entries(serviceState.toasts) as [i, toast] (i)}
+ destroyToast(i)}/>
+ {/each}
+
\ No newline at end of file
diff --git a/src/lib/ToastService/types.ts b/src/lib/ToastService/types.ts
new file mode 100644
index 0000000..c0ae0dc
--- /dev/null
+++ b/src/lib/ToastService/types.ts
@@ -0,0 +1,13 @@
+export type ToastType = {
+ type: 'info' | 'success' | 'warning' | 'error',
+ content: string,
+}
+
+export type InternalToasts = {
+ [key: string]: ToastType,
+}
+
+export type ServiceState = {
+ toasts: InternalToasts,
+ nextId: number,
+}
diff --git a/src/lib/ToastService/useToast.ts b/src/lib/ToastService/useToast.ts
new file mode 100644
index 0000000..7ac06e5
--- /dev/null
+++ b/src/lib/ToastService/useToast.ts
@@ -0,0 +1,8 @@
+import { getContext } from "svelte";
+import type { ToastType } from "$lib/ToastService/types";
+
+export function useToast(): { fireToast: (toast: ToastType) => void } {
+ return {
+ fireToast: getContext('toastservice')
+ };
+}
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 3153e95..c58ac0b 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -1,7 +1,10 @@
-{@render children()}
+
+ {@render children()}
+
diff --git a/src/routes/[qrcode]/+page.svelte b/src/routes/[qrcode]/+page.svelte
index e060cd6..aa697c3 100644
--- a/src/routes/[qrcode]/+page.svelte
+++ b/src/routes/[qrcode]/+page.svelte
@@ -2,9 +2,12 @@
import { scale } from 'svelte/transition';
import { goto } from "$app/navigation";
import BSlideOverlay from "$lib/BSlideOverlay.svelte";
+ import { useToast } from "$lib/ToastService/useToast";
let { data } = $props();
+ const { fireToast } = useToast();
+
let showOverlay = $state(false);
let startingCharge = $state(false);
@@ -13,12 +16,12 @@
startingCharge = true;
try {
// TODO: StartCharge fetch request
- const response = await fetch(`/api/public/1/chargecontroller/${data.qrcode}/start_charge/`, {
- method: 'POST',
- headers: {
- 'Accept': 'application/json',
- }
- });
+ // const response = await fetch(`/api/public/1/chargecontroller/${data.qrcode}/start_charge/`, {
+ // method: 'POST',
+ // headers: {
+ // 'Accept': 'application/json',
+ // }
+ // });
console.log("nop");
await goto(`/${data.qrcode}/status`);
} finally {
@@ -31,6 +34,9 @@
showOverlay = true}>Attivare la Ricarica
+ fireToast({type: 'success', content: 'Messaggio Ricevuto!'})}>
+ TEST
+