Add 'Mark as Cleaned Up' functionality

- Add cleaned_at and cleaned_by_user_id fields to reports table
- Create database migration for cleanup tracking
- Add markAsCleaned backend endpoint and service method
- Add Mark as Cleaned Up button to ReportDetailModal
- Update types to include cleaned fields
- Add frontend handler to mark reports as cleaned
This commit is contained in:
2025-11-16 22:26:59 +00:00
parent beb5d8e7d8
commit 17e3e85781
9 changed files with 168 additions and 21 deletions

View File

@@ -322,6 +322,37 @@ export function MapPage() {
}
};
const handleMarkCleaned = async (reportId: string) => {
try {
await reportService.markAsCleaned(reportId);
// Refresh the report details
const updatedReport = await reportService.getReport(reportId);
setSelectedReport(updatedReport);
// Refresh the reports list
const apiFilters: Parameters<typeof reportService.getReports>[0] = filters.dateRange
? {
dateRange: {
start: filters.dateRange.start.toISOString(),
end: filters.dateRange.end.toISOString(),
},
litterTypes: filters.litterTypes,
quantities: filters.quantities,
verificationStatus: filters.verificationStatus,
}
: {
litterTypes: filters.litterTypes,
quantities: filters.quantities,
verificationStatus: filters.verificationStatus,
};
const data = await reportService.getReports(apiFilters);
setReports(data);
alert('Report marked as cleaned up!');
} catch (error: any) {
console.error('Failed to mark report as cleaned:', error);
alert(error.message || 'Failed to mark report as cleaned. Please try again.');
}
};
const handleMapClick = (lat: number, lng: number) => {
console.log('Map clicked at:', lat, lng);
// In later tasks, this can be used for manual location selection
@@ -454,6 +485,7 @@ export function MapPage() {
onClose={handleCloseModal}
onVerify={isSignedIn ? handleVerify : undefined}
onDispute={isSignedIn ? handleDispute : undefined}
onMarkCleaned={isSignedIn ? handleMarkCleaned : undefined}
/>
)}