mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 08:11:13 -05:00
Refactor: Update user list item interfaces
This commit is contained in:
@@ -36,43 +36,10 @@ export function transformParkData(submissionData: any): ParkInsert {
|
||||
|
||||
/**
|
||||
* Transform ride submission data to database insert format
|
||||
* Note: Relational data (technical_specs, coaster_stats, former_names) are now
|
||||
* stored in separate tables and should not be included in the main ride insert.
|
||||
*/
|
||||
export function transformRideData(submissionData: any): RideInsert {
|
||||
// Parse JSON fields if they're strings
|
||||
let coasterStats = null;
|
||||
let technicalSpecs = null;
|
||||
let formerNames = null;
|
||||
|
||||
try {
|
||||
if (submissionData.coaster_stats) {
|
||||
coasterStats = typeof submissionData.coaster_stats === 'string'
|
||||
? JSON.parse(submissionData.coaster_stats)
|
||||
: submissionData.coaster_stats;
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Failed to parse coaster_stats:', e);
|
||||
}
|
||||
|
||||
try {
|
||||
if (submissionData.technical_specs) {
|
||||
technicalSpecs = typeof submissionData.technical_specs === 'string'
|
||||
? JSON.parse(submissionData.technical_specs)
|
||||
: submissionData.technical_specs;
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Failed to parse technical_specs:', e);
|
||||
}
|
||||
|
||||
try {
|
||||
if (submissionData.former_names) {
|
||||
formerNames = typeof submissionData.former_names === 'string'
|
||||
? JSON.parse(submissionData.former_names)
|
||||
: submissionData.former_names;
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Failed to parse former_names:', e);
|
||||
}
|
||||
|
||||
return {
|
||||
name: submissionData.name,
|
||||
slug: submissionData.slug,
|
||||
@@ -99,9 +66,6 @@ export function transformRideData(submissionData: any): RideInsert {
|
||||
coaster_type: submissionData.coaster_type || null,
|
||||
seating_type: submissionData.seating_type || null,
|
||||
intensity_level: submissionData.intensity_level || null,
|
||||
coaster_stats: coasterStats,
|
||||
technical_specs: technicalSpecs,
|
||||
former_names: formerNames || [],
|
||||
banner_image_url: submissionData.banner_image_url || null,
|
||||
banner_image_id: submissionData.banner_image_id || null,
|
||||
card_image_url: submissionData.card_image_url || null,
|
||||
@@ -136,20 +100,10 @@ export function transformCompanyData(
|
||||
|
||||
/**
|
||||
* Transform ride model submission data to database insert format
|
||||
* Note: Technical specifications are now stored in the ride_model_technical_specifications
|
||||
* table and should not be included in the main ride model insert.
|
||||
*/
|
||||
export function transformRideModelData(submissionData: any): RideModelInsert {
|
||||
let technicalSpecs = null;
|
||||
|
||||
try {
|
||||
if (submissionData.technical_specs) {
|
||||
technicalSpecs = typeof submissionData.technical_specs === 'string'
|
||||
? JSON.parse(submissionData.technical_specs)
|
||||
: submissionData.technical_specs;
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Failed to parse technical_specs:', e);
|
||||
}
|
||||
|
||||
return {
|
||||
name: submissionData.name,
|
||||
slug: submissionData.slug,
|
||||
@@ -157,7 +111,6 @@ export function transformRideModelData(submissionData: any): RideModelInsert {
|
||||
category: submissionData.category,
|
||||
ride_type: submissionData.ride_type || null,
|
||||
description: submissionData.description || null,
|
||||
technical_specs: technicalSpecs,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user