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

added signup page #3

Merged
merged 1 commit into from
Feb 11, 2022
Merged
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 changes: 28 additions & 5 deletions Client/murarixprs/src/Components/Login/LoginInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import { createTheme, ThemeProvider } from "@mui/material/styles";
import TextField from "@mui/material/TextField";
import Button from "@mui/material/Button";
import RoverImage from "../Assets/Rover.jpg";
import { useAppSelector, useAppDispatch } from "../../Redux/hooks";
import { useNavigate } from "react-router-dom";
import styles from "./Login.module.css";
import { authLogin } from "../../Redux/authentication/authAction";
import { Link } from "react-router-dom";

interface ILoginInputProps {
loginData: LoginModel;
Expand All @@ -29,7 +33,9 @@ const LoginInput: React.FunctionComponent<ILoginInputProps> = ({
const [showPasswordValid, setShowPasswordValid] = useState(false);
const [showEmailRequired, setShowEmailRequired] = useState(false);
const [showPasswordRequired, setShowPasswordRequired] = useState(false);

const isAuth = useAppSelector((state) => state.auth.loginSuccess);
const dispatch = useAppDispatch();
let navigate = useNavigate();
const emailValid = /\S+@\S+/;
// function for login
const handleSubmit = (): void => {
Expand All @@ -46,7 +52,11 @@ const LoginInput: React.FunctionComponent<ILoginInputProps> = ({

if (emailValid.test(email) && password.length >= 4) {
// calling the login API from loginPage container by passing the email and password
// onHandleSubmit(email, password);
const payload: object = {
email,
password,
};
dispatch(authLogin(payload));
setShowEmailValid(false);
setShowPasswordValid(false);
} else if (emailValid.test(email)) {
Expand All @@ -70,6 +80,9 @@ const LoginInput: React.FunctionComponent<ILoginInputProps> = ({
},
},
});
if (isAuth) {
navigate("/dashboard");
}
return (
<>
<Box
Expand All @@ -87,7 +100,7 @@ const LoginInput: React.FunctionComponent<ILoginInputProps> = ({
<img src={RoverImage} alt="RoverLogo" style={{ width: "90px" }} />
</Box>
<Box style={{ textAlign: "center", marginTop: "15px" }}>
<Typography variant="h4" gutterBottom component="div">
<Typography variant="h5" gutterBottom component="div">
Login to your account
</Typography>
<svg
Expand Down Expand Up @@ -246,7 +259,7 @@ const LoginInput: React.FunctionComponent<ILoginInputProps> = ({
style={{ textAlign: "center", marginTop: "45px" }}
>
<Typography
variant="h5"
variant="h6"
gutterBottom
component="div"
style={{ textAlign: "left", paddingLeft: "20%" }}
Expand All @@ -259,6 +272,7 @@ const LoginInput: React.FunctionComponent<ILoginInputProps> = ({
id="outlined-basic"
variant="outlined"
type="email"
name="email"
InputLabelProps={{ shrink: false }}
required
value={email}
Expand Down Expand Up @@ -295,7 +309,7 @@ const LoginInput: React.FunctionComponent<ILoginInputProps> = ({
</Typography>
) : null}
<Typography
variant="h5"
variant="h6"
gutterBottom
component="div"
style={{
Expand All @@ -311,6 +325,7 @@ const LoginInput: React.FunctionComponent<ILoginInputProps> = ({
id="outlined-basic"
variant="outlined"
type="password"
name="password"
InputLabelProps={{ shrink: false }}
required
value={password}
Expand Down Expand Up @@ -362,6 +377,14 @@ const LoginInput: React.FunctionComponent<ILoginInputProps> = ({
</Button>
</ThemeProvider>
</Box>
<Box sx={{ mt: "10px" }}>
<Typography variant="h6" sx={{ textAlign: "center" }}>
Need an account ?{" "}
<Link to="/signup" style={{ color: "#da6212" }}>
SignUp
</Link>{" "}
</Typography>
</Box>
</Box>
</Box>
</>
Expand Down
23 changes: 15 additions & 8 deletions Client/murarixprs/src/Components/Signup/SignUp.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import * as React from 'react';
import * as React from "react";
import { useState } from "react";
import { SignUpModel } from "../models/signup.model";
import SignUpInput from "./SignUpInput";

interface ISignUpProps {
}
const initialState = {
firstName: "",
lastName: "",
email: "",
password: "",
};
const SignUp: React.FunctionComponent = (props) => {
const [signUpData, setSignUpData] = useState<SignUpModel>(initialState || "");

const SignUp: React.FunctionComponent<ISignUpProps> = (props) => {
return (
<>

<h1>SignUp Page</h1>
</>
<>
<SignUpInput signUpData={signUpData} setSignUpData={setSignUpData} />
</>
);
};

Expand Down
Loading