Skip to content

Commit

Permalink
Merge branch 'master' into heatmap-element
Browse files Browse the repository at this point in the history
  • Loading branch information
Joepock123 committed May 28, 2020
2 parents 1b0052b + 2b87c11 commit 37b2e7c
Show file tree
Hide file tree
Showing 54 changed files with 5,813 additions and 525 deletions.
34 changes: 7 additions & 27 deletions client-app/src/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useContext } from "react";
import "./App.css";
import Landing from "./components/shared/landing.js";
import Header from "./components/shared/header.js";
Expand All @@ -8,52 +8,32 @@ import Login from "./components/shared/login.js";
import Home from "./components/vendor/home.js";
import Heatmap from "./components/vendor/heatmap.js";
import Timetable from "./components/vendor/timetable.js";
import CustomerMap from "./components/customer/map.js";
// For react router
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
// For React context management
import { AppContextProvider } from "./components/AppContext";

function App() {
const [isVendor, setIsVendor] = useState(true);

return (
<AppContextProvider>
<Router>
<div className="App">
<Header />
<Switch>
<Route path="/" exact render={() => <Landing />} />
<Route exact path="/" component={() => <Landing />} />
<Route path="/user" component={() => <User />} />
<Route
path="/signup"
component={() => <Signup isVendor={isVendor} />}
/>
<Route
path="/login"
component={() => <Login isVendor={isVendor} />}
/>
<Route path="/signup" component={() => <Signup />} />
<Route path="/login" component={() => <Login />} />
<Route path="/home" component={() => <Home />} />
<Route path="/heatmap" component={() => <Heatmap />} />
<Route path="/map" component={() => <CustomerMap />} />
<Route path="/timetable" component={() => <Timetable />} />
</Switch>
</div>
</Router>
</AppContextProvider>
);
}

/* <Route exact path="/props-through-render" render={(props) => <PropsPage {...props} title={`Props through render`} />} />
<Route
path='/dashboard'
component={() => <Dashboard isAuthed={true} />}
/> */

/* <Route
path='/dashboard'
render={(props) => <Dashboard {...props} isAuthed={true} />}
/> */

export default App;

/* <Route path="/signup-c" component={signupCustomer} />
<Route path="/signup-v" component={signupVendor} /> */
2 changes: 1 addition & 1 deletion client-app/src/components/AppContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useState, createContext } from "react";
const AppContext = createContext();

function AppContextProvider(props) {
const [logInStatus, setLogInStatus] = useState(true);
const [logInStatus, setLogInStatus] = useState(false);
const [isVendor, setIsVendor] = useState(true);
const [signUpStateVendor, setSignUpStateVendor] = useState({
name: "",
Expand Down
24 changes: 12 additions & 12 deletions client-app/src/components/customer/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import React from "react";
import LondonMap from "../../utils/london-map.js";

export default function CustomerMap() {
function signalInterest(e) {
e.preventDefault;
//API post request to customer location table INSERT INTO customer_location
}
// function signalInterest(e) {
// e.preventDefault;
// //API post request to customer location table INSERT INTO customer_location
// };

return (
<section>
<LondonMap />
<button onClick={signalInterest}>
Let Vendors Know You Would Like Some Ice Cream
</button>
</section>
);
return <h1>Customer map</h1>;
}

/* // <section>
// <LondonMap />
// <button onClick={signalInterest()}>
// Let Vendors Know You Would Like Some Ice Cream
// </button>
// </section> */
100 changes: 0 additions & 100 deletions client-app/src/components/shared/extra.js

This file was deleted.

31 changes: 25 additions & 6 deletions client-app/src/components/shared/header.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
import React, { useContext } from "react"
import { AppContext } from "../AppContext"
import { Title, HeaderArea } from "../../styles/header.js"
import React, { useContext } from "react";
import { AppContext } from "../AppContext";
import { Title, HeaderArea, LogInOption } from "../../styles/header.js";

export default function Header() {
const { logInStatus } = useContext(AppContext)
const { logInStatus, setLogInStatus } = useContext(AppContext);

function removeToken() {
window.localStorage.removeItem("token");
}

function headerStatus() {
let token = localStorage.getItem("token");
if (!token) {
setLogInStatus(false);
return <LogInOption href="/">Log In or Sign Up Here!</LogInOption>;
} else {
setLogInStatus(true);
return (
<LogInOption onClick={removeToken} href="/">
Log Out
</LogInOption>
);
}
}

return (
<HeaderArea>
<Title>Where's Whippy</Title>
{!logInStatus ? <a href="#">Log In</a> : <a href="#">Log Out</a>}
{headerStatus()}
</HeaderArea>
)
);
}
22 changes: 4 additions & 18 deletions client-app/src/components/shared/landing.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,16 @@ import { BlueButton, PinkButton, PageContainer } from "../../styles/buttons.js";
export default function Landing() {
const { isVendor, setIsVendor } = useContext(AppContext);

console.log("landing state: ", isVendor);

return (
<PageContainer>
<h2 className="landing-subtitle">Tired of waiting for the jingle?</h2>
<img className="landing-img" src="#" alt="illustation" />
<h2>Tired of waiting for the jingle?</h2>
<img src="#" alt="illustation" />
<Link to="/user" onClick={() => setIsVendor(true)}>
<PinkButton className="landing-btn-vendors">Vendors</PinkButton>
<PinkButton>Vendors</PinkButton>
</Link>
<Link to="/user" onClick={() => setIsVendor(false)}>
<BlueButton className="landing-btn-customers">Customers</BlueButton>
<BlueButton>Customers</BlueButton>
</Link>
</PageContainer>
);

// function handleLoginLinkVendor() {
// alert("Vendor login button clicked")
// setIsVendor(true)
// }

// function handleLoginLinkCustomer() {
// console.log(isVendor)
// setIsVendor(false)
// console.log(isVendor)
// // alert("Customer login button clicked")
// }
}
Loading

0 comments on commit 37b2e7c

Please sign in to comment.