diff --git a/src/components/search/Search.tsx b/src/components/search/Search.tsx index 2770af9..6b29cbb 100644 --- a/src/components/search/Search.tsx +++ b/src/components/search/Search.tsx @@ -6,6 +6,7 @@ import { useRouter, useSearchParams } from "next/navigation"; import { SearchFilterDialog } from "@/components/search/filter/search-filter-dialog"; import { SearchFilterSortDropdown } from "@/components/search/filter/search-filter-sort-dropdown"; import { SearchBlurb } from "@/components/search/search-blurb"; +import { SearchResults } from "@/components/search/search-results"; import { analyticsEnum, logAnalytics } from "@/lib/analytics"; import { UNIVERSITY_GE } from "@/lib/constants"; import { getDismissedRecently, getNumSearches } from "@/lib/utils/search"; @@ -16,7 +17,6 @@ import { ToastAction } from "../ui/toast"; import { useToast } from "../ui/use-toast"; import { SearchFilter } from "./filter/search-filter"; import ScrollToTop from "./ScrollToTop"; -import SearchResults from "./SearchResults"; import { SearchSelect } from "./SearchSelect"; export interface CourseObject { diff --git a/src/components/search/SearchResults.tsx b/src/components/search/SearchResults.tsx deleted file mode 100644 index 2e4f6bc..0000000 --- a/src/components/search/SearchResults.tsx +++ /dev/null @@ -1,185 +0,0 @@ -import { format } from "date-fns"; -import { ExternalLinkIcon } from "lucide-react"; -import LazyLoad from "react-lazy-load"; - -import { CourseObject } from "./Search"; -import Tags from "./Tags"; - -const formatTime = (date: number) => { - return format(new Date(date), "MMM d"); -}; - -interface SearchResultsProps { - results: CourseObject[]; - university: string; - ge: string; -} - -const SearchResults = (props: SearchResultsProps) => { - const { results, university, ge } = props; - - return ( - <> -
- {results.length > 0 ? ( - results.map((result: CourseObject) => { - const startTime = formatTime(result.startDate); - const endTime = formatTime(result.endDate); - - return ( - -
-
-
- {result.sendingInstitution} -
-
- {result.courseCode}{" "} - {result.courseName} -
-
- {result.niceToHaves.length > 0 && ( -
-
- {result.niceToHaves.map( - (tag) => ( - - ) - )} -
-
- )} -
-
-
-
-
- Units -
-
- {`${result.units} Units`} -
-
-
-
- Term -
-
- {startTime + - " - " + - endTime} -
-
-
-
- GEs -
-
- {result.fulfillsGEs - .map((obj) => { - const category = - obj.category; - - return category.includes( - ":" - ) - ? category.split( - ": " - )[1] - : category; - }) - .join(", ")} -
-
-
-
- Articulates To -
-
- {result.articulatesTo.join( - ", " - )} -
-
-
-
-
-
-
- Tuition:{" "} - - {`$${result.tuition.toFixed(2)}`} - -
-
- - -
-
-
-
- ); - }) - ) : ( -
-
- no results -
-
-

No results found...

- {university == "University of California, Irvine" && - (ge.includes("Ia") || ge.includes("Ib")) ? ( -

- (GE Ia and Ib are not transferable at UCI) -

- ) : null} -
-
- )} -
- - ); -}; - -export default SearchResults; diff --git a/src/components/search/search-results.tsx b/src/components/search/search-results.tsx new file mode 100644 index 0000000..f5d4483 --- /dev/null +++ b/src/components/search/search-results.tsx @@ -0,0 +1,175 @@ +import { format } from "date-fns"; +import { ExternalLinkIcon } from "lucide-react"; +import LazyLoad from "react-lazy-load"; + +import { CourseObject } from "./Search"; +import Tags from "./Tags"; + +const formatTime = (date: number) => { + return format(new Date(date), "MMM d"); +}; + +interface SearchResultsProps { + results: CourseObject[]; + university: string; + ge: string; +} + +export function SearchResults({ results, university, ge }: SearchResultsProps) { + if (results.length <= 0) { + return ( +
+
+ no results +
+
+

No results found...

+ {university == "University of California, Irvine" && + (ge.includes("Ia") || ge.includes("Ib")) ? ( +

+ (GE Ia and Ib are not transferable at UCI) +

+ ) : null} +
+
+ ); + } + + return ( +
+ {results.map((result: CourseObject) => { + const startTime = formatTime(result.startDate); + const endTime = formatTime(result.endDate); + + return ( + +
+
+
+ {result.sendingInstitution} +
+
+ {result.courseCode}{" "} + {result.courseName} +
+
+ {result.niceToHaves.length > 0 && ( +
+
+ {result.niceToHaves.map((tag) => ( + + ))} +
+
+ )} +
+
+
+
+
+ Units +
+
+ {`${result.units} Units`} +
+
+
+
+ Term +
+
+ {startTime + " - " + endTime} +
+
+
+
+ GEs +
+
+ {result.fulfillsGEs + .map((obj) => { + const category = + obj.category; + + return category.includes( + ":" + ) + ? category.split( + ": " + )[1] + : category; + }) + .join(", ")} +
+
+
+
+ Articulates To +
+
+ {result.articulatesTo.join(", ")} +
+
+
+
+
+
+
+ Tuition:{" "} + + {`$${result.tuition.toFixed(2)}`} + +
+
+ + +
+
+
+
+ ); + })} +
+ ); +}