Implement rejection workflow

This commit is contained in:
gpt-engineer-app[bot]
2025-09-30 13:56:32 +00:00
parent f7ce456cc0
commit cd76e30ed9
3 changed files with 319 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ import {
buildDependencyTree,
detectDependencyConflicts,
approveSubmissionItems,
rejectSubmissionItems,
escalateSubmission,
type SubmissionItemWithDeps,
type DependencyConflict
@@ -25,6 +26,7 @@ import { ItemReviewCard } from './ItemReviewCard';
import { DependencyVisualizer } from './DependencyVisualizer';
import { ConflictResolutionDialog } from './ConflictResolutionDialog';
import { EscalationDialog } from './EscalationDialog';
import { RejectionDialog } from './RejectionDialog';
interface SubmissionReviewManagerProps {
submissionId: string;
@@ -45,6 +47,7 @@ export function SubmissionReviewManager({
const [loading, setLoading] = useState(false);
const [showConflictDialog, setShowConflictDialog] = useState(false);
const [showEscalationDialog, setShowEscalationDialog] = useState(false);
const [showRejectionDialog, setShowRejectionDialog] = useState(false);
const [activeTab, setActiveTab] = useState<'items' | 'dependencies'>('items');
const { toast } = useToast();
@@ -151,20 +154,53 @@ export function SubmissionReviewManager({
};
const handleRejectSelected = async () => {
if (selectedItemIds.size === 0) {
toast({
title: 'No Items Selected',
description: 'Please select items to reject',
variant: 'destructive',
});
return;
}
if (!user?.id) {
toast({
title: 'Authentication Required',
description: 'You must be logged in to reject items',
variant: 'destructive',
});
return;
}
// Check if any selected items have dependents
const selectedItems = items.filter(item => selectedItemIds.has(item.id));
const hasDependents = selectedItems.some(item =>
item.dependents && item.dependents.length > 0
);
setShowRejectionDialog(true);
};
const handleReject = async (reason: string, cascade: boolean) => {
if (!user?.id) return;
setLoading(true);
try {
// TODO: Implement rejection with reason
toast({
title: 'Success',
description: `Rejected ${selectedItemIds.size} item(s)`,
});
const selectedItems = items.filter(item => selectedItemIds.has(item.id));
await rejectSubmissionItems(selectedItems, reason, user.id, cascade);
toast({
title: 'Items Rejected',
description: `Successfully rejected ${selectedItems.length} item${selectedItems.length !== 1 ? 's' : ''}`,
});
onComplete();
onOpenChange(false);
} catch (error: any) {
console.error('Error rejecting items:', error);
toast({
title: 'Error',
description: error.message || 'Failed to reject items',
description: 'Failed to reject items. Please try again.',
variant: 'destructive',
});
} finally {
@@ -246,6 +282,16 @@ export function SubmissionReviewManager({
onOpenChange={setShowEscalationDialog}
onEscalate={handleEscalate}
/>
<RejectionDialog
open={showRejectionDialog}
onOpenChange={setShowRejectionDialog}
itemCount={selectedItemIds.size}
hasDependents={items.filter(item => selectedItemIds.has(item.id)).some(item =>
item.dependents && item.dependents.length > 0
)}
onReject={handleReject}
/>
</>
);