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

Commit 0faeb8c

Browse files
Merge branch 'main' into sidebar
2 parents db9b88c + fafc910 commit 0faeb8c

File tree

7 files changed

+147
-45
lines changed

7 files changed

+147
-45
lines changed

.all-contributorsrc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"files": [
3+
"README.md"
4+
],
5+
"imageSize": 100,
6+
"commit": false,
7+
"commitConvention": "angular",
8+
"contributors": [
9+
{
10+
"login": "wensenfriendandextra",
11+
"name": "Wansen Dong",
12+
"avatar_url": "https://avatars.githubusercontent.com/u/23128324?v=4",
13+
"profile": "https://github.com/wensenfriendandextra",
14+
"contributions": [
15+
"code"
16+
]
17+
},
18+
{
19+
"login": "debater-coder",
20+
"name": "debater-coder",
21+
"avatar_url": "https://avatars.githubusercontent.com/u/52619668?v=4",
22+
"profile": "https://github.com/debater-coder",
23+
"contributions": [
24+
"code"
25+
]
26+
},
27+
{
28+
"login": "ZZZooHaq",
29+
"name": "ZZZooHaq",
30+
"avatar_url": "https://avatars.githubusercontent.com/u/88522048?v=4",
31+
"profile": "https://github.com/ZZZooHaq",
32+
"contributions": [
33+
"ideas"
34+
]
35+
}
36+
],
37+
"contributorsPerLine": 7,
38+
"skipCi": true,
39+
"repoType": "github",
40+
"repoHost": "https://github.com",
41+
"projectName": "timetabl-app",
42+
"projectOwner": "debater-coder"
43+
}

README.md

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

36
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fdebater-coder%2Ftimetabl-app&env=VITE_CLIENT_ID&envDescription=The%20client%20id%20you%20entered%20in%20the%20student%20portal.)
47

@@ -20,6 +23,33 @@ Timetabl is built on three principles:
2023

2124
3. **Be secure**
2225
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.
26+
27+
## Contributors
28+
29+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
30+
<!-- prettier-ignore-start -->
31+
<!-- markdownlint-disable -->
32+
<table>
33+
<tbody>
34+
<tr>
35+
<td align="center"><a href="https://github.com/wensenfriendandextra"><img src="https://avatars.githubusercontent.com/u/23128324?v=4?s=100" width="100px;" alt="Wansen Dong"/><br /><sub><b>Wansen Dong</b></sub></a><br /><a href="https://github.com/debater-coder/timetabl-app/commits?author=wensenfriendandextra" title="Code">💻</a></td>
36+
<td align="center"><a href="https://github.com/debater-coder"><img src="https://avatars.githubusercontent.com/u/52619668?v=4?s=100" width="100px;" alt="debater-coder"/><br /><sub><b>debater-coder</b></sub></a><br /><a href="https://github.com/debater-coder/timetabl-app/commits?author=debater-coder" title="Code">💻</a></td>
37+
<td align="center"><a href="https://github.com/ZZZooHaq"><img src="https://avatars.githubusercontent.com/u/88522048?v=4?s=100" width="100px;" alt="ZZZooHaq"/><br /><sub><b>ZZZooHaq</b></sub></a><br /><a href="#ideas-ZZZooHaq" title="Ideas, Planning, & Feedback">🤔</a></td>
38+
</tr>
39+
</tbody>
40+
</table>
41+
42+
<!-- markdownlint-restore -->
43+
<!-- prettier-ignore-end -->
44+
45+
<!-- ALL-CONTRIBUTORS-LIST:END -->
46+
<!-- prettier-ignore-start -->
47+
<!-- markdownlint-disable -->
48+
49+
<!-- markdownlint-restore -->
50+
<!-- prettier-ignore-end -->
51+
52+
<!-- ALL-CONTRIBUTORS-LIST:END -->
2353

2454
## For Contributors
2555

