Skip to content

Commit

Permalink
Merge branch 'main' into v6ctor-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
DCRepublic committed Nov 18, 2024
2 parents 07cec38 + 88aa1d8 commit 3558b6d
Show file tree
Hide file tree
Showing 13 changed files with 351 additions and 275 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ name: Mirror
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
Expand Down
4 changes: 2 additions & 2 deletions app/admin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ export default function AdminPage() {
if (status === "authenticated") {
if (session.user?.role === "admin") {
return (
<div className="w-[90vw]">
<div>
<Table
isHeaderSticky
className="overflow-scroll scrollbar-thin scrollbar-thumb-accent-500 scrollbar-track-transparent"
className="overflow-scroll scrollbar-thin scrollbar-thumb-accent-500 scrollbar-track-transparent h-[80vh] p-4"
fullWidth
aria-label="Rating table with dynamic content(ratings)"
>
Expand Down
182 changes: 97 additions & 85 deletions app/calendar/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,110 +5,122 @@ import Calendar from "../../components/Calendar";
import prisma from "../../lib/prisma";
import { getPlanCookie } from "../actions/actions";
import { generateColorFromName } from "../../components/primitives";
export default async function CalendarPage() {
async function getEvents() {
const output: any = [];
const planCookie: any = await getPlanCookie();

let courses;
interface Event {
classNames: string;
textColor: string;
title: string;
daColor: string;
subject: string;
courseNumber: string;
instructor: string;
room: string;
color: string;
borderWidth: string;
daysOfWeek: (false | "0" | "1" | "2" | "3" | "4" | "5" | "6" | undefined)[];
startTime: string;
endTime: string;
}

if (planCookie) {
const plan = await prisma.coursePlan.findUnique({
where: {
id: parseInt(planCookie),
},
include: {
courses: true,
async function getEvents(): Promise<Event[]> {
"use server";
const output: Event[] = [];
const planCookie: any = await getPlanCookie();

let courses;

if (planCookie) {
const plan = await prisma.coursePlan.findUnique({
where: {
id: parseInt(planCookie),
},
include: {
courses: {
include: {
instructor: true,
facultyMeet: {
include: {
meetingTimes: true,
},
},
},
},
});
},
});

courses = plan?.courses;
}
courses = plan?.courses;
}

if (courses) {
for (let i = 0; i < courses.length; i++) {
const color = generateColorFromName(courses[i].subject);
if (courses) {
for (let i = 0; i < courses.length; i++) {
const color = generateColorFromName(courses[i].subject);

const num: string = courses[i].courseReferenceNumber;
const meetingTimes = await prisma.meetingTime.findFirst({
where: {
courseReferenceNumber: num,
},
});
const num: string = courses[i].courseReferenceNumber;
const meetingTimes = await prisma.meetingTime.findFirst({
where: {
courseReferenceNumber: num,
},
});

output.push({
classNames: "font-sans",
textColor: "white",
title: courses[i]?.courseTitle,
daColor: color,
subject: courses[i]?.subject,
color: "rgba(0,0,0,0)",
output.push({
classNames: "font-sans",
textColor: "white",
title: courses[i]?.courseTitle,
daColor: color,
subject: courses[i]?.subject,
courseNumber: courses[i]?.courseNumber,
instructor: courses[i]?.instructor.displayName,
room:
courses[i]?.facultyMeet.meetingTimes.building +
" " +
courses[i]?.facultyMeet.meetingTimes.room,
color: "rgba(0,0,0,0)",

borderWidth: "0px",
daysOfWeek: [
meetingTimes?.sunday && "0",
meetingTimes?.monday && "1",
meetingTimes?.tuesday && "2",
meetingTimes?.wednesday && "3",
meetingTimes?.thursday && "4",
meetingTimes?.friday && "5",
meetingTimes?.saturday && "6",
],
borderWidth: "0px",
daysOfWeek: [
meetingTimes?.sunday && "0",
meetingTimes?.monday && "1",
meetingTimes?.tuesday && "2",
meetingTimes?.wednesday && "3",
meetingTimes?.thursday && "4",
meetingTimes?.friday && "5",
meetingTimes?.saturday && "6",
],

startTime:
meetingTimes?.beginTime.slice(0, 2) +
":" +
meetingTimes?.beginTime.slice(2),
endTime:
meetingTimes?.endTime.slice(0, 2) +
":" +
meetingTimes?.endTime.slice(2),
});
}
startTime:
meetingTimes?.beginTime.slice(0, 2) +
":" +
meetingTimes?.beginTime.slice(2),
endTime:
meetingTimes?.endTime.slice(0, 2) +
":" +
meetingTimes?.endTime.slice(2),
});
}

return output;
}

async function getUniqueStartEndTimes() {
const maxstart = await prisma.meetingTime.findFirst({
where: {
beginTime: { not: "" },
},
orderBy: {
beginTime: "desc",
},
});
const maxend = await prisma.meetingTime.findFirst({
where: {
endTime: { not: "" },
},
orderBy: {
beginTime: "desc",
},
});
return output;
}

/*
let times = {
minTime:
maxstart?.beginTime.slice(0, 2) + ":" + maxstart?.beginTime.slice(2),
maxTime:
maxstart?.endTime.slice(0, 2) + ":" + maxstart?.beginTime.slice(2),
};*/
console.log(maxstart);
export default async function CalendarPage() {
const events: Event[] = await getEvents();
let endTime = "17:00";
let startTime = "09:00";

return maxstart;
for (const event of events) {
if (event.startTime < startTime && event.startTime != ":")
startTime = event.startTime;
if (event.endTime > endTime && event.endTime != ":")
endTime = event.endTime;
}

const events = await getEvents();

//let times = await getUniqueStartEndTimes();
return (
<div className="grid grid-cols-3 p-4 w-screen absolute start-0 px-32 gap-20">
<div className=" col-start-1 h-[70vh] w-[57vw] col-span-2 font-sans font-normal">
<Calendar events={events} />
<div className="grid grid-cols-10 grid-rows-2 sm:grid-rows-1 p-3 lg:p-4">
<div className="sm:h-[75vh] col-span-10 md:col-span-7 font-sans font-normal flex-col">
<Calendar events={events} startTime={startTime} endTime={endTime} />
</div>
<div className="col-start-3 h-[62vh] ">
<div className="sm:h-[62vh] col-span-10 sm:col-span-3 sm:ml-[5vw]">
<CreatePlan />
</div>
</div>
Expand Down
30 changes: 3 additions & 27 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { NextAuthProvider } from "../components/providers/NextAuthProvider";
import { siteConfig } from "../config/site";
import { fontSans } from "../config/fonts";
import { Navbar } from "../components/navbar";
import FooterInfo from "../components/FooterInfo";

import { Providers } from "./providers";

Expand Down Expand Up @@ -54,35 +55,10 @@ export default function RootLayout({
>
<div className="flex flex-col h-screen ">
<Navbar />
<main className="container mx-auto px-1 lg:px-7 lg:pt-10 justify-center items-center flex-grow">
<main className="container mx-auto px-1 lg:px-7 lg:pt-10 justify-center items-center flex-grow ">
{children}
</main>
<footer className="w-full flex items-center justify-center py-3">
<div className="columns-1 container max-w-4xl text-center">
<span className="text-xs">
The Course Planner is a student-run service, and displays
classes from the Tri-College course database. We recommend
confirming your schedule with the official course listings
just in case. If there are any issues, email us.
</span>
<br />

<div className="space-x-5">
<Link
isExternal
href="https://www.sccs.swarthmore.edu/docs/policy"
title="SCCS Usage & Data Policy"
>
<span className=" text-xs underline ">
Usage & Data Policy
</span>
</Link>
<span className="text-xs ">
© 2024 Swarthmore College Computer Society | v2.0.0
</span>
</div>
</div>
</footer>
<FooterInfo />
</div>
</Providers>
</body>
Expand Down
2 changes: 1 addition & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default async function Page(props: {
homePageProps["createPlan"] = (
<Suspense
fallback={
<Skeleton className="rounded-lg w-8/12 h-full align-top justify-start" />
<Skeleton className="rounded-lg w-8/12 h-fit align-top justify-start" />
}
>
<CreatePlan />
Expand Down
56 changes: 31 additions & 25 deletions components/Calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
"use client";

import {
DayHeaderContentArg,
EventContentArg,
EventSourceInput,
} from "@fullcalendar/core";
import FullCalendar from "@fullcalendar/react";
import timeGridPlugin from "@fullcalendar/timegrid"; // a plugin!
import { Card } from "@nextui-org/react";
import moment from "moment";

export default function Calendar(props: any) {
function dayHeaderContent(args: any) {
export default function Calendar({
events,
startTime,
endTime,
}: {
events: EventSourceInput | undefined;
startTime: string;
endTime: string;
}) {
function dayHeaderContent(args: DayHeaderContentArg) {
return moment(args.date).format("ddd");
}

function renderEventContent(eventInfo: any) {
console.log(eventInfo);

function renderEventContent(eventInfo: EventContentArg) {
return (
<Card
className="fc-event-main-frame w-[100%] rounded-md hover:h-[20vh] ease-in-out z-0 hover:z-10 hover:transition-all duration-700 "
className="fc-event-main-frame w-[100%] rounded-md group min-h-0 hover:min-h-28 ease-in-out px-1 z-0 hover:z-10 hover:transition-all duration-700 "
style={{ backgroundColor: eventInfo.event.extendedProps.daColor }}
>
{/*
<div
className={`absolute top-0 left-0 h-full w-2 rounded-full`}
style={{
backgroundColor: generateColorFromName(
eventInfo.event.extendedProps.subject
),
}}
/>
*/}
<b className="font-sans text-[10px] font-normal">
{eventInfo.timeText} {"|"} {eventInfo.event.extendedProps.room}
</b>
<div className="font-sans text-[12px] font-bold inline">
{eventInfo.event.extendedProps.subject}
{eventInfo.event.extendedProps.courseNumber} :
<p className="font-normal inline"> {eventInfo.event.title}</p>
</div>

<b className="font-sans text-[9px] ml-1 mt-1">{eventInfo.timeText}</b>
<div className="font-sans text-[10px] ml-1 ">
{eventInfo.event.title}
<div className="transition-all opacity-0 group-hover:opacity-100 font-sans text-[10px] mt-5 ">
{eventInfo.event.extendedProps.instructor.replace("&#39;", "'")}
</div>
</Card>
);
Expand All @@ -43,17 +49,17 @@ export default function Calendar(props: any) {
<FullCalendar
expandRows
allDaySlot={false}
dayHeaderFormat={dayHeaderContent}
dayHeaderContent={dayHeaderContent}
editable={false}
eventContent={renderEventContent}
events={props.events}
events={events}
headerToolbar={false}
height="100%"
initialView="timeGridWeek"
plugins={[timeGridPlugin]}
slotDuration="01:00:00"
slotMaxTime="23:00:00"
slotMinTime="08:00:00"
slotMaxTime={endTime}
slotMinTime={startTime}
weekends={false}
/>
);
Expand Down
Loading

0 comments on commit 3558b6d

Please sign in to comment.