-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.tsx
71 lines (65 loc) 路 1.79 KB
/
index.tsx
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
import React, { ReactElement } from "react";
import { auth } from "../firebase.config";
import { useAuthState } from "react-firebase-hooks/auth";
import { Navbar } from "../components/utils/nav/Navbar";
import { Box, Spinner, Text } from "@chakra-ui/react";
import { Sessions } from "../components/sessions/Sessions";
import { LandingPage } from "../components/lpg/LandingPage";
import { PageHead } from "../components/utils/PageHead";
import { Footer } from "../components/std/Footer";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const Index = (): ReactElement<any, any> => {
const [user, loading, error] = useAuthState(auth);
// The auth state is being fetched. Displaying a spinner
if (loading) {
return (
<React.Fragment>
<PageHead title="Cubedeck" />
<Box textAlign={"center"} pt="25%">
<Spinner />
</Box>
</React.Fragment>
);
}
// The user is successfully logged in
if (user) {
return (
<React.Fragment>
<PageHead title={`Cubedeck | ${user.displayName}`} />
<Box>
<Navbar />
<Box pb="15%">
<Sessions />
</Box>
<Footer />
</Box>
</React.Fragment>
);
}
// there was an authentication error
if (error) {
return (
<React.Fragment>
<PageHead title="Cubedeck: Error" />
<Box>
<Navbar />
<Text fontWeight="bold" color="red.200">
Oopsie-doopsies! There was a glitch on our side...
</Text>
</Box>
<Footer />
</React.Fragment>
);
}
// User is not logged in
return (
<React.Fragment>
<PageHead title="Cubedeck" />
<Box>
<Navbar />
<LandingPage />
</Box>
</React.Fragment>
);
};
export default Index;