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

Commit 0a72415

Browse files
Revert "#50 use react routers data fetching mechanism"
1 parent 1fd8b24 commit 0a72415

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1720
-1842
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# [Timetabl](https://www.timetabl.app)
2-
32
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
4-
53
[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)
6-
74
<!-- ALL-CONTRIBUTORS-BADGE:END -->
85

96
![GitHub deployments](https://img.shields.io/github/deployments/debater-coder/timetabl-app/production?label=vercel&logo=vercel)
@@ -24,7 +21,7 @@ Timetabl is built on three principles:
2421

2522
3. **Be secure**
2623
Unlike other bell time apps, Timetabl stores your tokens in HTTPS-only cookies instead of `localStorage`, so that even in the event of an XSS attack, the tokens are secure.
27-
24+
2825
## Contributors
2926

3027
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->

package-lock.json

Lines changed: 853 additions & 946 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@react-three/fiber": "^8.9.1",
4141
"@rollup/plugin-replace": "^4.0.0",
4242
"@tanstack/query-sync-storage-persister": "^4.0.10",
43-
"@tanstack/react-query": "^4.20.4",
43+
"@tanstack/react-query": "4.0.10",
4444
"@tanstack/react-query-devtools": "^4.0.10",
4545
"@tanstack/react-query-persist-client": "^4.0.10",
4646
"@types/react-dom": "^18.0.9",
@@ -62,8 +62,7 @@
6262
"react": "^18.1.0",
6363
"react-dom": "^18.1.0",
6464
"react-icons": "^4.4.0",
65-
"react-query-kit": "^1.3.1",
66-
"react-router-dom": "^6.5.0",
65+
"react-router-dom": "^6.3.0",
6766
"rollup-plugin-workbox": "^6.2.0",
6867
"three": "^0.146.0",
6968
"web-vitals": "^3.0.1",
@@ -82,7 +81,7 @@
8281
"@typescript-eslint/eslint-plugin": "^5.38.0",
8382
"@typescript-eslint/parser": "^5.38.0",
8483
"@vercel/node": "^2.6.3",
85-
"@vitejs/plugin-react": "^3.0.0",
84+
"@vitejs/plugin-react": "^2.0.0",
8685
"cypress": "^11.2.0",
8786
"eslint": "^8.23.1",
8887
"eslint-config-prettier": "^8.5.0",
@@ -95,6 +94,6 @@
9594
"npm-run-all": "^4.1.5",
9695
"prettier": "2.6.2",
9796
"start-server-and-test": "^1.14.0",
98-
"vite": "^4.0.2"
97+
"vite": "^3.0.2"
9998
}
10099
}

src/Auth.tsx

Lines changed: 0 additions & 223 deletions
This file was deleted.

src/components/App/App.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ import Nav from "../Nav";
22
import { Outlet } from "react-router-dom";
33
import { Flex } from "@chakra-ui/react";
44
import { Box } from "@chakra-ui/react";
5+
import { ErrorBoundary } from "../ErrorBoundary";
56

67
export default () => {
78
return (
89
<Flex direction={"column"} width={"100vw"} maxW="full" height={"100vh"}>
910
<Nav />
1011
<Box mt={"100px"} />
1112
<Flex direction={"column"} w="full" h="full" maxH={"calc(100% - 100px)"}>
12-
<Outlet />
13+
<ErrorBoundary>
14+
<Outlet />
15+
</ErrorBoundary>
1316
</Flex>
1417
</Flex>
1518
);

src/components/BottomNavSheet/BottomNavSheet.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
import SidebarButton from "../Sidebar/SidebarButton";
88
import { motion, PanInfo } from "framer-motion";
99
import { useEffect, useRef, useState } from "react";
10-
import { pages } from "../../pages";
10+
import { routes } from "../../routes";
1111

1212
const Flex = motion(ChakraFlex);
1313

@@ -80,7 +80,7 @@ export const BottomNavSheet = () => {
8080
borderTop="none"
8181
borderColor={useColorModeValue("gray.200", "gray.700")}
8282
>
83-
{pages.pinned.map((routes) => (
83+
{routes.pinned.map((routes) => (
8484
<SidebarButton
8585
key={routes.path}
8686
name={routes.name}
@@ -92,7 +92,7 @@ export const BottomNavSheet = () => {
9292
))}
9393
</Flex>
9494
<SimpleGrid columns={4} w="full">
95-
{pages.unpinned.map((routes) => (
95+
{routes.unpinned.map((routes) => (
9696
<SidebarButton
9797
key={routes.path}
9898
name={routes.name}

src/components/DTTPeriod/DTTPeriod.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { chakra, useBoolean, useMediaQuery } from "@chakra-ui/react";
22
import { DateTime } from "luxon";
33
import { useState } from "react";
4+
import { TimetablPeriod } from "../../hooks/sbhsQuery/use/useDTT";
45
import useSettings from "../../hooks/useSettings";
5-
import { TimetablPeriod } from "../../services/sbhsApi/types";
66
import { Period } from "../Period";
77

88
export const DTTPeriod = ({

src/components/ErrorAlert.tsx/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { UseQueryResult } from "@tanstack/react-query";
2+
import handleQuery from "../../utils/handleQuery";
3+
import QueryError from "../QueryError";
4+
5+
export default function QueryHandler({
6+
queries,
7+
children,
8+
}: {
9+
queries: Record<string, UseQueryResult>;
10+
children: (isLoaded: boolean, data: Record<string, unknown>) => JSX.Element;
11+
}) {
12+
const errors: unknown[] = [];
13+
let isLoaded = true;
14+
15+
Object.entries(queries).forEach(([, query]) => {
16+
const { data, error } = query;
17+
if (error) {
18+
errors.push(error);
19+
}
20+
21+
if (!data) {
22+
isLoaded = false;
23+
}
24+
});
25+
26+
const data: Record<string, unknown> = {};
27+
28+
Object.entries(queries).forEach(([key, query]) => {
29+
data[key] = query.data;
30+
});
31+
32+
return handleQuery(
33+
isLoaded,
34+
errors.length,
35+
(isLoaded) => <>{children(isLoaded, data)}</>,
36+
<>
37+
{errors.map((error, index) => (
38+
<QueryError key={index} error={error} />
39+
))}
40+
</>
41+
);
42+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from "./QueriesHandler";

0 commit comments

Comments
 (0)