From 42a5d2de33564c060d2d6f3cefdd3cf21c26a996 Mon Sep 17 00:00:00 2001 From: l3wdfut4pwr Date: Mon, 27 Apr 2026 22:43:13 +0300 Subject: add password change --- src/components/settings/SecurityPage.tsx | 78 +++++++++++++++++--------------- 1 file changed, 42 insertions(+), 36 deletions(-) (limited to 'src/components/settings/SecurityPage.tsx') diff --git a/src/components/settings/SecurityPage.tsx b/src/components/settings/SecurityPage.tsx index b5f38a9..dd650c4 100644 --- a/src/components/settings/SecurityPage.tsx +++ b/src/components/settings/SecurityPage.tsx @@ -3,14 +3,41 @@ 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'; 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.password; + 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 ( <>
@@ -38,55 +65,34 @@ export default function SecurityPage() {
)} -
+

СМЕНА ПОЧТЫ

-
+ +
setEmail(e.target.value)} /> + setPassword(e.target.value)} />
- + +
- {hasPassword && ( -
-

- СМЕНА ПАРОЛЯ -

-
- - - -
- - -
- )} + {hasPassword && }
-- cgit v1.3-3-g829e