feat(pages): add edit page for individual chapter
This commit is contained in:
parent
1c69ad6c2c
commit
02ed969132
35
pages/story/[id]/[cidx]/edit.vue
Normal file
35
pages/story/[id]/[cidx]/edit.vue
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { IChapter } from "@models/stories/chapter";
|
||||||
|
import { IStory } from "@models/stories";
|
||||||
|
import { storyEditMiddleware } from "@client/middleware";
|
||||||
|
import { SingleChapterResult } from "@client/types/slightlyDifferentStory";
|
||||||
|
import SingleChapter from "~/components/story/create/singleChapter.vue";
|
||||||
|
import { toFormChapter } from "@client/types/form/story";
|
||||||
|
|
||||||
|
definePageMeta({
|
||||||
|
middleware: ["auth", storyEditMiddleware],
|
||||||
|
});
|
||||||
|
|
||||||
|
const rtr = useRoute();
|
||||||
|
const {
|
||||||
|
data: { value: originalStory },
|
||||||
|
} = await useApiFetch<SingleChapterResult | null>(
|
||||||
|
`/story/${rtr.params.id}/${rtr.params.cidx}`,
|
||||||
|
);
|
||||||
|
if (originalStory === null) {
|
||||||
|
throw createError({
|
||||||
|
statusCode: 404,
|
||||||
|
message: "That story doesn't exist...",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
useHead({
|
||||||
|
title: `Editing chapter: ${originalStory.currentChapter.title}`,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<single-chapter
|
||||||
|
:data="toFormChapter(originalStory!.currentChapter)"
|
||||||
|
:name="originalStory!.currentChapter.title"
|
||||||
|
/>
|
||||||
|
</template>
|
Loading…
Reference in New Issue
Block a user