Add coaster-specific fields

This commit is contained in:
gpt-engineer-app[bot]
2025-10-30 12:35:48 +00:00
parent 8795e756ce
commit 05217b00d4
8 changed files with 192 additions and 31 deletions

View File

@@ -20,6 +20,7 @@ import { FlexibleDateInput, type DatePrecision } from '@/components/ui/flexible-
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import { Combobox } from '@/components/ui/combobox';
import { SlugField } from '@/components/ui/slug-field';
import { Checkbox } from '@/components/ui/checkbox';
import { toast } from '@/hooks/use-toast';
import { handleError } from '@/lib/errorHandler';
import { Plus, Zap, Save, X } from 'lucide-react';
@@ -97,6 +98,39 @@ const intensityLevels = [
'extreme'
];
const TRACK_MATERIALS = [
{ value: 'wood', label: 'Wood' },
{ value: 'steel', label: 'Steel' },
{ value: 'hybrid', label: 'Hybrid' },
{ value: 'aluminum', label: 'Aluminum' },
{ value: 'composite', label: 'Composite' },
{ value: 'other', label: 'Other' },
];
const SUPPORT_MATERIALS = [
{ value: 'steel', label: 'Steel' },
{ value: 'wood', label: 'Wood' },
{ value: 'concrete', label: 'Concrete' },
{ value: 'aluminum', label: 'Aluminum' },
{ value: 'composite', label: 'Composite' },
{ value: 'other', label: 'Other' },
];
const PROPULSION_METHODS = [
{ value: 'chain_lift', label: 'Chain Lift' },
{ value: 'cable_lift', label: 'Cable Lift' },
{ value: 'friction_wheel_lift', label: 'Friction Wheel Lift' },
{ value: 'lsm_launch', label: 'LSM Launch' },
{ value: 'lim_launch', label: 'LIM Launch' },
{ value: 'hydraulic_launch', label: 'Hydraulic Launch' },
{ value: 'compressed_air_launch', label: 'Compressed Air Launch' },
{ value: 'flywheel_launch', label: 'Flywheel Launch' },
{ value: 'gravity', label: 'Gravity' },
{ value: 'tire_drive', label: 'Tire Drive' },
{ value: 'water_propulsion', label: 'Water Propulsion' },
{ value: 'other', label: 'Other' },
];
// Status value mappings between display (form) and database values
const STATUS_DISPLAY_TO_DB: Record<string, string> = {
'Operating': 'operating',
@@ -645,24 +679,82 @@ export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }:
</Select>
</div>
<div className="space-y-2">
<Label>Track Material</Label>
<Select
onValueChange={(value) => setValue('track_material', value === '' ? undefined : value as 'wood' | 'steel' | 'hybrid' | 'aluminum' | 'other')}
defaultValue={initialData?.track_material || ''}
>
<SelectTrigger>
<SelectValue placeholder="Select track material" />
</SelectTrigger>
<SelectContent>
<SelectItem value="">None</SelectItem>
<SelectItem value="wood">Wood</SelectItem>
<SelectItem value="steel">Steel</SelectItem>
<SelectItem value="hybrid">Hybrid (Wood/Steel)</SelectItem>
<SelectItem value="aluminum">Aluminum</SelectItem>
<SelectItem value="other">Other</SelectItem>
</SelectContent>
</Select>
<div className="space-y-3">
<Label>Track Material(s)</Label>
<p className="text-sm text-muted-foreground">Select all materials used in the track</p>
<div className="grid grid-cols-2 gap-3">
{TRACK_MATERIALS.map((material) => (
<div key={material.value} className="flex items-center space-x-2">
<Checkbox
id={`track_${material.value}`}
checked={watch('track_material')?.includes(material.value) || false}
onCheckedChange={(checked) => {
const current = watch('track_material') || [];
if (checked) {
setValue('track_material', [...current, material.value]);
} else {
setValue('track_material', current.filter((v) => v !== material.value));
}
}}
/>
<Label htmlFor={`track_${material.value}`} className="font-normal cursor-pointer">
{material.label}
</Label>
</div>
))}
</div>
</div>
<div className="space-y-3">
<Label>Support Material(s)</Label>
<p className="text-sm text-muted-foreground">Select all materials used in the supports</p>
<div className="grid grid-cols-2 gap-3">
{SUPPORT_MATERIALS.map((material) => (
<div key={material.value} className="flex items-center space-x-2">
<Checkbox
id={`support_${material.value}`}
checked={watch('support_material')?.includes(material.value) || false}
onCheckedChange={(checked) => {
const current = watch('support_material') || [];
if (checked) {
setValue('support_material', [...current, material.value]);
} else {
setValue('support_material', current.filter((v) => v !== material.value));
}
}}
/>
<Label htmlFor={`support_${material.value}`} className="font-normal cursor-pointer">
{material.label}
</Label>
</div>
))}
</div>
</div>
<div className="space-y-3">
<Label>Propulsion Method(s)</Label>
<p className="text-sm text-muted-foreground">Select all propulsion methods used</p>
<div className="grid grid-cols-2 gap-3">
{PROPULSION_METHODS.map((method) => (
<div key={method.value} className="flex items-center space-x-2">
<Checkbox
id={`propulsion_${method.value}`}
checked={watch('propulsion_method')?.includes(method.value) || false}
onCheckedChange={(checked) => {
const current = watch('propulsion_method') || [];
if (checked) {
setValue('propulsion_method', [...current, method.value]);
} else {
setValue('propulsion_method', current.filter((v) => v !== method.value));
}
}}
/>
<Label htmlFor={`propulsion_${method.value}`} className="font-normal cursor-pointer">
{method.label}
</Label>
</div>
))}
</div>
</div>
</div>