1.7 KiB
1.7 KiB
Walkthrough - Overtime Delegation API Implementation
I have implemented the backend API for Overtime Delegation as requested. This API allows superiors to delegate overtime tasks to multiple subordinates across a range of dates.
Changes Made
1. Delegation Service
- File: delegation-overtime-services.js
- Method:
insertOvertimeDelegation - Logic:
- Accepts a payload with employees, date range, and times.
- Generates a unique
idplanningfor tracking the batch. - Calculates the duration for the overtime.
- Performs a batch
INSERTinto thetrx_multi_ovttable. - Includes tracking fields:
nik_delegator,time_stamp_delegator,nik_delegate,name_delegate, andtime_stamp_delegate.
2. Delegation Routes
- File: delegation-routes.js
- Endpoint:
POST /api/delegations/overtime/insert - Middleware: Secured with
jwtAuth.verifyToken.
3. Server Integration
- File: server.js
- Action: Registered the new delegation routes.
Verification
- The API is now ready to be consumed by the UI.
- The batch insertion logic ensures that multiple records are created efficiently.
- Tracking fields are populated to allow auditing of who delegated to whom.
Next Steps
- Update the Flutter UI (
OvertimeDelegationPage) to call this new API endpoint when the "Submit Delegasi" button is pressed.