mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 08:11:12 -05:00
Refactor: Execute remaining phases
This commit is contained in:
@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { handleError } from '@/lib/errorHandler';
|
||||
import {
|
||||
fetchSubmissionItems,
|
||||
buildDependencyTree,
|
||||
@@ -108,11 +108,11 @@ export function SubmissionReviewManager({
|
||||
.filter(item => item.status === 'pending')
|
||||
.map(item => item.id);
|
||||
setSelectedItemIds(new Set(pendingIds));
|
||||
} catch (error) {
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: getErrorMessage(error),
|
||||
variant: 'destructive',
|
||||
} catch (error: unknown) {
|
||||
handleError(error, {
|
||||
action: 'Load Submission Items',
|
||||
userId: user?.id,
|
||||
metadata: { submissionId, submissionType }
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -147,11 +147,11 @@ export function SubmissionReviewManager({
|
||||
// No conflicts, proceed with approval
|
||||
handleApprove();
|
||||
}
|
||||
} catch (error) {
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: getErrorMessage(error),
|
||||
variant: 'destructive',
|
||||
} catch (error: unknown) {
|
||||
handleError(error, {
|
||||
action: 'Check Dependency Conflicts',
|
||||
userId: user?.id,
|
||||
metadata: { submissionId, selectedCount: selectedItemIds.size }
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -253,12 +253,16 @@ export function SubmissionReviewManager({
|
||||
|
||||
onComplete();
|
||||
onOpenChange(false);
|
||||
} catch (error) {
|
||||
console.error('Error approving items:', error);
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: getErrorMessage(error),
|
||||
variant: 'destructive',
|
||||
} catch (error: unknown) {
|
||||
handleError(error, {
|
||||
action: 'Approve Submission Items',
|
||||
userId: user?.id,
|
||||
metadata: {
|
||||
submissionId,
|
||||
itemCount: selectedItemIds.size,
|
||||
hasWarnings: userConfirmedWarnings,
|
||||
hasBlockingErrors
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -308,12 +312,16 @@ export function SubmissionReviewManager({
|
||||
|
||||
onComplete();
|
||||
onOpenChange(false);
|
||||
} catch (error) {
|
||||
console.error('Error rejecting items:', error);
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: getErrorMessage(error),
|
||||
variant: 'destructive',
|
||||
} catch (error: unknown) {
|
||||
handleError(error, {
|
||||
action: 'Reject Submission Items',
|
||||
userId: user?.id,
|
||||
metadata: {
|
||||
submissionId,
|
||||
itemCount: selectedItemIds.size,
|
||||
cascade,
|
||||
reason: reason.substring(0, 100)
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -361,12 +369,14 @@ export function SubmissionReviewManager({
|
||||
|
||||
onComplete();
|
||||
onOpenChange(false);
|
||||
} catch (error) {
|
||||
console.error('Error escalating submission:', error);
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: getErrorMessage(error),
|
||||
variant: 'destructive',
|
||||
} catch (error: unknown) {
|
||||
handleError(error, {
|
||||
action: 'Escalate Submission',
|
||||
userId: user?.id,
|
||||
metadata: {
|
||||
submissionId,
|
||||
reason: reason.substring(0, 100)
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -429,12 +439,15 @@ export function SubmissionReviewManager({
|
||||
}
|
||||
|
||||
await loadSubmissionItems();
|
||||
} catch (error) {
|
||||
console.error('Error changing item status:', error);
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: getErrorMessage(error),
|
||||
variant: 'destructive',
|
||||
} catch (error: unknown) {
|
||||
handleError(error, {
|
||||
action: `${status === 'approved' ? 'Approve' : 'Reject'} Item`,
|
||||
userId: user?.id,
|
||||
metadata: {
|
||||
submissionId,
|
||||
itemId,
|
||||
status
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -557,11 +570,11 @@ export function SubmissionReviewManager({
|
||||
});
|
||||
onComplete();
|
||||
onOpenChange(false);
|
||||
} catch (error) {
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: getErrorMessage(error),
|
||||
variant: 'destructive',
|
||||
} catch (error: unknown) {
|
||||
handleError(error, {
|
||||
action: 'Archive Corrupted Submission',
|
||||
userId: user?.id,
|
||||
metadata: { submissionId }
|
||||
});
|
||||
}
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user