-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
64 lines (51 loc) · 1.58 KB
/
App.js
File metadata and controls
64 lines (51 loc) · 1.58 KB
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
function startApp() {
function App() {
const [route, setRoute] = React.useState(location.hash || "#events");
React.useEffect(() => {
const onHashChange = () => setRoute(location.hash);
window.addEventListener("hashchange", onHashChange);
return () => window.removeEventListener("hashchange", onHashChange);
}, []);
if (route === "#availability/create") {
return <AddAvailabilityPage />;
}
if (route === "#event/create") {
return <CreateTablePage />;
}
if (route.match(/^#event\/[^\/]+\/create$/)) {
const locationId = route.split("/")[1];
return <CreateTablePage locationId={locationId} />;
}
if (route.startsWith("#event-detail/")) {
const eventId = route.split("/")[1];
return <EventDetailPage eventId={eventId} />;
}
if (route.startsWith("#location/")) {
const locationId = route.split("/")[1];
return <LocationPage locationId={locationId} />;
}
if (route.startsWith("#event-edit/")) {
const eventId = route.split("/")[1];
return <EditEventPage eventId={eventId} />;
}
switch (route) {
case "#calendar":
return <CalendarPage />;
case "#profile":
return <ProfilePage />;
case "#event":
return <EventDetailPage />;
case "#events":
default:
return <EventMapPage />;
}
}
ReactDOM.render(<App />, document.getElementById("app-root"));
}
if (typeof L === 'undefined') {
window.addEventListener('load', () => {
setTimeout(startApp, 100);
});
} else {
startApp();
}