Spaces:
Sleeping
Sleeping
Asset Request Management Updates
Summary of Changes
1. Custom Action Dialog Component
Created a new custom dialog component (ActionDialog.tsx) for approve/reject actions that:
- Provides a better user experience with custom styling
- Shows request details (ID and employee name) prominently
- Has built-in validation and error handling
- Displays character count for comments
- Uses backdrop blur effect for better focus
- Includes loading states during submission
2. Acknowledgement Status Added
Extended the asset request lifecycle to include an "acknowledged" status:
Type Updates (asset-request.ts):
- Added
'acknowledged'toRequestStatustype - Added new fields to
AssetRequestinterface:acknowledgedDate: string | nullacknowledgedBy: number | nullacknowledgementComments: string | null
- Updated status transition rules:
assignedβacknowledged - Added label: "Acknowledged"
- Added color: purple theme for acknowledged status
Status Flow:
pending β approved β assigned β acknowledged
β rejected
3. Updated Components
AssetRequestReview.tsx:
- Replaced shadcn Dialog with custom ActionDialog component
- Simplified approve/reject handlers
- Removed local state management for comments (now handled by ActionDialog)
- Cleaner code with better separation of concerns
MyAssetRequests.tsx:
- Added acknowledgement status icon and color
- Added "Acknowledged" tab to display acknowledged requests
- Added acknowledgement information section showing:
- Acknowledged date
- Acknowledgement comments
- Updated tab grid from 5 to 6 columns
assetRequestApi.ts:
- Updated
createSafeAssetRequesthelper to include acknowledgement fields - Ensures backward compatibility with API responses
4. Features
Custom Dialog Benefits:
- β Better visual hierarchy
- β Clearer action context
- β Inline validation feedback
- β Improved accessibility
- β Consistent styling across approve/reject actions
- β Backdrop click to close
- β Escape key support (via onClose)
Acknowledgement Status Benefits:
- β Employees can confirm receipt of assigned assets
- β Complete audit trail of asset request lifecycle
- β Optional comments for acknowledgement
- β Clear visual distinction with purple badge
- β Separate tab for tracking acknowledged requests
Usage
Approve/Reject Dialog
The custom dialog automatically handles:
- Comment validation (minimum 5 characters)
- Character count display
- Loading states
- Error messages
- Form submission
Acknowledgement Flow
- Admin assigns assets to approved request (status:
assigned) - Employee receives notification
- Employee acknowledges receipt (status:
acknowledged) - Optional: Employee can add comments during acknowledgement
API Integration Notes
The frontend now expects these additional fields in API responses:
{
acknowledgedDate: string | null,
acknowledgedBy: number | null,
acknowledgementComments: string | null
}
If the backend doesn't provide these fields yet, the frontend will safely default them to null.
Next Steps
To fully implement acknowledgement functionality:
- Add acknowledgement API endpoint (e.g.,
PUT /api/AssetRequests/{id}/acknowledge) - Add acknowledgement button in MyAssetRequests for assigned requests
- Create acknowledgement dialog similar to approve/reject
- Update backend to support acknowledgement status transition
- Add notifications for acknowledgement events