Files
HRM-System/docs/PLAN-overtime-fixes.md

2.9 KiB

Fix Overtime Apply Workflow

This plan resolves the bugs and UX flow issues where applying for Overtime from the attendance calendar disrupts the attendance record saving, and corrects the employee mapping in the Overtime Requests page.

User Review Required

Important

The "Apply OT" button on the Attendance Calendar will now be handled natively via axios so it doesn't reload the page. I will prompt the user to hit "Save" on the attendance modal afterward, OR I can automatically submit both the attendance record AND the OT application together if they click "Save" while the OT input is filled out. I am proceeding with the most robust method: The user clicks "Apply OT", it pushes a success toast and keeps the form open so the user can hit "Save" to commit the main attendance changes.

Open Questions

None. The UX flow changes and column bug fixes are straightforward.

Proposed Changes


calendar.tsx (Frontend - HR Attendance)

[MODIFY] calendar.tsx

  • Change the "Apply OT" button logic. Instead of router.post(...) (which causes a page reload and wipes the modal), use axios.post.
  • Show a success toast after axios.post completes, and keep the modal open so the user can finish filling out and saving their Attendance record.
  • Add user_id to the payload explicitly by pulling it from the modal's current user data so that it correctly maps the Employee, rather than defaulting to the logged-in Admin's ID.

OvertimeApplicationController.php (Backend API)

[MODIFY] OvertimeApplicationController.php

  • Update store method. Instead of hardcoding 'user_id' => Auth::id(), accept an optional user_id parameter. If provided (and if the Auth user is Admin/HR), apply it. If not, fallback to Auth::id(). This fixes the "Company is showing in Employee Column" bug.

index.tsx (Frontend - HR Overtime)

[MODIFY] index.tsx

  • In the data table, app.user?.name works, but currently since the user_id was the Admin's, it showed "Company". This will naturally resolve once the backend fix above is deployed. No major edits needed here unless we need to fallback to app.user?.employee?.first_name.

Verification Plan

Manual Verification

  1. Open the Attendance Calendar as an Admin.
  2. Select an employee and update their clock-out time so it triggers the "Apply OT" prompt.
  3. Click "Apply OT". Verify a green toast appears saying "Overtime Requested!" and the modal remains open.
  4. Click "Save" on the modal to save the attendance record.
  5. Go to the "Overtime" menu. Verify the record shows the actual Employee's name, not "Company".
  6. Approve the OT request.
  7. Return to the calendar and verify the grid cell changes from P to OT.