fix(pages): pass pasteOrType
property to story edit form
This commit is contained in:
parent
7f0fe97a18
commit
d5c9866cb0
@ -1,18 +1,17 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
import storyForm from "~/components/story/create/storyForm.vue";
|
import storyForm from "~/components/story/create/storyForm.vue";
|
||||||
import { FormStory } from "@client/types/form/story";
|
import { FormChapter, FormStory } from "@client/types/form/story";
|
||||||
import { IStory } from "@models/stories";
|
import { IStory } from "@models/stories";
|
||||||
import { IChapter } from "@models/stories/chapter";
|
import { IChapter } from "@models/stories/chapter";
|
||||||
|
|
||||||
import { storyEditMiddleware } from "@client/middleware";
|
import { storyEditMiddleware } from "@client/middleware";
|
||||||
import { IBand } from "@models/band";
|
import { IBand } from "@models/band";
|
||||||
import { IUser } from "@models/user";
|
import { IUser } from "@models/user";
|
||||||
|
|
||||||
const rtr = useRoute();
|
const rtr = useRoute();
|
||||||
const {
|
const { data: originalStory } = await useApiFetch<({ chapters: (IChapter & { text: string })[] } & IStory) | null>(`/story/${rtr.params.id}/full`);
|
||||||
data: { value: originalStory },
|
if (originalStory.value === null) {
|
||||||
} = await useApiFetch<({ chapters: (IChapter & { text: string })[] } & IStory) | null>(`/story/${rtr.params.id}/full`);
|
|
||||||
if (originalStory === null) {
|
|
||||||
console.log("IT DOESN'T EXIST DAWG");
|
console.log("IT DOESN'T EXIST DAWG");
|
||||||
throw createError({
|
throw createError({
|
||||||
statusCode: 404,
|
statusCode: 404,
|
||||||
@ -22,25 +21,31 @@
|
|||||||
definePageMeta({
|
definePageMeta({
|
||||||
middleware: ["auth", storyEditMiddleware],
|
middleware: ["auth", storyEditMiddleware],
|
||||||
});
|
});
|
||||||
const story: FormStory = {
|
const story: FormStory = ref<FormStory>({
|
||||||
title: originalStory!.title,
|
title: originalStory.value!.title,
|
||||||
coAuthor: originalStory.coAuthor ? (originalStory.coAuthor as IUser)._id : null,
|
coAuthor: originalStory.value.coAuthor ? (originalStory.coAuthor as IUser)._id : null,
|
||||||
completed: originalStory!.completed,
|
completed: originalStory.value!.completed,
|
||||||
chapters: originalStory!.chapters.map((a, i) => ({
|
chapters: originalStory.value!.chapters.map((a, i) => {
|
||||||
...a,
|
// delete
|
||||||
id: a.id,
|
return {
|
||||||
chapterTitle: a.title,
|
...a,
|
||||||
index: i + 1,
|
chapterTitle: a.title,
|
||||||
bands: (a.bands as IBand[]).map((a) => a._id),
|
id: a.id,
|
||||||
content: a.text,
|
index: i + 1,
|
||||||
uuidKey: v4(),
|
bands: (a.bands as IBand[]).map((a) => a._id),
|
||||||
})),
|
content: a.text,
|
||||||
};
|
uuidKey: v4(),
|
||||||
|
pot: "pasteOrType",
|
||||||
|
} as FormChapter;
|
||||||
|
}),
|
||||||
|
});
|
||||||
useHead({
|
useHead({
|
||||||
title: `Editing story: ${originalStory?.title}`,
|
title: `Editing story: ${originalStory?.title}`,
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<a-typography-title style="text-align: center"> Editing "{{ originalStory?.title }}" </a-typography-title>
|
<a-typography-title style="text-align: center"> Editing "{{ originalStory?.title }}" </a-typography-title>
|
||||||
<story-form :can-draft="false" :data="story" :endpoint="`/story/${rtr.params.id}`" endpoint-method="put"> </story-form>
|
<!-- <client-only>-->
|
||||||
|
<story-form :can-draft="false" v-model:data="story" :endpoint="`/story/${rtr.params.id}`" endpoint-method="put" />
|
||||||
|
<!-- </client-only>-->
|
||||||
</template>
|
</template>
|
||||||
|
Loading…
Reference in New Issue
Block a user