mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 16:11:12 -05:00
Fix content submissions constraint violation
This commit is contained in:
@@ -22,8 +22,9 @@ export async function submitCompanyCreation(
|
||||
.from('content_submissions')
|
||||
.insert([{
|
||||
user_id: userId,
|
||||
submission_type: 'company_create',
|
||||
submission_type: companyType, // Use entity-specific type: 'manufacturer', 'designer', 'operator', or 'property_owner'
|
||||
content: {
|
||||
action: 'create',
|
||||
name: data.name,
|
||||
slug: data.slug,
|
||||
description: data.description,
|
||||
@@ -46,13 +47,24 @@ export async function submitCompanyUpdate(
|
||||
data: CompanyFormData,
|
||||
userId: string
|
||||
) {
|
||||
// Fetch existing company to get its type
|
||||
const { data: existingCompany, error: fetchError } = await supabase
|
||||
.from('companies')
|
||||
.select('company_type')
|
||||
.eq('id', companyId)
|
||||
.single();
|
||||
|
||||
if (fetchError) throw fetchError;
|
||||
if (!existingCompany) throw new Error('Company not found');
|
||||
|
||||
// All users submit for moderation
|
||||
const { error } = await supabase
|
||||
.from('content_submissions')
|
||||
.insert([{
|
||||
user_id: userId,
|
||||
submission_type: 'company_edit',
|
||||
submission_type: existingCompany.company_type, // Use entity-specific type from existing company
|
||||
content: {
|
||||
action: 'edit',
|
||||
company_id: companyId,
|
||||
name: data.name,
|
||||
slug: data.slug,
|
||||
|
||||
Reference in New Issue
Block a user