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:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user