diff --git a/components/CourseCard.tsx b/components/CourseCard.tsx index 6763a80..d1238b7 100644 --- a/components/CourseCard.tsx +++ b/components/CourseCard.tsx @@ -2,6 +2,7 @@ import { Card, CardBody, + CardHeader, Divider, Link, User, @@ -10,26 +11,25 @@ import { PopoverContent, Button, } from "@nextui-org/react"; +import Image from "next/image"; import { tv } from "tailwind-variants"; import { generateColorFromName } from "../components/primitives"; import { ScrollShadow } from "@nextui-org/react"; import { InstructorCard } from "./InstructorCard"; import AddIcon from "@mui/icons-material/Add"; -import moment from "moment"; +import ErrorRoundedIcon from '@mui/icons-material/ErrorRounded'; + import axios from "axios"; + export const card = tv({ slots: { - base: "bg-light_foreground min-h-48 max-h-48 w-[98%] rounded-sm scroll-none drop-shadow-lg transition-colors", + base: "bg-light_foreground min-h-32 max-h-62 w-[98%] rounded-sm scroll-none drop-shadow-lg transition-colors", role: "font-bold text-primary ", }, }); -const { - base, - - role, -} = card(); +const { base, role } = card(); async function updatePlan(course: any) { console.log("updating"); @@ -38,7 +38,7 @@ async function updatePlan(course: any) { course: course, }) .then(function (response) { - //console.log(response); + // Handle response }) .catch(function (error) { console.log(error); @@ -46,207 +46,131 @@ async function updatePlan(course: any) { } export default function CourseCard(props: any) { + console.log(props.course) let color = generateColorFromName(props.course.subject); + const color_mappings: { [key: string]: string } = { + "0": "#4CB944", + "1": "#fb5607", + "2": "#ff006e", + "3": "#8338ec", + "4": "#3a86ff", + }; + + const days = { + "M": props.course.facultyMeet.meetingTimes.monday, + "T": props.course.facultyMeet.meetingTimes.tuesday, + "W": props.course.facultyMeet.meetingTimes.wednesday, + "TH": props.course.facultyMeet.meetingTimes.thursday, + "F": props.course.facultyMeet.meetingTimes.friday + }; + + const coloredDays = Object.entries(days).map((item, index) => { + if (item[1]) { + return ( +
+

{item[0]}

+
+ ); + } + return null; + }); + + const attributeCodes = props.course.sectionAttributes.map((item, index: number) => { + if (item) { + return

{item.code}

+ } + + return null; + }); + return (
- - updatePlan(props.course)} - > - {/* 3 cols 2 rows*/} -
-
-

- {props.course.subject + - " " + - props.course.courseNumber + - " - " + - props.course.courseTitle + - " (" + - props.course.facultyMeet.category + - ")" + - " " + - props.course.year} -

