Skip to content

Commit f2477b3

Browse files
gxncanunom27
authored andcommitted
feat: events calendar page (#91)
1 parent ead3d0c commit f2477b3

26 files changed

+1158
-459
lines changed

bun.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"@hookform/resolvers": "^5.1.1",
99
"@tanstack/react-query": "^5.84.1",
1010
"@tanstack/react-query-devtools": "^5.84.1",
11+
"@types/chroma-js": "^3.1.1",
1112
"axios": "^1.10.0",
13+
"chroma-js": "^3.1.2",
1214
"clsx": "^2.1.1",
1315
"jwt-decode": "^4.0.0",
1416
"mime-types": "^3.0.1",
@@ -441,6 +443,8 @@
441443

442444
"@types/chai": ["@types/[email protected]", "", { "dependencies": { "@types/deep-eql": "*" } }, "sha512-8kB30R7Hwqf40JPiKhVzodJs2Qc1ZJ5zuT3uzw5Hq/dhNCl3G3l83jfpdI1e20BP348+fV7VIL/+FxaXkqBmWg=="],
443445

446+
"@types/chroma-js": ["@types/[email protected]", "", {}, "sha512-SFCr4edNkZ1bGaLzGz7rgR1bRzVX4MmMxwsIa3/Bh6ose8v+hRpneoizHv0KChdjxaXyjRtaMq7sCuZSzPomQA=="],
447+
444448
"@types/d3-array": ["@types/[email protected]", "", {}, "sha512-hOLWVbm7uRza0BYXpIIW5pxfrKe0W+D5lrFiAEYR+pb6w3N2SwSMaJbXdUfSEv+dT4MfHBLtn5js0LAWaO6otw=="],
445449

446450
"@types/d3-color": ["@types/[email protected]", "", {}, "sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A=="],
@@ -637,6 +641,8 @@
637641

638642
"chownr": ["[email protected]", "", {}, "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g=="],
639643

644+
"chroma-js": ["[email protected]", "", {}, "sha512-IJnETTalXbsLx1eKEgx19d5L6SRM7cH4vINw/99p/M11HCuXGRWL+6YmCm7FWFGIo6dtWuQoQi1dc5yQ7ESIHg=="],
645+
640646
"chromatic": ["[email protected]", "", { "peerDependencies": { "@chromatic-com/cypress": "^0.*.* || ^1.0.0", "@chromatic-com/playwright": "^0.*.* || ^1.0.0" }, "optionalPeers": ["@chromatic-com/cypress", "@chromatic-com/playwright"], "bin": { "chroma": "dist/bin.js", "chromatic": "dist/bin.js", "chromatic-cli": "dist/bin.js" } }, "sha512-GswmBW9ZptAoTns1BMyjbm55Z7EsIJnUvYKdQqXIBZIKbGErmpA+p4c0BYA+nzw5B0M+rb3Iqp1IaH8TFwIQew=="],
641647

642648
"client-only": ["[email protected]", "", {}, "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA=="],

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
"@hookform/resolvers": "^5.1.1",
1818
"@tanstack/react-query": "^5.84.1",
1919
"@tanstack/react-query-devtools": "^5.84.1",
20+
"@types/chroma-js": "^3.1.1",
2021
"axios": "^1.10.0",
22+
"chroma-js": "^3.1.2",
2123
"clsx": "^2.1.1",
2224
"jwt-decode": "^4.0.0",
2325
"mime-types": "^3.0.1",

src/app/(app)/page.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import EventsCalendar from "@/components/events-calendar";
2-
import CalendarOptions from "@/components/calendar-options";
2+
import { EventsProvider } from "@/contexts/events-provider";
3+
import EventsOptions from "@/components/calendarOptions/events-options";
34

45
export default function Home() {
56
return (
67
<div className="flex h-full flex-col-reverse gap-5 md:flex-row md:gap-8">
7-
<CalendarOptions />
8-
<EventsCalendar />
8+
<EventsProvider>
9+
<EventsOptions />
10+
<EventsCalendar />
11+
</EventsProvider>
912
</div>
1013
);
1114
}

src/app/(app)/schedule/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import ScheduleCalendar from "@/components/schedule-calendar";
22
import { ScheduleProvider } from "@/contexts/schedule-provider";
3-
import CalendarOptions from "@/components/calendar-options";
43
import { AuthCheck } from "@/components/auth-check";
4+
import ScheduleOptions from "@/components/calendarOptions/schedule-options";
55

66
export default function Schedule() {
77
return (
88
<AuthCheck userTypes={["student"]}>
99
<div className="flex h-full flex-col-reverse gap-5 md:flex-row md:gap-8">
1010
<ScheduleProvider>
11-
<CalendarOptions schedule />
11+
<ScheduleOptions />
1212
<ScheduleCalendar />
1313
</ScheduleProvider>
1414
</div>

src/app/globals.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ input[type="number"] {
291291
font-weight: 600;
292292
border-radius: 6px !important;
293293
overflow: hidden !important;
294-
padding: 0px !important;
295294
}
296295

297296
@media (max-width: 640px) {
@@ -349,6 +348,10 @@ input[type="number"] {
349348
padding: 0px 4px 0px 4px !important;
350349
}
351350

351+
.schedule .rbc-event {
352+
padding: 0 !important;
353+
}
354+
352355
.schedule .rbc-event-content {
353356
padding: 2px !important;
354357
}

src/components/animated-options-section.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use client";
2-
import { ScheduleContext } from "@/contexts/schedule-provider";
2+
import { IEvent, IShift } from "@/lib/types";
33
import clsx from "clsx";
44
import { motion, AnimatePresence } from "motion/react";
55
import {
@@ -12,15 +12,18 @@ import {
1212
useCallback,
1313
useMemo,
1414
Children,
15-
useContext,
1615
} from "react";
1716
import { twMerge } from "tailwind-merge";
1817

19-
interface IAnimatedOptionsSection {
18+
interface IAnimatedOptionsSection<T = IShift | IEvent> {
2019
children: [ReactNode, ReactNode];
2120
title?: string;
2221
titleEdit?: string;
2322
classNameOpenedSection?: string;
23+
isEditing: boolean;
24+
setIsEditing: (prev: boolean) => void;
25+
setEditingItems: (prev: T[]) => void;
26+
currentItems: T[];
2427
}
2528

2629
const useIsMobile = () => {
@@ -41,26 +44,29 @@ const useIsMobile = () => {
4144
return { isMobile, viewportHeight };
4245
};
4346

44-
export default function AnimatedOptionsSection({
47+
export default function AnimatedOptionsSection<T = IShift | IEvent>({
4548
children,
4649
title = "Options",
4750
titleEdit = "Edit Options",
4851
classNameOpenedSection,
49-
}: IAnimatedOptionsSection) {
52+
isEditing,
53+
setIsEditing,
54+
setEditingItems,
55+
currentItems,
56+
}: IAnimatedOptionsSection<T>) {
5057
const [isOpen, setIsOpen] = useState(false);
5158

52-
const { isEditing, setIsEditing, setEditingShifts, currentSchedule } =
53-
useContext(ScheduleContext);
54-
5559
const handleClose = useCallback(() => {
5660
setIsOpen(false);
5761
setIsEditing(false);
5862
}, [setIsEditing]);
5963

6064
const handleEditClick = useCallback(() => {
61-
if (isEditing) setEditingShifts([...currentSchedule]);
65+
if (isEditing) {
66+
setEditingItems([...currentItems]);
67+
}
6268
setIsEditing(!isEditing);
63-
}, [isEditing, setIsEditing, setEditingShifts, currentSchedule]);
69+
}, [isEditing, setIsEditing, setEditingItems, currentItems]);
6470

6571
const handleMotionClick = useCallback(() => {
6672
if (!isOpen) {

0 commit comments

Comments
 (0)