src/components/DTTPeriod/DTTPeriod.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import { Period } from "../Period";
88
export const DTTPeriod = ({
99
period,
1010
isLoaded,
11-
date,
11+
active,
1212
}: {
1313
period: TimetablPeriod;
1414
isLoaded: boolean;
15-
date?: string;
15+
active: boolean;
1616
}) => {
1717
const {
1818
showTimesInsteadOfRooms,
@@ -28,11 +28,7 @@ export const DTTPeriod = ({
2828

2929
return (
3030
<Period
31-
active={
32-
(DateTime.fromISO(`${date}T${period.time}`) < DateTime.now() &&
33-
DateTime.now() < DateTime.fromISO(`${date}T${period.endTime}`)) ??
34-
false
35-
}
31+
active={active}
3632
colour={
3733
period.room &&
3834
{
@@ -44,14 +40,14 @@ export const DTTPeriod = ({
4440
leftContent={period.name}
4541
leftContentSize={"xs"}
4642
transition={
47-
period?.name == "Transition" ||
48-
DateTime.fromISO("15:15") <= DateTime.fromISO(period.time) ||
49-
DateTime.fromISO(period.time) <= DateTime.fromISO("09:00")
43+
period?.name === "Transition" ||
44+
DateTime.fromISO(`${period?.date}T15:15`) <= period.time ||
45+
period.time <= DateTime.fromISO(`${period?.date}T09:00`)
5046
}
5147
isLoaded={isLoaded}
5248
rightContent={
5349
showTimesInsteadOfRooms === "true" ? (
54-
period.time
50+
period?.time?.toLocaleString(DateTime.TIME_SIMPLE)
5551
) : period.room ? (
5652
<chakra.span
5753
bg={period.roomTo && "primary.100"}
@@ -62,12 +58,15 @@ export const DTTPeriod = ({
6258
{period.roomTo ?? period.room}
6359
</chakra.span>
6460
) : (
65-
period.time
61+
period?.time?.toLocaleString(DateTime.TIME_SIMPLE)
6662
)
6763
}
6864
expandedContent={
6965
<>
70-
at {showTimesInsteadOfRooms !== "true" ? period.time : period.room}{" "}
66+
at{" "}
67+
{showTimesInsteadOfRooms !== "true"
68+
? period?.time?.toLocaleString(DateTime.TIME_SIMPLE)
69+
: period.room}{" "}
7170
with{" "}
7271
<chakra.span
7372
bg={period.casual && "primary.100"}

src/hooks/sbhsQuery/use/useDTT.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1+
import { DateTime } from "luxon";
12
import { fetchDayTimetable } from "../fetch";
2-
import { APIPeriod } from "../fetch/fetchDayTimetable";
3+
import { APIDTT, APIPeriod } from "../fetch/fetchDayTimetable";
34
import { useSBHSQuery } from "./useSBHSQuery";
45

56
export type TimetablPeriod = {
67
name?: string;
78
room?: string;
89
teacher?: string;
9-
time?: string;
10-
endTime?: string;
10+
time?: DateTime;
11+
endTime?: DateTime;
1112
colour?: string;
1213
key?: string;
1314
casual?: string;
1415
roomTo?: string;
16+
date?: string;
1517
};
1618

1719
export type TimetablDTT = {
@@ -38,7 +40,7 @@ const formatCasual = (casual?: string) => {
3840
* @returns Query result for daily timetable.
3941
*/
4042
export const useDTT = (enabled?: boolean, date?: string) =>
41-
useSBHSQuery(
43+
useSBHSQuery<{ date: string }, APIDTT, TimetablDTT>(
4244
"timetable/daytimetable.json",
4345
fetchDayTimetable,
4446
{ date },
@@ -48,7 +50,7 @@ export const useDTT = (enabled?: boolean, date?: string) =>
4850

4951
const result = {
5052
periods: (data?.bells ?? [])
51-
.map((bell, index, bells) => {
53+
.flatMap((bell, index, bells) => {
5254
const timetable = data?.timetable;
5355
const subjects = timetable?.subjects;
5456
const period: APIPeriod =
@@ -85,26 +87,27 @@ export const useDTT = (enabled?: boolean, date?: string) =>
8587
return [
8688
{
8789
name: "Transition",
88-
endTime: bell?.startTime,
89-
time: bells?.[index - 1]?.endTime ?? "00:00",
90+
endTime: DateTime.fromISO(`${data?.date}T${bell?.startTime}`),
91+
time: DateTime.fromISO(bells?.[index - 1]?.endTime ?? "00:00"),
92+
date: data?.date,
9093
},
9194
{
9295
name,
9396
room: period?.room,
9497
teacher,
95-
time: bell?.startTime,
96-
endTime: bell?.endTime,
98+
time: DateTime.fromISO(`${data?.date}T${bell?.startTime}`),
99+
endTime: DateTime.fromISO(`${data?.date}T${bell?.endTime}`),
97100
colour:
98101
subject?.colour && period?.room
99102
? `#${subject?.colour}`
100103
: "transparent",
101104
key: bell?.bell,
102105
casual,
103106
roomTo,
107+
date: data?.date,
104108
},
105109
];
106110
})
107-
.flat()
108111
.filter((period) => period?.time !== period?.endTime),
109112
date: data?.date,
110113
};

src/routes/Landing/Footer.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
ButtonGroup,
66
IconButton,
77
Link,
8+
Box,
89
} from "@chakra-ui/react";
910
import { TimetablLogo } from "../../components/Nav/Nav";
1011
import { FaGithub } from "react-icons/fa";
@@ -34,7 +35,8 @@ export const Footer = () => {
3435
</ButtonGroup>
3536
</Stack>
3637
<Text fontSize="sm" color="subtle">
37-
&copy; {new Date().getFullYear()}, Hamzah Ahmed under{" "}
38+
&copy; {new Date().getFullYear()}, Hamzah Ahmed and Timetabl
39+
Contributors under{" "}
3840
<Link
3941
href="https://github.com/debater-coder/timetabl-app/blob/main/LICENSE"
4042
color={"primary.500"}
@@ -43,6 +45,27 @@ export const Footer = () => {
4345
MIT License.
4446
</Link>
4547
</Text>
48+
<Box
49+
mt="6"
50+
fontSize="sm"
51+
fontWeight="semibold"
52+
display="inline-block"
53+
bg="black"
54+
color="white"
55+
px="4"
56+
py="2"
57+
rounded="lg"
58+
alignSelf={"center"}
59+
as="a"
60+
target="_blank"
61+
href="https://vercel.com"
62+
>
63+
Deployed by{" "}
64+
<span role="img" aria-label="Vercel logo">
65+
66+
</span>{" "}
67+
Vercel
68+
</Box>
4669
</Stack>
4770
);
4871
};

src/routes/Main/Home/Home.tsx

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import "@fontsource/poppins";
1111
import { motion, LayoutGroup, AnimatePresence } from "framer-motion";
1212
import QueriesHandler from "../../../components/QueriesHandler";
13-
import { useEffect, useState } from "react";
13+
import { useState } from "react";
1414
import { ArrowLeft, ArrowRight } from "phosphor-react";
1515
import { DateTime } from "luxon";
1616
import Empty from "./../../../components/Empty";
@@ -54,14 +54,22 @@ const HomeView = ({
5454
room: 605,
5555
});
5656

57-
useEffect(() => {
58-
if (initialDate === date) {
59-
onDateChange();
60-
}
61-
}, [initialDate, date, onDateChange]);
57+
// useEffect(() => {
58+
// if (initialDate === date) {
59+
// onDateChange();
60+
// }
61+
// }, [initialDate, date, onDateChange]);
6262

6363
const [countdown, setCountdown] = useState("");
6464

65+
const activeIndex =
66+
date === initialDate
67+
? periods.findIndex(
68+
({ time, endTime }) =>
69+
time < DateTime.now() && DateTime.now() < endTime
70+
)
71+
: -1;
72+
6573
return (
6674
<LayoutGroup>
6775
<Flex direction={"column"} align="center" gap={1.5}>
@@ -118,9 +126,10 @@ const HomeView = ({
118126
</Flex>
119127
<Flex
120128
direction={"column"}
121-
bg={
122-
useToken("colors", useColorModeValue("gray.300", "gray.500")) + "33"
123-
}
129+
bg={`${useToken(
130+
"colors",
131+
useColorModeValue("gray.300", "gray.500")
132+
)}33`}
124133
minW={"50vw"}
125134
rounded={10}
126135
as={motion.div}
@@ -129,6 +138,7 @@ const HomeView = ({
129138
{periods.length ? (
130139
periods.map((period, index) => (
131140
<DTTPeriod
141+
active={activeIndex === index}
132142
period={period}
133143
key={period.key ?? index + 100}
134144
isLoaded={isLoaded}

src/routes/Main/Home/NextPeriod.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,20 @@ type NextPeriodProps = {
1515

1616
export default ({
1717
periods,
18-
date,
1918
countdown,
2019
setCountdown,
2120
isLoaded,
2221
}: NextPeriodProps) => {
2322
const activePeriod = periods.findIndex(
24-
({ time, endTime }: { time: string; endTime: string }) =>
25-
(DateTime.fromISO(`${date}T${time}`) < DateTime.now() &&
26-
DateTime.now() < DateTime.fromISO(`${date}T${endTime}`)) ??
27-
false
23+
({ time, endTime }) =>
24+
(time < DateTime.now() && DateTime.now() < endTime) ?? false
2825
);
2926

3027
const nextPeriod = periods[activePeriod + 1];
3128

3229
useEffect(() => {
3330
const timer = setInterval(() => {
34-
setCountdown(
35-
DateTime.fromISO(`${date}T${nextPeriod.time}`)
36-
.diffNow()
37-
.toFormat("hh:mm:ss")
38-
);
31+
setCountdown(nextPeriod.time.diffNow().toFormat("hh:mm:ss"));
3932
}, 500);
4033

4134
return () => clearInterval(timer);
@@ -58,8 +51,9 @@ export default ({
5851
leftContentSize={"lg"}
5952
rightContent={
6053
showTimesInsteadOfRooms === "true"
61-
? nextPeriod.time
62-
: nextPeriod.room ?? nextPeriod.time
54+
? nextPeriod?.time?.toLocaleString(DateTime.TIME_SIMPLE)
55+
: nextPeriod.room ??
56+
nextPeriod?.time?.toLocaleString(DateTime.TIME_SIMPLE)
6357
}
6458
expandedContent={<>IN {countdown}</>}
6559
expandedSize={"xl"}

0 commit comments

Comments
 (0)