import React from 'react' import { useTranslation } from 'react-i18next' import { Ship, Camera, Trash2, Plus, X } from 'lucide-react' import type { VesselFormInputs } from '../utils/vesselFormUtils.js' export interface VesselDataFieldsProps { inputs: VesselFormInputs onChange: (next: VesselFormInputs) => void readOnly?: boolean saving?: boolean newSailName: string onNewSailNameChange: (value: string) => void onAddSail: () => void onRemoveSail: (index: number) => void photoError?: string | null onPhotoChange: (e: React.ChangeEvent) => void onRemovePhoto: () => void fileInputRef: React.RefObject } export default function VesselDataFields({ inputs, onChange, readOnly = false, saving = false, newSailName, onNewSailNameChange, onAddSail, onRemoveSail, photoError, onPhotoChange, onRemovePhoto, fileInputRef }: VesselDataFieldsProps) { const { t } = useTranslation() const set = (patch: Partial) => onChange({ ...inputs, ...patch }) const triggerFileInput = () => { if (!readOnly) fileInputRef.current?.click() } return (
{inputs.photo ? ( {inputs.name ) : (
)} {!readOnly && (
{inputs.photo ? t('vessel.photo_change') : t('vessel.photo_add')}
)}
{!readOnly && (
{inputs.photo && ( )}
)} {photoError &&
{photoError}
}
set({ name: e.target.value })} disabled={saving || readOnly} required />
set({ lengthM: e.target.value })} disabled={saving || readOnly} placeholder="0.00" />
set({ draftM: e.target.value })} disabled={saving || readOnly} placeholder="0.00" />
set({ airDraftM: e.target.value })} disabled={saving || readOnly} placeholder="0.00" />
set({ homePort: e.target.value })} disabled={saving || readOnly} />
set({ owner: e.target.value })} disabled={saving || readOnly} />
set({ charterCompany: e.target.value })} disabled={saving || readOnly} />
set({ registrationNumber: e.target.value })} disabled={saving || readOnly} />
set({ callSign: e.target.value })} disabled={saving || readOnly} />
set({ atis: e.target.value })} disabled={saving || readOnly} />
set({ mmsi: e.target.value })} disabled={saving || readOnly} />

{t('vessel.tanks_section')}

{t('vessel.tanks_help')}

set({ freshwaterCapacityL: e.target.value })} disabled={saving || readOnly} placeholder="0" />
set({ fuelCapacityL: e.target.value })} disabled={saving || readOnly} placeholder="0" />
set({ greywaterCapacityL: e.target.value })} disabled={saving || readOnly} placeholder="0" />

{t('vessel.sails_list')}

{t('vessel.sails_help')}

{inputs.sails.length === 0 ? ( {t('vessel.no_sails')} ) : ( inputs.sails.map((sail, idx) => ( {sail} {!readOnly && ( )} )) )}
{!readOnly && (
onNewSailNameChange(e.target.value)} disabled={saving} onKeyDown={(e) => { if (e.key === 'Enter') { e.preventDefault() onAddSail() } }} />
)}
) }