fix: resolve contact form placeholders, restore process block layout, and fix testimonials carousel scroll logic

This commit is contained in:
MichalC
2026-09-17 22:25:25 +02:00
parent 7cc68b9f36
commit ab4c5c83dd
91 changed files with 4790 additions and 319 deletions
+117
View File
@@ -0,0 +1,117 @@
import { getPayload } from 'payload'
import configPromise from '../src/payload.config'
import fs from 'fs'
const ALLOWED_DUPLICATES = [
"b.b.h. Lohnsteuerhilfeverein e.V.",
"§4 Nr. 11 StBerG",
"Finanz- & Lohnbuchhaltung",
"Dipl.-Ing. Janusz Kędzierski",
"JK"
]
function isAllowedDuplicate(val: string): boolean {
if (!val || typeof val !== 'string') return true;
const trimmed = val.trim();
if (ALLOWED_DUPLICATES.includes(trimmed)) return true;
if (trimmed.startsWith('http') || trimmed.startsWith('/') || trimmed.startsWith('tel:') || trimmed.startsWith('mailto:')) return true;
// phone numbers, pure digits
if (/^[\d\s\+\-\(\)]+$/.test(trimmed)) return true;
// emails
if (trimmed.includes('@') && !trimmed.includes(' ')) return true;
return false;
}
function extractText(val: any): string {
if (typeof val === 'string') return val;
if (val && typeof val === 'object' && val.root && val.root.children) {
// Basic rich text extractor
let text = '';
const traverse = (node: any) => {
if (node.text) text += node.text;
if (node.children) node.children.forEach(traverse);
};
traverse(val.root);
return text.trim();
}
return JSON.stringify(val);
}
function compareObjects(objPL: any, objDE: any, path: string, results: string[]) {
if (!objPL || !objDE) return;
if (typeof objPL !== 'object' || typeof objDE !== 'object') return;
// If array
if (Array.isArray(objPL)) {
for (let i = 0; i < objPL.length; i++) {
compareObjects(objPL[i], objDE[i], `${path}[${i}]`, results);
}
return;
}
// Iterate keys
for (const key of Object.keys(objPL)) {
if ([
'id', 'createdAt', 'updatedAt', 'blockType', 'blockName',
'slug', 'value', 'name', 'icon', 'globalType', 'confirmationType',
'type', 'url', 'siteName', 'titleOrder', 'titleSeparator',
'defaultTheme', 'relationTo', 'status'
].includes(key)) continue;
const valPL = objPL[key];
const valDE = objDE[key];
if (typeof valPL === 'string' || (valPL && valPL.root)) {
const textPL = extractText(valPL);
const textDE = extractText(valDE);
if (textPL && textPL === textDE) {
if (!isAllowedDuplicate(textPL)) {
results.push(`[PODEJRZANY DUPLIKAT] ${path}.${key} | PL: "${textPL.substring(0, 50).replace(/\n/g, ' ')}" | DE: "${textDE.substring(0, 50).replace(/\n/g, ' ')}"`);
}
}
} else if (typeof valPL === 'object') {
compareObjects(valPL, valDE, `${path}.${key}`, results);
}
}
}
async function run() {
const payload = await getPayload({ config: configPromise })
const results: string[] = [];
console.log('Fetching pages...');
const pagesPL = await payload.find({ collection: 'pages', depth: 2, locale: 'pl', limit: 100 })
const pagesDE = await payload.find({ collection: 'pages', depth: 2, locale: 'de', limit: 100 })
for (const pagePL of pagesPL.docs) {
const pageDE = pagesDE.docs.find(p => p.id === pagePL.id)
if (pageDE) {
compareObjects(pagePL, pageDE, `Page(${pagePL.slug})`, results);
}
}
const globals = ['header', 'footer', 'company', 'site-settings']
for (const slug of globals) {
console.log(`Fetching global ${slug}...`);
const globalPL = await payload.findGlobal({ slug: slug as any, depth: 2, locale: 'pl' })
const globalDE = await payload.findGlobal({ slug: slug as any, depth: 2, locale: 'de' })
compareObjects(globalPL, globalDE, `Global(${slug})`, results);
}
console.log('Fetching forms...');
const formsPL = await payload.find({ collection: 'forms', depth: 2, locale: 'pl', limit: 100 })
const formsDE = await payload.find({ collection: 'forms', depth: 2, locale: 'de', limit: 100 })
for (const formPL of formsPL.docs) {
const formDE = formsDE.docs.find(f => f.id === formPL.id)
if (formDE) {
compareObjects(formPL, formDE, `Form(${formPL.title})`, results);
}
}
fs.writeFileSync('audit_results.txt', results.join('\n'));
console.log(`Audit complete. Found ${results.length} suspicious fields.`);
process.exit(0)
}
run()