mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 10:11:13 -05:00
Fix JSON storage violations
This commit is contained in:
@@ -59,6 +59,8 @@ const rideSchema = z.object({
|
||||
intensity_level: z.string().optional(),
|
||||
drop_height_meters: z.number().optional(),
|
||||
max_g_force: z.number().optional(),
|
||||
// ⚠️ DEPRECATED - These legacy JSON fields should not be used
|
||||
// Use relational tables instead: ride_technical_specifications, ride_coaster_statistics, ride_name_history
|
||||
former_names: z.string().optional(),
|
||||
coaster_stats: z.string().optional(),
|
||||
technical_specs: z.string().optional(),
|
||||
@@ -259,38 +261,21 @@ export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }:
|
||||
drop_height_meters: data.drop_height_meters
|
||||
? convertDistanceToMetric(data.drop_height_meters, measurementSystem)
|
||||
: undefined,
|
||||
// Add structured data from advanced editors
|
||||
technical_specs: JSON.stringify(technicalSpecs),
|
||||
coaster_stats: JSON.stringify(coasterStats),
|
||||
former_names: JSON.stringify(formerNames)
|
||||
// ⚠️ Remove JSON stringification - use relational tables instead
|
||||
// These fields are deprecated and should not be set
|
||||
technical_specs: undefined,
|
||||
coaster_stats: undefined,
|
||||
former_names: undefined,
|
||||
// Pass relational data for proper handling
|
||||
_technical_specifications: technicalSpecs,
|
||||
_coaster_statistics: coasterStats,
|
||||
_name_history: formerNames,
|
||||
_tempNewManufacturer: tempNewManufacturer,
|
||||
_tempNewRideModel: tempNewRideModel
|
||||
};
|
||||
|
||||
// Build composite submission if new entities were created
|
||||
const submissionContent: any = {
|
||||
ride: metricData,
|
||||
// Include structured data for relational tables
|
||||
technical_specifications: technicalSpecs,
|
||||
coaster_statistics: coasterStats,
|
||||
name_history: formerNames
|
||||
};
|
||||
|
||||
// Add new manufacturer if created
|
||||
if (tempNewManufacturer) {
|
||||
submissionContent.new_manufacturer = tempNewManufacturer;
|
||||
submissionContent.ride.manufacturer_id = null; // Clear since using new
|
||||
}
|
||||
|
||||
// Add new ride model if created
|
||||
if (tempNewRideModel) {
|
||||
submissionContent.new_ride_model = tempNewRideModel;
|
||||
submissionContent.ride.ride_model_id = null; // Clear since using new
|
||||
}
|
||||
|
||||
// Pass composite data to parent
|
||||
await onSubmit({
|
||||
...metricData,
|
||||
_compositeSubmission: submissionContent
|
||||
} as any);
|
||||
// Pass clean data to parent
|
||||
await onSubmit(metricData as any);
|
||||
|
||||
toast({
|
||||
title: isEditing ? "Ride Updated" : "Submission Sent",
|
||||
|
||||
Reference in New Issue
Block a user