Job Items Status Management API
This document outlines the API endpoints and functionality for managing job item statuses in the AttuneLogic system.
Start Job Itemβ
Initiates a job item and marks it as "In Progress".
Endpointβ
POST /api/v1/jobs/:id/items/:itemId/start
Authenticationβ
- Requires valid JWT token
- Requires user role
- Requires parent company verification
Parametersβ
URL Parametersβ
id(string, required): The ID of the jobitemId(string, required): The ID of the job item
Request Bodyβ
{
"status": string,
"notes": string (optional),
"appointmentDate": Date (optional)
}
Responseβ
Success Response (200 OK)β
{
"data": {
"_id": string,
"status": "In Progress",
"startDate": Date,
"performedBy": [string],
// ... other item fields
},
"status": "success",
"code": 200,
"message": "Service started successfully"
}
Implementation Detailsβ
The endpoint performs the following operations:
- Validates the job item exists
- Updates the parent job status to "In Progress" if needed
- Assigns the user to the item if not already assigned
- Sets the start date if not already set
- Adds the user to the job's assignedTo array
- Updates the item status to "In Progress"
- Updates the item approval status
- Saves both the item and job
Error Handlingβ
- 404: Item or job not found
- 403: Authentication/authorization errors
- 500: Server errors
Related Endpointsβ
Pause Job Itemβ
POST /api/v1/jobs/:id/items/:itemId/pause
Resume Job Itemβ
POST /api/v1/jobs/:id/items/:itemId/resume
Complete Job Itemβ
PUT /api/v1/jobs/:id/items/:itemId/complete
Update Item Statusβ
PUT /api/v1/jobs/:id/items/:itemId/status
Mobile App Integrationβ
The mobile app uses RTK Query to interact with these endpoints. The relevant API slice is located in @attunelogic-mobile/store/api/jobs/jobItemsApi.js.
Example Usage in Mobile Appβ
const [startJobItem] = useStartJobItemMutation();
const handleStart = async (status: string) => {
await startJobItem({
jobId: jobId,
itemId: _id,
data: { status },
});
};
Debuggingβ
If you're not seeing any logs when calling these endpoints:
- Verify the request is reaching the server by checking the logs at the route level
- Check the network tab in your mobile dev tools
- Verify the base URL configuration in your mobile app
- Check for network/firewall issues
- Ensure your server is running and accessible
Related Filesβ
- Route Definition:
routes/api/v1/jobs.js - Controller:
controllers/jobs/items.js - Mobile API Integration:
@attunelogic-mobile/store/api/jobs/jobItemsApi.js - Mobile Component:
@attunelogic-mobile/features/Job/Items/Services/Service/ServiceItem.tsx