diff --git a/client/scripts/feature-pairs.json b/client/scripts/feature-pairs.json index 808ffd82a..bbc3041f2 100644 --- a/client/scripts/feature-pairs.json +++ b/client/scripts/feature-pairs.json @@ -227,7 +227,11 @@ "src/pages/sharedTrip/SharedBookingsView.tsx", "src/pages/sharedTrip/SharedDayCard.tsx" ], - "mobile": ["src/mobile/screens/trip/tabs/MBookingsTab.tsx", "src/mobile/screens/trip/tabs/MTransportsTab.tsx"] + "mobile": [ + "src/mobile/screens/trip/tabs/MBookingsTab.tsx", + "src/mobile/screens/trip/tabs/MTransportsTab.tsx", + "src/mobile/screens/trip/MItineraryBookingCard.tsx" + ] }, { "feature": "Bottom nav context-aware create action", @@ -267,6 +271,12 @@ "desktop": ["src/components/Collab/useCollabChat.ts"], "mobile": ["src/mobile/screens/trip/tabs/MCollabChat.tsx"] }, + { + "feature": "Collab links", + "hooks": ["src/components/Collab/useCollabLinks.ts"], + "desktop": ["src/components/Collab/CollabLinks.tsx"], + "mobile": ["src/mobile/screens/trip/tabs/MCollabLinks.tsx"] + }, { "feature": "Collab notes", "hooks": ["src/components/Collab/useCollabNotesData.ts"], @@ -398,7 +408,7 @@ "src/mobile/screens/collections/MCollEditSheet.tsx", "src/mobile/screens/collections/MCollPlaceRow.tsx", "src/mobile/screens/collections/MCollPlaceSheet.tsx", - "src/mobile/screens/collections/MCollections.tsx" + "src/mobile/screens/collections/MCollSavedFilters.tsx" ] }, { @@ -438,7 +448,7 @@ "feature": "Costs/budget splitting or totals only: useCostsMode", "hooks": ["src/components/Budget/useCostsMode.ts"], "desktop": ["src/components/Budget/CostsModeCard.tsx"], - "mobile": ["src/mobile/screens/trip/tabs/MCostsTab.tsx"] + "mobile": ["src/mobile/screens/trip/sheets/MTripSettingsSheet.tsx"] }, { "feature": "Costs/budget settle-up payment: useSettlementForm", @@ -600,10 +610,8 @@ "src/pages/journeyPublic/useJourneyPublic.ts" ], "mobile": [ - "src/mobile/screens/journey/MJourneyCreateSheet.tsx", "src/mobile/screens/journey/MJourneyDetail.tsx", "src/mobile/screens/journey/MJourneyEntrySheet.tsx", - "src/mobile/screens/journey/MJourneySettingsSheet.tsx", "src/mobile/screens/journey/mobileJourneyMeta.ts" ] }, @@ -864,12 +872,6 @@ "desktop": ["src/components/Roadtrip/RoadtripStopPopup.tsx"], "mobile": ["src/mobile/screens/trip/roadtrip/MRtDraftSheet.tsx"] }, - { - "feature": "Road-trip Google Maps route import", - "hooks": ["src/components/Roadtrip/useGoogleRouteImport.ts"], - "desktop": ["src/components/Roadtrip/GoogleRouteImport.tsx"], - "mobile": ["src/mobile/screens/trip/roadtrip/MRtRouteImportSheet.tsx"] - }, { "feature": "Road-trip stay length draft", "hooks": ["src/components/Roadtrip/useStayDraft.ts"], @@ -1059,11 +1061,13 @@ "src/components/Planner/ReservationsPanel.tsx", "src/components/Planner/bookings/BookingDetailHost.tsx" ], - "mobile": [ - "src/mobile/screens/trip/sheets/MTransportSheet.tsx", - "src/mobile/screens/trip/tabs/MBookingsTab.tsx", - "src/mobile/screens/trip/tabs/MTransportsTab.tsx" - ] + "mobile": ["src/mobile/screens/trip/sheets/MTransportSheet.tsx"] + }, + { + "feature": "Transit itinerary facts and note formatting", + "hooks": ["src/components/Planner/transitJourneyModel.ts"], + "desktop": ["src/components/Planner/TransitJourneyModal.tsx"], + "mobile": ["src/mobile/screens/trip/sheets/MTransitJourneySheet.tsx"] }, { "feature": "Transport booking detail view: transportDetailModel", @@ -1234,6 +1238,7 @@ "src/mobile/screens/collections/collectionsMobileModel.ts": "Visual constants only the phone collections screens use (category and status specs, swatches, cover gradient).", "src/mobile/screens/dashboard/MUserMenu.tsx": "Phone avatar menu with a three state theme cycle the desktop navbar does not have.", "src/mobile/screens/journey/MDawarichDaySheet.tsx": "Markup only; the phone frame the Dawarich day sheets (route and stays) render their shared review in.", + "src/mobile/screens/journey/MJourneyCreateSheet.tsx": "The phone form receives the journey and trip selection state from MJourney, which shares useJourney with the desktop list.", "src/mobile/screens/journey/MJourneyFeed.tsx": "Markup only; the journey's entries as a feed beside the map on a wide window, with the entries, the active one and the tap handed in through props from useJourneyDetail and useJourneyCarouselSync.", "src/mobile/screens/settings/MAppLockCard.tsx": "Phone only: the app lock exists only in the native app, so there is no desktop setting to share with.", "src/mobile/screens/settings/MClientCertCard.tsx": "Phone only: the client certificate is kept by the native app, so there is no desktop setting to share with.", @@ -1252,7 +1257,26 @@ "src/mobile/screens/trip/MTripShellParts.tsx": "Markup only; small pieces of MTripShell's top controls (segment pill, compact toggle, document sync button), with the state and handlers MTripShell hands in.", "src/mobile/screens/trip/dockTabs.ts": "Phone only helper that picks which trip tabs get a seat in the mobile dock.", "src/mobile/screens/trip/useTripTabSwitch.ts": "Phone shell only; switches the section the dock and a notification link open, and the collab part a message link means. The desktop switches through useTripPlanner alone.", - "src/mobile/screens/trip/lib/dayNotes.ts": "Phone only helper that splits a leading time off a day note for the plan timeline.", + "src/mobile/screens/collections/MCollColorSwatches.tsx": "Shared color chooser for the phone list and tag forms.", + "src/mobile/screens/collections/MCollPlaceFields.tsx": "Shared layout of the nullable category, address and description fields in phone add and edit forms.", + "src/mobile/screens/collections/MCollToolbar.tsx": "Search, view and filter controls shared by the two phone collection lists.", + "src/mobile/screens/journey/MJourneyInviteFrame.tsx": "Phone invitation layout over the shared ContributorInviteDialog controller.", + "src/mobile/screens/journey/MJourneyEntryRead.tsx": "Phone journal reader over the shared markdown, photo and entry title models.", + "src/mobile/screens/journey/MJourneyVerdict.tsx": "Phone verdict layout shared by the reader and the editor; writes use the shared journey entry form.", + "src/mobile/screens/trip/map/MMapExplore.tsx": "Phone entry points and panels for the shared map exploration state.", + "src/mobile/screens/trip/map/MMapPlaceFilters.tsx": "Phone sheet presenting map and place visibility controls.", + "src/mobile/screens/trip/roadtrip/MRtChoice.tsx": "Phone grid option for the Roadtrip corridor sheets.", + "src/mobile/screens/trip/roadtrip/stageBookings.ts": "Places bookings and their approaches within the phone stage timeline using the shared Roadtrip router and stop associations.", + "src/mobile/screens/trip/sheets/MBookingImportSheet.tsx": "Phone presentation passed to the shared booking import controller.", + "src/mobile/screens/trip/sheets/MDayPickerSheet.tsx": "Searchable phone day picker, separate from the desktop day sidebar.", + "src/mobile/screens/trip/sheets/MGpxPreviewFrame.tsx": "Phone GPX preview layout over the shared TourGpxPreviewDialog controller.", + "src/mobile/screens/trip/sheets/MIcsSubscribeSheet.tsx": "Phone form for the shared calendar subscription hook.", + "src/mobile/screens/trip/sheets/MSubscribeLinks.tsx": "Phone provider and link actions for the shared subscription links hook.", + "src/mobile/screens/trip/sheets/MTripOfflinePage.tsx": "Trip-specific offline controls in the phone settings.", + "src/mobile/screens/trip/useMTripDayResume.ts": "Restores the last day in the phone's single-day planner.", + "src/mobile/screens/trip/tabs/MChecklistCheck.tsx": "Phone checkbox controls shared by trip tasks and packing.", + "src/mobile/screens/trip/sheets/MCurrencyPicker.tsx": "Searchable mobile currency picker shared by the dashboard and costs ledger.", + "src/mobile/screens/trip/tabs/MReservationList.tsx": "Shared phone shell for the bookings and transport tabs.", "src/mobile/screens/trip/map/MMapArea.tsx": "Phone map stage framing; already shares usePoiExplore and useMergedMapPois with the desktop trip planner.", "src/mobile/screens/trip/places/MPlacesBulkCategorySheet.tsx": "Markup only; categories and the pick handler come through props from MPlacesBrowser.", "src/mobile/screens/trip/places/MPlacesToursModeSwitch.tsx": "Markup only places or tours toggle; value and onChange come through props from MPlacesBrowser.", @@ -1288,7 +1312,7 @@ "src/mobile/screens/trip/sheets/PlTags.tsx": "Markup only; the tag picker's state comes through props from MPlaceEditSheet, which runs usePlaceTags, and the chips of the place sheet draw the tags the place carries.", "src/mobile/screens/trip/sheets/PlTimeFields.tsx": "Phone time fields that already share timeCollisions with the desktop PlaceFormModal.", "src/mobile/screens/trip/sheets/tourSheetOpen.ts": "Phone only context for MTourDetailShell: whether the tour sheet is open and the name it carries.", - "src/mobile/screens/trip/tabs/MCollabTab.tsx": "Phone collab sub tab router that reuses the desktop CollabLinks component.", + "src/mobile/screens/trip/tabs/MCollabTab.tsx": "Phone collab sub-tab router for the chat and boards.", "src/mobile/screens/trip/tabs/MFilesBoard.tsx": "Markup only; the trip's files as tiles and the picked file's preview on a wide window, with the files and their actions handed in through props from MFilesTab.", "src/mobile/screens/trip/tabs/MListsTab.tsx": "Phone router between the packing and to-do bodies, with no logic of its own.", "src/mobile/screens/trip/tabs/MPackingCategorySharingSheet.tsx": "Markup only; the sheet that shares a whole list, with its state from usePackingCategorySharing handed in through props by MPackingListTab.", diff --git a/client/scripts/i18n-unused-baseline.json b/client/scripts/i18n-unused-baseline.json index f5ffd6b37..54e175b43 100644 --- a/client/scripts/i18n-unused-baseline.json +++ b/client/scripts/i18n-unused-baseline.json @@ -1,25 +1,24 @@ { "admin.ts": 112, - "atlas.ts": 7, + "atlas.ts": 6, "backup.ts": 10, "budget.ts": 35, "categories.ts": 1, "collab.ts": 9, - "collection.ts": 29, + "collection.ts": 27, "common.ts": 6, - "dashboard.ts": 64, + "dashboard.ts": 60, "dawarich.ts": 15, "dayplan.ts": 17, "docsync.ts": 25, "files.ts": 4, "help.ts": 3, "inspector.ts": 4, - "journey.ts": 65, + "journey.ts": 64, "login.ts": 1, "map.ts": 5, "memories.ts": 8, "mobileNav.ts": 2, - "mobileVacay.ts": 4, "nav.ts": 1, "notif.ts": 7, "notifications.ts": 17, @@ -27,10 +26,10 @@ "pdf.ts": 1, "perm.ts": 4, "places.ts": 9, - "planner.ts": 52, - "reservations.ts": 21, + "planner.ts": 49, + "reservations.ts": 20, "roadtrip.ts": 36, - "settings.ts": 37, + "settings.ts": 36, "share.ts": 7, "shared.ts": 2, "storage.ts": 16, diff --git a/client/scripts/layers-baseline.json b/client/scripts/layers-baseline.json index 2c14dd2da..8bd83ba31 100644 --- a/client/scripts/layers-baseline.json +++ b/client/scripts/layers-baseline.json @@ -28,8 +28,6 @@ "src/components/Journey/MobileEntryView.tsx": 1, "src/components/Map/MapView.tsx": 1, "src/components/Map/MapViewGL.tsx": 1, - "src/components/Planner/IcsSubscribeModal.tsx": 1, - "src/components/Planner/TransitJourneyModal.tsx": 1, "src/components/Planner/TransitSearchPanel.tsx": 1, "src/components/Planner/TripWarningsBanner.tsx": 1, "src/components/Planner/transitDisplay.tsx": 1, diff --git a/client/scripts/offline-baseline.json b/client/scripts/offline-baseline.json index fbff7cf37..666a3172d 100644 --- a/client/scripts/offline-baseline.json +++ b/client/scripts/offline-baseline.json @@ -24,7 +24,6 @@ "src/components/Budget/ReceiptPreviewModal.tsx", "src/components/Budget/receiptUploads.ts", "src/components/Collab/CollabChatLinkPreview.tsx", - "src/components/Collab/CollabLinks.tsx", "src/components/Collab/CollabNotes.tsx", "src/components/Collab/CollabNotesAuthedImg.tsx", "src/components/Collab/CollabNotesFilePreviewPortal.tsx", diff --git a/client/scripts/rtl-baseline.json b/client/scripts/rtl-baseline.json index b73db3d3c..ce267eb02 100644 --- a/client/scripts/rtl-baseline.json +++ b/client/scripts/rtl-baseline.json @@ -13,7 +13,6 @@ "components/Journey/JourneyDetailPageGalleryView.tsx": 1, "components/Journey/JourneyDetailPagePhotoGrid.tsx": 1, "components/Journey/JourneyDetailPageProviderPicker.tsx": 1, - "components/Journey/JourneyEntryCover.tsx": 1, "components/Journey/JourneyMap.tsx": 1, "components/Journey/JourneyMapGL.tsx": 2, "components/Journey/MobileEntryView.tsx": 1, @@ -76,7 +75,7 @@ "hooks/useAnchoredPosition.ts": 3, "hooks/useElementRect.ts": 3, "mobile/components/MSegmented.tsx": 1, - "mobile/screens/journey/MJourneyDetail.tsx": 3, + "mobile/screens/journey/MJourneyDetail.tsx": 2, "mobile/screens/journey/MJourneyEntrySheet.tsx": 1, "mobile/screens/trip/map/MMapArea.tsx": 3, "mobile/screens/trip/tabs/MFileLightbox.tsx": 2, diff --git a/client/scripts/rtl-disable-baseline.json b/client/scripts/rtl-disable-baseline.json index 225945a30..0e9895549 100644 --- a/client/scripts/rtl-disable-baseline.json +++ b/client/scripts/rtl-disable-baseline.json @@ -5,6 +5,7 @@ "components/Studio/LineHandles.tsx": 1, "components/Studio/StudioSelectionChrome.tsx": 2, "components/Studio/inspector/FocalPad.tsx": 1, + "components/Tours/TourGpxPreviewDialog.tsx": 1, "mobile/components/trek3d/MascotClip.tsx": 1, "mobile/screens/trip/MTripShell.tsx": 1, "mobile/screens/vacay/MVacay.tsx": 1, diff --git a/client/scripts/strict-baseline.json b/client/scripts/strict-baseline.json index 640af04d8..5f144fbb3 100644 --- a/client/scripts/strict-baseline.json +++ b/client/scripts/strict-baseline.json @@ -96,7 +96,6 @@ "src/hooks/useDawarichSuggestions.test.ts": 1, "src/mobile/screens/admin/MAdminAddonManager.tsx": 2, "src/mobile/screens/admin/MAdminPluginsPanel.tsx": 6, - "src/mobile/screens/journey/MJourneySettingsSheet.tsx": 1, "src/mobile/screens/settings/MSettingsAccount.tsx": 1, "src/mobile/screens/trip/MTripShell.tsx": 1, "src/mobile/screens/trip/map/MMapArea.tsx": 1, diff --git a/client/scripts/theme-baseline.json b/client/scripts/theme-baseline.json index 380d752d7..680d82697 100644 --- a/client/scripts/theme-baseline.json +++ b/client/scripts/theme-baseline.json @@ -79,12 +79,10 @@ "components/Planner/BookingCostsSection.tsx": 1, "components/Planner/BookingImportModal.tsx": 4, "components/Planner/DayDetailPanel.tsx": 1, - "components/Planner/IcsSubscribeModal.tsx": 10, "components/Planner/PlaceInspector.tsx": 1, "components/Planner/PlacesSidebarMobileDayPicker.tsx": 3, "components/Planner/SubscribeLinks.tsx": 5, "components/Planner/SuggestionDropdown.tsx": 1, - "components/Planner/TransitJourneyModal.tsx": 4, "components/Planner/TransitSearchPanel.tsx": 2, "components/Planner/TravelerPicker.tsx": 3, "components/Planner/bookings/BookingsTimeline.tsx": 1, @@ -134,7 +132,6 @@ "components/shared/TrackColorPicker.tsx": 2, "components/shared/TripLoadingSplash.tsx": 10, "mobile/components/MBadge.tsx": 2, - "mobile/components/MBottomNav.tsx": 2, "mobile/components/MChip.tsx": 2, "mobile/components/MDayImpactList.tsx": 4, "mobile/components/MListRow.tsx": 1, @@ -142,7 +139,6 @@ "mobile/components/MSheet.tsx": 1, "mobile/components/MStorageTestResult.tsx": 3, "mobile/components/MToastHost.tsx": 2, - "mobile/components/MUserPickerList.tsx": 1, "mobile/screens/admin/MAdmin.tsx": 8, "mobile/screens/admin/MAdminAddonManager.tsx": 3, "mobile/screens/admin/MAdminAuditLogPanel.tsx": 15, @@ -162,31 +158,18 @@ "mobile/screens/admin/MAdminUi.tsx": 7, "mobile/screens/admin/MAdminUsersSection.tsx": 13, "mobile/screens/admin/MApiProviderBlocks.tsx": 10, - "mobile/screens/atlas/MAtlasCountryPopup.tsx": 11, "mobile/screens/atlas/MAtlasStatsCard.tsx": 2, - "mobile/screens/collections/MCollAddSheet.tsx": 6, - "mobile/screens/collections/MCollCategoryPicker.tsx": 2, - "mobile/screens/collections/MCollEditSheet.tsx": 2, - "mobile/screens/collections/MCollLabelsSheet.tsx": 6, - "mobile/screens/collections/MCollLinksEditor.tsx": 2, - "mobile/screens/collections/MCollListPickerSheet.tsx": 3, "mobile/screens/collections/MCollPlaceRow.tsx": 3, - "mobile/screens/collections/MCollShareSheet.tsx": 14, - "mobile/screens/collections/MCollSheetKit.tsx": 5, - "mobile/screens/collections/MCollTripPickerSheet.tsx": 4, - "mobile/screens/collections/MCollections.tsx": 9, - "mobile/screens/dashboard/MDashWidgets.tsx": 22, - "mobile/screens/dashboard/MDashboard.tsx": 30, - "mobile/screens/dashboard/MNewTripSheet.tsx": 12, + "mobile/screens/collections/MCollShareSheet.tsx": 1, + "mobile/screens/collections/MCollSheetKit.tsx": 3, + "mobile/screens/collections/MCollections.tsx": 2, + "mobile/screens/dashboard/MDashboard.tsx": 25, + "mobile/screens/dashboard/MNewTripSheet.tsx": 11, "mobile/screens/dashboard/MUserMenu.tsx": 7, "mobile/screens/journey/MJourney.tsx": 10, - "mobile/screens/journey/MJourneyCreateSheet.tsx": 7, - "mobile/screens/journey/MJourneyDetail.tsx": 6, - "mobile/screens/journey/MJourneyEntrySheet.tsx": 46, - "mobile/screens/journey/MJourneySettingsSheet.tsx": 2, + "mobile/screens/journey/MJourneyDetail.tsx": 3, + "mobile/screens/journey/MJourneyEntrySheet.tsx": 11, "mobile/screens/journey/mobileJourneyMeta.ts": 4, - "mobile/screens/notifications/MNotificationRow.tsx": 4, - "mobile/screens/notifications/MNotifications.tsx": 3, "mobile/screens/settings/MAirTrailConnectionSection.tsx": 2, "mobile/screens/settings/MConfirmSheet.tsx": 2, "mobile/screens/settings/MDawarichConnectionSection.tsx": 5, @@ -207,75 +190,49 @@ "mobile/screens/settings/MSettingsUi.tsx": 10, "mobile/screens/settings/MWebPushCard.tsx": 1, "mobile/screens/trip/MTripLoadingSplash.tsx": 2, - "mobile/screens/trip/MTripShell.tsx": 7, - "mobile/screens/trip/places/MPlacesBrowser.tsx": 10, + "mobile/screens/trip/MTripShell.tsx": 5, + "mobile/screens/trip/places/MPlacesBrowser.tsx": 1, "mobile/screens/trip/places/MPlacesBulkCategorySheet.tsx": 2, "mobile/screens/trip/places/MPlacesFilterControls.tsx": 1, "mobile/screens/trip/places/MPlacesSaveToCollectionSheet.tsx": 6, - "mobile/screens/trip/places/MPlacesToursModeSwitch.tsx": 1, - "mobile/screens/trip/plan/MPlanTimeline.tsx": 12, - "mobile/screens/trip/plan/MPlanTimelineRows.tsx": 24, - "mobile/screens/trip/roadtrip/MRoadtripRows.tsx": 31, - "mobile/screens/trip/roadtrip/MRoadtripTab.tsx": 16, - "mobile/screens/trip/roadtrip/MRtAlternativesBar.tsx": 8, + "mobile/screens/trip/plan/MPlanTimeline.tsx": 10, + "mobile/screens/trip/plan/MPlanTimelineRows.tsx": 12, + "mobile/screens/trip/roadtrip/MRoadtripRows.tsx": 18, + "mobile/screens/trip/roadtrip/MRoadtripTab.tsx": 11, "mobile/screens/trip/roadtrip/MRtCorridorBar.tsx": 2, - "mobile/screens/trip/roadtrip/MRtCorridorSheet.tsx": 7, - "mobile/screens/trip/roadtrip/MRtDraftSheet.tsx": 5, - "mobile/screens/trip/roadtrip/MRtInfoSheet.tsx": 9, - "mobile/screens/trip/roadtrip/MRtKindSheet.tsx": 3, - "mobile/screens/trip/roadtrip/MRtStaySheet.tsx": 17, - "mobile/screens/trip/roadtrip/MRtStopSheet.tsx": 12, - "mobile/screens/trip/sheets/ImpFileStep.tsx": 12, - "mobile/screens/trip/sheets/ImpListStep.tsx": 3, + "mobile/screens/trip/roadtrip/MRtCorridorSheet.tsx": 4, + "mobile/screens/trip/roadtrip/MRtKindSheet.tsx": 2, + "mobile/screens/trip/roadtrip/MRtStopSheet.tsx": 3, "mobile/screens/trip/sheets/MAccommodationSheet.tsx": 10, - "mobile/screens/trip/sheets/MBookingFields.tsx": 5, - "mobile/screens/trip/sheets/MBrowseActionsSheet.tsx": 3, - "mobile/screens/trip/sheets/MCostSheet.tsx": 33, - "mobile/screens/trip/sheets/MDaySheet.tsx": 22, - "mobile/screens/trip/sheets/MDaysSheet.tsx": 4, - "mobile/screens/trip/sheets/MExportSheet.tsx": 2, - "mobile/screens/trip/sheets/MImportSheet.tsx": 2, - "mobile/screens/trip/sheets/MLinkedCosts.tsx": 8, - "mobile/screens/trip/sheets/MMehrSheet.tsx": 3, - "mobile/screens/trip/sheets/MNoteSheet.tsx": 1, - "mobile/screens/trip/sheets/MPlaceEditSheet.tsx": 2, - "mobile/screens/trip/sheets/MPlaceSheet.tsx": 23, - "mobile/screens/trip/sheets/MReservationSheet.tsx": 2, - "mobile/screens/trip/sheets/MTransportFormSheet.tsx": 9, - "mobile/screens/trip/sheets/MTransportSheet.tsx": 9, + "mobile/screens/trip/sheets/MBookingFields.tsx": 4, + "mobile/screens/trip/sheets/MCostSheet.tsx": 23, + "mobile/screens/trip/sheets/MDaySheet.tsx": 5, + "mobile/screens/trip/sheets/MDaysSheet.tsx": 2, + "mobile/screens/trip/sheets/MLinkedCosts.tsx": 7, + "mobile/screens/trip/sheets/MPlaceSheet.tsx": 6, + "mobile/screens/trip/sheets/MReservationSheet.tsx": 1, + "mobile/screens/trip/sheets/MTransportSheet.tsx": 6, "mobile/screens/trip/sheets/MTripSheetUi.tsx": 5, "mobile/screens/trip/sheets/PlCategoryPicker.tsx": 1, - "mobile/screens/trip/sheets/PlFileAttach.tsx": 3, - "mobile/screens/trip/sheets/PlPlaceSearch.tsx": 6, - "mobile/screens/trip/sheets/PlSheetChrome.tsx": 5, + "mobile/screens/trip/sheets/PlPlaceSearch.tsx": 2, + "mobile/screens/trip/sheets/PlSheetChrome.tsx": 1, "mobile/screens/trip/sheets/PlTimeFields.tsx": 3, "mobile/screens/trip/tabs/MBagsSheet.tsx": 13, - "mobile/screens/trip/tabs/MBookingsTab.tsx": 2, - "mobile/screens/trip/tabs/MCollabChat.tsx": 22, - "mobile/screens/trip/tabs/MCollabNotes.tsx": 19, - "mobile/screens/trip/tabs/MCollabPolls.tsx": 18, + "mobile/screens/trip/tabs/MCollabChat.tsx": 6, + "mobile/screens/trip/tabs/MCollabNotes.tsx": 4, + "mobile/screens/trip/tabs/MCollabPolls.tsx": 12, "mobile/screens/trip/tabs/MCollabTab.tsx": 1, - "mobile/screens/trip/tabs/MCostsTab.tsx": 70, - "mobile/screens/trip/tabs/MDocSyncSheet.tsx": 43, + "mobile/screens/trip/tabs/MCostsTab.tsx": 36, + "mobile/screens/trip/tabs/MDocSyncSheet.tsx": 30, "mobile/screens/trip/tabs/MFileLightbox.tsx": 11, - "mobile/screens/trip/tabs/MFileLinkSheet.tsx": 2, - "mobile/screens/trip/tabs/MFileMenuSheet.tsx": 1, - "mobile/screens/trip/tabs/MFileTrashSheet.tsx": 4, - "mobile/screens/trip/tabs/MFilesTab.tsx": 12, + "mobile/screens/trip/tabs/MFilesTab.tsx": 2, "mobile/screens/trip/tabs/MPackItemSheet.tsx": 1, - "mobile/screens/trip/tabs/MPackingImportSheet.tsx": 3, "mobile/screens/trip/tabs/MPackingListTab.tsx": 2, - "mobile/screens/trip/tabs/MReservationCardParts.tsx": 6, - "mobile/screens/trip/tabs/MTaskSheet.tsx": 6, - "mobile/screens/trip/tabs/MTodoListTab.tsx": 3, - "mobile/screens/trip/tabs/MTransportsTab.tsx": 2, + "mobile/screens/trip/tabs/MTaskSheet.tsx": 1, + "mobile/screens/trip/tabs/MTodoListTab.tsx": 2, "mobile/screens/trip/tabs/filesModel.ts": 5, - "mobile/screens/trip/tabs/tabChrome.tsx": 12, - "mobile/screens/vacay/MVacay.tsx": 17, - "mobile/screens/vacay/MVacayInviteSheet.tsx": 8, - "mobile/screens/vacay/MVacayMonth.tsx": 3, - "mobile/screens/vacay/MVacaySettingsSheet.tsx": 34, - "mobile/screens/vacay/MVacayShareSheet.tsx": 10, + "mobile/screens/trip/tabs/tabChrome.tsx": 3, + "mobile/screens/vacay/MVacay.tsx": 1, "mobile/screens/vacay/vacayDayModel.ts": 1, "pages/DashboardPage.tsx": 1, "pages/FilesPage.tsx": 11, diff --git a/client/scripts/theme-disable-baseline.json b/client/scripts/theme-disable-baseline.json index beb4b2e9d..2d5f0a222 100644 --- a/client/scripts/theme-disable-baseline.json +++ b/client/scripts/theme-disable-baseline.json @@ -59,7 +59,6 @@ "mobile/screens/atlas/MAtlasCountryPopup.tsx": 2, "mobile/screens/atlas/hub/MHubTravellers.tsx": 1, "mobile/screens/collections/MCollEditSheet.tsx": 2, - "mobile/screens/collections/MCollShareSheet.tsx": 1, "mobile/screens/collections/collectionsMobileModel.ts": 15, "mobile/screens/dashboard/MDashboard.tsx": 3, "mobile/screens/journey/MJourney.tsx": 2, diff --git a/client/src/components/Collab/CollabLinks.tsx b/client/src/components/Collab/CollabLinks.tsx index 2addf3b7b..f528ddd7f 100644 --- a/client/src/components/Collab/CollabLinks.tsx +++ b/client/src/components/Collab/CollabLinks.tsx @@ -1,31 +1,22 @@ +import type { CollabLink } from '@trek/shared' import { focusRevealedEditor } from '../shared/dialogFocus' -import { cloneElement, CSSProperties, FormEvent, ReactElement, useEffect, useId, useRef, useState } from 'react' +import { cloneElement, CSSProperties, FormEvent, ReactElement, useId, useState } from 'react' import { createPortal } from 'react-dom' import { ExternalLink, Link2, Pencil, Pin, Plus, Trash2, X } from 'lucide-react' import CollabPanelHead, { HEAD_ACTION } from './CollabPanelHead' import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT } from '../shared/DialogShell' import { EditorField, INPUT } from '../shared/dialogParts' import { useIsPhone } from '../../mobile/useIsPhone' -import { collabApi } from '../../api/client' -import { addListener, removeListener } from '../../api/websocket' import { useTranslation } from '../../i18n' import { useCanDo } from '../../store/permissionsStore' import { useTripStore } from '../../store/tripStore' import ConfirmDialog from '../shared/ConfirmDialog' import EmptyState from '../shared/EmptyState' import { Tooltip } from '../shared/Tooltip' -import { useToast } from '../shared/Toast' -import { offlineOr } from '../../utils/needsConnection' +import { collabLinkHost, useCollabLinks } from './useCollabLinks' const FONT = "var(--font-system)" -interface CollabLink { - id: number - title: string - url: string - pinned: boolean | number -} - // The glyph holds the place until a favicon has really arrived: a host that never // answers, or answers with a blank pixel, left the chip with an empty square. function LinkIcon({ url }: { url: string }) { @@ -56,10 +47,6 @@ function ChipTip({ label, phone, children }: { label: string; phone: boolean; ch return phone ? cloneElement(children, { title: label }) : {children} } -function hostOf(url: string): string { - try { return new URL(url).hostname.replace(/^www\./, '') } catch { return url } -} - /** * The add and edit form as a modal, like the poll and note panels next to it. * Inline it pushed the list down and gave the panel a second header, which is @@ -173,101 +160,11 @@ export default function CollabLinks({ tripId }: { tripId: number }) { const isPhone = useIsPhone() const trip = useTripStore(s => s.trip) const canEdit = useCanDo()('collab_edit', trip) - const toast = useToast() - const [links, setLinks] = useState([]) + const { links, save, toggle, remove } = useCollabLinks(tripId) const [showForm, setShowForm] = useState(false) const [editing, setEditing] = useState(null) const [pendingDeleteId, setPendingDeleteId] = useState(null) - // Both are new objects on every render, so depending on them would reload the - // list after each keystroke and drop a link that was just added back out of it. - const toastRef = useRef(toast) - toastRef.current = toast - const tRef = useRef(t) - tRef.current = t - - useEffect(() => { - let cancelled = false - collabApi.getLinks(tripId) - .then(d => { if (!cancelled) setLinks(d.links || []) }) - .catch(err => { - if (cancelled) return - console.error('Failed to load collab links:', err) - toastRef.current.error(tRef.current('common.error')) - }) - return () => { cancelled = true } - }, [tripId]) - - // Live sync, the same shape the notes panel uses. Without it the three - // collab:link events the server broadcasts would arrive nowhere and a link - // somebody else added would only appear on the next reload. - useEffect(() => { - if (!tripId) return - const handler = (msg: { type?: string; tripId?: number | string; link?: CollabLink; linkId?: number }) => { - // The panel is not remounted on a trip change, so an event still in - // flight from the trip we just left must not land in this list. - if (String(msg?.tripId) !== String(tripId)) return - if (msg.type === 'collab:link:created' && msg.link) { - setLinks(prev => prev.some(l => l.id === msg.link!.id) ? prev : [msg.link!, ...prev]) - } - if (msg.type === 'collab:link:updated' && msg.link) { - setLinks(prev => prev - .map(l => l.id === msg.link!.id ? { ...l, ...msg.link! } : l) - .sort((a, b) => Number(b.pinned) - Number(a.pinned))) - } - if (msg.type === 'collab:link:deleted' && msg.linkId) { - setLinks(prev => prev.filter(l => l.id !== msg.linkId)) - } - } - addListener(handler) - return () => removeListener(handler) - }, [tripId]) - - // Every write says something when it fails. Silence left the pin looking - // unchanged and the delete looking ignored, with an unhandled rejection in - // the console as the only trace. - const add = async (data: { title: string; url: string }) => { - try { - const d = await collabApi.createLink(tripId, data) - setLinks(v => [d.link, ...v]) - } catch (err) { - console.error('Failed to add collab link:', err) - toast.error(offlineOr(t, t('common.error'))) - throw err - } - } - - const toggle = async (link: CollabLink) => { - try { - const d = await collabApi.updateLink(tripId, link.id, { pinned: !link.pinned }) - setLinks(v => v.map(x => x.id === link.id ? d.link : x).sort((a, b) => Number(b.pinned) - Number(a.pinned))) - } catch (err) { - console.error('Failed to pin collab link:', err) - toast.error(offlineOr(t, t('common.error'))) - } - } - - const edit = async (link: CollabLink, data: { title: string; url: string }) => { - try { - const d = await collabApi.updateLink(tripId, link.id, data) - setLinks(v => v.map(x => x.id === link.id ? d.link : x)) - } catch (err) { - console.error('Failed to edit collab link:', err) - toast.error(offlineOr(t, t('common.error'))) - throw err - } - } - - const remove = async (id: number) => { - try { - await collabApi.deleteLink(tripId, id) - setLinks(v => v.filter(x => x.id !== id)) - } catch (err) { - console.error('Failed to delete collab link:', err) - toast.error(offlineOr(t, t('common.error'))) - } - } - return (
{/* Header: the desktop's head band; the phone keeps its own */} @@ -316,7 +213,7 @@ export default function CollabLinks({ tripId }: { tripId: number }) { {link.title} - {hostOf(link.url)} + {collabLinkHost(link.url)} @@ -346,8 +243,8 @@ export default function CollabLinks({ tripId }: { tripId: number }) {
{/* Create and edit modals */} - {showForm && setShowForm(false)} onSave={add} />} - {editing && setEditing(null)} onSave={data => edit(editing, data)} />} + {showForm && setShowForm(false)} onSave={save} />} + {editing && setEditing(null)} onSave={data => save(data, editing.id)} />} {/* The delete is shared: the link goes for every member, and on the phone the button is a thumb's width from pin. Same guard as the notes panel. */} diff --git a/client/src/components/Collab/useCollabChatData.ts b/client/src/components/Collab/useCollabChatData.ts index c59eadca1..f4964a006 100644 --- a/client/src/components/Collab/useCollabChatData.ts +++ b/client/src/components/Collab/useCollabChatData.ts @@ -51,6 +51,9 @@ export function useCollabChatData({ }: CollabChatDataOptions) { const [messages, setMessages] = useState([]); const [loading, setLoading] = useState(true); + const [loadError, setLoadError] = useState(false); + const [loadAttempt, setLoadAttempt] = useState(0); + const retryLoad = useCallback(() => setLoadAttempt((attempt) => attempt + 1), []); const [hasMore, setHasMore] = useState(false); const [loadingMore, setLoadingMore] = useState(false); const [text, setText] = useState(''); @@ -96,6 +99,7 @@ export function useCollabChatData({ useEffect(() => { let cancelled = false; setLoading(true); + setLoadError(false); collabApi .getMessages(tripId) .then((data: MessagesResponse) => { @@ -107,12 +111,14 @@ export function useCollabChatData({ setTimeout(() => scrollToBottom(), 30); }) .catch(() => { - if (!cancelled) setLoading(false); + if (cancelled) return; + setLoadError(true); + setLoading(false); }); return () => { cancelled = true; }; - }, [tripId, scrollToBottom]); + }, [tripId, loadAttempt, scrollToBottom]); useEffect(() => { const handler = (event: Record) => { @@ -259,6 +265,8 @@ export function useCollabChatData({ messages, setMessages, loading, + loadError, + retryLoad, setLoading, hasMore, setHasMore, diff --git a/client/src/components/Collab/useCollabLinks.ts b/client/src/components/Collab/useCollabLinks.ts new file mode 100644 index 000000000..9a6803e91 --- /dev/null +++ b/client/src/components/Collab/useCollabLinks.ts @@ -0,0 +1,126 @@ +import type { CollabLink } from '@trek/shared'; +import { useEffect, useRef, useState } from 'react'; +import { useTranslation } from '../../i18n'; +import { collabLinkRepo, type LinkFields } from '../../repo/collabLinkRepo'; +import { offlineOr } from '../../utils/needsConnection'; +import { useToast } from '../shared/Toast'; + +type LinksState = { tripId: number; links: CollabLink[]; status: 'loading' | 'ready' | 'error' }; + +const EMPTY_LINKS: CollabLink[] = []; + +export function collabLinkHost(url: string): string { + try { + return new URL(url).hostname.replace(/^www\./, ''); + } catch { + return url; + } +} + +function insertLink(links: CollabLink[], link: CollabLink): CollabLink[] { + return links.some((row) => row.id === link.id) ? links : [link, ...links]; +} + +function updateLink(links: CollabLink[], link: CollabLink): CollabLink[] { + return links + .map((row) => (row.id === link.id ? { ...row, ...link } : row)) + .sort((a, b) => Number(b.pinned) - Number(a.pinned)); +} + +export function useCollabLinks(tripId: number) { + const { t } = useTranslation(); + const toast = useToast(); + const [state, setState] = useState({ tripId, links: EMPTY_LINKS, status: 'loading' }); + const [attempt, setAttempt] = useState(0); + const reportLoadError = useRef(() => toast.error(t('common.error'))); + reportLoadError.current = () => toast.error(t('common.error')); + + useEffect(() => { + let cancelled = false; + const changes: Array<(links: CollabLink[]) => CollabLink[]> = []; + let reading = true; + setState((current) => ({ + tripId, + links: current.tripId === tripId ? current.links : EMPTY_LINKS, + status: 'loading', + })); + + const handler = (msg: { type?: string; tripId?: number | string; link?: CollabLink; linkId?: number }) => { + if (String(msg.tripId) !== String(tripId)) return; + const { link, linkId } = msg; + const change = + msg.type === 'collab:link:created' && link + ? (links: CollabLink[]) => insertLink(links, link) + : msg.type === 'collab:link:updated' && link + ? (links: CollabLink[]) => updateLink(links, link) + : msg.type === 'collab:link:deleted' && linkId + ? (links: CollabLink[]) => links.filter((row) => row.id !== linkId) + : null; + if (!change) return; + if (reading) changes.push(change); + setState((current) => (current.tripId === tripId ? { ...current, links: change(current.links) } : current)); + }; + + const unsubscribe = collabLinkRepo.subscribe(handler); + void collabLinkRepo.list(tripId).then( + (data) => { + if (cancelled) return; + reading = false; + const links = changes.reduce((rows, change) => change(rows), data.links || []); + setState({ tripId, links, status: 'ready' }); + }, + () => { + if (cancelled) return; + reading = false; + setState((current) => ({ ...current, status: 'error' })); + reportLoadError.current(); + } + ); + return () => { + cancelled = true; + unsubscribe(); + }; + }, [tripId, attempt]); + + const changeLinks = (update: (links: CollabLink[]) => CollabLink[]) => + setState((current) => (current.tripId === tripId ? { ...current, links: update(current.links) } : current)); + const reportWriteError = () => toast.error(offlineOr(t, t('common.error'))); + + const save = async (data: LinkFields, id?: number) => { + try { + const { link } = + id == null ? await collabLinkRepo.create(tripId, data) : await collabLinkRepo.update(tripId, id, data); + changeLinks((links) => (id == null ? insertLink(links, link) : updateLink(links, link))); + } catch (error) { + reportWriteError(); + throw error; + } + }; + + const toggle = async (link: CollabLink) => { + try { + const { link: saved } = await collabLinkRepo.update(tripId, link.id, { pinned: !link.pinned }); + changeLinks((links) => updateLink(links, saved)); + } catch { + reportWriteError(); + } + }; + + const remove = async (id: number) => { + try { + await collabLinkRepo.remove(tripId, id); + changeLinks((links) => links.filter((link) => link.id !== id)); + } catch { + reportWriteError(); + } + }; + + return { + links: state.tripId === tripId ? state.links : EMPTY_LINKS, + status: state.tripId === tripId ? state.status : 'loading', + retry: () => setAttempt((value) => value + 1), + save, + toggle, + remove, + }; +} diff --git a/client/src/components/Collections/DuplicatePairCard.test.tsx b/client/src/components/Collections/DuplicatePairCard.test.tsx index 7e2075e3c..995926dc4 100644 --- a/client/src/components/Collections/DuplicatePairCard.test.tsx +++ b/client/src/components/Collections/DuplicatePairCard.test.tsx @@ -122,7 +122,7 @@ describe('DuplicatePairCard', () => { const user = userEvent.setup(); const { props, container } = setup({ variant: 'sheet' }); const card = within(container).getByRole('article'); - expect(card.className).toContain('bg-m-sheet'); + expect(card).toHaveClass('bg-m-ic'); expect(screen.getByText('The same name at the same spot')).toBeInTheDocument(); await user.click(screen.getAllByRole('button', { name: /Keep this one/ })[1]); expect(props.onMerge).toHaveBeenCalledWith('b'); diff --git a/client/src/components/Collections/DuplicatePairCard.tsx b/client/src/components/Collections/DuplicatePairCard.tsx index 99ffd272f..a638c9a39 100644 --- a/client/src/components/Collections/DuplicatePairCard.tsx +++ b/client/src/components/Collections/DuplicatePairCard.tsx @@ -8,7 +8,7 @@ const LOOK = { dialog: { card: 'rounded-xl border border-edge-faint bg-surface-secondary p-3', side: 'flex min-w-0 flex-col gap-1.5 rounded-lg bg-surface-card p-2.5', - name: 'text-body font-semibold text-content', + name: 'truncate text-body font-semibold text-content', sub: 'text-caption text-content-faint', diff: 'rounded bg-warning-soft px-1 text-content', chip: 'inline-flex max-w-full items-center gap-1 rounded-full border border-edge-faint px-2 py-0.5 text-caption text-content-muted', @@ -18,16 +18,16 @@ const LOOK = { link: 'text-caption font-semibold text-content-muted hover:text-content disabled:opacity-50', }, sheet: { - card: 'rounded-2xl border border-m-rowbr bg-m-sheet p-3', - side: 'flex min-w-0 flex-col gap-1.5 rounded-xl bg-m-sheetop p-2.5', - name: 'text-body font-bold text-m-ink', + card: 'rounded-[14px] bg-m-ic p-3', + side: 'flex min-w-0 flex-col gap-2 rounded-xl border border-m-rowbr bg-m-sheetop p-2.5', + name: 'line-clamp-2 break-words text-control font-semibold leading-tight text-m-ink', sub: 'text-caption text-m-muted', diff: 'rounded bg-warning-soft px-1 text-m-ink', chip: 'inline-flex max-w-full items-center gap-1 rounded-full border border-m-rowbr bg-m-ic px-2 py-0.5 text-caption text-m-muted', - keep: 'inline-flex items-center justify-center gap-1.5 rounded-full border border-m-rowbr bg-m-ic px-2.5 py-[7px] text-caption font-semibold text-m-ink disabled:opacity-50', + keep: 'inline-flex min-h-11 items-center justify-center gap-1.5 rounded-xl bg-m-ic px-2 py-2 text-start text-caption font-semibold leading-tight text-m-ink disabled:opacity-50', reason: 'text-caption font-semibold text-m-muted', note: 'text-caption text-m-faint', - link: 'text-caption font-semibold text-m-muted disabled:opacity-50', + link: 'min-h-11 rounded-xl px-2 text-start text-control font-medium text-m-muted active:bg-m-sheetop disabled:opacity-50', }, } as const; @@ -54,7 +54,7 @@ function Side({ differing.includes(field) ? {text} : text; return (
- + {mark('name', side.name)} {(side.address || differing.includes('address')) && ( @@ -77,7 +77,11 @@ function Side({ {canMerge && ( )} diff --git a/client/src/components/Collections/usePlacesLibrary.test.ts b/client/src/components/Collections/usePlacesLibrary.test.ts index 1d8c3bde0..af227206b 100644 --- a/client/src/components/Collections/usePlacesLibrary.test.ts +++ b/client/src/components/Collections/usePlacesLibrary.test.ts @@ -85,6 +85,35 @@ describe('parseEntryKey and entryHasPosition', () => { }); describe('usePlacesLibrary: the first page', () => { + it('uses the restored filters on its first request and opens the previous place', async () => { + const restoredDetail = libraryDetail(libraryEntry(), []); + list.mockResolvedValue(libraryPage([])); + detail.mockResolvedValue(restoredDetail); + const { result } = renderHook(() => + usePlacesLibrary({ + t, + active: true, + initialKey: 'trip:42', + initialFilters: { + search: 'Coffee', + kind: 'trip', + categoryId: 3, + sort: 'rating', + status: 'all', + minRating: 4, + tagNames: ['Morning'], + }, + }) + ); + await waitFor(() => expect(result.current.detail).toBe(restoredDetail)); + expect(list).toHaveBeenCalledWith( + { q: 'Coffee', kind: 'trip', category_id: 3, sort: 'rating', min_rating: 4, tags: ['Morning'], limit: 60 }, + expect.any(AbortSignal) + ); + expect(detail).toHaveBeenCalledWith('trip', 42, expect.any(AbortSignal)); + expect(result.current.search).toBe('Coffee'); + }); + it('FE-COMP-PLACESLIBHOOK-003: asks nothing while inactive and loads once it becomes active', async () => { list.mockResolvedValue(libraryPage([])); const { rerender, result } = mount(false); diff --git a/client/src/components/Collections/usePlacesLibrary.ts b/client/src/components/Collections/usePlacesLibrary.ts index bf5bf3762..9591737fc 100644 --- a/client/src/components/Collections/usePlacesLibrary.ts +++ b/client/src/components/Collections/usePlacesLibrary.ts @@ -17,6 +17,16 @@ import { getApiErrorMessage } from '../../utils/apiError'; /** Which origins the overview shows: all, only trip places, only saved ones. */ export type LibraryKindFilter = 'all' | PlacesLibraryKind; +export interface PlacesLibraryFilters { + search: string; + kind: LibraryKindFilter; + categoryId: number | 'all'; + sort: PlacesLibrarySort; + status: CollectionStatus | 'all'; + minRating: number | 'all'; + tagNames: string[]; +} + const PAGE = 60; /** How long typing settles before the search asks the server. */ const SEARCH_SETTLE_MS = 250; @@ -77,17 +87,17 @@ function failureOf(err: unknown, t: TranslationFn): { error: string | null; offl } /** The filters of "All places". */ -function useLibraryFilters() { - const [search, setSearch] = useState(''); - const [query, setQuery] = useState(''); - const [kind, setKind] = useState('all'); - const [categoryId, setCategoryId] = useState('all'); - const [sort, setSort] = useState('name'); - const [status, setStatus] = useState('all'); +function useLibraryFilters(initial?: PlacesLibraryFilters) { + const [search, setSearch] = useState(initial?.search ?? ''); + const [query, setQuery] = useState(initial?.search.trim() ?? ''); + const [kind, setKind] = useState(initial?.kind ?? 'all'); + const [categoryId, setCategoryId] = useState(initial?.categoryId ?? 'all'); + const [sort, setSort] = useState(initial?.sort ?? 'name'); + const [status, setStatus] = useState(initial?.status ?? 'all'); // At least this many stars on the average of the votes, as the lists filter; unrated places drop out. - const [minRating, setMinRating] = useState('all'); + const [minRating, setMinRating] = useState(initial?.minRating ?? 'all'); // PLC-21: tag names of the lists and trips, any of which an entry must carry, whatever their case. - const [tagNames, setTagNames] = useState([]); + const [tagNames, setTagNames] = useState(initial?.tagNames ?? []); const toggleTagName = useCallback( (name: string) => setTagNames((names) => { @@ -158,8 +168,8 @@ function useLibraryFilters() { } /** The first page for the filters and the pages "more" appends. */ -function useLibraryPages(active: boolean, reloadSeq: number, t: TranslationFn) { - const { filters, controls } = useLibraryFilters(); +function useLibraryPages(active: boolean, reloadSeq: number, t: TranslationFn, initial?: PlacesLibraryFilters) { + const { filters, controls } = useLibraryFilters(initial); const [page, setPage] = useState(EMPTY_PAGE); // The request "more" is loading for; another key means the button is free again. const [moreFor, setMoreFor] = useState(null); @@ -231,8 +241,13 @@ function useLibraryPages(active: boolean, reloadSeq: number, t: TranslationFn) { } /** The entry that is open and what its origins keep. */ -function useLibraryDetail(entries: readonly PlacesLibraryEntry[], reloadSeq: number, onError: (err: unknown) => void) { - const [selectedKey, setSelectedKey] = useState(null); +function useLibraryDetail( + entries: readonly PlacesLibraryEntry[], + reloadSeq: number, + onError: (err: unknown) => void, + initialKey?: string +) { + const [selectedKey, setSelectedKey] = useState(initialKey ?? null); const [loaded, setLoaded] = useState<{ key: string; detail: PlacesLibraryDetailResponse } | null>(null); const [settled, setSettled] = useState(null); // Where the open entry is read from, as text so a page arriving later does not ask again. @@ -348,15 +363,25 @@ export function useTagOptions(entries: readonly PlacesLibraryEntry[], picked: re * fresh first page, "more" appends the next one, and opening an entry loads what * each of its origins keeps. */ -export function usePlacesLibrary({ active, t }: { active: boolean; t: TranslationFn }) { +export function usePlacesLibrary({ + active, + t, + initialFilters, + initialKey, +}: { + active: boolean; + t: TranslationFn; + initialFilters?: PlacesLibraryFilters; + initialKey?: string; +}) { const [ownSeq, setReloadSeq] = useState(0); // A place saved to a list from here or anywhere else adds an origin: read again then too. const savedVersion = useSaveToCollectionStore((st) => st.version); const reloadSeq = ownSeq + savedVersion; const [detailError, setDetailError] = useState<{ error: string | null; offline: boolean } | null>(null); - const pages = useLibraryPages(active, reloadSeq, t); + const pages = useLibraryPages(active, reloadSeq, t, initialFilters); const onDetailError = useCallback((err: unknown) => setDetailError(failureOf(err, t)), [t]); - const sel = useLibraryDetail(pages.page.entries, reloadSeq, onDetailError); + const sel = useLibraryDetail(pages.page.entries, reloadSeq, onDetailError, initialKey); const cover = useLibraryCover(sel.detail); const reload = useCallback(() => { setDetailError(null); diff --git a/client/src/components/Journey/ContributorInviteDialog.test.tsx b/client/src/components/Journey/ContributorInviteDialog.test.tsx index f18287ae6..73728d137 100644 --- a/client/src/components/Journey/ContributorInviteDialog.test.tsx +++ b/client/src/components/Journey/ContributorInviteDialog.test.tsx @@ -6,6 +6,7 @@ import userEvent from '@testing-library/user-event' import { render, screen, waitFor, act } from '../../../tests/helpers/render' import { server } from '../../../tests/helpers/msw/server' import ContributorInviteDialog from './ContributorInviteDialog' +import MJourneyInviteFrame from '../../mobile/screens/journey/MJourneyInviteFrame' type ToastKind = 'success' | 'error' | 'warning' | 'info' @@ -198,29 +199,22 @@ describe('ContributorInviteDialog on a phone', () => { Object.defineProperty(window, 'innerWidth', { value: width, configurable: true, writable: true }) }) - it('FE-JRN-INVITE-013: keeps the panel it had, with the filled role button and the header close', async () => { + it('FE-JRN-INVITE-013: uses the mobile sheet with a labelled role selector and close action', async () => { const user = userEvent.setup() - const { onClose, onInvited } = mountDialog() + const { onClose, onInvited } = mountDialog({ Frame: MJourneyInviteFrame }) await screen.findByText('maurice') - expect(screen.queryByRole('dialog')).not.toBeInTheDocument() + expect(screen.getByRole('dialog', { name: 'Invite Contributor' })).toBeInTheDocument() const viewerBtn = screen.getByRole('button', { name: 'Viewer' }) const editorBtn = screen.getByRole('button', { name: 'Editor' }) - expect(viewerBtn.className).toContain('bg-zinc-900') - expect(editorBtn.className).not.toContain('bg-zinc-900') + expect(viewerBtn).toHaveAttribute('aria-pressed', 'true') + expect(editorBtn).toHaveAttribute('aria-pressed', 'false') await user.click(editorBtn) - expect(editorBtn.className).toContain('bg-zinc-900') - expect(viewerBtn.className).not.toContain('bg-zinc-900') + expect(editorBtn).toHaveAttribute('aria-pressed', 'true') + expect(viewerBtn).toHaveAttribute('aria-pressed', 'false') - // The header close button carries only an icon, so it is addressed by position. - const headerClose = screen.getByRole('heading', { name: 'Invite Contributor' }) - .parentElement!.querySelector('button')! - act(() => { headerClose.click() }) - expect(onClose).toHaveBeenCalledTimes(1) - - // Escape is the desktop's: the phone panel never had it. - await user.keyboard('{Escape}') + await user.click(screen.getByRole('button', { name: 'Close' })) expect(onClose).toHaveBeenCalledTimes(1) expect(onInvited).not.toHaveBeenCalled() }) @@ -232,7 +226,7 @@ describe('ContributorInviteDialog on a phone', () => { return HttpResponse.json({ ok: true }) })) const user = userEvent.setup() - const { onInvited } = mountDialog({ existingUserIds: [1] }) + const { onInvited } = mountDialog({ existingUserIds: [1], Frame: MJourneyInviteFrame }) await screen.findByText('julien') await user.type(screen.getByPlaceholderText('Username or email...'), 'zzz') diff --git a/client/src/components/Journey/ContributorInviteDialog.tsx b/client/src/components/Journey/ContributorInviteDialog.tsx index 556a9f156..a3e32cc22 100644 --- a/client/src/components/Journey/ContributorInviteDialog.tsx +++ b/client/src/components/Journey/ContributorInviteDialog.tsx @@ -1,4 +1,4 @@ -import { useEffect, useId, useState } from 'react' +import { useEffect, useId, useState, type ComponentType } from 'react' import { X, Check, UserPlus, Search, Loader2 } from 'lucide-react' import { journeyApi, authApi } from '../../api/client' import { useTranslation } from '../../i18n' @@ -10,37 +10,56 @@ import { TripMemberAvatar } from '../Trips/TripMemberAvatar' import { avatarSrc } from '../../utils/avatarSrc' const ROLES = ['viewer', 'editor'] as const +type InviteRole = (typeof ROLES)[number] +type InviteUser = { id: number; username: string; email?: string; avatar?: string | null } + +export interface ContributorInviteFrameProps { + users: InviteUser[] + loading: boolean + search: string + onSearch: (value: string) => void + selectedUserId: number | null + onSelectUser: (id: number) => void + role: InviteRole + roles: readonly InviteRole[] + onRoleChange: (role: InviteRole) => void + sending: boolean + onClose: () => void + onInvite: () => Promise +} /** * Adds a person to a journey. The desktop draws it in the planner's dialog * frame; the phone, which opens it from its journey screen, keeps the panel it * has always had. Both read and write the same state below. */ -export default function ContributorInviteDialog({ journeyId, existingUserIds, onClose, onInvited }: { +export default function ContributorInviteDialog({ journeyId, existingUserIds, onClose, onInvited, Frame }: { journeyId: number existingUserIds: number[] onClose: () => void onInvited: () => void + Frame?: ComponentType }) { const { t } = useTranslation() const phone = useIsPhone() const labelId = useId() - const [users, setUsers] = useState<{ id: number; username: string; email?: string; avatar?: string | null }[]>([]) + const [users, setUsers] = useState([]) + const [loading, setLoading] = useState(true) const [search, setSearch] = useState('') const [selectedUserId, setSelectedUserId] = useState(null) - const [role, setRole] = useState<'editor' | 'viewer'>('viewer') + const [role, setRole] = useState('viewer') const [sending, setSending] = useState(false) const toast = useToast() useEffect(() => { - authApi.listUsers().then(d => setUsers(d.users || [])).catch(() => {}) + authApi.listUsers().then(d => setUsers(d.users || [])).catch(() => {}).finally(() => setLoading(false)) }, []) // Captured and stopped on the desktop: the dialog is usually opened from the // journey settings, which close on Escape as well, and one key press should // only take back this dialog, not the one under it. useEffect(() => { - if (phone) return + if (phone || Frame) return const onKey = (e: KeyboardEvent) => { if (e.key !== 'Escape') return e.stopPropagation() @@ -48,7 +67,7 @@ export default function ContributorInviteDialog({ journeyId, existingUserIds, on } document.addEventListener('keydown', onKey, true) return () => document.removeEventListener('keydown', onKey, true) - }, [phone, onClose]) + }, [phone, Frame, onClose]) const filtered = users.filter(u => { if (existingUserIds.includes(u.id)) return false @@ -59,7 +78,7 @@ export default function ContributorInviteDialog({ journeyId, existingUserIds, on }) const handleInvite = async () => { - if (!selectedUserId) return + if (!selectedUserId || sending) return setSending(true) try { await journeyApi.addContributor(journeyId, selectedUserId, role) @@ -72,6 +91,12 @@ export default function ContributorInviteDialog({ journeyId, existingUserIds, on } } + if (Frame) { + return + } + if (phone) { return (
diff --git a/client/src/components/Journey/JourneyEntryComments.tsx b/client/src/components/Journey/JourneyEntryComments.tsx index 3e2f22909..470d84e4a 100644 --- a/client/src/components/Journey/JourneyEntryComments.tsx +++ b/client/src/components/Journey/JourneyEntryComments.tsx @@ -32,6 +32,7 @@ interface Props { publicHint?: boolean; /** Start unfolded, where the thread already has a section of its own. */ defaultOpen?: boolean; + mobile?: boolean; } const GUEST_NAME_KEY = 'trek.journey.guestName'; @@ -68,9 +69,10 @@ export default function JourneyEntryComments({ onDelete, publicHint, defaultOpen, + mobile = false, }: Props) { const { t, locale } = useTranslation(); - const [open, setOpen] = useState(!!defaultOpen); + const [expanded, setExpanded] = useState(null); const [body, setBody] = useState(''); const [name, setName] = useState(guest ? rememberedName : ''); const [trap, setTrap] = useState(''); @@ -78,6 +80,7 @@ export default function JourneyEntryComments({ const [message, setMessage] = useState(null); if (!canWrite && comments.length === 0) return null; + const open = expanded ?? Boolean(defaultOpen || (mobile && comments.length)); const submit = async (e: FormEvent) => { e.preventDefault(); @@ -108,9 +111,13 @@ export default function JourneyEntryComments({ aria-expanded={open} onClick={(e) => { e.stopPropagation(); - setOpen((shown) => !shown); + setExpanded(!open); }} - className="inline-flex items-center gap-1.5 self-start text-caption font-medium text-content-faint transition-colors hover:text-content" + className={ + mobile + ? 'flex min-h-11 w-full items-center gap-2 rounded-xl bg-m-sheetop px-3 text-start text-control font-medium text-m-ink' + : 'inline-flex items-center gap-1.5 self-start text-caption font-medium text-content-faint transition-colors hover:text-content' + } > {comments.length > 0 ? t('journey.comments.count', { count: comments.length }) : t('journey.comments.write')} @@ -121,7 +128,7 @@ export default function JourneyEntryComments({ return ( // The thread sits inside clickable cards: a click in it must not open the entry.
e.stopPropagation()} role="presentation"> - {!defaultOpen && toggle} + {!defaultOpen && !mobile && toggle} {comments.length > 0 && (
    {comments.map((c) => { @@ -149,7 +156,13 @@ export default function JourneyEntryComments({

    {c.body}

{(mayHide || mayDelete) && ( -
+
{mayHide && ( void onHide?.(c.id, !c.hidden)} - className="flex h-7 w-7 items-center justify-center rounded-full text-content-faint hover:bg-surface-secondary hover:text-content" + className={`flex ${mobile ? 'size-11' : 'size-7'} items-center justify-center rounded-full text-content-faint hover:bg-surface-secondary hover:text-content`} > {c.hidden ? : } @@ -171,7 +184,7 @@ export default function JourneyEntryComments({ type="button" aria-label={t('common.delete')} onClick={() => void onDelete?.(c.id)} - className="flex h-7 w-7 items-center justify-center rounded-full text-content-faint hover:bg-danger-soft hover:text-danger" + className={`flex ${mobile ? 'size-11' : 'size-7'} items-center justify-center rounded-full text-content-faint hover:bg-danger-soft hover:text-danger`} > @@ -216,14 +229,22 @@ export default function JourneyEntryComments({ rows={1} placeholder={t('journey.comments.write')} aria-label={t('journey.comments.write')} - className="max-h-40 min-h-[38px] flex-1 resize-none rounded-xl border border-edge bg-surface px-3 py-2 text-body text-content outline-none [field-sizing:content] placeholder:text-content-faint focus:border-content-faint" + className={`max-h-40 min-w-0 flex-1 resize-none rounded-xl border px-3 py-2 text-body outline-none [field-sizing:content] ${ + mobile + ? 'min-h-11 border-m-rowbr bg-m-sheetop text-m-ink placeholder:text-m-muted' + : 'min-h-[38px] border-edge bg-surface text-content placeholder:text-content-faint focus:border-content-faint' + }`} /> @@ -231,7 +252,9 @@ export default function JourneyEntryComments({
{message &&

{message}

} {publicHint && !guest && ( -

{t('journey.comments.publicHint')}

+

+ {t('journey.comments.publicHint')} +

)} )} @@ -252,10 +275,12 @@ export function MemberEntryComments({ entryId, thread, defaultOpen, + mobile, }: { entryId: number; thread: MemberThreadState; defaultOpen?: boolean; + mobile?: boolean; }) { const { t } = useTranslation(); const toast = useToast(); @@ -268,6 +293,7 @@ export function MemberEntryComments({ comments={thread.byEntry.get(entryId) ?? []} canWrite defaultOpen={defaultOpen} + mobile={mobile} canModerate={thread.canModerate} publicHint onAdd={async (body) => ((await thread.add(entryId, body)) ? null : t('journey.comments.failed'))} diff --git a/client/src/components/Journey/JourneyEntryCover.test.tsx b/client/src/components/Journey/JourneyEntryCover.test.tsx index 0a578ab48..38f289e81 100644 --- a/client/src/components/Journey/JourneyEntryCover.test.tsx +++ b/client/src/components/Journey/JourneyEntryCover.test.tsx @@ -134,14 +134,13 @@ describe('JourneyEntryCover', () => { expect(container.querySelector('svg.lucide-play')).toBeNull() }) - it('FE-JRN-COVER-011: only the phone draws a card without a photo in the deep day colour, opaque even as a suggestion', () => { + it('FE-JRN-COVER-011: the phone shows a neutral surface for suggestions without photos', () => { const entry = buildEntry({ photos: [], type: 'skeleton' }) const phone = render( {}} tone="mobile" />) const phoneCard = phone.getByRole('button') - // d9, the deep wash (jsdom spells the colour out as rgba) - expect(phoneCard.style.backgroundImage).toMatch(/rgba\(99, 102, 241, 0\.85/) - expect(phoneCard.className).not.toContain('opacity-90') - expect(phone.container.querySelector('svg.lucide-map-pin')?.getAttribute('class')).toContain('-mt-6') + expect(phoneCard.style.backgroundImage).toBe('') + expect(phoneCard).toHaveClass('bg-m-sheetop', 'text-m-ink') + expect(phone.container.querySelector('svg.lucide-map-pin')).not.toBeInTheDocument() phone.unmount() // The desktop and shared timelines keep their faint wash and the day-coloured pin. @@ -154,4 +153,12 @@ describe('JourneyEntryCover', () => { expect(pin.getAttribute('class')).not.toContain('-mt-6') expect(pin.style.color).not.toBe('') }) + + it('fills a mobile card with its photo and draws the text in white', () => { + const { container } = render( {}} tone="mobile" />) + + expect(container.querySelector('button')).toHaveClass('text-[color:var(--m-viewer-ink)]') + expect(container.querySelector('img[src*="/api/photos/"]')).toHaveClass('absolute', 'inset-0', 'size-full', 'object-cover') + expect(container.querySelector('.bg-gradient-to-t')).toBeInTheDocument() + }) }) diff --git a/client/src/components/Journey/JourneyEntryCover.tsx b/client/src/components/Journey/JourneyEntryCover.tsx index 6e7b97162..e75d39334 100644 --- a/client/src/components/Journey/JourneyEntryCover.tsx +++ b/client/src/components/Journey/JourneyEntryCover.tsx @@ -20,10 +20,8 @@ import type { JourneyEntry } from '../../store/journeyStore' * answers "how many stops into this day am I", which is not a question anyone * asks; the day scrubber above the carousel answers the one they do. * - * Two shells draw this card. `tone` picks the surface a card without a photo - * falls back to, because the phone shell's tokens are scoped to `.m-root` and - * the tablet timeline is outside it. Everything else is a photo and white text, - * which needs no tokens at all. + * Photos fill the cover. The mobile shell uses a neutral card for entries + * without a photo and a lighter active treatment over the map. */ /** A card's photo, plus what says whether a clip has a poster to draw (#2341). */ @@ -82,7 +80,10 @@ export default function JourneyEntryCover({ size = 'regular', }: Props) { const large = size === 'large' - const box = large ? 'h-[196px] w-[176px]' : size === 'compact' ? 'h-[112px] w-[124px]' : 'h-[152px] w-[136px]' + const mobile = tone === 'mobile' + const box = size === 'compact' ? 'h-[112px] w-[124px]' + : large ? (mobile ? 'h-[144px] w-[176px]' : 'h-[196px] w-[176px]') + : mobile ? 'h-[116px] w-[144px]' : 'h-[152px] w-[136px]' const { t, locale } = useTranslation() const isSuggestion = entry.type === 'skeleton' @@ -100,12 +101,44 @@ export default function JourneyEntryCover({ const mood = showMood ? moodMeta(entry.mood) : undefined const weather = showWeather ? weatherMeta(entry.weather) : undefined - const mobile = tone === 'mobile' - const emptyGround = mobile ? 'bg-[color:var(--m-sheetop)]' : 'bg-white dark:bg-zinc-800' - // The mark of a card without a photo: white and raised clear of the name on the - // phone's deep day colour, the day's own colour on the faint wash elsewhere. - const emptyIcon = mobile ? '-mt-6 opacity-80' : 'opacity-60' - const emptyIconStyle = mobile ? undefined : { color: dayColor } + if (mobile) { + return ( + + ) + } + // One ground for every corner mark. Dark rather than a white veil: these sit on // whatever photograph the traveller took, and a bright sky swallowed the white one. const badge = 'rounded-full bg-black/45 px-[7px] py-[2px] text-[10px] font-bold whitespace-nowrap text-white backdrop-blur-[2px]' @@ -123,11 +156,9 @@ export default function JourneyEntryCover({ // growing its box moved every card after it once a swipe had landed, and the // snap then pulled the strip again, which read as a jolt (carousels keep the // room for it with their gap and top padding). - // White on the root: every mark and line on the card is white, over a photo or - // over the day's colour alike. className={`relative text-white ${box} flex-none origin-bottom overflow-hidden rounded-[18px] text-start transition-[transform,box-shadow] duration-200 ease-[cubic-bezier(.2,.8,.2,1)] motion-reduce:transition-none ${ isActive ? 'z-[1] scale-[1.18] shadow-[0_18px_40px_-16px_rgba(0,0,0,.55)]' : 'scale-100 shadow-[0_10px_24px_-14px_rgba(0,0,0,.5)]' - } ${src ? '' : emptyGround} ${isSuggestion && !mobile ? 'opacity-90' : ''}`} + } ${src ? '' : 'bg-white dark:bg-zinc-800'} ${isSuggestion ? 'opacity-90' : ''}`} // backgroundImage, not background: the shorthand would drop the opaque colour // the class supplies and leave the map showing through a card that is only a // faint wash of the day's colour. @@ -139,14 +170,7 @@ export default function JourneyEntryCover({ // ring lost its top edge to that clip. style={{ boxShadow: `inset 0 0 0 ${isActive ? 2.5 : 1.5}px ${dayColor}${isActive ? '' : 'b3'}`, - // Without a photograph the phone's card is the day's colour, deep enough to - // carry the white name like a photo does, rather than a grey that read as - // empty. Its ground stays opaque (no dimming for a suggestion either): it - // floats over the map, whose labels read through anything less. The desktop - // and shared timelines keep their faint wash of the day. - ...(src ? null : { backgroundImage: mobile - ? `linear-gradient(160deg, ${dayColor}d9, ${dayColor}8c 55%, ${dayColor}59)` - : `linear-gradient(160deg, ${dayColor}2e, ${dayColor}0d)` }), + ...(src ? null : { backgroundImage: `linear-gradient(160deg, ${dayColor}2e, ${dayColor}0d)` }), }} > {src ? ( @@ -154,8 +178,8 @@ export default function JourneyEntryCover({ ) : ( {posterless - ? - : } + ? + : } )} @@ -196,7 +220,7 @@ export default function JourneyEntryCover({ )} {weather && ( - + )} diff --git a/client/src/components/Journey/PhotoLightbox.tsx b/client/src/components/Journey/PhotoLightbox.tsx index 383c76990..005843ce4 100644 --- a/client/src/components/Journey/PhotoLightbox.tsx +++ b/client/src/components/Journey/PhotoLightbox.tsx @@ -1,4 +1,5 @@ import { useState, useEffect, useCallback, useRef } from 'react' +import { useOverlay } from '../../hooks/overlayStack' import { createPortal } from 'react-dom' import { ChevronLeft, ChevronRight, Loader2, X, ZoomIn, ZoomOut } from 'lucide-react' import VideoPlayer from './VideoPlayerLazy' @@ -53,6 +54,7 @@ const SAFE = (side: 'top' | 'bottom' | 'left' | 'right') => `max(env(safe-area-inset-${side}, 0px), var(--safe-area-inset-${side}, 0px), var(--trek-native-safe-${side}, 0px))` export default function PhotoLightbox({ photos, startIndex = 0, onClose, label }: Props) { + useOverlay(true, onClose, true) const [idx, setIdx] = useState(startIndex) const touchStart = useRef<{ x: number; y: number } | null>(null) const dialogRef = useRef(null) @@ -87,13 +89,12 @@ export default function PhotoLightbox({ photos, startIndex = 0, onClose, label } useEffect(() => { const onKey = (e: KeyboardEvent) => { - if (e.key === 'Escape') onClose() if (e.key === 'ArrowLeft') (rtl ? next : prev)() if (e.key === 'ArrowRight') (rtl ? prev : next)() } window.addEventListener('keydown', onKey) return () => window.removeEventListener('keydown', onKey) - }, [prev, next, onClose, rtl]) + }, [prev, next, rtl]) // A pinch, a double tap or a pan of an enlarged photo belongs to the zoom; only // the rest is a swipe that turns the page or closes the lightbox. diff --git a/client/src/components/Journey/useJourneySettings.ts b/client/src/components/Journey/useJourneySettings.ts index c6240ed32..6b56d3da1 100644 --- a/client/src/components/Journey/useJourneySettings.ts +++ b/client/src/components/Journey/useJourneySettings.ts @@ -168,8 +168,8 @@ export function useJourneySettings({ journey, onSaved, onRefresh, onContentChang } }; - const handleRemoveContributor = async (c: JourneyContributor) => { - if (!window.confirm(t('journey.contributors.removeConfirm', { username: c.username }))) return; + const handleRemoveContributor = async (c: JourneyContributor, confirmed = false) => { + if (!confirmed && !window.confirm(t('journey.contributors.removeConfirm', { username: c.username }))) return; try { await journeyApi.removeContributor(journey.id, c.user_id); toast.success(t('journey.contributors.removed')); diff --git a/client/src/components/Layout/navItems.ts b/client/src/components/Layout/navItems.ts index 4a2926965..e17238af4 100644 --- a/client/src/components/Layout/navItems.ts +++ b/client/src/components/Layout/navItems.ts @@ -41,25 +41,20 @@ const ADDON_ICONS: Record = { /** The bar holds Dashboard + at most this many custom items; the rest go to More. * Two keeps the dock at 3 entries (Dashboard + 2) so the More slot still fits. */ export const MOBILE_NAV_MAX_BAR = 2 -/** - * The built-in dock next to Dashboard for an un-customised account, in priority - * order: the first MOBILE_NAV_MAX_BAR of these that are actually enabled take the - * slots, everything else starts under More. - * - * Journey outranks Atlas because a phone in the field wants the journal it writes - * to every day, not the map of countries it already visited. Journey ships - * disabled though, so an instance that never turned it on keeps the Vacay/Atlas - * dock it has today. Listing all four known global addons rather than just the - * top two also keeps the dock filled when one of them is switched off. The - * assistant comes last: it takes a slot only one of the addons left free, rather - * than sitting alone behind the More button. - */ /** Where an addon's page lives: its id, except Collections, which became Places (PLC-07). */ export function addonPath(id: string): string { return id === 'collections' ? '/places' : `/${id}` } -export const DEFAULT_DOCK_IDS = ['vacay', 'journey', 'atlas', 'collections', ASSISTANT_NAV_ID] +/** + * The built-in dock next to Dashboard for an un-customised account, in priority + * order: the first MOBILE_NAV_MAX_BAR of these that are actually enabled take the + * slots, everything else starts under More. + * + * Places and Journey sit beside trips when enabled. The remaining enabled + * destinations fill unused slots, and the customizer keeps saved choices. + */ +export const DEFAULT_DOCK_IDS = ['collections', 'journey', 'vacay', 'atlas', ASSISTANT_NAV_ID] export function buildNavItems( globalAddons: { id: string; name: string; icon: string }[], diff --git a/client/src/components/MailIngest/TripMailForward.tsx b/client/src/components/MailIngest/TripMailForward.tsx index d320e21ff..28a758609 100644 --- a/client/src/components/MailIngest/TripMailForward.tsx +++ b/client/src/components/MailIngest/TripMailForward.tsx @@ -14,7 +14,13 @@ import { useToast } from '../shared/Toast'; * own address; it is the person's own, so a fellow traveller gets another. * Nothing where the import is off for the person. */ -export default function TripMailForward({ tripId }: { tripId: number }): ReactElement | null { +export default function TripMailForward({ + tripId, + mobile = false, +}: { + tripId: number; + mobile?: boolean; +}): ReactElement | null { const { t } = useTranslation(); const toast = useToast(); const settings = useMailIngestStore((s) => s.settings); @@ -62,7 +68,7 @@ export default function TripMailForward({ tripId }: { tripId: number }): ReactEl }; return ( -
+
{t('mailInbox.trip.title')} @@ -72,7 +78,7 @@ export default function TripMailForward({ tripId }: { tripId: number }): ReactEl
{address.address} @@ -80,7 +86,7 @@ export default function TripMailForward({ tripId }: { tripId: number }): ReactEl type="button" onClick={() => void copy()} aria-label={t('mailInbox.settings.copy')} - className="grid h-8 w-8 flex-none place-items-center rounded-lg bg-surface-card text-content-muted hover:text-content" + className={`grid flex-none place-items-center rounded-lg text-content-muted hover:text-content ${mobile ? 'size-11 bg-m-sheetop' : 'size-8 bg-surface-card'}`} > @@ -90,7 +96,7 @@ export default function TripMailForward({ tripId }: { tripId: number }): ReactEl type="button" onClick={() => void create()} disabled={creating} - className="inline-flex w-fit items-center gap-1.5 rounded-lg bg-surface-card px-3 py-1.5 text-caption font-semibold text-content hover:bg-surface-hover disabled:opacity-50" + className={`inline-flex w-fit items-center gap-1.5 rounded-lg px-3 py-1.5 text-caption font-semibold text-content hover:bg-surface-hover disabled:opacity-50 ${mobile ? 'min-h-11 bg-m-sheetop' : 'bg-surface-card'}`} > {t('mailInbox.trip.create')} diff --git a/client/src/components/Map/PlaceNamesPill.tsx b/client/src/components/Map/PlaceNamesPill.tsx index d9051f591..aa212a440 100644 --- a/client/src/components/Map/PlaceNamesPill.tsx +++ b/client/src/components/Map/PlaceNamesPill.tsx @@ -1,9 +1,7 @@ import { Type } from 'lucide-react'; import { useTranslation } from '../../i18n'; -import { useSettingsStore } from '../../store/settingsStore'; -import { useToast } from '../shared/Toast'; import { MapTogglePill } from './MapTogglePill'; -import { usePlaceNamesSetting } from './usePlaceNameLayout'; +import { usePlaceNamesToggle } from './usePlaceNameLayout'; /** * Turns the place names beside the trip map's pins on and off (#2796). The choice is @@ -11,23 +9,12 @@ import { usePlaceNamesSetting } from './usePlaceNameLayout'; */ export function PlaceNamesPill() { const { t } = useTranslation(); - const on = usePlaceNamesSetting(); - const updateSetting = useSettingsStore((s) => s.updateSetting); - const toast = useToast(); - // The switch flips at once; a save that fails turns it back and says so. - const toggle = async () => { - try { - await updateSetting('map_place_labels', !on); - } catch (err) { - useSettingsStore.setState((s) => ({ settings: { ...s.settings, map_place_labels: on } })); - toast.error(err instanceof Error ? err.message : t('common.error')); - } - }; + const { on, setOn } = usePlaceNamesToggle(); return ( { - void toggle(); + void setOn(!on); }} label={on ? t('map.placeNames.hide') : t('map.placeNames.show')} testId="place-names-pill" diff --git a/client/src/components/Map/dayRoutePlan.ts b/client/src/components/Map/dayRoutePlan.ts index 967b8f73b..109cf62a2 100644 --- a/client/src/components/Map/dayRoutePlan.ts +++ b/client/src/components/Map/dayRoutePlan.ts @@ -1,5 +1,5 @@ import { withHotelBookends } from './RouteCalculator' -import { getTransportRouteEndpoints, getTransportForDay, getMergedItems, isCarrierTransport, hasCarrierEndpointOnDay } from '../../utils/dayMerge' +import { getSpanPhase, getTransportRouteEndpoints, getTransportForDay, getMergedItems, isCarrierTransport, hasCarrierEndpointOnDay, stopDayIds } from '../../utils/dayMerge' import { getDayBookendHotels, shouldDrawMorningLeg, shouldDrawEveningLeg, type CarrierEdge } from '../../utils/dayOrder' import { withinDriveRange } from '@trek/shared/roadtrip' import type { Accommodation, AssignmentsMap, Day, Place, Reservation } from '../../types' @@ -43,6 +43,15 @@ export interface DayRouteInputs { places?: Place[] /** MDT-02: where the stages of the trip's multi-day tours run, so a day holding one routes to it. */ tourStageStops?: TourStageStops + includeLocatedBookings?: boolean +} + +/** A reservation linked to a place can be a stop in the itinerary without being a transport leg. */ +export function locatedBookingWaypoint(reservation: Reservation, dayId: number, places?: readonly Place[]) { + if (reservation.place_id == null || reservation.type === 'hotel' || TRANSPORT_TYPES.includes(reservation.type) + || getSpanPhase(reservation, dayId) === 'middle') return null + const place = places?.find(candidate => candidate.id === reservation.place_id) + return place && place.lat != null && place.lng != null ? { lat: place.lat, lng: place.lng } : null } /** @@ -79,16 +88,18 @@ export function buildDayRouteRuns(dayId: number, input: DayRouteInputs): DayRout // it; getMergedItems places each leg by its own saved position, falling back to its // time. Notes carry no coordinates, so none are passed. const dayTransports = thisOrder == null ? [] : getTransportForDay({ - reservations: allReservations.filter(r => TRANSPORT_TYPES.includes(r.type)), + reservations: allReservations.filter(r => TRANSPORT_TYPES.includes(r.type) + || (input.includeLocatedBookings && !!locatedBookingWaypoint(r, dayId, input.places))), dayId, dayAssignmentIds: da.map(a => a.id), days: allDays, + stopDays: input.includeLocatedBookings ? stopDayIds(assignments) : undefined, }) const merged = getMergedItems({ dayAssignments: da, dayNotes: [], dayTransports, dayId }) const projected = projectedById(da, input.toursEnabled ?? false, input.places, input.tourStageStops) type Entry = - | { kind: 'place'; id: number; lat: number; lng: number; pos: number; time: string | null; mode: string | null; incoming: string | null } + | { kind: 'place'; id?: number; lat: number; lng: number; pos: number; time: string | null; mode: string | null; incoming: string | null } | { kind: 'tour'; start: { lat: number; lng: number } | null; end: { lat: number; lng: number } | null; pos: number; time: string | null; mode: string | null; incoming: string | null } | { kind: 'transport'; from: { lat: number; lng: number } | null; to: { lat: number; lng: number } | null; pos: number; carrier: boolean } const entries: Entry[] = merged.flatMap((item): Entry[] => { @@ -111,6 +122,8 @@ export function buildDayRouteRuns(dayId: number, input: DayRouteInputs): DayRout }] } if (item.type !== 'transport') return [] + const booking = input.includeLocatedBookings ? locatedBookingWaypoint(item.data, dayId, input.places) : null + if (booking) return [{ kind: 'place', ...booking, pos: item.sortKey, time: null, mode: null, incoming: null }] const { from, to } = getTransportRouteEndpoints(item.data, dayId) return [{ kind: 'transport', from, to, pos: item.sortKey, carrier: isCarrierTransport(item.data) }] }) diff --git a/client/src/components/Map/usePlaceNameLayout.ts b/client/src/components/Map/usePlaceNameLayout.ts index 55a5b8a41..21af54994 100644 --- a/client/src/components/Map/usePlaceNameLayout.ts +++ b/client/src/components/Map/usePlaceNameLayout.ts @@ -1,6 +1,8 @@ import { useCallback, useEffect } from 'react'; +import { useTranslation } from '../../i18n'; import { useSettingsStore } from '../../store/settingsStore'; +import { useToast } from '../shared/Toast'; import { controlBoxes, layoutPlaceNames, PLACE_NAMES_CONTROLS } from './placeNameLabels'; /** Whether the trip map shows its place names, the reader's own setting (#2796). */ @@ -8,6 +10,23 @@ export function usePlaceNamesSetting(): boolean { return useSettingsStore((s) => s.settings.map_place_labels) === true; } +/** Flips the reader's label setting at once and restores it if saving fails. */ +export function usePlaceNamesToggle() { + const { t } = useTranslation(); + const on = usePlaceNamesSetting(); + const updateSetting = useSettingsStore((s) => s.updateSetting); + const toast = useToast(); + const setOn = async (value: boolean) => { + try { + await updateSetting('map_place_labels', value); + } catch (err) { + useSettingsStore.setState((s) => ({ settings: { ...s.settings, map_place_labels: on } })); + toast.error(err instanceof Error ? err.message : t('common.error')); + } + }; + return { on, setOn }; +} + /** * Keeps the place names of one map laid out: once after every change of the markers * (a cluster opening, a day picked) and after every move or zoom the renderer reports diff --git a/client/src/components/Packing/PackingListPanelCategoryGroup.tsx b/client/src/components/Packing/PackingListPanelCategoryGroup.tsx index 81fa9f6ec..3816b5d70 100644 --- a/client/src/components/Packing/PackingListPanelCategoryGroup.tsx +++ b/client/src/components/Packing/PackingListPanelCategoryGroup.tsx @@ -24,7 +24,7 @@ interface KategorieGruppeProps { onRename: (oldName: string, newName: string) => Promise onDeleteAll: (items: PackingItem[]) => Promise onDeleteItem: (item: PackingItem) => Promise - onAddItem: (category: string, name: string) => Promise + onAddItem: (category: string, name: string) => Promise assignees: CategoryAssignee[] tripMembers: TripMember[] onSetAssignees: (category: string, userIds: number[]) => Promise diff --git a/client/src/components/Packing/usePackingItemActions.test.ts b/client/src/components/Packing/usePackingItemActions.test.ts index 58c47fe66..0f2f5edfd 100644 --- a/client/src/components/Packing/usePackingItemActions.test.ts +++ b/client/src/components/Packing/usePackingItemActions.test.ts @@ -80,6 +80,19 @@ describe('usePackingItemActions', () => { expect(phone.acts.addPackingItem).toHaveBeenCalledWith(7, { name: 'Tent', category: 'Camp', visibility: 'common' }); }); + it('uses the personal placeholder when both scopes have the same category name', async () => { + const shared = buildPackingItem({ id: 4, name: PACKING_PLACEHOLDER_NAME, category: 'Camp' }); + const personal = buildPackingItem({ ...shared, id: 5, is_private: 1, owner_id: 9 }); + const { result, acts } = setup({ items: [shared, personal], view: 'personal' }); + + await act(async () => { + await result.current.addItemToCategory('Camp', 'Tent'); + }); + + expect(acts.updatePackingItem).toHaveBeenCalledWith(7, 5, { name: 'Tent' }); + expect(acts.updatePackingItem).toHaveBeenCalledOnce(); + }); + it('FE-PACK-ITEMACT-003: in my list a new item is shared the way the category already is (#2241)', async () => { const own = buildPackingItem({ id: 5, diff --git a/client/src/components/Packing/usePackingItemActions.ts b/client/src/components/Packing/usePackingItemActions.ts index 20ec4c321..1cab5fa88 100644 --- a/client/src/components/Packing/usePackingItemActions.ts +++ b/client/src/components/Packing/usePackingItemActions.ts @@ -57,13 +57,18 @@ export function usePackingItemActions({ const [addingCategory, setAddingCategory] = useState(false); const [newCategoryName, setNewCategoryName] = useState(''); - const addItemToCategory = async (category: string, name: string) => { + const addItemToCategory = async (category: string | null, name: string) => { try { // Reuse the '...' placeholder slot when the category already has one, so a // freshly-emptied category keeps its position (and therefore its colour) // instead of the new item being appended to the end of the list. const pool = placeholderFrom === 'store' ? useTripStore.getState().packingItems : items; - const placeholder = pool.find((i) => i.category === category && isPackingPlaceholder(i)); + const placeholder = packingViewItems(pool, view).find( + (i) => + (i.category || null) === category && + isPackingPlaceholder(i) && + (view === 'common' || i.owner_id == null || i.owner_id === currentUserId) + ); if (placeholder) { await updatePackingItem(tripId, placeholder.id, { name }); } else { @@ -71,12 +76,13 @@ export function usePackingItemActions({ // category's own items agree on (#2241). await addPackingItem(tripId, { name, - category, - ...newItemSharing(items, category, view, currentUserId), + ...(category ? { category, ...newItemSharing(items, category, view, currentUserId) } : { visibility: view }), } as Parameters[1]); } + return true; } catch { toast.error(t('packing.toast.addError')); + return false; } }; @@ -88,7 +94,7 @@ export function usePackingItemActions({ // removing the placeholder is how an empty category is dismissed. const deleteItem = async (item: PackingItem) => { try { - if (isLastCustomItemInCategory(item, items)) { + if (isLastCustomItemInCategory(item, packingViewItems(items, item.is_private ? 'personal' : 'common'))) { if (item.checked) await togglePackingItem(tripId, item.id, false); await updatePackingItem(tripId, item.id, { name: PACKING_PLACEHOLDER_NAME, @@ -106,7 +112,7 @@ export function usePackingItemActions({ /** Moves every item of a category to the new name, one write each; a failure stops it and is thrown. */ const renameCategory = async (oldName: string, newName: string) => { - const toUpdate = items.filter((i) => (i.category || defaultCategory) === oldName); + const toUpdate = packingViewItems(items, view).filter((i) => (i.category || defaultCategory) === oldName); for (const item of toUpdate) { await updatePackingItem(tripId, item.id, { category: newName }); } @@ -136,7 +142,7 @@ export function usePackingItemActions({ /** Removes the checked items of the open view only, the ones the button's count names. */ const clearChecked = async () => { let failed = false; - for (const item of packingViewItems(items, view).filter((i) => i.checked)) { + for (const item of packingViewItems(items, view).filter((i) => i.checked && !isPackingPlaceholder(i))) { try { await deletePackingItem(tripId, item.id); } catch { diff --git a/client/src/components/Planner/BookingImportModal.test.tsx b/client/src/components/Planner/BookingImportModal.test.tsx index 6874371f3..5bd985c63 100644 --- a/client/src/components/Planner/BookingImportModal.test.tsx +++ b/client/src/components/Planner/BookingImportModal.test.tsx @@ -8,6 +8,7 @@ import { useBackgroundTasksStore } from '../../store/backgroundTasksStore'; import { resetAllStores } from '../../../tests/helpers/store'; import { saveImportFiles } from '../../db/offlineDb'; import BookingImportModal from './BookingImportModal'; +import MBookingImportSheet from '../../mobile/screens/trip/sheets/MBookingImportSheet'; vi.mock('../../db/offlineDb', () => ({ saveImportFiles: vi.fn(async () => {}) })); @@ -36,6 +37,32 @@ beforeEach(() => { }); describe('BookingImportModal', () => { + it('uploads the selected mobile PDF once and keeps it for the booking review', async () => { + const onClose = vi.fn(); + const pdf = new File(['%PDF-1.4'], 'booking.pdf', { type: 'application/pdf' }); + const upload = vi.fn(() => HttpResponse.json({ jobId: 'mobile-pdf' })); + server.use(http.post('/api/trips/4/reservations/import/booking/async', upload)); + render(); + expect(screen.getByRole('dialog', { name: 'Import booking confirmations' })).toBeInTheDocument(); + await userEvent.upload(fileInput(), [pdf, eml()]); + await userEvent.click(screen.getByRole('button', { name: 'Remove: booking.eml' })); + const submit = screen.getByRole('button', { name: 'Import' }); + await waitFor(() => expect(submit).toBeEnabled()); + await userEvent.click(submit); + await waitFor(() => expect(onClose).toHaveBeenCalledOnce()); + expect(upload).toHaveBeenCalledOnce(); + expect(saveImportFiles).toHaveBeenCalledWith('mobile-pdf', [pdf]); + expect(useBackgroundTasksStore.getState().tasks.find(task => task.id === 'mobile-pdf')) + .toMatchObject({ kind: 'bookings', total: 1 }); + }); + + it('opens the mobile dialog with an explanation if the server has no parser', async () => { + server.use(http.get('/api/health/features', () => HttpResponse.json({ bookingImport: false, aiParsing: false }))); + render(); + expect(await screen.findByText(/import is not available on this server/i)).toBeInTheDocument(); + expect(screen.queryByRole('button', { name: 'Import' })).not.toBeInTheDocument(); + }); + it('FE-PLANNER-BOOKIMP-001: renders nothing while closed', () => { render(); expect(screen.queryByText('Import booking confirmations')).not.toBeInTheDocument(); diff --git a/client/src/components/Planner/BookingImportModal.tsx b/client/src/components/Planner/BookingImportModal.tsx index d3e4b7da6..86fd2117f 100644 --- a/client/src/components/Planner/BookingImportModal.tsx +++ b/client/src/components/Planner/BookingImportModal.tsx @@ -1,6 +1,6 @@ import { createPortal } from 'react-dom' import { useSharedImportStore } from '../../native/sharedFiles' -import { useState, useRef, useEffect } from 'react' +import { useState, useRef, useEffect, type ReactNode, type DragEventHandler } from 'react' import { Upload, X } from 'lucide-react' import { useTranslation } from '../../i18n' import { reservationsApi, healthApi } from '../../api/client' @@ -11,13 +11,34 @@ import { saveImportFiles } from '../../db/offlineDb' import { isEffectivelyOffline } from '../../sync/networkMode' import TripMailForward from '../MailIngest/TripMailForward' -interface BookingImportModalProps { +export interface BookingImportModalProps { isOpen: boolean onClose: () => void tripId: number /** The tab this import was started from, carried into the job so the review * can pick the right form for an item whose type had to be guessed (#2076). */ kind?: 'transports' | 'bookings' + renderContent?: (view: BookingImportView) => ReactNode +} + +export interface BookingImportView { + tripId: number + files: File[] + fileInput: ReactNode + pickFiles: () => void + removeFile: (index: number) => void + dragHandlers: { + onDragOver: DragEventHandler + onDragLeave: DragEventHandler + onDrop: DragEventHandler + } + isDragOver: boolean + loading: boolean + error: string + available: boolean | null + readsPhotos: boolean + handleClose: () => void + handleParse: () => Promise } const ACCEPTED_EXTS = ['.eml', '.pdf', '.pkpass', '.html', '.htm', '.txt'] @@ -30,7 +51,7 @@ const MAX_FILES = 5 * (progress over the WebSocket). When it finishes, the trip page opens the per-item * review flow — so the user can navigate and keep editing while it works. */ -export default function BookingImportModal({ isOpen, onClose, tripId, kind }: BookingImportModalProps) { +export default function BookingImportModal({ isOpen, onClose, tripId, kind, renderContent }: BookingImportModalProps) { const { t } = useTranslation() const addTask = useBackgroundTasksStore((s) => s.addTask) const fileInputRef = useRef(null) @@ -44,6 +65,7 @@ export default function BookingImportModal({ isOpen, onClose, tripId, kind }: Bo const [loading, setLoading] = useState(false) const [error, setError] = useState('') const [aiParsing, setAiParsing] = useState(false) + const [uploadAvailable, setUploadAvailable] = useState(null) const [readsPhotos, setReadsPhotos] = useState(false) // Only a model that reads images can do anything with a photo, so photos are offered only then. const acceptedExts: readonly string[] = readsPhotos ? [...ACCEPTED_EXTS, ...LLM_PHOTO_EXTENSIONS] : ACCEPTED_EXTS @@ -60,6 +82,7 @@ export default function BookingImportModal({ isOpen, onClose, tripId, kind }: Bo setIsDragOver(false) setLoading(false) setError('') + setUploadAvailable(null) } } @@ -72,8 +95,22 @@ export default function BookingImportModal({ isOpen, onClose, tripId, kind }: Bo useEffect(() => { if (!isOpen) return - healthApi.features().then((f) => setAiParsing(!!f.aiParsing)).catch(() => setAiParsing(false)) - llmRepo.readsPhotos().then(setReadsPhotos).catch(() => setReadsPhotos(false)) + let active = true + healthApi.features().then((f) => { + if (!active) return + setAiParsing(!!f.aiParsing) + setUploadAvailable(!!(f.bookingImport || f.aiParsing)) + }).catch(() => { + if (!active) return + setAiParsing(false) + // Let the import endpoint report a connection or capability error if the feature check fails. + setUploadAvailable(true) + }) + llmRepo.readsPhotos().then( + (supported) => { if (active) setReadsPhotos(supported) }, + () => { if (active) setReadsPhotos(false) } + ) + return () => { active = false } }, [isOpen]) const handleClose = () => { reset(); onClose() } @@ -115,7 +152,7 @@ export default function BookingImportModal({ isOpen, onClose, tripId, kind }: Bo // Start the parse in the background and close — the widget takes it from here. const handleParse = async () => { - if (files.length === 0 || loading) return + if (files.length === 0 || loading || (renderContent && !uploadAvailable)) return // Reading a booking runs on the server: offline there is nothing to send it to. if (isEffectivelyOffline()) { setError(t('reservations.needsConnection')); return } setLoading(true) @@ -136,6 +173,27 @@ export default function BookingImportModal({ isOpen, onClose, tripId, kind }: Bo if (!isOpen) return null + const fileInput = ( + + ) + + if (renderContent) { + return renderContent({ + tripId, files, fileInput, isDragOver, loading, error, available: uploadAvailable, readsPhotos, + pickFiles: () => fileInputRef.current?.click(), + removeFile: index => setFiles(current => current.filter((_, i) => i !== index)), + dragHandlers: { onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop }, + handleClose, handleParse, + }) + } + return createPortal(
{t('reservations.import.acceptedPhotos')}}
- + {fileInput} -
- -

- {description} -

- - {loading ? ( -
- {t('common.loading')} -
- ) : !feedUrl ? ( - <> - -

- {t('dashboard.ics.enableHint')} -

- - ) : ( - <> -
- -
- - -
- - -
-

- {t('dashboard.ics.manageHint')} -

- - )} -
- - -
, - document.body +export function IcsSubscribeModal({ endpoint, title, description, onClose }: IcsSubscribeModalProps) { + const titleId = useId() + const { loading, busy, feedUrl, httpsUrl, webcalUrl, mutate, dayEvents, toggleDayEvents } = useIcsSubscription(endpoint) + return ( + ) } @@ -282,7 +153,7 @@ function DesktopSubscribeDialog({ titleId, title, description, onClose, loading, footer = ( - mutate('POST')} disabled={busy} icon={}> + void mutate('POST')} disabled={busy} icon={}> {t('dashboard.ics.enable')} @@ -299,11 +170,11 @@ function DesktopSubscribeDialog({ titleId, title, description, onClose, loading, ) footer = ( - mutate('PUT')} disabled={busy} icon={}> + void mutate('PUT')} disabled={busy} icon={}> {t('dashboard.ics.regenerate')} - diff --git a/client/src/components/Planner/PlaceDetailsColumn.test.tsx b/client/src/components/Planner/PlaceDetailsColumn.test.tsx index 7d17de1d4..ee7a15098 100644 --- a/client/src/components/Planner/PlaceDetailsColumn.test.tsx +++ b/client/src/components/Planner/PlaceDetailsColumn.test.tsx @@ -86,6 +86,20 @@ describe('PlaceDetailsColumn', () => { expect(placeEnrichment).not.toHaveBeenCalled() }) + it('lets a mobile user upload a picture without opening an empty details group', () => { + renderColumn({ + selection: null, + variant: 'mobile', + image: { + chosen: { kind: 'none' }, + own: { currentUrl: null, attached: [], pendingPreview: null, canUpload: true, onUpload: vi.fn(), onPickAttached: vi.fn(), onRemove: vi.fn() }, + }, + }) + expect(screen.getByRole('button', { name: 'places.uploadImage' })).toHaveTextContent('places.uploadImage') + expect(screen.queryByText('places.details.empty')).not.toBeInTheDocument() + expect(placeEnrichment).not.toHaveBeenCalled() + }) + it('FE-PDC-002: shows a loading state, then the result', async () => { let settle: (v: MapsPlaceEnrichmentResult) => void = () => {} placeEnrichment.mockReturnValue(new Promise((r) => { settle = r })) diff --git a/client/src/components/Planner/PlaceDetailsColumn.tsx b/client/src/components/Planner/PlaceDetailsColumn.tsx index 648143ea5..1fb8f05e2 100644 --- a/client/src/components/Planner/PlaceDetailsColumn.tsx +++ b/client/src/components/Planner/PlaceDetailsColumn.tsx @@ -68,7 +68,7 @@ interface PlaceDetailsColumnProps { * small eyebrows. The default is the phone sheet's look: a card in the mobile * tokens with the same one-line hints. */ - variant?: 'sheet' | 'dialog' + variant?: 'sheet' | 'dialog' | 'mobile' /** False on an instance with no Google key, which is most of them. */ t: TranslationFn } @@ -91,8 +91,7 @@ function SheetHint({ icon, children }: { icon: React.ReactNode; children: React. */ function Overline({ children }: { children: React.ReactNode }): React.ReactElement { return ( - // The phone form's eyebrow (mobile Eyebrow), so these labels match Name, Notes and the rest below. -

{children}

+

{children}

) } @@ -133,6 +132,7 @@ export default function PlaceDetailsColumn({ t, }: PlaceDetailsColumnProps): React.ReactElement { const dialog = variant === 'dialog' + const mobile = variant === 'mobile' const adoptBlockedId = useId() const [data, setData] = useState(null) const [state, setState] = useState('idle') @@ -233,12 +233,27 @@ export default function PlaceDetailsColumn({ !data?.hours && !data?.rating + const pictures = ( + + ) + + if (mobile && !selection) return pictures + return ( // 320px, not 288: the picture grid was doing (288 - 24 - 12) / 3 = 84px // tiles, which is too small to tell a facade from a foyer. The column is // stretched to the form's height by the row it sits in, so the extra room // costs nothing that was being used.