Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
UPDATE "WorldBibleVersion"
SET "publishedAt" = COALESCE("publishedAt", "createdAt")
WHERE "versionNumber" = 1
AND "publishedAt" IS NULL;
2 changes: 2 additions & 0 deletions apps/api/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ async function main() {
},
],
},
publishedAt: new Date(),
},
create: {
worldId: world.id,
Expand All @@ -164,6 +165,7 @@ async function main() {
},
],
},
publishedAt: new Date(),
},
});

Expand Down
47 changes: 44 additions & 3 deletions apps/web/src/app/worlds/[worldId]/contribute/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,54 @@
import { LoreContributeClient } from '@/components/lore/lore-contribute-client';
import { ContributionEditorForm } from '@/components/contributions/contribution-editor-form';
import type { ContributionKind } from '@/lib/api/contributions';
import { loreCategories } from '@/lib/worlds/constants';

type ContributePageProps = {
params: Promise<{ worldId: string }>;
searchParams: Promise<{ entryId?: string; type?: string }>;
searchParams: Promise<{ targetLoreEntryId?: string; type?: string }>;
};

function getInitialKind(type?: string): ContributionKind {
return type?.toLowerCase() === 'stories' || type?.toLowerCase() === 'story' ? 'STORY' : 'LORE';
}

function getUnsupportedTypeLabel(type?: string) {
const normalizedType = type?.toLowerCase();

if (!normalizedType || ['lore', 'stories', 'story'].includes(normalizedType)) {
return undefined;
}

return (
loreCategories.find((category) => category.id === normalizedType)?.label ?? 'that category'
);
}

export default async function ContributePage({ params, searchParams }: ContributePageProps) {
const { worldId } = await params;
const query = await searchParams;
const unsupportedTypeLabel = getUnsupportedTypeLabel(query.type);

return (
<div className="space-y-8">
<section>
<p className="text-sm font-medium uppercase tracking-[0.18em] text-muted-foreground">
World {worldId}
</p>
<h1 className="mt-3 max-w-3xl text-4xl font-semibold tracking-normal text-foreground">
Contribution editor
</h1>
<p className="prose-text mt-5 max-w-2xl">
Author a structured draft, save it against this world, then submit it into the proposal
queue for canon voting.
</p>
</section>

return <LoreContributeClient entryId={query.entryId} type={query.type} worldId={worldId} />;
<ContributionEditorForm
initialKind={getInitialKind(query.type)}
{...(query.targetLoreEntryId ? { targetLoreEntryId: query.targetLoreEntryId } : {})}
{...(unsupportedTypeLabel ? { unsupportedType: unsupportedTypeLabel } : {})}
worldId={worldId}
/>
</div>
);
}
13 changes: 13 additions & 0 deletions apps/web/src/app/worlds/[worldId]/lore/edit/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { LoreContributeClient } from '@/components/lore/lore-contribute-client';

type LoreEditPageProps = {
params: Promise<{ worldId: string }>;
searchParams: Promise<{ entryId?: string; type?: string }>;
};

export default async function LoreEditPage({ params, searchParams }: LoreEditPageProps) {
const { worldId } = await params;
const query = await searchParams;

return <LoreContributeClient entryId={query.entryId} type={query.type} worldId={worldId} />;
}
4 changes: 2 additions & 2 deletions apps/web/src/app/worlds/[worldId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ function WorldHubContent({ hub }: { hub: WorldHub }) {
<CardContent>
<Link
className="inline-flex min-h-10 w-full items-center justify-center rounded-control border border-[var(--hive-red)] bg-[var(--hive-red)] px-4 text-sm font-semibold text-white transition-colors hover:bg-[color-mix(in_srgb,var(--hive-red)_88%,black)] focus-visible:outline focus-visible:outline-3 focus-visible:outline-offset-2 focus-visible:outline-focus-ring"
href={`/worlds/${world.id}/contribute`}
href={`/worlds/${world.id}/lore/edit`}
>
Create Lore Entry
</Link>
<Link
className="inline-flex min-h-10 w-full items-center justify-center rounded-control border border-primary bg-primary px-4 text-sm font-semibold text-primary-foreground transition-colors hover:bg-primary/90 focus-visible:outline focus-visible:outline-3 focus-visible:outline-offset-2 focus-visible:outline-focus-ring"
href={`/worlds/${world.id}/contribute?type=story`}
href={`/worlds/${world.id}/contribute?type=stories`}
>
Write Story Contribution
</Link>
Expand Down
Loading
Loading