Fix image upload and moderation display

This commit is contained in:
gpt-engineer-app[bot]
2025-10-01 20:28:34 +00:00
parent db839ef957
commit 65c3e92c70
2 changed files with 149 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
import { supabase } from '@/integrations/supabase/client';
import { ImageAssignments } from '@/components/upload/EntityMultiImageUploader';
import { uploadPendingImages } from './imageUploadHelper';
export interface CompanyFormData {
name: string;
@@ -17,6 +18,16 @@ export async function submitCompanyCreation(
companyType: 'manufacturer' | 'designer' | 'operator' | 'property_owner',
userId: string
) {
// Upload any pending local images first
let processedImages = data.images;
if (data.images?.uploaded && data.images.uploaded.length > 0) {
const uploadedImages = await uploadPendingImages(data.images.uploaded);
processedImages = {
...data.images,
uploaded: uploadedImages
};
}
// All users submit for moderation
const { error } = await supabase
.from('content_submissions')
@@ -33,7 +44,7 @@ export async function submitCompanyCreation(
founded_year: data.founded_year,
headquarters_location: data.headquarters_location,
company_type: companyType,
images: data.images as any // Include image assignments in submission
images: processedImages as any // Include uploaded image assignments in submission
} as any,
status: 'pending'
}]);
@@ -57,6 +68,16 @@ export async function submitCompanyUpdate(
if (fetchError) throw fetchError;
if (!existingCompany) throw new Error('Company not found');
// Upload any pending local images first
let processedImages = data.images;
if (data.images?.uploaded && data.images.uploaded.length > 0) {
const uploadedImages = await uploadPendingImages(data.images.uploaded);
processedImages = {
...data.images,
uploaded: uploadedImages
};
}
// All users submit for moderation
const { error } = await supabase
.from('content_submissions')
@@ -73,7 +94,7 @@ export async function submitCompanyUpdate(
website_url: data.website_url,
founded_year: data.founded_year,
headquarters_location: data.headquarters_location,
images: data.images as any // Include image role assignments in submission
images: processedImages as any // Include uploaded image role assignments in submission
} as any,
status: 'pending'
}]);