From b7f83cb73470b9a5d1fe5776ba3d8177a57cf6cb Mon Sep 17 00:00:00 2001 From: Till JS Date: Thu, 16 Apr 2026 15:27:18 +0200 Subject: [PATCH] fix: migrate remaining inline toasts + delete dead /subscription route MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix 2 broken showToast() calls in SyncSection (function was removed but two call sites survived — runtime error on deactivate/interval). Migrate inline toasts to central toast store in: - gifts/+page.svelte (11 refs) - gifts/redeem/[code]/+page.svelte (9 refs) Delete routes/(app)/subscription/+page.svelte — dead standalone route from before the credits merge. Update Stripe redirect URLs in subscriptions API to use /?app=credits&success/canceled=true. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../apps/web/src/lib/api/subscriptions.ts | 4 +- .../settings/sections/SyncSection.svelte | 4 +- .../web/src/routes/(app)/gifts/+page.svelte | 33 +- .../(app)/gifts/redeem/[code]/+page.svelte | 29 +- .../routes/(app)/subscription/+page.svelte | 560 ------------------ 5 files changed, 14 insertions(+), 616 deletions(-) delete mode 100644 apps/mana/apps/web/src/routes/(app)/subscription/+page.svelte diff --git a/apps/mana/apps/web/src/lib/api/subscriptions.ts b/apps/mana/apps/web/src/lib/api/subscriptions.ts index af62ea65f..c1e3241cd 100644 --- a/apps/mana/apps/web/src/lib/api/subscriptions.ts +++ b/apps/mana/apps/web/src/lib/api/subscriptions.ts @@ -103,8 +103,8 @@ export const subscriptionsService = { planId: string, billingInterval: 'month' | 'year' ): Promise<{ sessionId: string; url: string }> { - const successUrl = `${window.location.origin}/subscription?success=true`; - const cancelUrl = `${window.location.origin}/subscription?canceled=true`; + const successUrl = `${window.location.origin}/?app=credits&success=true`; + const cancelUrl = `${window.location.origin}/?app=credits&canceled=true`; return fetchWithAuth('/api/v1/subscriptions/checkout', { method: 'POST', diff --git a/apps/mana/apps/web/src/lib/components/settings/sections/SyncSection.svelte b/apps/mana/apps/web/src/lib/components/settings/sections/SyncSection.svelte index 19d0bff22..a46d889b2 100644 --- a/apps/mana/apps/web/src/lib/components/settings/sections/SyncSection.svelte +++ b/apps/mana/apps/web/src/lib/components/settings/sections/SyncSection.svelte @@ -57,7 +57,7 @@ error = null; try { await syncBilling.deactivate(); - showToast('Cloud Sync deaktiviert', 'success'); + toast.success('Cloud Sync deaktiviert'); } catch (e) { error = e instanceof Error ? e.message : 'Deaktivierung fehlgeschlagen'; toast.error(error); @@ -72,7 +72,7 @@ error = null; try { await syncBilling.changeInterval(selectedInterval); - showToast(`Intervall auf ${INTERVAL_LABELS[selectedInterval]} geändert`, 'success'); + toast.success(`Intervall auf ${INTERVAL_LABELS[selectedInterval]} geändert`); } catch (e) { error = e instanceof Error ? e.message : 'Änderung fehlgeschlagen'; toast.error(error); diff --git a/apps/mana/apps/web/src/routes/(app)/gifts/+page.svelte b/apps/mana/apps/web/src/routes/(app)/gifts/+page.svelte index 31d21e340..ffbdf672e 100644 --- a/apps/mana/apps/web/src/routes/(app)/gifts/+page.svelte +++ b/apps/mana/apps/web/src/routes/(app)/gifts/+page.svelte @@ -3,6 +3,7 @@ import { onMount } from 'svelte'; import { page } from '$app/stores'; import { Card, PageHeader } from '@mana/shared-ui'; + import { toast } from '$lib/stores/toast.svelte'; import { ClipboardText, X } from '@mana/shared-icons'; import { giftsService, @@ -32,8 +33,6 @@ let cancellingId = $state(null); // Toast notification - let toastMessage = $state(null); - let toastType = $state<'success' | 'error'>('success'); // Handle tab from URL params $effect(() => { @@ -91,7 +90,7 @@ const result = await giftsService.createGift(request); createdGift = { code: result.code, url: result.url }; - showToast('Geschenk-Code erstellt!', 'success'); + toast.success('Geschenk-Code erstellt!'); // Reset form createCredits = 50; @@ -103,7 +102,7 @@ await loadData(); } catch (e) { createError = e instanceof Error ? e.message : 'Erstellen fehlgeschlagen'; - showToast(createError, 'error'); + toast.error(createError); console.error('Failed to create gift:', e); } finally { creating = false; @@ -122,10 +121,10 @@ cancellingId = gift.id; try { const result = await giftsService.cancelGift(gift.id); - showToast(`${result.refundedCredits} Credits erstattet`, 'success'); + toast.success(`${result.refundedCredits} Credits erstattet`); await loadData(); } catch (e) { - showToast(e instanceof Error ? e.message : 'Stornieren fehlgeschlagen', 'error'); + toast.error(e instanceof Error ? e.message : 'Stornieren fehlgeschlagen'); console.error('Failed to cancel gift:', e); } finally { cancellingId = null; @@ -134,15 +133,7 @@ function copyToClipboard(text: string) { navigator.clipboard.writeText(text); - showToast('In Zwischenablage kopiert', 'success'); - } - - function showToast(message: string, type: 'success' | 'error') { - toastMessage = message; - toastType = type; - setTimeout(() => { - toastMessage = null; - }, 4000); + toast.success('In Zwischenablage kopiert'); } function formatCredits(amount: number): string { @@ -640,18 +631,6 @@ {/if} - -{#if toastMessage} -
- {toastMessage} -
-{/if} -