import { Input, Button } from '@nextui-org/react';
import router from 'next/router';
import { SetStateAction, useEffect, useState } from 'react';
const SignIn = () => {
const [errorMessage, setErrorMessage] = useState('');
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const handleEmailChange = (e: { target: { value: SetStateAction<string>; }; }) => {
setEmail(e.target.value);
};
const handlePasswordChange = (e: { target: { value: SetStateAction<string>; }; }) => {
setPassword(e.target.value);
};
const handleSignIn = async (e: { preventDefault: () => void; }) => {
e.preventDefault();
try {
const response = await fetch('/api/signin', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ email, password }),
});
console.log('response:',response)
if (response.ok) {
// Redirect to the dashboard or any other page on successful login
console.log('response2:',response)
router.push('/meet');
} else {
// Handle authentication error (display error message, etc.)
setErrorMessage('Login failed.');
console.error('Authentication failed');
}
} catch (error) {
// Handle fetch error
console.error('Error occurred while signing in:', error);
}
};
I am unable to redirect to a page named "meet" which is in the same directory. It seems like router.push is not working as expected.
Could it be that router.push is no longer supported or is there an issue with my code? What mistake am I making here? The API call functions correctly.