Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Login #5

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33,770 changes: 33,770 additions & 0 deletions client/package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@coreui/react": "^4.4.0",
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"@mui/icons-material": "^5.10.9",
Expand All @@ -21,6 +22,7 @@
"redux-saga": "^1.2.1",
"redux-thunk": "^2.4.1",
"styled-components": "^5.3.6",
"bootstrap": "^5.2.2",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
5 changes: 5 additions & 0 deletions client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<!-- JavaScript Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Expand All @@ -43,5 +47,6 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->

</body>
</html>
4 changes: 2 additions & 2 deletions client/src/components/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const NavBar = () => {

const handleClose = () => {
setAnchor(null);
}
};

return (
<AppBar position="sticky">
Expand Down Expand Up @@ -43,6 +43,6 @@ const NavBar = () => {
</Toolbar>
</AppBar>
);
}
};

export default NavBar;
328 changes: 235 additions & 93 deletions client/src/components/users/Login.jsx
Original file line number Diff line number Diff line change
@@ -1,107 +1,249 @@
import React, {useEffect, useState} from "react";
import {
Box,
Button,
Container,
CssBaseline,
TextField,
Typography,
} from "@mui/material";
import {useDispatch, useSelector} from 'react-redux';
import {loginAction} from "../../store/actions/users";
import { useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { loginAction } from "../../store/actions/users";
import { useNavigate } from "react-router-dom";
import * as React from "react";
import img1 from "./images/1.jpg";
import img2 from "./images/2.jpg";
import img3 from "./images/3.jpg";
import TextField from "@mui/material/TextField";
import { Card, CardContent, Typography } from "@mui/material";
import { CCarousel, CCarouselItem, CImage } from "@coreui/react";
import Box from "@mui/material/Box";
import IconButton from "@mui/material/IconButton";
import OutlinedInput from "@mui/material/OutlinedInput";
import InputLabel from "@mui/material/InputLabel";
import InputAdornment from "@mui/material/InputAdornment";
import FormControl from "@mui/material/FormControl";
import Visibility from "@mui/icons-material/Visibility";
import VisibilityOff from "@mui/icons-material/VisibilityOff";
import Button from "@mui/material/Button";

const Login = () => {
const [userid, setUserID] = useState('');
const [password, setPassword] = useState('');
const [errors, setErrors] = useState({userName: '', password: ''});
const dispatcher = useDispatch();
const navigate = useNavigate();
const [state, setState] = React.useState("");
const [err, seterr] = React.useState(false);

const loggedIn = useSelector(state => state.users.loggedIn);
const e = useSelector(state => state.users.errors);
const [state1, setState1] = React.useState("");
const [err1, seterr1] = React.useState(false);

useEffect(() => {
if (loggedIn) {
navigate('/');
}
}, [loggedIn, navigate]);
const textout = (e) => {
setState(e.target.value);
setUserID(e.target.value);
};
const textout1 = (e) => {
setState1(e.target.value);
setPassword(e.target.value);
};
const handleChange = (prop) => (event) => {
setValues({ ...values, [prop]: event.target.value });
};

useEffect(() => {
setErrors(err => ({
...err,
userName: e.userName ? e.userName : '',
password: e.password ? e.password : '',
}));
}, [e]);
const handleClickShowPassword = () => {
setValues({
...values,
showPassword: !values.showPassword,
});
};

const login = async () => {
dispatcher(loginAction(userid, password));
}
const handleMouseDownPassword = (event) => {
event.preventDefault();
};

return (
<Box
sx={{
flexGrow: '1',
display: "flex",
justifyContent: "center",
alignItems: "center",
}}
>
<CssBaseline/>
<Container
maxWidth={"xs"}
sx={{
height: "70%",
border: "2px solid gray",
borderRadius: 5,
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
}}
>
<Typography variant="h3" textAlign={"center"} mb={5}>
Login
</Typography>
const [values, setValues] = React.useState({
amount: "",
password: "",
weight: "",
weightRange: "",
showPassword: false,
});

<TextField
error={errors.userName !== ''}
helperText={errors.userName}
label="User ID"
sx={{
width: "90%",
marginX: "5%",
marginY: "5%",
}}
onChange={(e) => setUserID(e.target.value)}
/>
const handleClickOpen = async () => {
dispatcher(loginAction(userid, password));
if (state === "") {
seterr(true);
} else {
seterr(false);
}
if (state1 === "") {
seterr1(true);
} else {
seterr1(false);
}
};

<TextField
error={errors.password !== ''}
helperText={errors.password}
label="Password"
sx={{
width: "90%",
marginX: "5%",
marginY: "5%",
}}
type={'password'}
onChange={(e) => setPassword(e.target.value)}
/>
const [userid, setUserID] = useState("");
const [password, setPassword] = useState("");
const dispatcher = useDispatch();
const navigate = useNavigate();

<Button
variant={"contained"}
sx={{
marginY: "5%",
}}
onClick={login}
>
Login
</Button>
</Container>
</Box>
);
const loggedIn = useSelector((state) => state.users.loggedIn);

useEffect(() => {
if (loggedIn) {
navigate("/");
}
}, [loggedIn, navigate]);

return (
<Box
style={{
display: "flex",
flexDirection: "column",
justifyContent: "center",
height: "100%",
}}
>
<Box
style={{
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
height: "100%",
}}
>
<Card
sx={{ width: { md: "850px", sm: "425px", xs: "425px" }, m: 2 }}
style={{
height: "425px",
borderRadius: "25px",
boxShadow: "0 0 25px 15px lightgrey",
padding: "0px",
margin: "40px",
}}
>
<CardContent
sx={{ width: { md: "850px", sm: "425px" } }}
style={{ display: "flex", padding: "0px", height: "425px" }}
>
<Box
sx={{ display: { md: "block", sm: "none", xs: "none" } }}
style={{ flex: 1 }}
>
<CCarousel interval={2000} controls transition="crossfade">
<CCarouselItem>
<CImage className="d-block w-100" src={img1} alt="slide 1" />
</CCarouselItem>

<CCarouselItem>
<CImage className="d-block w-100" src={img2} alt="slide 2" />
</CCarouselItem>

<CCarouselItem>
<CImage className="d-block w-100" src={img3} alt="slide 3" />
</CCarouselItem>
</CCarousel>
</Box>
<div
style={{
flex: 1,
height: "425px",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
textAlign: "center",
}}
>
<Box style={{ marginBottom: "40px" }}>
<Typography
style={{
fontSize: "35px",
fontFamily: "inherit",
fontWeight: "bold",
color: "#1875d1",
}}
>
LOGIN
</Typography>
</Box>
<Box
style={{
display: "flex",
flexDirection: "row",
alignItems: "center",
marginBottom: "25px",
}}
>
<Typography>User ID:</Typography>
<TextField
value={state}
onChange={textout}
error={err}
id="outlined-basic"
label={!err ? "User id*" : " Error! "}
variant="outlined"
style={{ marginLeft: "25px", width: "220px" }}
/>
</Box>
<Box
style={{
display: "flex",
flexDirection: "row",
alignItems: "center",
}}
>
<Typography
style={{ marginBottom: "20px", marginRight: "10px" }}
>
Password:
</Typography>
<FormControl
sx={{ mb: 3, width: "25ch" }}
variant="outlined"
value={state1}
onChange={textout1}
error={err1}
label={!err1 ? "Mail Id*" : " Error! "}
>
<InputLabel htmlFor="outlined-adornment-password">
Password*
</InputLabel>
<OutlinedInput
id="outlined-adornment-password"
type={values.showPassword ? "text" : "password"}
value={values.password}
onChange={handleChange("password")}
endAdornment={
<InputAdornment position="end">
<IconButton
aria-label="toggle password visibility"
onClick={handleClickShowPassword}
onMouseDown={handleMouseDownPassword}
edge="end"
>
{values.showPassword ? (
<VisibilityOff />
) : (
<Visibility />
)}
</IconButton>
</InputAdornment>
}
label="Password"
/>
</FormControl>
</Box>
<Box>
<Typography>forget password?</Typography>
</Box>
<Box
style={{
display: "flex",
justifyContent: "center",
marginTop: "30px",
}}
>
<Button variant="contained" onClick={handleClickOpen}>
Login
</Button>
</Box>
</div>
</CardContent>
</Card>
</Box>
</Box>
);
};

export default Login;
Binary file added client/src/components/users/images/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/components/users/images/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/components/users/images/3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/components/users/images/lt1.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/components/users/images/lt2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/components/users/images/lt3.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading