fix(forms): fix message render, confirmation text, radio disabled, placeholder, replyTo
- Replace dangerouslySetInnerHTML with extractLexicalText helper for message blocks
- Show CMS confirmationMessage text on success instead of hardcoded string
- Disable radio field in plugin config (not rendered in FormBlock)
- Remove placeholder from text/number/textarea/date seed fields (plugin ignores them)
- Replace {{email}} replyTo template with static manager email fallback
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3ea4d95cc7
commit
85d2f7d16e
3 changed files with 21 additions and 17 deletions
|
|
@ -147,7 +147,7 @@ export default buildConfig({
|
|||
text: true,
|
||||
textarea: true,
|
||||
select: true,
|
||||
radio: true,
|
||||
radio: false,
|
||||
email: true,
|
||||
number: true,
|
||||
message: true,
|
||||
|
|
|
|||
|
|
@ -695,7 +695,7 @@ export async function POST(req: NextRequest) {
|
|||
emailTo: managerEmail,
|
||||
subject,
|
||||
emailFrom: 'noreply@shumiland.com.ua',
|
||||
replyTo: '{{email}}',
|
||||
replyTo: process.env['MANAGER_EMAILS']?.split(',')[0]?.trim() ?? '',
|
||||
message: {
|
||||
root: {
|
||||
type: 'root',
|
||||
|
|
@ -767,7 +767,6 @@ export async function POST(req: NextRequest) {
|
|||
name: 'name',
|
||||
label: "Ваше ім'я",
|
||||
required: true,
|
||||
placeholder: 'Іван Іванов',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
|
|
@ -775,14 +774,12 @@ export async function POST(req: NextRequest) {
|
|||
name: 'phone',
|
||||
label: 'Телефон',
|
||||
required: true,
|
||||
placeholder: '+38 (0__) ___-__-__',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
blockType: 'email',
|
||||
name: 'email',
|
||||
label: 'Email',
|
||||
placeholder: 'your@email.com',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
|
|
@ -790,7 +787,6 @@ export async function POST(req: NextRequest) {
|
|||
name: 'groupSize',
|
||||
label: 'Кількість учасників',
|
||||
required: true,
|
||||
placeholder: '30',
|
||||
width: 50,
|
||||
},
|
||||
{ blockType: 'date', name: 'preferredDate', label: 'Бажана дата', width: 50 },
|
||||
|
|
@ -810,7 +806,6 @@ export async function POST(req: NextRequest) {
|
|||
blockType: 'textarea',
|
||||
name: 'message',
|
||||
label: 'Повідомлення',
|
||||
placeholder: 'Додаткові побажання або запитання...',
|
||||
width: 100,
|
||||
},
|
||||
],
|
||||
|
|
@ -835,7 +830,6 @@ export async function POST(req: NextRequest) {
|
|||
name: 'name',
|
||||
label: "Ваше ім'я",
|
||||
required: true,
|
||||
placeholder: 'Іван Іванов',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
|
|
@ -843,21 +837,18 @@ export async function POST(req: NextRequest) {
|
|||
name: 'phone',
|
||||
label: 'Телефон',
|
||||
required: true,
|
||||
placeholder: '+38 (0__) ___-__-__',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
blockType: 'email',
|
||||
name: 'email',
|
||||
label: 'Email',
|
||||
placeholder: 'your@email.com',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
blockType: 'number',
|
||||
name: 'childAge',
|
||||
label: 'Вік іменинника',
|
||||
placeholder: '7',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
|
|
@ -875,7 +866,6 @@ export async function POST(req: NextRequest) {
|
|||
blockType: 'number',
|
||||
name: 'guestCount',
|
||||
label: 'Кількість гостей',
|
||||
placeholder: '15',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
|
|
@ -889,7 +879,6 @@ export async function POST(req: NextRequest) {
|
|||
blockType: 'textarea',
|
||||
name: 'wishes',
|
||||
label: 'Побажання',
|
||||
placeholder: 'Тема свята, улюблені герої, особливі побажання...',
|
||||
width: 100,
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -4,6 +4,17 @@ import { useState, useTransition } from 'react'
|
|||
|
||||
const FONT = 'var(--font-montserrat, Montserrat), sans-serif'
|
||||
|
||||
function extractLexicalText(node: unknown): string {
|
||||
if (!node || typeof node !== 'object') return ''
|
||||
const n = node as Record<string, unknown>
|
||||
if (n['text'] && typeof n['text'] === 'string') return n['text']
|
||||
if (Array.isArray(n['children'])) {
|
||||
return (n['children'] as unknown[]).map(extractLexicalText).join(' ')
|
||||
}
|
||||
if (n['root']) return extractLexicalText(n['root'])
|
||||
return ''
|
||||
}
|
||||
|
||||
const INPUT_CLS =
|
||||
'w-full rounded-[12px] border-2 border-white/20 bg-white/10 px-4 py-3 text-[15px] text-white placeholder-white/40 focus:border-[#f28b4a] focus:outline-none'
|
||||
|
||||
|
|
@ -21,7 +32,7 @@ interface FormField {
|
|||
placeholder?: string
|
||||
defaultValue?: string
|
||||
options?: FieldOption[]
|
||||
message?: string
|
||||
message?: unknown
|
||||
width?: number
|
||||
}
|
||||
|
||||
|
|
@ -77,6 +88,9 @@ export function FormBlock({ form, submitLabel }: FormBlockProps) {
|
|||
}
|
||||
|
||||
if (success) {
|
||||
const confirmText = form.confirmationMessage
|
||||
? extractLexicalText(form.confirmationMessage)
|
||||
: "Менеджер зв'яжеться з вами найближчим часом."
|
||||
return (
|
||||
<div className="flex flex-col items-center gap-4 py-10 text-center">
|
||||
<div className="text-[48px]">✅</div>
|
||||
|
|
@ -84,7 +98,7 @@ export function FormBlock({ form, submitLabel }: FormBlockProps) {
|
|||
Заявку отримано!
|
||||
</h3>
|
||||
<p className="text-[16px] text-white/70" style={{ fontFamily: FONT }}>
|
||||
Менеджер зв'яжеться з вами найближчим часом.
|
||||
{confirmText}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
|
|
@ -102,8 +116,9 @@ export function FormBlock({ form, submitLabel }: FormBlockProps) {
|
|||
key={field.id ?? field.name}
|
||||
className="text-[14px] text-white/60 md:col-span-2"
|
||||
style={{ fontFamily: FONT }}
|
||||
dangerouslySetInnerHTML={{ __html: field.message ?? '' }}
|
||||
/>
|
||||
>
|
||||
{extractLexicalText(field.message)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue