Mobile App Job Items Management
This document outlines how job items are managed in the AttuneLogic mobile app, particularly focusing on status management and service operations.
Overviewβ
The mobile app provides functionality to manage job items, including starting, pausing, resuming, and completing services. This is primarily handled through the ServiceItem component and RTK Query mutations.
Componentsβ
ServiceItem Componentβ
Located at: features/Job/Items/Services/Service/ServiceItem.tsx
The ServiceItem component is responsible for displaying and managing individual service items within a job. It handles:
- Service status management
- Document uploads
- Parts management
- Equipment tracking
- Service details
Key Featuresβ
- Status Management
const [startJobItem] = useStartJobItemMutation();
const [pauseJobItem] = usePauseJobItemMutation();
const [resumeJobItem] = useResumeJobItemMutation();
const [markItemComplete] = useMarkItemCompleteMutation();
// Starting a service
const handleStart = async (status: string) => {
await startJobItem({
jobId: jobId,
itemId: _id,
data: { status },
});
};
// Other status management functions...
- Service Details
- Equipment information
- Parts tracking
- Time tracking
- Document management
API Integrationβ
RTK Query Setupβ
The app uses RTK Query for API integration. The relevant API slice is defined in store/api/jobs/jobItemsApi.js.
Key mutations include:
startJobItempauseJobItemresumeJobItemmarkItemCompleteupdateItemStatus
Example API Call Flowβ
- User initiates action (e.g., starts a service)
- Component calls appropriate mutation
- RTK Query sends request to backend
- Response updates local state automatically
- UI updates to reflect new status
State Managementβ
Service item state is managed through:
- RTK Query cache
- Local component state for UI elements
- Parent job context when needed
Error Handlingβ
The component implements error handling for:
- Failed API calls
- Invalid state transitions
- Missing permissions
- Network issues
Related Documentationβ
Debugging Tipsβ
-
Check RTK Query Developer Tools for:
- Request/response data
- Cache state
- Pending mutations
-
Common Issues:
- Authentication token expiration
- Network connectivity
- Invalid state transitions
- Missing permissions
-
Logging:
- API calls are logged at the route level
- Component state changes are logged in development
- Service status transitions are tracked