'use client'; import { useState } from 'react'; import { OrganizationConfig, SecurityConfig } from '@/lib/types/settings'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Switch } from '@/components/ui/switch'; import { updateSystemSetting } from '@/lib/actions/settings'; import { toast } from 'sonner'; import { Building2, ShieldCheck, Mail, Globe } from 'lucide-react'; interface OrganizationSettingsProps { orgConfig: OrganizationConfig; securityConfig: SecurityConfig; onUpdate: (section: 'organization' | 'security', data: any) => void; } export function OrganizationSettings({ orgConfig, securityConfig, onUpdate }: OrganizationSettingsProps) { const [loading, setLoading] = useState(false); // Internal state for form usage const [orgState, setOrgState] = useState(orgConfig); const [secState, setSecState] = useState(securityConfig); const handleSaveOrg = async () => { setLoading(true); try { const res = await updateSystemSetting('organization', orgState); if (res.success) { toast.success('Organization profile updated'); onUpdate('organization', res.updatedSettings.organization); } } catch (error) { toast.error('Failed to update organization settings'); } finally { setLoading(false); } }; const handleSaveSecurity = async () => { setLoading(true); try { const res = await updateSystemSetting('security', secState); if (res.success) { toast.success('Security policy updated'); onUpdate('security', res.updatedSettings.security); } } catch (error) { toast.error('Failed to update security settings'); } finally { setLoading(false); } }; return (
Require Two-Factor Authentication for all admin accounts.