feat: builds multi-tenant example (#2689)

* feat: builds multi-tenant example

* chore: updates seed script logic
This commit is contained in:
Jacob Fletcher
2023-05-23 16:40:18 -04:00
committed by GitHub
parent f9de807daa
commit 2fc9288870
42 changed files with 8286 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import type { FieldHook } from 'payload/types'
const format = (val: string): string =>
val
.replace(/ /g, '-')
.replace(/[^\w-]+/g, '')
.toLowerCase()
const formatSlug =
(fallback: string): FieldHook =>
({ operation, value, originalDoc, data }) => {
if (typeof value === 'string') {
return format(value)
}
if (operation === 'create') {
const fallbackData = data?.[fallback] || originalDoc?.[fallback]
if (fallbackData && typeof fallbackData === 'string') {
return format(fallbackData)
}
}
return value
}
export default formatSlug