summaryrefslogtreecommitdiff
path: root/src/components/header
diff options
context:
space:
mode:
authorl3wdfut4pwr <l3wdfut4pwr@gmail.com>2026-04-29 02:07:46 +0300
committerl3wdfut4pwr <l3wdfut4pwr@gmail.com>2026-04-29 02:07:46 +0300
commite619245f1fa83a29a9ec553ef9017871bb5c27c0 (patch)
treed945801c8dd8e2b3d3fd36f962c31f29ead4b690 /src/components/header
parent42a5d2de33564c060d2d6f3cefdd3cf21c26a996 (diff)
add google auth
Diffstat (limited to 'src/components/header')
-rw-r--r--src/components/header/authdialog/LoginForm.tsx12
-rw-r--r--src/components/header/authdialog/RegisterForm.tsx12
2 files changed, 21 insertions, 3 deletions
diff --git a/src/components/header/authdialog/LoginForm.tsx b/src/components/header/authdialog/LoginForm.tsx
index b4d90f1..3a42979 100644
--- a/src/components/header/authdialog/LoginForm.tsx
+++ b/src/components/header/authdialog/LoginForm.tsx
@@ -6,6 +6,10 @@ import { InputField } from '@/components/ui/inputfield';
import { useAuthContext } from '@/lib/contexts/Auth.context';
import { useRouter } from 'next/navigation';
export default function LoginForm({ redirectTo }: { redirectTo?: string }) {
+ const handleGoogleLogin = () => {
+ window.location.href = `${API_URL}/api/auth/google/login`;
+ };
+
const API_URL = process.env.NEXT_PUBLIC_API_URL;
const [errors, setErrors] = useState<any>({});
const [loading, setLoading] = useState(false);
@@ -70,9 +74,13 @@ export default function LoginForm({ redirectTo }: { redirectTo?: string }) {
onSubmit={handleSubmit}
className="flex flex-col gap-5 min-w-[310px] w-fit"
>
- <Button className="w-full bg-white hover:bg-white hover:text-black">
+ <Button
+ type="button"
+ onClick={handleGoogleLogin}
+ className="w-full bg-white hover:bg-white hover:text-black"
+ >
<GoogleIcon />
- <span className="text-black text-sm">Войти через Google</span>
+ <span className="text-black">Войти через Google</span>
</Button>
<div className="flex flex-col gap-2.5">
diff --git a/src/components/header/authdialog/RegisterForm.tsx b/src/components/header/authdialog/RegisterForm.tsx
index ef22433..604b26c 100644
--- a/src/components/header/authdialog/RegisterForm.tsx
+++ b/src/components/header/authdialog/RegisterForm.tsx
@@ -8,6 +8,12 @@ import { useAuthContext } from '@/lib/contexts/Auth.context';
import Image from 'next/image';
import { useRouter } from 'next/navigation';
export default function RegisterForm({ redirectTo }: { redirectTo?: string }) {
+ const API_URL = process.env.NEXT_PUBLIC_API_URL;
+
+ const handleGoogleLogin = () => {
+ window.location.href = `${API_URL}/api/auth/google/login`;
+ };
+
const [errors, setErrors] = useState<any>({});
const [loading, setLoading] = useState(false);
const router = useRouter();
@@ -53,7 +59,11 @@ export default function RegisterForm({ redirectTo }: { redirectTo?: string }) {
onSubmit={handleSubmit}
className="flex flex-col gap-5 min-w-[310px] w-fit"
>
- <Button className="w-full bg-white hover:bg-white hover:text-black">
+ <Button
+ type="button"
+ onClick={handleGoogleLogin}
+ className="w-full bg-white hover:bg-white hover:text-black"
+ >
<GoogleIcon />
<span className="text-black">Войти через Google</span>
</Button>