mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 02:51:13 -05:00
Implement all phases sequentially
This commit is contained in:
@@ -64,12 +64,12 @@ const categories = [
|
||||
|
||||
const statusOptions = [
|
||||
'Operating',
|
||||
'Seasonal',
|
||||
'Closed Temporarily',
|
||||
'Closed Permanently',
|
||||
'Under Construction',
|
||||
'Planned',
|
||||
'SBNO' // Standing But Not Operating
|
||||
'Relocated',
|
||||
'Stored',
|
||||
'Demolished'
|
||||
];
|
||||
|
||||
const coasterTypes = [
|
||||
@@ -99,20 +99,22 @@ const intensityLevels = [
|
||||
// Status value mappings between display (form) and database values
|
||||
const STATUS_DISPLAY_TO_DB: Record<string, string> = {
|
||||
'Operating': 'operating',
|
||||
'Seasonal': 'operating',
|
||||
'Closed Temporarily': 'maintenance',
|
||||
'Closed Permanently': 'closed',
|
||||
'Closed Temporarily': 'closed_temporarily',
|
||||
'Closed Permanently': 'closed_permanently',
|
||||
'Under Construction': 'under_construction',
|
||||
'Planned': 'under_construction',
|
||||
'SBNO': 'sbno'
|
||||
'Relocated': 'relocated',
|
||||
'Stored': 'stored',
|
||||
'Demolished': 'demolished'
|
||||
};
|
||||
|
||||
const STATUS_DB_TO_DISPLAY: Record<string, string> = {
|
||||
'operating': 'Operating',
|
||||
'closed': 'Closed Permanently',
|
||||
'closed_permanently': 'Closed Permanently',
|
||||
'closed_temporarily': 'Closed Temporarily',
|
||||
'under_construction': 'Under Construction',
|
||||
'maintenance': 'Closed Temporarily',
|
||||
'sbno': 'SBNO'
|
||||
'relocated': 'Relocated',
|
||||
'stored': 'Stored',
|
||||
'demolished': 'Demolished'
|
||||
};
|
||||
|
||||
export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }: RideFormProps) {
|
||||
@@ -180,9 +182,7 @@ export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }:
|
||||
description: initialData?.description || '',
|
||||
category: initialData?.category || '',
|
||||
ride_sub_type: initialData?.ride_sub_type || '',
|
||||
status: initialData?.status
|
||||
? STATUS_DB_TO_DISPLAY[initialData.status] || 'Operating'
|
||||
: 'Operating',
|
||||
status: initialData?.status || 'operating' as const, // Store DB value directly
|
||||
opening_date: initialData?.opening_date || '',
|
||||
opening_date_precision: initialData?.opening_date_precision || 'day',
|
||||
closing_date: initialData?.closing_date || '',
|
||||
@@ -223,13 +223,10 @@ export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }:
|
||||
const handleFormSubmit = async (data: RideFormData) => {
|
||||
setSubmitting(true);
|
||||
try {
|
||||
// Transform status from display value to DB value
|
||||
const dbStatus = STATUS_DISPLAY_TO_DB[data.status] || 'operating';
|
||||
|
||||
// Convert form values back to metric for storage
|
||||
const metricData = {
|
||||
...data,
|
||||
status: dbStatus,
|
||||
// Status is already in DB format
|
||||
height_requirement: data.height_requirement
|
||||
? convertValueToMetric(data.height_requirement, getDisplayUnit('cm', measurementSystem))
|
||||
: undefined,
|
||||
@@ -354,21 +351,21 @@ export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }:
|
||||
<div className="space-y-2">
|
||||
<Label>Status *</Label>
|
||||
<Select
|
||||
onValueChange={(value) => setValue('status', value)}
|
||||
defaultValue={initialData?.status
|
||||
? STATUS_DB_TO_DISPLAY[initialData.status] || 'Operating'
|
||||
: 'Operating'
|
||||
}
|
||||
onValueChange={(value) => setValue('status', value as any)}
|
||||
defaultValue={initialData?.status || 'operating'}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Select status" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{statusOptions.map((status) => (
|
||||
<SelectItem key={status} value={status}>
|
||||
{status}
|
||||
</SelectItem>
|
||||
))}
|
||||
{statusOptions.map((displayStatus) => {
|
||||
const dbValue = STATUS_DISPLAY_TO_DB[displayStatus];
|
||||
return (
|
||||
<SelectItem key={dbValue} value={dbValue}>
|
||||
{displayStatus}
|
||||
</SelectItem>
|
||||
);
|
||||
})}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
{errors.status && (
|
||||
|
||||
Reference in New Issue
Block a user