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.

730 B
Raw Blame
import type { TourListItem } from '@trek/shared';
import type { Assignment } from '../../types';

/**
 * The place form's day context: while a place is edited, the whole day plan to check its times
 * against and, TIME-02, the tour that place is, whose end the time fields work out from its start.
 */
export function placeFormContext(
  editingPlace: { id: number } | null,
  assignments: Record<string, Assignment[]>,
  tours: readonly TourListItem[]
): { dayAssignments: Assignment[]; tour: TourListItem | null } {
  if (!editingPlace) return { dayAssignments: [], tour: null };
  return {
    dayAssignments: Object.values(assignments).flat(),
    tour: tours.find((item) => item.place_id === editingPlace.id) ?? null,
  };
}