Skip to content

Commit

Permalink
Refactor Schedule (#130)
Browse files Browse the repository at this point in the history
* refactor: move schedule page from views to app

* refactor: reexport component

* refactor: arrow functions and reorganization
  • Loading branch information
alexanderl19 committed Nov 3, 2023
1 parent 10fe97c commit 48fba6f
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
"use client";

import Image from "next/image";
import { cubicBezier, motion, Variants } from "framer-motion";

import Accordion from "react-bootstrap/Accordion";
import Col from "react-bootstrap/Col";
import Container from "react-bootstrap/Container";
import Row from "react-bootstrap/Row";
import { cubicBezier, motion, Variants } from "framer-motion";
import { utcToZonedTime } from "date-fns-tz";

import clip from "@/assets/images/clip.svg";

import styles from "./ClipboardSchedule.module.scss";
import Countdown from "../../components/Countdown/Countdown";

interface ClipboardScheduleProps {
schedule: {
title: string;
location?: string | undefined;
virtual?: string | undefined;
startTime: Date;
endTime: Date;
organization?: string | undefined;
hosts?: string[] | undefined;
description: JSX.Element;
}[][];
}
import Countdown from "./Countdown";

const dateTimeFormat = new Intl.DateTimeFormat("en", {
hour: "numeric",
Expand Down Expand Up @@ -57,7 +43,20 @@ const variant: Variants = {
},
};

function ClipboardSchedule({ schedule }: ClipboardScheduleProps) {
interface ClipboardScheduleProps {
schedule: {
title: string;
location?: string | undefined;
virtual?: string | undefined;
startTime: Date;
endTime: Date;
organization?: string | undefined;
hosts?: string[] | undefined;
description: JSX.Element;
}[][];
}

const ClipboardSchedule: React.FC<ClipboardScheduleProps> = ({ schedule }) => {
return (
<Container as="section" className={" px-0 pt-0 position-relative"}>
<div className={styles.clip}>
Expand Down Expand Up @@ -139,6 +138,6 @@ function ClipboardSchedule({ schedule }: ClipboardScheduleProps) {
</div>
</Container>
);
}
};

export default ClipboardSchedule;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import styles from "./Countdown.module.scss";
// 10/4/23 10AM in UTC
const hackingStarts = new Date(Date.UTC(2023, 10, 4, 17, 0, 0));

export default function Countdown() {
const Countdown = () => {
const [remainingSeconds, setRemainingSeconds] = useState<number>(NaN);

useEffect(() => {
Expand Down Expand Up @@ -50,4 +50,6 @@ export default function Countdown() {
<span className={styles.caption}>Until Hacking Begins</span>
</div>
);
}
};

export default Countdown;
1 change: 1 addition & 0 deletions apps/site/src/app/schedule/ClipboardSchedule/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./ClipboardSchedule";
File renamed without changes.
File renamed without changes.
28 changes: 21 additions & 7 deletions apps/site/src/app/schedule/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import { Schedule } from "@/views";
import { Maintenance } from "@/views";
import { PortableText } from "@portabletext/react";
import ClipboardSchedule from "./ClipboardSchedule";
import { getSchedule } from "./getSchedule";

export const revalidate = 60;

// When set to any value
const Component = process.env.MAINTENANCE_MODE_SCHEDULE
? Maintenance
: Schedule;
import styles from "./page.module.scss";

export default Component;
export default async function Schedule() {
const days = await getSchedule();

const schedule = days.map((events) =>
events.map(({ description, ...event }) => ({
...event,
description: <PortableText value={description} />,
})),
);

return (
<div className={styles.schedule}>
<h1>Schedule</h1>
<ClipboardSchedule schedule={schedule} />
</div>
);
}
23 changes: 0 additions & 23 deletions apps/site/src/views/Schedule/Schedule.tsx

This file was deleted.

1 change: 0 additions & 1 deletion apps/site/src/views/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export { default as Maintenance } from "./Maintenance/Maintenance";
export { default as Resources } from "./Resources/Resources";
export { default as Schedule } from "./Schedule/Schedule";

0 comments on commit 48fba6f

Please sign in to comment.