@fleetbridge/ui 1.1.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -3
- package/index.d.ts +1282 -1176
- package/index.js +5841 -5738
- package/package.json +2 -2
- package/server.d.ts +150 -3
- package/server.js +234 -23
- package/styles.css +1 -1
package/index.d.ts
CHANGED
|
@@ -80,126 +80,10 @@ interface SearchWidgetProps {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
|
-
*
|
|
84
|
-
* URL that carries them between the two shortcodes, and the summary bar that
|
|
85
|
-
* echoes them back on the results page.
|
|
86
|
-
*
|
|
87
|
-
* `SAME_AS_PICKUP` is a sentinel rather than an empty string because Radix
|
|
88
|
-
* Select can't use "" as an item value. It's stripped when building the
|
|
89
|
-
* query, so it never reaches the URL.
|
|
90
|
-
*/
|
|
91
|
-
declare const SAME_AS_PICKUP = "same";
|
|
92
|
-
interface SearchCriteria {
|
|
93
|
-
pickupLocation: string;
|
|
94
|
-
dropoffLocation: string;
|
|
95
|
-
pickupDate: string;
|
|
96
|
-
dropoffDate: string;
|
|
97
|
-
pickupTime: string;
|
|
98
|
-
dropoffTime: string;
|
|
99
|
-
coupon: string;
|
|
100
|
-
/**
|
|
101
|
-
* Country of residence, same distinction carhire.co.za's own search form
|
|
102
|
-
* makes - some suppliers (e.g. Bluu, see AvailabilityParams.isInternational)
|
|
103
|
-
* quote different rates/terms for a foreign renter.
|
|
104
|
-
*/
|
|
105
|
-
residency: 'ZA' | 'INT';
|
|
106
|
-
/**
|
|
107
|
-
* Adapter identifier to search (e.g. "hertz"). Only set for amend: a
|
|
108
|
-
* normal search fans out to every subscribed supplier.
|
|
109
|
-
*/
|
|
110
|
-
supplier?: string;
|
|
111
|
-
/**
|
|
112
|
-
* The driver's age, when it is outside the usual 25–70 band. Young (and
|
|
113
|
-
* some older) drivers pay a fee or are refused, so suppliers price it.
|
|
114
|
-
* Left out for the usual band, so those searches stay exactly as before.
|
|
115
|
-
*/
|
|
116
|
-
driverAge?: number;
|
|
117
|
-
}
|
|
118
|
-
/** The driver-age choices the card search style offers. `age` is what is sent (the youngest age in the band); none means the usual band. */
|
|
119
|
-
declare const DRIVER_AGE_BANDS: ReadonlyArray<{
|
|
120
|
-
label: string;
|
|
121
|
-
age?: number;
|
|
122
|
-
}>;
|
|
123
|
-
declare const DEFAULT_CRITERIA: SearchCriteria;
|
|
124
|
-
declare function criteriaToQuery(criteria: SearchCriteria): string;
|
|
125
|
-
declare function criteriaFromParams(search: string): SearchCriteria;
|
|
126
|
-
/**
|
|
127
|
-
* Whole days in the rental window, or 0 without one. A rental "day" is a
|
|
128
|
-
* billing unit, so a same-day return still counts as one.
|
|
129
|
-
*/
|
|
130
|
-
declare function rentalDays(criteria: SearchCriteria): number;
|
|
131
|
-
/**
|
|
132
|
-
* True when the criteria carry a complete trip the server can search: real
|
|
133
|
-
* pick-up and return dates (return not before pick-up) and real times. A
|
|
134
|
-
* link into the results page without dates (for example "Find a car at
|
|
135
|
-
* Sandton") is not a failed search; the page asks for the dates instead.
|
|
136
|
-
*/
|
|
137
|
-
declare function hasValidTrip(criteria: SearchCriteria): boolean;
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* How the results page sits on the host page.
|
|
141
|
-
*
|
|
142
|
-
* `boxed` (the default) draws the summary bar and the filter rail as cards
|
|
143
|
-
* inside a content column. `flush` drops the cards for hairlines, so a site
|
|
144
|
-
* can attach the summary to its own header and run the results full width.
|
|
145
|
-
*/
|
|
146
|
-
type ResultsLayout = 'boxed' | 'flush';
|
|
147
|
-
/**
|
|
148
|
-
* The search summary, and the form behind it.
|
|
149
|
-
*
|
|
150
|
-
* Collapsed it's a single line of criteria; "Modify search" expands the same
|
|
151
|
-
* form the search shortcode uses, and submitting re-searches in place. Nothing
|
|
152
|
-
* about the criteria needs a round trip today, so reloading here would only
|
|
153
|
-
* cost the user their filters and their place in the list.
|
|
154
|
-
*/
|
|
155
|
-
declare function SearchBar({ criteria, days, editing, onToggleEditing, onSubmit, layout, prompt, needsDates, }: {
|
|
156
|
-
criteria: SearchCriteria;
|
|
157
|
-
days: number;
|
|
158
|
-
editing: boolean;
|
|
159
|
-
onToggleEditing: () => void;
|
|
160
|
-
onSubmit: (criteria: SearchCriteria) => void;
|
|
161
|
-
layout?: ResultsLayout;
|
|
162
|
-
/** A line above the open form, e.g. "Choose your dates to see cars at Sandton". */
|
|
163
|
-
prompt?: string | null;
|
|
164
|
-
/** The page has no usable trip yet: the summary asks for dates and the form searches instead of updating. */
|
|
165
|
-
needsDates?: boolean;
|
|
166
|
-
}): react_jsx_runtime.JSX.Element;
|
|
167
|
-
|
|
168
|
-
interface ResultsPageProps {
|
|
169
|
-
/** Passed through to every card's CTA - see CarCard's `bookingUrl`. */
|
|
170
|
-
bookingUrl?: string;
|
|
171
|
-
/** How the cars are laid out: the site owner's choice, or the shortcode's (see lib/widget.styles.ts). */
|
|
172
|
-
listStyle?: ListStyle;
|
|
173
|
-
/**
|
|
174
|
-
* `boxed` (default): the summary and filters as cards in a content column.
|
|
175
|
-
* `flush`: hairlines instead of cards, for a full-width page whose header
|
|
176
|
-
* carries the summary (see `summaryContainer`).
|
|
177
|
-
*/
|
|
178
|
-
layout?: ResultsLayout;
|
|
179
|
-
/**
|
|
180
|
-
* Where to draw the search summary and its Modify search form, for example
|
|
181
|
-
* a row in the site's own sticky header. Left out, it sits above the results.
|
|
182
|
-
*/
|
|
183
|
-
summaryContainer?: HTMLElement | null;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
interface ManageBookingProps {
|
|
187
|
-
/** Renders an on-page "Manage my booking" trigger card that opens the
|
|
188
|
-
* lookup dialog - only meaningful where [fleetbridge_manage_booking] was
|
|
189
|
-
* deliberately placed on a page (see the shortcode's own
|
|
190
|
-
* `data-show-trigger` attribute). The wp_footer fallback mount that makes
|
|
191
|
-
* a `#manage=booking&id=&pin=` link work from *any* page renders this
|
|
192
|
-
* component without it - there, the drawer opening itself straight from the
|
|
193
|
-
* URL is the entire interaction. */
|
|
194
|
-
showTrigger?: boolean;
|
|
195
|
-
/** How the cars are laid out when changing a booking (the site owner's choice on the Theme page). */
|
|
196
|
-
listStyle?: ListStyle;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* How the UI talks to the site it is embedded in.
|
|
83
|
+
* How the customer booking logic talks to the host site.
|
|
201
84
|
*
|
|
202
|
-
* Every query in this package goes through one `FleetBridgeTransport
|
|
85
|
+
* Every query in this package goes through one `FleetBridgeTransport`, and so
|
|
86
|
+
* does every query in @fleetbridge/ui, which bundles this package. The
|
|
203
87
|
* transport carries a public action (by its short name, e.g.
|
|
204
88
|
* "search_availability") and its string fields to the host site, and reads
|
|
205
89
|
* back the `{ success, data }` envelope WordPress's `wp_send_json_*` uses -
|
|
@@ -209,6 +93,8 @@ interface ManageBookingProps {
|
|
|
209
93
|
* as `fleetbridge_<action>`.
|
|
210
94
|
* - Anything else (Next.js, Remix, Express…): `httpTransport({ endpoint })`
|
|
211
95
|
* posts to one route of your own that runs `createPublicHandler`.
|
|
96
|
+
* - Native apps (React Native) use `httpTransport` too, with the absolute
|
|
97
|
+
* URL of that route, and send any headers they need through `headers`.
|
|
212
98
|
*
|
|
213
99
|
* Supplier credentials and the account API key never reach the browser:
|
|
214
100
|
* both transports only ever talk to the host site's own server.
|
|
@@ -219,6 +105,13 @@ type QueryResult<T> = {
|
|
|
219
105
|
} | {
|
|
220
106
|
success: false;
|
|
221
107
|
error: string;
|
|
108
|
+
/**
|
|
109
|
+
* The HTTP status of the failed answer (for example 401, 404, 409, 429),
|
|
110
|
+
* or 0 when the site could not be reached at all (no connection, a
|
|
111
|
+
* timeout). Missing when the transport does not know it (a custom
|
|
112
|
+
* transport, or the "not connected yet" stand-in).
|
|
113
|
+
*/
|
|
114
|
+
status?: number;
|
|
222
115
|
/**
|
|
223
116
|
* Whatever else came back with the failure. Some of it matters to the
|
|
224
117
|
* customer - a booking that the supplier declined still returns the
|
|
@@ -231,8 +124,18 @@ interface FleetBridgeTransport {
|
|
|
231
124
|
/** `action` is the short name, without the "fleetbridge_" prefix. */
|
|
232
125
|
post<T>(action: string, fields?: Record<string, string>): Promise<QueryResult<T>>;
|
|
233
126
|
}
|
|
234
|
-
/** Every public action the
|
|
235
|
-
declare const PUBLIC_ACTIONS: readonly ["public_branches", "search_sources", "search_availability", "get_estimation", "get_extras", "get_one_way_fee", "supplier_terms", "booking_request", "request_quote", "lookup_quote", "confirm_quote", "lookup_booking", "cancel_my_booking", "amend_my_booking", "payment_methods", "start_payment", "verify_payment"];
|
|
127
|
+
/** Every public action the booking flow calls. */
|
|
128
|
+
declare const PUBLIC_ACTIONS: readonly ["public_branches", "search_sources", "cache_version", "search_availability", "get_estimation", "get_extras", "get_one_way_fee", "supplier_terms", "booking_request", "request_quote", "lookup_quote", "confirm_quote", "lookup_booking", "cancel_my_booking", "amend_my_booking", "payment_methods", "start_payment", "verify_payment", "claim_coupon", "my_coupons"];
|
|
129
|
+
/**
|
|
130
|
+
* Where a request comes from: the website, the mobile app or a WhatsApp bot.
|
|
131
|
+
* Coupons can be limited to some channels.
|
|
132
|
+
*
|
|
133
|
+
* Kept in step by hand with COUPON_CHANNELS in @fleetbridge/contract
|
|
134
|
+
* (packages/contract/src/promotions.ts), which this package does not depend
|
|
135
|
+
* on at run time. Add a channel there and here together.
|
|
136
|
+
*/
|
|
137
|
+
declare const COUPON_CHANNELS: readonly ["web", "app", "whatsapp"];
|
|
138
|
+
type CouponChannel = (typeof COUPON_CHANNELS)[number];
|
|
236
139
|
type PublicAction = (typeof PUBLIC_ACTIONS)[number];
|
|
237
140
|
/** Strips a leading "fleetbridge_", so either spelling of an action works. */
|
|
238
141
|
declare function shortAction(action: string): string;
|
|
@@ -241,371 +144,53 @@ declare function wordpressTransport(options: {
|
|
|
241
144
|
ajaxUrl: string;
|
|
242
145
|
nonce: string;
|
|
243
146
|
}): FleetBridgeTransport;
|
|
147
|
+
/** Whether fetch sends cookies (the same values as fetch's own `credentials`). */
|
|
148
|
+
type TransportCredentials = 'omit' | 'same-origin' | 'include';
|
|
149
|
+
interface HttpTransportOptions {
|
|
150
|
+
/** The route that runs `createPublicHandler`. Native apps pass an absolute URL. */
|
|
151
|
+
endpoint: string;
|
|
152
|
+
/** Sent with every request, e.g. an app key or a client version header. */
|
|
153
|
+
headers?: Record<string, string>;
|
|
154
|
+
/** Defaults to 'same-origin'. */
|
|
155
|
+
credentials?: TransportCredentials;
|
|
156
|
+
/**
|
|
157
|
+
* Where the requests come from, sent as the `x-fleetbridge-channel` header.
|
|
158
|
+
* The site decides whether to believe it (createPublicHandler's
|
|
159
|
+
* `getChannel`); coupons limited to other channels are then refused.
|
|
160
|
+
* Leave it out on a web page: the site treats its own pages as "web".
|
|
161
|
+
*/
|
|
162
|
+
channel?: CouponChannel;
|
|
163
|
+
/**
|
|
164
|
+
* Gives up on a request after this many milliseconds, failing with
|
|
165
|
+
* status 0 like a lost connection. A number for every action, or a
|
|
166
|
+
* function that picks one per action (for example longer for
|
|
167
|
+
* "search_availability" and "booking_request"); 0 or undefined from it
|
|
168
|
+
* means no limit. Default: no limit.
|
|
169
|
+
*/
|
|
170
|
+
timeoutMs?: number | ((action: string) => number | undefined);
|
|
171
|
+
}
|
|
244
172
|
/**
|
|
245
173
|
* Talks to a route of the host site that runs `createPublicHandler` (see
|
|
246
174
|
* `@fleetbridge/ui/server`). The action travels as the `action` field.
|
|
247
175
|
*/
|
|
248
|
-
declare function httpTransport(options:
|
|
249
|
-
endpoint: string;
|
|
250
|
-
headers?: Record<string, string>;
|
|
251
|
-
credentials?: RequestCredentials;
|
|
252
|
-
}): FleetBridgeTransport;
|
|
176
|
+
declare function httpTransport(options: HttpTransportOptions): FleetBridgeTransport;
|
|
253
177
|
declare function setTransport(transport: FleetBridgeTransport): void;
|
|
254
178
|
/** The transport in use, or a stand-in that explains what is missing. */
|
|
255
179
|
declare function getTransport(): FleetBridgeTransport;
|
|
256
180
|
|
|
257
181
|
/**
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
* - The base palette (shadcn names): --primary, --primary-foreground,
|
|
262
|
-
* --accent, --background, --foreground, --muted, --border, --ring, --radius…
|
|
263
|
-
* - The font: --fb-font-sans.
|
|
264
|
-
* - Per-surface tokens (--fb-search-*, --fb-listing-*, --fb-car-*,
|
|
265
|
-
* --fb-filter-*, --fb-wizard-*), which default to the base palette - see
|
|
266
|
-
* styles/public-tokens.css for the full list.
|
|
267
|
-
*
|
|
268
|
-
* `FleetBridgeTheme` is a typed shortcut for the common ones, `colors` sets any
|
|
269
|
-
* element's own colour by name, and anything else goes in `vars`. Pass it to <FleetBridgeProvider theme={…}>, or print
|
|
270
|
-
* themeToCss(theme) in a <style> tag (best for server-rendered pages), or set
|
|
271
|
-
* the properties in your own stylesheet.
|
|
272
|
-
*/
|
|
273
|
-
/**
|
|
274
|
-
* Every colour a site owner can set, one per surface token - the same keys
|
|
275
|
-
* and custom properties as the WordPress plugin's Theme tab
|
|
276
|
-
* (ThemeController::COLOR_FIELDS / ShortcodeController::COLOR_VARS), so a
|
|
277
|
-
* theme saved there or in another host's settings maps one-to-one.
|
|
182
|
+
* Public results-grid vehicle shape. Mapped from the availability AJAX
|
|
183
|
+
* response (see lib/offers.ts → NormalizedVehicleListing) — only fields the
|
|
184
|
+
* UI can actually populate from a live supplier search.
|
|
278
185
|
*/
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
readonly background: "--background";
|
|
283
|
-
readonly card: "--card";
|
|
284
|
-
readonly cardForeground: "--card-foreground";
|
|
285
|
-
readonly border: "--border";
|
|
286
|
-
readonly foreground: "--foreground";
|
|
287
|
-
readonly mutedForeground: "--muted-foreground";
|
|
288
|
-
readonly muted: "--muted";
|
|
289
|
-
readonly input: "--input";
|
|
290
|
-
readonly secondary: "--secondary";
|
|
291
|
-
readonly secondaryForeground: "--secondary-foreground";
|
|
292
|
-
readonly searchSurface: "--fb-search-surface";
|
|
293
|
-
readonly searchBorder: "--fb-search-border";
|
|
294
|
-
readonly searchField: "--fb-search-field";
|
|
295
|
-
readonly searchLabel: "--fb-search-label";
|
|
296
|
-
readonly searchValue: "--fb-search-value";
|
|
297
|
-
readonly searchButton: "--fb-search-button";
|
|
298
|
-
readonly searchButtonFg: "--fb-search-button-fg";
|
|
299
|
-
readonly searchToggle: "--fb-search-toggle";
|
|
300
|
-
readonly searchToggleFg: "--fb-search-toggle-fg";
|
|
301
|
-
readonly listingBar: "--fb-listing-bar";
|
|
302
|
-
readonly listingBorder: "--fb-listing-border";
|
|
303
|
-
readonly listingText: "--fb-listing-text";
|
|
304
|
-
readonly listingMuted: "--fb-listing-muted";
|
|
305
|
-
readonly listingModifyBg: "--fb-listing-modify";
|
|
306
|
-
readonly listingModifyBorder: "--fb-listing-modify-border";
|
|
307
|
-
readonly listingChip: "--fb-listing-chip";
|
|
308
|
-
readonly listingChipFg: "--fb-listing-chip-fg";
|
|
309
|
-
readonly listingSidebar: "--fb-listing-sidebar";
|
|
310
|
-
readonly carBg: "--fb-car-bg";
|
|
311
|
-
readonly carBorder: "--fb-car-border";
|
|
312
|
-
readonly carBorderHover: "--fb-car-border-hover";
|
|
313
|
-
readonly carTitle: "--fb-car-title";
|
|
314
|
-
readonly carMuted: "--fb-car-muted";
|
|
315
|
-
readonly carPhoto: "--fb-car-photo";
|
|
316
|
-
readonly carPrice: "--fb-car-price";
|
|
317
|
-
readonly carCta: "--fb-car-cta";
|
|
318
|
-
readonly carCtaFg: "--fb-car-cta-fg";
|
|
319
|
-
readonly carQuoteBorder: "--fb-car-quote-border";
|
|
320
|
-
readonly carBadge: "--fb-car-badge";
|
|
321
|
-
readonly carBadgeFg: "--fb-car-badge-fg";
|
|
322
|
-
readonly carInsured: "--fb-car-insured";
|
|
323
|
-
readonly carInsuredFg: "--fb-car-insured-fg";
|
|
324
|
-
readonly carOption: "--fb-car-option";
|
|
325
|
-
readonly carOptionFg: "--fb-car-option-fg";
|
|
326
|
-
readonly filterTitle: "--fb-filter-title";
|
|
327
|
-
readonly filterMuted: "--fb-filter-muted";
|
|
328
|
-
readonly filterPill: "--fb-filter-pill";
|
|
329
|
-
readonly filterPillFg: "--fb-filter-pill-fg";
|
|
330
|
-
readonly filterPillActive: "--fb-filter-pill-active";
|
|
331
|
-
readonly filterPillActiveFg: "--fb-filter-pill-active-fg";
|
|
332
|
-
readonly filterBar: "--fb-filter-bar";
|
|
333
|
-
readonly surface2: "--fb-surface-2";
|
|
334
|
-
readonly borderStrong: "--fb-border-strong";
|
|
335
|
-
readonly ring: "--ring";
|
|
336
|
-
readonly destructive: "--destructive";
|
|
337
|
-
};
|
|
338
|
-
type ThemeColorKey = keyof typeof THEME_COLOR_VARS;
|
|
339
|
-
interface FleetBridgeTheme {
|
|
340
|
-
/** The main brand colour: search button, selected states, CTAs. */
|
|
341
|
-
primary?: string;
|
|
342
|
-
primaryForeground?: string;
|
|
343
|
-
/** The highlight colour: the "Book"/"View deal" buttons and filter bars. */
|
|
344
|
-
accent?: string;
|
|
345
|
-
accentForeground?: string;
|
|
346
|
-
background?: string;
|
|
347
|
-
foreground?: string;
|
|
348
|
-
/** Field backgrounds and quiet surfaces. */
|
|
349
|
-
muted?: string;
|
|
350
|
-
mutedForeground?: string;
|
|
351
|
-
border?: string;
|
|
352
|
-
ring?: string;
|
|
353
|
-
/** Corner radius, e.g. "12px" or "0.75rem". */
|
|
354
|
-
radius?: string;
|
|
355
|
-
/** Font stack, e.g. "Inter, system-ui, sans-serif". The host page loads the font. */
|
|
356
|
-
fontFamily?: string;
|
|
186
|
+
/** One CDP / km package on a listing — values already cleaned by the API. */
|
|
187
|
+
interface RatePackage {
|
|
188
|
+
cdpCode: string;
|
|
357
189
|
/**
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
|
|
362
|
-
colors?: Partial<Record<ThemeColorKey, string>>;
|
|
363
|
-
/** Any other custom property, e.g. { '--fb-wizard-selected': '#153673' }. */
|
|
364
|
-
vars?: Record<string, string>;
|
|
365
|
-
}
|
|
366
|
-
declare function themeToVars(theme: FleetBridgeTheme): Record<string, string>;
|
|
367
|
-
/** The theme as a `:root { … }` rule, for a server-rendered <style> tag. */
|
|
368
|
-
declare function themeToCss(theme: FleetBridgeTheme, selector?: string): string;
|
|
369
|
-
|
|
370
|
-
/** How long a cached search/quote survives, both as staleTime and as the persisted ceiling. */
|
|
371
|
-
declare const CACHE_MS: number;
|
|
372
|
-
interface FleetBridgeConfig {
|
|
373
|
-
/** Where the search form sends the customer (the page that renders <ResultsPage />). */
|
|
374
|
-
resultsUrl: string;
|
|
375
|
-
/** The page that renders <ManageBooking />. */
|
|
376
|
-
manageUrl?: string;
|
|
377
|
-
/** Where the customer comes back to after paying online. Defaults to the results page. */
|
|
378
|
-
paymentReturnUrl?: string;
|
|
379
|
-
/** Passed to every car card's CTA, when the site has its own booking page. */
|
|
380
|
-
bookingUrl?: string;
|
|
381
|
-
}
|
|
382
|
-
/** The URLs the host gave FleetBridgeProvider. */
|
|
383
|
-
declare function useFleetBridgeConfig(): FleetBridgeConfig;
|
|
384
|
-
interface FleetBridgeProviderProps extends Partial<FleetBridgeConfig> {
|
|
385
|
-
/** How the UI reaches the host site: wordpressTransport(…) or httpTransport(…). */
|
|
386
|
-
transport: FleetBridgeTransport;
|
|
387
|
-
/** Bring your own QueryClient to share a cache with the rest of the app. */
|
|
388
|
-
queryClient?: QueryClient;
|
|
389
|
-
/** Keep successful searches/quotes in localStorage for CACHE_MS, so a page refresh is instant. Default true. */
|
|
390
|
-
persistCache?: boolean;
|
|
391
|
-
/** The look of each booking part (filters, steps, extras, price, confirmation, find-booking). */
|
|
392
|
-
looks?: Partial<Looks>;
|
|
393
|
-
/**
|
|
394
|
-
* Brand colours, radius and font. Written as CSS custom properties on
|
|
395
|
-
* :root while the provider is mounted (portalled dialogs live on <body>,
|
|
396
|
-
* so the tokens have to be inheritable from the root). For a flash-free
|
|
397
|
-
* first paint, also print themeToCss(theme) in a <style> tag on the server.
|
|
398
|
-
*/
|
|
399
|
-
theme?: FleetBridgeTheme;
|
|
400
|
-
/** Render the toast viewport. Default true. Turn off if the host already renders @fleetbridge/components' <Toaster />. */
|
|
401
|
-
toaster?: boolean;
|
|
402
|
-
children: ReactNode;
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Everything the FleetBridge components need around them: the transport,
|
|
406
|
-
* the query cache, tooltips, toasts, looks, theme and page URLs. Mount it
|
|
407
|
-
* once (or once per island) around any FleetBridge component.
|
|
408
|
-
*/
|
|
409
|
-
declare function FleetBridgeProvider({ transport, queryClient, persistCache, looks, theme, toaster, resultsUrl, manageUrl, paymentReturnUrl, bookingUrl, children, }: FleetBridgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
410
|
-
/** True once running in the browser, after hydration. */
|
|
411
|
-
declare function useIsClient(): boolean;
|
|
412
|
-
/** Renders `fallback` on the server and during hydration, then the component. */
|
|
413
|
-
declare function clientOnly<P extends object>(Component: ComponentType<P>, displayName: string): {
|
|
414
|
-
(props: P & {
|
|
415
|
-
fallback?: ReactNode;
|
|
416
|
-
}): react_jsx_runtime.JSX.Element;
|
|
417
|
-
displayName: string;
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* The colours a site owner can change, grouped and worded for a settings
|
|
422
|
-
* screen: the WordPress plugin's Theme tab and any other host's (e.g. the
|
|
423
|
-
* Carhire Studio's Booking look → Colours) use the same list, so a theme
|
|
424
|
-
* means the same thing everywhere. Plain data, importing nothing but
|
|
425
|
-
* ../theme (which imports nothing), so a host's server can bundle it without
|
|
426
|
-
* the React components.
|
|
427
|
-
*
|
|
428
|
-
* Store only the colours that were changed ({colors, radius}, see
|
|
429
|
-
* BookingTheme) and pass them as `FleetBridgeTheme.colors` / `radius`.
|
|
430
|
-
*/
|
|
431
|
-
|
|
432
|
-
declare const THEME_KEYS: ThemeColorKey[];
|
|
433
|
-
/** FleetBridge's own starting colours, for anything neither the brand nor its parent token sets. */
|
|
434
|
-
declare const FLEETBRIDGE_DEFAULTS: Record<ThemeColorKey, string>;
|
|
435
|
-
/** A part's colours follow this token until they are changed (FleetBridge's CSS fallbacks). */
|
|
436
|
-
declare const THEME_INHERIT: Partial<Record<ThemeColorKey, ThemeColorKey>>;
|
|
437
|
-
type ThemeField = {
|
|
438
|
-
key: ThemeColorKey;
|
|
439
|
-
label: string;
|
|
440
|
-
hint?: string;
|
|
441
|
-
};
|
|
442
|
-
type ThemeSection = {
|
|
443
|
-
title: string;
|
|
444
|
-
fields: ThemeField[];
|
|
445
|
-
};
|
|
446
|
-
type ThemeGroup = {
|
|
447
|
-
id: 'brand' | 'search' | 'listing' | 'filters' | 'card';
|
|
448
|
-
title: string; /** A Remix icon class, for hosts that use Remix icons. */
|
|
449
|
-
icon: string;
|
|
450
|
-
description: string;
|
|
451
|
-
sections: ThemeSection[];
|
|
452
|
-
};
|
|
453
|
-
/** The Theme tab's groups, in its order and wording. `icon` is a Remix icon class for the Studio. */
|
|
454
|
-
declare const THEME_GROUPS: ThemeGroup[];
|
|
455
|
-
/** One-click brand colours for a settings screen. */
|
|
456
|
-
declare const THEME_PRESETS: {
|
|
457
|
-
name: string;
|
|
458
|
-
primary: string;
|
|
459
|
-
primaryForeground: string;
|
|
460
|
-
}[];
|
|
461
|
-
/** Corner radius choices in px (the Theme tab allows 0–40px). */
|
|
462
|
-
declare const THEME_RADII: number[];
|
|
463
|
-
type BookingTheme = {
|
|
464
|
-
colors?: Partial<Record<ThemeColorKey, string>> | null;
|
|
465
|
-
radius?: number | null;
|
|
466
|
-
};
|
|
467
|
-
declare const isHex: (v: unknown) => v is string;
|
|
468
|
-
/** A stored or posted theme with anything unknown or malformed dropped. */
|
|
469
|
-
declare function cleanBookingTheme(raw: unknown): BookingTheme;
|
|
470
|
-
/**
|
|
471
|
-
* What each colour shows as when it has not been changed: the site's brand
|
|
472
|
-
* values (`base`), else the token it follows, else FleetBridge's default.
|
|
473
|
-
*/
|
|
474
|
-
declare function effectiveColors(base: Partial<Record<ThemeColorKey, string>>, overrides?: Partial<Record<ThemeColorKey, string>>): Record<ThemeColorKey, string>;
|
|
475
|
-
|
|
476
|
-
interface SearchPanelProps {
|
|
477
|
-
/** Pre-fills the form - the results page passes the criteria from the URL. */
|
|
478
|
-
initialCriteria?: SearchCriteria;
|
|
479
|
-
onSubmit: (criteria: SearchCriteria) => void;
|
|
480
|
-
submitLabel?: string;
|
|
481
|
-
/**
|
|
482
|
-
* Which look to use (see lib/widget.styles.ts). The results page's Modify
|
|
483
|
-
* search drawer and the amend flow always use the bar.
|
|
484
|
-
*/
|
|
485
|
-
style?: SearchStyle;
|
|
486
|
-
/**
|
|
487
|
-
* For the bar only. `card` is the standalone shortcode: a soft shadow and a
|
|
488
|
-
* short fade in. `bare` is the same bar without that, for the results
|
|
489
|
-
* page's Modify search drawer.
|
|
490
|
-
*/
|
|
491
|
-
variant?: 'card' | 'bare';
|
|
492
|
-
/** The headline of the hero and sidebar styles. An empty string hides it. */
|
|
493
|
-
title?: string;
|
|
494
|
-
/** The line under the hero headline. An empty string hides it. */
|
|
495
|
-
subtitle?: string;
|
|
496
|
-
className?: string;
|
|
497
|
-
/**
|
|
498
|
-
* `Date.now()` when the currently-applied search (the one `initialCriteria`
|
|
499
|
-
* reflects) last actually ran - only meaningful alongside submitLabel="Update".
|
|
500
|
-
*/
|
|
501
|
-
resultsFetchedAt?: number;
|
|
502
|
-
}
|
|
503
|
-
/**
|
|
504
|
-
* The search form, in the look the site owner chose. Every look shares one
|
|
505
|
-
* form (useSearchForm), so they check, remember and send a search the same
|
|
506
|
-
* way; they only place the fields differently.
|
|
507
|
-
*/
|
|
508
|
-
declare function SearchPanel({ initialCriteria, onSubmit, submitLabel, style, variant, title, subtitle, className, resultsFetchedAt, }: SearchPanelProps): react_jsx_runtime.JSX.Element;
|
|
509
|
-
|
|
510
|
-
/** A location the picker can search - one entry per branch NAME, already
|
|
511
|
-
* merged server-side (see fleetbridge.php's ajax_public_branches) since the
|
|
512
|
-
* same name can exist under more than one supplier. The form searches by
|
|
513
|
-
* name; ajax_search_availability() resolves each active supplier's own
|
|
514
|
-
* branch code for that name at search time (a code means nothing outside
|
|
515
|
-
* the supplier it belongs to). */
|
|
516
|
-
interface BranchLocation {
|
|
517
|
-
name: string;
|
|
518
|
-
region: string;
|
|
519
|
-
isAirportBranch: boolean;
|
|
520
|
-
isInternational: boolean;
|
|
521
|
-
/** The branch's street address, when the catalogue has one. Searchable. */
|
|
522
|
-
address?: string;
|
|
523
|
-
}
|
|
524
|
-
interface LocationOption {
|
|
525
|
-
value: string;
|
|
526
|
-
label: string;
|
|
527
|
-
icon?: LucideIcon;
|
|
528
|
-
/** A second line under the label (the branch's address). Searchable. */
|
|
529
|
-
description?: string;
|
|
530
|
-
}
|
|
531
|
-
interface LocationGroup {
|
|
532
|
-
/** Omitted for a leading, header-less group (e.g. sentinel options). */
|
|
533
|
-
label?: string;
|
|
534
|
-
options: LocationOption[];
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
interface SearchComboboxProps {
|
|
538
|
-
id?: string;
|
|
539
|
-
ariaLabel?: string;
|
|
540
|
-
value: string;
|
|
541
|
-
/** What shows in the closed trigger - may differ from `value` for sentinel
|
|
542
|
-
* options like "Any location" / "Same as pick-up". */
|
|
543
|
-
displayLabel: string;
|
|
544
|
-
groups: LocationGroup[];
|
|
545
|
-
onChange: (value: string) => void;
|
|
546
|
-
searchPlaceholder?: string;
|
|
547
|
-
emptyMessage?: string;
|
|
548
|
-
/** True while `groups` is empty because the list is still being fetched,
|
|
549
|
-
* not because it genuinely has no matches - an empty array reads
|
|
550
|
-
* identically either way otherwise, so a picker opened right as the fetch
|
|
551
|
-
* kicks off would flash `emptyMessage` for what's actually just latency. */
|
|
552
|
-
loading?: boolean;
|
|
553
|
-
triggerClassName?: string;
|
|
554
|
-
contentClassName?: string;
|
|
555
|
-
invalid?: boolean;
|
|
556
|
-
}
|
|
557
|
-
/**
|
|
558
|
-
* A searchable, groupable single-select - the search form's replacement for
|
|
559
|
-
* a plain <select> on pick-up/drop-off location and time, so a long location
|
|
560
|
-
* list can be typed through instead of scrolled.
|
|
561
|
-
*/
|
|
562
|
-
declare function SearchCombobox({ id, ariaLabel, value, displayLabel, groups, onChange, searchPlaceholder, emptyMessage, loading, triggerClassName, contentClassName, invalid, }: SearchComboboxProps): react_jsx_runtime.JSX.Element;
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* Pick-up -> drop-off as one range, rather than two independent date pickers:
|
|
566
|
-
* a single two-month calendar makes the rental window visible while choosing
|
|
567
|
-
* it, and makes an end-before-start selection impossible by construction.
|
|
568
|
-
*
|
|
569
|
-
* Values are local-date ISO strings (YYYY-MM-DD). `new Date("2026-01-01")`
|
|
570
|
-
* parses as UTC and shifts a day in negative-offset timezones, so parsing and
|
|
571
|
-
* formatting are done by hand - same approach as ui/date-picker.tsx.
|
|
572
|
-
*/
|
|
573
|
-
interface DateRangeFieldProps {
|
|
574
|
-
from: string;
|
|
575
|
-
to: string;
|
|
576
|
-
onChange: (range: {
|
|
577
|
-
from: string;
|
|
578
|
-
to: string;
|
|
579
|
-
}) => void;
|
|
580
|
-
className?: string;
|
|
581
|
-
/** Inverted styling for use on a dark surface. */
|
|
582
|
-
tone?: 'default' | 'stage';
|
|
583
|
-
id?: string;
|
|
584
|
-
invalid?: boolean;
|
|
585
|
-
/**
|
|
586
|
-
* What the trigger shows: the whole range (default), or only one end. The
|
|
587
|
-
* "card" search style draws pick-up and return in separate cells; both open
|
|
588
|
-
* the same range calendar, so a return before pick-up is still impossible.
|
|
589
|
-
*/
|
|
590
|
-
display?: 'range' | 'from' | 'to';
|
|
591
|
-
/** The text shown for an empty end, e.g. "Add date". */
|
|
592
|
-
placeholder?: string;
|
|
593
|
-
}
|
|
594
|
-
declare function DateRangeField({ from, to, onChange, className, tone, id, invalid, display, placeholder, }: DateRangeFieldProps): react_jsx_runtime.JSX.Element;
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* Public results-grid vehicle shape. Mapped from the availability AJAX
|
|
598
|
-
* response (see lib/offers.ts → NormalizedVehicleListing) — only fields the
|
|
599
|
-
* UI can actually populate from a live supplier search.
|
|
600
|
-
*/
|
|
601
|
-
/** One CDP / km package on a listing — values already cleaned by the API. */
|
|
602
|
-
interface RatePackage {
|
|
603
|
-
cdpCode: string;
|
|
604
|
-
/**
|
|
605
|
-
* Whether this package's CDP code should show the "Discount" badge - set
|
|
606
|
-
* server-side (by the core's search.availability action) once for
|
|
607
|
-
* DIRECT-mode codes, or only once a matching Coupon was submitted and
|
|
608
|
-
* validated for a COUPON_GATED-mode code.
|
|
190
|
+
* Whether this package's CDP code should show the "Discount" badge - set
|
|
191
|
+
* server-side (by the core's search.availability action) once for
|
|
192
|
+
* DIRECT-mode codes, or only once a matching Coupon was submitted and
|
|
193
|
+
* validated for a COUPON_GATED-mode code.
|
|
609
194
|
*/
|
|
610
195
|
isDiscounted: boolean;
|
|
611
196
|
/**
|
|
@@ -790,209 +375,21 @@ interface Car {
|
|
|
790
375
|
}
|
|
791
376
|
|
|
792
377
|
/**
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
}
|
|
809
|
-
/**
|
|
810
|
-
* One car in the results grid.
|
|
811
|
-
*
|
|
812
|
-
* Identity sits above a short photo: group, body class, name, supplier.
|
|
813
|
-
* Specs are a single icon row. Mileage and cover are compact switches, only
|
|
814
|
-
* when the supplier offered more than one. Price, total and Book now close
|
|
815
|
-
* the card. Every colour comes from the --fb-car-* tokens.
|
|
816
|
-
*/
|
|
817
|
-
declare function CarCard({ car, bookingUrl, onBook, onQuote, rentalDays, priority, bookLabel, className, }: CarCardProps): react_jsx_runtime.JSX.Element;
|
|
818
|
-
|
|
819
|
-
/**
|
|
820
|
-
* Grey placeholders shown while the search is running. They have the same
|
|
821
|
-
* shape as the chosen list style, so nothing jumps when the cars arrive.
|
|
822
|
-
* Screen readers hear "Loading cars" once instead of a pile of empty boxes.
|
|
823
|
-
*/
|
|
824
|
-
declare function CarListSkeleton({ count, listStyle, className, }: {
|
|
825
|
-
count?: number;
|
|
826
|
-
listStyle?: ListStyle;
|
|
827
|
-
className?: string;
|
|
828
|
-
}): react_jsx_runtime.JSX.Element;
|
|
829
|
-
|
|
830
|
-
interface CarListProps {
|
|
831
|
-
cars: Car[];
|
|
832
|
-
/** Which look to use (see lib/widget.styles.ts). Every look books the same way. */
|
|
833
|
-
listStyle?: ListStyle;
|
|
834
|
-
bookingUrl?: string;
|
|
835
|
-
/** Opens the booking dialog; see CarCard's `onBook`. */
|
|
836
|
-
onBook?: (car: Car) => void;
|
|
837
|
-
/** Quote request for the selected car / rate package. */
|
|
838
|
-
onQuote?: (car: Car) => void;
|
|
839
|
-
/** Forwarded to each card for the estimated total. */
|
|
840
|
-
rentalDays?: number;
|
|
841
|
-
/** Renders a reset action in the empty state when provided. */
|
|
842
|
-
onReset?: () => void;
|
|
843
|
-
bookLabel?: string;
|
|
844
|
-
emptyActionLabel?: string;
|
|
845
|
-
emptyDescription?: string;
|
|
846
|
-
/** `card` (default): a dashed card. `inline`: a centred note without a card, for full-width pages. */
|
|
847
|
-
emptyLayout?: 'card' | 'inline';
|
|
848
|
-
className?: string;
|
|
849
|
-
}
|
|
850
|
-
/**
|
|
851
|
-
* The cars, in the look the site owner chose: grid cards (the default),
|
|
852
|
-
* rows, a compare table, a showcase or rows grouped by class. Each car's
|
|
853
|
-
* choices and booking come from the same offer (CarCard/useCarOffer.ts), so
|
|
854
|
-
* the look never changes what gets booked.
|
|
855
|
-
*
|
|
856
|
-
* The list is its own size container (`@container/list`), so each look fits
|
|
857
|
-
* the width it was given, beside the filter rail or on a full-width page.
|
|
858
|
-
*/
|
|
859
|
-
declare function CarList({ cars, listStyle, bookingUrl, onBook, onQuote, rentalDays, onReset, bookLabel, emptyActionLabel, emptyDescription, emptyLayout, className, }: CarListProps): react_jsx_runtime.JSX.Element;
|
|
860
|
-
|
|
861
|
-
/**
|
|
862
|
-
* Filtering, sorting and formatting for the results shortcode — kept out of
|
|
863
|
-
* the components so the whole filter model is readable in one place.
|
|
864
|
-
*/
|
|
865
|
-
|
|
866
|
-
interface Filters {
|
|
867
|
-
query: string;
|
|
868
|
-
makes: string[];
|
|
869
|
-
models: string[];
|
|
870
|
-
/** Body class (SMALL / MEDIUM / LARGE / PREMIUM) from supplier specs — not group codes. */
|
|
871
|
-
categories: string[];
|
|
872
|
-
fuels: string[];
|
|
873
|
-
suppliers: string[];
|
|
874
|
-
transmission: 'any' | 'Manual' | 'Automatic';
|
|
875
|
-
condition: 'any' | 'New' | 'Used';
|
|
876
|
-
seats: number | null;
|
|
877
|
-
luggage: number | null;
|
|
878
|
-
priceRange: [number, number];
|
|
879
|
-
yearRange: [number, number];
|
|
880
|
-
location: string;
|
|
881
|
-
availableOnly: boolean;
|
|
882
|
-
instantBook: boolean;
|
|
883
|
-
insuranceIncluded: boolean;
|
|
884
|
-
/**
|
|
885
|
-
* Free kilometres per day: null is any, a number keeps cars with at least
|
|
886
|
-
* that many km per day (unlimited counts as more than any number), and
|
|
887
|
-
* "unlimited" keeps only cars with unlimited km.
|
|
888
|
-
*/
|
|
889
|
-
mileage: MileageFilter;
|
|
890
|
-
sort: SortOption;
|
|
891
|
-
}
|
|
892
|
-
type MileageFilter = number | 'unlimited' | null;
|
|
893
|
-
type SortOption = 'recommended' | 'price-asc' | 'price-desc' | 'rating-desc' | 'year-desc';
|
|
894
|
-
declare const DEFAULT_FILTERS: Filters;
|
|
895
|
-
declare function priceBoundsFromCars(cars: Car[]): [number, number];
|
|
896
|
-
declare function formatZAR(amount: number): string;
|
|
897
|
-
interface ActiveChip {
|
|
898
|
-
id: string;
|
|
899
|
-
label: string;
|
|
900
|
-
clear: Partial<Filters>;
|
|
901
|
-
}
|
|
902
|
-
declare function activeChips(filters: Filters, bounds?: {
|
|
903
|
-
price: [number, number];
|
|
904
|
-
year: [number, number] | null;
|
|
905
|
-
}): ActiveChip[];
|
|
906
|
-
|
|
907
|
-
type ArrayKey = 'makes' | 'models' | 'categories' | 'fuels' | 'suppliers';
|
|
908
|
-
interface FilterControlProps {
|
|
909
|
-
cars: Car[];
|
|
910
|
-
filters: Filters;
|
|
911
|
-
priceBounds: [number, number];
|
|
912
|
-
onChange: (patch: Partial<Filters>) => void;
|
|
913
|
-
onToggle: (key: ArrayKey, value: string) => void;
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
/**
|
|
917
|
-
* "Chip bar": one strip of chips above the cars, one chip per filter. A chip
|
|
918
|
-
* opens a small panel with that filter's control. A chip that is in use is
|
|
919
|
-
* filled in and shows a dot, so the customer sees at a glance what is on.
|
|
920
|
-
* On a phone the strip scrolls sideways.
|
|
921
|
-
*/
|
|
922
|
-
declare function FilterChipBar({ activeCount, onReset, className, ...props }: FilterControlProps & {
|
|
923
|
-
activeCount: number;
|
|
924
|
-
onReset: () => void;
|
|
925
|
-
className?: string;
|
|
926
|
-
}): react_jsx_runtime.JSX.Element;
|
|
927
|
-
/**
|
|
928
|
-
* "Car type tabs": a big tile for each kind of car (small, SUV, bakkie …)
|
|
929
|
-
* with a photo of its cheapest car, how many there are and the lowest price
|
|
930
|
-
* a day. Choosing a tile shows only that kind; "All cars" shows every car.
|
|
931
|
-
* The chosen tile fills with the brand colour. Nothing is drawn when the
|
|
932
|
-
* cars only come in one kind, as there would be nothing to choose.
|
|
933
|
-
*/
|
|
934
|
-
declare function CarTypeTabs({ cars, filters, priceBounds, onChange, className }: FilterControlProps & {
|
|
935
|
-
className?: string;
|
|
936
|
-
}): react_jsx_runtime.JSX.Element | null;
|
|
937
|
-
|
|
938
|
-
interface FilterPanelProps {
|
|
939
|
-
cars: Car[];
|
|
940
|
-
filters: Filters;
|
|
941
|
-
priceBounds: [number, number];
|
|
942
|
-
activeCount: number;
|
|
943
|
-
onChange: (patch: Partial<Filters>) => void;
|
|
944
|
-
onToggle: (key: ArrayKey, value: string) => void;
|
|
945
|
-
onReset: () => void;
|
|
946
|
-
}
|
|
947
|
-
/**
|
|
948
|
-
* The filter rail: a heading with a "Clear" button, then one block per
|
|
949
|
-
* filter (price, gearbox, supplier, category, fuel, free km, seats, bags). Category chips are body classes from the API
|
|
950
|
-
* (SMALL / MEDIUM / …), never supplier group codes. The filters themselves
|
|
951
|
-
* live in FilterControls, shared with the other filter looks.
|
|
952
|
-
*/
|
|
953
|
-
declare function FilterPanel({ cars, filters, priceBounds, activeCount, onChange, onToggle, onReset }: FilterPanelProps): react_jsx_runtime.JSX.Element;
|
|
954
|
-
|
|
955
|
-
/**
|
|
956
|
-
* Shared transport for every `*.queries.ts` file: all of them talk to
|
|
957
|
-
* FleetBridge the same way - send an action + fields through the transport
|
|
958
|
-
* the host set on FleetBridgeProvider (see transport.ts) and read back `{ success, data }` /
|
|
959
|
-
* `{ success: false, data: { message } }`.
|
|
960
|
-
*
|
|
961
|
-
* Before this, `extras.queries.ts` and `booking.queries.ts` each duplicated
|
|
962
|
-
* that POST-and-parse dance with slightly different error copy and no
|
|
963
|
-
* shared logging. Subclassing this gets every query the same "site not
|
|
964
|
-
* connected" / "couldn't reach the site" messages and the same
|
|
965
|
-
* `console.log`/`console.error` shape, so a network tab or console filtered
|
|
966
|
-
* on "[FleetBridge]" reads consistently across every query.
|
|
967
|
-
*/
|
|
968
|
-
|
|
969
|
-
declare abstract class BaseQuery {
|
|
970
|
-
/**
|
|
971
|
-
* Sends `action` + `fields` through the transport, which normalizes
|
|
972
|
-
* every possible outcome - unconfigured site, network failure, non-2xx
|
|
973
|
-
* response, `{success: false}` - into one `QueryResult`, so subclasses
|
|
974
|
-
* never branch on `response.ok` vs `payload.success` vs a thrown error
|
|
975
|
-
* differently from each other.
|
|
976
|
-
*/
|
|
977
|
-
protected post<T>(action: string, fields?: Record<string, string>): Promise<QueryResult<T>>;
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
/**
|
|
981
|
-
* The add-on shape the booking wizard's first step renders. Populated live,
|
|
982
|
-
* per car/supplier, by lib/queries/extras.queries.ts (which calls the real
|
|
983
|
-
* adapter - apps/api/src/handlers/suppliers/extras.ts - via the WordPress
|
|
984
|
-
* plugin).
|
|
985
|
-
* There is no static/placeholder list here: a supplier with nothing to
|
|
986
|
-
* offer (or whose adapter doesn't implement getExtras yet) simply has no
|
|
987
|
-
* extras, rather than falling back to invented ones.
|
|
988
|
-
*
|
|
989
|
-
* Prices are in the same currency as the vehicle's daily rate (ZAR).
|
|
990
|
-
*
|
|
991
|
-
* Billing mirrors carhire's `serviceType` / `priceType`:
|
|
992
|
-
* - Per Day → `perDay` (× rental days × quantity)
|
|
993
|
-
* - Per Unit → `onceOff` (× quantity; Quant=true on Sani)
|
|
994
|
-
* - Per Rental → `onceOff` (× 1; Quant=false on Sani)
|
|
995
|
-
* - Per Trip / Per Kilometer / WAIVERS & EXTRAS → `onceOff`
|
|
378
|
+
* The add-on shape the booking wizard's first step renders. Populated live,
|
|
379
|
+
* per car/supplier, by lib/queries/extras.queries.ts (which calls the real
|
|
380
|
+
* adapter - apps/api/src/handlers/suppliers/extras.ts - via the WordPress
|
|
381
|
+
* plugin).
|
|
382
|
+
* There is no static/placeholder list here: a supplier with nothing to
|
|
383
|
+
* offer (or whose adapter doesn't implement getExtras yet) simply has no
|
|
384
|
+
* extras, rather than falling back to invented ones.
|
|
385
|
+
*
|
|
386
|
+
* Prices are in the same currency as the vehicle's daily rate (ZAR).
|
|
387
|
+
*
|
|
388
|
+
* Billing mirrors carhire's `serviceType` / `priceType`:
|
|
389
|
+
* - Per Day → `perDay` (× rental days × quantity)
|
|
390
|
+
* - Per Unit → `onceOff` (× quantity; Quant=true on Sani)
|
|
391
|
+
* - Per Rental → `onceOff` (× 1; Quant=false on Sani)
|
|
392
|
+
* - Per Trip / Per Kilometer / WAIVERS & EXTRAS → `onceOff`
|
|
996
393
|
*/
|
|
997
394
|
/** Charge basis labels shown on the card — same set carhire's ExtraOptionItem uses. */
|
|
998
395
|
type ExtraServiceType = 'Per Unit' | 'Per Rental' | 'Per Day' | 'Per Trip' | 'Per Kilometer' | 'WAIVERS & EXTRAS';
|
|
@@ -1035,389 +432,1234 @@ interface Extra {
|
|
|
1035
432
|
type ExtraSelection = Record<string, number>;
|
|
1036
433
|
|
|
1037
434
|
/**
|
|
1038
|
-
*
|
|
1039
|
-
*
|
|
1040
|
-
*
|
|
1041
|
-
*/
|
|
1042
|
-
|
|
1043
|
-
interface Driver {
|
|
1044
|
-
title: string;
|
|
1045
|
-
firstName: string;
|
|
1046
|
-
lastName: string;
|
|
1047
|
-
email: string;
|
|
1048
|
-
phone: string;
|
|
1049
|
-
licenceNumber: string;
|
|
1050
|
-
notes: string;
|
|
1051
|
-
/** Defaults to 'South Africa' - drives the phone dial-code prefix and the
|
|
1052
|
-
* ID-number field's label ("SA ID number" vs "Passport number"). */
|
|
1053
|
-
country: string;
|
|
1054
|
-
/** SA ID number or passport number, label driven by `country` above. */
|
|
1055
|
-
idNumber: string;
|
|
1056
|
-
crossingBorder: boolean;
|
|
1057
|
-
streetAddress: string;
|
|
1058
|
-
city: string;
|
|
1059
|
-
suburb: string;
|
|
1060
|
-
province: string;
|
|
1061
|
-
postalCode: string;
|
|
1062
|
-
/** Optional second recipient for the booking confirmation. */
|
|
1063
|
-
additionalEmail: string;
|
|
1064
|
-
}
|
|
1065
|
-
declare const EMPTY_DRIVER: Driver;
|
|
1066
|
-
interface QuoteLine {
|
|
1067
|
-
id: string;
|
|
1068
|
-
label: string;
|
|
1069
|
-
/** Sub-label: how the amount was arrived at. */
|
|
1070
|
-
detail?: string;
|
|
1071
|
-
amount: number;
|
|
1072
|
-
}
|
|
1073
|
-
interface QuoteNote {
|
|
1074
|
-
label: string;
|
|
1075
|
-
value: string;
|
|
1076
|
-
}
|
|
1077
|
-
interface Quote {
|
|
1078
|
-
days: number;
|
|
1079
|
-
lines: QuoteLine[];
|
|
1080
|
-
/** Things that will change the price but that this bundle can't put a number on. */
|
|
1081
|
-
notes: QuoteNote[];
|
|
1082
|
-
extrasTotal: number;
|
|
1083
|
-
total: number;
|
|
1084
|
-
/** Refundable card hold, not a charge - see PriceSummary's "Funds needed on card". */
|
|
1085
|
-
deposit: number;
|
|
1086
|
-
/** What the driver owes if the car is damaged. Not added to the rental price. */
|
|
1087
|
-
excess: number;
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
/**
|
|
1091
|
-
* Paying online for one of the site's own cars.
|
|
1092
|
-
*
|
|
1093
|
-
* The site's own cars can be paid for online (Paystack, Stitch or PayFast)
|
|
1094
|
-
* or at the branch, depending on the payment methods staff set up in the
|
|
1095
|
-
* admin (Fleets, Payment methods). This file talks to the WordPress plugin's
|
|
1096
|
-
* three public endpoints for that (Controllers\ActionController):
|
|
1097
|
-
*
|
|
1098
|
-
* - methods(): the ways a customer may pay at a pick-up branch. An empty
|
|
1099
|
-
* list means the booking wizard shows no payment step.
|
|
1100
|
-
* - start(): tries the payment again for a booking that waits for one,
|
|
1101
|
-
* and gives back the payment page's address.
|
|
1102
|
-
* - verify(): asks how the payment went when the customer comes back from
|
|
1103
|
-
* the payment page. Once it is paid, the booking is confirmed.
|
|
435
|
+
* The search criteria - one shape shared by the form that collects them, the
|
|
436
|
+
* URL that carries them between the two shortcodes, and the summary bar that
|
|
437
|
+
* echoes them back on the results page.
|
|
1104
438
|
*
|
|
1105
|
-
*
|
|
1106
|
-
*
|
|
1107
|
-
*
|
|
439
|
+
* `SAME_AS_PICKUP` is a sentinel rather than an empty string because Radix
|
|
440
|
+
* Select can't use "" as an item value. It's stripped when building the
|
|
441
|
+
* query, so it never reaches the URL.
|
|
1108
442
|
*/
|
|
1109
|
-
|
|
443
|
+
declare const SAME_AS_PICKUP = "same";
|
|
444
|
+
interface SearchCriteria {
|
|
445
|
+
pickupLocation: string;
|
|
446
|
+
dropoffLocation: string;
|
|
447
|
+
pickupDate: string;
|
|
448
|
+
dropoffDate: string;
|
|
449
|
+
pickupTime: string;
|
|
450
|
+
dropoffTime: string;
|
|
451
|
+
coupon: string;
|
|
452
|
+
/**
|
|
453
|
+
* Country of residence, same distinction carhire.co.za's own search form
|
|
454
|
+
* makes - some suppliers (e.g. Bluu, see AvailabilityParams.isInternational)
|
|
455
|
+
* quote different rates/terms for a foreign renter.
|
|
456
|
+
*/
|
|
457
|
+
residency: 'ZA' | 'INT';
|
|
458
|
+
/**
|
|
459
|
+
* Adapter identifier to search (e.g. "hertz"). Only set for amend: a
|
|
460
|
+
* normal search fans out to every subscribed supplier.
|
|
461
|
+
*/
|
|
462
|
+
supplier?: string;
|
|
463
|
+
/**
|
|
464
|
+
* The driver's age, when it is outside the usual 25–70 band. Young (and
|
|
465
|
+
* some older) drivers pay a fee or are refused, so suppliers price it.
|
|
466
|
+
* Left out for the usual band, so those searches stay exactly as before.
|
|
467
|
+
*/
|
|
468
|
+
driverAge?: number;
|
|
469
|
+
}
|
|
470
|
+
/** The driver-age choices the card search style offers. `age` is what is sent (the youngest age in the band); none means the usual band. */
|
|
471
|
+
declare const DRIVER_AGE_BANDS: ReadonlyArray<{
|
|
472
|
+
label: string;
|
|
473
|
+
age?: number;
|
|
474
|
+
}>;
|
|
475
|
+
declare const DEFAULT_CRITERIA: SearchCriteria;
|
|
476
|
+
declare function criteriaToQuery(criteria: SearchCriteria): string;
|
|
477
|
+
declare function criteriaFromParams(search: string): SearchCriteria;
|
|
478
|
+
/**
|
|
479
|
+
* Whole days in the rental window, or 0 without one. A rental "day" is a
|
|
480
|
+
* billing unit, so a same-day return still counts as one.
|
|
481
|
+
*/
|
|
482
|
+
declare function rentalDays(criteria: SearchCriteria): number;
|
|
483
|
+
/**
|
|
484
|
+
* True when the criteria carry a complete trip the server can search: real
|
|
485
|
+
* pick-up and return dates (return not before pick-up) and real times. A
|
|
486
|
+
* link into the results page without dates (for example "Find a car at
|
|
487
|
+
* Sandton") is not a failed search; the page asks for the dates instead.
|
|
488
|
+
*/
|
|
489
|
+
declare function hasValidTrip(criteria: SearchCriteria): boolean;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Maps the availability search response onto the `Car` shape the results grid
|
|
493
|
+
* renders. The API normalizer owns money/km/image cleaning — this only flattens
|
|
494
|
+
* offers → fleets → Car and copies fields.
|
|
495
|
+
*/
|
|
496
|
+
|
|
497
|
+
interface RawRateOption {
|
|
498
|
+
cdpCode?: string;
|
|
499
|
+
standardRate: number;
|
|
500
|
+
/** Supplier's higher-cover tier total (e.g. Europcar's SuperCover) - see
|
|
501
|
+
* rate.resolver.ts. Most suppliers mirror standardRate into this, which
|
|
502
|
+
* toPackage() treats as "no real second tier" rather than a choice. */
|
|
503
|
+
superRate?: number;
|
|
504
|
+
dailyRate?: number;
|
|
505
|
+
kmPerDay?: number;
|
|
506
|
+
rentalDays?: number;
|
|
507
|
+
unlimitedMileage?: boolean;
|
|
508
|
+
superDeposit?: number;
|
|
509
|
+
liability?: number;
|
|
510
|
+
/** Extra-kilometre price in Rand. Suppliers send standardPricePerKm; own fleet sends standardExcessRatePerKm. */
|
|
511
|
+
standardPricePerKm?: number;
|
|
512
|
+
standardExcessRatePerKm?: number;
|
|
513
|
+
superPricePerKm?: number;
|
|
514
|
+
superExcessRatePerKm?: number;
|
|
515
|
+
/** Own fleet: excess and deposit for the higher cover. */
|
|
516
|
+
superExcess?: number;
|
|
517
|
+
superCoverDeposit?: number;
|
|
518
|
+
/** Drop-off/one-way fee (ZAR) - set only when pick-up and return branches
|
|
519
|
+
* differ (see rate.resolver.ts/aggregator.ts on the API side). */
|
|
520
|
+
dropOffFee?: number;
|
|
521
|
+
/** Supplier rate identifiers - needed to BOOK this rate, see RatePackage. */
|
|
522
|
+
rateNo?: string | number;
|
|
523
|
+
rateSrNo?: string | number;
|
|
524
|
+
/** The supplier's price quote for this rate (SaniSixt), sent back when booking it. */
|
|
525
|
+
quoteRef?: string;
|
|
526
|
+
/** Amount (ZAR, off standardRate) this rate beat a pricier same-km-tier
|
|
527
|
+
* competitor by - see aggregator.ts's dedupeCheapestPerKm(). */
|
|
528
|
+
discount?: number;
|
|
529
|
+
/** Own fleet: false when this plan's km allowance differs from its CDP. */
|
|
530
|
+
kmSelectable?: boolean;
|
|
531
|
+
/** Own fleet: the CDP km allowance behind a blocked option. 0 means unlimited. */
|
|
532
|
+
cdpKmAllowance?: number | null;
|
|
533
|
+
options?: Record<string, unknown>[];
|
|
534
|
+
}
|
|
535
|
+
interface RawSupplier {
|
|
536
|
+
id?: string;
|
|
537
|
+
name?: string;
|
|
538
|
+
logoUrl?: string;
|
|
539
|
+
}
|
|
540
|
+
interface RawListingMetadata {
|
|
541
|
+
supplierId?: string;
|
|
542
|
+
origin?: Record<string, unknown>[];
|
|
543
|
+
adapter?: Record<string, unknown>[];
|
|
544
|
+
}
|
|
545
|
+
interface RawFleetListing {
|
|
546
|
+
seat?: number;
|
|
547
|
+
door?: number;
|
|
548
|
+
code?: string;
|
|
549
|
+
carGroup: string;
|
|
550
|
+
carGroupInt?: string | number;
|
|
551
|
+
model: string;
|
|
552
|
+
carImage?: string;
|
|
553
|
+
category?: string;
|
|
554
|
+
/** Every category the cars in this listing belong to. Own fleet can have more than one. */
|
|
555
|
+
categories?: string[];
|
|
556
|
+
transmission?: string;
|
|
557
|
+
fuel?: string;
|
|
558
|
+
luggage?: number;
|
|
559
|
+
rates: RawRateOption[];
|
|
560
|
+
/** WheelSys price-quote references, one per rate (see Car.quoteIds). */
|
|
561
|
+
quoteId?: string[] | string;
|
|
562
|
+
pickUpBranch?: string;
|
|
563
|
+
returnBranch?: string;
|
|
564
|
+
supplier?: RawSupplier;
|
|
565
|
+
termsAndConditions?: string;
|
|
566
|
+
metadata?: RawListingMetadata;
|
|
567
|
+
}
|
|
568
|
+
interface RawOffer {
|
|
569
|
+
supplier?: string | RawSupplier;
|
|
570
|
+
available: boolean;
|
|
571
|
+
fleets: RawFleetListing[] | null;
|
|
572
|
+
pickBranch?: string | null;
|
|
573
|
+
returnBranch?: string | null;
|
|
574
|
+
cdpCode?: string | null;
|
|
575
|
+
/** CDP codes this search should badge as discounted - worked out by the core's search.availability action. */
|
|
576
|
+
discountCodes?: string[];
|
|
577
|
+
message?: string;
|
|
578
|
+
metadata?: {
|
|
579
|
+
supplierId?: string;
|
|
580
|
+
rentalDays?: number;
|
|
581
|
+
originResponse?: string;
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
/** How one source (a supplier, or the site's own cars) answered a search. */
|
|
585
|
+
interface SourceNotice {
|
|
586
|
+
source: string;
|
|
587
|
+
supplierName?: string;
|
|
588
|
+
/** The supplier's logo (from search_sources), when the site has one. */
|
|
589
|
+
logoUrl?: string;
|
|
590
|
+
status: string;
|
|
591
|
+
/** How many cars this source answered with (for status "ok"). */
|
|
592
|
+
count?: number;
|
|
593
|
+
/** A short reason for customers when this source has no cars to show (from the core). */
|
|
594
|
+
customerMessage?: string;
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Why the typed coupon's special rate is not shown to the signed-in customer
|
|
598
|
+
* (the site sends who is searching when its getCustomer knows): they used it
|
|
599
|
+
* as often as one customer may (COUPON_CUSTOMER_LIMIT), or it must be claimed
|
|
600
|
+
* first (COUPON_NOT_CLAIMED). `message` is written for customers.
|
|
601
|
+
*/
|
|
602
|
+
interface CouponNotice {
|
|
603
|
+
code: 'COUPON_CUSTOMER_LIMIT' | 'COUPON_NOT_CLAIMED' | (string & {});
|
|
604
|
+
message: string;
|
|
605
|
+
/** The code that was typed. */
|
|
606
|
+
couponCode: string;
|
|
607
|
+
}
|
|
608
|
+
interface OffersResult {
|
|
609
|
+
offers: RawOffer[];
|
|
610
|
+
sources?: SourceNotice[];
|
|
611
|
+
/** Set when the typed coupon's special rate was left out for this customer. */
|
|
612
|
+
couponNotice?: CouponNotice;
|
|
613
|
+
}
|
|
614
|
+
interface MapOffersOptions {
|
|
615
|
+
pickupLabel?: string;
|
|
616
|
+
}
|
|
617
|
+
declare function isOffersResult(value: unknown): value is OffersResult;
|
|
618
|
+
declare function mapOffersToCars(offers: RawOffer[], options?: MapOffersOptions): Car[];
|
|
619
|
+
|
|
620
|
+
/** Every field of `criteria` feeds the search, so the whole object is the
|
|
621
|
+
* cache key - two identical searches (e.g. the same trip re-opened within
|
|
622
|
+
* the 10-minute staleTime) hit the same cache entry and skip the round trip. */
|
|
623
|
+
declare function availabilityQueryKey(criteria: SearchCriteria): readonly ["availability", SearchCriteria];
|
|
624
|
+
/** How one source stands while a search runs: still asking, or answered. */
|
|
625
|
+
interface SourceProgress extends SourceNotice {
|
|
626
|
+
/** True until this source has answered (or failed). */
|
|
627
|
+
pending?: boolean;
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Searches every source for the trip.
|
|
631
|
+
*
|
|
632
|
+
* It first asks the site who to search (fleetbridge_search_sources), then
|
|
633
|
+
* searches each source on its own, all at the same time. Each time a
|
|
634
|
+
* source answers, `onProgress` gets the whole list again, so the page can
|
|
635
|
+
* tick that source off while the others are still being asked. The answer
|
|
636
|
+
* comes once every source has answered, with all their cars together, in
|
|
637
|
+
* the same shape one big search gives. `onProgress` also gets the offers
|
|
638
|
+
* found so far.
|
|
639
|
+
*
|
|
640
|
+
* A search for one supplier only (criteria.supplier, used when changing a
|
|
641
|
+
* booking), or a site whose plugin has no fleetbridge_search_sources yet,
|
|
642
|
+
* makes one request for everything, as before.
|
|
643
|
+
*/
|
|
644
|
+
declare function searchAvailability(criteria: SearchCriteria,
|
|
645
|
+
/**
|
|
646
|
+
* Called each time a source answers. `offers` is every offer so far (a new
|
|
647
|
+
* array each time), so an app can show cars while the search runs:
|
|
648
|
+
* `mapOffersToCars(offers)`.
|
|
649
|
+
*/
|
|
650
|
+
onProgress?: (sources: SourceProgress[], offers: RawOffer[]) => void): Promise<unknown>;
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Shared transport for every `*.queries.ts` file: all of them talk to
|
|
654
|
+
* FleetBridge the same way - send an action + fields through the transport
|
|
655
|
+
* the host set on FleetBridgeProvider (see transport.ts) and read back `{ success, data }` /
|
|
656
|
+
* `{ success: false, data: { message } }`.
|
|
657
|
+
*
|
|
658
|
+
* Before this, `extras.queries.ts` and `booking.queries.ts` each duplicated
|
|
659
|
+
* that POST-and-parse dance with slightly different error copy and no
|
|
660
|
+
* shared logging. Subclassing this gets every query the same "site not
|
|
661
|
+
* connected" / "couldn't reach the site" messages and the same
|
|
662
|
+
* `console.log`/`console.error` shape, so a network tab or console filtered
|
|
663
|
+
* on "[FleetBridge]" reads consistently across every query.
|
|
664
|
+
*/
|
|
665
|
+
|
|
666
|
+
declare abstract class BaseQuery {
|
|
667
|
+
/**
|
|
668
|
+
* Sends `action` + `fields` through the transport, which normalizes
|
|
669
|
+
* every possible outcome - unconfigured site, network failure, non-2xx
|
|
670
|
+
* response, `{success: false}` - into one `QueryResult`, so subclasses
|
|
671
|
+
* never branch on `response.ok` vs `payload.success` vs a thrown error
|
|
672
|
+
* differently from each other.
|
|
673
|
+
*/
|
|
674
|
+
protected post<T>(action: string, fields?: Record<string, string>): Promise<QueryResult<T>>;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Filtering, sorting and formatting for the results shortcode — kept out of
|
|
679
|
+
* the components so the whole filter model is readable in one place.
|
|
680
|
+
*/
|
|
681
|
+
|
|
682
|
+
interface Filters {
|
|
683
|
+
query: string;
|
|
684
|
+
makes: string[];
|
|
685
|
+
models: string[];
|
|
686
|
+
/** Body class (SMALL / MEDIUM / LARGE / PREMIUM) from supplier specs — not group codes. */
|
|
687
|
+
categories: string[];
|
|
688
|
+
fuels: string[];
|
|
689
|
+
suppliers: string[];
|
|
690
|
+
transmission: 'any' | 'Manual' | 'Automatic';
|
|
691
|
+
condition: 'any' | 'New' | 'Used';
|
|
692
|
+
seats: number | null;
|
|
693
|
+
luggage: number | null;
|
|
694
|
+
priceRange: [number, number];
|
|
695
|
+
yearRange: [number, number];
|
|
696
|
+
location: string;
|
|
697
|
+
availableOnly: boolean;
|
|
698
|
+
instantBook: boolean;
|
|
699
|
+
insuranceIncluded: boolean;
|
|
700
|
+
/**
|
|
701
|
+
* Free kilometres per day: null is any, a number keeps cars with at least
|
|
702
|
+
* that many km per day (unlimited counts as more than any number), and
|
|
703
|
+
* "unlimited" keeps only cars with unlimited km.
|
|
704
|
+
*/
|
|
705
|
+
mileage: MileageFilter;
|
|
706
|
+
sort: SortOption;
|
|
707
|
+
}
|
|
708
|
+
type MileageFilter = number | 'unlimited' | null;
|
|
709
|
+
type SortOption = 'recommended' | 'price-asc' | 'price-desc' | 'rating-desc' | 'year-desc';
|
|
710
|
+
declare const DEFAULT_FILTERS: Filters;
|
|
711
|
+
declare function priceBoundsFromCars(cars: Car[]): [number, number];
|
|
712
|
+
declare function formatZAR(amount: number): string;
|
|
713
|
+
interface ActiveChip {
|
|
714
|
+
id: string;
|
|
715
|
+
label: string;
|
|
716
|
+
clear: Partial<Filters>;
|
|
717
|
+
}
|
|
718
|
+
declare function activeChips(filters: Filters, bounds?: {
|
|
719
|
+
price: [number, number];
|
|
720
|
+
year: [number, number] | null;
|
|
721
|
+
}): ActiveChip[];
|
|
722
|
+
interface Driver {
|
|
723
|
+
title: string;
|
|
724
|
+
firstName: string;
|
|
725
|
+
lastName: string;
|
|
726
|
+
email: string;
|
|
727
|
+
phone: string;
|
|
728
|
+
licenceNumber: string;
|
|
729
|
+
notes: string;
|
|
730
|
+
/** Defaults to 'South Africa' - drives the phone dial-code prefix and the
|
|
731
|
+
* ID-number field's label ("SA ID number" vs "Passport number"). */
|
|
732
|
+
country: string;
|
|
733
|
+
/** SA ID number or passport number, label driven by `country` above. */
|
|
734
|
+
idNumber: string;
|
|
735
|
+
crossingBorder: boolean;
|
|
736
|
+
streetAddress: string;
|
|
737
|
+
city: string;
|
|
738
|
+
suburb: string;
|
|
739
|
+
province: string;
|
|
740
|
+
postalCode: string;
|
|
741
|
+
/** Optional second recipient for the booking confirmation. */
|
|
742
|
+
additionalEmail: string;
|
|
743
|
+
/**
|
|
744
|
+
* The phone number's dial code, for example "+44", when it differs from
|
|
745
|
+
* the country of residence's. Left out, the country's dial code is used.
|
|
746
|
+
*/
|
|
747
|
+
dialCode?: string;
|
|
748
|
+
}
|
|
749
|
+
declare const EMPTY_DRIVER: Driver;
|
|
750
|
+
interface QuoteLine {
|
|
751
|
+
id: string;
|
|
752
|
+
label: string;
|
|
753
|
+
/** Sub-label: how the amount was arrived at. */
|
|
754
|
+
detail?: string;
|
|
755
|
+
amount: number;
|
|
756
|
+
}
|
|
757
|
+
interface QuoteNote {
|
|
758
|
+
label: string;
|
|
759
|
+
value: string;
|
|
760
|
+
}
|
|
761
|
+
interface Quote {
|
|
762
|
+
days: number;
|
|
763
|
+
lines: QuoteLine[];
|
|
764
|
+
/** Things that will change the price but that this bundle can't put a number on. */
|
|
765
|
+
notes: QuoteNote[];
|
|
766
|
+
extrasTotal: number;
|
|
767
|
+
total: number;
|
|
768
|
+
/** Refundable card hold, not a charge - see PriceSummary's "Funds needed on card". */
|
|
769
|
+
deposit: number;
|
|
770
|
+
/** What the driver owes if the car is damaged. Not added to the rental price. */
|
|
771
|
+
excess: number;
|
|
772
|
+
}
|
|
1110
773
|
type PaymentPurpose = 'FULL' | 'DEPOSIT';
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Submits the booking wizard's booking to WordPress, which makes the real
|
|
777
|
+
* reservation with the supplier.
|
|
778
|
+
*
|
|
779
|
+
* The call still goes through admin-ajax rather than straight to
|
|
780
|
+
* FleetBridge, and for the original reason: creating a reservation needs the
|
|
781
|
+
* account's API key plus the supplier's own credentials in the request body
|
|
782
|
+
* (see apps/api/src/handlers/suppliers/booking.ts), and neither may ever
|
|
783
|
+
* live in front-end JavaScript. What changed is what the PHP handler does
|
|
784
|
+
* with the payload - it used to record an enquiry and fire an action for a
|
|
785
|
+
* site to forward itself; it now records the attempt in the tenant
|
|
786
|
+
* `Bookings` table and books it (see Frontend\BookingController).
|
|
787
|
+
*
|
|
788
|
+
* So the fields below carry everything the reservation needs and nothing the
|
|
789
|
+
* browser could be trusted to decide: the supplier's adapter identifier and
|
|
790
|
+
* pre-resolved branch codes, the vehicle group, and the rate/quote/CDP
|
|
791
|
+
* references from the search - all values FleetBridge itself produced. The
|
|
792
|
+
* handler re-resolves credentials and the active CDP code server-side.
|
|
793
|
+
*/
|
|
794
|
+
|
|
795
|
+
interface BookingRequest {
|
|
796
|
+
car: Car;
|
|
797
|
+
criteria: SearchCriteria;
|
|
798
|
+
driver: Driver;
|
|
799
|
+
selection: ExtraSelection;
|
|
800
|
+
/** Whichever catalogue `selection`'s codes were chosen from - live or static. */
|
|
801
|
+
extras: Extra[];
|
|
802
|
+
days: number;
|
|
803
|
+
total: number;
|
|
804
|
+
/**
|
|
805
|
+
* The resolved one-way drop-off fee, if any - `quoteFor`'s own
|
|
806
|
+
* `liveDropOffFee ?? car.dropOffFee` (see BookingWizard, which already
|
|
807
|
+
* computed this for the price breakdown the customer sees). Persisted on
|
|
808
|
+
* BookingRate, not folded into `extras` - see that field's own note in
|
|
809
|
+
* `bookingRequestFields` below.
|
|
810
|
+
*/
|
|
811
|
+
dropOffFee?: number | null;
|
|
812
|
+
/** `quoteFor`'s refundable deposit (Quote.deposit) - PriceSummary's "Funds
|
|
813
|
+
* needed on card", persisted on BookingRate alongside the drop-off fee. */
|
|
814
|
+
deposit?: number | null;
|
|
815
|
+
/** The published terms version shown on the review step, when this supplier has one. */
|
|
816
|
+
terms?: {
|
|
817
|
+
id: string;
|
|
818
|
+
version: number;
|
|
819
|
+
} | null;
|
|
820
|
+
/** How the customer pays, for the site's own cars (see payment.queries.ts). */
|
|
821
|
+
payment?: {
|
|
822
|
+
methodId: string;
|
|
823
|
+
purpose: PaymentPurpose;
|
|
824
|
+
/**
|
|
825
|
+
* Where the payment page sends the customer back to. When left out, the
|
|
826
|
+
* `paymentReturnUrl` option of bookingRequestFields / createBookingQueries
|
|
827
|
+
* supplies it (@fleetbridge/ui passes the current page).
|
|
828
|
+
*/
|
|
829
|
+
returnUrl?: string;
|
|
830
|
+
} | null;
|
|
831
|
+
}
|
|
832
|
+
/** Options for bookingRequestFields(), and for the query objects that call it. */
|
|
833
|
+
interface BookingFieldOptions {
|
|
834
|
+
/**
|
|
835
|
+
* Gives the payment return address for a request whose `payment` has no
|
|
836
|
+
* `returnUrl` of its own. Called only when the request has a payment.
|
|
837
|
+
*/
|
|
838
|
+
paymentReturnUrl?: () => string;
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Callbacks for a booking or quote request, called just before it is sent.
|
|
842
|
+
* Optional, and a no-op when left out. @fleetbridge/ui uses them to dispatch
|
|
843
|
+
* the `fleetbridge:booking-requested` / `fleetbridge:quote-requested` window
|
|
844
|
+
* events. A callback that throws does not stop the request.
|
|
845
|
+
*/
|
|
846
|
+
interface BookingHooks extends BookingFieldOptions {
|
|
847
|
+
onBookingRequested?: (request: BookingRequest) => void;
|
|
848
|
+
onQuoteRequested?: (request: BookingRequest) => void;
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* A booking of the site's own cars that is paid online. It is not confirmed
|
|
852
|
+
* yet: the customer goes to the payment page first (redirectUrl). When the
|
|
853
|
+
* page could not be opened, paymentError says why, and the token lets the
|
|
854
|
+
* customer try again.
|
|
855
|
+
*/
|
|
856
|
+
interface PendingPayment {
|
|
857
|
+
token: string;
|
|
858
|
+
redirectUrl?: string;
|
|
859
|
+
error?: string;
|
|
860
|
+
}
|
|
861
|
+
/** A confirmed reservation, as the confirmation step shows it. */
|
|
862
|
+
interface ConfirmedBooking {
|
|
863
|
+
/**
|
|
864
|
+
* The supplier's booking number - the only id THEY know this booking by,
|
|
865
|
+
* and so the one the customer quotes at the desk.
|
|
866
|
+
*/
|
|
867
|
+
reservationId: string;
|
|
868
|
+
/**
|
|
869
|
+
* FleetBridge's own PIN for the booking. Paired with the booking number
|
|
870
|
+
* it finds the booking on FleetBridge's side (the admin Bookings
|
|
871
|
+
* tab searches on it); the supplier has no idea what it is.
|
|
872
|
+
*/
|
|
873
|
+
bookingPin: string;
|
|
874
|
+
supplier: string;
|
|
875
|
+
/**
|
|
876
|
+
* Tenant / FleetBridge booking reference (`fb-booking-{uuid}`), generated
|
|
877
|
+
* before the supplier was called. Deliberately NOT displayed to customers.
|
|
878
|
+
*/
|
|
879
|
+
reference: string;
|
|
880
|
+
/**
|
|
881
|
+
* The tenant Customer row this booking was recorded against (see
|
|
882
|
+
* BookingController's upsert_customer call). Used to remember "this
|
|
883
|
+
* device belongs to this customer" for a return visit - see
|
|
884
|
+
* store/customerStore.ts.
|
|
885
|
+
*/
|
|
886
|
+
customerId?: string;
|
|
887
|
+
/** Set when the booking still has to be paid online. The booking number arrives once it is paid. */
|
|
888
|
+
payment?: PendingPayment;
|
|
889
|
+
}
|
|
890
|
+
type BookingResult = ({
|
|
891
|
+
ok: true;
|
|
892
|
+
} & ConfirmedBooking) | {
|
|
893
|
+
ok: false;
|
|
894
|
+
error: string;
|
|
895
|
+
/**
|
|
896
|
+
* Present when the attempt was recorded before it failed - the normal
|
|
897
|
+
* case, since the row is written before the supplier is called. Worth
|
|
898
|
+
* showing: a failed attempt has no reservation number, so this is the
|
|
899
|
+
* only handle on it, including when the reservation did in fact get
|
|
900
|
+
* created upstream.
|
|
901
|
+
*/
|
|
902
|
+
bookingPin?: string;
|
|
903
|
+
};
|
|
904
|
+
/**
|
|
905
|
+
* "Request a quote" never makes a reservation - see Tenant\Quote's own
|
|
906
|
+
* docblock (WordPress plugin) for why the request is emailed rather than
|
|
907
|
+
* booked immediately. Deliberately not `BookingResult`: there is no
|
|
908
|
+
* reservation number/PIN/supplier to show on success, only confirmation
|
|
909
|
+
* that the email went out.
|
|
910
|
+
*/
|
|
911
|
+
type QuoteRequestResult = {
|
|
912
|
+
ok: true;
|
|
913
|
+
message?: string;
|
|
914
|
+
} | {
|
|
915
|
+
ok: false;
|
|
916
|
+
error: string;
|
|
917
|
+
};
|
|
918
|
+
declare class BookingQueries extends BaseQuery {
|
|
919
|
+
private readonly hooks;
|
|
920
|
+
constructor(hooks?: BookingHooks);
|
|
921
|
+
/**
|
|
922
|
+
* Posts the booking to the host site. Calls `onBookingRequested` first,
|
|
923
|
+
* either way (@fleetbridge/ui turns it into the
|
|
924
|
+
* `fleetbridge:booking-requested` window event, so a theme that would
|
|
925
|
+
* rather handle bookings itself can listen instead).
|
|
926
|
+
*/
|
|
927
|
+
submitBooking(request: BookingRequest): Promise<BookingResult>;
|
|
928
|
+
/**
|
|
929
|
+
* Posts a "Request a quote" - same fields as `submitBooking()` (it's the
|
|
930
|
+
* same wizard, just ending here instead of at "Confirm booking"), but
|
|
931
|
+
* WordPress records it as a Quote and emails it rather than calling the
|
|
932
|
+
* supplier - see Tenant\Quote's own docblock. Calls `onQuoteRequested`
|
|
933
|
+
* first (in @fleetbridge/ui, the `fleetbridge:quote-requested` window
|
|
934
|
+
* event, the quote-mode counterpart of `fleetbridge:booking-requested`).
|
|
935
|
+
*/
|
|
936
|
+
requestQuote(request: BookingRequest): Promise<QuoteRequestResult>;
|
|
937
|
+
/** The terms version this supplier's customers agree to now. Null when none is published, or when they could not be loaded (see supplierTermsResult()). */
|
|
938
|
+
supplierTerms(identifier: string): Promise<SupplierTerms | null>;
|
|
939
|
+
/** Like supplierTerms(), but a failure comes back as `{ ok: false }` instead of looking like "no terms". */
|
|
940
|
+
supplierTermsResult(identifier: string): Promise<SupplierTermsResult>;
|
|
941
|
+
}
|
|
942
|
+
/** A supplier's published terms. */
|
|
943
|
+
interface SupplierTerms {
|
|
944
|
+
id: string;
|
|
945
|
+
version: number;
|
|
946
|
+
html: string;
|
|
947
|
+
}
|
|
948
|
+
/** supplierTermsResult()'s answer: the terms (null when none is published), or why they could not be loaded. */
|
|
949
|
+
type SupplierTermsResult = {
|
|
950
|
+
ok: true;
|
|
951
|
+
terms: SupplierTerms | null;
|
|
952
|
+
} | {
|
|
953
|
+
ok: false;
|
|
954
|
+
error: string;
|
|
955
|
+
status?: number;
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
type ManagedBookingStatus = 'PENDING'
|
|
959
|
+
/** Booked, waiting for the online payment. */
|
|
960
|
+
| 'PAYMENT_PENDING'
|
|
961
|
+
/** The supplier did not confirm it. */
|
|
962
|
+
| 'FAILED' | 'CONFIRMED' | 'PICKED_UP' | 'RETURNED' | 'CANCELLED' | 'RECONCILED' | 'NO_SHOW';
|
|
963
|
+
/** One selected add-on, as `BookingExtra` rows come back formatted. */
|
|
964
|
+
interface ManagedBookingExtra {
|
|
965
|
+
code: string;
|
|
966
|
+
name: string;
|
|
967
|
+
quantity: number;
|
|
968
|
+
unitPrice: number | null;
|
|
969
|
+
currency: string;
|
|
970
|
+
}
|
|
971
|
+
interface ManagedBookingVehicle {
|
|
972
|
+
group: string | null;
|
|
973
|
+
name: string | null;
|
|
974
|
+
image: string | null;
|
|
975
|
+
supplierLogo: string | null;
|
|
976
|
+
seats: number | null;
|
|
977
|
+
doors: number | null;
|
|
978
|
+
transmission: string | null;
|
|
979
|
+
fuelType: string | null;
|
|
980
|
+
insuranceIncluded: boolean | null;
|
|
981
|
+
ratePackageLabel: string | null;
|
|
982
|
+
unlimitedMileage?: boolean | null;
|
|
983
|
+
kmPerDay?: number | null;
|
|
984
|
+
}
|
|
985
|
+
interface ManagedBookingCustomer {
|
|
986
|
+
name: string | null;
|
|
987
|
+
firstName?: string | null;
|
|
988
|
+
lastName?: string | null;
|
|
989
|
+
title?: string | null;
|
|
990
|
+
email: string | null;
|
|
991
|
+
additionalEmail?: string | null;
|
|
992
|
+
phone: string | null;
|
|
993
|
+
dialCode?: string | null;
|
|
994
|
+
idNumber?: string | null;
|
|
995
|
+
idType?: string | null;
|
|
996
|
+
licenseNumber?: string | null;
|
|
997
|
+
country?: string | null;
|
|
998
|
+
streetAddress?: string | null;
|
|
999
|
+
suburb?: string | null;
|
|
1000
|
+
city?: string | null;
|
|
1001
|
+
province?: string | null;
|
|
1002
|
+
postalCode?: string | null;
|
|
1003
|
+
}
|
|
1004
|
+
/** How a booking was priced, as the site stored it. Amounts in rands. */
|
|
1005
|
+
interface ManagedBookingRate {
|
|
1006
|
+
/** The vehicle line only. */
|
|
1007
|
+
amount?: number | null;
|
|
1008
|
+
dailyRate?: number | null;
|
|
1009
|
+
days?: number | null;
|
|
1010
|
+
ratePackageLabel?: string | null;
|
|
1011
|
+
extrasTotal?: number | null;
|
|
1012
|
+
dropOffFee?: number | null;
|
|
1013
|
+
deposit?: number | null;
|
|
1014
|
+
total?: number | null;
|
|
1015
|
+
currency?: string | null;
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Matches ActionController::booking_view()'s shape -
|
|
1019
|
+
* that method redacts BookingStore::format_row()'s output down to this
|
|
1020
|
+
* (stripping only a handful of internal-only keys) rather than re-listing
|
|
1021
|
+
* every field, so this type is the same "whatever format_row() returns,
|
|
1022
|
+
* minus a short deny-list" contract, not a hand-picked subset.
|
|
1023
|
+
*/
|
|
1024
|
+
interface ManagedBooking {
|
|
1025
|
+
supplierRef: string | null;
|
|
1026
|
+
status: ManagedBookingStatus;
|
|
1027
|
+
supplierStatus: string | null;
|
|
1028
|
+
failureReason: string | null;
|
|
1029
|
+
supplierName: string | null;
|
|
1030
|
+
vehicle: ManagedBookingVehicle;
|
|
1031
|
+
pickupLocation: string | null;
|
|
1032
|
+
dropoffLocation: string | null;
|
|
1033
|
+
pickupDate: string | null;
|
|
1034
|
+
dropoffDate: string | null;
|
|
1035
|
+
rentalDays: number | null;
|
|
1036
|
+
extras: ManagedBookingExtra[];
|
|
1037
|
+
totalPrice: number;
|
|
1038
|
+
currency: string;
|
|
1039
|
+
/** The priced parts of the booking (the site's BookingRate row), when it has one. */
|
|
1040
|
+
rate?: ManagedBookingRate | null;
|
|
1041
|
+
customer: ManagedBookingCustomer;
|
|
1042
|
+
cdpCode: string | null;
|
|
1043
|
+
quoteRef: string | null;
|
|
1044
|
+
rateId: string | null;
|
|
1045
|
+
/** Adapter identifier ("hertz", "bluu", …) — amend re-search is locked to this supplier. */
|
|
1046
|
+
supplierIdentifier: string | null;
|
|
1047
|
+
crossBorder: boolean;
|
|
1048
|
+
notes: string | null;
|
|
1049
|
+
source: string | null;
|
|
1050
|
+
cancelledAt: string | null;
|
|
1051
|
+
cancellationReason: string | null;
|
|
1052
|
+
createdAt: string | null;
|
|
1053
|
+
/** Both gate on `status === 'CONFIRMED'` server-side - see customer_view(). */
|
|
1054
|
+
canCancel: boolean;
|
|
1055
|
+
canAmend: boolean;
|
|
1056
|
+
}
|
|
1057
|
+
interface QuotedQuote {
|
|
1058
|
+
quoteRef: string;
|
|
1059
|
+
status: 'PENDING' | 'CONFIRMED' | 'EXPIRED' | 'CANCELLED';
|
|
1060
|
+
expiresAt: string | null;
|
|
1061
|
+
supplierName: string | null;
|
|
1062
|
+
vehicle: ManagedBookingVehicle;
|
|
1063
|
+
pickupLocation: string | null;
|
|
1064
|
+
dropoffLocation: string | null;
|
|
1065
|
+
pickupDate: string | null;
|
|
1066
|
+
dropoffDate: string | null;
|
|
1067
|
+
rentalDays: number | null;
|
|
1068
|
+
extras: ManagedBookingExtra[];
|
|
1069
|
+
priceBreakdown: {
|
|
1070
|
+
label: string;
|
|
1071
|
+
amount: number;
|
|
1072
|
+
}[];
|
|
1073
|
+
totalPrice: number;
|
|
1074
|
+
currency: string;
|
|
1075
|
+
deposit: number | null;
|
|
1076
|
+
customer: ManagedBookingCustomer;
|
|
1077
|
+
notes: string | null;
|
|
1078
|
+
crossBorder?: boolean;
|
|
1079
|
+
}
|
|
1080
|
+
/** The flat shape `ajax_confirm_quote()` returns on success - the same
|
|
1081
|
+
* create-booking result shape a fresh booking gets, not a full `ManagedBooking`
|
|
1082
|
+
* (that needs a follow-up `lookup()` call - see ManageBooking's own confirm-quote effect). */
|
|
1083
|
+
interface ConfirmedQuoteBooking {
|
|
1084
|
+
reference: string;
|
|
1085
|
+
reservationId: string;
|
|
1086
|
+
bookingPin: string;
|
|
1087
|
+
supplier: string;
|
|
1088
|
+
status: string;
|
|
1089
|
+
customerId?: string;
|
|
1090
|
+
}
|
|
1091
|
+
declare class BookingManagementQueries extends BaseQuery {
|
|
1092
|
+
private readonly options;
|
|
1093
|
+
/** `options.paymentReturnUrl` feeds amend()'s booking fields (see bookingRequestFields). */
|
|
1094
|
+
constructor(options?: BookingFieldOptions);
|
|
1095
|
+
lookup(reservationNumber: string, bookingPin: string): Promise<QueryResult<{
|
|
1096
|
+
booking: ManagedBooking;
|
|
1097
|
+
}>>;
|
|
1098
|
+
cancel(reservationNumber: string, bookingPin: string, reason: string): Promise<QueryResult<{
|
|
1099
|
+
booking: ManagedBooking;
|
|
1100
|
+
}>>;
|
|
1101
|
+
/**
|
|
1102
|
+
* Load a pending quote for review. The email link calls this first; Book
|
|
1103
|
+
* on that screen then calls `confirmQuote()`.
|
|
1104
|
+
*/
|
|
1105
|
+
lookupQuote(token: string): Promise<QueryResult<{
|
|
1106
|
+
quote: QuotedQuote;
|
|
1107
|
+
}>>;
|
|
1108
|
+
/**
|
|
1109
|
+
* Turns a pending Quote into a real reservation after the customer has
|
|
1110
|
+
* reviewed it and clicked Book. The caller still needs its own `lookup()`
|
|
1111
|
+
* afterwards for the full `ManagedBooking` shape the rest of this drawer
|
|
1112
|
+
* expects.
|
|
1113
|
+
*/
|
|
1114
|
+
confirmQuote(token: string): Promise<QueryResult<ConfirmedQuoteBooking>>;
|
|
1115
|
+
/**
|
|
1116
|
+
* Re-search submit: same payload as a new booking, plus the reservation
|
|
1117
|
+
* number + PIN that prove ownership. If the supplier doesn't support
|
|
1118
|
+
* amending online (AdapterCapabilities.amendBooking), this fails with a
|
|
1119
|
+
* plain message rather than a structured code.
|
|
1120
|
+
*/
|
|
1121
|
+
amend(reservationNumber: string, bookingPin: string, request: BookingRequest): Promise<(BookingResult & {
|
|
1122
|
+
booking?: ManagedBooking;
|
|
1123
|
+
})>;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
/**
|
|
1127
|
+
* How the results page sits on the host page.
|
|
1128
|
+
*
|
|
1129
|
+
* `boxed` (the default) draws the summary bar and the filter rail as cards
|
|
1130
|
+
* inside a content column. `flush` drops the cards for hairlines, so a site
|
|
1131
|
+
* can attach the summary to its own header and run the results full width.
|
|
1132
|
+
*/
|
|
1133
|
+
type ResultsLayout = 'boxed' | 'flush';
|
|
1134
|
+
/**
|
|
1135
|
+
* The search summary, and the form behind it.
|
|
1136
|
+
*
|
|
1137
|
+
* Collapsed it's a single line of criteria; "Modify search" expands the same
|
|
1138
|
+
* form the search shortcode uses, and submitting re-searches in place. Nothing
|
|
1139
|
+
* about the criteria needs a round trip today, so reloading here would only
|
|
1140
|
+
* cost the user their filters and their place in the list.
|
|
1141
|
+
*/
|
|
1142
|
+
declare function SearchBar({ criteria, days, editing, onToggleEditing, onSubmit, layout, prompt, needsDates, }: {
|
|
1143
|
+
criteria: SearchCriteria;
|
|
1144
|
+
days: number;
|
|
1145
|
+
editing: boolean;
|
|
1146
|
+
onToggleEditing: () => void;
|
|
1147
|
+
onSubmit: (criteria: SearchCriteria) => void;
|
|
1148
|
+
layout?: ResultsLayout;
|
|
1149
|
+
/** A line above the open form, e.g. "Choose your dates to see cars at Sandton". */
|
|
1150
|
+
prompt?: string | null;
|
|
1151
|
+
/** The page has no usable trip yet: the summary asks for dates and the form searches instead of updating. */
|
|
1152
|
+
needsDates?: boolean;
|
|
1153
|
+
}): react_jsx_runtime.JSX.Element;
|
|
1154
|
+
|
|
1155
|
+
interface ResultsPageProps {
|
|
1156
|
+
/** Passed through to every card's CTA - see CarCard's `bookingUrl`. */
|
|
1157
|
+
bookingUrl?: string;
|
|
1158
|
+
/** How the cars are laid out: the site owner's choice, or the shortcode's (see lib/widget.styles.ts). */
|
|
1159
|
+
listStyle?: ListStyle;
|
|
1160
|
+
/**
|
|
1161
|
+
* `boxed` (default): the summary and filters as cards in a content column.
|
|
1162
|
+
* `flush`: hairlines instead of cards, for a full-width page whose header
|
|
1163
|
+
* carries the summary (see `summaryContainer`).
|
|
1164
|
+
*/
|
|
1165
|
+
layout?: ResultsLayout;
|
|
1166
|
+
/**
|
|
1167
|
+
* Where to draw the search summary and its Modify search form, for example
|
|
1168
|
+
* a row in the site's own sticky header. Left out, it sits above the results.
|
|
1169
|
+
*/
|
|
1170
|
+
summaryContainer?: HTMLElement | null;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
interface ManageBookingProps {
|
|
1174
|
+
/** Renders an on-page "Manage my booking" trigger card that opens the
|
|
1175
|
+
* lookup dialog - only meaningful where [fleetbridge_manage_booking] was
|
|
1176
|
+
* deliberately placed on a page (see the shortcode's own
|
|
1177
|
+
* `data-show-trigger` attribute). The wp_footer fallback mount that makes
|
|
1178
|
+
* a `#manage=booking&id=&pin=` link work from *any* page renders this
|
|
1179
|
+
* component without it - there, the drawer opening itself straight from the
|
|
1180
|
+
* URL is the entire interaction. */
|
|
1181
|
+
showTrigger?: boolean;
|
|
1182
|
+
/** How the cars are laid out when changing a booking (the site owner's choice on the Theme page). */
|
|
1183
|
+
listStyle?: ListStyle;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
/**
|
|
1187
|
+
* Theming. Every colour the UI paints comes from a CSS custom property, so a
|
|
1188
|
+
* host restyles it without touching the package:
|
|
1189
|
+
*
|
|
1190
|
+
* - The base palette (shadcn names): --primary, --primary-foreground,
|
|
1191
|
+
* --accent, --background, --foreground, --muted, --border, --ring, --radius…
|
|
1192
|
+
* - The font: --fb-font-sans.
|
|
1193
|
+
* - Per-surface tokens (--fb-search-*, --fb-listing-*, --fb-car-*,
|
|
1194
|
+
* --fb-filter-*, --fb-wizard-*), which default to the base palette - see
|
|
1195
|
+
* styles/public-tokens.css for the full list.
|
|
1196
|
+
*
|
|
1197
|
+
* `FleetBridgeTheme` is a typed shortcut for the common ones, `colors` sets any
|
|
1198
|
+
* element's own colour by name, and anything else goes in `vars`. Pass it to <FleetBridgeProvider theme={…}>, or print
|
|
1199
|
+
* themeToCss(theme) in a <style> tag (best for server-rendered pages), or set
|
|
1200
|
+
* the properties in your own stylesheet.
|
|
1201
|
+
*/
|
|
1202
|
+
/**
|
|
1203
|
+
* Every colour a site owner can set, one per surface token - the same keys
|
|
1204
|
+
* and custom properties as the WordPress plugin's Theme tab
|
|
1205
|
+
* (ThemeController::COLOR_FIELDS / ShortcodeController::COLOR_VARS), so a
|
|
1206
|
+
* theme saved there or in another host's settings maps one-to-one.
|
|
1207
|
+
*/
|
|
1208
|
+
declare const THEME_COLOR_VARS: {
|
|
1209
|
+
readonly primary: "--primary";
|
|
1210
|
+
readonly primaryForeground: "--primary-foreground";
|
|
1211
|
+
readonly background: "--background";
|
|
1212
|
+
readonly card: "--card";
|
|
1213
|
+
readonly cardForeground: "--card-foreground";
|
|
1214
|
+
readonly border: "--border";
|
|
1215
|
+
readonly foreground: "--foreground";
|
|
1216
|
+
readonly mutedForeground: "--muted-foreground";
|
|
1217
|
+
readonly muted: "--muted";
|
|
1218
|
+
readonly input: "--input";
|
|
1219
|
+
readonly secondary: "--secondary";
|
|
1220
|
+
readonly secondaryForeground: "--secondary-foreground";
|
|
1221
|
+
readonly searchSurface: "--fb-search-surface";
|
|
1222
|
+
readonly searchBorder: "--fb-search-border";
|
|
1223
|
+
readonly searchField: "--fb-search-field";
|
|
1224
|
+
readonly searchLabel: "--fb-search-label";
|
|
1225
|
+
readonly searchValue: "--fb-search-value";
|
|
1226
|
+
readonly searchButton: "--fb-search-button";
|
|
1227
|
+
readonly searchButtonFg: "--fb-search-button-fg";
|
|
1228
|
+
readonly searchToggle: "--fb-search-toggle";
|
|
1229
|
+
readonly searchToggleFg: "--fb-search-toggle-fg";
|
|
1230
|
+
readonly listingBar: "--fb-listing-bar";
|
|
1231
|
+
readonly listingBorder: "--fb-listing-border";
|
|
1232
|
+
readonly listingText: "--fb-listing-text";
|
|
1233
|
+
readonly listingMuted: "--fb-listing-muted";
|
|
1234
|
+
readonly listingModifyBg: "--fb-listing-modify";
|
|
1235
|
+
readonly listingModifyBorder: "--fb-listing-modify-border";
|
|
1236
|
+
readonly listingChip: "--fb-listing-chip";
|
|
1237
|
+
readonly listingChipFg: "--fb-listing-chip-fg";
|
|
1238
|
+
readonly listingSidebar: "--fb-listing-sidebar";
|
|
1239
|
+
readonly carBg: "--fb-car-bg";
|
|
1240
|
+
readonly carBorder: "--fb-car-border";
|
|
1241
|
+
readonly carBorderHover: "--fb-car-border-hover";
|
|
1242
|
+
readonly carTitle: "--fb-car-title";
|
|
1243
|
+
readonly carMuted: "--fb-car-muted";
|
|
1244
|
+
readonly carPhoto: "--fb-car-photo";
|
|
1245
|
+
readonly carPrice: "--fb-car-price";
|
|
1246
|
+
readonly carCta: "--fb-car-cta";
|
|
1247
|
+
readonly carCtaFg: "--fb-car-cta-fg";
|
|
1248
|
+
readonly carQuoteBorder: "--fb-car-quote-border";
|
|
1249
|
+
readonly carBadge: "--fb-car-badge";
|
|
1250
|
+
readonly carBadgeFg: "--fb-car-badge-fg";
|
|
1251
|
+
readonly carInsured: "--fb-car-insured";
|
|
1252
|
+
readonly carInsuredFg: "--fb-car-insured-fg";
|
|
1253
|
+
readonly carOption: "--fb-car-option";
|
|
1254
|
+
readonly carOptionFg: "--fb-car-option-fg";
|
|
1255
|
+
readonly filterTitle: "--fb-filter-title";
|
|
1256
|
+
readonly filterMuted: "--fb-filter-muted";
|
|
1257
|
+
readonly filterPill: "--fb-filter-pill";
|
|
1258
|
+
readonly filterPillFg: "--fb-filter-pill-fg";
|
|
1259
|
+
readonly filterPillActive: "--fb-filter-pill-active";
|
|
1260
|
+
readonly filterPillActiveFg: "--fb-filter-pill-active-fg";
|
|
1261
|
+
readonly filterBar: "--fb-filter-bar";
|
|
1262
|
+
readonly surface2: "--fb-surface-2";
|
|
1263
|
+
readonly borderStrong: "--fb-border-strong";
|
|
1264
|
+
readonly ring: "--ring";
|
|
1265
|
+
readonly destructive: "--destructive";
|
|
1266
|
+
};
|
|
1267
|
+
type ThemeColorKey = keyof typeof THEME_COLOR_VARS;
|
|
1268
|
+
interface FleetBridgeTheme {
|
|
1269
|
+
/** The main brand colour: search button, selected states, CTAs. */
|
|
1270
|
+
primary?: string;
|
|
1271
|
+
primaryForeground?: string;
|
|
1272
|
+
/** The highlight colour: the "Book"/"View deal" buttons and filter bars. */
|
|
1273
|
+
accent?: string;
|
|
1274
|
+
accentForeground?: string;
|
|
1275
|
+
background?: string;
|
|
1276
|
+
foreground?: string;
|
|
1277
|
+
/** Field backgrounds and quiet surfaces. */
|
|
1278
|
+
muted?: string;
|
|
1279
|
+
mutedForeground?: string;
|
|
1280
|
+
border?: string;
|
|
1281
|
+
ring?: string;
|
|
1282
|
+
/** Corner radius, e.g. "12px" or "0.75rem". */
|
|
1283
|
+
radius?: string;
|
|
1284
|
+
/** Font stack, e.g. "Inter, system-ui, sans-serif". The host page loads the font. */
|
|
1285
|
+
fontFamily?: string;
|
|
1286
|
+
/**
|
|
1287
|
+
* Per-element colours (search form, results bar, car cards, filters,
|
|
1288
|
+
* wizard…), keyed as on the WordPress Theme tab. Set ones win over the
|
|
1289
|
+
* shortcuts above; unset ones follow them.
|
|
1290
|
+
*/
|
|
1291
|
+
colors?: Partial<Record<ThemeColorKey, string>>;
|
|
1292
|
+
/** Any other custom property, e.g. { '--fb-wizard-selected': '#153673' }. */
|
|
1293
|
+
vars?: Record<string, string>;
|
|
1294
|
+
}
|
|
1295
|
+
declare function themeToVars(theme: FleetBridgeTheme): Record<string, string>;
|
|
1296
|
+
/** The theme as a `:root { … }` rule, for a server-rendered <style> tag. */
|
|
1297
|
+
declare function themeToCss(theme: FleetBridgeTheme, selector?: string): string;
|
|
1298
|
+
|
|
1299
|
+
/** How long a cached search/quote survives, both as staleTime and as the persisted ceiling. */
|
|
1300
|
+
declare const CACHE_MS: number;
|
|
1301
|
+
interface FleetBridgeConfig {
|
|
1302
|
+
/** Where the search form sends the customer (the page that renders <ResultsPage />). */
|
|
1303
|
+
resultsUrl: string;
|
|
1304
|
+
/** The page that renders <ManageBooking />. */
|
|
1305
|
+
manageUrl?: string;
|
|
1306
|
+
/** Where the customer comes back to after paying online. Defaults to the results page. */
|
|
1307
|
+
paymentReturnUrl?: string;
|
|
1308
|
+
/** Passed to every car card's CTA, when the site has its own booking page. */
|
|
1309
|
+
bookingUrl?: string;
|
|
1310
|
+
}
|
|
1311
|
+
/** The URLs the host gave FleetBridgeProvider. */
|
|
1312
|
+
declare function useFleetBridgeConfig(): FleetBridgeConfig;
|
|
1313
|
+
interface FleetBridgeProviderProps extends Partial<FleetBridgeConfig> {
|
|
1314
|
+
/** How the UI reaches the host site: wordpressTransport(…) or httpTransport(…). */
|
|
1315
|
+
transport: FleetBridgeTransport;
|
|
1316
|
+
/** Bring your own QueryClient to share a cache with the rest of the app. */
|
|
1317
|
+
queryClient?: QueryClient;
|
|
1318
|
+
/** Keep successful searches/quotes in localStorage for CACHE_MS, so a page refresh is instant. Default true. */
|
|
1319
|
+
persistCache?: boolean;
|
|
1320
|
+
/** The look of each booking part (filters, steps, extras, price, confirmation, find-booking). */
|
|
1321
|
+
looks?: Partial<Looks>;
|
|
1322
|
+
/**
|
|
1323
|
+
* Brand colours, radius and font. Written as CSS custom properties on
|
|
1324
|
+
* :root while the provider is mounted (portalled dialogs live on <body>,
|
|
1325
|
+
* so the tokens have to be inheritable from the root). For a flash-free
|
|
1326
|
+
* first paint, also print themeToCss(theme) in a <style> tag on the server.
|
|
1327
|
+
*/
|
|
1328
|
+
theme?: FleetBridgeTheme;
|
|
1329
|
+
/** Render the toast viewport. Default true. Turn off if the host already renders @fleetbridge/components' <Toaster />. */
|
|
1330
|
+
toaster?: boolean;
|
|
1331
|
+
children: ReactNode;
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Everything the FleetBridge components need around them: the transport,
|
|
1335
|
+
* the query cache, tooltips, toasts, looks, theme and page URLs. Mount it
|
|
1336
|
+
* once (or once per island) around any FleetBridge component.
|
|
1337
|
+
*/
|
|
1338
|
+
declare function FleetBridgeProvider({ transport, queryClient, persistCache, looks, theme, toaster, resultsUrl, manageUrl, paymentReturnUrl, bookingUrl, children, }: FleetBridgeProviderProps): react_jsx_runtime.JSX.Element;
|
|
1339
|
+
/** True once running in the browser, after hydration. */
|
|
1340
|
+
declare function useIsClient(): boolean;
|
|
1341
|
+
/** Renders `fallback` on the server and during hydration, then the component. */
|
|
1342
|
+
declare function clientOnly<P extends object>(Component: ComponentType<P>, displayName: string): {
|
|
1343
|
+
(props: P & {
|
|
1344
|
+
fallback?: ReactNode;
|
|
1345
|
+
}): react_jsx_runtime.JSX.Element;
|
|
1346
|
+
displayName: string;
|
|
1347
|
+
};
|
|
1348
|
+
|
|
1349
|
+
/**
|
|
1350
|
+
* The colours a site owner can change, grouped and worded for a settings
|
|
1351
|
+
* screen: the WordPress plugin's Theme tab and any other host's (e.g. the
|
|
1352
|
+
* Carhire Studio's Booking look → Colours) use the same list, so a theme
|
|
1353
|
+
* means the same thing everywhere. Plain data, importing nothing but
|
|
1354
|
+
* ../theme (which imports nothing), so a host's server can bundle it without
|
|
1355
|
+
* the React components.
|
|
1356
|
+
*
|
|
1357
|
+
* Store only the colours that were changed ({colors, radius}, see
|
|
1358
|
+
* BookingTheme) and pass them as `FleetBridgeTheme.colors` / `radius`.
|
|
1359
|
+
*/
|
|
1360
|
+
|
|
1361
|
+
declare const THEME_KEYS: ThemeColorKey[];
|
|
1362
|
+
/** FleetBridge's own starting colours, for anything neither the brand nor its parent token sets. */
|
|
1363
|
+
declare const FLEETBRIDGE_DEFAULTS: Record<ThemeColorKey, string>;
|
|
1364
|
+
/** A part's colours follow this token until they are changed (FleetBridge's CSS fallbacks). */
|
|
1365
|
+
declare const THEME_INHERIT: Partial<Record<ThemeColorKey, ThemeColorKey>>;
|
|
1366
|
+
type ThemeField = {
|
|
1367
|
+
key: ThemeColorKey;
|
|
1368
|
+
label: string;
|
|
1369
|
+
hint?: string;
|
|
1370
|
+
};
|
|
1371
|
+
type ThemeSection = {
|
|
1372
|
+
title: string;
|
|
1373
|
+
fields: ThemeField[];
|
|
1374
|
+
};
|
|
1375
|
+
type ThemeGroup = {
|
|
1376
|
+
id: 'brand' | 'search' | 'listing' | 'filters' | 'card';
|
|
1377
|
+
title: string; /** A Remix icon class, for hosts that use Remix icons. */
|
|
1378
|
+
icon: string;
|
|
1379
|
+
description: string;
|
|
1380
|
+
sections: ThemeSection[];
|
|
1381
|
+
};
|
|
1382
|
+
/** The Theme tab's groups, in its order and wording. `icon` is a Remix icon class for the Studio. */
|
|
1383
|
+
declare const THEME_GROUPS: ThemeGroup[];
|
|
1384
|
+
/** One-click brand colours for a settings screen. */
|
|
1385
|
+
declare const THEME_PRESETS: {
|
|
1386
|
+
name: string;
|
|
1387
|
+
primary: string;
|
|
1388
|
+
primaryForeground: string;
|
|
1389
|
+
}[];
|
|
1390
|
+
/** Corner radius choices in px (the Theme tab allows 0–40px). */
|
|
1391
|
+
declare const THEME_RADII: number[];
|
|
1392
|
+
type BookingTheme = {
|
|
1393
|
+
colors?: Partial<Record<ThemeColorKey, string>> | null;
|
|
1394
|
+
radius?: number | null;
|
|
1395
|
+
};
|
|
1396
|
+
declare const isHex: (v: unknown) => v is string;
|
|
1397
|
+
/** A stored or posted theme with anything unknown or malformed dropped. */
|
|
1398
|
+
declare function cleanBookingTheme(raw: unknown): BookingTheme;
|
|
1399
|
+
/**
|
|
1400
|
+
* What each colour shows as when it has not been changed: the site's brand
|
|
1401
|
+
* values (`base`), else the token it follows, else FleetBridge's default.
|
|
1402
|
+
*/
|
|
1403
|
+
declare function effectiveColors(base: Partial<Record<ThemeColorKey, string>>, overrides?: Partial<Record<ThemeColorKey, string>>): Record<ThemeColorKey, string>;
|
|
1404
|
+
|
|
1405
|
+
interface SearchPanelProps {
|
|
1406
|
+
/** Pre-fills the form - the results page passes the criteria from the URL. */
|
|
1407
|
+
initialCriteria?: SearchCriteria;
|
|
1408
|
+
onSubmit: (criteria: SearchCriteria) => void;
|
|
1409
|
+
submitLabel?: string;
|
|
1410
|
+
/**
|
|
1411
|
+
* Which look to use (see lib/widget.styles.ts). The results page's Modify
|
|
1412
|
+
* search drawer and the amend flow always use the bar.
|
|
1413
|
+
*/
|
|
1414
|
+
style?: SearchStyle;
|
|
1415
|
+
/**
|
|
1416
|
+
* For the bar only. `card` is the standalone shortcode: a soft shadow and a
|
|
1417
|
+
* short fade in. `bare` is the same bar without that, for the results
|
|
1418
|
+
* page's Modify search drawer.
|
|
1419
|
+
*/
|
|
1420
|
+
variant?: 'card' | 'bare';
|
|
1421
|
+
/** The headline of the hero and sidebar styles. An empty string hides it. */
|
|
1422
|
+
title?: string;
|
|
1423
|
+
/** The line under the hero headline. An empty string hides it. */
|
|
1424
|
+
subtitle?: string;
|
|
1425
|
+
className?: string;
|
|
1426
|
+
/**
|
|
1427
|
+
* `Date.now()` when the currently-applied search (the one `initialCriteria`
|
|
1428
|
+
* reflects) last actually ran - only meaningful alongside submitLabel="Update".
|
|
1429
|
+
*/
|
|
1430
|
+
resultsFetchedAt?: number;
|
|
1431
|
+
}
|
|
1432
|
+
/**
|
|
1433
|
+
* The search form, in the look the site owner chose. Every look shares one
|
|
1434
|
+
* form (useSearchForm), so they check, remember and send a search the same
|
|
1435
|
+
* way; they only place the fields differently.
|
|
1436
|
+
*/
|
|
1437
|
+
declare function SearchPanel({ initialCriteria, onSubmit, submitLabel, style, variant, title, subtitle, className, resultsFetchedAt, }: SearchPanelProps): react_jsx_runtime.JSX.Element;
|
|
1438
|
+
|
|
1439
|
+
/** A location the picker can search - one entry per branch NAME, already
|
|
1440
|
+
* merged server-side (see fleetbridge.php's ajax_public_branches) since the
|
|
1441
|
+
* same name can exist under more than one supplier. The form searches by
|
|
1442
|
+
* name; ajax_search_availability() resolves each active supplier's own
|
|
1443
|
+
* branch code for that name at search time (a code means nothing outside
|
|
1444
|
+
* the supplier it belongs to). */
|
|
1445
|
+
interface BranchLocation {
|
|
1446
|
+
name: string;
|
|
1447
|
+
region: string;
|
|
1448
|
+
isAirportBranch: boolean;
|
|
1449
|
+
isInternational: boolean;
|
|
1450
|
+
/** The branch's street address, when the catalogue has one. Searchable. */
|
|
1451
|
+
address?: string;
|
|
1452
|
+
}
|
|
1453
|
+
interface LocationOption {
|
|
1454
|
+
value: string;
|
|
1455
|
+
label: string;
|
|
1456
|
+
icon?: LucideIcon;
|
|
1457
|
+
/** A second line under the label (the branch's address). Searchable. */
|
|
1458
|
+
description?: string;
|
|
1459
|
+
}
|
|
1460
|
+
interface LocationGroup {
|
|
1461
|
+
/** Omitted for a leading, header-less group (e.g. sentinel options). */
|
|
1462
|
+
label?: string;
|
|
1463
|
+
options: LocationOption[];
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
interface SearchComboboxProps {
|
|
1467
|
+
id?: string;
|
|
1468
|
+
ariaLabel?: string;
|
|
1469
|
+
value: string;
|
|
1470
|
+
/** What shows in the closed trigger - may differ from `value` for sentinel
|
|
1471
|
+
* options like "Any location" / "Same as pick-up". */
|
|
1472
|
+
displayLabel: string;
|
|
1473
|
+
groups: LocationGroup[];
|
|
1474
|
+
onChange: (value: string) => void;
|
|
1475
|
+
searchPlaceholder?: string;
|
|
1476
|
+
emptyMessage?: string;
|
|
1477
|
+
/** True while `groups` is empty because the list is still being fetched,
|
|
1478
|
+
* not because it genuinely has no matches - an empty array reads
|
|
1479
|
+
* identically either way otherwise, so a picker opened right as the fetch
|
|
1480
|
+
* kicks off would flash `emptyMessage` for what's actually just latency. */
|
|
1481
|
+
loading?: boolean;
|
|
1482
|
+
triggerClassName?: string;
|
|
1483
|
+
contentClassName?: string;
|
|
1484
|
+
invalid?: boolean;
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* A searchable, groupable single-select - the search form's replacement for
|
|
1488
|
+
* a plain <select> on pick-up/drop-off location and time, so a long location
|
|
1489
|
+
* list can be typed through instead of scrolled.
|
|
1490
|
+
*/
|
|
1491
|
+
declare function SearchCombobox({ id, ariaLabel, value, displayLabel, groups, onChange, searchPlaceholder, emptyMessage, loading, triggerClassName, contentClassName, invalid, }: SearchComboboxProps): react_jsx_runtime.JSX.Element;
|
|
1492
|
+
|
|
1493
|
+
/**
|
|
1494
|
+
* Pick-up -> drop-off as one range, rather than two independent date pickers:
|
|
1495
|
+
* a single two-month calendar makes the rental window visible while choosing
|
|
1496
|
+
* it, and makes an end-before-start selection impossible by construction.
|
|
1497
|
+
*
|
|
1498
|
+
* Values are local-date ISO strings (YYYY-MM-DD). `new Date("2026-01-01")`
|
|
1499
|
+
* parses as UTC and shifts a day in negative-offset timezones, so parsing and
|
|
1500
|
+
* formatting are done by hand - same approach as ui/date-picker.tsx.
|
|
1501
|
+
*/
|
|
1502
|
+
interface DateRangeFieldProps {
|
|
1503
|
+
from: string;
|
|
1504
|
+
to: string;
|
|
1505
|
+
onChange: (range: {
|
|
1506
|
+
from: string;
|
|
1507
|
+
to: string;
|
|
1508
|
+
}) => void;
|
|
1509
|
+
className?: string;
|
|
1510
|
+
/** Inverted styling for use on a dark surface. */
|
|
1511
|
+
tone?: 'default' | 'stage';
|
|
1512
|
+
id?: string;
|
|
1513
|
+
invalid?: boolean;
|
|
1514
|
+
/**
|
|
1515
|
+
* What the trigger shows: the whole range (default), or only one end. The
|
|
1516
|
+
* "card" search style draws pick-up and return in separate cells; both open
|
|
1517
|
+
* the same range calendar, so a return before pick-up is still impossible.
|
|
1518
|
+
*/
|
|
1519
|
+
display?: 'range' | 'from' | 'to';
|
|
1520
|
+
/** The text shown for an empty end, e.g. "Add date". */
|
|
1521
|
+
placeholder?: string;
|
|
1522
|
+
}
|
|
1523
|
+
declare function DateRangeField({ from, to, onChange, className, tone, id, invalid, display, placeholder, }: DateRangeFieldProps): react_jsx_runtime.JSX.Element;
|
|
1524
|
+
|
|
1525
|
+
/**
|
|
1526
|
+
* A grey stand-in for a car card while the search runs. It copies the real
|
|
1527
|
+
* card's shape so the grid does not jump when the cars arrive.
|
|
1528
|
+
*/
|
|
1529
|
+
declare function CarCardSkeleton(): react_jsx_runtime.JSX.Element;
|
|
1530
|
+
|
|
1531
|
+
interface CarCardProps {
|
|
1532
|
+
car: Car;
|
|
1533
|
+
bookingUrl?: string;
|
|
1534
|
+
onBook?: (car: Car) => void;
|
|
1535
|
+
/** Opens a quote request flow for this vehicle / selected rate package. */
|
|
1536
|
+
onQuote?: (car: Car) => void;
|
|
1537
|
+
rentalDays?: number;
|
|
1538
|
+
priority?: boolean;
|
|
1539
|
+
bookLabel?: string;
|
|
1540
|
+
className?: string;
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* One car in the results grid.
|
|
1544
|
+
*
|
|
1545
|
+
* Identity sits above a short photo: group, body class, name, supplier.
|
|
1546
|
+
* Specs are a single icon row. Mileage and cover are compact switches, only
|
|
1547
|
+
* when the supplier offered more than one. Price, total and Book now close
|
|
1548
|
+
* the card. Every colour comes from the --fb-car-* tokens.
|
|
1549
|
+
*/
|
|
1550
|
+
declare function CarCard({ car, bookingUrl, onBook, onQuote, rentalDays, priority, bookLabel, className, }: CarCardProps): react_jsx_runtime.JSX.Element;
|
|
1551
|
+
|
|
1111
1552
|
/**
|
|
1112
|
-
*
|
|
1113
|
-
*
|
|
1114
|
-
*
|
|
1553
|
+
* Grey placeholders shown while the search is running. They have the same
|
|
1554
|
+
* shape as the chosen list style, so nothing jumps when the cars arrive.
|
|
1555
|
+
* Screen readers hear "Loading cars" once instead of a pile of empty boxes.
|
|
1115
1556
|
*/
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
selection: ExtraSelection;
|
|
1122
|
-
}
|
|
1123
|
-
/** What was chosen before going to the payment page, so the page can carry on when the customer comes back. */
|
|
1124
|
-
interface RememberedPayment {
|
|
1125
|
-
token: string;
|
|
1126
|
-
methodId: string;
|
|
1127
|
-
purpose: PaymentPurpose;
|
|
1128
|
-
supplier: string;
|
|
1129
|
-
wizard?: WizardSnapshot;
|
|
1130
|
-
}
|
|
1557
|
+
declare function CarListSkeleton({ count, listStyle, className, }: {
|
|
1558
|
+
count?: number;
|
|
1559
|
+
listStyle?: ListStyle;
|
|
1560
|
+
className?: string;
|
|
1561
|
+
}): react_jsx_runtime.JSX.Element;
|
|
1131
1562
|
|
|
1563
|
+
interface CarListProps {
|
|
1564
|
+
cars: Car[];
|
|
1565
|
+
/** Which look to use (see lib/widget.styles.ts). Every look books the same way. */
|
|
1566
|
+
listStyle?: ListStyle;
|
|
1567
|
+
bookingUrl?: string;
|
|
1568
|
+
/** Opens the booking dialog; see CarCard's `onBook`. */
|
|
1569
|
+
onBook?: (car: Car) => void;
|
|
1570
|
+
/** Quote request for the selected car / rate package. */
|
|
1571
|
+
onQuote?: (car: Car) => void;
|
|
1572
|
+
/** Forwarded to each card for the estimated total. */
|
|
1573
|
+
rentalDays?: number;
|
|
1574
|
+
/** Renders a reset action in the empty state when provided. */
|
|
1575
|
+
onReset?: () => void;
|
|
1576
|
+
bookLabel?: string;
|
|
1577
|
+
emptyActionLabel?: string;
|
|
1578
|
+
emptyDescription?: string;
|
|
1579
|
+
/** `card` (default): a dashed card. `inline`: a centred note without a card, for full-width pages. */
|
|
1580
|
+
emptyLayout?: 'card' | 'inline';
|
|
1581
|
+
className?: string;
|
|
1582
|
+
}
|
|
1132
1583
|
/**
|
|
1133
|
-
*
|
|
1134
|
-
*
|
|
1135
|
-
*
|
|
1136
|
-
*
|
|
1137
|
-
* FleetBridge, and for the original reason: creating a reservation needs the
|
|
1138
|
-
* account's API key plus the supplier's own credentials in the request body
|
|
1139
|
-
* (see apps/api/src/handlers/suppliers/booking.ts), and neither may ever
|
|
1140
|
-
* live in front-end JavaScript. What changed is what the PHP handler does
|
|
1141
|
-
* with the payload - it used to record an enquiry and fire an action for a
|
|
1142
|
-
* site to forward itself; it now records the attempt in the tenant
|
|
1143
|
-
* `Bookings` table and books it (see Frontend\BookingController).
|
|
1584
|
+
* The cars, in the look the site owner chose: grid cards (the default),
|
|
1585
|
+
* rows, a compare table, a showcase or rows grouped by class. Each car's
|
|
1586
|
+
* choices and booking come from the same offer (CarCard/useCarOffer.ts), so
|
|
1587
|
+
* the look never changes what gets booked.
|
|
1144
1588
|
*
|
|
1145
|
-
*
|
|
1146
|
-
*
|
|
1147
|
-
* pre-resolved branch codes, the vehicle group, and the rate/quote/CDP
|
|
1148
|
-
* references from the search - all values FleetBridge itself produced. The
|
|
1149
|
-
* handler re-resolves credentials and the active CDP code server-side.
|
|
1589
|
+
* The list is its own size container (`@container/list`), so each look fits
|
|
1590
|
+
* the width it was given, beside the filter rail or on a full-width page.
|
|
1150
1591
|
*/
|
|
1592
|
+
declare function CarList({ cars, listStyle, bookingUrl, onBook, onQuote, rentalDays, onReset, bookLabel, emptyActionLabel, emptyDescription, emptyLayout, className, }: CarListProps): react_jsx_runtime.JSX.Element;
|
|
1151
1593
|
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
days: number;
|
|
1160
|
-
total: number;
|
|
1161
|
-
/**
|
|
1162
|
-
* The resolved one-way drop-off fee, if any - `quoteFor`'s own
|
|
1163
|
-
* `liveDropOffFee ?? car.dropOffFee` (see BookingWizard, which already
|
|
1164
|
-
* computed this for the price breakdown the customer sees). Persisted on
|
|
1165
|
-
* BookingRate, not folded into `extras` - see that field's own note in
|
|
1166
|
-
* `bookingRequestFields` below.
|
|
1167
|
-
*/
|
|
1168
|
-
dropOffFee?: number | null;
|
|
1169
|
-
/** `quoteFor`'s refundable deposit (Quote.deposit) - PriceSummary's "Funds
|
|
1170
|
-
* needed on card", persisted on BookingRate alongside the drop-off fee. */
|
|
1171
|
-
deposit?: number | null;
|
|
1172
|
-
/** The published terms version shown on the review step, when this supplier has one. */
|
|
1173
|
-
terms?: {
|
|
1174
|
-
id: string;
|
|
1175
|
-
version: number;
|
|
1176
|
-
} | null;
|
|
1177
|
-
/** How the customer pays, for the site's own cars (see payment.queries.ts). */
|
|
1178
|
-
payment?: {
|
|
1179
|
-
methodId: string;
|
|
1180
|
-
purpose: PaymentPurpose;
|
|
1181
|
-
} | null;
|
|
1594
|
+
type ArrayKey = 'makes' | 'models' | 'categories' | 'fuels' | 'suppliers';
|
|
1595
|
+
interface FilterControlProps {
|
|
1596
|
+
cars: Car[];
|
|
1597
|
+
filters: Filters;
|
|
1598
|
+
priceBounds: [number, number];
|
|
1599
|
+
onChange: (patch: Partial<Filters>) => void;
|
|
1600
|
+
onToggle: (key: ArrayKey, value: string) => void;
|
|
1182
1601
|
}
|
|
1602
|
+
|
|
1183
1603
|
/**
|
|
1184
|
-
*
|
|
1185
|
-
*
|
|
1186
|
-
*
|
|
1187
|
-
*
|
|
1604
|
+
* "Chip bar": one strip of chips above the cars, one chip per filter. A chip
|
|
1605
|
+
* opens a small panel with that filter's control. A chip that is in use is
|
|
1606
|
+
* filled in and shows a dot, so the customer sees at a glance what is on.
|
|
1607
|
+
* On a phone the strip scrolls sideways.
|
|
1188
1608
|
*/
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
}
|
|
1194
|
-
/** A confirmed reservation, as the confirmation step shows it. */
|
|
1195
|
-
interface ConfirmedBooking {
|
|
1196
|
-
/**
|
|
1197
|
-
* The supplier's booking number - the only id THEY know this booking by,
|
|
1198
|
-
* and so the one the customer quotes at the desk.
|
|
1199
|
-
*/
|
|
1200
|
-
reservationId: string;
|
|
1201
|
-
/**
|
|
1202
|
-
* FleetBridge's own PIN for the booking. Paired with the booking number
|
|
1203
|
-
* it finds the booking on FleetBridge's side (the admin Bookings
|
|
1204
|
-
* tab searches on it); the supplier has no idea what it is.
|
|
1205
|
-
*/
|
|
1206
|
-
bookingPin: string;
|
|
1207
|
-
supplier: string;
|
|
1208
|
-
/**
|
|
1209
|
-
* Tenant / FleetBridge booking reference (`fb-booking-{uuid}`), generated
|
|
1210
|
-
* before the supplier was called. Deliberately NOT displayed to customers.
|
|
1211
|
-
*/
|
|
1212
|
-
reference: string;
|
|
1213
|
-
/**
|
|
1214
|
-
* The tenant Customer row this booking was recorded against (see
|
|
1215
|
-
* BookingController's upsert_customer call). Used to remember "this
|
|
1216
|
-
* device belongs to this customer" for a return visit - see
|
|
1217
|
-
* store/customerStore.ts.
|
|
1218
|
-
*/
|
|
1219
|
-
customerId?: string;
|
|
1220
|
-
/** Set when the booking still has to be paid online. The booking number arrives once it is paid. */
|
|
1221
|
-
payment?: PendingPayment;
|
|
1222
|
-
}
|
|
1223
|
-
type BookingResult = ({
|
|
1224
|
-
ok: true;
|
|
1225
|
-
} & ConfirmedBooking) | {
|
|
1226
|
-
ok: false;
|
|
1227
|
-
error: string;
|
|
1228
|
-
/**
|
|
1229
|
-
* Present when the attempt was recorded before it failed - the normal
|
|
1230
|
-
* case, since the row is written before the supplier is called. Worth
|
|
1231
|
-
* showing: a failed attempt has no reservation number, so this is the
|
|
1232
|
-
* only handle on it, including when the reservation did in fact get
|
|
1233
|
-
* created upstream.
|
|
1234
|
-
*/
|
|
1235
|
-
bookingPin?: string;
|
|
1236
|
-
};
|
|
1609
|
+
declare function FilterChipBar({ activeCount, onReset, className, ...props }: FilterControlProps & {
|
|
1610
|
+
activeCount: number;
|
|
1611
|
+
onReset: () => void;
|
|
1612
|
+
className?: string;
|
|
1613
|
+
}): react_jsx_runtime.JSX.Element;
|
|
1237
1614
|
/**
|
|
1238
|
-
* "
|
|
1239
|
-
*
|
|
1240
|
-
*
|
|
1241
|
-
*
|
|
1242
|
-
*
|
|
1615
|
+
* "Car type tabs": a big tile for each kind of car (small, SUV, bakkie …)
|
|
1616
|
+
* with a photo of its cheapest car, how many there are and the lowest price
|
|
1617
|
+
* a day. Choosing a tile shows only that kind; "All cars" shows every car.
|
|
1618
|
+
* The chosen tile fills with the brand colour. Nothing is drawn when the
|
|
1619
|
+
* cars only come in one kind, as there would be nothing to choose.
|
|
1243
1620
|
*/
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
} | {
|
|
1248
|
-
ok: false;
|
|
1249
|
-
error: string;
|
|
1250
|
-
};
|
|
1251
|
-
declare class BookingQueries extends BaseQuery {
|
|
1252
|
-
/**
|
|
1253
|
-
* Posts the booking to WordPress. Also dispatches
|
|
1254
|
-
* `fleetbridge:booking-requested` either way, so a theme that would rather
|
|
1255
|
-
* handle bookings itself can listen instead.
|
|
1256
|
-
*/
|
|
1257
|
-
submitBooking(request: BookingRequest): Promise<BookingResult>;
|
|
1258
|
-
/**
|
|
1259
|
-
* Posts a "Request a quote" - same fields as `submitBooking()` (it's the
|
|
1260
|
-
* same wizard, just ending here instead of at "Confirm booking"), but
|
|
1261
|
-
* WordPress records it as a Quote and emails it rather than calling the
|
|
1262
|
-
* supplier - see Tenant\Quote's own docblock. Dispatches
|
|
1263
|
-
* `fleetbridge:quote-requested`, the quote-mode counterpart of
|
|
1264
|
-
* `fleetbridge:booking-requested` above.
|
|
1265
|
-
*/
|
|
1266
|
-
requestQuote(request: BookingRequest): Promise<QuoteRequestResult>;
|
|
1267
|
-
/** The terms version this supplier's customers agree to now. Null when none is published. */
|
|
1268
|
-
supplierTerms(identifier: string): Promise<{
|
|
1269
|
-
id: string;
|
|
1270
|
-
version: number;
|
|
1271
|
-
html: string;
|
|
1272
|
-
} | null>;
|
|
1273
|
-
}
|
|
1274
|
-
declare const bookingQueries: BookingQueries;
|
|
1621
|
+
declare function CarTypeTabs({ cars, filters, priceBounds, onChange, className }: FilterControlProps & {
|
|
1622
|
+
className?: string;
|
|
1623
|
+
}): react_jsx_runtime.JSX.Element | null;
|
|
1275
1624
|
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
}
|
|
1285
|
-
interface ManagedBookingVehicle {
|
|
1286
|
-
group: string | null;
|
|
1287
|
-
name: string | null;
|
|
1288
|
-
image: string | null;
|
|
1289
|
-
supplierLogo: string | null;
|
|
1290
|
-
seats: number | null;
|
|
1291
|
-
doors: number | null;
|
|
1292
|
-
transmission: string | null;
|
|
1293
|
-
fuelType: string | null;
|
|
1294
|
-
insuranceIncluded: boolean | null;
|
|
1295
|
-
ratePackageLabel: string | null;
|
|
1296
|
-
unlimitedMileage?: boolean | null;
|
|
1297
|
-
kmPerDay?: number | null;
|
|
1298
|
-
}
|
|
1299
|
-
interface ManagedBookingCustomer {
|
|
1300
|
-
name: string | null;
|
|
1301
|
-
firstName?: string | null;
|
|
1302
|
-
lastName?: string | null;
|
|
1303
|
-
title?: string | null;
|
|
1304
|
-
email: string | null;
|
|
1305
|
-
additionalEmail?: string | null;
|
|
1306
|
-
phone: string | null;
|
|
1307
|
-
dialCode?: string | null;
|
|
1308
|
-
idNumber?: string | null;
|
|
1309
|
-
idType?: string | null;
|
|
1310
|
-
licenseNumber?: string | null;
|
|
1311
|
-
country?: string | null;
|
|
1312
|
-
streetAddress?: string | null;
|
|
1313
|
-
suburb?: string | null;
|
|
1314
|
-
city?: string | null;
|
|
1315
|
-
province?: string | null;
|
|
1316
|
-
postalCode?: string | null;
|
|
1625
|
+
interface FilterPanelProps {
|
|
1626
|
+
cars: Car[];
|
|
1627
|
+
filters: Filters;
|
|
1628
|
+
priceBounds: [number, number];
|
|
1629
|
+
activeCount: number;
|
|
1630
|
+
onChange: (patch: Partial<Filters>) => void;
|
|
1631
|
+
onToggle: (key: ArrayKey, value: string) => void;
|
|
1632
|
+
onReset: () => void;
|
|
1317
1633
|
}
|
|
1318
1634
|
/**
|
|
1319
|
-
*
|
|
1320
|
-
*
|
|
1321
|
-
* (
|
|
1322
|
-
*
|
|
1323
|
-
|
|
1635
|
+
* The filter rail: a heading with a "Clear" button, then one block per
|
|
1636
|
+
* filter (price, gearbox, supplier, category, fuel, free km, seats, bags). Category chips are body classes from the API
|
|
1637
|
+
* (SMALL / MEDIUM / …), never supplier group codes. The filters themselves
|
|
1638
|
+
* live in FilterControls, shared with the other filter looks.
|
|
1639
|
+
*/
|
|
1640
|
+
declare function FilterPanel({ cars, filters, priceBounds, activeCount, onChange, onToggle, onReset }: FilterPanelProps): react_jsx_runtime.JSX.Element;
|
|
1641
|
+
|
|
1642
|
+
/**
|
|
1643
|
+
* The booking wizard as it was when the customer left for the payment page.
|
|
1644
|
+
* When they come back, the results page opens the same wizard again with
|
|
1645
|
+
* it, so they see the normal confirmation step (see ResultsPage).
|
|
1324
1646
|
*/
|
|
1325
|
-
interface
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
vehicle: ManagedBookingVehicle;
|
|
1332
|
-
pickupLocation: string | null;
|
|
1333
|
-
dropoffLocation: string | null;
|
|
1334
|
-
pickupDate: string | null;
|
|
1335
|
-
dropoffDate: string | null;
|
|
1336
|
-
rentalDays: number | null;
|
|
1337
|
-
extras: ManagedBookingExtra[];
|
|
1338
|
-
totalPrice: number;
|
|
1339
|
-
currency: string;
|
|
1340
|
-
customer: ManagedBookingCustomer;
|
|
1341
|
-
cdpCode: string | null;
|
|
1342
|
-
quoteRef: string | null;
|
|
1343
|
-
rateId: string | null;
|
|
1344
|
-
/** Adapter identifier ("hertz", "bluu", …) — amend re-search is locked to this supplier. */
|
|
1345
|
-
supplierIdentifier: string | null;
|
|
1346
|
-
crossBorder: boolean;
|
|
1347
|
-
notes: string | null;
|
|
1348
|
-
source: string | null;
|
|
1349
|
-
cancelledAt: string | null;
|
|
1350
|
-
cancellationReason: string | null;
|
|
1351
|
-
createdAt: string | null;
|
|
1352
|
-
/** Both gate on `status === 'CONFIRMED'` server-side - see customer_view(). */
|
|
1353
|
-
canCancel: boolean;
|
|
1354
|
-
canAmend: boolean;
|
|
1355
|
-
}
|
|
1356
|
-
interface QuotedQuote {
|
|
1357
|
-
quoteRef: string;
|
|
1358
|
-
status: 'PENDING' | 'CONFIRMED' | 'EXPIRED' | 'CANCELLED';
|
|
1359
|
-
expiresAt: string | null;
|
|
1360
|
-
supplierName: string | null;
|
|
1361
|
-
vehicle: ManagedBookingVehicle;
|
|
1362
|
-
pickupLocation: string | null;
|
|
1363
|
-
dropoffLocation: string | null;
|
|
1364
|
-
pickupDate: string | null;
|
|
1365
|
-
dropoffDate: string | null;
|
|
1366
|
-
rentalDays: number | null;
|
|
1367
|
-
extras: ManagedBookingExtra[];
|
|
1368
|
-
priceBreakdown: {
|
|
1369
|
-
label: string;
|
|
1370
|
-
amount: number;
|
|
1371
|
-
}[];
|
|
1372
|
-
totalPrice: number;
|
|
1373
|
-
currency: string;
|
|
1374
|
-
deposit: number | null;
|
|
1375
|
-
customer: ManagedBookingCustomer;
|
|
1376
|
-
notes: string | null;
|
|
1377
|
-
crossBorder?: boolean;
|
|
1647
|
+
interface WizardSnapshot {
|
|
1648
|
+
car: Car;
|
|
1649
|
+
criteria: SearchCriteria;
|
|
1650
|
+
days: number;
|
|
1651
|
+
driver: Driver;
|
|
1652
|
+
selection: ExtraSelection;
|
|
1378
1653
|
}
|
|
1379
|
-
/**
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
reservationId: string;
|
|
1385
|
-
bookingPin: string;
|
|
1654
|
+
/** What was chosen before going to the payment page, so the page can carry on when the customer comes back. */
|
|
1655
|
+
interface RememberedPayment {
|
|
1656
|
+
token: string;
|
|
1657
|
+
methodId: string;
|
|
1658
|
+
purpose: PaymentPurpose;
|
|
1386
1659
|
supplier: string;
|
|
1387
|
-
|
|
1388
|
-
customerId?: string;
|
|
1389
|
-
}
|
|
1390
|
-
declare class BookingManagementQueries extends BaseQuery {
|
|
1391
|
-
lookup(reservationNumber: string, bookingPin: string): Promise<QueryResult<{
|
|
1392
|
-
booking: ManagedBooking;
|
|
1393
|
-
}>>;
|
|
1394
|
-
cancel(reservationNumber: string, bookingPin: string, reason: string): Promise<QueryResult<{
|
|
1395
|
-
booking: ManagedBooking;
|
|
1396
|
-
}>>;
|
|
1397
|
-
/**
|
|
1398
|
-
* Load a pending quote for review. The email link calls this first; Book
|
|
1399
|
-
* on that screen then calls `confirmQuote()`.
|
|
1400
|
-
*/
|
|
1401
|
-
lookupQuote(token: string): Promise<QueryResult<{
|
|
1402
|
-
quote: QuotedQuote;
|
|
1403
|
-
}>>;
|
|
1404
|
-
/**
|
|
1405
|
-
* Turns a pending Quote into a real reservation after the customer has
|
|
1406
|
-
* reviewed it and clicked Book. The caller still needs its own `lookup()`
|
|
1407
|
-
* afterwards for the full `ManagedBooking` shape the rest of this drawer
|
|
1408
|
-
* expects.
|
|
1409
|
-
*/
|
|
1410
|
-
confirmQuote(token: string): Promise<QueryResult<ConfirmedQuoteBooking>>;
|
|
1411
|
-
/**
|
|
1412
|
-
* Re-search submit: same payload as a new booking, plus the reservation
|
|
1413
|
-
* number + PIN that prove ownership. If the supplier doesn't support
|
|
1414
|
-
* amending online (AdapterCapabilities.amendBooking), this fails with a
|
|
1415
|
-
* plain message rather than a structured code.
|
|
1416
|
-
*/
|
|
1417
|
-
amend(reservationNumber: string, bookingPin: string, request: BookingRequest): Promise<(BookingResult & {
|
|
1418
|
-
booking?: ManagedBooking;
|
|
1419
|
-
})>;
|
|
1660
|
+
wizard?: WizardSnapshot;
|
|
1420
1661
|
}
|
|
1662
|
+
|
|
1421
1663
|
declare const bookingManagementQueries: BookingManagementQueries;
|
|
1422
1664
|
|
|
1423
1665
|
interface BookingWizardProps {
|
|
@@ -1757,143 +1999,7 @@ declare function LooksProvider({ looks, children }: {
|
|
|
1757
1999
|
/** The look chosen for one booking part. */
|
|
1758
2000
|
declare function useLook<K extends LookKind>(kind: K): Looks[K];
|
|
1759
2001
|
|
|
1760
|
-
|
|
1761
|
-
* Maps the availability search response onto the `Car` shape the results grid
|
|
1762
|
-
* renders. The API normalizer owns money/km/image cleaning — this only flattens
|
|
1763
|
-
* offers → fleets → Car and copies fields.
|
|
1764
|
-
*/
|
|
1765
|
-
|
|
1766
|
-
interface RawRateOption {
|
|
1767
|
-
cdpCode?: string;
|
|
1768
|
-
standardRate: number;
|
|
1769
|
-
/** Supplier's higher-cover tier total (e.g. Europcar's SuperCover) - see
|
|
1770
|
-
* rate.resolver.ts. Most suppliers mirror standardRate into this, which
|
|
1771
|
-
* toPackage() treats as "no real second tier" rather than a choice. */
|
|
1772
|
-
superRate?: number;
|
|
1773
|
-
dailyRate?: number;
|
|
1774
|
-
kmPerDay?: number;
|
|
1775
|
-
rentalDays?: number;
|
|
1776
|
-
unlimitedMileage?: boolean;
|
|
1777
|
-
superDeposit?: number;
|
|
1778
|
-
liability?: number;
|
|
1779
|
-
/** Extra-kilometre price in Rand. Suppliers send standardPricePerKm; own fleet sends standardExcessRatePerKm. */
|
|
1780
|
-
standardPricePerKm?: number;
|
|
1781
|
-
standardExcessRatePerKm?: number;
|
|
1782
|
-
superPricePerKm?: number;
|
|
1783
|
-
superExcessRatePerKm?: number;
|
|
1784
|
-
/** Own fleet: excess and deposit for the higher cover. */
|
|
1785
|
-
superExcess?: number;
|
|
1786
|
-
superCoverDeposit?: number;
|
|
1787
|
-
/** Drop-off/one-way fee (ZAR) - set only when pick-up and return branches
|
|
1788
|
-
* differ (see rate.resolver.ts/aggregator.ts on the API side). */
|
|
1789
|
-
dropOffFee?: number;
|
|
1790
|
-
/** Supplier rate identifiers - needed to BOOK this rate, see RatePackage. */
|
|
1791
|
-
rateNo?: string | number;
|
|
1792
|
-
rateSrNo?: string | number;
|
|
1793
|
-
/** The supplier's price quote for this rate (SaniSixt), sent back when booking it. */
|
|
1794
|
-
quoteRef?: string;
|
|
1795
|
-
/** Amount (ZAR, off standardRate) this rate beat a pricier same-km-tier
|
|
1796
|
-
* competitor by - see aggregator.ts's dedupeCheapestPerKm(). */
|
|
1797
|
-
discount?: number;
|
|
1798
|
-
/** Own fleet: false when this plan's km allowance differs from its CDP. */
|
|
1799
|
-
kmSelectable?: boolean;
|
|
1800
|
-
/** Own fleet: the CDP km allowance behind a blocked option. 0 means unlimited. */
|
|
1801
|
-
cdpKmAllowance?: number | null;
|
|
1802
|
-
options?: Record<string, unknown>[];
|
|
1803
|
-
}
|
|
1804
|
-
interface RawSupplier {
|
|
1805
|
-
id?: string;
|
|
1806
|
-
name?: string;
|
|
1807
|
-
logoUrl?: string;
|
|
1808
|
-
}
|
|
1809
|
-
interface RawListingMetadata {
|
|
1810
|
-
supplierId?: string;
|
|
1811
|
-
origin?: Record<string, unknown>[];
|
|
1812
|
-
adapter?: Record<string, unknown>[];
|
|
1813
|
-
}
|
|
1814
|
-
interface RawFleetListing {
|
|
1815
|
-
seat?: number;
|
|
1816
|
-
door?: number;
|
|
1817
|
-
code?: string;
|
|
1818
|
-
carGroup: string;
|
|
1819
|
-
carGroupInt?: string | number;
|
|
1820
|
-
model: string;
|
|
1821
|
-
carImage?: string;
|
|
1822
|
-
category?: string;
|
|
1823
|
-
/** Every category the cars in this listing belong to. Own fleet can have more than one. */
|
|
1824
|
-
categories?: string[];
|
|
1825
|
-
transmission?: string;
|
|
1826
|
-
fuel?: string;
|
|
1827
|
-
luggage?: number;
|
|
1828
|
-
rates: RawRateOption[];
|
|
1829
|
-
/** WheelSys price-quote references, one per rate (see Car.quoteIds). */
|
|
1830
|
-
quoteId?: string[] | string;
|
|
1831
|
-
pickUpBranch?: string;
|
|
1832
|
-
returnBranch?: string;
|
|
1833
|
-
supplier?: RawSupplier;
|
|
1834
|
-
termsAndConditions?: string;
|
|
1835
|
-
metadata?: RawListingMetadata;
|
|
1836
|
-
}
|
|
1837
|
-
interface RawOffer {
|
|
1838
|
-
supplier?: string | RawSupplier;
|
|
1839
|
-
available: boolean;
|
|
1840
|
-
fleets: RawFleetListing[] | null;
|
|
1841
|
-
pickBranch?: string | null;
|
|
1842
|
-
returnBranch?: string | null;
|
|
1843
|
-
cdpCode?: string | null;
|
|
1844
|
-
/** CDP codes this search should badge as discounted - worked out by the core's search.availability action. */
|
|
1845
|
-
discountCodes?: string[];
|
|
1846
|
-
message?: string;
|
|
1847
|
-
metadata?: {
|
|
1848
|
-
supplierId?: string;
|
|
1849
|
-
rentalDays?: number;
|
|
1850
|
-
originResponse?: string;
|
|
1851
|
-
};
|
|
1852
|
-
}
|
|
1853
|
-
/** How one source (a supplier, or the site's own cars) answered a search. */
|
|
1854
|
-
interface SourceNotice {
|
|
1855
|
-
source: string;
|
|
1856
|
-
supplierName?: string;
|
|
1857
|
-
status: string;
|
|
1858
|
-
/** How many cars this source answered with (for status "ok"). */
|
|
1859
|
-
count?: number;
|
|
1860
|
-
/** A short reason for customers when this source has no cars to show (from the core). */
|
|
1861
|
-
customerMessage?: string;
|
|
1862
|
-
}
|
|
1863
|
-
interface OffersResult {
|
|
1864
|
-
offers: RawOffer[];
|
|
1865
|
-
sources?: SourceNotice[];
|
|
1866
|
-
}
|
|
1867
|
-
interface MapOffersOptions {
|
|
1868
|
-
pickupLabel?: string;
|
|
1869
|
-
}
|
|
1870
|
-
declare function isOffersResult(value: unknown): value is OffersResult;
|
|
1871
|
-
declare function mapOffersToCars(offers: RawOffer[], options?: MapOffersOptions): Car[];
|
|
1872
|
-
|
|
1873
|
-
/** Every field of `criteria` feeds the search, so the whole object is the
|
|
1874
|
-
* cache key - two identical searches (e.g. the same trip re-opened within
|
|
1875
|
-
* the 10-minute staleTime) hit the same cache entry and skip the round trip. */
|
|
1876
|
-
declare function availabilityQueryKey(criteria: SearchCriteria): readonly ["availability", SearchCriteria];
|
|
1877
|
-
/** How one source stands while a search runs: still asking, or answered. */
|
|
1878
|
-
interface SourceProgress extends SourceNotice {
|
|
1879
|
-
/** True until this source has answered (or failed). */
|
|
1880
|
-
pending?: boolean;
|
|
1881
|
-
}
|
|
1882
|
-
/**
|
|
1883
|
-
* Searches every source for the trip.
|
|
1884
|
-
*
|
|
1885
|
-
* It first asks the site who to search (fleetbridge_search_sources), then
|
|
1886
|
-
* searches each source on its own, all at the same time. Each time a
|
|
1887
|
-
* source answers, `onProgress` gets the whole list again, so the page can
|
|
1888
|
-
* tick that source off while the others are still being asked. The answer
|
|
1889
|
-
* comes once every source has answered, with all their cars together, in
|
|
1890
|
-
* the same shape one big search gives.
|
|
1891
|
-
*
|
|
1892
|
-
* A search for one supplier only (criteria.supplier, used when changing a
|
|
1893
|
-
* booking), or a site whose plugin has no fleetbridge_search_sources yet,
|
|
1894
|
-
* makes one request for everything, as before.
|
|
1895
|
-
*/
|
|
1896
|
-
declare function searchAvailability(criteria: SearchCriteria, onProgress?: (sources: SourceProgress[]) => void): Promise<unknown>;
|
|
2002
|
+
declare const bookingQueries: BookingQueries;
|
|
1897
2003
|
|
|
1898
2004
|
type LocationsStatus = 'idle' | 'loading' | 'success' | 'error';
|
|
1899
2005
|
interface LocationsState {
|