mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 02:14:05 +00:00
feat(client): follow and switch a trip's own addons
- 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.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
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),
|
||||
};
|
||||
@@ -46,6 +46,10 @@ export const HANDLED_OUTSIDE_TRIP_STORE = [
|
||||
'roadtripVia:changed',
|
||||
'roadtripTrack:changed',
|
||||
'roadtripPreferences:changed',
|
||||
// Per-trip addons: store/tripAddonsStore (watchTripAddons, mounted by App through
|
||||
// hooks/useTripAddonsSync) puts the trip's list into the store and the device's copy, so the
|
||||
// tabs and panels a trip switched off disappear for every member at once.
|
||||
'tripAddons:changed',
|
||||
// components/Roadtrip/useDayBoundaries reloads the shared boundaries.
|
||||
'roadtripBoundary:changed',
|
||||
// In-app notifications: hooks/useInAppNotificationListener, which also keeps
|
||||
|
||||
Reference in New Issue
Block a user