From aa53e6f2ceae65345e711daff9e7a7300e9288f3 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Fri, 29 Nov 2024 21:52:48 +0100 Subject: [PATCH] fixing the page form --- src/entities/page/page.mock.ts | 4 ++-- src/entities/page/page.ts | 23 +++++------------------ src/entities/page/page.types.ts | 2 +- src/modals/page/EditPageModal.vue | 1 - 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/entities/page/page.mock.ts b/src/entities/page/page.mock.ts index 90e5e8f5..347adfc9 100644 --- a/src/entities/page/page.mock.ts +++ b/src/entities/page/page.mock.ts @@ -11,7 +11,7 @@ export const mockPageData = (): TPage[] => [ uuid: '123e4567-e89b-12d3-a456-426614174000', name: 'Test Page', slug: 'test-page', - contents: [], + contents: '{}', createdAt: new Date().toISOString(), updatedAt: new Date().toISOString() }, @@ -29,7 +29,7 @@ export const mockPageData = (): TPage[] => [ uuid: '123e4567-e89b-12d3-a456-426614174002', name: '', slug: '', - contents: [], + contents: '{}', createdAt: new Date().toISOString(), updatedAt: new Date().toISOString() }, diff --git a/src/entities/page/page.ts b/src/entities/page/page.ts index 978eaf07..60281ad1 100644 --- a/src/entities/page/page.ts +++ b/src/entities/page/page.ts @@ -11,7 +11,7 @@ export class Page implements TPage { public uuid: string public name: string public slug: string - public contents: Array + public contents: string public createdAt: string public updatedAt: string @@ -33,12 +33,7 @@ export class Page implements TPage { this.uuid = data?.uuid || '' this.name = data?.name || '' this.slug = data?.slug || '' - this.contents = data?.contents?.map(contents => ({ - title: contents?.title || '', - summary: contents?.summary || '', - description: contents?.description || '', - image: contents?.image || '' - })) || [] + this.contents = data?.contents || '{}' this.createdAt = data?.createdAt || '' this.updatedAt = data?.updatedAt || '' } @@ -51,17 +46,9 @@ export class Page implements TPage { public validate(): SafeParseReturnType { // Schema validation for page data const schema = z.object({ - uuid: z.string().min(1, 'is verplicht'), - name: z.string().min(1, 'is verplicht'), - slug: z.string().min(1, 'is verplicht'), - contents: z.array(z.object({ - title: z.string().min(1, 'is verplicht'), - summary: z.string().min(1, 'is verplicht'), - description: z.string(), - image: z.string() - })), - createdAt: z.string(), - updatedAt: z.string() + name: z.string().min(1, 'naam is verplicht'), + slug: z.string().min(1, 'slug is verplicht'), + contents: z.string(), }) const result = schema.safeParse({ diff --git a/src/entities/page/page.types.ts b/src/entities/page/page.types.ts index 2aea7d70..b005d72c 100644 --- a/src/entities/page/page.types.ts +++ b/src/entities/page/page.types.ts @@ -6,7 +6,7 @@ export type TPage = { id: string // Unique identifier for the page uuid: string // Unique identifier for the page name: string // Title/heading of the page - contents: Array // Main content/body of the page - can contain any type of content + contents: string // JSON object, Main content/body of the page - can contain any type of content slug: string // URL-friendly version of the title createdAt: string // Creation timestamp updatedAt: string // Last update timestamp diff --git a/src/modals/page/EditPageModal.vue b/src/modals/page/EditPageModal.vue index 5328a160..9498f98a 100644 --- a/src/modals/page/EditPageModal.vue +++ b/src/modals/page/EditPageModal.vue @@ -44,7 +44,6 @@ import { navigationStore, pageStore } from '../../store/store.js'