-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAppOutline.tsx
More file actions
33 lines (27 loc) · 1.14 KB
/
AppOutline.tsx
File metadata and controls
33 lines (27 loc) · 1.14 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
import { LoadingScreen, ErrorScreen, apiUrl, Service, Footer } from "@hex-labs/core";
import useAxios from "axios-hooks";
import React from "react";
import { Navigate, Outlet, useLocation, useParams } from "react-router-dom";
import { Box } from "@chakra-ui/react";
import Navigation from "./Navigation";
import { CurrentHexathonProvider } from "../../contexts/CurrentHexathonContext";
import HelpScoutBeacon from "./HelpScoutBeacon";
const AppOutline: React.FC = () => {
const [{ data: hexathons, loading, error }] = useAxios(apiUrl(Service.HEXATHONS, "/hexathons"));
const { hexathonId } = useParams();
const location = useLocation();
if (loading) return <LoadingScreen />;
if (error) return <ErrorScreen error={error} />;
const currentHexathon = hexathons.find((hexathon: any) => hexathon.id === hexathonId);
return (
<CurrentHexathonProvider hexathons={hexathons}>
<Navigation />
{!currentHexathon && location.pathname !== "/" ? <Navigate to="/" /> : <Outlet />}
<HelpScoutBeacon />
<Box backgroundColor="white">
<Footer />
</Box>
</CurrentHexathonProvider>
);
};
export default AppOutline;