69 lines
2.2 KiB
TypeScript
69 lines
2.2 KiB
TypeScript
|
|
|
|
import { DriverViewModel } from "@/lib/view-models/DriverViewModel";
|
|
import { ProtestViewModel } from "@/lib/view-models/ProtestViewModel";
|
|
import { RaceViewModel } from "@/lib/view-models/RaceViewModel";
|
|
import { Box } from "@/ui/Box";
|
|
import { Card } from "@/ui/Card";
|
|
import { ProtestListItem } from "@/ui/ProtestListItem";
|
|
import { Stack } from "@/ui/Stack";
|
|
import { Text } from "@/ui/Text";
|
|
import { Flag } from "lucide-react";
|
|
|
|
interface PendingProtestsListProps {
|
|
protests: ProtestViewModel[];
|
|
races: Record<string, RaceViewModel>;
|
|
drivers: Record<string, DriverViewModel>;
|
|
leagueId: string;
|
|
onReviewProtest: (protest: ProtestViewModel) => void;
|
|
onProtestReviewed: () => void;
|
|
}
|
|
|
|
export function PendingProtestsList({
|
|
protests,
|
|
leagueId,
|
|
}: PendingProtestsListProps) {
|
|
|
|
if (protests.length === 0) {
|
|
return (
|
|
<Card>
|
|
<Box p={12} textAlign="center">
|
|
<Stack align="center" gap={4}>
|
|
<Box w="16" h="16" rounded="full" bg="bg-performance-green/10" display="flex" alignItems="center" justifyContent="center">
|
|
<Flag className="h-8 w-8 text-performance-green" />
|
|
</Box>
|
|
<Box>
|
|
<Text weight="semibold" size="lg" color="text-white" block mb={2}>All Clear! 🏁</Text>
|
|
<Text size="sm" color="text-gray-400">No pending protests to review</Text>
|
|
</Box>
|
|
</Stack>
|
|
</Box>
|
|
</Card>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Stack gap={4}>
|
|
{protests.map((protest) => {
|
|
const filedAt = protest.filedAt || protest.submittedAt;
|
|
const daysSinceFiled = Math.floor((Date.now() - new Date(filedAt).getTime()) / (1000 * 60 * 60 * 24));
|
|
const isUrgent = daysSinceFiled > 2;
|
|
|
|
return (
|
|
<ProtestListItem
|
|
key={protest.id}
|
|
id={protest.id}
|
|
filedAt={filedAt}
|
|
description={protest.incident?.description || protest.description}
|
|
lap={protest.incident?.lap}
|
|
hasVideo={!!protest.proofVideoUrl}
|
|
isUrgent={isUrgent}
|
|
daysOld={daysSinceFiled}
|
|
href={`/leagues/${leagueId}/stewarding/protests/${protest.id}`}
|
|
/>
|
|
);
|
|
})}
|
|
</Stack>
|
|
);
|
|
}
|