diff --git a/src/routes/recipes/[id]/+page.svelte b/src/routes/recipes/[id]/+page.svelte index e08a89b..2623ea0 100644 --- a/src/routes/recipes/[id]/+page.svelte +++ b/src/routes/recipes/[id]/+page.svelte @@ -194,6 +194,28 @@ } } + async function deleteComment(id: number) { + const ok = await confirmAction({ + title: 'Kommentar löschen?', + message: 'Der Eintrag verschwindet ohne Umweg.', + confirmLabel: 'Löschen', + destructive: true + }); + if (!ok) return; + if (!requireOnline('Das Löschen')) return; + const res = await asyncFetch( + `/api/recipes/${data.recipe.id}/comments`, + { + method: 'DELETE', + headers: { 'content-type': 'application/json' }, + body: JSON.stringify({ comment_id: id }) + }, + 'Löschen fehlgeschlagen' + ); + if (!res) return; + comments = comments.filter((c) => c.id !== id); + } + async function deleteRecipe() { const ok = await confirmAction({ title: 'Rezept löschen?', @@ -466,6 +488,16 @@
{c.author}
{c.text}
{new Date(c.created_at).toLocaleString('de-DE')}
+ {#if profileStore.active?.id === c.profile_id} + + {/if} {/each} @@ -673,6 +705,26 @@ border: 1px solid #e4eae7; border-radius: 12px; padding: 0.75rem 0.9rem; + position: relative; + } + .comment-del { + position: absolute; + top: 0.5rem; + right: 0.5rem; + width: 28px; + height: 28px; + display: inline-flex; + align-items: center; + justify-content: center; + border: 0; + background: transparent; + color: #888; + border-radius: 8px; + cursor: pointer; + } + .comment-del:hover { + background: #f3f5f3; + color: #b42626; } .comments .author { font-weight: 600;