mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 13:51:13 -05:00
Fix submission process issues
This commit is contained in:
@@ -779,8 +779,13 @@ export async function submitRideCreation(
|
|||||||
|
|
||||||
if (submissionError) throw submissionError;
|
if (submissionError) throw submissionError;
|
||||||
|
|
||||||
// Extract images for assignment
|
// ✅ FIXED: Get image URLs/IDs from processed images using assignments
|
||||||
const changedFields = extractChangedFields(data, {});
|
const uploadedImages = processedImages?.uploaded || [];
|
||||||
|
const bannerIndex = processedImages?.banner_assignment;
|
||||||
|
const cardIndex = processedImages?.card_assignment;
|
||||||
|
|
||||||
|
const bannerImage = (bannerIndex !== null && bannerIndex !== undefined) ? uploadedImages[bannerIndex] : null;
|
||||||
|
const cardImage = (cardIndex !== null && cardIndex !== undefined) ? uploadedImages[cardIndex] : null;
|
||||||
|
|
||||||
// Insert into relational ride_submissions table
|
// Insert into relational ride_submissions table
|
||||||
const { data: rideSubmission, error: rideSubmissionError } = await supabase
|
const { data: rideSubmission, error: rideSubmissionError } = await supabase
|
||||||
@@ -812,10 +817,10 @@ export async function submitRideCreation(
|
|||||||
coaster_type: data.coaster_type || null,
|
coaster_type: data.coaster_type || null,
|
||||||
seating_type: data.seating_type || null,
|
seating_type: data.seating_type || null,
|
||||||
intensity_level: data.intensity_level || null,
|
intensity_level: data.intensity_level || null,
|
||||||
banner_image_url: changedFields.banner_image_url as string || null,
|
banner_image_url: bannerImage?.url || data.banner_image_url || null,
|
||||||
banner_image_id: changedFields.banner_image_id as string || null,
|
banner_image_id: bannerImage?.cloudflare_id || data.banner_image_id || null,
|
||||||
card_image_url: changedFields.card_image_url as string || null,
|
card_image_url: cardImage?.url || data.card_image_url || null,
|
||||||
card_image_id: changedFields.card_image_id as string || null,
|
card_image_id: cardImage?.cloudflare_id || data.card_image_id || null,
|
||||||
image_url: null
|
image_url: null
|
||||||
} as any)
|
} as any)
|
||||||
.select('id')
|
.select('id')
|
||||||
@@ -1006,7 +1011,11 @@ export async function submitRideModelCreation(
|
|||||||
item_type: 'ride_model',
|
item_type: 'ride_model',
|
||||||
action_type: 'create',
|
action_type: 'create',
|
||||||
item_data: {
|
item_data: {
|
||||||
...extractChangedFields(data, {}),
|
// ✅ FIXED: Don't use extractChangedFields for CREATE - include ALL data
|
||||||
|
...(() => {
|
||||||
|
const { images, ...dataWithoutImages } = data;
|
||||||
|
return dataWithoutImages;
|
||||||
|
})(),
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
status: 'pending' as const,
|
status: 'pending' as const,
|
||||||
@@ -1138,7 +1147,11 @@ export async function submitManufacturerCreation(
|
|||||||
item_type: 'manufacturer',
|
item_type: 'manufacturer',
|
||||||
action_type: 'create',
|
action_type: 'create',
|
||||||
item_data: {
|
item_data: {
|
||||||
...extractChangedFields(data, {}),
|
// ✅ FIXED: Don't use extractChangedFields for CREATE - include ALL data
|
||||||
|
...(() => {
|
||||||
|
const { images, ...dataWithoutImages } = data;
|
||||||
|
return dataWithoutImages;
|
||||||
|
})(),
|
||||||
company_type: 'manufacturer',
|
company_type: 'manufacturer',
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
@@ -1244,7 +1257,11 @@ export async function submitDesignerCreation(
|
|||||||
item_type: 'designer',
|
item_type: 'designer',
|
||||||
action_type: 'create',
|
action_type: 'create',
|
||||||
item_data: {
|
item_data: {
|
||||||
...extractChangedFields(data, {}),
|
// ✅ FIXED: Don't use extractChangedFields for CREATE - include ALL data
|
||||||
|
...(() => {
|
||||||
|
const { images, ...dataWithoutImages } = data;
|
||||||
|
return dataWithoutImages;
|
||||||
|
})(),
|
||||||
company_type: 'designer',
|
company_type: 'designer',
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
@@ -1350,7 +1367,11 @@ export async function submitOperatorCreation(
|
|||||||
item_type: 'operator',
|
item_type: 'operator',
|
||||||
action_type: 'create',
|
action_type: 'create',
|
||||||
item_data: {
|
item_data: {
|
||||||
...extractChangedFields(data, {}),
|
// ✅ FIXED: Don't use extractChangedFields for CREATE - include ALL data
|
||||||
|
...(() => {
|
||||||
|
const { images, ...dataWithoutImages } = data;
|
||||||
|
return dataWithoutImages;
|
||||||
|
})(),
|
||||||
company_type: 'operator',
|
company_type: 'operator',
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
@@ -1456,7 +1477,11 @@ export async function submitPropertyOwnerCreation(
|
|||||||
item_type: 'property_owner',
|
item_type: 'property_owner',
|
||||||
action_type: 'create',
|
action_type: 'create',
|
||||||
item_data: {
|
item_data: {
|
||||||
...extractChangedFields(data, {}),
|
// ✅ FIXED: Don't use extractChangedFields for CREATE - include ALL data
|
||||||
|
...(() => {
|
||||||
|
const { images, ...dataWithoutImages } = data;
|
||||||
|
return dataWithoutImages;
|
||||||
|
})(),
|
||||||
company_type: 'property_owner',
|
company_type: 'property_owner',
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user