mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 21:31:12 -05:00
Implement submission protections
This commit is contained in:
@@ -93,6 +93,13 @@ export function SubmissionReviewManager({
|
||||
}
|
||||
|
||||
const fetchedItems = await fetchSubmissionItems(submissionId);
|
||||
|
||||
// Protection 2: Detect empty submissions
|
||||
if (!fetchedItems || fetchedItems.length === 0) {
|
||||
setItems([]);
|
||||
return;
|
||||
}
|
||||
|
||||
const itemsWithDeps = buildDependencyTree(fetchedItems);
|
||||
setItems(itemsWithDeps);
|
||||
|
||||
@@ -524,6 +531,49 @@ export function SubmissionReviewManager({
|
||||
);
|
||||
|
||||
function ReviewContent() {
|
||||
// Protection 2: UI detection of empty submissions
|
||||
if (items.length === 0 && !loading) {
|
||||
return (
|
||||
<Alert variant="destructive" className="my-4">
|
||||
<AlertCircle className="h-4 w-4" />
|
||||
<AlertDescription>
|
||||
This submission has no items and appears to be corrupted or incomplete.
|
||||
This usually happens when the submission creation process was interrupted.
|
||||
<div className="mt-2 flex gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={async () => {
|
||||
try {
|
||||
const { supabase } = await import('@/integrations/supabase/client');
|
||||
await supabase
|
||||
.from('content_submissions')
|
||||
.delete()
|
||||
.eq('id', submissionId);
|
||||
|
||||
toast({
|
||||
title: 'Submission Archived',
|
||||
description: 'The corrupted submission has been removed',
|
||||
});
|
||||
onComplete();
|
||||
onOpenChange(false);
|
||||
} catch (error) {
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: getErrorMessage(error),
|
||||
variant: 'destructive',
|
||||
});
|
||||
}
|
||||
}}
|
||||
>
|
||||
Archive Submission
|
||||
</Button>
|
||||
</div>
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4 h-full">
|
||||
<Tabs
|
||||
|
||||
Reference in New Issue
Block a user