-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use typed functions in seed endpoint
`JSON.parse(JSON.stringify().replace())` is easy to make mistakes with and since we have TypeScript data objects already for the data we're seeding it's pretty easy to just factor these as functions, making their dependencies explicit. Signed-off-by: Steve Kuznetsov <[email protected]>
- Loading branch information
1 parent
827c75a
commit d0d05e3
Showing
7 changed files
with
1,414 additions
and
1,415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,52 @@ | ||
import type { Page } from '@/payload-types' | ||
import type { Form } from '@/payload-types' | ||
import { RequiredDataFromCollectionSlug } from 'payload' | ||
|
||
export const contact: Partial<Page> = { | ||
slug: 'contact', | ||
_status: 'published', | ||
hero: { | ||
type: 'none', | ||
}, | ||
layout: [ | ||
{ | ||
blockType: 'formBlock', | ||
enableIntro: true, | ||
// @ts-ignore | ||
form: '{{CONTACT_FORM_ID}}', | ||
introContent: { | ||
root: { | ||
type: 'root', | ||
children: [ | ||
{ | ||
type: 'heading', | ||
children: [ | ||
{ | ||
type: 'text', | ||
detail: 0, | ||
format: 0, | ||
mode: 'normal', | ||
style: '', | ||
text: 'Example contact form:', | ||
version: 1, | ||
}, | ||
], | ||
direction: 'ltr', | ||
format: '', | ||
indent: 0, | ||
tag: 'h3', | ||
version: 1, | ||
}, | ||
], | ||
direction: 'ltr', | ||
format: '', | ||
indent: 0, | ||
version: 1, | ||
export const contact: (contactForm: Form) => RequiredDataFromCollectionSlug<'pages'> = ( | ||
contactForm: Form, | ||
): RequiredDataFromCollectionSlug<'pages'> => { | ||
return { | ||
slug: 'contact', | ||
_status: 'published', | ||
hero: { | ||
type: 'none', | ||
}, | ||
layout: [ | ||
{ | ||
blockType: 'formBlock', | ||
enableIntro: true, | ||
form: contactForm, | ||
introContent: { | ||
root: { | ||
type: 'root', | ||
children: [ | ||
{ | ||
type: 'heading', | ||
children: [ | ||
{ | ||
type: 'text', | ||
detail: 0, | ||
format: 0, | ||
mode: 'normal', | ||
style: '', | ||
text: 'Example contact form:', | ||
version: 1, | ||
}, | ||
], | ||
direction: 'ltr', | ||
format: '', | ||
indent: 0, | ||
tag: 'h3', | ||
version: 1, | ||
}, | ||
], | ||
direction: 'ltr', | ||
format: '', | ||
indent: 0, | ||
version: 1, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
title: 'Contact', | ||
], | ||
title: 'Contact', | ||
} | ||
} |
Oops, something went wrong.