mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 01:31:12 -05:00
Reverted to commit 026a4e9362
This commit is contained in:
@@ -150,38 +150,13 @@ export function SubmissionReviewManager({
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
// Use edge function for complex approval processing
|
||||
const { supabase } = await import('@/integrations/supabase/client');
|
||||
const selectedItems = items.filter(item => selectedItemIds.has(item.id));
|
||||
await approveSubmissionItems(selectedItems, user.id);
|
||||
|
||||
const { data, error } = await supabase.functions.invoke('process-selective-approval', {
|
||||
body: {
|
||||
submissionId,
|
||||
selectedItemIds: Array.from(selectedItemIds),
|
||||
moderatorId: user.id,
|
||||
}
|
||||
toast({
|
||||
title: 'Success',
|
||||
description: `Approved ${selectedItems.length} item(s)`,
|
||||
});
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
const result = data as {
|
||||
success: boolean;
|
||||
processedItems: any[];
|
||||
successCount: number;
|
||||
failureCount: number;
|
||||
};
|
||||
|
||||
if (result.failureCount > 0) {
|
||||
toast({
|
||||
title: 'Partial Success',
|
||||
description: `Approved ${result.successCount} of ${result.processedItems.length} item(s). ${result.failureCount} failed.`,
|
||||
variant: 'default',
|
||||
});
|
||||
} else {
|
||||
toast({
|
||||
title: 'Success',
|
||||
description: `Approved ${result.successCount} item(s)`,
|
||||
});
|
||||
}
|
||||
|
||||
onComplete();
|
||||
onOpenChange(false);
|
||||
@@ -251,7 +226,7 @@ export function SubmissionReviewManager({
|
||||
}
|
||||
};
|
||||
|
||||
const handleEscalate = async (reason: string, additionalNotes?: string) => {
|
||||
const handleEscalate = async (reason: string) => {
|
||||
if (!user?.id) {
|
||||
toast({
|
||||
title: 'Authentication Required',
|
||||
@@ -263,35 +238,12 @@ export function SubmissionReviewManager({
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
// Update submission escalation status
|
||||
await escalateSubmission(submissionId, reason, user.id);
|
||||
|
||||
// Send email notifications via edge function
|
||||
const { supabase } = await import('@/integrations/supabase/client');
|
||||
|
||||
const { data, error: emailError } = await supabase.functions.invoke('send-escalation-notification', {
|
||||
body: {
|
||||
submissionId,
|
||||
escalationReason: reason,
|
||||
escalatedBy: user.id,
|
||||
additionalNotes,
|
||||
}
|
||||
toast({
|
||||
title: 'Escalated',
|
||||
description: 'Submission escalated to admin for review',
|
||||
});
|
||||
|
||||
if (emailError) {
|
||||
console.error('Failed to send escalation emails:', emailError);
|
||||
toast({
|
||||
title: 'Escalated',
|
||||
description: 'Submission escalated but email notifications failed',
|
||||
variant: 'default',
|
||||
});
|
||||
} else {
|
||||
const result = data as { emailsSent: number; totalRecipients: number };
|
||||
toast({
|
||||
title: 'Escalated',
|
||||
description: `Submission escalated to admin. ${result.emailsSent} of ${result.totalRecipients} admin(s) notified.`,
|
||||
});
|
||||
}
|
||||
|
||||
onComplete();
|
||||
onOpenChange(false);
|
||||
|
||||
Reference in New Issue
Block a user