From 47d57b96c858445749908ee6b43dd2f37552b30c Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 17 Apr 2026 09:15:29 +0200 Subject: [PATCH] fix(#248): show merge success banner via PRG pattern (?merged=1 redirect) After a successful merge, redirect 303 to /admin/tags/{targetId}?merged=1. Load function detects the param and returns mergeSuccess:true; +page.svelte renders the banner and cleans the URL with replaceState so refresh doesn't re-show it. Co-Authored-By: Claude Sonnet 4.6 --- .../routes/admin/tags/[id]/+page.server.ts | 6 +-- .../src/routes/admin/tags/[id]/+page.svelte | 17 +++++++ .../admin/tags/[id]/TagMergeZone.svelte | 14 +----- .../tags/[id]/TagMergeZone.svelte.spec.ts | 17 ------- .../admin/tags/[id]/page.server.spec.ts | 46 +++++++++++++++---- .../admin/tags/[id]/page.svelte.spec.ts | 28 ++++++++++- 6 files changed, 86 insertions(+), 42 deletions(-) diff --git a/frontend/src/routes/admin/tags/[id]/+page.server.ts b/frontend/src/routes/admin/tags/[id]/+page.server.ts index da3e5e26..ffa99d47 100644 --- a/frontend/src/routes/admin/tags/[id]/+page.server.ts +++ b/frontend/src/routes/admin/tags/[id]/+page.server.ts @@ -3,11 +3,11 @@ import type { PageServerLoad, Actions } from './$types'; import { createApiClient } from '$lib/api.server'; import { getErrorMessage } from '$lib/errors'; -export const load: PageServerLoad = async ({ params, parent }) => { +export const load: PageServerLoad = async ({ params, parent, url }) => { const { tags } = await parent(); const tag = tags.find((t: { id: string }) => t.id === params.id); if (!tag) throw error(404, getErrorMessage('TAG_NOT_FOUND')); - return { tag }; + return { tag, mergeSuccess: url.searchParams.has('merged') }; }; export const actions: Actions = { @@ -47,7 +47,7 @@ export const actions: Actions = { return fail(result.response.status, { error: getErrorMessage(code) }); } - return { mergeSuccess: true, mergeTargetId: result.data!.id }; + throw redirect(303, `/admin/tags/${result.data!.id}?merged=1`); }, delete: async ({ params, request, fetch }) => { diff --git a/frontend/src/routes/admin/tags/[id]/+page.svelte b/frontend/src/routes/admin/tags/[id]/+page.svelte index daae6402..51a0ce27 100644 --- a/frontend/src/routes/admin/tags/[id]/+page.svelte +++ b/frontend/src/routes/admin/tags/[id]/+page.svelte @@ -1,5 +1,7 @@