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.

985 B
Raw Blame
import type { PaddleLock } from '@trek/shared';
import { useCallback } from 'react';
import { setPortageExtraMinutes, setWaypointLock, togglePortageLeg } from '../planner/tourRouteActions';
import type { TourPlannerController } from '../planner/useTourPlanner';

/** The paddle edits of the planner's waypoint rows, each one step of its history. */
export function usePaddleWaypointActions(planner: TourPlannerController) {
  const { editPaddlePoints } = planner;
  return {
    togglePortage: useCallback(
      (id: string) => editPaddlePoints((points) => togglePortageLeg(points, id)),
      [editPaddlePoints]
    ),
    setPortageExtra: useCallback(
      (id: string, minutes: number | null) => editPaddlePoints((points) => setPortageExtraMinutes(points, id, minutes)),
      [editPaddlePoints]
    ),
    setLock: useCallback(
      (id: string, lock: PaddleLock | null) => editPaddlePoints((points) => setWaypointLock(points, id, lock)),
      [editPaddlePoints]
    ),
  };
}