Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

Commit 35aa4e5

Browse files
committed
ui: logout if not accept
1 parent 31f4cd6 commit 35aa4e5

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

apps/client/src/routes/Main/Main.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,31 @@ import { Outlet, useNavigate } from "react-router-dom";
33
import {
44
Flex,
55
useBreakpointValue,
6-
useDisclosure,
76
Modal,
87
ModalOverlay,
98
ModalContent,
109
ModalHeader,
1110
ModalFooter,
1211
ModalBody,
13-
ModalCloseButton,
1412
Button,
1513
Heading,
1614
} from "@chakra-ui/react";
1715
import Sidebar from "../../components/Sidebar";
1816
import { BottomNav } from "../../components/BottomNav";
19-
import { useIsLoggedIn } from "../../stores/auth";
17+
import { authActions, useIsLoggedIn } from "../../stores/auth";
2018

2119
export default function Main() {
2220
const navigate = useNavigate();
2321
const loggedIn = useIsLoggedIn();
22+
const { logout } = authActions;
2423
const isLargerThanMd = useBreakpointValue({ base: false, md: true });
25-
const { isOpen, onOpen } = useDisclosure();
2624

2725
useEffect(() => {
2826
if (!loggedIn) {
2927
navigate("/");
3028
}
3129
}, [loggedIn, navigate]);
3230

33-
useEffect(() => {
34-
if (!localStorage.getItem("consentedToWelcomeMessage")) {
35-
onOpen();
36-
}
37-
});
38-
3931
const consent = () => {
4032
localStorage.setItem("consentedToWelcomeMessage", "true");
4133
window.location.reload(); // We reload instead of just closing the dialog so that the analytics can be initialised
@@ -63,13 +55,18 @@ export default function Main() {
6355
>
6456
<Outlet />
6557
</Flex>
66-
<Modal closeOnOverlayClick={false} isOpen={isOpen} onClose={consent}>
58+
<Modal
59+
closeOnOverlayClick={false}
60+
isOpen={localStorage.getItem("consentedToWelcomeMessage") !== "true"}
61+
onClose={() => {
62+
/** void */
63+
}}
64+
>
6765
<ModalOverlay />
6866
<ModalContent>
6967
<ModalHeader fontFamily="Poppins, sans-serif">
7068
Welcome to Timetabl!
7169
</ModalHeader>
72-
<ModalCloseButton />
7370
<ModalBody pb={6}>
7471
<Heading size="xs" pb={4} fontWeight="regular">
7572
By continuing, you consent to Timetabl sending anonymous error
@@ -85,8 +82,11 @@ export default function Main() {
8582
desktop or by clicking on More {">"} Feedback on mobile.
8683
</ModalBody>
8784

88-
<ModalFooter>
89-
<Button onClick={consent}>Continue</Button>
85+
<ModalFooter gap={2}>
86+
<Button onClick={logout} colorScheme="red" variant={"outline"}>
87+
{"Don't accept"}
88+
</Button>
89+
<Button onClick={consent}>Accept and continue</Button>
9090
</ModalFooter>
9191
</ModalContent>
9292
</Modal>

0 commit comments

Comments
 (0)