/** * Checkout Field Editor - Settings Tab * * Global settings for the checkout field editor */ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Label } from "@/components/ui/label" import { Switch } from "@/components/ui/switch" import { Input } from "@/components/ui/input" import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group" import { Button } from "@/components/ui/button" import { Separator } from "@/components/ui/separator" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select" import { Eye, FileCode, Upload, MapPin, Download, Upload as UploadIcon, Shield, } from "lucide-react" import { FieldEditorSettings } from "../../config" import { usePro } from "@/contexts/pro-context" interface SettingsTabProps { settings: FieldEditorSettings updateSettings: (key: K, value: FieldEditorSettings[K]) => void exportSettings: () => string importSettings: (json: string) => boolean } export function SettingsTab({ settings, updateSettings, exportSettings, importSettings }: SettingsTabProps) { const { isPro } = usePro() const handleExport = () => { const json = exportSettings() const blob = new Blob([json], { type: 'application/json' }) const url = URL.createObjectURL(blob) const a = document.createElement('a') a.href = url a.download = 'checkout-fields-export.json' a.click() URL.revokeObjectURL(url) } const handleImport = () => { const input = document.createElement('input') input.type = 'file' input.accept = '.json' input.onchange = (e) => { const file = (e.target as HTMLInputElement).files?.[0] if (file) { const reader = new FileReader() reader.onload = (e) => { const content = e.target?.result as string importSettings(content) } reader.readAsText(file) } } input.click() } return (
{/* Left Column */}
{/* Display Settings */} Display Settings Control how fields are displayed on the checkout page.

Display labels above form fields.

updateSettings('showFieldLabels', v)} />

Display placeholder text inside fields.

updateSettings('showPlaceholders', v)} />

Display help text below fields.

updateSettings('showDescriptions', v)} />
updateSettings('requiredIndicator', e.target.value)} placeholder="*" />
{/* Validation Settings */} Validation Settings Configure how field validation behaves.

Validate fields when user leaves them.

updateSettings('validateOnBlur', v)} />

Validate all fields when form is submitted.

updateSettings('validateOnSubmit', v)} />

Display error messages next to fields.

updateSettings('showErrorsInline', v)} />

Automatically scroll to the first error on validation.

updateSettings('scrollToError', v)} />

Add visual highlight to fields with errors.

updateSettings('highlightErrorFields', v)} />
updateSettings('errorPosition', v as 'above' | 'below')} className="flex gap-4" >
{/* Address Override Settings */} Address Override Settings Configure how address fields interact with user profiles.

Allow checkout fields to override saved address data.

updateSettings('overrideAddressFields', v)} />

Users can override their saved billing address.

updateSettings('allowBillingOverride', v)} />

Users can override their saved shipping address.

updateSettings('allowShippingOverride', v)} />

Keep billing and shipping address in sync.

updateSettings('syncBillingShipping', v)} />
{/* Right Column */}
{/* File Upload Settings - Pro Only */} {isPro && ( File Upload Settings Configure file upload behavior for file fields.
updateSettings('fileUploadPath', e.target.value)} placeholder="checkout-uploads" />

Files will be stored in wp-content/uploads/{settings.fileUploadPath || 'checkout-uploads'}

updateSettings('maxTotalUploadSize', parseInt(e.target.value) || 10)} min={1} max={100} />

Maximum total size of all file uploads per checkout.

)} {/* Import/Export */} Import & Export Backup your checkout field configuration.
) }