Skip to content

Commit

Permalink
feat: add UCLA support (#54)
Browse files Browse the repository at this point in the history
* chore: add UCLA data

* refactor: swap ternary condition order

* feat: handle colon in UCLA categories
  • Loading branch information
KevinWu098 authored Apr 5, 2024
1 parent ee32d0e commit fc6a025
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
2 changes: 1 addition & 1 deletion components/search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 12 additions & 1 deletion components/search/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,18 @@ const SearchResults = (props: SearchResultsProps) => {
</div>
<div className="flex flex-row gap-2 text-base font-light">
{result.fulfillsGEs
.map((obj) => obj.category)
.map((obj) => {
const category =
obj.category;

return category.includes(
":",
)
? category.split(
": ",
)[1]
: category;
})
.join(", ")}
</div>
</div>
Expand Down
30 changes: 22 additions & 8 deletions components/search/SearchSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,31 @@ export const SearchSelect = (props: DropdownComponentProps) => {
return (
<div className="relative flex h-12 w-[300px] md:h-16">
<Select value={value} onValueChange={onChange}>
<SelectTrigger className="h-full w-full overflow-ellipsis rounded-xl border-2 border-gray px-4 text-base md:text-2xl">
<SelectTrigger className="h-full w-full overflow-ellipsis rounded-xl border-2 border-gray px-4 text-left text-base md:text-2xl">
<SelectValue placeholder={placeholder} />
</SelectTrigger>
<SelectContent>
{data.map((item) => (
<SelectItem value={item} key={item} className="text-lg">
{item.includes("University of California")
? "UC " + item.split(", ")[1]
: item}
</SelectItem>
))}
{data.map((item) => {
let option = item;

if (option.includes("University of California")) {
option = "UC " + item.split(", ")[1];
}

if (option.includes(": ")) {
option = item.split(": ")[1];
}

return (
<SelectItem
value={item}
key={item}
className="text-lg"
>
{option}
</SelectItem>
);
})}
</SelectContent>
</Select>
</div>
Expand Down
9 changes: 9 additions & 0 deletions lib/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,13 @@ export const UNIVERSITY_GE: Record<string, string[]> = {
"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",
],
};

0 comments on commit fc6a025

Please sign in to comment.