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
axiosso 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), useaxios.post. - Show a success toast after
axios.postcompletes, and keep the modal open so the user can finish filling out and saving their Attendance record. - Add
user_idto 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
storemethod. Instead of hardcoding'user_id' => Auth::id(), accept an optionaluser_idparameter. If provided (and if the Auth user is Admin/HR), apply it. If not, fallback toAuth::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?.nameworks, but currently since theuser_idwas 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 toapp.user?.employee?.first_name.
Verification Plan
Manual Verification
- Open the Attendance Calendar as an Admin.
- Select an employee and update their clock-out time so it triggers the "Apply OT" prompt.
- Click "Apply OT". Verify a green toast appears saying "Overtime Requested!" and the modal remains open.
- Click "Save" on the modal to save the attendance record.
- Go to the "Overtime" menu. Verify the record shows the actual Employee's name, not "Company".
- Approve the OT request.
- Return to the calendar and verify the grid cell changes from
PtoOT.