feat(journey-editor): branch edit page on geschichte type
Static imports for both editors; type-aware <h1> title; JOURNEY type routes to JourneyEditor, STORY type continues to GeschichteEditor unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { m } from '$lib/paraglide/messages.js';
|
import { m } from '$lib/paraglide/messages.js';
|
||||||
import GeschichteEditor from '$lib/geschichte/GeschichteEditor.svelte';
|
import GeschichteEditor from '$lib/geschichte/GeschichteEditor.svelte';
|
||||||
|
import JourneyEditor from '$lib/geschichte/JourneyEditor.svelte';
|
||||||
import BackButton from '$lib/shared/primitives/BackButton.svelte';
|
import BackButton from '$lib/shared/primitives/BackButton.svelte';
|
||||||
import { getErrorMessage } from '$lib/shared/errors';
|
import { getErrorMessage } from '$lib/shared/errors';
|
||||||
import { csrfFetch } from '$lib/shared/cookies';
|
import { csrfFetch } from '$lib/shared/cookies';
|
||||||
@@ -12,6 +13,8 @@ let { data }: { data: PageData } = $props();
|
|||||||
let submitting = $state(false);
|
let submitting = $state(false);
|
||||||
let errorMessage: string | null = $state(null);
|
let errorMessage: string | null = $state(null);
|
||||||
|
|
||||||
|
const isJourney = $derived(data.geschichte.type === 'JOURNEY');
|
||||||
|
|
||||||
async function handleSubmit(payload: {
|
async function handleSubmit(payload: {
|
||||||
title: string;
|
title: string;
|
||||||
body: string;
|
body: string;
|
||||||
@@ -44,7 +47,8 @@ async function handleSubmit(payload: {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h1 class="mb-6 font-serif text-3xl font-bold text-ink">
|
<h1 class="mb-6 font-serif text-3xl font-bold text-ink">
|
||||||
{m.btn_edit()}: {data.geschichte.title}
|
{isJourney ? m.journey_edit_title_journey() : m.journey_edit_title_story()}:
|
||||||
|
{data.geschichte.title}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
{#if errorMessage}
|
{#if errorMessage}
|
||||||
@@ -56,5 +60,13 @@ async function handleSubmit(payload: {
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<GeschichteEditor geschichte={data.geschichte} onSubmit={handleSubmit} submitting={submitting} />
|
{#if isJourney}
|
||||||
|
<JourneyEditor geschichte={data.geschichte} onSubmit={handleSubmit} submitting={submitting} />
|
||||||
|
{:else}
|
||||||
|
<GeschichteEditor
|
||||||
|
geschichte={data.geschichte}
|
||||||
|
onSubmit={handleSubmit}
|
||||||
|
submitting={submitting}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user