feat: add toast notification system, replace all alert() calls

Create shared toast store and Toast component mounted in root layout.
Wire toast.error() into all fitness API calls that previously failed
silently, and replace all alert() calls across recipes and cospend.
This commit is contained in:
2026-03-25 07:40:37 +01:00
parent 0263a18c5f
commit 3b805861cf
13 changed files with 185 additions and 25 deletions

View File

@@ -8,6 +8,7 @@
import CardAdd from '$lib/components/recipes/CardAdd.svelte';
import CreateIngredientList from '$lib/components/recipes/CreateIngredientList.svelte';
import CreateStepList from '$lib/components/recipes/CreateStepList.svelte';
import { toast } from '$lib/js/toast.svelte';
import Toggle from '$lib/components/Toggle.svelte';
import '$lib/css/action_button.css';
@@ -109,11 +110,11 @@
function prepareSubmit() {
// Client-side validation
if (!short_name.trim()) {
alert('Bitte geben Sie einen Kurznamen ein');
toast.error('Bitte geben Sie einen Kurznamen ein');
return;
}
if (!card_data.name) {
alert('Bitte geben Sie einen Namen ein');
toast.error('Bitte geben Sie einen Namen ein');
return;
}
@@ -159,7 +160,7 @@
// Display form errors if any
$effect(() => {
if (form?.error) {
alert(`Fehler: ${form.error}`);
toast.error(form.error);
}
});
</script>

View File

@@ -15,6 +15,7 @@
import { season } from '$lib/js/season_store';
import { portions } from '$lib/js/portions_store';
import '$lib/css/action_button.css';
import { toast } from '$lib/js/toast.svelte';
let { data, form }: { data: PageData; form: ActionData } = $props();
@@ -173,11 +174,11 @@
function prepareSubmit() {
// Client-side validation
if (!short_name.trim()) {
alert('Bitte geben Sie einen Kurznamen ein');
toast.error('Bitte geben Sie einen Kurznamen ein');
return;
}
if (!card_data.name) {
alert('Bitte geben Sie einen Namen ein');
toast.error('Bitte geben Sie einen Namen ein');
return;
}
@@ -239,7 +240,7 @@
// Display form errors if any
$effect(() => {
if (form?.error) {
alert(`Fehler: ${form.error}`);
toast.error(form.error);
}
});
</script>