'use client'; import React, { useState } from 'react'; import { useRouter } from 'next/navigation'; import { ProfileSettingsTemplate } from '@/templates/ProfileSettingsTemplate'; import type { ProfileViewData } from '@/lib/view-data/ProfileViewData'; import type { Result } from '@/lib/contracts/Result'; import { ProgressLine } from '@/components/shared/ux/ProgressLine'; import { InlineNotice } from '@/components/shared/ux/InlineNotice'; import { Box } from '@/ui/Box'; interface ProfileSettingsPageClientProps { viewData: ProfileViewData; onSave: (updates: { bio?: string; country?: string }) => Promise>; } export function ProfileSettingsPageClient({ viewData, onSave }: ProfileSettingsPageClientProps) { const router = useRouter(); const [isSaving, setIsSaving] = useState(false); const [error, setError] = useState(null); const [bio, setBio] = useState(viewData.driver.bio || ''); const [country, setCountry] = useState(viewData.driver.countryCode); const handleSave = async () => { setIsSaving(true); setError(null); try { const result = await onSave({ bio, country }); if (result.isErr()) { setError(result.getError()); } else { router.refresh(); } } catch (err) { setError(err instanceof Error ? err.message : 'Failed to save settings'); } finally { setIsSaving(false); } }; return ( <> {error && ( )} ); }