mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 14: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(),
|
intensity_level: z.string().optional(),
|
||||||
drop_height_meters: z.number().optional(),
|
drop_height_meters: z.number().optional(),
|
||||||
max_g_force: 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(),
|
former_names: z.string().optional(),
|
||||||
coaster_stats: z.string().optional(),
|
coaster_stats: z.string().optional(),
|
||||||
technical_specs: 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
|
drop_height_meters: data.drop_height_meters
|
||||||
? convertDistanceToMetric(data.drop_height_meters, measurementSystem)
|
? convertDistanceToMetric(data.drop_height_meters, measurementSystem)
|
||||||
: undefined,
|
: undefined,
|
||||||
// Add structured data from advanced editors
|
// ⚠️ Remove JSON stringification - use relational tables instead
|
||||||
technical_specs: JSON.stringify(technicalSpecs),
|
// These fields are deprecated and should not be set
|
||||||
coaster_stats: JSON.stringify(coasterStats),
|
technical_specs: undefined,
|
||||||
former_names: JSON.stringify(formerNames)
|
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
|
// Pass clean data to parent
|
||||||
const submissionContent: any = {
|
await onSubmit(metricData as 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);
|
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
title: isEditing ? "Ride Updated" : "Submission Sent",
|
title: isEditing ? "Ride Updated" : "Submission Sent",
|
||||||
|
|||||||
Reference in New Issue
Block a user