Skip to content
Merged
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
1 change: 1 addition & 0 deletions mosu-app/src/entities/exam/ui/RegisteredExamDetailCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const RegisteredExamDetailCard = ({
<button
className="flex-1 border-l-[0.5px] p-4 hover:cursor-pointer"
onClick={() => onPrintTicketButtonClick()}
disabled={true}
>
수험표 출력
</button>
Comment on lines 64 to 70
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Implement conditional disabling based on exam date.

The button is permanently disabled with a hardcoded true value. Based on the overlay message (lines 80-81), the button should be conditionally disabled—enabled within 3 days of the exam date and disabled otherwise.

With the current implementation:

  • The onClick handler (line 66) is unreachable dead code
  • Users cannot access the informative overlay message
  • The button remains disabled even when the exam is within 3 days

Consider implementing date-based conditional logic:

+    const isWithinThreeDays = useCallback(() => {
+        const examDateObj = new Date(examDate);
+        const today = new Date();
+        const diffInDays = Math.ceil((examDateObj.getTime() - today.getTime()) / (1000 * 60 * 60 * 24));
+        return diffInDays <= 3;
+    }, [examDate]);
+
+    const canPrintTicket = isWithinThreeDays();
+
     const onPrintTicketButtonClick = useCallback(() => {
+        if (!canPrintTicket) {
+            overlay.open();
+            return;
+        }
-        overlay.open();
+        // TODO: Implement actual ticket printing logic
-    }, [overlay]);
+    }, [canPrintTicket, overlay]);

     // ... in the button:
     <button
         className="flex-1 border-l-[0.5px] p-4 hover:cursor-pointer"
         onClick={() => onPrintTicketButtonClick()}
-        disabled={true}
+        disabled={!canPrintTicket}
+        aria-label={canPrintTicket ? "수험표 출력" : "수험표 출력 불가 (시험 3일 전부터 가능)"}
     >
         수험표 출력
     </button>

This approach:

  • Shows the overlay message when users click while the button is enabled but before the 3-day window
  • Disables the button visually when outside the window
  • Adds ARIA attributes for accessibility
  • Preserves the onClick handler for future ticket printing implementation
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<button
className="flex-1 border-l-[0.5px] p-4 hover:cursor-pointer"
onClick={() => onPrintTicketButtonClick()}
disabled={true}
>
수험표 출력
</button>
<button
className="flex-1 border-l-[0.5px] p-4 hover:cursor-pointer"
onClick={() => onPrintTicketButtonClick()}
disabled={!canPrintTicket}
aria-label={canPrintTicket
? "수험표 출력"
: "수험표 출력 불가 (시험 3일 전부터 가능)"}
>
수험표 출력
</button>

Expand Down