Skip to content

Commit

Permalink
feat: added ge priority label
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJustChew committed Jun 23, 2024
1 parent 205bb5d commit a7635d4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/app/[lang]/(mods-pages)/courses/CourseSearchContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ const CourseSearchContainer = () => {
</TabsContent>
<TabsContent value="list">
<ScrollArea className="w-full h-[calc(100vh-12.5rem)] overflow-auto border rounded-2xl">
<div className="p-4 h-full">
<div className="py-4 h-full">
<TimetableCourseListWithSemester />
</div>
</ScrollArea>
Expand Down Expand Up @@ -266,7 +266,7 @@ const CourseSearchContainer = () => {
</TabsContent>
<TabsContent value="list">
<ScrollArea className="w-full h-[calc(100vh-12.5rem)] overflow-auto border rounded-2xl">
<div className="p-4 h-full">
<div className="py-4 h-full">
<TimetableCourseListWithSemester />
</div>
</ScrollArea>
Expand Down
20 changes: 20 additions & 0 deletions src/components/Timetable/TimetableCourseList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ const TimetableCourseListItem = ({
course,
hasConflict,
isDuplicate,
priority
}: {
course: MinimalCourse,
hasConflict: boolean,
isDuplicate: boolean,
priority: number
}) => {
const { language } = useSettings();

Expand Down Expand Up @@ -98,6 +100,7 @@ const TimetableCourseListItem = ({
</Popover>
<TimetableItemDrawer course={course}>
<div className="flex flex-col flex-1">
<p className='mb-1'>{priority != 0 && <span className='px-2 py-0.5 dark:bg-white dark:text-black bg-neutral-700 text-white mr-1 rounded-md text-xs'>{priority} 志願</span>}</p>
<span className="text-sm">{course.department} {course.course}-{course.class} {course.name_zh} - {course.teacher_zh.join(',')}</span>
<span className="text-xs">{course.name_en}</span>
<div className="mt-1">
Expand Down Expand Up @@ -181,6 +184,22 @@ export const TimetableCourseList = ({
})
);

const peAndGeAllocation = useMemo(() => {
//filter by pe and ge: include PE (exclude PE 1110) and courses with ge_target
const peAndGe = displayCourseData.filter(course => {
if (course.department == 'PE' && course.course != 'PE 1110') {
return true;
}
if (course.ge_target && course.ge_target != " ") {
return true;
}
return false;
});
console.log(peAndGe)

return peAndGe.map(course => course.raw_id);
}, [displayCourseData]);

function handleDragEnd(event: DragEndEvent) {
const { active, over } = event;
if (!over) return;
Expand Down Expand Up @@ -217,6 +236,7 @@ export const TimetableCourseList = ({
course={course as MinimalCourse}
hasConflict={!!timeConflicts.find(ts => ts.course.raw_id == course.raw_id)}
isDuplicate={duplicates.includes(course.raw_id)}
priority={peAndGeAllocation.indexOf(course.raw_id) + 1}
/>
))}
</SortableContext>
Expand Down

0 comments on commit a7635d4

Please sign in to comment.