'use client' import { useState, useEffect } from 'react' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { updateProfile, changePassword } from '@/app/actions/profile' import { toast } from 'sonner' import { useLanguage } from '@/lib/i18n' import { User, Lock } from 'lucide-react' export function ProfileForm({ user, userAISettings }: { user: any; userAISettings?: any }) { const { t } = useLanguage() return (

{t('profile.description')}

{/* Profile info card */}

{t('profile.title')}

{t('profile.description')}

{ const result = await updateProfile({ name: formData.get('name') as string }) if (result?.error) toast.error(t('profile.updateFailed')) else toast.success(t('profile.updateSuccess')) }} className="space-y-4">
{/* Password card */}

{t('profile.changePassword')}

{t('profile.changePasswordDescription')}

{ const result = await changePassword(formData) if (result?.error) { const msg = '_form' in result.error ? result.error._form[0] : result.error.currentPassword?.[0] || result.error.newPassword?.[0] || result.error.confirmPassword?.[0] || t('profile.passwordChangeFailed') toast.error(msg) } else { toast.success(t('profile.passwordChangeSuccess')) const form = document.querySelector('form#password-form') as HTMLFormElement form?.reset() } }} id="password-form" className="space-y-4">
) }