Skip to content

Commit

Permalink
Login logic
Browse files Browse the repository at this point in the history
  • Loading branch information
hariharan2017 committed Jun 20, 2022
1 parent 395ed48 commit 361d216
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/components/Login/Login.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
import "./Login.scss";
import { useState } from "react";
import { actions } from "../../data/login";
import { useDispatch } from "react-redux";

const Login = () => {
const [form, setForm] = useState({ username: null, password: null });
const dispatch = useDispatch();

const onTextChange = (event) => {
const currentField = event.target.id;
const currentValue = event.target.value;
setForm({ ...form, [currentField]: currentValue });
}

return (
<div className="login-container">
<div className="card-container">
<img src={"https://t3.ftcdn.net/jpg/03/39/70/90/360_F_339709048_ZITR4wrVsOXCKdjHncdtabSNWpIhiaR7.jpg"} height="250px" />
<div>
<input placeholder="Username" type={"text"} className="input-style"/>
<input id="username" placeholder="Username" type={"text"} className="input-style" onChange={(event) => onTextChange(event)}/>
</div>
<div>
<input placeholder="Password" type={"password"} className="input-style"/>
<input id="password" placeholder="Password" type={"password"} className="input-style" onChange={(event) => onTextChange(event)}/>
</div>
<button className="button-style">Login</button>
<button className="button-style" onClick={() => {console.log(form); dispatch(actions.login(form))}}>Login</button>
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sidebar/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Sidebar = () => {
<div className="main-items-container">
<div className="group-container">
<div>Main</div>
<Link to="/">
<Link to="/home">
<div className="group-item">
<Dashboard className="group-item-icon"/>
<div className="group-item-title">Dashboard</div>
Expand Down

0 comments on commit 361d216

Please sign in to comment.