'use client' import React, { useState } from 'react'; import {app, auth} from '@/app/firebase/config'; import { createUserWithEmailAndPassword, getAuth } from 'firebase/auth'; import { getApp } from 'firebase/app'; import { SOLOGIN_API } from '../shared'; import { useRouter } from 'next/navigation'; import { RegisterSologin } from '../sologin'; const SignUp = () => { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(null); const router = useRouter(); const onLoginSuccess = ()=>{ router.push('/'); } const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); try{ createUserWithEmailAndPassword(auth, email, password) .then(async(userCredential) => { // Signed up const user = userCredential.user; await RegisterSologin(userCredential.user); console.log(user); onLoginSuccess(); }) .catch((error) => { const errorCode = error.code; switch(errorCode){ case 'auth/email-already-in-use': setError("This email address is already signed up. Forgot password?") break; default: setError("Something went wrong"); break; } }); setEmail(''); setPassword(''); }catch(e){ console.error(e); } }; return (

Sign Up

setEmail(e.target.value)} required />
setPassword(e.target.value)} required />

Already have an account?{' '} Log In

{error && (

Error

{error}

)}
); }; export default SignUp;