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

log out routes back to login page #45

Open
wants to merge 2 commits into
base: development
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
9 changes: 7 additions & 2 deletions src/components/signInComponent/signInComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React, { useContext, useState } from "react";
import { Context } from "../../Context";
import { Form, Row, Col, Button } from "react-bootstrap";
import axios from "axios";
import { useNavigate } from "react-router-dom";
import { useNavigate, Link } from "react-router-dom";
import "./signinComponent.css";

// test login
// [email protected]
Expand Down Expand Up @@ -47,7 +48,8 @@ export default function SignInComponent() {
console.log("sub");
};
return (
<div>
<div className="sign-in-box">
<h1 className="sign-in-header">Wallet Zen</h1>
<Form onSubmit={onformSubmit}>
<Form.Group as={Row} className="mb-3" controlId="formPlaintextEmail">
<Form.Label column sm="2">
Expand All @@ -72,6 +74,9 @@ export default function SignInComponent() {
</Col>
</Form.Group>
<Button type="submit">Sign in</Button>
<Link to="/createUser">
<Button type="submit">Sign Up</Button>
</Link>
</Form>
</div>
);
Expand Down
10 changes: 10 additions & 0 deletions src/components/signInComponent/signinComponent.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.sign-in-header {
text-align: center;
}

.sign-in-box {
width: 400px;
border: 1px solid green;
height: 400px;
margin: 0 auto;
}
21 changes: 12 additions & 9 deletions src/pages/budgetPage/BudgetPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ export default function BudgetPage() {
const { isLoggedIn, userData, budgetList } = useContext(Context);
let navigate = useNavigate();

console.log("UserID",userData)
console.log("UserID", userData);
const loginHandler = () => {
if (isLoggedIn) {
navigate("/");
window.location.reload();
} else {
navigate("/");
Expand All @@ -31,7 +32,7 @@ export default function BudgetPage() {
<h1>Logo</h1>
</div>
<div className="right-side">
<h2>Welcome </h2>
<h2>Welcome {userData.firstame} </h2>
<button onClick={loginHandler}>
{isLoggedIn ? "Sign out" : "Sign in"}
</button>
Expand All @@ -42,13 +43,15 @@ export default function BudgetPage() {
<div className="budget">
<h1>Budget</h1>
{budgetList.map((budget, key) => {
return (
<Link to="/expense:id" key={key}>
{budget}
</Link>
);
})}
<Link to="/newBudget"><button>Create new budget</button></Link>
return (
<Link to="/expense:id" key={key}>
{budget}
</Link>
);
})}
<Link to="/newBudget">
<button>Create new budget</button>
</Link>
</div>

<div className="expense-result">
Expand Down