diff --git a/package-lock.json b/package-lock.json index 76746cc..c055c04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dotbugi", - "version": "3.1.16", + "version": "3.1.17", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dotbugi", - "version": "3.1.16", + "version": "3.1.17", "dependencies": { "@heroui/switch": "^2.2.9", "@heroui/system": "^2.4.7", @@ -4279,9 +4279,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001692", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001692.tgz", - "integrity": "sha512-A95VKan0kdtrsnMubMKxEKUKImOPSuCpYgxSQBo036P5YYgVIcOYJEgt/txJWqObiRQeISNCfef9nvlQ0vbV7A==", + "version": "1.0.30001743", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001743.tgz", + "integrity": "sha512-e6Ojr7RV14Un7dz6ASD0aZDmQPT/A+eZU+nuTNfjqmRrmkmQlnTNWH0SKmqagx9PeW87UVqapSurtAXifmtdmw==", "dev": true, "funding": [ { diff --git a/src/content/components/Video.tsx b/src/content/components/Video.tsx index 122cd2f..685e4bf 100644 --- a/src/content/components/Video.tsx +++ b/src/content/components/Video.tsx @@ -20,16 +20,6 @@ interface Props { export default function Video({ courseData }: Props) { const [expandedCards, setExpandedCards] = useState<{ [key: string]: boolean }>({}); - if (!courseData || courseData.length === 0) { - return ( -
- -
- 강의가 없습니다 -
-
- ); - } const toggleCard = (courseId: string) => { setExpandedCards((prev) => ({ ...prev, [courseId]: !prev[courseId] })); }; @@ -46,6 +36,17 @@ export default function Video({ courseData }: Props) { {} as Record ); + if (!courseData || courseData.length === 0) { + return ( +
+ +
+ 강의가 없습니다 +
+
+ ); + } + const sortedVodGroups = Object.values(groupedData).sort((groupA, groupB) => { const firstA = groupA[0]; const firstB = groupB[0]; @@ -158,13 +159,11 @@ export default function Video({ courseData }: Props) {
{formatDateString(vod.range)},{' '} - + {vod.length}
diff --git a/src/hooks/useCourseData.tsx b/src/hooks/useCourseData.tsx index c973e30..287c341 100644 --- a/src/hooks/useCourseData.tsx +++ b/src/hooks/useCourseData.tsx @@ -3,10 +3,7 @@ import { Vod, Assign, Quiz, CourseBase } from '@/content/types'; import { loadDataFromStorage, saveDataToStorage } from '@/lib/storage'; import { requestData } from '@/lib/fetchCourseData'; import { isCurrentDateByDate, isCurrentDateInRange } from '@/lib/utils'; - -const makeVodKey = (courseId: string, title: string, week: number) => `${courseId}-${title}-${week}`; -const makeAssignKey = (courseId: string, title: string, dueDate: string) => `${courseId}-${title}-${dueDate}`; -const makeQuizKey = (courseId: string, title: string, dueDate: string) => `${courseId}-${title}-${dueDate}`; +import { makeAssignKey, makeQuizKey, makeVodKey } from '@/utils/generate-key'; export function useCourseData(courses: CourseBase[]) { const [vods, setVods] = useState([]); @@ -39,7 +36,7 @@ export function useCourseData(courses: CourseBase[]) { result.vodDataArray.forEach((vodData) => { result.vodAttendanceArray.forEach((vodAttendanceData) => { const vodKey = makeVodKey(course.courseId, vodData.title, vodData.week); - if (vodAttendanceData.week === vodData.week) { + if (vodAttendanceData.title === vodData.title && vodAttendanceData.week === vodData.week) { if (!vodSet.has(vodKey)) { vodSet.add(vodKey); tempVods.push({ diff --git a/src/utils/generate-key.ts b/src/utils/generate-key.ts new file mode 100644 index 0000000..b1cece6 --- /dev/null +++ b/src/utils/generate-key.ts @@ -0,0 +1,3 @@ +export const makeVodKey = (courseId: string, title: string, week: number) => `${courseId}-${title}-${week}`; +export const makeAssignKey = (courseId: string, title: string, dueDate: string) => `${courseId}-${title}-${dueDate}`; +export const makeQuizKey = (courseId: string, title: string, dueDate: string) => `${courseId}-${title}-${dueDate}`;