Skip to content

Commit

Permalink
Updated UI to use new database formats
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJustChew committed Nov 1, 2023
1 parent fe4d644 commit 86a3363
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 26 deletions.
9 changes: 6 additions & 3 deletions src/app/[lang]/courses/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,13 @@ const CoursePage: NextPage = () => {
.or(`compulsory_for.cs.{"${filters.className}"},elective_for.cs.{"${filters.className}"}`);
if (filters.others.includes('xclass'))
temp = temp
.textSearch(`備註`, `'X-Class'`)
.contains('tags', ['X-Class'])
if (filters.others.includes('16_weeks'))
temp = temp
.contains('tags', ['16周'])
if (filters.others.includes('extra_selection'))
temp = temp
.eq('no_extra_selection', false)
temp = temp
.not('tags', 'cs', '{"不可加簽"}')
if (filters.firstSpecialization || filters.secondSpecialization) {
temp = temp
.or(`first_specialization.cs.{"${filters.firstSpecialization ?? ""}"},second_specialization.cs.{"${filters.secondSpecialization ?? ""}"}`)
Expand Down
49 changes: 27 additions & 22 deletions src/components/Courses/CourseListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,16 @@ const CourseListItem: FC<{ course: CourseDefinition }> = ({ course }) => {

return <div className="text-gray-600 dark:text-gray-400 px-4">
<div className="grid grid-cols-1 lg:grid-rows-none lg:grid-cols-[auto_224px]">
<div className='flex-1'>
<div className="mb-3">
<Link className="font-semibold text-lg text-fuchsia-800 dark:text-fuchsia-500" href={'courses/'+course.raw_id}>{course.department} {course.course}-{course.class} {course.name_zh} - {course.raw_teacher_zh}</Link>
<h3 className="text-base text-gray-800 dark:text-gray-300 mt-0 break-words">{course.name_en} - <span className='w-max'>{course.raw_teacher_en}</span></h3>
<div className='flex-1 space-y-4'>
<div className="mb-3 space-y-1">
<Link className="font-semibold text-lg text-fuchsia-800 dark:text-fuchsia-500" href={'courses/'+course.raw_id}>{course.department} {course.course}-{course.class} {course.name_zh} - {(course.teacher_zh ?? []).join(',')}</Link>
<h3 className="text-sm text-gray-800 dark:text-gray-300 mt-0 break-words">{course.name_en} - <span className='w-max'>{(course.teacher_en ?? []).join(',')}</span></h3>
</div>
<div className="space-y-1">
<p>{course.venues?.join(', ') || "No Venue"}{course.credits} {dict.course.credits}</p>
<p>{course.課程限制說明}</p>
{isCourseSelected ?
<Button color="danger" variant="outlined" onClick={() => setCourses(courses => courses.filter(m => m != course.raw_id))}>
{dict.course.item.remove_from_semester}
</Button> :
<Button variant="outlined" onClick={() => setCourses(courses => [...courses, course.raw_id ?? ""])}>
{dict.course.item.add_to_semester}
</Button>}
</div>
</div>
<div className='flex flex-col'>
{course.capacity && <div className="flex flex-row space-x-1 mb-2">
<Users />
<span className="">{course.capacity}{course.reserve == 0 ? '' : ` / ${course.reserve}R`}</span>
</div>}
<div>
<div className="space-y-1 text-black">
<p className='text-sm'>{course.課程限制說明}</p>
<p className='text-sm'>{course.備註}</p>
<p className='text-sm'>{course.擋修說明}</p>

<div className="space-x-2 justify-end">
{course.備註?.includes('X-Class') && <Chip
color="danger"
Expand All @@ -60,6 +47,24 @@ const CourseListItem: FC<{ course: CourseDefinition }> = ({ course }) => {
</div>
</div>
</div>
<div className='flex flex-col space-y-3'>
<p>{course.credits} {dict.course.credits}</p>
{course.venues?
course.venues.map((vn, i) => <p className='text-blue-600 font-mono'>{vn} <span className='text-black'>{course.times![i]}</span></p>) :
<p>No Venues</p>
}
{course.capacity && <div className="flex flex-row space-x-1 mb-2">
<Users className='w-5 h-5'/>
<span className="">{course.capacity}{course.reserve == 0 ? '' : ` / ${course.reserve}R`}</span>
</div>}
{isCourseSelected ?
<Button color="danger" variant="outlined" onClick={() => setCourses(courses => courses.filter(m => m != course.raw_id))}>
{dict.course.item.remove_from_semester}
</Button> :
<Button variant="outlined" onClick={() => setCourses(courses => [...courses, course.raw_id ?? ""])}>
{dict.course.item.add_to_semester}
</Button>}
</div>
</div>
</div>
}
Expand Down
1 change: 1 addition & 0 deletions src/components/Courses/RefineControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ const RefineControls: FC<{ control: Control<RefineControlFormTypes>, onClear: ()
name="others"
options={[
{ value: 'xclass', label: dict.course.refine['x-class'] },
{ value: '16_weeks', label: dict.course.refine['16_weeks']},
{ value: 'extra_selection', label: dict.course.refine['extra_selection']}
]}
label={dict.course.refine.others}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Timetable/TimetableSlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const TimetableSlot: FC<TimetableSlotProps> = ({ course, tableDim, fraction = 1,
<span className='text-xs lg:text-sm font-bold'>{course.course.name_zh}</span>
{/* {<span className='text-xs'>{course.course.name_en}</span>} */}
<span className='text-[10px]'>{course.venue}</span>
<span className='text-[10px]'>{course.course.raw_teacher_zh}</span>
{course.course.teacher_zh && <span className='text-[10px]'>{course.course.teacher_zh?.join(',')}</span>}
{/* <span className='text-xs'>{course.course.raw_teacher_en}</span> */}
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/dictionaries/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"gecDimensions": "GEC Dimensions",
"extra_selection": "Allows Extra Selection",
"x-class": "X-Class",
"16_weeks": "16 Weeks",
"others": "Others",
"clear": "Clear All"
},
Expand Down
1 change: 1 addition & 0 deletions src/dictionaries/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"gecDimensions": "核通向度",
"extra_selection": "允許加簽",
"x-class": "X-Class",
"16_weeks": "16 週課程",
"others": "其他",
"clear": "清除"
},
Expand Down

0 comments on commit 86a3363

Please sign in to comment.