feat(phase2): add admin photo replacement button with ItemDetailModal

- Add ItemDetailModal component for viewing item details and replacing photos
- Add photo replacement/deletion endpoints to API layer (PUT/DELETE /items/{id}/photo)
- Update InventoryTable to open detail modal on item click
- Show current photo thumbnail with Replace/Delete buttons
- Support uploading new photo with ItemPhotoUpload component
- Delete old photo on backend when replacing (no orphaned files)
- Full test coverage: 18 tests for ItemDetailModal component
- All 393 tests passing, zero TypeScript errors
- Build verified successfully
This commit is contained in:
2026-04-21 13:30:38 +03:00
parent 2ba1994022
commit a8d7e5ac09
5 changed files with 599 additions and 2 deletions

View File

@@ -272,4 +272,18 @@ export const inventoryApi = {
});
return res.data;
},
// Photo Replacement
replaceItemPhoto: async (itemId: number, formData: FormData) => {
const res = await axiosInstance.put(`/items/${itemId}/photo`, formData, {
headers: { 'Content-Type': 'multipart/form-data' }
});
return res.data;
},
// Photo Deletion
deleteItemPhoto: async (itemId: number) => {
const res = await axiosInstance.delete(`/items/${itemId}/photo`);
return res.data;
},
};