mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-23 23:46:35 +00:00
fix(public transit): only show public transit option when a trip has actual dates
This commit is contained in:
@@ -387,6 +387,13 @@ describe('TransportModal', () => {
|
||||
expect(screen.queryByPlaceholderText(/e\.g\. Lufthansa/i)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-PLANNER-TRANSMODAL-022b: a trip without start/end dates only offers the manual form', () => {
|
||||
render(<TransportModal {...defaultProps} tripHasDates={false} places={[]} accommodations={[]} />);
|
||||
expect(screen.queryByRole('button', { name: 'Automated transport' })).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole('button', { name: 'Manual transport' })).not.toBeInTheDocument();
|
||||
expect(screen.getByPlaceholderText(/e\.g\. Lufthansa/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-PLANNER-TRANSMODAL-023: initialAutomated opens straight in the transit search with the day preset', () => {
|
||||
const days = [{ id: 10, trip_id: 1, day_number: 1, date: '2025-06-01', title: 'Day 1' }] as any;
|
||||
render(<TransportModal {...defaultProps} days={days} selectedDayId={10} initialAutomated places={[]} accommodations={[]} />);
|
||||
|
||||
@@ -156,11 +156,13 @@ interface TransportModalProps {
|
||||
accommodations?: Accommodation[]
|
||||
/** Open directly in the Automated public-transit mode (day-header tram button, "change route"). */
|
||||
initialAutomated?: boolean
|
||||
/** Transit search needs real dates to depart on, so the Automated mode is hidden on a dateless trip. */
|
||||
tripHasDates?: boolean
|
||||
/** Pre-seed the transit search — used by "change route" on an existing journey. */
|
||||
transitPrefill?: { from?: PickedPlace | null; to?: PickedPlace | null } | null
|
||||
}
|
||||
|
||||
export function TransportModal({ isOpen, onClose, onSave, reservation, days, selectedDayId, files = [], onFileUpload, onFileDelete, onOpenExpense, prefill = null, places = [], assignments = {}, accommodations = [], initialAutomated = false, transitPrefill = null }: TransportModalProps) {
|
||||
export function TransportModal({ isOpen, onClose, onSave, reservation, days, selectedDayId, files = [], onFileUpload, onFileDelete, onOpenExpense, prefill = null, places = [], assignments = {}, accommodations = [], initialAutomated = false, transitPrefill = null, tripHasDates = true }: TransportModalProps) {
|
||||
const { t, locale } = useTranslation()
|
||||
const toast = useToast()
|
||||
const isBudgetEnabled = useAddonStore(s => s.isEnabled('budget'))
|
||||
@@ -606,8 +608,10 @@ export function TransportModal({ isOpen, onClose, onSave, reservation, days, sel
|
||||
}
|
||||
>
|
||||
{/* Manual vs Automated creation switch (#1065) — creating only; editing a
|
||||
journey re-enters via "change route" with the switch hidden. */}
|
||||
{!reservation && (
|
||||
journey re-enters via "change route" with the switch hidden. Without
|
||||
trip dates there is nothing to plan a departure against, so Automated
|
||||
is not offered and only the manual form shows. */}
|
||||
{!reservation && tripHasDates && (
|
||||
<div className="bg-surface-secondary" style={{ display: 'flex', borderRadius: 11, padding: 3, gap: 2, marginBottom: 14 }}>
|
||||
{([['manual', t('transport.modeManual')], ['automated', t('transport.modeAutomated')]] as const).map(([m, label]) => {
|
||||
const active = (m === 'automated') === automated
|
||||
|
||||
Reference in New Issue
Block a user