"use client"; import React, { useState } from "react"; import { Divider, Input, message } from "antd"; import { FaCode, FaGithub } from "react-icons/fa6"; import { FcGoogle } from "react-icons/fc"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { createClientComponentClient } from "@supabase/auth-helpers-nextjs"; const Login = () => { const supabase = createClientComponentClient(); const router = useRouter(); const [messageApi, contextHolder] = message.useMessage(); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); var fieldsCheck = false; const handleLogin = async () => { if (email.trim() === "" || password === "") { console.log("Please fill in all fields"); messageApi.open({ type: "error", content: "Please fill in all fields", duration: 3, }); } else { fieldsCheck = true; } if (fieldsCheck) { try { const { data: { user }, } = await supabase.auth.signInWithPassword({ email: email, password: password, }); router.push(`/users/${user?.id}`); console.log("Sign up successful"); } catch (err) { console.log("Error:", err); } } }; const loginWithGoogle = async () => { const { data } = await supabase.auth.signInWithOAuth({ provider: "google", }); console.log(data.url); const { data: { user }, } = await supabase.auth.getUser(); router.push(`/users/${user?.id}`); }; const loginWithGithub = async () => { const { data } = await supabase.auth.signInWithOAuth({ provider: "github", }); console.log(data.url); const { data: { user }, } = await supabase.auth.getUser(); router.push(`/users/${user?.id}`); }; return ( <> {contextHolder}
CodingOH

Login

Login Using Google →
Login Using GitHub →
or
setEmail(e.target.value)} /> setPassword(e.target.value)} />
New user? Sign up here →
); }; export default Login;