Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 16 additions & 17 deletions src/content/components/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className="w-full h-full flex flex-col items-center justify-center gap-2">
<img src={thung} width={100} height={100} />
<div>
<span className="py-3 text-2xl font-medium">강의가 없습니다</span>
</div>
</div>
);
}
const toggleCard = (courseId: string) => {
setExpandedCards((prev) => ({ ...prev, [courseId]: !prev[courseId] }));
};
Expand All @@ -46,6 +36,17 @@ export default function Video({ courseData }: Props) {
{} as Record<string, Vod[]>
);

if (!courseData || courseData.length === 0) {
return (
<div className="w-full h-full flex flex-col items-center justify-center gap-2">
<img src={thung} width={100} height={100} />
<div>
<span className="py-3 text-2xl font-medium">강의가 없습니다</span>
</div>
</div>
);
}

const sortedVodGroups = Object.values(groupedData).sort((groupA, groupB) => {
const firstA = groupA[0];
const firstB = groupB[0];
Expand Down Expand Up @@ -158,13 +159,11 @@ export default function Video({ courseData }: Props) {
</div>
<div className="font-light text-zinc-500 text-ellipsis line-clamp-1" style={{ fontSize: 10 }}>
{formatDateString(vod.range)},{' '}
<span
className={`font-medium ${
vod.isAttendance.toLowerCase().trim() === 'o'
? 'text-green-500'
: 'text-amber-500'
} !text-amber-500`}
>
<span
className={`font-medium ${
vod.isAttendance.toLowerCase().trim() === 'o' ? 'text-green-500' : 'text-amber-500'
}`}
>
{vod.length}
</span>
</div>
Expand Down
7 changes: 2 additions & 5 deletions src/hooks/useCourseData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vod[]>([]);
Expand Down Expand Up @@ -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({
Expand Down
3 changes: 3 additions & 0 deletions src/utils/generate-key.ts
Original file line number Diff line number Diff line change
@@ -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}`;
Loading