mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 17:41:51 +00:00
feat(tours): assistant takes found places into saved tours and route files from the chat
P6: insert_tour_stop and remove_tour_stop take a place into a saved hike or city walk as one stop and out again, each the other's undo, with change cards in the chat. The planner's insertion rule (poiInsertion) moved to shared so the planner and the server place a stop the same way. "+ Tour" on a found place holds it as a stop of the saved tour open in the planner. P7: GPX, KML and KMZ files attached in the chat are read into their tracks and each is held as a change that takes it in as a hike through import_tour_gpx, undoable per track; the GPX text stays on the held call.
This commit is contained in:
@@ -41,18 +41,6 @@ function stationSplit<T extends RoutePoint>(point: T & StationParts): { station:
|
||||
return { station, rest: rest as T };
|
||||
}
|
||||
|
||||
/**
|
||||
* A new point at the end of the tour; a loop keeps returning to its start,
|
||||
* so there the point goes in before the way back.
|
||||
*/
|
||||
export function withPointAppended<T extends { lat: number; lng: number; role: string }>(
|
||||
points: readonly T[],
|
||||
point: T
|
||||
): T[] {
|
||||
if (!isClosedLoop(points)) return [...points, { ...point, role: 'end' }];
|
||||
return [...points.slice(0, -1), { ...point, role: 'via' }, points[points.length - 1]];
|
||||
}
|
||||
|
||||
/**
|
||||
* The tour taken back from its last point to its start: one end point on the
|
||||
* start's spot, not a second copy of the start among the stops. `newId` names
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { act, fireEvent, render, renderHook, screen } from '@testing-library/react';
|
||||
import { withPointAppended } from '@trek/shared';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { buildCategory, buildPlace } from '../../../../tests/helpers/factories';
|
||||
import { resetAllStores, seedStore } from '../../../../tests/helpers/store';
|
||||
@@ -10,7 +11,6 @@ import {
|
||||
unlinkedPoint,
|
||||
type TourPlannerWaypoint,
|
||||
} from './tourPlannerWaypoints';
|
||||
import { withPointAppended } from './tourRouteActions';
|
||||
import { TripPlacePicker } from './TripPlacePicker';
|
||||
import type { TourPlannerController } from './useTourPlanner';
|
||||
import { useTripPlaceWaypoints } from './useTripPlaceWaypoints';
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { nearnessToLine } from '@trek/shared';
|
||||
import { nearnessToLine, withPointAppended } from '@trek/shared';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { useTripStore } from '../../../store/tripStore';
|
||||
import type { Category, Place } from '../../../types';
|
||||
import { randomId } from '../../../utils/randomId';
|
||||
import { useLinkedPlaceOf } from '../walk/useWalkSchedule';
|
||||
import { unlinkedPoint, type TourPlannerWaypoint } from './tourPlannerWaypoints';
|
||||
import { withPointAppended } from './tourRouteActions';
|
||||
import type { TourPlannerController } from './useTourPlanner';
|
||||
|
||||
/** A place of the trip as the picker offers it. */
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { isClosedLoop, type PlannableTourType, type TourFixedLeg } from '@trek/shared';
|
||||
import { isClosedLoop, withPointAppended, type PlannableTourType, type TourFixedLeg } from '@trek/shared';
|
||||
import { useCallback, type Dispatch, type RefObject, type SetStateAction } from 'react';
|
||||
import { randomId } from '../../../utils/randomId';
|
||||
import { holdsHorseSection } from '../horse/horseLegs';
|
||||
import { unlinkedPoint, type TourPlannerWaypoint } from './tourPlannerWaypoints';
|
||||
import { closeLoop, reverseRoute, toggleFreeLeg, withPointAppended } from './tourRouteActions';
|
||||
import { closeLoop, reverseRoute, toggleFreeLeg } from './tourRouteActions';
|
||||
|
||||
type WaypointChange = TourPlannerWaypoint[] | ((current: TourPlannerWaypoint[]) => TourPlannerWaypoint[]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user