-
-
- -
-
- {props.course.instructor ? ( - - - - - - - - - ) : null} -
- -
-
{props.course.creditHours} credit(s)
-
-
- {/*props.course.courseReferenceNumber.replace( - props.course.year, - "" - )*/} -
- -
- {/* */} - {props.course.enrollment}/{props.course.maximumEnrollment} -
- -
-
Attributes
- {props.course.sectionAttributes.map((attribute: any) => ( -
- {attribute.code} -
- ))} -
- - {props.course.facultyMeet.meetingTimes ? ( -
-

Days

-
- {props.course.facultyMeet.meetingTimes.monday ? "M" : null}{" "} - {props.course.facultyMeet.meetingTimes.tuesday ? "T" : null}{" "} - {props.course.facultyMeet.meetingTimes.wednesday ? "W" : null}{" "} - {props.course.facultyMeet.meetingTimes.thursday ? "TH" : null}{" "} - {props.course.facultyMeet.meetingTimes.friday ? "F" : null}{" "} - {props.course.facultyMeet.meetingTimes.saturday ? "Sat" : null}{" "} - {props.course.facultyMeet.meetingTimes.sunday ? "Sun" : null} -
+
+ +
+
+

+ {props.course.courseTitle} +

+

+ {props.course.subject} {props.course.courseNumber} |{" "} + {props.course.creditHours} credit(s) | + {props.course.sectionAttributes.length > 0 && attributeCodes} +

- ) : null} - {props.course.facultyMeet.meetingTimes ? ( -
-

Time

-
- {moment( - props.course.facultyMeet.meetingTimes.beginTime.slice(0, 2) + - ":" + - props.course.facultyMeet.meetingTimes.beginTime.slice(2), - "HH:mm" - ).format("hh:mm a")} - - - {moment( - props.course.facultyMeet.meetingTimes.endTime.slice(0, 2) + - ":" + - props.course.facultyMeet.meetingTimes.endTime.slice(2), - "HH:mm" - ).format("hh:mm a")} -
+
+ Professor
- ) : null} - - {/* -
-
-

Availability

-
- {props.course.enrollment}/{props.course.maximumEnrollment} +
+ + + +
+
+ {props.course.facultyMeet.meetingTimes.room ? (
+

+ {props.course.facultyMeet.meetingTimes.buildingDescription}{" "} + {props.course.facultyMeet.meetingTimes.room} +

+
+ {props.course.facultyMeet.meetingTimes ? ( +
+

+ {" "} + {props.course.facultyMeet.meetingTimes.beginTime.slice(0, 2) + + ":" + + props.course.facultyMeet.meetingTimes.beginTime.slice(2)}{" "} + -{" "} + {props.course.facultyMeet.meetingTimes.endTime.slice(0, 2) + + ":" + + props.course.facultyMeet.meetingTimes.endTime.slice(2)} +

+
+ ) : null} +
+
) :
+

Contact your Professor for additional details.

+
} +
+
+ {coloredDays}
-
-

Attributes

- {props.course.sectionAttributes.map((attribute: any) => ( -
- {attribute.code} -
- ))} -
- - {props.course.facultyMeet.meetingTimes ? ( +
+
+
-

Days

-
- {props.course.facultyMeet.meetingTimes.monday ? "M" : null}{" "} - {props.course.facultyMeet.meetingTimes.tuesday ? "T" : null}{" "} - {props.course.facultyMeet.meetingTimes.wednesday - ? "W" - : null}{" "} - {props.course.facultyMeet.meetingTimes.thursday - ? "TH" - : null}{" "} - {props.course.facultyMeet.meetingTimes.friday ? "F" : null}{" "} - {props.course.facultyMeet.meetingTimes.saturday - ? "Sat" - : null}{" "} - {props.course.facultyMeet.meetingTimes.sunday - ? "Sun" - : null} -
+

Instructor

+

{props.course.instructor.displayName}

- ) : null} - - {props.course.facultyMeet.meetingTimes ? ( -
-

Time

-
- {" "} - {props.course.facultyMeet.meetingTimes.beginTime.slice( - 0, - 2 - ) + - ":" + - props.course.facultyMeet.meetingTimes.beginTime.slice( - 2 - )}{" "} - -{" "} - {props.course.facultyMeet.meetingTimes.endTime.slice(0, 2) + - ":" + - props.course.facultyMeet.meetingTimes.endTime.slice(2)} -
-
- ) : null} -
- {props.course.instructor ? ( -
-

Instructor

-
- {props.course.instructor.displayName} +
+

?

- ) : null} - {props.course.facultyMeet.meetingTimes ? ( -
-

Room

-

- {props.course.facultyMeet.meetingTimes.buildingDescription} - {
} - {props.course.facultyMeet.meetingTimes.room} -

-
- ) : null} - - */} -
- + {props.course.seatsAvailable >= 0 &&
+

No available seats left for this section

+ +
} +
+
+
+
); } diff --git a/next.config.js b/next.config.js index 767719f..73dc253 100644 --- a/next.config.js +++ b/next.config.js @@ -1,4 +1,8 @@ /** @type {import('next').NextConfig} */ -const nextConfig = {} +const nextConfig = { + images: { + domains: ["www.swarthmore.edu", "cdn.vectorstock.com"] + } +} module.exports = nextConfig diff --git a/swatscraper b/swatscraper index 6089f91..32a5d97 160000 --- a/swatscraper +++ b/swatscraper @@ -1 +1 @@ -Subproject commit 6089f9194726570223d8d85018e2a4377925366b +Subproject commit 32a5d975a8cbe906764c553846d220de1f0ed4ab