@burdenoff/microfe-ggnomad 2026.1016.1 → 2026.1029.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ggnomad/GGNomadRoot.js +4 -2
- package/dist/ggnomad/GGNomadRoot.js.map +1 -1
- package/dist/ggnomad/GGNomadRoutes.js.map +1 -1
- package/dist/ggnomad/components/AuditTrailDialog.js.map +1 -1
- package/dist/ggnomad/components/AvailabilityPanel.js.map +1 -1
- package/dist/ggnomad/components/BookingPanel.d.ts.map +1 -1
- package/dist/ggnomad/components/BookingPanel.js +53 -70
- package/dist/ggnomad/components/BookingPanel.js.map +1 -1
- package/dist/ggnomad/components/CreateProviderDialog.js.map +1 -1
- package/dist/ggnomad/components/CreateTravelPolicyDialog.js.map +1 -1
- package/dist/ggnomad/components/GroupTripPanel.js.map +1 -1
- package/dist/ggnomad/components/ListingEditDialog.js.map +1 -1
- package/dist/ggnomad/components/ListingFilters.js.map +1 -1
- package/dist/ggnomad/components/PhotoGallery.js.map +1 -1
- package/dist/ggnomad/components/ProviderCard.js.map +1 -1
- package/dist/ggnomad/components/ProviderDashboardCard.js.map +1 -1
- package/dist/ggnomad/components/RatingSummary.js.map +1 -1
- package/dist/ggnomad/components/RedeemTicketPanel.js.map +1 -1
- package/dist/ggnomad/components/ReviewsSection.js.map +1 -1
- package/dist/ggnomad/components/StatusBadge.js.map +1 -1
- package/dist/ggnomad/components/TicketDialog.js +1 -1
- package/dist/ggnomad/components/TicketDialog.js.map +1 -1
- package/dist/ggnomad/components/index.js +26 -25
- package/dist/ggnomad/index.js +3 -2
- package/dist/ggnomad/pages/ActivityDetailsPage.js.map +1 -1
- package/dist/ggnomad/pages/AnalyticsPage.js.map +1 -1
- package/dist/ggnomad/pages/BookingsPage.d.ts.map +1 -1
- package/dist/ggnomad/pages/BookingsPage.js +54 -52
- package/dist/ggnomad/pages/BookingsPage.js.map +1 -1
- package/dist/ggnomad/pages/DashboardPage.js.map +1 -1
- package/dist/ggnomad/pages/EntertainmentPage.js.map +1 -1
- package/dist/ggnomad/pages/EventDetailsPage.js.map +1 -1
- package/dist/ggnomad/pages/FavoritesPage.js.map +1 -1
- package/dist/ggnomad/pages/HospitalityPage.js.map +1 -1
- package/dist/ggnomad/pages/OperationsQueuePage.js.map +1 -1
- package/dist/ggnomad/pages/PageShell.js.map +1 -1
- package/dist/ggnomad/pages/PropertyDetailsPage.js.map +1 -1
- package/dist/ggnomad/pages/ProviderAnalyticsPage.js.map +1 -1
- package/dist/ggnomad/pages/SearchPage.js +1 -1
- package/dist/ggnomad/pages/SearchPage.js.map +1 -1
- package/dist/ggnomad/pages/StorefrontPage.js.map +1 -1
- package/dist/ggnomad/pages/StorefrontPublicPage.js.map +1 -1
- package/dist/ggnomad/pages/TourDetailsPage.js.map +1 -1
- package/dist/ggnomad/pages/TourismPage.js.map +1 -1
- package/dist/ggnomad/pages/TravelPage.js +1 -1
- package/dist/ggnomad/pages/TravelPage.js.map +1 -1
- package/dist/ggnomad/pages/TravelPolicyPage.js.map +1 -1
- package/dist/ggnomad/pages/TripPlanDetailPage.d.ts.map +1 -1
- package/dist/ggnomad/pages/TripPlanDetailPage.js +278 -273
- package/dist/ggnomad/pages/TripPlanDetailPage.js.map +1 -1
- package/dist/ggnomad/pages/TripsPage.js.map +1 -1
- package/dist/ggnomad/providers/GGNomadProvider.js.map +1 -1
- package/dist/ggnomad/utils/bookingDates.d.ts +21 -0
- package/dist/ggnomad/utils/bookingDates.d.ts.map +1 -0
- package/dist/ggnomad/utils/bookingDates.js +22 -0
- package/dist/ggnomad/utils/bookingDates.js.map +1 -0
- package/dist/ggnomad/utils/format.js.map +1 -1
- package/dist/ggnomad/utils/notify.js +1 -1
- package/dist/ggnomad/utils/providerListControls.js +1 -1
- package/dist/ggnomad/utils/providerListControls.js.map +1 -1
- package/dist/ggnomad/utils/providerTypeMeta.js.map +1 -1
- package/dist/utils/pageContext.js +1 -1
- package/dist/utils/pageContext.js.map +1 -1
- package/package.json +18 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TripPlanDetailPage.js","names":[],"sources":["../../../src/ggnomad/pages/TripPlanDetailPage.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport type { TypedDocumentNode } from '@apollo/client';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { ChevronDown, Plus, Users, X } from 'lucide-react';\nimport { useNavigate, useParams } from 'react-router';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n GlassCard,\n IllustratedEmptyState,\n Tabs,\n TabsContent,\n TabsList,\n TabsTrigger,\n} from '@burdenoff/fe-libs/ui';\n\nimport {\n ADD_GGNOMAD_TRIP_PLAN_ITEM_MUTATION,\n CREATE_GGNOMAD_BOOKING_MUTATION,\n GGNOMAD_ACTIVITIES_QUERY,\n GGNOMAD_EVENTS_QUERY,\n GGNOMAD_PROPERTIES_QUERY,\n GGNOMAD_TOURS_QUERY,\n GGNOMAD_TRIP_PLAN_QUERY,\n REMOVE_GGNOMAD_TRIP_PLAN_ITEM_MUTATION,\n UPDATE_GGNOMAD_TRIP_PLAN_MUTATION,\n} from '../graphql';\nimport { PageShell } from './PageShell';\nimport { GroupTripPanel } from '../components';\nimport { notify } from '../utils/notify';\nimport { useGGNomad } from '../providers/GGNomadProvider';\nimport { joinPath } from '../utils/navigation';\n\ntype ItemType = 'PROPERTY' | 'TOUR' | 'EVENT' | 'ACTIVITY';\n\ninterface TripPlanItem {\n id: string;\n itemType: ItemType;\n itemId: string;\n itemName: string;\n day?: number;\n scheduledAt?: string;\n price: number;\n currency: string;\n notes?: string;\n}\n\ninterface AddingItem {\n itemType: ItemType;\n itemId: string;\n itemName: string;\n price: number;\n currency: string;\n}\n\nexport function TripPlanDetailPage() {\n const { t } = useI18n();\n const navigate = useNavigate();\n const { basePath = '/' } = useGGNomad();\n const { id = '' } = useParams();\n const [addingItem, setAddingItem] = useState<AddingItem | null>(null);\n const [showCheckout, setShowCheckout] = useState(false);\n const [removingItemId, setRemovingItemId] = useState<string | null>(null);\n const [activeTab, setActiveTab] = useState('itinerary');\n\n const { data, refetch } = useQuery(\n GGNOMAD_TRIP_PLAN_QUERY as TypedDocumentNode<\n {\n ggnomadTripPlan: {\n id: string;\n name: string;\n description?: string;\n startDate?: string;\n endDate?: string;\n travelers: number;\n status: string;\n total: number;\n itemCount: number;\n items: TripPlanItem[];\n createdAt: string;\n updatedAt: string;\n } | null;\n },\n { id: string }\n >,\n { variables: { id }, skip: !id }\n );\n\n const tripPlan = data?.ggnomadTripPlan;\n\n const { data: propertiesData } = useQuery(\n GGNOMAD_PROPERTIES_QUERY as TypedDocumentNode<\n {\n ggnomadProperties: Array<{\n id: string;\n name: string;\n pricePerNight: number;\n currency: string;\n }>;\n },\n { limit: number; offset: number }\n >,\n { variables: { limit: 20, offset: 0 } }\n );\n\n const { data: toursData } = useQuery(\n GGNOMAD_TOURS_QUERY as TypedDocumentNode<\n {\n ggnomadTours: Array<{\n id: string;\n name: string;\n price: number;\n currency: string;\n }>;\n },\n { limit: number; offset: number }\n >,\n { variables: { limit: 20, offset: 0 } }\n );\n\n const { data: eventsData } = useQuery(\n GGNOMAD_EVENTS_QUERY as TypedDocumentNode<\n {\n ggnomadEvents: Array<{\n id: string;\n name: string;\n price: number;\n currency: string;\n }>;\n },\n { limit: number; offset: number }\n >,\n { variables: { limit: 20, offset: 0 } }\n );\n\n const { data: activitiesData } = useQuery(\n GGNOMAD_ACTIVITIES_QUERY as TypedDocumentNode<\n {\n ggnomadActivities: Array<{\n id: string;\n name: string;\n price: number;\n currency: string;\n }>;\n },\n { limit: number; offset: number }\n >,\n { variables: { limit: 20, offset: 0 } }\n );\n\n const [addItem, { loading: addingItemMutation }] = useMutation(\n ADD_GGNOMAD_TRIP_PLAN_ITEM_MUTATION as TypedDocumentNode<\n {\n addGgnomadTripPlanItem: TripPlanItem;\n },\n {\n tripPlanId: string;\n input: {\n itemType: ItemType;\n itemId: string;\n itemName: string;\n price: number;\n currency: string;\n };\n }\n >\n );\n\n const [removeItem, { loading: removingItemMutation }] = useMutation(\n REMOVE_GGNOMAD_TRIP_PLAN_ITEM_MUTATION as TypedDocumentNode<\n { removeGgnomadTripPlanItem: boolean },\n { id: string }\n >\n );\n\n const [updateStatus] = useMutation(\n UPDATE_GGNOMAD_TRIP_PLAN_MUTATION as TypedDocumentNode<\n {\n updateGgnomadTripPlan: {\n id: string;\n status: string;\n };\n },\n {\n id: string;\n input: {\n status: string;\n };\n }\n >\n );\n\n const [createBooking] = useMutation(\n CREATE_GGNOMAD_BOOKING_MUTATION as TypedDocumentNode<\n {\n createGgnomadBooking: {\n id: string;\n referenceCode: string;\n itemName: string;\n };\n },\n {\n input: {\n bookingType: ItemType;\n itemId: string;\n itemName: string;\n guestName: string;\n guestEmail: string;\n guests: number;\n totalPrice: number;\n currency: string;\n paymentMethod: string;\n };\n }\n >\n );\n\n const handleAddItem = async () => {\n if (!addingItem || !tripPlan) return;\n\n try {\n const result = await addItem({\n variables: {\n tripPlanId: tripPlan.id,\n input: {\n itemType: addingItem.itemType,\n itemId: addingItem.itemId,\n itemName: addingItem.itemName,\n price: addingItem.price,\n currency: addingItem.currency,\n },\n },\n });\n\n if (result.error) {\n notify.error(\n t('ggnomad.tripPlan.toast.addItemErrorTitle', 'Could not add item'),\n result.error.message\n );\n return;\n }\n\n notify.success(\n t('ggnomad.tripPlan.toast.addItemSuccessTitle', 'Item added'),\n addingItem.itemName\n );\n\n setAddingItem(null);\n await refetch();\n } catch (err) {\n notify.error(\n t('ggnomad.tripPlan.toast.addItemErrorTitle', 'Could not add item'),\n err instanceof Error ? err.message : String(err)\n );\n }\n };\n\n const handleRemoveItem = async () => {\n if (!removingItemId) return;\n\n try {\n const result = await removeItem({\n variables: { id: removingItemId },\n });\n\n if (result.error) {\n notify.error(\n t('ggnomad.tripPlan.toast.removeItemErrorTitle', 'Could not remove item'),\n result.error.message\n );\n return;\n }\n\n notify.success(t('ggnomad.tripPlan.toast.removeItemSuccessTitle', 'Item removed'), '');\n\n setRemovingItemId(null);\n await refetch();\n } catch (err) {\n notify.error(\n t('ggnomad.tripPlan.toast.removeItemErrorTitle', 'Could not remove item'),\n err instanceof Error ? err.message : String(err)\n );\n }\n };\n\n const handleCheckout = async () => {\n if (!tripPlan) return;\n\n try {\n for (const item of tripPlan.items) {\n await createBooking({\n variables: {\n input: {\n bookingType: item.itemType,\n itemId: item.itemId,\n itemName: item.itemName,\n guestName: 'Guest',\n guestEmail: 'guest@burdenoff.com',\n guests: tripPlan.travelers,\n totalPrice: item.price,\n currency: item.currency,\n paymentMethod: 'card',\n },\n },\n });\n }\n\n await updateStatus({\n variables: {\n id: tripPlan.id,\n input: { status: 'BOOKED' },\n },\n });\n\n notify.success(\n t('ggnomad.tripPlan.toast.checkoutSuccessTitle', 'Trip booked!'),\n t('ggnomad.tripPlan.toast.checkoutSuccessBody', 'All items have been booked')\n );\n\n await refetch();\n setShowCheckout(false);\n navigate(joinPath(basePath, 'bookings'));\n } catch (err) {\n notify.error(\n t('ggnomad.tripPlan.toast.checkoutErrorTitle', 'Booking failed'),\n err instanceof Error ? err.message : String(err)\n );\n }\n };\n\n if (!tripPlan) {\n return (\n <PageShell\n title={t('ggnomad.tripPlan.loadingTitle', 'Trip Plan')}\n subtitle={t('ggnomad.tripPlan.loadingSubtitle', 'Loading trip plan')}\n >\n <IllustratedEmptyState\n illustration=\"empty-data\"\n title={t('ggnomad.tripPlan.notFoundTitle', 'Trip plan not found')}\n description={t(\n 'ggnomad.tripPlan.notFoundDescription',\n 'This trip may have been deleted or is unavailable.'\n )}\n />\n </PageShell>\n );\n }\n\n const itemsByDay: Record<number, TripPlanItem[]> = {};\n tripPlan.items.forEach((item) => {\n const day = item.day ?? 0;\n if (!itemsByDay[day]) {\n itemsByDay[day] = [];\n }\n itemsByDay[day].push(item);\n });\n\n const sortedDays: number[] = Object.keys(itemsByDay)\n .map((d) => Number(d))\n .sort((a: number, b: number) => a - b);\n\n const properties = propertiesData?.ggnomadProperties ?? [];\n const tours = toursData?.ggnomadTours ?? [];\n const events = eventsData?.ggnomadEvents ?? [];\n const activities = activitiesData?.ggnomadActivities ?? [];\n\n return (\n <PageShell\n title={tripPlan.name}\n subtitle={t('ggnomad.tripPlan.subtitle', 'Build your complete itinerary')}\n >\n <Tabs value={activeTab} onValueChange={setActiveTab} className=\"w-full\">\n <TabsList className=\"mb-6 w-full justify-start\">\n <TabsTrigger value=\"itinerary\">\n {t('ggnomad.tripPlan.tabs.itinerary', 'Itinerary')}\n </TabsTrigger>\n <TabsTrigger value=\"timeline\">\n {t('ggnomad.tripPlan.tabs.timeline', 'Timeline')}\n </TabsTrigger>\n <TabsTrigger value=\"group\">{t('ggnomad.tripPlan.tabs.group', 'Group')}</TabsTrigger>\n </TabsList>\n\n <TabsContent value=\"itinerary\" className=\"space-y-6\">\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-4\">\n {/* Left Rail - Add Items */}\n <div className=\"space-y-4\">\n <GlassCard treatment=\"glass\" glow className=\"border-border-seam p-4\">\n <h3 className=\"mb-3 flex items-center gap-2 font-medium text-text-primary\">\n <Plus className=\"size-4\" />\n {t('ggnomad.tripPlan.addToTrip', 'Add to trip')}\n </h3>\n\n <div className=\"space-y-3\">\n {/* Stays */}\n <details className=\"group\">\n <summary className=\"flex cursor-pointer items-center justify-between rounded-md bg-bg-canvas-inverted p-2 text-sm font-medium text-text-primary hover:bg-opacity-80\">\n {t('ggnomad.tripPlan.stays', 'Stays')}\n <ChevronDown className=\"size-4 transition-transform group-open:rotate-180\" />\n </summary>\n <div className=\"mt-2 space-y-2\">\n {properties.length === 0 ? (\n <p className=\"text-xs text-text-secondary\">\n {t('ggnomad.tripPlan.noStaysAvailable', 'No stays available')}\n </p>\n ) : (\n properties.map((property) => (\n <button\n key={property.id}\n onClick={() =>\n setAddingItem({\n itemType: 'PROPERTY',\n itemId: property.id,\n itemName: property.name,\n price: property.pricePerNight,\n currency: property.currency,\n })\n }\n className=\"w-full rounded-md border border-border-seam bg-bg-canvas p-2 text-left text-xs text-text-primary hover:bg-action-primary-bg hover:text-action-primary-text\"\n >\n <div className=\"font-medium\">{property.name}</div>\n <div className=\"text-text-secondary\">\n {property.currency} {property.pricePerNight.toFixed(2)}\n </div>\n </button>\n ))\n )}\n </div>\n </details>\n\n {/* Tours */}\n <details className=\"group\">\n <summary className=\"flex cursor-pointer items-center justify-between rounded-md bg-bg-canvas-inverted p-2 text-sm font-medium text-text-primary hover:bg-opacity-80\">\n {t('ggnomad.tripPlan.tours', 'Tours')}\n <ChevronDown className=\"size-4 transition-transform group-open:rotate-180\" />\n </summary>\n <div className=\"mt-2 space-y-2\">\n {tours.length === 0 ? (\n <p className=\"text-xs text-text-secondary\">\n {t('ggnomad.tripPlan.noToursAvailable', 'No tours available')}\n </p>\n ) : (\n tours.map((tour) => (\n <button\n key={tour.id}\n onClick={() =>\n setAddingItem({\n itemType: 'TOUR',\n itemId: tour.id,\n itemName: tour.name,\n price: tour.price,\n currency: tour.currency,\n })\n }\n className=\"w-full rounded-md border border-border-seam bg-bg-canvas p-2 text-left text-xs text-text-primary hover:bg-action-primary-bg hover:text-action-primary-text\"\n >\n <div className=\"font-medium\">{tour.name}</div>\n <div className=\"text-text-secondary\">\n {tour.currency} {tour.price.toFixed(2)}\n </div>\n </button>\n ))\n )}\n </div>\n </details>\n\n {/* Events */}\n <details className=\"group\">\n <summary className=\"flex cursor-pointer items-center justify-between rounded-md bg-bg-canvas-inverted p-2 text-sm font-medium text-text-primary hover:bg-opacity-80\">\n {t('ggnomad.tripPlan.events', 'Events')}\n <ChevronDown className=\"size-4 transition-transform group-open:rotate-180\" />\n </summary>\n <div className=\"mt-2 space-y-2\">\n {events.length === 0 ? (\n <p className=\"text-xs text-text-secondary\">\n {t('ggnomad.tripPlan.noEventsAvailable', 'No events available')}\n </p>\n ) : (\n events.map((event) => (\n <button\n key={event.id}\n onClick={() =>\n setAddingItem({\n itemType: 'EVENT',\n itemId: event.id,\n itemName: event.name,\n price: event.price,\n currency: event.currency,\n })\n }\n className=\"w-full rounded-md border border-border-seam bg-bg-canvas p-2 text-left text-xs text-text-primary hover:bg-action-primary-bg hover:text-action-primary-text\"\n >\n <div className=\"font-medium\">{event.name}</div>\n <div className=\"text-text-secondary\">\n {event.currency} {event.price.toFixed(2)}\n </div>\n </button>\n ))\n )}\n </div>\n </details>\n\n {/* Activities */}\n <details className=\"group\">\n <summary className=\"flex cursor-pointer items-center justify-between rounded-md bg-bg-canvas-inverted p-2 text-sm font-medium text-text-primary hover:bg-opacity-80\">\n {t('ggnomad.tripPlan.activities', 'Activities')}\n <ChevronDown className=\"size-4 transition-transform group-open:rotate-180\" />\n </summary>\n <div className=\"mt-2 space-y-2\">\n {activities.length === 0 ? (\n <p className=\"text-xs text-text-secondary\">\n {t('ggnomad.tripPlan.noActivitiesAvailable', 'No activities available')}\n </p>\n ) : (\n activities.map((activity) => (\n <button\n key={activity.id}\n onClick={() =>\n setAddingItem({\n itemType: 'ACTIVITY',\n itemId: activity.id,\n itemName: activity.name,\n price: activity.price,\n currency: activity.currency,\n })\n }\n className=\"w-full rounded-md border border-border-seam bg-bg-canvas p-2 text-left text-xs text-text-primary hover:bg-action-primary-bg hover:text-action-primary-text\"\n >\n <div className=\"font-medium\">{activity.name}</div>\n <div className=\"text-text-secondary\">\n {activity.currency} {activity.price.toFixed(2)}\n </div>\n </button>\n ))\n )}\n </div>\n </details>\n </div>\n </GlassCard>\n </div>\n\n {/* Center - Itinerary Items */}\n <div className=\"space-y-4 lg:col-span-2\">\n <GlassCard treatment=\"glass\" glow className=\"border-border-seam p-5\">\n <h2 className=\"mb-4 text-lg font-medium tracking-tight text-text-primary\">\n {t('ggnomad.tripPlan.itineraryHeader', 'Your itinerary')}\n </h2>\n\n {tripPlan.items.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t(\n 'ggnomad.tripPlan.noItemsYet',\n 'No items added yet. Start adding stays, tours, events and activities from the left.'\n )}\n </p>\n ) : (\n <div className=\"space-y-6\">\n {sortedDays.map((day: number) => (\n <div key={String(day)}>\n <h3 className=\"mb-2 text-sm font-medium text-text-secondary\">\n {day === 0\n ? t('ggnomad.tripPlan.unscheduled', 'Unscheduled')\n : t('ggnomad.tripPlan.day', 'Day {{day}}').replace(\n '{{day}}',\n String(day)\n )}\n </h3>\n <div className=\"space-y-2\">\n {(itemsByDay[day] || []).map((item: TripPlanItem) => (\n <div\n key={item.id}\n className=\"flex items-start justify-between rounded-md border border-border-seam bg-bg-canvas p-3\"\n >\n <div className=\"flex-1\">\n <p className=\"font-medium text-text-primary\">{item.itemName}</p>\n <p className=\"text-xs text-text-secondary\">\n {item.itemType.charAt(0) + item.itemType.slice(1).toLowerCase()}\n </p>\n <p className=\"mt-1 font-semibold text-status-success-text\">\n {item.currency} {item.price.toFixed(2)}\n </p>\n </div>\n <button\n onClick={() => setRemovingItemId(item.id)}\n className=\"ml-2 rounded-md p-1 text-text-secondary hover:bg-action-danger-bg hover:text-action-danger-text\"\n aria-label={t('ggnomad.tripPlan.removeItem', 'Remove item')}\n >\n <X className=\"size-4\" />\n </button>\n </div>\n ))}\n </div>\n </div>\n ))}\n </div>\n )}\n </GlassCard>\n </div>\n\n {/* Right - Trip Summary */}\n <div className=\"space-y-4\">\n <GlassCard treatment=\"glass\" glow className=\"sticky top-6 border-border-seam p-5\">\n <h3 className=\"mb-4 font-medium text-text-primary\">\n {t('ggnomad.tripPlan.tripTotal', 'Trip total')}\n </h3>\n\n <div className=\"space-y-3 border-b border-border-seam pb-4\">\n <div className=\"flex items-center justify-between text-sm\">\n <span className=\"text-text-secondary\">\n {t('ggnomad.tripPlan.items', 'Items')}\n </span>\n <span className=\"font-medium text-text-primary\">{tripPlan.itemCount}</span>\n </div>\n <div className=\"flex items-center justify-between text-sm\">\n <span className=\"text-text-secondary\">\n {t('ggnomad.tripPlan.travelers', 'Travelers')}\n </span>\n <span className=\"font-medium text-text-primary flex items-center gap-1\">\n <Users className=\"size-3\" />\n {tripPlan.travelers}\n </span>\n </div>\n </div>\n\n <div className=\"my-4\">\n <div className=\"text-2xl font-bold text-text-primary\">\n USD {tripPlan.total.toFixed(2)}\n </div>\n {tripPlan.travelers > 0 && (\n <div className=\"mt-3 rounded-md border border-border-seam bg-bg-canvas/50 p-3\">\n <p className=\"text-xs font-medium text-text-secondary\">\n {t('ggnomad.tripPlan.costSplit', 'Split {{count}} ways').replace(\n '{{count}}',\n String(tripPlan.travelers)\n )}\n </p>\n <p className=\"mt-1 text-lg font-semibold text-action-primary-text\">\n USD {(tripPlan.total / tripPlan.travelers).toFixed(2)} each\n </p>\n <p className=\"mt-2 text-xs text-text-secondary\">\n {t(\n 'ggnomad.tripPlan.costSplitNote',\n 'This trip plan is shared with everyone in your workspace.'\n )}\n </p>\n </div>\n )}\n </div>\n\n <div className=\"space-y-2\">\n <button\n onClick={() => setShowCheckout(true)}\n disabled={tripPlan.items.length === 0}\n className=\"w-full rounded-md bg-action-primary-bg px-4 py-2 font-medium text-action-primary-text hover:bg-action-primary-bgHover disabled:opacity-50\"\n >\n {t('ggnomad.tripPlan.checkout', 'Checkout')}\n </button>\n\n <div className=\"flex items-center gap-2\">\n <select\n value={tripPlan.status}\n onChange={async (e) => {\n await updateStatus({\n variables: {\n id: tripPlan.id,\n input: { status: e.target.value },\n },\n });\n await refetch();\n }}\n className=\"flex-1 rounded-md border border-border-seam bg-bg-canvas px-2 py-1 text-sm text-text-primary\"\n >\n <option value=\"DRAFT\">Draft</option>\n <option value=\"PLANNED\">Planned</option>\n <option value=\"BOOKED\">Booked</option>\n <option value=\"CONFIRMED\">Confirmed</option>\n <option value=\"COMPLETED\">Completed</option>\n <option value=\"CANCELLED\">Cancelled</option>\n </select>\n </div>\n </div>\n </GlassCard>\n </div>\n </div>\n </TabsContent>\n\n <TabsContent value=\"timeline\" className=\"space-y-4\">\n <GlassCard treatment=\"glass\" glow className=\"border-border-seam p-5\">\n <h2 className=\"mb-4 text-lg font-medium tracking-tight text-text-primary\">\n {t('ggnomad.tripPlan.timeline', 'Trip timeline')}\n </h2>\n\n <div className=\"space-y-6\">\n {/* Plan Status Milestone */}\n <div className=\"flex gap-4\">\n <div className=\"flex flex-col items-center\">\n <div className=\"size-3 rounded-full bg-status-info-bg\" />\n <div className=\"my-2 h-8 w-0.5 bg-border-seam\" />\n </div>\n <div>\n <h3 className=\"font-medium text-text-primary\">\n {t('ggnomad.tripPlan.milestone.started', 'Trip started')}\n </h3>\n <p className=\"text-xs text-text-secondary\">\n {t('ggnomad.tripPlan.milestone.startedDesc', 'Created your itinerary')}\n </p>\n </div>\n </div>\n\n {/* Items Timeline */}\n {tripPlan.items.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('ggnomad.tripPlan.noItemsInTimeline', 'No items in your timeline yet')}\n </p>\n ) : (\n tripPlan.items.map((item, index) => (\n <div key={item.id} className=\"flex gap-4\">\n <div className=\"flex flex-col items-center\">\n <div\n className={`size-3 rounded-full ${\n tripPlan.status === 'BOOKED' || tripPlan.status === 'COMPLETED'\n ? 'bg-status-success-bg'\n : 'bg-status-warning-bg'\n }`}\n />\n {index < tripPlan.items.length - 1 && (\n <div className=\"my-2 h-8 w-0.5 bg-border-seam\" />\n )}\n </div>\n <div>\n <h3 className=\"font-medium text-text-primary\">{item.itemName}</h3>\n <p className=\"text-xs text-text-secondary\">\n {item.itemType.charAt(0) + item.itemType.slice(1).toLowerCase()}\n {item.day && ` · Day ${item.day}`}\n </p>\n <p className=\"mt-1 text-sm font-semibold text-status-success-text\">\n {item.currency} {item.price.toFixed(2)}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {tripPlan.status === 'BOOKED' || tripPlan.status === 'COMPLETED'\n ? t('ggnomad.tripPlan.milestone.booked', 'Booked')\n : t('ggnomad.tripPlan.milestone.planned', 'Planned')}\n </p>\n </div>\n </div>\n ))\n )}\n\n {/* Final Status */}\n {tripPlan.items.length > 0 && (\n <>\n <div className=\"flex gap-4\">\n <div className=\"flex flex-col items-center\">\n <div\n className={`size-3 rounded-full ${\n tripPlan.status === 'COMPLETED'\n ? 'bg-status-success-bg'\n : 'bg-status-secondary-bg'\n }`}\n />\n </div>\n <div>\n <h3 className=\"font-medium text-text-primary\">\n {tripPlan.status === 'COMPLETED'\n ? t('ggnomad.tripPlan.milestone.completed', 'Trip completed')\n : t('ggnomad.tripPlan.milestone.confirming', 'Awaiting completion')}\n </h3>\n <p className=\"text-xs text-text-secondary\">\n {tripPlan.status === 'COMPLETED'\n ? t('ggnomad.tripPlan.milestone.completedDesc', 'Your trip is complete')\n : t(\n 'ggnomad.tripPlan.milestone.confirmingDesc',\n 'Update status as your trip progresses'\n )}\n </p>\n </div>\n </div>\n </>\n )}\n </div>\n </GlassCard>\n </TabsContent>\n\n <TabsContent value=\"group\" className=\"space-y-4\">\n <GroupTripPanel\n tripPlanId={tripPlan.id}\n tripPlanName={tripPlan.name}\n items={tripPlan.items.map((item) => ({\n id: item.id,\n itemName: item.itemName,\n price: item.price,\n currency: item.currency,\n }))}\n />\n </TabsContent>\n </Tabs>\n\n {/* Add Item Dialog */}\n <AlertDialog open={addingItem !== null} onOpenChange={(open) => !open && setAddingItem(null)}>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>\n {t('ggnomad.tripPlan.addItemDialog.title', 'Add to itinerary?')}\n </AlertDialogTitle>\n <AlertDialogDescription>\n {addingItem && (\n <>\n {addingItem.itemName}\n {' · '}\n {addingItem.currency} {addingItem.price.toFixed(2)}\n </>\n )}\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel disabled={addingItemMutation}>\n {t('ggnomad.tripPlan.addItemDialog.cancel', 'Cancel')}\n </AlertDialogCancel>\n <AlertDialogAction\n disabled={addingItemMutation}\n onClick={(event) => {\n event.preventDefault();\n void handleAddItem();\n }}\n >\n {addingItemMutation\n ? t('ggnomad.tripPlan.addItemDialog.adding', 'Adding…')\n : t('ggnomad.tripPlan.addItemDialog.add', 'Add item')}\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n\n {/* Remove Item Dialog */}\n <AlertDialog\n open={removingItemId !== null}\n onOpenChange={(open) => !open && setRemovingItemId(null)}\n >\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>\n {t('ggnomad.tripPlan.removeItemDialog.title', 'Remove item from trip?')}\n </AlertDialogTitle>\n <AlertDialogDescription>\n {t(\n 'ggnomad.tripPlan.removeItemDialog.description',\n 'This item will be removed from your itinerary.'\n )}\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel disabled={removingItemMutation}>\n {t('ggnomad.tripPlan.removeItemDialog.cancel', 'Keep item')}\n </AlertDialogCancel>\n <AlertDialogAction\n className=\"bg-action-danger-bg text-action-danger-text hover:bg-action-danger-bgHover\"\n disabled={removingItemMutation}\n onClick={(event) => {\n event.preventDefault();\n void handleRemoveItem();\n }}\n >\n {removingItemMutation\n ? t('ggnomad.tripPlan.removeItemDialog.removing', 'Removing…')\n : t('ggnomad.tripPlan.removeItemDialog.remove', 'Remove item')}\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n\n {/* Checkout Dialog */}\n <AlertDialog open={showCheckout} onOpenChange={setShowCheckout}>\n <AlertDialogContent className=\"max-w-2xl\">\n <AlertDialogHeader>\n <AlertDialogTitle>\n {t('ggnomad.tripPlan.checkoutDialog.title', 'Review and book')}\n </AlertDialogTitle>\n <AlertDialogDescription>\n {t(\n 'ggnomad.tripPlan.checkoutDialog.description',\n 'Review your items and confirm to book everything at once.'\n )}\n </AlertDialogDescription>\n </AlertDialogHeader>\n\n <div className=\"space-y-4 max-h-96 overflow-y-auto\">\n {tripPlan.items.map((item) => (\n <div\n key={item.id}\n className=\"flex items-center justify-between rounded-md border border-border-seam bg-bg-canvas p-3\"\n >\n <div>\n <p className=\"font-medium text-text-primary\">{item.itemName}</p>\n <p className=\"text-xs text-text-secondary\">\n {item.itemType.charAt(0) + item.itemType.slice(1).toLowerCase()}\n </p>\n </div>\n <p className=\"font-semibold text-text-primary\">\n {item.currency} {item.price.toFixed(2)}\n </p>\n </div>\n ))}\n\n <div className=\"space-y-2 border-t border-border-seam pt-4\">\n <div className=\"flex justify-between text-sm\">\n <span className=\"text-text-secondary\">Subtotal</span>\n <span className=\"text-text-primary\">USD {tripPlan.total.toFixed(2)}</span>\n </div>\n <div className=\"flex justify-between text-sm\">\n <span className=\"text-text-secondary\">Taxes (10%)</span>\n <span className=\"text-text-primary\">USD {(tripPlan.total * 0.1).toFixed(2)}</span>\n </div>\n <div className=\"flex justify-between border-t border-border-seam pt-2 text-lg font-bold\">\n <span className=\"text-text-primary\">Total</span>\n <span className=\"text-status-success-text\">\n USD {(tripPlan.total * 1.1).toFixed(2)}\n </span>\n </div>\n </div>\n </div>\n\n <AlertDialogFooter>\n <AlertDialogCancel disabled={false}>\n {t('ggnomad.tripPlan.checkoutDialog.cancel', 'Cancel')}\n </AlertDialogCancel>\n <AlertDialogAction\n onClick={(event) => {\n event.preventDefault();\n void handleCheckout();\n }}\n >\n {t('ggnomad.tripPlan.checkoutDialog.confirm', 'Confirm & book all')}\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </PageShell>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8DA,SAAgB,IAAqB;CACnC,IAAM,EAAE,SAAM,GAAQ,GAChB,IAAW,GAAY,GACvB,EAAE,cAAW,QAAQ,EAAW,GAChC,EAAE,QAAK,OAAO,GAAU,GACxB,CAAC,GAAY,KAAiB,EAA4B,IAAI,GAC9D,CAAC,GAAc,KAAmB,EAAS,EAAK,GAChD,CAAC,GAAgB,KAAqB,EAAwB,IAAI,GAClE,CAAC,GAAW,KAAgB,EAAS,WAAW,GAEhD,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kBAAC,OAAD;QAAK,WAAU;kBAAf;SACE,kBAAC,OAAD;UAAK,WAAU;oBAAf,CACE,kBAAC,QAAD;WAAM,WAAU;qBAAsB;UAAc,CAAA,GACpD,kBAAC,QAAD;WAAM,WAAU;qBAAhB,CAAoC,QAAK,EAAS,MAAM,QAAQ,CAAC,CAAQ;YACtE;;SACL,kBAAC,OAAD;UAAK,WAAU;oBAAf,CACE,kBAAC,QAAD;WAAM,WAAU;qBAAsB;UAAiB,CAAA,GACvD,kBAAC,QAAD;WAAM,WAAU;qBAAhB,CAAoC,SAAM,EAAS,QAAQ,IAAK,QAAQ,CAAC,CAAQ;YAC9E;;SACL,kBAAC,OAAD;UAAK,WAAU;oBAAf,CACE,kBAAC,QAAD;WAAM,WAAU;qBAAoB;UAAW,CAAA,GAC/C,kBAAC,QAAD;WAAM,WAAU;qBAAhB,CAA2C,SACnC,EAAS,QAAQ,KAAK,QAAQ,CAAC,CACjC;YACH;;QACF;SACF;;MAEL,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;OAAmB,UAAU;iBAC1B,EAAE,0CAA0C,QAAQ;MACpC,CAAA,GACnB,kBAAC,GAAD;OACE,UAAU,MAAU;QAElB,AADA,EAAM,eAAe,GACrB,GAAoB;OACtB;iBAEC,EAAE,2CAA2C,oBAAoB;MACjD,CAAA,CACF,EAAA,CAAA;KACD;;GACT,CAAA;EACJ;;AAEf"}
|
|
1
|
+
{"version":3,"file":"TripPlanDetailPage.js","names":[],"sources":["../../../src/ggnomad/pages/TripPlanDetailPage.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport type { TypedDocumentNode } from '@apollo/client';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { ChevronDown, Plus, Users, X } from 'lucide-react';\nimport { useNavigate, useParams } from 'react-router';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n GlassCard,\n IllustratedEmptyState,\n Tabs,\n TabsContent,\n TabsList,\n TabsTrigger,\n} from '@burdenoff/fe-libs/ui';\n\nimport {\n ADD_GGNOMAD_TRIP_PLAN_ITEM_MUTATION,\n CREATE_GGNOMAD_BOOKING_MUTATION,\n GGNOMAD_ACTIVITIES_QUERY,\n GGNOMAD_EVENTS_QUERY,\n GGNOMAD_PROPERTIES_QUERY,\n GGNOMAD_TOURS_QUERY,\n GGNOMAD_TRIP_PLAN_QUERY,\n REMOVE_GGNOMAD_TRIP_PLAN_ITEM_MUTATION,\n UPDATE_GGNOMAD_TRIP_PLAN_MUTATION,\n} from '../graphql';\nimport { PageShell } from './PageShell';\nimport { GroupTripPanel } from '../components';\nimport { notify } from '../utils/notify';\nimport { useGGNomad } from '../providers/GGNomadProvider';\nimport { joinPath } from '../utils/navigation';\nimport { stayDates } from '../utils/bookingDates';\n\ntype ItemType = 'PROPERTY' | 'TOUR' | 'EVENT' | 'ACTIVITY';\n\ninterface TripPlanItem {\n id: string;\n itemType: ItemType;\n itemId: string;\n itemName: string;\n day?: number;\n scheduledAt?: string;\n price: number;\n currency: string;\n notes?: string;\n}\n\ninterface AddingItem {\n itemType: ItemType;\n itemId: string;\n itemName: string;\n price: number;\n currency: string;\n}\n\nexport function TripPlanDetailPage() {\n const { t } = useI18n();\n const navigate = useNavigate();\n const { basePath = '/' } = useGGNomad();\n const { id = '' } = useParams();\n const [addingItem, setAddingItem] = useState<AddingItem | null>(null);\n const [showCheckout, setShowCheckout] = useState(false);\n const [removingItemId, setRemovingItemId] = useState<string | null>(null);\n const [activeTab, setActiveTab] = useState('itinerary');\n\n const { data, refetch } = useQuery(\n GGNOMAD_TRIP_PLAN_QUERY as TypedDocumentNode<\n {\n ggnomadTripPlan: {\n id: string;\n name: string;\n description?: string;\n startDate?: string;\n endDate?: string;\n travelers: number;\n status: string;\n total: number;\n itemCount: number;\n items: TripPlanItem[];\n createdAt: string;\n updatedAt: string;\n } | null;\n },\n { id: string }\n >,\n { variables: { id }, skip: !id }\n );\n\n const tripPlan = data?.ggnomadTripPlan;\n\n const { data: propertiesData } = useQuery(\n GGNOMAD_PROPERTIES_QUERY as TypedDocumentNode<\n {\n ggnomadProperties: Array<{\n id: string;\n name: string;\n pricePerNight: number;\n currency: string;\n }>;\n },\n { limit: number; offset: number }\n >,\n { variables: { limit: 20, offset: 0 } }\n );\n\n const { data: toursData } = useQuery(\n GGNOMAD_TOURS_QUERY as TypedDocumentNode<\n {\n ggnomadTours: Array<{\n id: string;\n name: string;\n price: number;\n currency: string;\n }>;\n },\n { limit: number; offset: number }\n >,\n { variables: { limit: 20, offset: 0 } }\n );\n\n const { data: eventsData } = useQuery(\n GGNOMAD_EVENTS_QUERY as TypedDocumentNode<\n {\n ggnomadEvents: Array<{\n id: string;\n name: string;\n price: number;\n currency: string;\n }>;\n },\n { limit: number; offset: number }\n >,\n { variables: { limit: 20, offset: 0 } }\n );\n\n const { data: activitiesData } = useQuery(\n GGNOMAD_ACTIVITIES_QUERY as TypedDocumentNode<\n {\n ggnomadActivities: Array<{\n id: string;\n name: string;\n price: number;\n currency: string;\n }>;\n },\n { limit: number; offset: number }\n >,\n { variables: { limit: 20, offset: 0 } }\n );\n\n const [addItem, { loading: addingItemMutation }] = useMutation(\n ADD_GGNOMAD_TRIP_PLAN_ITEM_MUTATION as TypedDocumentNode<\n {\n addGgnomadTripPlanItem: TripPlanItem;\n },\n {\n tripPlanId: string;\n input: {\n itemType: ItemType;\n itemId: string;\n itemName: string;\n price: number;\n currency: string;\n };\n }\n >\n );\n\n const [removeItem, { loading: removingItemMutation }] = useMutation(\n REMOVE_GGNOMAD_TRIP_PLAN_ITEM_MUTATION as TypedDocumentNode<\n { removeGgnomadTripPlanItem: boolean },\n { id: string }\n >\n );\n\n const [updateStatus] = useMutation(\n UPDATE_GGNOMAD_TRIP_PLAN_MUTATION as TypedDocumentNode<\n {\n updateGgnomadTripPlan: {\n id: string;\n status: string;\n };\n },\n {\n id: string;\n input: {\n status: string;\n };\n }\n >\n );\n\n const [createBooking] = useMutation(\n CREATE_GGNOMAD_BOOKING_MUTATION as TypedDocumentNode<\n {\n createGgnomadBooking: {\n id: string;\n referenceCode: string;\n itemName: string;\n };\n },\n {\n input: {\n bookingType: ItemType;\n itemId: string;\n itemName: string;\n guestName: string;\n guestEmail: string;\n guests: number;\n totalPrice: number;\n currency: string;\n paymentMethod: string;\n checkIn?: string;\n checkOut?: string;\n eventDate?: string;\n };\n }\n >\n );\n\n const handleAddItem = async () => {\n if (!addingItem || !tripPlan) return;\n\n try {\n const result = await addItem({\n variables: {\n tripPlanId: tripPlan.id,\n input: {\n itemType: addingItem.itemType,\n itemId: addingItem.itemId,\n itemName: addingItem.itemName,\n price: addingItem.price,\n currency: addingItem.currency,\n },\n },\n });\n\n if (result.error) {\n notify.error(\n t('ggnomad.tripPlan.toast.addItemErrorTitle', 'Could not add item'),\n result.error.message\n );\n return;\n }\n\n notify.success(\n t('ggnomad.tripPlan.toast.addItemSuccessTitle', 'Item added'),\n addingItem.itemName\n );\n\n setAddingItem(null);\n await refetch();\n } catch (err) {\n notify.error(\n t('ggnomad.tripPlan.toast.addItemErrorTitle', 'Could not add item'),\n err instanceof Error ? err.message : String(err)\n );\n }\n };\n\n const handleRemoveItem = async () => {\n if (!removingItemId) return;\n\n try {\n const result = await removeItem({\n variables: { id: removingItemId },\n });\n\n if (result.error) {\n notify.error(\n t('ggnomad.tripPlan.toast.removeItemErrorTitle', 'Could not remove item'),\n result.error.message\n );\n return;\n }\n\n notify.success(t('ggnomad.tripPlan.toast.removeItemSuccessTitle', 'Item removed'), '');\n\n setRemovingItemId(null);\n await refetch();\n } catch (err) {\n notify.error(\n t('ggnomad.tripPlan.toast.removeItemErrorTitle', 'Could not remove item'),\n err instanceof Error ? err.message : String(err)\n );\n }\n };\n\n const handleCheckout = async () => {\n if (!tripPlan) return;\n\n try {\n for (const item of tripPlan.items) {\n // The service prices each booking from its listing (BOFF-10193): a\n // stay needs its nights, anything else the day it is scheduled for.\n const dates =\n item.itemType === 'PROPERTY'\n ? stayDates(item.scheduledAt ?? tripPlan.startDate, tripPlan.endDate)\n : item.scheduledAt\n ? { eventDate: item.scheduledAt }\n : {};\n await createBooking({\n variables: {\n input: {\n bookingType: item.itemType,\n itemId: item.itemId,\n itemName: item.itemName,\n guestName: 'Guest',\n guestEmail: 'guest@burdenoff.com',\n guests: tripPlan.travelers,\n totalPrice: item.price,\n currency: item.currency,\n paymentMethod: 'card',\n ...dates,\n },\n },\n });\n }\n\n await updateStatus({\n variables: {\n id: tripPlan.id,\n input: { status: 'BOOKED' },\n },\n });\n\n notify.success(\n t('ggnomad.tripPlan.toast.checkoutSuccessTitle', 'Trip booked!'),\n t('ggnomad.tripPlan.toast.checkoutSuccessBody', 'All items have been booked')\n );\n\n await refetch();\n setShowCheckout(false);\n navigate(joinPath(basePath, 'bookings'));\n } catch (err) {\n notify.error(\n t('ggnomad.tripPlan.toast.checkoutErrorTitle', 'Booking failed'),\n err instanceof Error ? err.message : String(err)\n );\n }\n };\n\n if (!tripPlan) {\n return (\n <PageShell\n title={t('ggnomad.tripPlan.loadingTitle', 'Trip Plan')}\n subtitle={t('ggnomad.tripPlan.loadingSubtitle', 'Loading trip plan')}\n >\n <IllustratedEmptyState\n illustration=\"empty-data\"\n title={t('ggnomad.tripPlan.notFoundTitle', 'Trip plan not found')}\n description={t(\n 'ggnomad.tripPlan.notFoundDescription',\n 'This trip may have been deleted or is unavailable.'\n )}\n />\n </PageShell>\n );\n }\n\n const itemsByDay: Record<number, TripPlanItem[]> = {};\n tripPlan.items.forEach((item) => {\n const day = item.day ?? 0;\n if (!itemsByDay[day]) {\n itemsByDay[day] = [];\n }\n itemsByDay[day].push(item);\n });\n\n const sortedDays: number[] = Object.keys(itemsByDay)\n .map((d) => Number(d))\n .sort((a: number, b: number) => a - b);\n\n const properties = propertiesData?.ggnomadProperties ?? [];\n const tours = toursData?.ggnomadTours ?? [];\n const events = eventsData?.ggnomadEvents ?? [];\n const activities = activitiesData?.ggnomadActivities ?? [];\n\n return (\n <PageShell\n title={tripPlan.name}\n subtitle={t('ggnomad.tripPlan.subtitle', 'Build your complete itinerary')}\n >\n <Tabs value={activeTab} onValueChange={setActiveTab} className=\"w-full\">\n <TabsList className=\"mb-6 w-full justify-start\">\n <TabsTrigger value=\"itinerary\">\n {t('ggnomad.tripPlan.tabs.itinerary', 'Itinerary')}\n </TabsTrigger>\n <TabsTrigger value=\"timeline\">\n {t('ggnomad.tripPlan.tabs.timeline', 'Timeline')}\n </TabsTrigger>\n <TabsTrigger value=\"group\">{t('ggnomad.tripPlan.tabs.group', 'Group')}</TabsTrigger>\n </TabsList>\n\n <TabsContent value=\"itinerary\" className=\"space-y-6\">\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-4\">\n {/* Left Rail - Add Items */}\n <div className=\"space-y-4\">\n <GlassCard treatment=\"glass\" glow className=\"border-border-seam p-4\">\n <h3 className=\"mb-3 flex items-center gap-2 font-medium text-text-primary\">\n <Plus className=\"size-4\" />\n {t('ggnomad.tripPlan.addToTrip', 'Add to trip')}\n </h3>\n\n <div className=\"space-y-3\">\n {/* Stays */}\n <details className=\"group\">\n <summary className=\"flex cursor-pointer items-center justify-between rounded-md bg-bg-canvas-inverted p-2 text-sm font-medium text-text-primary hover:bg-opacity-80\">\n {t('ggnomad.tripPlan.stays', 'Stays')}\n <ChevronDown className=\"size-4 transition-transform group-open:rotate-180\" />\n </summary>\n <div className=\"mt-2 space-y-2\">\n {properties.length === 0 ? (\n <p className=\"text-xs text-text-secondary\">\n {t('ggnomad.tripPlan.noStaysAvailable', 'No stays available')}\n </p>\n ) : (\n properties.map((property) => (\n <button\n key={property.id}\n onClick={() =>\n setAddingItem({\n itemType: 'PROPERTY',\n itemId: property.id,\n itemName: property.name,\n price: property.pricePerNight,\n currency: property.currency,\n })\n }\n className=\"w-full rounded-md border border-border-seam bg-bg-canvas p-2 text-left text-xs text-text-primary hover:bg-action-primary-bg hover:text-action-primary-text\"\n >\n <div className=\"font-medium\">{property.name}</div>\n <div className=\"text-text-secondary\">\n {property.currency} {property.pricePerNight.toFixed(2)}\n </div>\n </button>\n ))\n )}\n </div>\n </details>\n\n {/* Tours */}\n <details className=\"group\">\n <summary className=\"flex cursor-pointer items-center justify-between rounded-md bg-bg-canvas-inverted p-2 text-sm font-medium text-text-primary hover:bg-opacity-80\">\n {t('ggnomad.tripPlan.tours', 'Tours')}\n <ChevronDown className=\"size-4 transition-transform group-open:rotate-180\" />\n </summary>\n <div className=\"mt-2 space-y-2\">\n {tours.length === 0 ? (\n <p className=\"text-xs text-text-secondary\">\n {t('ggnomad.tripPlan.noToursAvailable', 'No tours available')}\n </p>\n ) : (\n tours.map((tour) => (\n <button\n key={tour.id}\n onClick={() =>\n setAddingItem({\n itemType: 'TOUR',\n itemId: tour.id,\n itemName: tour.name,\n price: tour.price,\n currency: tour.currency,\n })\n }\n className=\"w-full rounded-md border border-border-seam bg-bg-canvas p-2 text-left text-xs text-text-primary hover:bg-action-primary-bg hover:text-action-primary-text\"\n >\n <div className=\"font-medium\">{tour.name}</div>\n <div className=\"text-text-secondary\">\n {tour.currency} {tour.price.toFixed(2)}\n </div>\n </button>\n ))\n )}\n </div>\n </details>\n\n {/* Events */}\n <details className=\"group\">\n <summary className=\"flex cursor-pointer items-center justify-between rounded-md bg-bg-canvas-inverted p-2 text-sm font-medium text-text-primary hover:bg-opacity-80\">\n {t('ggnomad.tripPlan.events', 'Events')}\n <ChevronDown className=\"size-4 transition-transform group-open:rotate-180\" />\n </summary>\n <div className=\"mt-2 space-y-2\">\n {events.length === 0 ? (\n <p className=\"text-xs text-text-secondary\">\n {t('ggnomad.tripPlan.noEventsAvailable', 'No events available')}\n </p>\n ) : (\n events.map((event) => (\n <button\n key={event.id}\n onClick={() =>\n setAddingItem({\n itemType: 'EVENT',\n itemId: event.id,\n itemName: event.name,\n price: event.price,\n currency: event.currency,\n })\n }\n className=\"w-full rounded-md border border-border-seam bg-bg-canvas p-2 text-left text-xs text-text-primary hover:bg-action-primary-bg hover:text-action-primary-text\"\n >\n <div className=\"font-medium\">{event.name}</div>\n <div className=\"text-text-secondary\">\n {event.currency} {event.price.toFixed(2)}\n </div>\n </button>\n ))\n )}\n </div>\n </details>\n\n {/* Activities */}\n <details className=\"group\">\n <summary className=\"flex cursor-pointer items-center justify-between rounded-md bg-bg-canvas-inverted p-2 text-sm font-medium text-text-primary hover:bg-opacity-80\">\n {t('ggnomad.tripPlan.activities', 'Activities')}\n <ChevronDown className=\"size-4 transition-transform group-open:rotate-180\" />\n </summary>\n <div className=\"mt-2 space-y-2\">\n {activities.length === 0 ? (\n <p className=\"text-xs text-text-secondary\">\n {t('ggnomad.tripPlan.noActivitiesAvailable', 'No activities available')}\n </p>\n ) : (\n activities.map((activity) => (\n <button\n key={activity.id}\n onClick={() =>\n setAddingItem({\n itemType: 'ACTIVITY',\n itemId: activity.id,\n itemName: activity.name,\n price: activity.price,\n currency: activity.currency,\n })\n }\n className=\"w-full rounded-md border border-border-seam bg-bg-canvas p-2 text-left text-xs text-text-primary hover:bg-action-primary-bg hover:text-action-primary-text\"\n >\n <div className=\"font-medium\">{activity.name}</div>\n <div className=\"text-text-secondary\">\n {activity.currency} {activity.price.toFixed(2)}\n </div>\n </button>\n ))\n )}\n </div>\n </details>\n </div>\n </GlassCard>\n </div>\n\n {/* Center - Itinerary Items */}\n <div className=\"space-y-4 lg:col-span-2\">\n <GlassCard treatment=\"glass\" glow className=\"border-border-seam p-5\">\n <h2 className=\"mb-4 text-lg font-medium tracking-tight text-text-primary\">\n {t('ggnomad.tripPlan.itineraryHeader', 'Your itinerary')}\n </h2>\n\n {tripPlan.items.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t(\n 'ggnomad.tripPlan.noItemsYet',\n 'No items added yet. Start adding stays, tours, events and activities from the left.'\n )}\n </p>\n ) : (\n <div className=\"space-y-6\">\n {sortedDays.map((day: number) => (\n <div key={String(day)}>\n <h3 className=\"mb-2 text-sm font-medium text-text-secondary\">\n {day === 0\n ? t('ggnomad.tripPlan.unscheduled', 'Unscheduled')\n : t('ggnomad.tripPlan.day', 'Day {{day}}').replace(\n '{{day}}',\n String(day)\n )}\n </h3>\n <div className=\"space-y-2\">\n {(itemsByDay[day] || []).map((item: TripPlanItem) => (\n <div\n key={item.id}\n className=\"flex items-start justify-between rounded-md border border-border-seam bg-bg-canvas p-3\"\n >\n <div className=\"flex-1\">\n <p className=\"font-medium text-text-primary\">{item.itemName}</p>\n <p className=\"text-xs text-text-secondary\">\n {item.itemType.charAt(0) + item.itemType.slice(1).toLowerCase()}\n </p>\n <p className=\"mt-1 font-semibold text-status-success-text\">\n {item.currency} {item.price.toFixed(2)}\n </p>\n </div>\n <button\n onClick={() => setRemovingItemId(item.id)}\n className=\"ml-2 rounded-md p-1 text-text-secondary hover:bg-action-danger-bg hover:text-action-danger-text\"\n aria-label={t('ggnomad.tripPlan.removeItem', 'Remove item')}\n >\n <X className=\"size-4\" />\n </button>\n </div>\n ))}\n </div>\n </div>\n ))}\n </div>\n )}\n </GlassCard>\n </div>\n\n {/* Right - Trip Summary */}\n <div className=\"space-y-4\">\n <GlassCard treatment=\"glass\" glow className=\"sticky top-6 border-border-seam p-5\">\n <h3 className=\"mb-4 font-medium text-text-primary\">\n {t('ggnomad.tripPlan.tripTotal', 'Trip total')}\n </h3>\n\n <div className=\"space-y-3 border-b border-border-seam pb-4\">\n <div className=\"flex items-center justify-between text-sm\">\n <span className=\"text-text-secondary\">\n {t('ggnomad.tripPlan.items', 'Items')}\n </span>\n <span className=\"font-medium text-text-primary\">{tripPlan.itemCount}</span>\n </div>\n <div className=\"flex items-center justify-between text-sm\">\n <span className=\"text-text-secondary\">\n {t('ggnomad.tripPlan.travelers', 'Travelers')}\n </span>\n <span className=\"font-medium text-text-primary flex items-center gap-1\">\n <Users className=\"size-3\" />\n {tripPlan.travelers}\n </span>\n </div>\n </div>\n\n <div className=\"my-4\">\n <div className=\"text-2xl font-bold text-text-primary\">\n USD {tripPlan.total.toFixed(2)}\n </div>\n {tripPlan.travelers > 0 && (\n <div className=\"mt-3 rounded-md border border-border-seam bg-bg-canvas/50 p-3\">\n <p className=\"text-xs font-medium text-text-secondary\">\n {t('ggnomad.tripPlan.costSplit', 'Split {{count}} ways').replace(\n '{{count}}',\n String(tripPlan.travelers)\n )}\n </p>\n <p className=\"mt-1 text-lg font-semibold text-action-primary-text\">\n USD {(tripPlan.total / tripPlan.travelers).toFixed(2)} each\n </p>\n <p className=\"mt-2 text-xs text-text-secondary\">\n {t(\n 'ggnomad.tripPlan.costSplitNote',\n 'This trip plan is shared with everyone in your workspace.'\n )}\n </p>\n </div>\n )}\n </div>\n\n <div className=\"space-y-2\">\n <button\n onClick={() => setShowCheckout(true)}\n disabled={tripPlan.items.length === 0}\n className=\"w-full rounded-md bg-action-primary-bg px-4 py-2 font-medium text-action-primary-text hover:bg-action-primary-bgHover disabled:opacity-50\"\n >\n {t('ggnomad.tripPlan.checkout', 'Checkout')}\n </button>\n\n <div className=\"flex items-center gap-2\">\n <select\n value={tripPlan.status}\n onChange={async (e) => {\n await updateStatus({\n variables: {\n id: tripPlan.id,\n input: { status: e.target.value },\n },\n });\n await refetch();\n }}\n className=\"flex-1 rounded-md border border-border-seam bg-bg-canvas px-2 py-1 text-sm text-text-primary\"\n >\n <option value=\"DRAFT\">Draft</option>\n <option value=\"PLANNED\">Planned</option>\n <option value=\"BOOKED\">Booked</option>\n <option value=\"CONFIRMED\">Confirmed</option>\n <option value=\"COMPLETED\">Completed</option>\n <option value=\"CANCELLED\">Cancelled</option>\n </select>\n </div>\n </div>\n </GlassCard>\n </div>\n </div>\n </TabsContent>\n\n <TabsContent value=\"timeline\" className=\"space-y-4\">\n <GlassCard treatment=\"glass\" glow className=\"border-border-seam p-5\">\n <h2 className=\"mb-4 text-lg font-medium tracking-tight text-text-primary\">\n {t('ggnomad.tripPlan.timeline', 'Trip timeline')}\n </h2>\n\n <div className=\"space-y-6\">\n {/* Plan Status Milestone */}\n <div className=\"flex gap-4\">\n <div className=\"flex flex-col items-center\">\n <div className=\"size-3 rounded-full bg-status-info-bg\" />\n <div className=\"my-2 h-8 w-0.5 bg-border-seam\" />\n </div>\n <div>\n <h3 className=\"font-medium text-text-primary\">\n {t('ggnomad.tripPlan.milestone.started', 'Trip started')}\n </h3>\n <p className=\"text-xs text-text-secondary\">\n {t('ggnomad.tripPlan.milestone.startedDesc', 'Created your itinerary')}\n </p>\n </div>\n </div>\n\n {/* Items Timeline */}\n {tripPlan.items.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('ggnomad.tripPlan.noItemsInTimeline', 'No items in your timeline yet')}\n </p>\n ) : (\n tripPlan.items.map((item, index) => (\n <div key={item.id} className=\"flex gap-4\">\n <div className=\"flex flex-col items-center\">\n <div\n className={`size-3 rounded-full ${\n tripPlan.status === 'BOOKED' || tripPlan.status === 'COMPLETED'\n ? 'bg-status-success-bg'\n : 'bg-status-warning-bg'\n }`}\n />\n {index < tripPlan.items.length - 1 && (\n <div className=\"my-2 h-8 w-0.5 bg-border-seam\" />\n )}\n </div>\n <div>\n <h3 className=\"font-medium text-text-primary\">{item.itemName}</h3>\n <p className=\"text-xs text-text-secondary\">\n {item.itemType.charAt(0) + item.itemType.slice(1).toLowerCase()}\n {item.day && ` · Day ${item.day}`}\n </p>\n <p className=\"mt-1 text-sm font-semibold text-status-success-text\">\n {item.currency} {item.price.toFixed(2)}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {tripPlan.status === 'BOOKED' || tripPlan.status === 'COMPLETED'\n ? t('ggnomad.tripPlan.milestone.booked', 'Booked')\n : t('ggnomad.tripPlan.milestone.planned', 'Planned')}\n </p>\n </div>\n </div>\n ))\n )}\n\n {/* Final Status */}\n {tripPlan.items.length > 0 && (\n <>\n <div className=\"flex gap-4\">\n <div className=\"flex flex-col items-center\">\n <div\n className={`size-3 rounded-full ${\n tripPlan.status === 'COMPLETED'\n ? 'bg-status-success-bg'\n : 'bg-status-secondary-bg'\n }`}\n />\n </div>\n <div>\n <h3 className=\"font-medium text-text-primary\">\n {tripPlan.status === 'COMPLETED'\n ? t('ggnomad.tripPlan.milestone.completed', 'Trip completed')\n : t('ggnomad.tripPlan.milestone.confirming', 'Awaiting completion')}\n </h3>\n <p className=\"text-xs text-text-secondary\">\n {tripPlan.status === 'COMPLETED'\n ? t('ggnomad.tripPlan.milestone.completedDesc', 'Your trip is complete')\n : t(\n 'ggnomad.tripPlan.milestone.confirmingDesc',\n 'Update status as your trip progresses'\n )}\n </p>\n </div>\n </div>\n </>\n )}\n </div>\n </GlassCard>\n </TabsContent>\n\n <TabsContent value=\"group\" className=\"space-y-4\">\n <GroupTripPanel\n tripPlanId={tripPlan.id}\n tripPlanName={tripPlan.name}\n items={tripPlan.items.map((item) => ({\n id: item.id,\n itemName: item.itemName,\n price: item.price,\n currency: item.currency,\n }))}\n />\n </TabsContent>\n </Tabs>\n\n {/* Add Item Dialog */}\n <AlertDialog open={addingItem !== null} onOpenChange={(open) => !open && setAddingItem(null)}>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>\n {t('ggnomad.tripPlan.addItemDialog.title', 'Add to itinerary?')}\n </AlertDialogTitle>\n <AlertDialogDescription>\n {addingItem && (\n <>\n {addingItem.itemName}\n {' · '}\n {addingItem.currency} {addingItem.price.toFixed(2)}\n </>\n )}\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel disabled={addingItemMutation}>\n {t('ggnomad.tripPlan.addItemDialog.cancel', 'Cancel')}\n </AlertDialogCancel>\n <AlertDialogAction\n disabled={addingItemMutation}\n onClick={(event) => {\n event.preventDefault();\n void handleAddItem();\n }}\n >\n {addingItemMutation\n ? t('ggnomad.tripPlan.addItemDialog.adding', 'Adding…')\n : t('ggnomad.tripPlan.addItemDialog.add', 'Add item')}\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n\n {/* Remove Item Dialog */}\n <AlertDialog\n open={removingItemId !== null}\n onOpenChange={(open) => !open && setRemovingItemId(null)}\n >\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>\n {t('ggnomad.tripPlan.removeItemDialog.title', 'Remove item from trip?')}\n </AlertDialogTitle>\n <AlertDialogDescription>\n {t(\n 'ggnomad.tripPlan.removeItemDialog.description',\n 'This item will be removed from your itinerary.'\n )}\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel disabled={removingItemMutation}>\n {t('ggnomad.tripPlan.removeItemDialog.cancel', 'Keep item')}\n </AlertDialogCancel>\n <AlertDialogAction\n className=\"bg-action-danger-bg text-action-danger-text hover:bg-action-danger-bgHover\"\n disabled={removingItemMutation}\n onClick={(event) => {\n event.preventDefault();\n void handleRemoveItem();\n }}\n >\n {removingItemMutation\n ? t('ggnomad.tripPlan.removeItemDialog.removing', 'Removing…')\n : t('ggnomad.tripPlan.removeItemDialog.remove', 'Remove item')}\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n\n {/* Checkout Dialog */}\n <AlertDialog open={showCheckout} onOpenChange={setShowCheckout}>\n <AlertDialogContent className=\"max-w-2xl\">\n <AlertDialogHeader>\n <AlertDialogTitle>\n {t('ggnomad.tripPlan.checkoutDialog.title', 'Review and book')}\n </AlertDialogTitle>\n <AlertDialogDescription>\n {t(\n 'ggnomad.tripPlan.checkoutDialog.description',\n 'Review your items and confirm to book everything at once.'\n )}\n </AlertDialogDescription>\n </AlertDialogHeader>\n\n <div className=\"space-y-4 max-h-96 overflow-y-auto\">\n {tripPlan.items.map((item) => (\n <div\n key={item.id}\n className=\"flex items-center justify-between rounded-md border border-border-seam bg-bg-canvas p-3\"\n >\n <div>\n <p className=\"font-medium text-text-primary\">{item.itemName}</p>\n <p className=\"text-xs text-text-secondary\">\n {item.itemType.charAt(0) + item.itemType.slice(1).toLowerCase()}\n </p>\n </div>\n <p className=\"font-semibold text-text-primary\">\n {item.currency} {item.price.toFixed(2)}\n </p>\n </div>\n ))}\n\n <div className=\"space-y-2 border-t border-border-seam pt-4\">\n <div className=\"flex justify-between text-sm\">\n <span className=\"text-text-secondary\">Subtotal</span>\n <span className=\"text-text-primary\">USD {tripPlan.total.toFixed(2)}</span>\n </div>\n <div className=\"flex justify-between text-sm\">\n <span className=\"text-text-secondary\">Taxes (10%)</span>\n <span className=\"text-text-primary\">USD {(tripPlan.total * 0.1).toFixed(2)}</span>\n </div>\n <div className=\"flex justify-between border-t border-border-seam pt-2 text-lg font-bold\">\n <span className=\"text-text-primary\">Total</span>\n <span className=\"text-status-success-text\">\n USD {(tripPlan.total * 1.1).toFixed(2)}\n </span>\n </div>\n </div>\n </div>\n\n <AlertDialogFooter>\n <AlertDialogCancel disabled={false}>\n {t('ggnomad.tripPlan.checkoutDialog.cancel', 'Cancel')}\n </AlertDialogCancel>\n <AlertDialogAction\n onClick={(event) => {\n event.preventDefault();\n void handleCheckout();\n }}\n >\n {t('ggnomad.tripPlan.checkoutDialog.confirm', 'Confirm & book all')}\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </PageShell>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA+DA,SAAgB,IAAqB;CACnC,IAAM,EAAE,SAAM,GAAQ,GAChB,IAAW,EAAY,GACvB,EAAE,cAAW,QAAQ,EAAW,GAChC,EAAE,QAAK,OAAO,EAAU,GACxB,CAAC,GAAY,KAAiB,EAA4B,IAAI,GAC9D,CAAC,GAAc,KAAmB,EAAS,EAAK,GAChD,CAAC,GAAgB,KAAqB,EAAwB,IAAI,GAClE,CAAC,GAAW,KAAgB,EAAS,WAAW,GAEhD,EAAE,SAAM,eAAY,EACxB,GAmBA;EAAE,WAAW,EAAE,MAAG;EAAG,MAAM,CAAC;CAAG,CACjC,GAEM,IAAW,GAAM,iBAEjB,EAAE,MAAM,OAAmB,EAC/B,IAWA,EA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EAAK,MAAM,QAAQ,CAAC;SACpC;UACA;UAZE,EAAK,EAYP,CACN,GAED,kBAAC,OAAD;QAAK,WAAU;kBAAf;SACE,kBAAC,OAAD;UAAK,WAAU;oBAAf,CACE,kBAAC,QAAD;WAAM,WAAU;qBAAsB;UAAc,CAAA,GACpD,kBAAC,QAAD;WAAM,WAAU;qBAAhB,CAAoC,QAAK,EAAS,MAAM,QAAQ,CAAC,CAAQ;YACtE;;SACL,kBAAC,OAAD;UAAK,WAAU;oBAAf,CACE,kBAAC,QAAD;WAAM,WAAU;qBAAsB;UAAiB,CAAA,GACvD,kBAAC,QAAD;WAAM,WAAU;qBAAhB,CAAoC,SAAM,EAAS,QAAQ,GAAA,CAAK,QAAQ,CAAC,CAAQ;YAC9E;;SACL,kBAAC,OAAD;UAAK,WAAU;oBAAf,CACE,kBAAC,QAAD;WAAM,WAAU;qBAAoB;UAAW,CAAA,GAC/C,kBAAC,QAAD;WAAM,WAAU;qBAAhB,CAA2C,SACnC,EAAS,QAAQ,IAAA,CAAK,QAAQ,CAAC,CACjC;YACH;;QACF;SACF;;MAEL,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;OAAmB,UAAU;iBAC1B,EAAE,0CAA0C,QAAQ;MACpC,CAAA,GACnB,kBAAC,GAAD;OACE,UAAU,MAAU;QAElB,AADA,EAAM,eAAe,GACrB,GAAoB;OACtB;iBAEC,EAAE,2CAA2C,oBAAoB;MACjD,CAAA,CACF,EAAA,CAAA;KACD;;GACT,CAAA;EACJ;;AAEf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TripsPage.js","names":[],"sources":["../../../src/ggnomad/pages/TripsPage.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport type { TypedDocumentNode } from '@apollo/client';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Calendar, Map, Plus } from 'lucide-react';\nimport { useNavigate } from 'react-router';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n CTAOverflowMenu,\n GlassCard,\n IllustratedEmptyState,\n NextSteps,\n PagePurpose,\n} from '@burdenoff/fe-libs/ui';\n\nimport { CREATE_GGNOMAD_TRIP_PLAN_MUTATION, GGNOMAD_TRIP_PLANS_QUERY } from '../graphql';\nimport { PageShell } from './PageShell';\nimport { EntityCard, StatusBadge } from '../components';\nimport { notify } from '../utils/notify';\n\ninterface NewTripFormState {\n name: string;\n startDate: string;\n endDate: string;\n}\n\nconst defaultFormState: NewTripFormState = {\n name: '',\n startDate: '',\n endDate: '',\n};\n\nexport function TripsPage() {\n const { t } = useI18n();\n const navigate = useNavigate();\n const [showNewTripDialog, setShowNewTripDialog] = useState(false);\n const [formState, setFormState] = useState<NewTripFormState>(defaultFormState);\n\n const { data, refetch } = useQuery(\n GGNOMAD_TRIP_PLANS_QUERY as TypedDocumentNode<\n {\n ggnomadTripPlans: Array<{\n id: string;\n name: string;\n description?: string;\n startDate?: string;\n endDate?: string;\n travelers: number;\n status: string;\n total: number;\n itemCount: number;\n createdAt: string;\n }>;\n },\n { limit: number; offset: number }\n >,\n { variables: { limit: 50, offset: 0 } }\n );\n\n const [createTripPlan, { loading: creating }] = useMutation(\n CREATE_GGNOMAD_TRIP_PLAN_MUTATION as TypedDocumentNode<\n {\n createGgnomadTripPlan: {\n id: string;\n name: string;\n startDate?: string;\n endDate?: string;\n };\n },\n {\n input: {\n name: string;\n description?: string;\n startDate?: string;\n endDate?: string;\n travelers?: number;\n };\n }\n >\n );\n\n const trips = data?.ggnomadTripPlans ?? [];\n\n const handleCreateTrip = async () => {\n if (!formState.name.trim()) {\n notify.warning(\n t('ggnomad.trips.toast.validationTitle', 'Required field missing'),\n t('ggnomad.trips.toast.nameRequired', 'Please enter a trip name')\n );\n return;\n }\n\n try {\n const result = await createTripPlan({\n variables: {\n input: {\n name: formState.name.trim(),\n startDate: formState.startDate\n ? new Date(formState.startDate).toISOString()\n : undefined,\n endDate: formState.endDate ? new Date(formState.endDate).toISOString() : undefined,\n travelers: 1,\n },\n },\n });\n\n if (result.error) {\n notify.error(\n t('ggnomad.trips.toast.createErrorTitle', 'Could not create trip'),\n result.error.message\n );\n return;\n }\n\n const created = result.data?.createGgnomadTripPlan;\n if (!created) return;\n\n notify.success(t('ggnomad.trips.toast.createSuccessTitle', 'Trip created'), created.name);\n\n setShowNewTripDialog(false);\n setFormState(defaultFormState);\n await refetch();\n navigate(`trips/${created.id}`);\n } catch (err) {\n notify.error(\n t('ggnomad.trips.toast.createErrorTitle', 'Could not create trip'),\n err instanceof Error ? err.message : String(err)\n );\n }\n };\n\n const formatDate = (dateStr?: string) => {\n if (!dateStr) return '';\n const date = new Date(dateStr);\n return date.toLocaleDateString('en-US', {\n month: 'short',\n day: 'numeric',\n year: 'numeric',\n });\n };\n\n return (\n <PageShell\n title={t('ggnomad.trips.title', 'Trips')}\n titleAccent={t('ggnomad.trips.title.accent', 'Trips')}\n subtitle={t(\n 'ggnomad.trips.subtitle',\n 'Plan complete itineraries with real trip planning API mutations'\n )}\n actions={\n <CTAOverflowMenu\n primary={{\n label: t('ggnomad.trips.actions.newTrip', 'New trip'),\n onSelect: () => setShowNewTripDialog(true),\n disabled: creating,\n icon: <Plus />,\n }}\n actions={[]}\n />\n }\n >\n <PagePurpose icon={<Map className=\"size-4\" />}>\n {t(\n 'ggnomad.trips.purpose',\n 'Organize every aspect of your journey — build itineraries day by day, add activities and accommodations, manage your trip status, and book everything at once. All your trips in one place.'\n )}\n </PagePurpose>\n\n <NextSteps\n storageKey=\"ggnomad-trips\"\n steps={[\n {\n id: 'add-stays',\n label: t('ggnomad.trips.next.stays', 'Add places to stay'),\n description: t(\n 'ggnomad.trips.next.staysDesc',\n 'Browse accommodations and add them to your itinerary.'\n ),\n icon: <Calendar className=\"size-4\" />,\n onClick: () => navigate('../hospitality'),\n },\n {\n id: 'build-activities',\n label: t('ggnomad.trips.next.activities', 'Plan activities'),\n description: t(\n 'ggnomad.trips.next.activitiesDesc',\n 'Mix in tours, events, and activities by day.'\n ),\n icon: <Map className=\"size-4\" />,\n onClick: () => navigate('../tourism'),\n },\n ]}\n />\n\n {trips.length === 0 ? (\n <IllustratedEmptyState\n illustration=\"empty-data\"\n title={t('ggnomad.trips.emptyTitle', 'No trips yet')}\n description={t(\n 'ggnomad.trips.emptyDescription',\n 'Create your first trip to start building an itinerary.'\n )}\n />\n ) : (\n <GlassCard treatment=\"glass\" glow className=\"border-border-seam p-5\">\n <h2 className=\"mb-4 text-lg font-medium tracking-tight text-text-primary\">\n {t('ggnomad.trips.yourTrips', 'Your trips')}\n </h2>\n <div className=\"grid gap-3 sm:grid-cols-2 lg:grid-cols-3\">\n {trips.map((trip) => (\n <EntityCard\n key={trip.id}\n to={`trips/${trip.id}`}\n title={trip.name}\n meta={`${trip.travelers} ${\n trip.travelers === 1\n ? t('ggnomad.trips.card.traveler', 'traveler')\n : t('ggnomad.trips.card.travelers', 'travelers')\n } · ${trip.itemCount} ${t('ggnomad.trips.card.items', 'items')}`}\n price={trip.total > 0 ? `USD ${trip.total.toFixed(2)}` : ''}\n badge={<StatusBadge status={trip.status} live={trip.status !== 'CANCELLED'} />}\n footer={\n trip.startDate && trip.endDate\n ? `${formatDate(trip.startDate)} – ${formatDate(trip.endDate)}`\n : t('ggnomad.trips.card.noDates', 'No dates set')\n }\n />\n ))}\n </div>\n </GlassCard>\n )}\n\n <AlertDialog open={showNewTripDialog} onOpenChange={setShowNewTripDialog}>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>\n {t('ggnomad.trips.newDialog.title', 'Create a new trip')}\n </AlertDialogTitle>\n <AlertDialogDescription>\n {t(\n 'ggnomad.trips.newDialog.description',\n 'Name your trip and set the dates to get started building your itinerary.'\n )}\n </AlertDialogDescription>\n </AlertDialogHeader>\n\n <div className=\"space-y-4\">\n <div>\n <label htmlFor=\"trip-name\" className=\"block text-sm font-medium text-text-primary\">\n {t('ggnomad.trips.newDialog.tripName', 'Trip name')}\n </label>\n <input\n id=\"trip-name\"\n type=\"text\"\n className=\"mt-1 w-full rounded-md border border-border-seam bg-bg-canvas px-3 py-2 text-sm text-text-primary placeholder-text-secondary focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary\"\n placeholder={t(\n 'ggnomad.trips.newDialog.tripNamePlaceholder',\n 'e.g. Summer Europe Adventure'\n )}\n value={formState.name}\n onChange={(e) => setFormState((prev) => ({ ...prev, name: e.target.value }))}\n />\n </div>\n\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <label\n htmlFor=\"trip-start-date\"\n className=\"block text-sm font-medium text-text-primary\"\n >\n {t('ggnomad.trips.newDialog.startDate', 'Start date')}\n </label>\n <input\n id=\"trip-start-date\"\n type=\"date\"\n className=\"mt-1 w-full rounded-md border border-border-seam bg-bg-canvas px-3 py-2 text-sm text-text-primary focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary\"\n value={formState.startDate}\n onChange={(e) => setFormState((prev) => ({ ...prev, startDate: e.target.value }))}\n />\n </div>\n <div>\n <label\n htmlFor=\"trip-end-date\"\n className=\"block text-sm font-medium text-text-primary\"\n >\n {t('ggnomad.trips.newDialog.endDate', 'End date')}\n </label>\n <input\n id=\"trip-end-date\"\n type=\"date\"\n className=\"mt-1 w-full rounded-md border border-border-seam bg-bg-canvas px-3 py-2 text-sm text-text-primary focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary\"\n value={formState.endDate}\n onChange={(e) => setFormState((prev) => ({ ...prev, endDate: e.target.value }))}\n />\n </div>\n </div>\n </div>\n\n <AlertDialogFooter>\n <AlertDialogCancel disabled={creating}>\n {t('ggnomad.trips.newDialog.cancel', 'Cancel')}\n </AlertDialogCancel>\n <AlertDialogAction\n disabled={creating || !formState.name.trim()}\n onClick={(event) => {\n event.preventDefault();\n void handleCreateTrip();\n }}\n >\n {creating\n ? t('ggnomad.trips.newDialog.creating', 'Creating…')\n : t('ggnomad.trips.newDialog.create', 'Create trip')}\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </PageShell>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAiCA,IAAM,IAAqC;CACzC,MAAM;CACN,WAAW;CACX,SAAS;AACX;AAEA,SAAgB,IAAY;CAC1B,IAAM,EAAE,SAAM,EAAQ,GAChB,IAAW,EAAY,GACvB,CAAC,GAAmB,KAAwB,EAAS,EAAK,GAC1D,CAAC,GAAW,KAAgB,EAA2B,CAAgB,GAEvE,EAAE,SAAM,eAAY,EACxB,GAiBA,EAAE,WAAW;EAAE,OAAO;EAAI,QAAQ;CAAE,EAAE,CACxC,GAEM,CAAC,GAAgB,EAAE,SAAS,OAAc,EAC9C,CAmBF,GAEM,IAAQ,GAAM,oBAAoB,CAAC,GAEnC,IAAmB,YAAY;EACnC,IAAI,CAAC,EAAU,KAAK,KAAK,GAAG;GAC1B,EAAO,QACL,EAAE,uCAAuC,wBAAwB,GACjE,EAAE,oCAAoC,0BAA0B,CAClE;GACA;EACF;EAEA,IAAI;GACF,IAAM,IAAS,MAAM,EAAe,EAClC,WAAW,EACT,OAAO;IACL,MAAM,EAAU,KAAK,KAAK;IAC1B,WAAW,EAAU,YACjB,IAAI,KAAK,EAAU,SAAS,EAAE,YAAY,IAC1C,KAAA;IACJ,SAAS,EAAU,UAAU,IAAI,KAAK,EAAU,OAAO,EAAE,YAAY,IAAI,KAAA;IACzE,WAAW;GACb,EACF,EACF,CAAC;GAED,IAAI,EAAO,OAAO;IAChB,EAAO,MACL,EAAE,wCAAwC,uBAAuB,GACjE,EAAO,MAAM,OACf;IACA;GACF;GAEA,IAAM,IAAU,EAAO,MAAM;GAC7B,IAAI,CAAC,GAAS;GAOd,AALA,EAAO,QAAQ,EAAE,0CAA0C,cAAc,GAAG,EAAQ,IAAI,GAExF,EAAqB,EAAK,GAC1B,EAAa,CAAgB,GAC7B,MAAM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,CAAA,GAEL,kBAAC,OAAD;OAAK,WAAU;iBAAf,CACE,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;QACE,SAAQ;QACR,WAAU;kBAET,EAAE,qCAAqC,YAAY;OAC/C,CAAA,GACP,kBAAC,SAAD;QACE,IAAG;QACH,MAAK;QACL,WAAU;QACV,OAAO,EAAU;QACjB,WAAW,MAAM,GAAc,OAAU;SAAE,GAAG;SAAM,WAAW,EAAE,OAAO;QAAM,EAAE;OACjF,CAAA,CACE,EAAA,CAAA,GACL,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;QACE,SAAQ;QACR,WAAU;kBAET,EAAE,mCAAmC,UAAU;OAC3C,CAAA,GACP,kBAAC,SAAD;QACE,IAAG;QACH,MAAK;QACL,WAAU;QACV,OAAO,EAAU;QACjB,WAAW,MAAM,GAAc,OAAU;SAAE,GAAG;SAAM,SAAS,EAAE,OAAO;QAAM,EAAE;OAC/E,CAAA,CACE,EAAA,CAAA,CACF;QACF;;KAEL,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;MAAmB,UAAU;gBAC1B,EAAE,kCAAkC,QAAQ;KAC5B,CAAA,GACnB,kBAAC,GAAD;MACE,UAAU,KAAY,CAAC,EAAU,KAAK,KAAK;MAC3C,UAAU,MAAU;OAElB,AADA,EAAM,eAAe,GACrB,EAAsB;MACxB;gBAEC,IACG,EAAE,oCAAoC,WAAW,IACjD,EAAE,kCAAkC,aAAa;KACpC,CAAA,CACF,EAAA,CAAA;IACD,EAAA,CAAA;GACT,CAAA;EACJ;;AAEf"}
|
|
1
|
+
{"version":3,"file":"TripsPage.js","names":[],"sources":["../../../src/ggnomad/pages/TripsPage.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport type { TypedDocumentNode } from '@apollo/client';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Calendar, Map, Plus } from 'lucide-react';\nimport { useNavigate } from 'react-router';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n CTAOverflowMenu,\n GlassCard,\n IllustratedEmptyState,\n NextSteps,\n PagePurpose,\n} from '@burdenoff/fe-libs/ui';\n\nimport { CREATE_GGNOMAD_TRIP_PLAN_MUTATION, GGNOMAD_TRIP_PLANS_QUERY } from '../graphql';\nimport { PageShell } from './PageShell';\nimport { EntityCard, StatusBadge } from '../components';\nimport { notify } from '../utils/notify';\n\ninterface NewTripFormState {\n name: string;\n startDate: string;\n endDate: string;\n}\n\nconst defaultFormState: NewTripFormState = {\n name: '',\n startDate: '',\n endDate: '',\n};\n\nexport function TripsPage() {\n const { t } = useI18n();\n const navigate = useNavigate();\n const [showNewTripDialog, setShowNewTripDialog] = useState(false);\n const [formState, setFormState] = useState<NewTripFormState>(defaultFormState);\n\n const { data, refetch } = useQuery(\n GGNOMAD_TRIP_PLANS_QUERY as TypedDocumentNode<\n {\n ggnomadTripPlans: Array<{\n id: string;\n name: string;\n description?: string;\n startDate?: string;\n endDate?: string;\n travelers: number;\n status: string;\n total: number;\n itemCount: number;\n createdAt: string;\n }>;\n },\n { limit: number; offset: number }\n >,\n { variables: { limit: 50, offset: 0 } }\n );\n\n const [createTripPlan, { loading: creating }] = useMutation(\n CREATE_GGNOMAD_TRIP_PLAN_MUTATION as TypedDocumentNode<\n {\n createGgnomadTripPlan: {\n id: string;\n name: string;\n startDate?: string;\n endDate?: string;\n };\n },\n {\n input: {\n name: string;\n description?: string;\n startDate?: string;\n endDate?: string;\n travelers?: number;\n };\n }\n >\n );\n\n const trips = data?.ggnomadTripPlans ?? [];\n\n const handleCreateTrip = async () => {\n if (!formState.name.trim()) {\n notify.warning(\n t('ggnomad.trips.toast.validationTitle', 'Required field missing'),\n t('ggnomad.trips.toast.nameRequired', 'Please enter a trip name')\n );\n return;\n }\n\n try {\n const result = await createTripPlan({\n variables: {\n input: {\n name: formState.name.trim(),\n startDate: formState.startDate\n ? new Date(formState.startDate).toISOString()\n : undefined,\n endDate: formState.endDate ? new Date(formState.endDate).toISOString() : undefined,\n travelers: 1,\n },\n },\n });\n\n if (result.error) {\n notify.error(\n t('ggnomad.trips.toast.createErrorTitle', 'Could not create trip'),\n result.error.message\n );\n return;\n }\n\n const created = result.data?.createGgnomadTripPlan;\n if (!created) return;\n\n notify.success(t('ggnomad.trips.toast.createSuccessTitle', 'Trip created'), created.name);\n\n setShowNewTripDialog(false);\n setFormState(defaultFormState);\n await refetch();\n navigate(`trips/${created.id}`);\n } catch (err) {\n notify.error(\n t('ggnomad.trips.toast.createErrorTitle', 'Could not create trip'),\n err instanceof Error ? err.message : String(err)\n );\n }\n };\n\n const formatDate = (dateStr?: string) => {\n if (!dateStr) return '';\n const date = new Date(dateStr);\n return date.toLocaleDateString('en-US', {\n month: 'short',\n day: 'numeric',\n year: 'numeric',\n });\n };\n\n return (\n <PageShell\n title={t('ggnomad.trips.title', 'Trips')}\n titleAccent={t('ggnomad.trips.title.accent', 'Trips')}\n subtitle={t(\n 'ggnomad.trips.subtitle',\n 'Plan complete itineraries with real trip planning API mutations'\n )}\n actions={\n <CTAOverflowMenu\n primary={{\n label: t('ggnomad.trips.actions.newTrip', 'New trip'),\n onSelect: () => setShowNewTripDialog(true),\n disabled: creating,\n icon: <Plus />,\n }}\n actions={[]}\n />\n }\n >\n <PagePurpose icon={<Map className=\"size-4\" />}>\n {t(\n 'ggnomad.trips.purpose',\n 'Organize every aspect of your journey — build itineraries day by day, add activities and accommodations, manage your trip status, and book everything at once. All your trips in one place.'\n )}\n </PagePurpose>\n\n <NextSteps\n storageKey=\"ggnomad-trips\"\n steps={[\n {\n id: 'add-stays',\n label: t('ggnomad.trips.next.stays', 'Add places to stay'),\n description: t(\n 'ggnomad.trips.next.staysDesc',\n 'Browse accommodations and add them to your itinerary.'\n ),\n icon: <Calendar className=\"size-4\" />,\n onClick: () => navigate('../hospitality'),\n },\n {\n id: 'build-activities',\n label: t('ggnomad.trips.next.activities', 'Plan activities'),\n description: t(\n 'ggnomad.trips.next.activitiesDesc',\n 'Mix in tours, events, and activities by day.'\n ),\n icon: <Map className=\"size-4\" />,\n onClick: () => navigate('../tourism'),\n },\n ]}\n />\n\n {trips.length === 0 ? (\n <IllustratedEmptyState\n illustration=\"empty-data\"\n title={t('ggnomad.trips.emptyTitle', 'No trips yet')}\n description={t(\n 'ggnomad.trips.emptyDescription',\n 'Create your first trip to start building an itinerary.'\n )}\n />\n ) : (\n <GlassCard treatment=\"glass\" glow className=\"border-border-seam p-5\">\n <h2 className=\"mb-4 text-lg font-medium tracking-tight text-text-primary\">\n {t('ggnomad.trips.yourTrips', 'Your trips')}\n </h2>\n <div className=\"grid gap-3 sm:grid-cols-2 lg:grid-cols-3\">\n {trips.map((trip) => (\n <EntityCard\n key={trip.id}\n to={`trips/${trip.id}`}\n title={trip.name}\n meta={`${trip.travelers} ${\n trip.travelers === 1\n ? t('ggnomad.trips.card.traveler', 'traveler')\n : t('ggnomad.trips.card.travelers', 'travelers')\n } · ${trip.itemCount} ${t('ggnomad.trips.card.items', 'items')}`}\n price={trip.total > 0 ? `USD ${trip.total.toFixed(2)}` : ''}\n badge={<StatusBadge status={trip.status} live={trip.status !== 'CANCELLED'} />}\n footer={\n trip.startDate && trip.endDate\n ? `${formatDate(trip.startDate)} – ${formatDate(trip.endDate)}`\n : t('ggnomad.trips.card.noDates', 'No dates set')\n }\n />\n ))}\n </div>\n </GlassCard>\n )}\n\n <AlertDialog open={showNewTripDialog} onOpenChange={setShowNewTripDialog}>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>\n {t('ggnomad.trips.newDialog.title', 'Create a new trip')}\n </AlertDialogTitle>\n <AlertDialogDescription>\n {t(\n 'ggnomad.trips.newDialog.description',\n 'Name your trip and set the dates to get started building your itinerary.'\n )}\n </AlertDialogDescription>\n </AlertDialogHeader>\n\n <div className=\"space-y-4\">\n <div>\n <label htmlFor=\"trip-name\" className=\"block text-sm font-medium text-text-primary\">\n {t('ggnomad.trips.newDialog.tripName', 'Trip name')}\n </label>\n <input\n id=\"trip-name\"\n type=\"text\"\n className=\"mt-1 w-full rounded-md border border-border-seam bg-bg-canvas px-3 py-2 text-sm text-text-primary placeholder-text-secondary focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary\"\n placeholder={t(\n 'ggnomad.trips.newDialog.tripNamePlaceholder',\n 'e.g. Summer Europe Adventure'\n )}\n value={formState.name}\n onChange={(e) => setFormState((prev) => ({ ...prev, name: e.target.value }))}\n />\n </div>\n\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <label\n htmlFor=\"trip-start-date\"\n className=\"block text-sm font-medium text-text-primary\"\n >\n {t('ggnomad.trips.newDialog.startDate', 'Start date')}\n </label>\n <input\n id=\"trip-start-date\"\n type=\"date\"\n className=\"mt-1 w-full rounded-md border border-border-seam bg-bg-canvas px-3 py-2 text-sm text-text-primary focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary\"\n value={formState.startDate}\n onChange={(e) => setFormState((prev) => ({ ...prev, startDate: e.target.value }))}\n />\n </div>\n <div>\n <label\n htmlFor=\"trip-end-date\"\n className=\"block text-sm font-medium text-text-primary\"\n >\n {t('ggnomad.trips.newDialog.endDate', 'End date')}\n </label>\n <input\n id=\"trip-end-date\"\n type=\"date\"\n className=\"mt-1 w-full rounded-md border border-border-seam bg-bg-canvas px-3 py-2 text-sm text-text-primary focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary\"\n value={formState.endDate}\n onChange={(e) => setFormState((prev) => ({ ...prev, endDate: e.target.value }))}\n />\n </div>\n </div>\n </div>\n\n <AlertDialogFooter>\n <AlertDialogCancel disabled={creating}>\n {t('ggnomad.trips.newDialog.cancel', 'Cancel')}\n </AlertDialogCancel>\n <AlertDialogAction\n disabled={creating || !formState.name.trim()}\n onClick={(event) => {\n event.preventDefault();\n void handleCreateTrip();\n }}\n >\n {creating\n ? t('ggnomad.trips.newDialog.creating', 'Creating…')\n : t('ggnomad.trips.newDialog.create', 'Create trip')}\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </PageShell>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAiCA,IAAM,IAAqC;CACzC,MAAM;CACN,WAAW;CACX,SAAS;AACX;AAEA,SAAgB,IAAY;CAC1B,IAAM,EAAE,SAAM,EAAQ,GAChB,IAAW,EAAY,GACvB,CAAC,GAAmB,KAAwB,EAAS,EAAK,GAC1D,CAAC,GAAW,KAAgB,EAA2B,CAAgB,GAEvE,EAAE,SAAM,eAAY,EACxB,GAiBA,EAAE,WAAW;EAAE,OAAO;EAAI,QAAQ;CAAE,EAAE,CACxC,GAEM,CAAC,GAAgB,EAAE,SAAS,OAAc,EAC9C,CAmBF,GAEM,IAAQ,GAAM,oBAAoB,CAAC,GAEnC,IAAmB,YAAY;EACnC,IAAI,CAAC,EAAU,KAAK,KAAK,GAAG;GAC1B,EAAO,QACL,EAAE,uCAAuC,wBAAwB,GACjE,EAAE,oCAAoC,0BAA0B,CAClE;GACA;EACF;EAEA,IAAI;GACF,IAAM,IAAS,MAAM,EAAe,EAClC,WAAW,EACT,OAAO;IACL,MAAM,EAAU,KAAK,KAAK;IAC1B,WAAW,EAAU,YACjB,IAAI,KAAK,EAAU,SAAS,CAAC,CAAC,YAAY,IAC1C,KAAA;IACJ,SAAS,EAAU,UAAU,IAAI,KAAK,EAAU,OAAO,CAAC,CAAC,YAAY,IAAI,KAAA;IACzE,WAAW;GACb,EACF,EACF,CAAC;GAED,IAAI,EAAO,OAAO;IAChB,EAAO,MACL,EAAE,wCAAwC,uBAAuB,GACjE,EAAO,MAAM,OACf;IACA;GACF;GAEA,IAAM,IAAU,EAAO,MAAM;GAC7B,IAAI,CAAC,GAAS;GAOd,AALA,EAAO,QAAQ,EAAE,0CAA0C,cAAc,GAAG,EAAQ,IAAI,GAExF,EAAqB,EAAK,GAC1B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AM,EAAE;MAC5E,CAAA,CACE,EAAA,CAAA,GAEL,kBAAC,OAAD;OAAK,WAAU;iBAAf,CACE,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;QACE,SAAQ;QACR,WAAU;kBAET,EAAE,qCAAqC,YAAY;OAC/C,CAAA,GACP,kBAAC,SAAD;QACE,IAAG;QACH,MAAK;QACL,WAAU;QACV,OAAO,EAAU;QACjB,WAAW,MAAM,GAAc,OAAU;SAAE,GAAG;SAAM,WAAW,EAAE,OAAO;QAAM,EAAE;OACjF,CAAA,CACE,EAAA,CAAA,GACL,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;QACE,SAAQ;QACR,WAAU;kBAET,EAAE,mCAAmC,UAAU;OAC3C,CAAA,GACP,kBAAC,SAAD;QACE,IAAG;QACH,MAAK;QACL,WAAU;QACV,OAAO,EAAU;QACjB,WAAW,MAAM,GAAc,OAAU;SAAE,GAAG;SAAM,SAAS,EAAE,OAAO;QAAM,EAAE;OAC/E,CAAA,CACE,EAAA,CAAA,CACF;QACF;;KAEL,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;MAAmB,UAAU;gBAC1B,EAAE,kCAAkC,QAAQ;KAC5B,CAAA,GACnB,kBAAC,GAAD;MACE,UAAU,KAAY,CAAC,EAAU,KAAK,KAAK;MAC3C,UAAU,MAAU;OAElB,AADA,EAAM,eAAe,GACrB,EAAsB;MACxB;gBAEC,IACG,EAAE,oCAAoC,WAAW,IACjD,EAAE,kCAAkC,aAAa;KACpC,CAAA,CACF,EAAA,CAAA;IACD,EAAA,CAAA;GACT,CAAA;EACJ;;AAEf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GGNomadProvider.js","names":[],"sources":["../../../src/ggnomad/providers/GGNomadProvider.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport { MemoryRouter } from 'react-router';\nimport { ApolloProvider } from '@apollo/client/react';\nimport { ApolloClient, ApolloLink, HttpLink, InMemoryCache, from } from '@apollo/client/core';\nimport { onError } from '@apollo/client/link/error';\nimport { setContext } from '@apollo/client/link/context';\n\nimport type { GGNomadRootProps } from '../types';\n\ntype GGNomadContextValue = GGNomadRootProps;\n\nconst GGNomadContext = createContext<GGNomadContextValue | null>(null);\n\nexport const useGGNomad = (): GGNomadRootProps => {\n const context = useContext(GGNomadContext);\n if (!context) {\n throw new Error('useGGNomad must be used within GGNomadProvider');\n }\n return context;\n};\n\nexport const GGNomadProvider: FC<PropsWithChildren<GGNomadRootProps>> = ({\n children,\n ...props\n}) => {\n const { apiGatewayUrl, authToken, workspaceToken, onAuthError, basePath } = props;\n\n const client = useMemo(() => {\n const endpoint = `${(apiGatewayUrl ?? '').replace(/\\/$/, '')}/workspaces/graphql`;\n\n const errorLink = onError(({ error }) => {\n const graphQLErrors =\n 'errors' in (error ?? {})\n ? (error as { errors?: Array<{ extensions?: { code?: string } }> }).errors\n : undefined;\n const networkError =\n 'cause' in (error ?? {}) ? (error as { cause?: { statusCode?: number } }).cause : undefined;\n\n const authGraphError = graphQLErrors?.some((graphQLError) =>\n ['UNAUTHENTICATED', 'FORBIDDEN'].includes(String(graphQLError.extensions?.code ?? ''))\n );\n const authNetworkError =\n typeof networkError === 'object' && networkError !== null && 'statusCode' in networkError\n ? [401, 403].includes(Number((networkError as { statusCode?: number }).statusCode))\n : false;\n\n if (authGraphError || authNetworkError) {\n onAuthError?.();\n }\n });\n\n const authLink = setContext((_, prevContext) => ({\n headers: {\n ...(prevContext.headers as Record<string, string> | undefined),\n ...(authToken ? { Authorization: `Bearer ${authToken}` } : {}),\n ...(workspaceToken ? { 'X-Workspace-Authorization': `Bearer ${workspaceToken}` } : {}),\n },\n }));\n\n const httpLink = new HttpLink({\n uri: endpoint,\n credentials: 'include',\n });\n\n return new ApolloClient({\n cache: new InMemoryCache(),\n link: from([errorLink as ApolloLink, authLink, httpLink]),\n defaultOptions: {\n watchQuery: { fetchPolicy: 'cache-and-network', errorPolicy: 'all' },\n query: { fetchPolicy: 'network-only', errorPolicy: 'all' },\n mutate: { errorPolicy: 'all' },\n },\n });\n }, [apiGatewayUrl, authToken, workspaceToken, onAuthError]);\n\n const isIntegrated = !!basePath;\n const contextProvider = (\n <GGNomadContext.Provider value={props}>{children}</GGNomadContext.Provider>\n );\n\n const content = isIntegrated ? (\n contextProvider\n ) : (\n <ApolloProvider client={client}>{contextProvider}</ApolloProvider>\n );\n\n if (isIntegrated) {\n return content;\n }\n\n return <MemoryRouter>{content}</MemoryRouter>;\n};\n"],"mappings":";;;;;;;;AAYA,IAAM,IAAiB,EAA0C,IAAI,GAExD,UAAqC;CAChD,IAAM,IAAU,EAAW,CAAc;CACzC,IAAI,CAAC,GACH,MAAU,MAAM,gDAAgD;CAElE,OAAO;AACT,GAEa,KAA4D,EACvE,aACA,GAAG,QACC;CACJ,IAAM,EAAE,kBAAe,cAAW,mBAAgB,gBAAa,gBAAa,GAEtE,IAAS,QAAc;EAC3B,IAAM,IAAW,IAAI,KAAiB,
|
|
1
|
+
{"version":3,"file":"GGNomadProvider.js","names":[],"sources":["../../../src/ggnomad/providers/GGNomadProvider.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport { MemoryRouter } from 'react-router';\nimport { ApolloProvider } from '@apollo/client/react';\nimport { ApolloClient, ApolloLink, HttpLink, InMemoryCache, from } from '@apollo/client/core';\nimport { onError } from '@apollo/client/link/error';\nimport { setContext } from '@apollo/client/link/context';\n\nimport type { GGNomadRootProps } from '../types';\n\ntype GGNomadContextValue = GGNomadRootProps;\n\nconst GGNomadContext = createContext<GGNomadContextValue | null>(null);\n\nexport const useGGNomad = (): GGNomadRootProps => {\n const context = useContext(GGNomadContext);\n if (!context) {\n throw new Error('useGGNomad must be used within GGNomadProvider');\n }\n return context;\n};\n\nexport const GGNomadProvider: FC<PropsWithChildren<GGNomadRootProps>> = ({\n children,\n ...props\n}) => {\n const { apiGatewayUrl, authToken, workspaceToken, onAuthError, basePath } = props;\n\n const client = useMemo(() => {\n const endpoint = `${(apiGatewayUrl ?? '').replace(/\\/$/, '')}/workspaces/graphql`;\n\n const errorLink = onError(({ error }) => {\n const graphQLErrors =\n 'errors' in (error ?? {})\n ? (error as { errors?: Array<{ extensions?: { code?: string } }> }).errors\n : undefined;\n const networkError =\n 'cause' in (error ?? {}) ? (error as { cause?: { statusCode?: number } }).cause : undefined;\n\n const authGraphError = graphQLErrors?.some((graphQLError) =>\n ['UNAUTHENTICATED', 'FORBIDDEN'].includes(String(graphQLError.extensions?.code ?? ''))\n );\n const authNetworkError =\n typeof networkError === 'object' && networkError !== null && 'statusCode' in networkError\n ? [401, 403].includes(Number((networkError as { statusCode?: number }).statusCode))\n : false;\n\n if (authGraphError || authNetworkError) {\n onAuthError?.();\n }\n });\n\n const authLink = setContext((_, prevContext) => ({\n headers: {\n ...(prevContext.headers as Record<string, string> | undefined),\n ...(authToken ? { Authorization: `Bearer ${authToken}` } : {}),\n ...(workspaceToken ? { 'X-Workspace-Authorization': `Bearer ${workspaceToken}` } : {}),\n },\n }));\n\n const httpLink = new HttpLink({\n uri: endpoint,\n credentials: 'include',\n });\n\n return new ApolloClient({\n cache: new InMemoryCache(),\n link: from([errorLink as ApolloLink, authLink, httpLink]),\n defaultOptions: {\n watchQuery: { fetchPolicy: 'cache-and-network', errorPolicy: 'all' },\n query: { fetchPolicy: 'network-only', errorPolicy: 'all' },\n mutate: { errorPolicy: 'all' },\n },\n });\n }, [apiGatewayUrl, authToken, workspaceToken, onAuthError]);\n\n const isIntegrated = !!basePath;\n const contextProvider = (\n <GGNomadContext.Provider value={props}>{children}</GGNomadContext.Provider>\n );\n\n const content = isIntegrated ? (\n contextProvider\n ) : (\n <ApolloProvider client={client}>{contextProvider}</ApolloProvider>\n );\n\n if (isIntegrated) {\n return content;\n }\n\n return <MemoryRouter>{content}</MemoryRouter>;\n};\n"],"mappings":";;;;;;;;AAYA,I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;CACH,GAAG;EAAC;EAAe;EAAW;EAAgB;CAAW,CAAC,GAEpD,IAAe,CAAC,CAAC,GACjB,IACJ,kBAAC,EAAe,UAAhB;EAAyB,OAAO;EAAQ;CAAkC,CAAA,GAGtE,IAAU,IACd,IAEA,kBAAC,GAAD;EAAwB;YAAS;CAAgC,CAAA;CAOnE,OAJI,IACK,IAGF,kBAAC,GAAD,EAAA,UAAe,EAAsB,CAAA;AAC9C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Booking dates for flows that book without an explicit date picker.
|
|
3
|
+
*
|
|
4
|
+
* Since BOFF-10193 the service prices every booking itself: a stay
|
|
5
|
+
* (PROPERTY) is priced per night, so it must carry a check-in and a later
|
|
6
|
+
* check-out, and any other listing is priced for the date it is booked on.
|
|
7
|
+
* These helpers turn the dates a flow does have (a trip plan's schedule, or
|
|
8
|
+
* nothing at all for the demo booking) into dates the service can price.
|
|
9
|
+
*/
|
|
10
|
+
/** Midnight UTC `days` from now, as an ISO string. */
|
|
11
|
+
export declare function daysFromNowIso(days: number, now?: Date): string;
|
|
12
|
+
export interface StayDates {
|
|
13
|
+
checkIn: string;
|
|
14
|
+
checkOut: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A stay starting at `start` (or a week from today when there is none) and
|
|
18
|
+
* ending at `end` when that is later, otherwise one night after the start.
|
|
19
|
+
*/
|
|
20
|
+
export declare function stayDates(start: string | null | undefined, end: string | null | undefined, now?: Date): StayDates;
|
|
21
|
+
//# sourceMappingURL=bookingDates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bookingDates.d.ts","sourceRoot":"","sources":["../../../src/ggnomad/utils/bookingDates.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,sDAAsD;AACtD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,IAAiB,GAAG,MAAM,CAG3E;AAQD,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9B,GAAG,GAAE,IAAiB,GACrB,SAAS,CAQX"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/ggnomad/utils/bookingDates.ts
|
|
2
|
+
var e = 1440 * 60 * 1e3;
|
|
3
|
+
function t(t, n = /* @__PURE__ */ new Date()) {
|
|
4
|
+
let r = Date.UTC(n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate());
|
|
5
|
+
return new Date(r + t * e).toISOString();
|
|
6
|
+
}
|
|
7
|
+
function n(e) {
|
|
8
|
+
if (!e) return null;
|
|
9
|
+
let t = new Date(e);
|
|
10
|
+
return Number.isNaN(t.getTime()) ? null : t;
|
|
11
|
+
}
|
|
12
|
+
function r(r, i, a = /* @__PURE__ */ new Date()) {
|
|
13
|
+
let o = n(r) ?? new Date(t(7, a)), s = n(i), c = s && s.getTime() > o.getTime() ? s : new Date(o.getTime() + e);
|
|
14
|
+
return {
|
|
15
|
+
checkIn: o.toISOString(),
|
|
16
|
+
checkOut: c.toISOString()
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { t as daysFromNowIso, r as stayDates };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=bookingDates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bookingDates.js","names":[],"sources":["../../../src/ggnomad/utils/bookingDates.ts"],"sourcesContent":["/**\n * Booking dates for flows that book without an explicit date picker.\n *\n * Since BOFF-10193 the service prices every booking itself: a stay\n * (PROPERTY) is priced per night, so it must carry a check-in and a later\n * check-out, and any other listing is priced for the date it is booked on.\n * These helpers turn the dates a flow does have (a trip plan's schedule, or\n * nothing at all for the demo booking) into dates the service can price.\n */\n\nconst MS_PER_DAY = 24 * 60 * 60 * 1000;\n\n/** Midnight UTC `days` from now, as an ISO string. */\nexport function daysFromNowIso(days: number, now: Date = new Date()): string {\n const midnight = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate());\n return new Date(midnight + days * MS_PER_DAY).toISOString();\n}\n\nfunction parseIso(value: string | null | undefined): Date | null {\n if (!value) return null;\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? null : date;\n}\n\nexport interface StayDates {\n checkIn: string;\n checkOut: string;\n}\n\n/**\n * A stay starting at `start` (or a week from today when there is none) and\n * ending at `end` when that is later, otherwise one night after the start.\n */\nexport function stayDates(\n start: string | null | undefined,\n end: string | null | undefined,\n now: Date = new Date()\n): StayDates {\n const checkIn = parseIso(start) ?? new Date(daysFromNowIso(7, now));\n const requestedEnd = parseIso(end);\n const checkOut =\n requestedEnd && requestedEnd.getTime() > checkIn.getTime()\n ? requestedEnd\n : new Date(checkIn.getTime() + MS_PER_DAY);\n return { checkIn: checkIn.toISOString(), checkOut: checkOut.toISOString() };\n}\n"],"mappings":";AAUA,IAAM,IAAa,OAAU,KAAK;AAGlC,SAAgB,EAAe,GAAc,oBAAY,IAAI,KAAK,GAAW;CAC3E,IAAM,IAAW,KAAK,IAAI,EAAI,eAAe,GAAG,EAAI,YAAY,GAAG,EAAI,WAAW,CAAC;CACnF,OAAO,IAAI,KAAK,IAAW,IAAO,CAAU,CAAC,CAAC,YAAY;AAC5D;AAEA,SAAS,EAAS,GAA+C;CAC/D,IAAI,CAAC,GAAO,OAAO;CACnB,IAAM,IAAO,IAAI,KAAK,CAAK;CAC3B,OAAO,OAAO,MAAM,EAAK,QAAQ,CAAC,IAAI,OAAO;AAC/C;AAWA,SAAgB,EACd,GACA,GACA,oBAAY,IAAI,KAAK,GACV;CACX,IAAM,IAAU,EAAS,CAAK,KAAK,IAAI,KAAK,EAAe,GAAG,CAAG,CAAC,GAC5D,IAAe,EAAS,CAAG,GAC3B,IACJ,KAAgB,EAAa,QAAQ,IAAI,EAAQ,QAAQ,IACrD,IACA,IAAI,KAAK,EAAQ,QAAQ,IAAI,CAAU;CAC7C,OAAO;EAAE,SAAS,EAAQ,YAAY;EAAG,UAAU,EAAS,YAAY;CAAE;AAC5E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","names":[],"sources":["../../../src/ggnomad/utils/format.ts"],"sourcesContent":["/**\n * Presentation helpers shared across GGNomad pages.\n *\n * Several GGNomad fields are `JSON!` on the service schema (`GgnomadProperty.address`,\n * `GgnomadTour.location`, `GgnomadEvent.venue`, `GgnomadTrip.origin`/`destination`,\n * `GgnomadTrip.stops`, `GgnomadAnalytics.monthlyTrends`/`topDestinations`) with no\n * enforced shape — the reference transport provider writes `{ name, code }`, listing\n * mutations pass whatever the caller supplied, and an unset column is `{}`. These\n * helpers therefore read defensively: anything they cannot resolve to a real scalar is\n * dropped rather than guessed, so a page never presents an invented value as fact.\n */\n\n/** `PENDING_REVIEW` / `step_free_entrance` → `Pending review` / `Step free entrance`. */\nexport function humanizeEnum(value: string): string {\n const spaced = value.replace(/[_-]+/g, ' ').trim().toLowerCase();\n if (!spaced) return value;\n return spaced.charAt(0).toUpperCase() + spaced.slice(1);\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** Scalar entries of a JSON object, in declaration order, with empty values dropped. */\nexport function jsonFacts(value: unknown): Array<{ key: string; label: string; value: string }> {\n if (!isPlainObject(value)) return [];\n const facts: Array<{ key: string; label: string; value: string }> = [];\n for (const [key, raw] of Object.entries(value)) {\n if (typeof raw === 'string') {\n const trimmed = raw.trim();\n if (trimmed) facts.push({ key, label: humanizeEnum(key), value: trimmed });\n } else if (typeof raw === 'number' && Number.isFinite(raw)) {\n facts.push({ key, label: humanizeEnum(key), value: String(raw) });\n } else if (typeof raw === 'boolean') {\n facts.push({ key, label: humanizeEnum(key), value: raw ? 'Yes' : 'No' });\n }\n }\n return facts;\n}\n\nconst LABEL_KEYS = ['name', 'label', 'city', 'title', 'address', 'code'];\n\n/**\n * A single human label for a JSON location-ish value: the first recognised naming key,\n * else the first scalar entry, else null (never a stringified object).\n */\nexport function jsonLabel(value: unknown): string | null {\n if (typeof value === 'string') return value.trim() || null;\n const facts = jsonFacts(value);\n if (facts.length === 0) return null;\n for (const key of LABEL_KEYS) {\n const match = facts.find((fact) => fact.key.toLowerCase() === key);\n if (match) return match.value;\n }\n return facts[0].value;\n}\n\n/** Number of entries in a JSON array field (e.g. `GgnomadTrip.stops`), or null. */\nexport function jsonArrayLength(value: unknown): number | null {\n return Array.isArray(value) ? value.length : null;\n}\n\nexport function formatMoney(amount: number, currency: string): string {\n return `${currency} ${Number(amount).toFixed(2)}`;\n}\n\n/**\n * Currency-formatted number with compact notation at >=10,000. Used by\n * the Provider Dashboard card so large revenues don't break the stats\n * row. The full unformatted amount is returned in a `title` attribute\n * via the second tuple element when callers need the exact value.\n *\n * `GgnomadProvider` does not currently expose a `currency` field in the\n * GraphQL schema, so callers pass `'USD'` as the default until the\n * backend adds the field. Keeping the parameter preserves the call site\n * for when it does.\n *\n * Returns `{ display, exact }` so the card can render `$98.5K` and\n * keep the full `$98,450` in the tooltip.\n */\nexport function formatRevenue(\n amount: number,\n currency = 'USD'\n): { display: string; exact: string } {\n const safe = Number.isFinite(amount) ? amount : 0;\n const useCompact = Math.abs(safe) >= 10_000;\n const formatter = new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency,\n notation: useCompact ? 'compact' : 'standard',\n maximumFractionDigits: useCompact ? 1 : 0,\n });\n const exact = new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency,\n maximumFractionDigits: 0,\n }).format(safe);\n return { display: formatter.format(safe), exact };\n}\n\nexport function formatDate(value?: string | null): string | null {\n if (!value) return null;\n const date = new Date(value);\n if (Number.isNaN(date.getTime())) return null;\n return date.toLocaleDateString(undefined, { day: 'numeric', month: 'short', year: 'numeric' });\n}\n\nexport function formatDateTime(value?: string | null): string | null {\n if (!value) return null;\n const date = new Date(value);\n if (Number.isNaN(date.getTime())) return null;\n return date.toLocaleString(undefined, {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n });\n}\n\nexport function formatTimeOnly(value?: string | null): string | null {\n if (!value) return null;\n const date = new Date(value);\n if (Number.isNaN(date.getTime())) return null;\n return date.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' });\n}\n\n/** `95` → `1h 35m`. */\nexport function formatDurationMinutes(minutes: number): string {\n const safe = Math.max(0, Math.round(minutes));\n const hours = Math.floor(safe / 60);\n const rest = safe % 60;\n if (hours === 0) return `${rest}m`;\n if (rest === 0) return `${hours}h`;\n return `${hours}h ${rest}m`;\n}\n\n/** Whole nights between two `<input type=\"date\">` values; 0 when unusable. */\nexport function nightsBetween(checkIn: string, checkOut: string): number {\n if (!checkIn || !checkOut) return 0;\n const from = new Date(checkIn).getTime();\n const to = new Date(checkOut).getTime();\n if (Number.isNaN(from) || Number.isNaN(to) || to <= from) return 0;\n return Math.round((to - from) / 86_400_000);\n}\n\n/**\n * Reads a `label → count` series out of an unshaped JSON field such as\n * `GgnomadAnalytics.topDestinations`, which the service passes straight through from\n * the latest analytics snapshot. Accepts either an array of objects (a string-valued\n * key is the label, the first numeric key is the count) or a flat `{ label: count }`\n * map. Entries that yield neither a label nor a finite number are dropped, so a\n * snapshot written in an unexpected shape renders as \"no data\" rather than as noise.\n */\nexport function parseNamedCounts(value: unknown): Array<{ label: string; value: number }> {\n const out: Array<{ label: string; value: number }> = [];\n\n if (Array.isArray(value)) {\n for (const entry of value) {\n if (!isPlainObject(entry)) continue;\n let label: string | null = null;\n let count: number | null = null;\n for (const key of LABEL_KEYS) {\n const candidate = entry[key];\n if (typeof candidate === 'string' && candidate.trim()) {\n label = candidate.trim();\n break;\n }\n }\n if (label === null) {\n const firstString = Object.values(entry).find(\n (item): item is string => typeof item === 'string' && item.trim().length > 0\n );\n label = firstString?.trim() ?? null;\n }\n for (const item of Object.values(entry)) {\n if (typeof item === 'number' && Number.isFinite(item)) {\n count = item;\n break;\n }\n }\n if (label !== null && count !== null) out.push({ label, value: count });\n }\n return out;\n }\n\n if (isPlainObject(value)) {\n for (const [key, item] of Object.entries(value)) {\n if (typeof item === 'number' && Number.isFinite(item)) {\n out.push({ label: humanizeEnum(key), value: item });\n }\n }\n }\n\n return out;\n}\n"],"mappings":";AAaA,SAAgB,EAAa,GAAuB;CAClD,IAAM,IAAS,EAAM,QAAQ,UAAU,GAAG,EAAE,KAAK,EAAE,YAAY;CAE/D,OADK,IACE,EAAO,OAAO,CAAC,EAAE,YAAY,IAAI,EAAO,MAAM,CAAC,IADlC;AAEtB;AAEA,SAAS,EAAc,GAAkD;CACvE,OAAO,OAAO,KAAU,cAAY,KAAkB,CAAC,MAAM,QAAQ,CAAK;AAC5E;AAGA,SAAgB,EAAU,GAAsE;CAC9F,IAAI,CAAC,EAAc,CAAK,GAAG,OAAO,CAAC;CACnC,IAAM,IAA8D,CAAC;CACrE,KAAK,IAAM,CAAC,GAAK,MAAQ,OAAO,QAAQ,CAAK,GAC3C,IAAI,OAAO,KAAQ,UAAU;EAC3B,IAAM,IAAU,EAAI,KAAK;EACzB,AAAI,KAAS,EAAM,KAAK;GAAE;GAAK,OAAO,EAAa,CAAG;GAAG,OAAO;EAAQ,CAAC;CAC3E,OAAO,AAAI,OAAO,KAAQ,YAAY,OAAO,SAAS,CAAG,IACvD,EAAM,KAAK;EAAE;EAAK,OAAO,EAAa,CAAG;EAAG,OAAO,OAAO,CAAG;CAAE,CAAC,IACvD,OAAO,KAAQ,aACxB,EAAM,KAAK;EAAE;EAAK,OAAO,EAAa,CAAG;EAAG,OAAO,IAAM,QAAQ;CAAK,CAAC;CAG3E,OAAO;AACT;AAEA,IAAM,IAAa;CAAC;CAAQ;CAAS;CAAQ;CAAS;CAAW;AAAM;AAMvE,SAAgB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,IAHoB,OAAO,OAAO,CAAK,EAAE,MACtC,MAAyB,OAAO,KAAS,YAAY,EAAK,KAAK,EAAE,SAAS,CAErE,GAAa,KAAK,KAAK;GAEjC,KAAK,IAAM,KAAQ,OAAO,OAAO,CAAK,GACpC,IAAI,OAAO,KAAS,YAAY,OAAO,SAAS,CAAI,GAAG;IACrD,IAAQ;IACR;GACF;GAEF,AAAI,MAAU,QAAQ,MAAU,QAAM,EAAI,KAAK;IAAE;IAAO,OAAO;GAAM,CAAC;EACxE;EACA,OAAO;CACT;CAEA,IAAI,EAAc,CAAK,QAChB,IAAM,CAAC,GAAK,MAAS,OAAO,QAAQ,CAAK,GAC5C,AAAI,OAAO,KAAS,YAAY,OAAO,SAAS,CAAI,KAClD,EAAI,KAAK;EAAE,OAAO,EAAa,CAAG;EAAG,OAAO;CAAK,CAAC;CAKxD,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"format.js","names":[],"sources":["../../../src/ggnomad/utils/format.ts"],"sourcesContent":["/**\n * Presentation helpers shared across GGNomad pages.\n *\n * Several GGNomad fields are `JSON!` on the service schema (`GgnomadProperty.address`,\n * `GgnomadTour.location`, `GgnomadEvent.venue`, `GgnomadTrip.origin`/`destination`,\n * `GgnomadTrip.stops`, `GgnomadAnalytics.monthlyTrends`/`topDestinations`) with no\n * enforced shape — the reference transport provider writes `{ name, code }`, listing\n * mutations pass whatever the caller supplied, and an unset column is `{}`. These\n * helpers therefore read defensively: anything they cannot resolve to a real scalar is\n * dropped rather than guessed, so a page never presents an invented value as fact.\n */\n\n/** `PENDING_REVIEW` / `step_free_entrance` → `Pending review` / `Step free entrance`. */\nexport function humanizeEnum(value: string): string {\n const spaced = value.replace(/[_-]+/g, ' ').trim().toLowerCase();\n if (!spaced) return value;\n return spaced.charAt(0).toUpperCase() + spaced.slice(1);\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** Scalar entries of a JSON object, in declaration order, with empty values dropped. */\nexport function jsonFacts(value: unknown): Array<{ key: string; label: string; value: string }> {\n if (!isPlainObject(value)) return [];\n const facts: Array<{ key: string; label: string; value: string }> = [];\n for (const [key, raw] of Object.entries(value)) {\n if (typeof raw === 'string') {\n const trimmed = raw.trim();\n if (trimmed) facts.push({ key, label: humanizeEnum(key), value: trimmed });\n } else if (typeof raw === 'number' && Number.isFinite(raw)) {\n facts.push({ key, label: humanizeEnum(key), value: String(raw) });\n } else if (typeof raw === 'boolean') {\n facts.push({ key, label: humanizeEnum(key), value: raw ? 'Yes' : 'No' });\n }\n }\n return facts;\n}\n\nconst LABEL_KEYS = ['name', 'label', 'city', 'title', 'address', 'code'];\n\n/**\n * A single human label for a JSON location-ish value: the first recognised naming key,\n * else the first scalar entry, else null (never a stringified object).\n */\nexport function jsonLabel(value: unknown): string | null {\n if (typeof value === 'string') return value.trim() || null;\n const facts = jsonFacts(value);\n if (facts.length === 0) return null;\n for (const key of LABEL_KEYS) {\n const match = facts.find((fact) => fact.key.toLowerCase() === key);\n if (match) return match.value;\n }\n return facts[0].value;\n}\n\n/** Number of entries in a JSON array field (e.g. `GgnomadTrip.stops`), or null. */\nexport function jsonArrayLength(value: unknown): number | null {\n return Array.isArray(value) ? value.length : null;\n}\n\nexport function formatMoney(amount: number, currency: string): string {\n return `${currency} ${Number(amount).toFixed(2)}`;\n}\n\n/**\n * Currency-formatted number with compact notation at >=10,000. Used by\n * the Provider Dashboard card so large revenues don't break the stats\n * row. The full unformatted amount is returned in a `title` attribute\n * via the second tuple element when callers need the exact value.\n *\n * `GgnomadProvider` does not currently expose a `currency` field in the\n * GraphQL schema, so callers pass `'USD'` as the default until the\n * backend adds the field. Keeping the parameter preserves the call site\n * for when it does.\n *\n * Returns `{ display, exact }` so the card can render `$98.5K` and\n * keep the full `$98,450` in the tooltip.\n */\nexport function formatRevenue(\n amount: number,\n currency = 'USD'\n): { display: string; exact: string } {\n const safe = Number.isFinite(amount) ? amount : 0;\n const useCompact = Math.abs(safe) >= 10_000;\n const formatter = new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency,\n notation: useCompact ? 'compact' : 'standard',\n maximumFractionDigits: useCompact ? 1 : 0,\n });\n const exact = new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency,\n maximumFractionDigits: 0,\n }).format(safe);\n return { display: formatter.format(safe), exact };\n}\n\nexport function formatDate(value?: string | null): string | null {\n if (!value) return null;\n const date = new Date(value);\n if (Number.isNaN(date.getTime())) return null;\n return date.toLocaleDateString(undefined, { day: 'numeric', month: 'short', year: 'numeric' });\n}\n\nexport function formatDateTime(value?: string | null): string | null {\n if (!value) return null;\n const date = new Date(value);\n if (Number.isNaN(date.getTime())) return null;\n return date.toLocaleString(undefined, {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n });\n}\n\nexport function formatTimeOnly(value?: string | null): string | null {\n if (!value) return null;\n const date = new Date(value);\n if (Number.isNaN(date.getTime())) return null;\n return date.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' });\n}\n\n/** `95` → `1h 35m`. */\nexport function formatDurationMinutes(minutes: number): string {\n const safe = Math.max(0, Math.round(minutes));\n const hours = Math.floor(safe / 60);\n const rest = safe % 60;\n if (hours === 0) return `${rest}m`;\n if (rest === 0) return `${hours}h`;\n return `${hours}h ${rest}m`;\n}\n\n/** Whole nights between two `<input type=\"date\">` values; 0 when unusable. */\nexport function nightsBetween(checkIn: string, checkOut: string): number {\n if (!checkIn || !checkOut) return 0;\n const from = new Date(checkIn).getTime();\n const to = new Date(checkOut).getTime();\n if (Number.isNaN(from) || Number.isNaN(to) || to <= from) return 0;\n return Math.round((to - from) / 86_400_000);\n}\n\n/**\n * Reads a `label → count` series out of an unshaped JSON field such as\n * `GgnomadAnalytics.topDestinations`, which the service passes straight through from\n * the latest analytics snapshot. Accepts either an array of objects (a string-valued\n * key is the label, the first numeric key is the count) or a flat `{ label: count }`\n * map. Entries that yield neither a label nor a finite number are dropped, so a\n * snapshot written in an unexpected shape renders as \"no data\" rather than as noise.\n */\nexport function parseNamedCounts(value: unknown): Array<{ label: string; value: number }> {\n const out: Array<{ label: string; value: number }> = [];\n\n if (Array.isArray(value)) {\n for (const entry of value) {\n if (!isPlainObject(entry)) continue;\n let label: string | null = null;\n let count: number | null = null;\n for (const key of LABEL_KEYS) {\n const candidate = entry[key];\n if (typeof candidate === 'string' && candidate.trim()) {\n label = candidate.trim();\n break;\n }\n }\n if (label === null) {\n const firstString = Object.values(entry).find(\n (item): item is string => typeof item === 'string' && item.trim().length > 0\n );\n label = firstString?.trim() ?? null;\n }\n for (const item of Object.values(entry)) {\n if (typeof item === 'number' && Number.isFinite(item)) {\n count = item;\n break;\n }\n }\n if (label !== null && count !== null) out.push({ label, value: count });\n }\n return out;\n }\n\n if (isPlainObject(value)) {\n for (const [key, item] of Object.entries(value)) {\n if (typeof item === 'number' && Number.isFinite(item)) {\n out.push({ label: humanizeEnum(key), value: item });\n }\n }\n }\n\n return out;\n}\n"],"mappings":";AAaA,SAAgB,EAAa,GAAuB;CAClD,IAAM,IAAS,EAAM,QAAQ,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY;CAE/D,OADK,IACE,EAAO,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,EAAO,MAAM,CAAC,IADlC;AAEtB;AAEA,SAAS,EAAc,GAAkD;CACvE,OAAO,OAAO,KAAU,cAAY,KAAkB,CAAC,MAAM,QAAQ,CAAK;AAC5E;AAGA,SAAgB,EAAU,GAAsE;CAC9F,IAAI,CAAC,EAAc,CAAK,GAAG,OAAO,CAAC;CACnC,IAAM,IAA8D,CAAC;CACrE,KAAK,IAAM,CAAC,GAAK,MAAQ,OAAO,QAAQ,CAAK,GAC3C,IAAI,OAAO,KAAQ,UAAU;EAC3B,IAAM,IAAU,EAAI,KAAK;EACzB,AAAI,KAAS,EAAM,KAAK;GAAE;GAAK,OAAO,EAAa,CAAG;GAAG,OAAO;EAAQ,CAAC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AU;AAC5C;AAUA,SAAgB,EAAiB,GAAyD;CACxF,IAAM,IAA+C,CAAC;CAEtD,IAAI,MAAM,QAAQ,CAAK,GAAG;EACxB,KAAK,IAAM,KAAS,GAAO;GACzB,IAAI,CAAC,EAAc,CAAK,GAAG;GAC3B,IAAI,IAAuB,MACvB,IAAuB;GAC3B,KAAK,IAAM,KAAO,GAAY;IAC5B,IAAM,IAAY,EAAM;IACxB,IAAI,OAAO,KAAc,YAAY,EAAU,KAAK,GAAG;KACrD,IAAQ,EAAU,KAAK;KACvB;IACF;GACF;GACA,AAAI,MAAU,SAIZ,IAHoB,OAAO,OAAO,CAAK,CAAC,CAAC,MACtC,MAAyB,OAAO,KAAS,YAAY,EAAK,KAAK,CAAC,CAAC,SAAS,CAErE,CAAA,EAAa,KAAK,KAAK;GAEjC,KAAK,IAAM,KAAQ,OAAO,OAAO,CAAK,GACpC,IAAI,OAAO,KAAS,YAAY,OAAO,SAAS,CAAI,GAAG;IACrD,IAAQ;IACR;GACF;GAEF,AAAI,MAAU,QAAQ,MAAU,QAAM,EAAI,KAAK;IAAE;IAAO,OAAO;GAAM,CAAC;EACxE;EACA,OAAO;CACT;CAEA,IAAI,EAAc,CAAK,QAChB,IAAM,CAAC,GAAK,MAAS,OAAO,QAAQ,CAAK,GAC5C,AAAI,OAAO,KAAS,YAAY,OAAO,SAAS,CAAI,KAClD,EAAI,KAAK;EAAE,OAAO,EAAa,CAAG;EAAG,OAAO;CAAK,CAAC;CAKxD,OAAO;AACT"}
|
|
@@ -45,6 +45,6 @@ function a(e, n, r) {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
//#endregion
|
|
48
|
-
export { e as DEFAULT_PROVIDER_QUERY, a as applyProviderControls };
|
|
48
|
+
export { e as DEFAULT_PROVIDER_QUERY, a as applyProviderControls, t as isProviderQueryFiltered };
|
|
49
49
|
|
|
50
50
|
//# sourceMappingURL=providerListControls.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providerListControls.js","names":[],"sources":["../../../src/ggnomad/utils/providerListControls.ts"],"sourcesContent":["/**\n * Pure filter / sort / paging logic for the Provider Dashboard toolbar\n * (BOFF-8177 follow-up). Kept out of the component so the behavior is\n * trivially exercisable and the page stays presentational. No React\n * imports here.\n *\n * The backend `ggnomadProviders` query exposes offset paging only — no\n * filter args and no totalCount — and caps one request at MAX_LIMIT=100\n * rows. Callers therefore fetch EVERY page up front and run the toolbar\n * controls over the full loaded list here. That is correct for a fleet\n * of hundreds; past ~a thousand providers the backend should grow filter\n * args + totalCount and this logic moves server-side.\n */\n\n/** Number of provider cards shown before \"Load more\" offers the next batch. */\nexport const PROVIDER_PAGE_SIZE = 12;\n\nexport type ProviderSort = 'newest' | 'oldest' | 'nameAsc' | 'nameDesc' | 'revenueDesc';\n\n/** The minimum shape the controls need from a provider row. */\nexport interface ProviderListItem {\n id: string;\n name: string;\n type: string;\n status: string;\n totalRevenue: number;\n createdAt: string;\n}\n\nexport interface ProviderListQuery {\n /** Case-insensitive substring matched anywhere in the provider name. */\n search: string;\n /** Provider type enum value; null = all types. */\n type: string | null;\n sort: ProviderSort;\n}\n\n/** Toolbar rest state — also what \"Clear filters\" returns to. */\nexport const DEFAULT_PROVIDER_QUERY: ProviderListQuery = {\n search: '',\n type: null,\n sort: 'newest',\n};\n\nexport interface ProviderControlsResult<T> {\n /** Filtered + sorted slice, cut to `visibleCount`. */\n shown: T[];\n /** Rows matching the current filters (before the visible-count cut). */\n total: number;\n /** True when search/type/status differ from their defaults. */\n isFiltered: boolean;\n /** True when matching rows exist beyond what `shown` contains. */\n hasMore: boolean;\n}\n\n/** A query counts as \"filtered\" when search/type are non-default; sort never does. */\nexport function isProviderQueryFiltered(query: ProviderListQuery): boolean {\n return query.search.trim() !== '' || query.type !== null;\n}\n\nfunction timestamp(value: string): number {\n const parsed = Date.parse(value);\n return Number.isFinite(parsed) ? parsed : 0;\n}\n\nfunction revenue(value: number): number {\n return Number.isFinite(value) ? value : 0;\n}\n\nfunction sortItems<T extends ProviderListItem>(items: readonly T[], sort: ProviderSort): T[] {\n const copy = [...items];\n switch (sort) {\n case 'oldest':\n copy.sort((a, b) => timestamp(a.createdAt) - timestamp(b.createdAt));\n break;\n case 'nameAsc':\n copy.sort((a, b) => a.name.localeCompare(b.name));\n break;\n case 'nameDesc':\n copy.sort((a, b) => b.name.localeCompare(a.name));\n break;\n case 'revenueDesc':\n copy.sort((a, b) => revenue(b.totalRevenue) - revenue(a.totalRevenue));\n break;\n case 'newest':\n default:\n // Mirrors the backend's orderBy: { createdAt: 'desc' } default.\n copy.sort((a, b) => timestamp(b.createdAt) - timestamp(a.createdAt));\n break;\n }\n return copy;\n}\n\n/**\n * Apply the toolbar search/type/status filters and sort, then cut the\n * result to the visible page. `items` MUST be the complete loaded list —\n * callers page through every backend batch first (see the module note).\n */\nexport function applyProviderControls<T extends ProviderListItem>(\n items: readonly T[],\n query: ProviderListQuery,\n visibleCount: number\n): ProviderControlsResult<T> {\n const needle = query.search.trim().toLowerCase();\n const filtered = items.filter((item) => {\n if (needle && !item.name.toLowerCase().includes(needle)) return false;\n if (query.type !== null && item.type !== query.type) return false;\n return true;\n });\n\n const sorted = sortItems(filtered, query.sort);\n const cap = Math.max(1, Math.floor(visibleCount));\n return {\n shown: sorted.slice(0, cap),\n total: sorted.length,\n isFiltered: isProviderQueryFiltered(query),\n hasMore: sorted.length > cap,\n };\n}\n"],"mappings":";AAsCA,IAAa,IAA4C;CACvD,QAAQ;CACR,MAAM;CACN,MAAM;AACR;AAcA,SAAgB,EAAwB,GAAmC;CACzE,OAAO,EAAM,OAAO,KAAK,MAAM,MAAM,EAAM,SAAS;AACtD;AAEA,SAAS,EAAU,GAAuB;CACxC,IAAM,IAAS,KAAK,MAAM,CAAK;CAC/B,OAAO,OAAO,SAAS,CAAM,IAAI,IAAS;AAC5C;AAEA,SAAS,EAAQ,GAAuB;CACtC,OAAO,OAAO,SAAS,CAAK,IAAI,IAAQ;AAC1C;AAEA,SAAS,EAAsC,GAAqB,GAAyB;CAC3F,IAAM,IAAO,CAAC,GAAG,CAAK;CACtB,QAAQ,GAAR;EACE,KAAK;GACH,EAAK,MAAM,GAAG,MAAM,EAAU,EAAE,SAAS,IAAI,EAAU,EAAE,SAAS,CAAC;GACnE;EACF,KAAK;GACH,EAAK,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;GAChD;EACF,KAAK;GACH,EAAK,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;GAChD;EACF,KAAK;GACH,EAAK,MAAM,GAAG,MAAM,EAAQ,EAAE,YAAY,IAAI,EAAQ,EAAE,YAAY,CAAC;GACrE;EAEF;GAEE,EAAK,MAAM,GAAG,MAAM,EAAU,EAAE,SAAS,IAAI,EAAU,EAAE,SAAS,CAAC;GACnE;CACJ;CACA,OAAO;AACT;AAOA,SAAgB,EACd,GACA,GACA,GAC2B;CAC3B,IAAM,IAAS,EAAM,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"providerListControls.js","names":[],"sources":["../../../src/ggnomad/utils/providerListControls.ts"],"sourcesContent":["/**\n * Pure filter / sort / paging logic for the Provider Dashboard toolbar\n * (BOFF-8177 follow-up). Kept out of the component so the behavior is\n * trivially exercisable and the page stays presentational. No React\n * imports here.\n *\n * The backend `ggnomadProviders` query exposes offset paging only — no\n * filter args and no totalCount — and caps one request at MAX_LIMIT=100\n * rows. Callers therefore fetch EVERY page up front and run the toolbar\n * controls over the full loaded list here. That is correct for a fleet\n * of hundreds; past ~a thousand providers the backend should grow filter\n * args + totalCount and this logic moves server-side.\n */\n\n/** Number of provider cards shown before \"Load more\" offers the next batch. */\nexport const PROVIDER_PAGE_SIZE = 12;\n\nexport type ProviderSort = 'newest' | 'oldest' | 'nameAsc' | 'nameDesc' | 'revenueDesc';\n\n/** The minimum shape the controls need from a provider row. */\nexport interface ProviderListItem {\n id: string;\n name: string;\n type: string;\n status: string;\n totalRevenue: number;\n createdAt: string;\n}\n\nexport interface ProviderListQuery {\n /** Case-insensitive substring matched anywhere in the provider name. */\n search: string;\n /** Provider type enum value; null = all types. */\n type: string | null;\n sort: ProviderSort;\n}\n\n/** Toolbar rest state — also what \"Clear filters\" returns to. */\nexport const DEFAULT_PROVIDER_QUERY: ProviderListQuery = {\n search: '',\n type: null,\n sort: 'newest',\n};\n\nexport interface ProviderControlsResult<T> {\n /** Filtered + sorted slice, cut to `visibleCount`. */\n shown: T[];\n /** Rows matching the current filters (before the visible-count cut). */\n total: number;\n /** True when search/type/status differ from their defaults. */\n isFiltered: boolean;\n /** True when matching rows exist beyond what `shown` contains. */\n hasMore: boolean;\n}\n\n/** A query counts as \"filtered\" when search/type are non-default; sort never does. */\nexport function isProviderQueryFiltered(query: ProviderListQuery): boolean {\n return query.search.trim() !== '' || query.type !== null;\n}\n\nfunction timestamp(value: string): number {\n const parsed = Date.parse(value);\n return Number.isFinite(parsed) ? parsed : 0;\n}\n\nfunction revenue(value: number): number {\n return Number.isFinite(value) ? value : 0;\n}\n\nfunction sortItems<T extends ProviderListItem>(items: readonly T[], sort: ProviderSort): T[] {\n const copy = [...items];\n switch (sort) {\n case 'oldest':\n copy.sort((a, b) => timestamp(a.createdAt) - timestamp(b.createdAt));\n break;\n case 'nameAsc':\n copy.sort((a, b) => a.name.localeCompare(b.name));\n break;\n case 'nameDesc':\n copy.sort((a, b) => b.name.localeCompare(a.name));\n break;\n case 'revenueDesc':\n copy.sort((a, b) => revenue(b.totalRevenue) - revenue(a.totalRevenue));\n break;\n case 'newest':\n default:\n // Mirrors the backend's orderBy: { createdAt: 'desc' } default.\n copy.sort((a, b) => timestamp(b.createdAt) - timestamp(a.createdAt));\n break;\n }\n return copy;\n}\n\n/**\n * Apply the toolbar search/type/status filters and sort, then cut the\n * result to the visible page. `items` MUST be the complete loaded list —\n * callers page through every backend batch first (see the module note).\n */\nexport function applyProviderControls<T extends ProviderListItem>(\n items: readonly T[],\n query: ProviderListQuery,\n visibleCount: number\n): ProviderControlsResult<T> {\n const needle = query.search.trim().toLowerCase();\n const filtered = items.filter((item) => {\n if (needle && !item.name.toLowerCase().includes(needle)) return false;\n if (query.type !== null && item.type !== query.type) return false;\n return true;\n });\n\n const sorted = sortItems(filtered, query.sort);\n const cap = Math.max(1, Math.floor(visibleCount));\n return {\n shown: sorted.slice(0, cap),\n total: sorted.length,\n isFiltered: isProviderQueryFiltered(query),\n hasMore: sorted.length > cap,\n };\n}\n"],"mappings":";AAsCA,IAAa,IAA4C;CACvD,QAAQ;CACR,MAAM;CACN,MAAM;AACR;AAcA,SAAgB,EAAwB,GAAmC;CACzE,OAAO,EAAM,OAAO,KAAK,MAAM,MAAM,EAAM,SAAS;AACtD;AAEA,SAAS,EAAU,GAAuB;CACxC,IAAM,IAAS,KAAK,MAAM,CAAK;CAC/B,OAAO,OAAO,SAAS,CAAM,IAAI,IAAS;AAC5C;AAEA,SAAS,EAAQ,GAAuB;CACtC,OAAO,OAAO,SAAS,CAAK,IAAI,IAAQ;AAC1C;AAEA,SAAS,EAAsC,GAAqB,GAAyB;CAC3F,IAAM,IAAO,CAAC,GAAG,CAAK;CACtB,QAAQ,GAAR;EACE,KAAK;GACH,EAAK,MAAM,GAAG,MAAM,EAAU,EAAE,SAAS,IAAI,EAAU,EAAE,SAAS,CAAC;GACnE;EACF,KAAK;GACH,EAAK,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;GAChD;EACF,KAAK;GACH,EAAK,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;GAChD;EACF,KAAK;GACH,EAAK,MAAM,GAAG,MAAM,EAAQ,EAAE,YAAY,IAAI,EAAQ,EAAE,YAAY,CAAC;GACrE;EAEF;GAEE,EAAK,MAAM,GAAG,MAAM,EAAU,EAAE,SAAS,IAAI,EAAU,EAAE,SAAS,CAAC;GACnE;CACJ;CACA,OAAO;AACT;AAOA,SAAgB,EACd,GACA,GACA,GAC2B;CAC3B,IAAM,IA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