Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

1.1 KB
Raw Blame
import { useSearchParams } from 'react-router';

import { useBookingDeepLink } from './deepLinks/useBookingDeepLink';
import { useRoadtripDeepLink } from './deepLinks/useRoadtripDeepLink';
import { useTourDeepLink } from './deepLinks/useTourDeepLink';
import type { useTourWorkspace } from './useTourWorkspace';
import type { useTripPlanner } from './useTripPlanner';

interface AssistantEntityLinkOptions {
  planner: ReturnType<typeof useTripPlanner>;
  workspace: ReturnType<typeof useTourWorkspace>;
}

/**
 * The links the chat opens the planner with while it is already on screen:
 * what each part of TREK opens in its own tab (a tour, a booking, a stop of
 * the road trip). Each is taken once and then leaves the URL. The shared
 * planner handles `?tab=` for both desktop and mobile.
 */
export function useAssistantEntityLinks({ planner, workspace }: AssistantEntityLinkOptions): void {
  const [searchParams, setSearchParams] = useSearchParams();
  const links = { planner, workspace, searchParams, setSearchParams };
  useTourDeepLink(links);
  useBookingDeepLink(links);
  useRoadtripDeepLink(links);
}