The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(tours): keep the day menu items with the stage logic their views import
Maurice7fa8b3fe35ee
diff --git a/client/src/components/Admin/AddonManager.test.tsx b/client/src/components/Admin/AddonManager.test.tsxindex 26781b73d..c5fc07f8c 100644--- a/client/src/components/Admin/AddonManager.test.tsx+++ b/client/src/components/Admin/AddonManager.test.tsx@@ -78,7 +78,11 @@ beforeEach(() => {vi.spyOn(useAddonStore.getState(), 'loadAddons').mockResolvedValue(undefined);server.use(http.get('/api/admin/addons', () => HttpResponse.json({ addons: [] })),- http.get('/api/admin/tours-wanderer', () => HttpResponse.json({ enabled: false }))+ http.get('/api/admin/tours-wanderer', () => HttpResponse.json({ enabled: false })),+ // The Tours switches load beside the list; unanswered, each would toast the same error as a failed list.+ http.get('/api/admin/tours-hiking-map', () => HttpResponse.json({ enabled: false })),+ http.get('/api/admin/tours-cycle-map', () => HttpResponse.json({ enabled: false })),+ http.get('/api/admin/tours-ski-routing', () => HttpResponse.json({ enabled: false })));});diff --git a/client/src/components/Tours/stages/TourDayAddButton.tsx b/client/src/components/Tours/stages/TourDayAddButton.tsxindex 7ded23cbe..0fddbb560 100644--- a/client/src/components/Tours/stages/TourDayAddButton.tsx+++ b/client/src/components/Tours/stages/TourDayAddButton.tsx@@ -3,7 +3,7 @@ import type { MouseEvent } from 'react';import { useTranslation } from '../../../i18n';import { ContextMenu, useContextMenu } from '../../shared/ContextMenu';import { DialogButton } from '../../shared/DialogShell';-import { tourDayHowItems, type TourDayHowInput } from './tourDayHowItems';+import { tourDayHowItems, type TourDayHowInput } from './stageSpread';/*** The detail's "Add to day" for the day selected in the plan. A day tour goesdiff --git a/client/src/components/Tours/stages/stageSpread.ts b/client/src/components/Tours/stages/stageSpread.tsindex 034d59005..e303c1911 100644--- a/client/src/components/Tours/stages/stageSpread.ts+++ b/client/src/components/Tours/stages/stageSpread.ts@@ -1,6 +1,10 @@import type { TourListItem } from '@trek/shared';+import { CalendarDays, CalendarRange } from 'lucide-react';import type { useTranslation } from '../../../i18n';import type { AssignmentsMap, Day } from '../../../types';+import type { useContextMenu } from '../../shared/ContextMenu';+import { dayMenuLabel } from '../tourDays';+import type { TourDayAssignment } from '../useTourDayAssignment';type Translate = ReturnType<typeof useTranslation>['t'];@@ -168,3 +172,44 @@ export function tourDayChoices({ count, fit, wholeFree }: TourDayChoiceFacts, t:},];}++type MenuItems = Parameters<ReturnType<typeof useContextMenu>['open']>[1];++export interface TourDayHowInput {+ placeId: number;+ dayId: number;+ days: Day[];+ /** The stages of the multi-day tour. */+ stageCount: number;+ assignment: TourDayAssignment;+}++/**+ * MDT-02: the two ways a multi-day tour goes on a day, as menu items: whole,+ * or a stage a day from it on, under the day they act on, so the step after+ * the day menu still says which day was picked. Whole is greyed out on a day+ * that holds the tour already, and says so; the stages say how many fit when+ * the trip ends before them.+ */+export function tourDayHowItems(input: TourDayHowInput, t: Translate, locale: string): MenuItems {+ const { placeId, dayId, days, stageCount, assignment } = input;+ const facts = {+ count: stageCount,+ fit: stagesThatFit(days, dayId, stageCount),+ wholeFree: !assignment.isOnDay(placeId, dayId),+ };+ const ways = tourDayChoices(facts, t).map((choice) => {+ const disabled = choice.disabled || !assignment.isAvailable(placeId, dayId, choice.how);+ return {+ label: choice.title,+ // Greyed out with no reason reads as broken; the reason goes right under it.+ hint: choice.disabled && choice.how === 'whole' ? choice.hint : undefined,+ icon: choice.how === 'whole' ? CalendarDays : CalendarRange,+ disabled,+ onClick: () => void assignment.assign(placeId, dayId, choice.how),+ };+ });+ const at = days.findIndex((day) => day.id === dayId);+ if (at < 0) return ways;+ return [{ label: dayMenuLabel(days[at], at, t, locale), heading: true }, ...ways];+}diff --git a/client/src/components/Tours/stages/tourDayHowItems.ts b/client/src/components/Tours/stages/tourDayHowItems.tsdeleted file mode 100644index 21460733a..000000000--- a/client/src/components/Tours/stages/tourDayHowItems.ts+++ /dev/null@@ -1,49 +0,0 @@-import { CalendarDays, CalendarRange } from 'lucide-react';-import type { useTranslation } from '../../../i18n';-import type { Day } from '../../../types';-import type { useContextMenu } from '../../shared/ContextMenu';-import { dayMenuLabel } from '../tourDays';-import type { TourDayAssignment } from '../useTourDayAssignment';-import { stagesThatFit, tourDayChoices } from './stageSpread';--type Translate = ReturnType<typeof useTranslation>['t'];-type MenuItems = Parameters<ReturnType<typeof useContextMenu>['open']>[1];--export interface TourDayHowInput {- placeId: number;- dayId: number;- days: Day[];- /** The stages of the multi-day tour. */- stageCount: number;- assignment: TourDayAssignment;-}--/**- * MDT-02: the two ways a multi-day tour goes on a day, as menu items: whole,- * or a stage a day from it on, under the day they act on, so the step after- * the day menu still says which day was picked. Whole is greyed out on a day- * that holds the tour already, and says so; the stages say how many fit when- * the trip ends before them.- */-export function tourDayHowItems(input: TourDayHowInput, t: Translate, locale: string): MenuItems {- const { placeId, dayId, days, stageCount, assignment } = input;- const facts = {- count: stageCount,- fit: stagesThatFit(days, dayId, stageCount),- wholeFree: !assignment.isOnDay(placeId, dayId),- };- const ways = tourDayChoices(facts, t).map((choice) => {- const disabled = choice.disabled || !assignment.isAvailable(placeId, dayId, choice.how);- return {- label: choice.title,- // Greyed out with no reason reads as broken; the reason goes right under it.- hint: choice.disabled && choice.how === 'whole' ? choice.hint : undefined,- icon: choice.how === 'whole' ? CalendarDays : CalendarRange,- disabled,- onClick: () => void assignment.assign(placeId, dayId, choice.how),- };- });- const at = days.findIndex((day) => day.id === dayId);- if (at < 0) return ways;- return [{ label: dayMenuLabel(days[at], at, t, locale), heading: true }, ...ways];-}diff --git a/client/src/components/Tours/tourParts.tsx b/client/src/components/Tours/tourParts.tsxindex a3e66575d..7ad46502f 100644--- a/client/src/components/Tours/tourParts.tsx+++ b/client/src/components/Tours/tourParts.tsx@@ -18,7 +18,7 @@ import type { TourDayAssignment } from './useTourDayAssignment'import { useRailFold } from './railFold'import { tourDayRowIcon } from './tourDayRowIcon'import { SkiCornerMark } from './ski/skiMarks'-import { tourDayHowItems } from './stages/tourDayHowItems'+import { tourDayHowItems } from './stages/stageSpread'/*** A tour's tile in a list: its T-scale grade in place of the mountain, named in