Files
TREK/client/src/pages/tripPlanner/placeFormContext.ts
T
Maurice b71e32cf12 fix(tours): clear the last lint, knip and wiring findings of the follow-up
The unused day pills go, a client-only type stops being exported, the place
form context moves out of the page hook so its view model stays the first
object it returns, the place form test helpers split the stub component
from the plain setup, and four router files are formatted.
2026-10-20 22:13:25 +02:00

19 lines
730 B
TypeScript

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,
};
}