mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 13:10:29 +00:00
9956c58dd5
- The trip's addon list is read through tripAddonsRepo into tripAddonsStore (per account and trip, kept in Dexie version 16 for offline), refreshed when the connection returns and live on tripAddons:changed. - The planner's tabs, dock, rail and deep links, the cost, tour and list readers, the PDF export, the share link options, the widgets and the watch follow the trip instead of the instance switch. - Trip settings gets an Addons area for the owner, on the desktop dialog and the phone sheet, on one useTripAddonRows hook: each trip addon with its switch, marked "This trip only" while it differs from the instance. Switching back to the instance's value drops the trip's choice. Switching needs a connection.
11 lines
683 B
TypeScript
11 lines
683 B
TypeScript
import type { TripAddonsResponse, TripAddonUpdateRequest } from '@trek/shared';
|
|
import apiClient from './client';
|
|
|
|
/** The trip addons of one trip, each on or off for it: every member reads them, only the owner switches one. */
|
|
export const tripAddonsApi = {
|
|
list: (tripId: number): Promise<TripAddonsResponse> => apiClient.get(`/trips/${tripId}/addons`).then((r) => r.data),
|
|
/** `enabled: null` drops the trip's own choice, so the instance setting applies again. */
|
|
update: (tripId: number, addonId: string, body: TripAddonUpdateRequest): Promise<TripAddonsResponse> =>
|
|
apiClient.put(`/trips/${tripId}/addons/${encodeURIComponent(addonId)}`, body).then((r) => r.data),
|
|
};
|