import { InputField } from '@/components/ui/inputfield'; import { Button } from '@/components/ui'; import { Separator } from '@/components/ui'; import { useAuthContext } from '@/lib/contexts/Auth.context'; import LogoutButton from './LogoutButton'; import { changeEmail } from '@/lib/api/ChangeEmail'; import { useState } from 'react'; import { ChangePasswordField } from './ChangePassword'; import { SetPasswordField } from './SetPasswordField'; export default function SecurityPage() { const { user } = useAuthContext(); if (!user) return; const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); if (!user) return null; const hasGoogle = !!user.google_id; const hasPassword = user.has_password; const showSetPassword = hasGoogle && !hasPassword; const handleChangeEmail = async () => { if (!email || !password) return; setLoading(true); const res = await changeEmail(email, password); setLoading(false); if (res.error) { console.error(res.error.general); return; } setEmail(''); setPassword(''); }; return ( <>
СМЕНА ПОЧТЫ