- 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
181 lines
3.8 KiB
TypeScript
181 lines
3.8 KiB
TypeScript
// Core type definitions for the Beach Litter Mapping Platform
|
|
|
|
export type LitterType = 'plastic' | 'metal' | 'glass' | 'organic' | 'hazardous' | 'other';
|
|
|
|
export type QuantityLevel = 'minimal' | 'moderate' | 'significant' | 'severe';
|
|
|
|
export type LocationSource = 'exif' | 'gps' | 'manual';
|
|
|
|
export type VerificationStatus = 'pending' | 'verified' | 'disputed';
|
|
|
|
export type EventStatus = 'upcoming' | 'completed' | 'cancelled';
|
|
|
|
export interface Coordinates {
|
|
latitude: number;
|
|
longitude: number;
|
|
}
|
|
|
|
export interface User {
|
|
id: string;
|
|
clerkId: string;
|
|
email: string;
|
|
username: string;
|
|
firstName?: string;
|
|
lastName?: string;
|
|
avatarUrl?: string;
|
|
impactScore: number;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
}
|
|
|
|
export interface Report {
|
|
id: string;
|
|
userId: string;
|
|
latitude: number;
|
|
longitude: number;
|
|
locationSource: LocationSource;
|
|
photoUrls: string[];
|
|
photoTimestamp?: Date;
|
|
litterType: LitterType;
|
|
quantity: QuantityLevel;
|
|
description?: string;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
submittedAt: Date;
|
|
verificationStatus: VerificationStatus;
|
|
cleanedAt?: Date;
|
|
cleanedByUserId?: string;
|
|
}
|
|
|
|
export interface CleanupEvent {
|
|
id: string;
|
|
organizerId: string;
|
|
organizerClerkId?: string; // Clerk ID of the organizer for permission checks
|
|
title: string;
|
|
description: string;
|
|
latitude: number;
|
|
longitude: number;
|
|
locationName: string;
|
|
scheduledDate: Date;
|
|
duration: number; // in minutes
|
|
status: EventStatus;
|
|
participantCount: number;
|
|
litterCollected?: number; // in kilograms
|
|
photos?: string[];
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
}
|
|
|
|
export interface EnvironmentalConcern {
|
|
id: string;
|
|
reportId: string;
|
|
concernType: string;
|
|
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
description: string;
|
|
createdAt: Date;
|
|
}
|
|
|
|
export interface Hotspot {
|
|
id: string;
|
|
latitude: number;
|
|
longitude: number;
|
|
radius: number; // in meters
|
|
reportCount: number;
|
|
severityScore: number;
|
|
lastReportDate: Date;
|
|
calculatedAt: Date;
|
|
}
|
|
|
|
export type HotspotSeverity = 'low' | 'medium' | 'high' | 'critical';
|
|
|
|
export interface HotspotWithSeverity extends Hotspot {
|
|
severity: HotspotSeverity;
|
|
}
|
|
|
|
// DTOs (Data Transfer Objects)
|
|
export interface CreateReportDTO {
|
|
photos: File[];
|
|
latitude?: number;
|
|
longitude?: number;
|
|
locationSource: LocationSource;
|
|
litterType: LitterType;
|
|
quantity: QuantityLevel;
|
|
description?: string;
|
|
environmentalConcerns?: {
|
|
type: string;
|
|
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
description: string;
|
|
}[];
|
|
}
|
|
|
|
export interface Verification {
|
|
id: string;
|
|
reportId: string;
|
|
userId: string;
|
|
verificationType: 'verify' | 'dispute';
|
|
comment?: string;
|
|
createdAt: Date;
|
|
user: {
|
|
id: string;
|
|
username: string;
|
|
};
|
|
}
|
|
|
|
export interface ReportResponseDTO extends Report {
|
|
user: {
|
|
id: string;
|
|
username: string;
|
|
avatarUrl?: string;
|
|
};
|
|
verificationCount: number;
|
|
disputeCount: number;
|
|
environmentalConcerns: EnvironmentalConcern[];
|
|
verifications?: Verification[];
|
|
}
|
|
|
|
export interface FilterState {
|
|
dateRange?: {
|
|
start: Date;
|
|
end: Date;
|
|
};
|
|
litterTypes?: LitterType[];
|
|
quantities?: QuantityLevel[];
|
|
verificationStatus?: VerificationStatus[];
|
|
}
|
|
|
|
// Analytics types
|
|
export interface AnalyticsSummary {
|
|
totalReports: number;
|
|
totalEvents: number;
|
|
totalUsers: number;
|
|
totalLitterCollected?: number; // in kilograms
|
|
periodComparison?: {
|
|
reports: number; // percentage change
|
|
events: number;
|
|
users: number;
|
|
};
|
|
}
|
|
|
|
export interface DateRange {
|
|
start: Date;
|
|
end: Date;
|
|
}
|
|
|
|
export interface TimeSeriesDataPoint {
|
|
date: string;
|
|
reports: number;
|
|
events?: number;
|
|
}
|
|
|
|
export interface LitterTypeDistribution {
|
|
type: LitterType;
|
|
count: number;
|
|
percentage: number;
|
|
}
|
|
|
|
export interface QuantityAggregation {
|
|
quantity: QuantityLevel;
|
|
count: number;
|
|
percentage: number;
|
|
}
|