/** * Gating Form Field Component * * Individual form field with label, input, and error display. */ import React from 'react'; import type { GatingInfoField, GatingConfig } from '../types/gating'; import { t } from '../i18n/config'; export interface GatingFormFieldProps { /** Field name (name, email, phone, company) */ field: GatingInfoField; /** Field value */ value: string; /** Called when field value changes */ onChange: (value: string) => void; /** Error message (translated) */ error?: string; /** Is field required */ required: boolean; /** Gating configuration (for custom translations) */ config: GatingConfig; } /** * Individual form field component */ export function GatingFormField(props: GatingFormFieldProps): React.ReactElement { const { field, value, onChange, error, required, config } = props; // Get field-specific attributes const inputType = field === 'email' ? 'email' : field === 'phone' ? 'tel' : 'text'; const inputMode = field === 'email' ? 'email' : field === 'phone' ? 'tel' : 'text'; // Get translated label and placeholder const label = config.translations?.labels?.[field] || t(`labels.${field}`); const placeholder = config.translations?.placeholders?.[field] || t(`placeholders.${field}`); return (
{error}
)}