Friendly Captcha ook voor de SLP-site: gedeelde widget in formulier B en het terminalformulier van E
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useMemo, useRef } from 'react';
|
||||
import { lazy, Suspense, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import type { ReactNode } from 'react';
|
||||
import {
|
||||
useContactForm,
|
||||
@@ -14,6 +14,8 @@ import { useContactPreselect } from '../../shared/contact/useContactPreselect';
|
||||
import { buildSubjectOptions, subjectForSlug } from '../../shared/contact/subjects';
|
||||
import { terminalText } from './eraContent';
|
||||
|
||||
const CaptchaWidget = lazy(() => import('../../shared/contact/CaptchaWidget'));
|
||||
|
||||
interface TerminalFormProps {
|
||||
client: ContactClient;
|
||||
token: ContactToken;
|
||||
@@ -72,6 +74,7 @@ export function TerminalForm({ client, token, refreshToken }: TerminalFormProps)
|
||||
onEvent: (event) => trackEvent(event === 'sent' ? 'contact-sent' : 'contact-failed'),
|
||||
});
|
||||
|
||||
const [captchaProblem, setCaptchaProblem] = useState(false);
|
||||
const successRef = useRef<HTMLDivElement>(null);
|
||||
useEffect(() => {
|
||||
if (form.status === 'sent') {
|
||||
@@ -156,6 +159,29 @@ export function TerminalForm({ client, token, refreshToken }: TerminalFormProps)
|
||||
<input type="text" id={hpId} {...hpProps} />
|
||||
</div>
|
||||
|
||||
{/* Robot check (Friendly Captcha) when the server asks for it; client only, own chunk. */}
|
||||
{form.captcha ? (
|
||||
<div style={{ minHeight: 76 }}>
|
||||
<Suspense fallback={null}>
|
||||
<CaptchaWidget
|
||||
captcha={form.captcha}
|
||||
resetCount={form.captchaResetCount}
|
||||
onToken={form.setCaptchaToken}
|
||||
onProblem={setCaptchaProblem}
|
||||
theme="dark"
|
||||
/>
|
||||
</Suspense>
|
||||
</div>
|
||||
) : null}
|
||||
{captchaProblem ? (
|
||||
<p role="alert" className="e-term-error m-0" data-testid="contact-captcha-problem">
|
||||
{contactForm.captchaProblem}{' '}
|
||||
<a href={`mailto:${contactInfo.email}`} className="underline">
|
||||
{contactInfo.email}
|
||||
</a>
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
{form.failureMessage ? (
|
||||
<p role="alert" className="e-term-error m-0" data-testid="contact-failure">
|
||||
{form.failureMessage}
|
||||
|
||||
Reference in New Issue
Block a user