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.

563 B
Raw Blame
import { useLocation } from 'react-router'

/**
 * A screen's route ready to follow. A trip screen's route carries `:id`, which
 * only the address of the trip the reader is on can fill in; browsed from
 * elsewhere, such a screen has no way in and the button stays away.
 */
export function useScreenRoute(route: string | undefined): string | null {
  const { pathname } = useLocation()
  if (!route) return null
  if (!route.includes(':id')) return route
  const match = /^\/trips\/(\d+)/.exec(pathname)
  return match ? route.replace(':id', match[1]) : null
}