Skip to content

Commit

Permalink
Merge pull request #36 from bliutech/test
Browse files Browse the repository at this point in the history
signout button
  • Loading branch information
bliutech authored Jul 16, 2023
2 parents 88b3ee7 + 18649a9 commit c3d80c1
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 15 deletions.
3 changes: 2 additions & 1 deletion client/src/components/LoginForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import styles from "../styles/components/LoginForm.module.css";
import { useState } from "react";
import { useCookies } from "react-cookie";
import { getUser } from "../api/user";
import { useContext } from "react";

function Login() {
document.title = "Login";
Expand Down Expand Up @@ -63,7 +64,7 @@ function Login() {
placeholder="Show Password"
onClick={() => handleToggle()}
></input>
<text id={styles.regis}> Show password?</text>
<text id={styles.regis}> Show password</text>
</span>
<p></p>
<input
Expand Down
22 changes: 17 additions & 5 deletions client/src/components/NavBar.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Link } from "react-router-dom";
import React from "react";
import styles from "../styles/components/NavBar.module.css";
import { useCookies } from "react-cookie";

function NavBar() {
const [cookies, setCookie, removeCookie] = useCookies("");
const auth = cookies.name > 0;

return (
<div id={styles.navBar}>
<div id={styles.bar}>
Expand All @@ -27,11 +31,19 @@ function NavBar() {
Profile
</Link>
</li>
<li>
<Link id={styles.navLink} to="/login">
<text className={styles.regis}>Login/Register</text>
</Link>
</li>
{auth ? (
<li>
<Link id={styles.navLink} to="/login">
<text> Sign out</text>
</Link>
</li>
) : (
<li>
<Link id={styles.navLink} to="/login">
<text className={styles.regis}>Login/Register</text>
</Link>
</li>
)}
</div>
</div>
);
Expand Down
5 changes: 2 additions & 3 deletions client/src/components/RegistrationForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import { useCookies } from "react-cookie";
import "../styles/index.css";
import styles from "../styles/components/RegistrationForm.module.css";
import { createUser, getUser } from "../api/user";
import { useState, createContext, useContext } from "react";
import { useState } from "react";

function Registration() {
document.title = "Registration";

const UserContext = createContext();
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [cookies, setCookie, removeCookie] = useCookies("");
Expand Down Expand Up @@ -70,7 +69,7 @@ function Registration() {
placeholder="Show Password"
onClick={() => handleToggle()}
></input>
<text id={styles.regis}> Show password?</text>
<text id={styles.regis}> Show password</text>
</span>
<p></p>
<input
Expand Down
30 changes: 24 additions & 6 deletions client/src/pages/ProfilePage.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
import { useState } from "react";
import { useCookies } from "react-cookie";
import { Link } from "react-router-dom";
import styles from "../styles/components/LoginForm.module.css";
import { useNavigate } from "react-router-dom";
import React from "react";

function ProfilePage() {
const navigate = useNavigate();
document.title = "Account";
const [cookies, setCookie, removeCookie] = useCookies("");
const [auth, setAuth] = useState(false);
// if (true) {
// setCookie("name", "cy");
// }

return <p></p>;
function handleSignout() {
removeCookie("name");
navigate("/");
}

return (
<div>
<p>{cookies.name}'s account</p>
<li>
<input
type="button"
id={styles.button}
placeholder="Signout"
onClick={() => handleSignout()}
></input>
</li>
</div>
);
}

export default ProfilePage;

// **** PLEASE ADD A BUTTON TO SIGN UP ****
// **** button needs prettyification ****
6 changes: 6 additions & 0 deletions client/src/styles/components/LoginForm.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
cursor: pointer;
}

#button {
font-size: 20px;
text-decoration: none;
cursor: pointer;
}

:root {
/* generic */
--gutterSm: 0.4rem;
Expand Down

0 comments on commit c3d80c1

Please sign in to comment.