-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappmain.js
106 lines (96 loc) · 2.63 KB
/
appmain.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import "./App.css";
import React, {useState, useEffect} from "react";
import { Routes, Route } from "react-router-dom";
import BusinessContainer from "./BusinessContainer";
import NavBar from "./NavBar";
import Homepage from "./Homepage";
import FavoritesContainer from "./FavoritesContainer";
import SignUp from "./SignUp";
import Login from "./Login";
function App() {
const [businesses, setBusinesses] = useState([]);
const [user, setUser] = useState(null);
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [favorite, setFavorite] = useState("");
useEffect(() => {
fetch("/businesses")
.then((r) => r.json())
.then(setBusinesses);
}, []);
console.log(businesses);
return (
<>
<header className="header-image"></header>
<div className="navbar">
<span className="app-name">BOB</span>
<span className="header-description">
Black Owned Businesses Around You
</span>
</div>
<NavBar user={user} setUser={setUser} />
<br />
<>
{user ? (
<Routes>
<Route exact path="/" element={<Homepage user={user} />} />
<Route
path="businesses"
element={
<BusinessContainer
businesses = {businesses}
/>
}
/>
<Route
path="/favorites"
element={
<FavoritesContainer
favorite = {favorite}
setFavorite={setFavorite}
user={user}
/>
}
/>
</Routes>
) : (
<Routes>
<Route
path="businesses"
element={
<BusinessContainer
businesses = {businesses}
/>
}
/>
<Route
path="/signup"
element={
<SignUp
setUser={setUser}
username={username}
setUsername={setUsername}
password={password}
setPassword={setPassword}
/>
}
/>
<Route
path="/login"
element={
<Login
setUser={setUser}
username={username}
setUsername={setUsername}
password={password}
setPassword={setPassword}
/>
}
/>
</Routes>
)}
</>
</>
);
}
export default App;