diff --git a/src/components/Courses/CourseListItem.tsx b/src/components/Courses/CourseListItem.tsx index 7a5a83cd..2516aea5 100644 --- a/src/components/Courses/CourseListItem.tsx +++ b/src/components/Courses/CourseListItem.tsx @@ -1,10 +1,17 @@ import { CourseDefinition } from '@/config/supabase'; import useDictionary from '@/dictionaries/useDictionary'; import { useSettings } from '@/hooks/contexts/settings'; -import { Button, Chip } from '@mui/joy'; +import { Button, Chip, Tooltip } from '@mui/joy'; import Link from 'next/link'; -import { FC, useMemo } from 'react'; -import { Users } from 'react-feather'; +import { FC, PropsWithChildren, useMemo } from 'react'; +import { Minus, Plus, Users } from 'react-feather'; +import {getGECType} from '@/helpers/courses'; + +const HighlightItem: FC> = ({ children }) => { + return
+ {children} +
+} const CourseListItem: FC<{ course: CourseDefinition }> = ({ course }) => { const { courses, setCourses } = useSettings(); @@ -15,53 +22,105 @@ const CourseListItem: FC<{ course: CourseDefinition }> = ({ course }) => {
- {course.department} {course.course}-{course.class} {course.name_zh} - {(course.teacher_zh ?? []).join(',')} + {course.department} {course.course}-{course.class} {course.name_zh} - {(course.teacher_zh ?? []).join(',')}

{course.name_en} - {(course.teacher_en ?? []).join(',')}

-
+

{course.課程限制說明}

{course.備註}

-

{course.擋修說明}

- -
- {course.備註?.includes('X-Class') &&

} + > +

有儅修

+ } +
+
+ {course.tags.includes('X-Class') && + X-Class} - {course.language == '英' ? English : - 國語} -
-
+ > + English + : + + 國語 + } + {(course.ge_target?.trim() || "").length > 0 && + {course.ge_target} 通識課} + {getGECType(course.ge_type || "") && + 核通 {getGECType(course.ge_type!)} + }
-
-

{course.credits} {dict.course.credits}

+

{course.semester} 學期

{course.venues? - course.venues.map((vn, i) =>

{vn} {course.times![i]}

) : + course.venues.map((vn, i) =>

{vn} {course.times![i]}

) :

No Venues

} - {course.capacity &&
- - {course.capacity}{course.reserve == 0 ? '' : ` / ${course.reserve}R`} -
} +
+ + + {course.capacity ?? '-'} + {(course.reserve ?? 0) > 0 && <> +
+ {`保 ${course.reserve}`} + } +
+ + +
+ + {course.credits} + {dict.course.credits} + + {course.tags.includes('16周') && + 16 週 + } + {course.tags.includes('18周') && + 18 週 + } +
{isCourseSelected ? - : - }
diff --git a/src/helpers/courses.ts b/src/helpers/courses.ts index e69de29b..9c8d8ee2 100644 --- a/src/helpers/courses.ts +++ b/src/helpers/courses.ts @@ -0,0 +1,7 @@ +export const getGECType = (ge_type: string) => { + //核心通識Core GE courses 1, 核心通識Core GE courses 2 <- return this number + if(ge_type.includes('核心通識Core GE courses')){ + return parseInt(ge_type.slice(-1)); + } + else return null; +} \ No newline at end of file diff --git a/src/types/supabase.ts b/src/types/supabase.ts index 6ef3dfe0..4f947cb6 100644 --- a/src/types/supabase.ts +++ b/src/types/supabase.ts @@ -458,36 +458,60 @@ export interface Database { cds_courses: { Row: { class: number | null - course: number | null + course: string | null credits: number | null + cross_discipline: string[] | null department: string | null + first_specialization: string[] | null id: number + language: string | null name_en: string | null name_zh: string | null - teacher_en: string[] | null + note: string | null + raw_id: string + second_specialization: string[] | null + semester: string | null teacher_zh: string[] | null + times: string[] | null + venues: string[] | null } Insert: { class?: number | null - course?: number | null + course?: string | null credits?: number | null + cross_discipline?: string[] | null department?: string | null - id?: number + first_specialization?: string[] | null + id: number + language?: string | null name_en?: string | null name_zh?: string | null - teacher_en?: string[] | null + note?: string | null + raw_id: string + second_specialization?: string[] | null + semester?: string | null teacher_zh?: string[] | null + times?: string[] | null + venues?: string[] | null } Update: { class?: number | null - course?: number | null + course?: string | null credits?: number | null + cross_discipline?: string[] | null department?: string | null + first_specialization?: string[] | null id?: number + language?: string | null name_en?: string | null name_zh?: string | null - teacher_en?: string[] | null + note?: string | null + raw_id?: string + second_specialization?: string[] | null + semester?: string | null teacher_zh?: string[] | null + times?: string[] | null + venues?: string[] | null } Relationships: [] } @@ -512,7 +536,7 @@ export interface Database { raw_1_2_specialization: string | null raw_cross_discipline: string | null raw_extra_selection: string | null - raw_id: string | null + raw_id: string raw_teacher_en: string | null raw_teacher_zh: string | null raw_time: string | null @@ -520,6 +544,7 @@ export interface Database { reserve: number | null second_specialization: string[] | null semester: string | null + tags: string[] teacher_en: string[] | null teacher_zh: string[] | null times: string[] | null @@ -552,7 +577,7 @@ export interface Database { raw_1_2_specialization?: string | null raw_cross_discipline?: string | null raw_extra_selection?: string | null - raw_id?: string | null + raw_id: string raw_teacher_en?: string | null raw_teacher_zh?: string | null raw_time?: string | null @@ -560,6 +585,7 @@ export interface Database { reserve?: number | null second_specialization?: string[] | null semester?: string | null + tags?: string[] teacher_en?: string[] | null teacher_zh?: string[] | null times?: string[] | null @@ -590,7 +616,7 @@ export interface Database { raw_1_2_specialization?: string | null raw_cross_discipline?: string | null raw_extra_selection?: string | null - raw_id?: string | null + raw_id?: string raw_teacher_en?: string | null raw_teacher_zh?: string | null raw_time?: string | null @@ -598,6 +624,7 @@ export interface Database { reserve?: number | null second_specialization?: string[] | null semester?: string | null + tags?: string[] teacher_en?: string[] | null teacher_zh?: string[] | null times?: string[] | null @@ -1226,6 +1253,30 @@ export interface Database { } Returns: number } + search_cds_courses: { + Args: { + keyword: string + } + Returns: { + class: number | null + course: string | null + credits: number | null + cross_discipline: string[] | null + department: string | null + first_specialization: string[] | null + id: number + language: string | null + name_en: string | null + name_zh: string | null + note: string | null + raw_id: string + second_specialization: string[] | null + semester: string | null + teacher_zh: string[] | null + times: string[] | null + venues: string[] | null + }[] + } search_courses: { Args: { keyword: string @@ -1250,7 +1301,7 @@ export interface Database { raw_1_2_specialization: string | null raw_cross_discipline: string | null raw_extra_selection: string | null - raw_id: string | null + raw_id: string raw_teacher_en: string | null raw_teacher_zh: string | null raw_time: string | null @@ -1258,6 +1309,7 @@ export interface Database { reserve: number | null second_specialization: string[] | null semester: string | null + tags: string[] teacher_en: string[] | null teacher_zh: string[] | null times: string[] | null