11import { useEffect } from "react" ;
22import { Outlet , useNavigate } from "react-router-dom" ;
3- import { Flex , useBreakpointValue } from "@chakra-ui/react" ;
3+ import {
4+ Flex ,
5+ useBreakpointValue ,
6+ useDisclosure ,
7+ Modal ,
8+ ModalOverlay ,
9+ ModalContent ,
10+ ModalHeader ,
11+ ModalFooter ,
12+ ModalBody ,
13+ ModalCloseButton ,
14+ Button ,
15+ Heading ,
16+ } from "@chakra-ui/react" ;
417import Sidebar from "../../components/Sidebar" ;
518import { BottomNav } from "../../components/BottomNav" ;
619import { useIsLoggedIn } from "../../stores/auth" ;
@@ -9,34 +22,75 @@ export default function Main() {
922 const navigate = useNavigate ( ) ;
1023 const loggedIn = useIsLoggedIn ( ) ;
1124 const isLargerThanMd = useBreakpointValue ( { base : false , md : true } ) ;
25+ const { isOpen, onOpen } = useDisclosure ( ) ;
1226
1327 useEffect ( ( ) => {
1428 if ( ! loggedIn ) {
1529 navigate ( "/" ) ;
1630 }
1731 } , [ loggedIn , navigate ] ) ;
1832
33+ useEffect ( ( ) => {
34+ if ( ! localStorage . getItem ( "consentedToWelcomeMessage" ) ) {
35+ onOpen ( ) ;
36+ }
37+ } ) ;
38+
39+ const consent = ( ) => {
40+ localStorage . setItem ( "consentedToWelcomeMessage" , "true" ) ;
41+ window . location . reload ( ) ; // We reload instead of just closing the dialog so that the analytics can be initialised
42+ } ;
43+
1944 return (
20- < Flex
21- align = { "center" }
22- width = { "full" }
23- height = { "full" }
24- direction = { { base : "column-reverse" , md : "row" } }
25- >
26- { isLargerThanMd ? < Sidebar /> : < BottomNav /> }
45+ < >
2746 < Flex
28- direction = { "column" }
2947 align = { "center" }
3048 width = { "full" }
3149 height = { "full" }
32- maxH = { { base : "calc(100% - 64px)" , md : "100%" } }
33- mb = { { base : "64px" , md : 0 } }
34- maxW = { { base : "100%" , md : "calc(100% - 100px)" } }
35- ml = { { base : 0 , md : "100px" } }
36- overflowY = { "auto" }
50+ direction = { { base : "column-reverse" , md : "row" } }
3751 >
38- < Outlet />
52+ { isLargerThanMd ? < Sidebar /> : < BottomNav /> }
53+ < Flex
54+ direction = { "column" }
55+ align = { "center" }
56+ width = { "full" }
57+ height = { "full" }
58+ maxH = { { base : "calc(100% - 64px)" , md : "100%" } }
59+ mb = { { base : "64px" , md : 0 } }
60+ maxW = { { base : "100%" , md : "calc(100% - 100px)" } }
61+ ml = { { base : 0 , md : "100px" } }
62+ overflowY = { "auto" }
63+ >
64+ < Outlet />
65+ </ Flex >
66+ < Modal closeOnOverlayClick = { false } isOpen = { isOpen } onClose = { consent } >
67+ < ModalOverlay />
68+ < ModalContent >
69+ < ModalHeader fontFamily = "Poppins, sans-serif" >
70+ Welcome to Timetabl!
71+ </ ModalHeader >
72+ < ModalCloseButton />
73+ < ModalBody pb = { 6 } >
74+ < Heading size = "xs" pb = { 4 } fontWeight = "regular" >
75+ By continuing, you consent to Timetabl sending anonymous error
76+ diagnostics and usage metrics.
77+ </ Heading >
78+ Timetabl is a blazing fast, offline-enabled, installable timetable
79+ app for Sydney Boys High School, made by Hamzah Ahmed. It is
80+ currently in beta, meaning that some features may not work as
81+ expected and there may be bugs. It is in active development, with
82+ new features being added and bugs being fixed regularly. If there
83+ is a feature you'd like to see, or a bug that needs to be
84+ fixed, send feedback by clicking on Feedback in the left panel on
85+ desktop or by clicking on More { ">" } Feedback on mobile.
86+ </ ModalBody >
87+
88+ < ModalFooter >
89+ < Button onClick = { consent } > Continue</ Button >
90+ </ ModalFooter >
91+ </ ModalContent >
92+ </ Modal >
3993 </ Flex >
40- </ Flex >
94+ </ >
4195 ) ;
4296}
0 commit comments