Skip to content

Commit

Permalink
gg
Browse files Browse the repository at this point in the history
  • Loading branch information
upayanmazumder committed Nov 29, 2024
1 parent 7b3274d commit aeea15e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/src/components/auth/signup/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import React, { useState } from 'react';
import { createUserWithEmailAndPassword } from 'firebase/auth';
import { auth } from '../../../../shared/firebase';
import styles from '../auth.module.css';
import { useRouter } from 'next/navigation'; // Import the router to handle the redirection

const Signup = () => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [error, setError] = useState('');
const [success, setSuccess] = useState(false);
const router = useRouter(); // Use router for redirection

const handleSignup = async (e) => {
e.preventDefault();
Expand Down Expand Up @@ -43,6 +45,9 @@ const Signup = () => {

setSuccess(true);
console.log('User created successfully:', userCredential.user);

// Only redirect after the user is signed up successfully
router.push('/dashboard'); // Redirect to dashboard after signup
} catch (err) {
console.error('Error signing up:', err);
setError(err.message || 'Something went wrong');
Expand Down

0 comments on commit aeea15e

Please sign in to comment.