2023-12-29 19:02:53 -05:00
|
|
|
<script setup lang="ts">
|
|
|
|
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 },
|
2023-12-29 20:11:07 -05:00
|
|
|
} = await useApiFetch<SingleChapterResult | null>(`/story/${rtr.params.id}/${rtr.params.cidx}`);
|
2023-12-29 19:02:53 -05:00
|
|
|
if (originalStory === null) {
|
|
|
|
throw createError({
|
|
|
|
statusCode: 404,
|
|
|
|
message: "That story doesn't exist...",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
useHead({
|
|
|
|
title: `Editing chapter: ${originalStory.currentChapter.title}`,
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-12-29 20:11:07 -05:00
|
|
|
<single-chapter :data="toFormChapter(originalStory!.currentChapter)" :name="originalStory!.currentChapter.title" />
|
2023-12-29 19:02:53 -05:00
|
|
|
</template>
|