Fix FAQFull: Use isDraft boolean for draft filtering, fix Kontakt ID override
This commit is contained in:
@@ -6,15 +6,13 @@ import type { Page } from '../../payload-types'
|
||||
|
||||
type Props = Extract<NonNullable<Page['layout']>[0], { blockType: 'faqFull' }>
|
||||
|
||||
const PLACEHOLDER_PL = "Odpowiedź w przygotowaniu"
|
||||
const PLACEHOLDER_DE = "Antwort in Vorbereitung"
|
||||
|
||||
function isPlaceholder(answer: string | null | undefined): boolean {
|
||||
if (!answer) return true;
|
||||
return answer.includes(PLACEHOLDER_PL) || answer.includes(PLACEHOLDER_DE) || answer.includes('DO POTWIERDZENIA');
|
||||
}
|
||||
|
||||
export const FAQFullBlockComponent: React.FC<Props> = ({ title, subtitle, questions, ctaText, ctaUrl }) => {
|
||||
export const FAQFullBlockComponent: React.FC<Props> = ({
|
||||
title,
|
||||
subtitle,
|
||||
questions,
|
||||
ctaText,
|
||||
ctaUrl,
|
||||
}) => {
|
||||
const { scrollYProgress } = useScroll();
|
||||
const scaleX = useSpring(scrollYProgress, {
|
||||
stiffness: 100,
|
||||
@@ -33,7 +31,7 @@ export const FAQFullBlockComponent: React.FC<Props> = ({ title, subtitle, questi
|
||||
}
|
||||
|
||||
// Filter out placeholder questions
|
||||
const validQuestions = (questions || []).filter(q => !isPlaceholder(q.answer));
|
||||
const validQuestions = (questions || []).filter((q: any) => !q.isDraft);
|
||||
|
||||
// Group by category
|
||||
const groupedQuestions = validQuestions.reduce((acc, q) => {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { Block } from 'payload'
|
||||
|
||||
export const FAQFull: Block = {
|
||||
slug: 'faqFull',
|
||||
fields: [
|
||||
{ name: 'title', type: 'text', required: true, localized: true },
|
||||
{
|
||||
name: 'subtitle',
|
||||
type: 'text',
|
||||
required: false,
|
||||
localized: true,
|
||||
},
|
||||
{
|
||||
name: 'questions',
|
||||
type: 'array',
|
||||
minRows: 1,
|
||||
localized: true,
|
||||
fields: [
|
||||
{ name: 'category', type: 'text', required: true },
|
||||
{
|
||||
name: 'isDraft',
|
||||
type: 'checkbox',
|
||||
defaultValue: false,
|
||||
admin: {
|
||||
description: 'Zaznacz, jeśli treść nie jest jeszcze gotowa do publikacji (pytanie nie pojawi się na stronie ani w SEO)',
|
||||
},
|
||||
},
|
||||
{ name: 'question', type: 'text', required: true },
|
||||
{ name: 'answer', type: 'textarea', required: true },
|
||||
],
|
||||
},
|
||||
{ name: 'ctaText', type: 'text', required: false, localized: true },
|
||||
{ name: 'ctaUrl', type: 'text', required: false },
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user