mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-25 08:11:12 -05:00
feat: Implement comprehensive entity submission architecture
This commit is contained in:
@@ -28,14 +28,29 @@ export async function submitCompanyCreation(
|
||||
};
|
||||
}
|
||||
|
||||
// All users submit for moderation
|
||||
const { error } = await supabase
|
||||
// Create the main submission record
|
||||
const { data: submissionData, error: submissionError } = await supabase
|
||||
.from('content_submissions')
|
||||
.insert([{
|
||||
.insert({
|
||||
user_id: userId,
|
||||
submission_type: companyType, // Use entity-specific type: 'manufacturer', 'designer', 'operator', or 'property_owner'
|
||||
submission_type: companyType,
|
||||
content: {
|
||||
action: 'create',
|
||||
action: 'create'
|
||||
},
|
||||
status: 'pending'
|
||||
})
|
||||
.select()
|
||||
.single();
|
||||
|
||||
if (submissionError) throw submissionError;
|
||||
|
||||
// Create the submission item with actual company data
|
||||
const { error: itemError } = await supabase
|
||||
.from('submission_items')
|
||||
.insert({
|
||||
submission_id: submissionData.id,
|
||||
item_type: companyType,
|
||||
item_data: {
|
||||
name: data.name,
|
||||
slug: data.slug,
|
||||
description: data.description,
|
||||
@@ -44,13 +59,15 @@ export async function submitCompanyCreation(
|
||||
founded_year: data.founded_year,
|
||||
headquarters_location: data.headquarters_location,
|
||||
company_type: companyType,
|
||||
images: processedImages as any // Include uploaded image assignments in submission
|
||||
} as any,
|
||||
status: 'pending'
|
||||
}]);
|
||||
images: processedImages as any
|
||||
},
|
||||
status: 'pending',
|
||||
order_index: 0
|
||||
});
|
||||
|
||||
if (error) throw error;
|
||||
return { submitted: true };
|
||||
if (itemError) throw itemError;
|
||||
|
||||
return { submitted: true, submissionId: submissionData.id };
|
||||
}
|
||||
|
||||
export async function submitCompanyUpdate(
|
||||
@@ -78,14 +95,30 @@ export async function submitCompanyUpdate(
|
||||
};
|
||||
}
|
||||
|
||||
// All users submit for moderation
|
||||
const { error } = await supabase
|
||||
// Create the main submission record
|
||||
const { data: submissionData, error: submissionError } = await supabase
|
||||
.from('content_submissions')
|
||||
.insert([{
|
||||
.insert({
|
||||
user_id: userId,
|
||||
submission_type: existingCompany.company_type, // Use entity-specific type from existing company
|
||||
submission_type: existingCompany.company_type,
|
||||
content: {
|
||||
action: 'edit',
|
||||
company_id: companyId
|
||||
},
|
||||
status: 'pending'
|
||||
})
|
||||
.select()
|
||||
.single();
|
||||
|
||||
if (submissionError) throw submissionError;
|
||||
|
||||
// Create the submission item with actual company data
|
||||
const { error: itemError } = await supabase
|
||||
.from('submission_items')
|
||||
.insert({
|
||||
submission_id: submissionData.id,
|
||||
item_type: existingCompany.company_type,
|
||||
item_data: {
|
||||
company_id: companyId,
|
||||
name: data.name,
|
||||
slug: data.slug,
|
||||
@@ -94,11 +127,13 @@ export async function submitCompanyUpdate(
|
||||
website_url: data.website_url,
|
||||
founded_year: data.founded_year,
|
||||
headquarters_location: data.headquarters_location,
|
||||
images: processedImages as any // Include uploaded image role assignments in submission
|
||||
} as any,
|
||||
status: 'pending'
|
||||
}]);
|
||||
images: processedImages as any
|
||||
},
|
||||
status: 'pending',
|
||||
order_index: 0
|
||||
});
|
||||
|
||||
if (error) throw error;
|
||||
return { submitted: true };
|
||||
if (itemError) throw itemError;
|
||||
|
||||
return { submitted: true, submissionId: submissionData.id };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user