Reverted to commit 026a4e9362

This commit is contained in:
gpt-engineer-app[bot]
2025-09-30 20:10:02 +00:00
parent 6f1544309e
commit 9319aadfed
8 changed files with 13 additions and 706 deletions

View File

@@ -8,7 +8,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@
interface EscalationDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
onEscalate: (reason: string, additionalNotes?: string) => void;
onEscalate: (reason: string) => void;
}
const escalationReasons = [
@@ -31,9 +31,9 @@ export function EscalationDialog({
const handleEscalate = () => {
const reason = selectedReason === 'Other'
? additionalNotes
: selectedReason;
: `${selectedReason}${additionalNotes ? ': ' + additionalNotes : ''}`;
onEscalate(reason, selectedReason !== 'Other' ? additionalNotes : undefined);
onEscalate(reason);
onOpenChange(false);
// Reset form

View File

@@ -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);

View File

@@ -130,8 +130,6 @@ export type Database = {
approval_mode: string | null
content: Json
created_at: string
escalated: boolean | null
escalated_at: string | null
escalated_by: string | null
escalation_reason: string | null
id: string
@@ -148,8 +146,6 @@ export type Database = {
approval_mode?: string | null
content: Json
created_at?: string
escalated?: boolean | null
escalated_at?: string | null
escalated_by?: string | null
escalation_reason?: string | null
id?: string
@@ -166,8 +162,6 @@ export type Database = {
approval_mode?: string | null
content?: Json
created_at?: string
escalated?: boolean | null
escalated_at?: string | null
escalated_by?: string | null
escalation_reason?: string | null
id?: string
@@ -190,36 +184,6 @@ export type Database = {
},
]
}
email_aliases: {
Row: {
created_at: string
description: string | null
email: string
id: string
key: string
owner_id: string | null
updated_at: string
}
Insert: {
created_at?: string
description?: string | null
email: string
id?: string
key: string
owner_id?: string | null
updated_at?: string
}
Update: {
created_at?: string
description?: string | null
email?: string
id?: string
key?: string
owner_id?: string | null
updated_at?: string
}
Relationships: []
}
locations: {
Row: {
city: string | null