From fc6a0259d571db527a30abeb394a3623f033a788 Mon Sep 17 00:00:00 2001 From: Kevin Wu Date: Fri, 5 Apr 2024 00:45:41 -0700 Subject: [PATCH] feat: add UCLA support (#54) * chore: add UCLA data * refactor: swap ternary condition order * feat: handle colon in UCLA categories --- components/search/Search.tsx | 2 +- components/search/SearchResults.tsx | 13 ++++++++++++- components/search/SearchSelect.tsx | 30 +++++++++++++++++++++-------- lib/constants.tsx | 9 +++++++++ 4 files changed, 44 insertions(+), 10 deletions(-) diff --git a/components/search/Search.tsx b/components/search/Search.tsx index 37cedd9..3a72136 100644 --- a/components/search/Search.tsx +++ b/components/search/Search.tsx @@ -196,7 +196,7 @@ const Search = () => { const fetchData = async () => { try { const universityParam = university; - const geParam = !ge.includes("GE") ? ge : ge.split(" ")[1]; + const geParam = ge.includes("GE") ? ge.split(" ")[1] : ge; const courses = await queryDatabase(universityParam, geParam); setCourses(courses); diff --git a/components/search/SearchResults.tsx b/components/search/SearchResults.tsx index 21b9682..99068e4 100644 --- a/components/search/SearchResults.tsx +++ b/components/search/SearchResults.tsx @@ -88,7 +88,18 @@ const SearchResults = (props: SearchResultsProps) => {
{result.fulfillsGEs - .map((obj) => obj.category) + .map((obj) => { + const category = + obj.category; + + return category.includes( + ":", + ) + ? category.split( + ": ", + )[1] + : category; + }) .join(", ")}
diff --git a/components/search/SearchSelect.tsx b/components/search/SearchSelect.tsx index c7df1de..e904cfa 100644 --- a/components/search/SearchSelect.tsx +++ b/components/search/SearchSelect.tsx @@ -21,17 +21,31 @@ export const SearchSelect = (props: DropdownComponentProps) => { return (
diff --git a/lib/constants.tsx b/lib/constants.tsx index ad51f33..47f7038 100644 --- a/lib/constants.tsx +++ b/lib/constants.tsx @@ -21,4 +21,13 @@ export const UNIVERSITY_GE: Record = { "GE F", "GE G", ], + "University of California, Los Angeles": [ + "Arts and Humanities: Literary and Cultural Analysis", + "Arts and Humanities: Philosophical and Linguistic Analysis", + "Arts and Humanities: Visual and Performance Arts Analysis and Practice", + "Scientific Inquiry: Life Sciences", + "Scientific Inquiry: Physical Sciences", + "Society and Culture: Historical Analysis", + "Society and Culture: Social Analysis", + ], };