fix(shopping): requireOnline-Guards + 2-space indent
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 3m14s
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 3m14s
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
import type { ShoppingListRow as Row } from '$lib/server/shopping/repository';
|
import type { ShoppingListRow as Row } from '$lib/server/shopping/repository';
|
||||||
import { shoppingCartStore } from '$lib/client/shopping-cart.svelte';
|
import { shoppingCartStore } from '$lib/client/shopping-cart.svelte';
|
||||||
import { confirmAction } from '$lib/client/confirm.svelte';
|
import { confirmAction } from '$lib/client/confirm.svelte';
|
||||||
|
import { requireOnline } from '$lib/client/require-online';
|
||||||
|
|
||||||
let snapshot = $state<ShoppingListSnapshot>({ recipes: [], rows: [], uncheckedCount: 0 });
|
let snapshot = $state<ShoppingListSnapshot>({ recipes: [], rows: [], uncheckedCount: 0 });
|
||||||
let loading = $state(true);
|
let loading = $state(true);
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function onToggleRow(row: Row, next: boolean) {
|
async function onToggleRow(row: Row, next: boolean) {
|
||||||
|
if (!requireOnline('Abhaken')) return;
|
||||||
const method = next ? 'POST' : 'DELETE';
|
const method = next ? 'POST' : 'DELETE';
|
||||||
await fetch('/api/shopping-list/check', {
|
await fetch('/api/shopping-list/check', {
|
||||||
method,
|
method,
|
||||||
@@ -34,6 +36,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function onServingsChange(recipeId: number, servings: number) {
|
async function onServingsChange(recipeId: number, servings: number) {
|
||||||
|
if (!requireOnline('Portionen-Aenderung')) return;
|
||||||
await fetch(`/api/shopping-list/recipe/${recipeId}`, {
|
await fetch(`/api/shopping-list/recipe/${recipeId}`, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
headers: { 'content-type': 'application/json' },
|
headers: { 'content-type': 'application/json' },
|
||||||
@@ -44,18 +47,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function onRemoveRecipe(recipeId: number) {
|
async function onRemoveRecipe(recipeId: number) {
|
||||||
|
if (!requireOnline('Rezept-Entfernung')) return;
|
||||||
await fetch(`/api/shopping-list/recipe/${recipeId}`, { method: 'DELETE' });
|
await fetch(`/api/shopping-list/recipe/${recipeId}`, { method: 'DELETE' });
|
||||||
await load();
|
await load();
|
||||||
void shoppingCartStore.refresh();
|
void shoppingCartStore.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clearChecked() {
|
async function clearChecked() {
|
||||||
|
if (!requireOnline('Erledigte entfernen')) return;
|
||||||
await fetch('/api/shopping-list/checked', { method: 'DELETE' });
|
await fetch('/api/shopping-list/checked', { method: 'DELETE' });
|
||||||
await load();
|
await load();
|
||||||
void shoppingCartStore.refresh();
|
void shoppingCartStore.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clearAll() {
|
async function clearAll() {
|
||||||
|
if (!requireOnline('Liste leeren')) return;
|
||||||
const ok = await confirmAction({
|
const ok = await confirmAction({
|
||||||
title: 'Einkaufsliste leeren?',
|
title: 'Einkaufsliste leeren?',
|
||||||
message: 'Alle Rezepte und abgehakten Zutaten werden entfernt. Das lässt sich nicht rückgängig machen.',
|
message: 'Alle Rezepte und abgehakten Zutaten werden entfernt. Das lässt sich nicht rückgängig machen.',
|
||||||
|
|||||||
Reference in New Issue
Block a user