import { useForm } from 'react-hook-form'; import { zodResolver } from '@hookform/resolvers/zod'; import { FileText, Check, AlertCircle, Loader2 } from 'lucide-react'; import { useConfig, useMessages } from '../hooks'; import { configFormSchema, defaultConfigValues, type ConfigFormData } from '../schemas/config'; import { Card, CardHeader, CardTitle, CardContent, Button, Form, FormField, FormItem, FormLabel, FormControl, FormDescription, FormMessage, Input, } from './ui'; export const ConfigurationForm = () => { const { config, isConfigured, showConfigSetup, isLoading, isCreating, error, createConfig, refetch } = useConfig(); const form = useForm({ resolver: zodResolver(configFormSchema), defaultValues: defaultConfigValues, }); const onSubmit = (data: ConfigFormData) => { createConfig(data); }; return ( Configuration (With Form Validation) {error && (

Configuration Error

{error.message}

)} {showConfigSetup && (

Initial Configuration Setup

Configure your wild-cloud central server settings with real-time validation.

{/* Server Configuration */}

Server Configuration

( Server Host The host address the server will bind to )} /> ( Server Port field.onChange(parseInt(e.target.value) || 0)} /> The port the server will listen on )} />
{/* Cloud Configuration */}

Cloud Configuration

( Domain The main domain for your wild-cloud )} /> ( Internal Domain The internal cluster domain )} /> ( DNS Server IP The IP address of the DNS server )} /> ( Router IP The IP address of the network router )} /> ( DHCP Range DHCP IP range in format: start_ip,end_ip )} /> ( Network Interface The network interface for dnsmasq to use )} />
{/* Cluster Configuration */}

Cluster Configuration

( Cluster Endpoint IP The IP address of the cluster endpoint )} /> ( Talos Version The version of Talos Linux to use )} />
)} {config && isConfigured && (

✓ Configuration loaded successfully

              {JSON.stringify(config, null, 2)}
            
)}
Form Validation Status: {form.formState.isValid ? '✓ Valid' : '⚠ Has Errors'} | Errors: {Object.keys(form.formState.errors).length}
); };