mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-02 17:26:24 +00:00
b71e32cf12
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.
19 lines
730 B
TypeScript
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,
|
|
};
|
|
}
|