mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 21:46:49 +00:00
692373c8b8
The Tours tab's list of the trip's tours gains a button beside the GPX import: take a tour over from another trip. Its dialog lists the tours of the user's other trips, searched by name and filtered by trip and type, each with its trip and the measures it has (time, distance, ascent; one it lacks is left out, a paddle tour's climb too). Choosing one shows it on a map with where it comes from, its type, distance, time, heights and number of waypoints, and the name it gets in this trip, its own name to start with. The note under the name says the copy is a tour of this trip of its own, on no day yet, and that later changes stay apart. Only the button in the foot takes it over. The new tour then comes into the trip's lists and map and opens in the editor, unless the editor holds unsaved work, which it never replaces. Nothing is written before the confirm, and closing writes nothing. The library is online only: offline, or when the list fails, the dialog says so and offers to try again; a list cut at 100 tours says to search or filter. A tour taken over names its source in its provenance: "Taken over from" with the trip and the tour as they were called then.
19 lines
845 B
TypeScript
19 lines
845 B
TypeScript
import type {
|
|
TourCreateResponse,
|
|
TourLibraryDetailResponse,
|
|
TourLibraryQuery,
|
|
TourLibraryResponse,
|
|
TourTakeOverRequest,
|
|
} from '@trek/shared';
|
|
import apiClient from './client';
|
|
|
|
/** LIB-02: the tours of the user's other trips, one's preview, and taking one over into a trip. */
|
|
export const tourLibraryApi = {
|
|
list: (query: TourLibraryQuery, signal?: AbortSignal): Promise<TourLibraryResponse> =>
|
|
apiClient.get('/tours/library', { params: query, signal }).then((r) => r.data),
|
|
detail: (placeId: number, signal?: AbortSignal): Promise<TourLibraryDetailResponse> =>
|
|
apiClient.get(`/tours/library/${placeId}`, { signal }).then((r) => r.data),
|
|
takeOver: (tripId: number | string, body: TourTakeOverRequest): Promise<TourCreateResponse> =>
|
|
apiClient.post(`/trips/${tripId}/tours/take-over`, body).then((r) => r.data),
|
|
};
|