Fix photo_delete display issues

This commit is contained in:
gpt-engineer-app[bot]
2025-10-06 18:16:49 +00:00
parent 3f1e4abb62
commit c2c70524f7
2 changed files with 86 additions and 6 deletions

View File

@@ -104,6 +104,27 @@ export function PhotoManagementDialog({
const { data: { user } } = await supabase.auth.getUser();
if (!user) throw new Error('Not authenticated');
// Fetch entity name from database based on entity type
let entityName = 'Unknown';
try {
if (entityType === 'park') {
const { data } = await supabase.from('parks').select('name').eq('id', entityId).single();
if (data?.name) entityName = data.name;
} else if (entityType === 'ride') {
const { data } = await supabase.from('rides').select('name').eq('id', entityId).single();
if (data?.name) entityName = data.name;
} else if (entityType === 'ride_model') {
const { data } = await supabase.from('ride_models').select('name').eq('id', entityId).single();
if (data?.name) entityName = data.name;
} else if (['manufacturer', 'operator', 'designer', 'property_owner'].includes(entityType)) {
const { data } = await supabase.from('companies').select('name').eq('id', entityId).single();
if (data?.name) entityName = data.name;
}
} catch (err) {
console.error('Error fetching entity name:', err);
}
// Create content submission
const { data: submission, error: submissionError } = await supabase
.from('content_submissions')
@@ -120,7 +141,7 @@ export function PhotoManagementDialog({
if (submissionError) throw submissionError;
// Create submission item
// Create submission item with all necessary data
const { error: itemError } = await supabase
.from('submission_items')
.insert({
@@ -130,9 +151,11 @@ export function PhotoManagementDialog({
photo_id: photoToDelete.id,
entity_type: entityType,
entity_id: entityId,
entity_name: entityName,
cloudflare_image_url: photoToDelete.cloudflare_image_url,
title: photoToDelete.title,
caption: photoToDelete.caption,
reason: deleteReason
deletion_reason: deleteReason
},
status: 'pending'
});