Skip to content

Commit

Permalink
refactor: CollegeObject -> CourseObject
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinWu098 committed Apr 3, 2024
1 parent 963a602 commit 0c97afc
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
8 changes: 4 additions & 4 deletions components/search/Blurb.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import { CollegeObject, FilterValues } from "./Search";
import { CourseObject, FilterValues } from "./Search";

interface BlurbProps {
filterData: (
data: CollegeObject[],
data: CourseObject[],
filterValues: FilterValues,
) => CollegeObject[];
data: CollegeObject[] | undefined;
) => CourseObject[];
data: CourseObject[] | undefined;
filterValues: FilterValues;
}

Expand Down
20 changes: 11 additions & 9 deletions components/search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,30 @@ import Link from "next/link";
import { SearchSelect } from "./SearchSelect";
import { getDismissedRecently, getNumSearches } from "@/lib/utils/search";

export interface CollegeObject {
export interface CourseObject {
sendingInstitution: string;
courseCode: string;
courseName: string;
cvcId: string;
assistPath: string;
niceToHaves: string[];
units: number;
term: string;
startMonth: number;
startDay: number;
endMonth: number;
endDay: number;
tuition: number;
startDate: number;
endDate: number;
async: boolean;
hasOpenSeats: boolean;
hasPrereqs: boolean;
instantEnrollment: boolean;
fulfillsGEs: string[];
fulfillsGEs: FullFillsGE[];
articulatesTo: string[];
assistPath: string;
}

type FullFillsGE = {
category: string;
count: number;
};

export type FilterValues = {
format: boolean[];
enrollment: boolean[];
Expand Down Expand Up @@ -112,7 +114,7 @@ const Search = () => {

const [sort, setSort] = useState("Default Sort");

const [courses, setCourses] = useState<CollegeObject[]>();
const [courses, setCourses] = useState<CourseObject[]>();

const [filterValues, setFilterValues] = useState<FilterValues>({
format: format,
Expand Down
6 changes: 3 additions & 3 deletions components/search/filter/FilterComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import React, { ChangeEvent, Dispatch, SetStateAction, useState } from "react";
import { FaCheck } from "react-icons/fa";
import { CollegeObject } from "../Search";
import { CourseObject } from "../Search";
import { format } from "date-fns";

import { Calendar } from "@/components/ui/calendar";
Expand Down Expand Up @@ -185,7 +185,7 @@ export const CalendarFilter = (props: CalendarFilterProps) => {

interface InstitutionDropdownProps {
defaultValue: string;
courses: CollegeObject[] | undefined;
courses: CourseObject[] | undefined;
onChange: Dispatch<SetStateAction<string>>;
}

Expand All @@ -203,7 +203,7 @@ export const InstitutionDropdown = (props: InstitutionDropdownProps) => {
defaultValue == "Any Institution" ? [] : [defaultValue];

const sendingInstitutions = courses?.map(
(course: CollegeObject) => course.sendingInstitution,
(course: CourseObject) => course.sendingInstitution,
);

if (sendingInstitutions) {
Expand Down
4 changes: 2 additions & 2 deletions components/search/filter/Filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
UnitsFilter,
} from "./FilterComponents";
import { FaCircleXmark } from "react-icons/fa6";
import { CollegeObject, FilterValues } from "../Search";
import { CourseObject, FilterValues } from "../Search";

interface SearchFilterProps {
handleClick: () => void;
Expand All @@ -19,7 +19,7 @@ interface SearchFilterProps {
setMin: Dispatch<SetStateAction<number>>;
setMax: Dispatch<SetStateAction<number>>;
filterValues: FilterValues;
courses: CollegeObject[] | undefined;
courses: CourseObject[] | undefined;
}

export const SearchFilters = (props: SearchFilterProps) => {
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/query-db.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { CollegeObject } from "../../components/search/Search";
import { CourseObject } from "../../components/search/Search";

const cache: Record<string, [Date, CollegeObject[]]> = {};
const cache: Record<string, [Date, CourseObject[]]> = {};

export async function queryDatabase(
university: string,
ge: string,
): Promise<CollegeObject[]> {
): Promise<CourseObject[]> {
const cacheKey = university + ge;

if (cache[cacheKey] && cache[cacheKey][0]) {
Expand Down

0 comments on commit 0c97afc

Please sign in to comment.