Skip to content

Commit

Permalink
Removed Signup customr form
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas957 committed Jun 23, 2024
1 parent 9133bed commit 953419d
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions frontend/react/src/components/login/Login.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/**
* 'use client' is a directive that tells the browser to run the script in a so-called "modern" way.
*/
'use client'

// Importing necessary components and hooks from various libraries
import {
Button,
Flex,
Expand All @@ -17,10 +21,12 @@ import {useAuth} from "../context/AuthContext.jsx";
import {errorNotification} from "../../services/notification.js";
import {useNavigate} from "react-router-dom";

/**
* MyTextInput is a custom input component that includes form validation.
* @param {object} props - The properties passed to the component.
* @returns {JSX.Element} - A Box component containing the FormLabel, Input and Alert components.
*/
const MyTextInput = ({label, ...props}) => {
// useField() returns [formik.getFieldProps(), formik.getFieldMeta()]
// which we can spread on <input>. We can use field meta to show an error
// message if the field is invalid, and it has been touched (i.e. visited)
const [field, meta] = useField(props);
return (
<Box>
Expand All @@ -36,6 +42,10 @@ const MyTextInput = ({label, ...props}) => {
);
};

/**
* LoginForm is a component that handles the login form submission.
* @returns {JSX.Element} - A Formik component containing the form and its validation logic.
*/
const LoginForm = () => {
const {login} = useAuth();
const navigate = useNavigate();
Expand All @@ -53,14 +63,13 @@ const LoginForm = () => {
onSubmit={(values, {setSubmitting}) => {
setSubmitting(true);
login(values).then(res => {
// TODO: Redirect to dashboard
navigate('/dashboard')
console.log("Successfully logged in");
}).catch(err => {
console.log(err);
errorNotification(err.code, err.response.data.message)
}).finally(() => {
setSubmitting(false); // I can submit form again
setSubmitting(false);
})
}}>

Expand Down Expand Up @@ -91,6 +100,10 @@ const LoginForm = () => {
)
}

/**
* Login is the main component that renders the login page.
* @returns {JSX.Element} - A Stack component containing the LoginForm and other UI elements.
*/
const Login = () => {
const {customer} = useAuth();
const navigate = useNavigate();
Expand All @@ -117,9 +130,6 @@ const Login = () => {
alignItems={"center"}
justifyContent={"center"}
bgGradient={{sm: 'linear(to-r, blue.600, purple.600)'}}>
{/*<Text fontSize={'6xl'} color={'white'} fontWeight={'bold'} mb={5}>*/}
{/* <Link href={'www.linkedin.com/in/shreyas-shevale'}> My linkedin profile</Link>*/}
{/*</Text>*/}
<Image
alt={'Login Image'}
objectFit={'cover'}
Expand All @@ -132,4 +142,5 @@ const Login = () => {
)
}

// Exporting the Login component to be used in other parts of the application
export default Login;

0 comments on commit 953419d

Please sign in to comment.