Archived
Merge pull request #2 from JMR-dev/jr-skiploginbutton
merging changes for skip login button
This commit was merged in pull request #2.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import React from "react"
|
||||
import { Route } from "react-router-dom"
|
||||
import { GraphicsBayTrackerHome } from "./home/GraphicsBayTrackerHome"
|
||||
import { Profile } from "./profile/Profile"
|
||||
|
||||
|
||||
export const ApplicationViews = () => {
|
||||
return (
|
||||
<>
|
||||
<Route path="/GraphicsBayTrackerHome">
|
||||
<GraphicsBayTrackerHome />
|
||||
</Route>
|
||||
<Route path="profile/Profile" >
|
||||
<Profile />
|
||||
</Route>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ export const Login = () => {
|
||||
const history = useHistory()
|
||||
|
||||
const existingUserCheck = () => {
|
||||
return fetch(`http://localhost:8088/customers?email=${email}`)
|
||||
return fetch(`http://localhost:8088/users?email=${email}`)
|
||||
.then(res => res.json())
|
||||
.then(user => user.length ? user[0] : false)
|
||||
}
|
||||
@@ -20,7 +20,7 @@ export const Login = () => {
|
||||
.then(exists => {
|
||||
if (exists) {
|
||||
localStorage.setItem("graphicsbaytracker_customer", exists.id)
|
||||
history.push("/")
|
||||
history.push("")
|
||||
} else {
|
||||
existDialog.current.showModal()
|
||||
}
|
||||
@@ -56,6 +56,9 @@ export const Login = () => {
|
||||
<section className="link--register">
|
||||
<Link to="/register">Not a member yet?</Link>
|
||||
</section>
|
||||
<section className="link-skiplogin">
|
||||
<Link to="/GraphicsBayTrackerHome">Skip Login</Link>
|
||||
</section>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import React from "react"
|
||||
import {useState, useEffect} from "react"
|
||||
import { useHistory } from "react-router-dom"
|
||||
|
||||
export const Logout = () => {
|
||||
const [loggedincustomer, setloggedincustomer] = useState(localStorage.graphicsbaytracker_customer)
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<button onClick={() => setloggedincustomer(localStorage.removeItem("graphicsbaytracker_customer"))}>Log Out</button>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
@@ -9,7 +9,7 @@ export const Register = (props) => {
|
||||
const history = useHistory()
|
||||
|
||||
const existingUserCheck = () => {
|
||||
return fetch(`http://localhost:8088/customers?email=${customer.email}`)
|
||||
return fetch(`http://localhost:8088/users?email=${customer.email}`)
|
||||
.then(res => res.json())
|
||||
.then(user => !!user.length)
|
||||
}
|
||||
@@ -18,7 +18,7 @@ export const Register = (props) => {
|
||||
existingUserCheck()
|
||||
.then((userExists) => {
|
||||
if (!userExists) {
|
||||
fetch("http://localhost:8088/customers", {
|
||||
fetch("http://localhost:8088/users", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import React from "react"
|
||||
import { NavBar } from "../nav/NavBar"
|
||||
|
||||
export const GraphicsBayTrackerHome =()=>{
|
||||
const displayNavBar = NavBar()
|
||||
|
||||
return <div>
|
||||
{displayNavBar}
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
export const NewsStories = () => {
|
||||
return <div></div>
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import React, { useEffect, useState } from "react"
|
||||
import { Link, useHistory } from "react-router-dom"
|
||||
import { Login } from "../auth/Login"
|
||||
import { Logout } from "../auth/Logout"
|
||||
import "./NavBar.css"
|
||||
|
||||
|
||||
|
||||
export const NavBar = () => {
|
||||
const history = useHistory()
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<div className="container">
|
||||
<nav className="navbar navbar-expand-sm navbar-light bg-light fixed-top onTop">
|
||||
<button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span className="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div id="navbarNavDropdown" className="navbar-collapse collapse">
|
||||
<ul className="navbar-nav mr-auto">
|
||||
<li className="nav-item active">
|
||||
<Link className="nav-link" to="/PricingData">Pricing Data<span className="sr-only"></span></Link>
|
||||
</li>
|
||||
<li className="nav-item">
|
||||
<Link className="nav-link" to="/Profile">My Profile and Tracked Cards<span className="sr-only"></span></Link>
|
||||
</li>
|
||||
</ul>
|
||||
<ul className="navbar-nav">
|
||||
<li className="nav-item">
|
||||
{
|
||||
localStorage.graphicsbaytracker_customer >= 1 ? <Link className="nav-Link" to="/Logout">Logout</Link> : <Link className="nav-link" to="/Login">Login</Link>
|
||||
|
||||
|
||||
}
|
||||
</li>
|
||||
<li className="nav-item">
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user