Files
j_kedzierski/scripts/dump_proof.ts
T

44 lines
1.8 KiB
TypeScript

import { getPayload } from 'payload'
import configPromise from '../src/payload.config'
async function run() {
const payload = await getPayload({ config: configPromise })
console.log('--- KOTWICE USŁUG (HOME -> USLUGI) ---')
for (const locale of ['pl', 'de'] as const) {
const pages = await payload.find({ collection: 'pages', locale, where: { slug: { equals: 'home' } } })
if (pages.docs.length > 0) {
console.log(`\nStrona ${locale.toUpperCase()} (Home):`)
pages.docs[0].layout?.forEach((b:any) => {
if (b.blockType === 'servicesList' && b.services) {
b.services.forEach((s:any) => console.log(` - ${s.title} -> ${s.linkUrl}`))
}
})
}
}
console.log('\n--- FORMULARZ KONTAKTOWY (PL vs DE) ---')
const forms = await payload.find({ collection: 'forms', locale: 'all', limit: 1 })
if (forms.docs.length > 0) {
const form = forms.docs[0] as any
console.log(`\nFormularz ID: ${form.id}`)
console.log(`Tytuł: PL="${form.title.pl}", DE="${form.title.de}"`)
console.log(`Wiadomość z podziękowaniem (PL): ${form.confirmationMessage.pl.root.children[0].children[0].text}`)
console.log(`Wiadomość z podziękowaniem (DE): ${form.confirmationMessage.de.root.children[0].children[0].text}`)
console.log(`Temat email (PL): ${form.emails[0].subject.pl}`)
console.log(`Temat email (DE): ${form.emails[0].subject.de}`)
console.log('\nPola formularza:')
form.fields?.forEach((f:any) => {
console.log(` - Pole ${f.blockType}: ${f.name} (Etykieta PL: "${f.label.pl}", DE: "${f.label.de}")`)
if (f.blockType === 'select' && f.options) {
f.options.forEach((o:any) => {
console.log(` * [${o.value}] PL: "${o.label.pl}", DE: "${o.label.de}"`)
})
}
})
}
process.exit(0)
}
run()