48 lines
1.7 KiB
TypeScript
48 lines
1.7 KiB
TypeScript
import { getPayload } from 'payload'
|
|
import configPromise from '../src/payload.config'
|
|
|
|
async function run() {
|
|
const payload = await getPayload({ config: configPromise })
|
|
|
|
for (const locale of ['pl', 'de']) {
|
|
const pages = await payload.find({
|
|
collection: 'pages',
|
|
locale: locale as 'pl' | 'de',
|
|
where: { slug: { equals: 'kontakt' } }
|
|
})
|
|
|
|
if (pages.docs.length > 0) {
|
|
const page = pages.docs[0];
|
|
const formBlock = page.layout?.find(b => b.blockType === 'contactSection');
|
|
if (formBlock && formBlock.form) {
|
|
// Fetch the form
|
|
const formId = typeof formBlock.form === 'object' ? formBlock.form.id : formBlock.form;
|
|
console.log(`\n=== FORMULARZ PODPIĘTY POD /${locale}/kontakt (ID: ${formId}) ===`);
|
|
|
|
const form = await payload.findByID({
|
|
collection: 'forms',
|
|
id: formId as number,
|
|
locale: locale as 'pl' | 'de',
|
|
});
|
|
|
|
const serviceField = form.fields?.find(f => f.name === 'service' && f.blockType === 'select');
|
|
console.log(`POLE SERVICE OPTIONS (LOCALE: ${locale}):`);
|
|
console.log(JSON.stringify(serviceField?.options, null, 2));
|
|
|
|
// Let's also check placeholders and other texts for step 5
|
|
console.log(`\nPOZOSTAŁE POLA (LOCALE: ${locale}):`);
|
|
form.fields?.forEach(f => {
|
|
if (f.blockType !== 'select') {
|
|
const placeholderValue = f.defaultValue || (f.name === 'email' ? (f.label === 'Adres e-mail' ? '[email protected]' : '[email protected]') : '');
|
|
console.log(`- ${f.name} (${f.blockType}): label="${f.label}", placeholder="${placeholderValue}"`);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
process.exit(0);
|
|
}
|
|
|
|
run().catch(console.error);
|