feat: Implement enhanced multi-image upload

This commit is contained in:
gpt-engineer-app[bot]
2025-10-01 18:51:48 +00:00
parent 69ce1a8132
commit 37b70111c6
7 changed files with 350 additions and 132 deletions

View File

@@ -1,4 +1,5 @@
import { supabase } from '@/integrations/supabase/client';
import { ImageAssignments } from '@/components/upload/EntityMultiImageUploader';
export interface CompanyFormData {
name: string;
@@ -8,6 +9,7 @@ export interface CompanyFormData {
website_url?: string;
founded_year?: number;
headquarters_location?: string;
images?: ImageAssignments;
}
export async function submitCompanyCreation(
@@ -21,7 +23,13 @@ export async function submitCompanyCreation(
const { data: newCompany, error } = await supabase
.from('companies')
.insert({
...data,
name: data.name,
slug: data.slug,
description: data.description,
person_type: data.person_type,
website_url: data.website_url,
founded_year: data.founded_year,
headquarters_location: data.headquarters_location,
company_type: companyType
})
.select()
@@ -33,15 +41,22 @@ export async function submitCompanyCreation(
// Regular users submit for moderation
const { error } = await supabase
.from('content_submissions')
.insert({
.insert([{
user_id: userId,
submission_type: 'company_create',
content: {
...data,
company_type: companyType
},
name: data.name,
slug: data.slug,
description: data.description,
person_type: data.person_type,
website_url: data.website_url,
founded_year: data.founded_year,
headquarters_location: data.headquarters_location,
company_type: companyType,
images: data.images as any // Include image assignments in submission
} as any,
status: 'pending'
});
}]);
if (error) throw error;
return { company: null, submitted: true };
@@ -59,7 +74,13 @@ export async function submitCompanyUpdate(
const { error } = await supabase
.from('companies')
.update({
...data,
name: data.name,
slug: data.slug,
description: data.description,
person_type: data.person_type,
website_url: data.website_url,
founded_year: data.founded_year,
headquarters_location: data.headquarters_location,
updated_at: new Date().toISOString()
})
.eq('id', companyId);
@@ -70,15 +91,22 @@ export async function submitCompanyUpdate(
// Regular users submit for moderation
const { error } = await supabase
.from('content_submissions')
.insert({
.insert([{
user_id: userId,
submission_type: 'company_edit',
content: {
company_id: companyId,
...data
},
name: data.name,
slug: data.slug,
description: data.description,
person_type: data.person_type,
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
} as any,
status: 'pending'
});
}]);
if (error) throw error;
return { submitted: true };