@travories/frontend-sdk 0.1.2 → 0.1.4
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/dist/index.d.mts +60 -17
- package/dist/index.d.ts +60 -17
- package/dist/index.js +52 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -215,6 +215,24 @@ interface AgencyBundle {
|
|
|
215
215
|
associations: AgencyAssociationItem[];
|
|
216
216
|
packages: HomePackageCard[];
|
|
217
217
|
}
|
|
218
|
+
/** One row in the booking's traveler breakdown. `name` is the category label. */
|
|
219
|
+
interface BookingTraveler {
|
|
220
|
+
/** "Adult" | "Senior Citizen" | "Children" | "Infant" */
|
|
221
|
+
name: string;
|
|
222
|
+
count: number;
|
|
223
|
+
}
|
|
224
|
+
interface BookingInitiateRequest {
|
|
225
|
+
/** Package slug (NOT the package UUID — the BE looks it up by slug). */
|
|
226
|
+
packageId: string;
|
|
227
|
+
/** ISO date string, e.g. "2027-08-15". */
|
|
228
|
+
arrivalDate: string;
|
|
229
|
+
travelers: BookingTraveler[];
|
|
230
|
+
}
|
|
231
|
+
interface BookingInitiateResponse {
|
|
232
|
+
message: string;
|
|
233
|
+
/** Booking UUID. Used to build the payment URL: `/package/<data>/payment`. */
|
|
234
|
+
data: string;
|
|
235
|
+
}
|
|
218
236
|
|
|
219
237
|
declare class PackagesResource {
|
|
220
238
|
private http;
|
|
@@ -268,6 +286,24 @@ declare class AgenciesResource {
|
|
|
268
286
|
}, options?: HttpRequestOptions): Promise<AgencyBundle | null>;
|
|
269
287
|
}
|
|
270
288
|
|
|
289
|
+
/**
|
|
290
|
+
* Booking-related endpoints. Currently exposes the kickoff step (`initiate`);
|
|
291
|
+
* the rest of the flow (payment, confirmation) lives on travories.com today.
|
|
292
|
+
*/
|
|
293
|
+
declare class BookingsResource {
|
|
294
|
+
private http;
|
|
295
|
+
constructor(http: HttpClient);
|
|
296
|
+
/**
|
|
297
|
+
* Open a booking. The BE returns a booking UUID — combine it with
|
|
298
|
+
* `https://travories.com/package/<id>/payment`
|
|
299
|
+
* to send the user into the existing payment flow.
|
|
300
|
+
*
|
|
301
|
+
* Throws (not silent) so the consumer can surface errors to the user. Wrap
|
|
302
|
+
* in try/catch in your `onReserve` handler.
|
|
303
|
+
*/
|
|
304
|
+
initiate(payload: BookingInitiateRequest, options?: HttpRequestOptions): Promise<BookingInitiateResponse>;
|
|
305
|
+
}
|
|
306
|
+
|
|
271
307
|
interface TravoriesClientConfig extends HttpClientConfig {
|
|
272
308
|
}
|
|
273
309
|
/**
|
|
@@ -288,6 +324,7 @@ declare class TravoriesClient {
|
|
|
288
324
|
private http;
|
|
289
325
|
packages: PackagesResource;
|
|
290
326
|
agencies: AgenciesResource;
|
|
327
|
+
bookings: BookingsResource;
|
|
291
328
|
constructor(config: TravoriesClientConfig);
|
|
292
329
|
getPackageBySlug: (slug: string) => Promise<TravoriesPackage | null>;
|
|
293
330
|
getPackageBundle: (slug: string) => Promise<PackageBundle | null>;
|
|
@@ -484,6 +521,15 @@ interface PackageCardProps {
|
|
|
484
521
|
*/
|
|
485
522
|
declare const PackageCard: React.FC<PackageCardProps>;
|
|
486
523
|
|
|
524
|
+
/** Booking details the user picked in the BookingCardLite when they hit Reserve. */
|
|
525
|
+
interface ReservePayload {
|
|
526
|
+
pkg: TravoriesPackage;
|
|
527
|
+
arrival: string;
|
|
528
|
+
departure: string;
|
|
529
|
+
travelers: BookingTraveler[];
|
|
530
|
+
totalCost: number;
|
|
531
|
+
pricePerPerson: number;
|
|
532
|
+
}
|
|
487
533
|
interface PackageDetailViewProps {
|
|
488
534
|
/** Travories SDK client. Required when using `slug`. */
|
|
489
535
|
client?: TravoriesClient;
|
|
@@ -493,8 +539,10 @@ interface PackageDetailViewProps {
|
|
|
493
539
|
initialBundle?: PackageBundle | null;
|
|
494
540
|
/** Currency code for prices (default "USD"). */
|
|
495
541
|
currency?: string;
|
|
496
|
-
/** Called when the user hits Reserve.
|
|
497
|
-
|
|
542
|
+
/** Called when the user hits Reserve. Receives the full picked payload
|
|
543
|
+
* (pkg + arrival date + travelers + computed totals). Return a Promise to
|
|
544
|
+
* show an "Initiating…" state on the CTA until it resolves. */
|
|
545
|
+
onReserve?: (payload: ReservePayload) => void | Promise<void>;
|
|
498
546
|
/** Called when the user clicks the host card. Receives the host. */
|
|
499
547
|
onSelectHost?: (host: PackageHost) => void;
|
|
500
548
|
/** When set, host card renders as `<a href={agencyHrefFor(host)}>` — enables
|
|
@@ -617,7 +665,7 @@ interface DescriptionSectionProps {
|
|
|
617
665
|
DescriptionData: DescriptionData;
|
|
618
666
|
topData: TopData;
|
|
619
667
|
currency?: string;
|
|
620
|
-
onReserve?: (
|
|
668
|
+
onReserve?: (payload: ReservePayload) => void | Promise<void>;
|
|
621
669
|
pkg: TravoriesPackage;
|
|
622
670
|
routes?: PackageRoutesDay[];
|
|
623
671
|
}
|
|
@@ -693,28 +741,23 @@ interface HostAboutProps {
|
|
|
693
741
|
}
|
|
694
742
|
declare const HostAbout: React.FC<HostAboutProps>;
|
|
695
743
|
|
|
696
|
-
type TravelerOption = {
|
|
697
|
-
id: "Adult" | "Senior Citizen" | "Children" | "Infant";
|
|
698
|
-
name: string;
|
|
699
|
-
count: number;
|
|
700
|
-
ageRange?: {
|
|
701
|
-
min: number;
|
|
702
|
-
max: number;
|
|
703
|
-
};
|
|
704
|
-
countInTotal: boolean;
|
|
705
|
-
};
|
|
706
744
|
interface BookingCardLiteProps {
|
|
707
745
|
DescriptionData: DescriptionData;
|
|
708
746
|
currency?: string;
|
|
709
747
|
/** Called when user clicks Book/Reserve. Receives the picked values so the
|
|
710
|
-
* consumer can wire their own booking flow.
|
|
748
|
+
* consumer can wire their own booking flow. Return a `Promise` to make the
|
|
749
|
+
* button show an "Initiating…" state until it resolves. */
|
|
711
750
|
onReserve?: (payload: {
|
|
712
751
|
arrival: string;
|
|
713
752
|
departure: string;
|
|
714
|
-
|
|
753
|
+
/** Same shape `client.bookings.initiate()` accepts. */
|
|
754
|
+
travelers: {
|
|
755
|
+
name: string;
|
|
756
|
+
count: number;
|
|
757
|
+
}[];
|
|
715
758
|
totalCost: number;
|
|
716
759
|
pricePerPerson: number;
|
|
717
|
-
}) => void
|
|
760
|
+
}) => void | Promise<void>;
|
|
718
761
|
}
|
|
719
762
|
/**
|
|
720
763
|
* High-fidelity port of frontend `BookingForm.tsx` — visual only.
|
|
@@ -781,4 +824,4 @@ declare function startingPrice(prices: PackagePriceTier[] | undefined): number;
|
|
|
781
824
|
declare function formatCurrency(amount: number, currency?: string): string;
|
|
782
825
|
declare function formatRating(rating: number | undefined): string;
|
|
783
826
|
|
|
784
|
-
export { AgenciesResource, type AgencyAssociationItem, AgencyAssociations, type AgencyBundle, AgencyDetailView, type AgencyDetailViewProps, type AgencyHostDetails, type AgencyHostResponse, BookingCardLite, type DescriptionData, DescriptionSection, GallerySection, type HomePackageCard, type HomeSectionKey, HomeSections, type HomeSectionsContextValue, type HomeSectionsProps, HomeSectionsProvider, type HomeSectionsProviderProps, type HomeSectionsResponse, HostAbout, HostCard, type HttpClientConfig, type HttpRequestOptions, Itinerary, type MajorAttractionItem, type MajorAttractionsResponse, type MediaItem, type PackageBundle, PackageCard, type PackageDay, type PackageDayLocation, PackageDetailView, type PackageDetailViewProps, type PackageDiscount, PackageExcludedAndToPack, type PackageHost, type PackageHostResponse, PackageIncluded, PackageMap, PackageOverview, type PackagePriceTier, type PackageRoute, type PackageRouteGeometry, type PackageRoutesDay, type PackageRoutesResponse, PackagesCarousel, PackagesResource, PackagesSection, type PackagesSectionProps, type ThingItem, type TopData, TopSection, TravoriesApiError, TravoriesClient, type TravoriesClientConfig, type TravoriesImage, type TravoriesImageUrls, type TravoriesPackage, type UseAgencyBundleResult, type UseHomeSectionsResult, type UsePackageBundleResult, type UsePackageBySlugResult, buildDescriptionData, buildGalleryMedia, buildTopData, createTravoriesClient, formatCurrency, formatRating, pickImageUrl, startingPrice, useAgencyBundle, useHomeSections, useHomeSectionsContext, usePackageBundle, usePackageBySlug };
|
|
827
|
+
export { AgenciesResource, type AgencyAssociationItem, AgencyAssociations, type AgencyBundle, AgencyDetailView, type AgencyDetailViewProps, type AgencyHostDetails, type AgencyHostResponse, BookingCardLite, type BookingInitiateRequest, type BookingInitiateResponse, type BookingTraveler, BookingsResource, type DescriptionData, DescriptionSection, GallerySection, type HomePackageCard, type HomeSectionKey, HomeSections, type HomeSectionsContextValue, type HomeSectionsProps, HomeSectionsProvider, type HomeSectionsProviderProps, type HomeSectionsResponse, HostAbout, HostCard, type HttpClientConfig, type HttpRequestOptions, Itinerary, type MajorAttractionItem, type MajorAttractionsResponse, type MediaItem, type PackageBundle, PackageCard, type PackageDay, type PackageDayLocation, PackageDetailView, type PackageDetailViewProps, type PackageDiscount, PackageExcludedAndToPack, type PackageHost, type PackageHostResponse, PackageIncluded, PackageMap, PackageOverview, type PackagePriceTier, type PackageRoute, type PackageRouteGeometry, type PackageRoutesDay, type PackageRoutesResponse, PackagesCarousel, PackagesResource, PackagesSection, type PackagesSectionProps, type ReservePayload, type ThingItem, type TopData, TopSection, TravoriesApiError, TravoriesClient, type TravoriesClientConfig, type TravoriesImage, type TravoriesImageUrls, type TravoriesPackage, type UseAgencyBundleResult, type UseHomeSectionsResult, type UsePackageBundleResult, type UsePackageBySlugResult, buildDescriptionData, buildGalleryMedia, buildTopData, createTravoriesClient, formatCurrency, formatRating, pickImageUrl, startingPrice, useAgencyBundle, useHomeSections, useHomeSectionsContext, usePackageBundle, usePackageBySlug };
|
package/dist/index.d.ts
CHANGED
|
@@ -215,6 +215,24 @@ interface AgencyBundle {
|
|
|
215
215
|
associations: AgencyAssociationItem[];
|
|
216
216
|
packages: HomePackageCard[];
|
|
217
217
|
}
|
|
218
|
+
/** One row in the booking's traveler breakdown. `name` is the category label. */
|
|
219
|
+
interface BookingTraveler {
|
|
220
|
+
/** "Adult" | "Senior Citizen" | "Children" | "Infant" */
|
|
221
|
+
name: string;
|
|
222
|
+
count: number;
|
|
223
|
+
}
|
|
224
|
+
interface BookingInitiateRequest {
|
|
225
|
+
/** Package slug (NOT the package UUID — the BE looks it up by slug). */
|
|
226
|
+
packageId: string;
|
|
227
|
+
/** ISO date string, e.g. "2027-08-15". */
|
|
228
|
+
arrivalDate: string;
|
|
229
|
+
travelers: BookingTraveler[];
|
|
230
|
+
}
|
|
231
|
+
interface BookingInitiateResponse {
|
|
232
|
+
message: string;
|
|
233
|
+
/** Booking UUID. Used to build the payment URL: `/package/<data>/payment`. */
|
|
234
|
+
data: string;
|
|
235
|
+
}
|
|
218
236
|
|
|
219
237
|
declare class PackagesResource {
|
|
220
238
|
private http;
|
|
@@ -268,6 +286,24 @@ declare class AgenciesResource {
|
|
|
268
286
|
}, options?: HttpRequestOptions): Promise<AgencyBundle | null>;
|
|
269
287
|
}
|
|
270
288
|
|
|
289
|
+
/**
|
|
290
|
+
* Booking-related endpoints. Currently exposes the kickoff step (`initiate`);
|
|
291
|
+
* the rest of the flow (payment, confirmation) lives on travories.com today.
|
|
292
|
+
*/
|
|
293
|
+
declare class BookingsResource {
|
|
294
|
+
private http;
|
|
295
|
+
constructor(http: HttpClient);
|
|
296
|
+
/**
|
|
297
|
+
* Open a booking. The BE returns a booking UUID — combine it with
|
|
298
|
+
* `https://travories.com/package/<id>/payment`
|
|
299
|
+
* to send the user into the existing payment flow.
|
|
300
|
+
*
|
|
301
|
+
* Throws (not silent) so the consumer can surface errors to the user. Wrap
|
|
302
|
+
* in try/catch in your `onReserve` handler.
|
|
303
|
+
*/
|
|
304
|
+
initiate(payload: BookingInitiateRequest, options?: HttpRequestOptions): Promise<BookingInitiateResponse>;
|
|
305
|
+
}
|
|
306
|
+
|
|
271
307
|
interface TravoriesClientConfig extends HttpClientConfig {
|
|
272
308
|
}
|
|
273
309
|
/**
|
|
@@ -288,6 +324,7 @@ declare class TravoriesClient {
|
|
|
288
324
|
private http;
|
|
289
325
|
packages: PackagesResource;
|
|
290
326
|
agencies: AgenciesResource;
|
|
327
|
+
bookings: BookingsResource;
|
|
291
328
|
constructor(config: TravoriesClientConfig);
|
|
292
329
|
getPackageBySlug: (slug: string) => Promise<TravoriesPackage | null>;
|
|
293
330
|
getPackageBundle: (slug: string) => Promise<PackageBundle | null>;
|
|
@@ -484,6 +521,15 @@ interface PackageCardProps {
|
|
|
484
521
|
*/
|
|
485
522
|
declare const PackageCard: React.FC<PackageCardProps>;
|
|
486
523
|
|
|
524
|
+
/** Booking details the user picked in the BookingCardLite when they hit Reserve. */
|
|
525
|
+
interface ReservePayload {
|
|
526
|
+
pkg: TravoriesPackage;
|
|
527
|
+
arrival: string;
|
|
528
|
+
departure: string;
|
|
529
|
+
travelers: BookingTraveler[];
|
|
530
|
+
totalCost: number;
|
|
531
|
+
pricePerPerson: number;
|
|
532
|
+
}
|
|
487
533
|
interface PackageDetailViewProps {
|
|
488
534
|
/** Travories SDK client. Required when using `slug`. */
|
|
489
535
|
client?: TravoriesClient;
|
|
@@ -493,8 +539,10 @@ interface PackageDetailViewProps {
|
|
|
493
539
|
initialBundle?: PackageBundle | null;
|
|
494
540
|
/** Currency code for prices (default "USD"). */
|
|
495
541
|
currency?: string;
|
|
496
|
-
/** Called when the user hits Reserve.
|
|
497
|
-
|
|
542
|
+
/** Called when the user hits Reserve. Receives the full picked payload
|
|
543
|
+
* (pkg + arrival date + travelers + computed totals). Return a Promise to
|
|
544
|
+
* show an "Initiating…" state on the CTA until it resolves. */
|
|
545
|
+
onReserve?: (payload: ReservePayload) => void | Promise<void>;
|
|
498
546
|
/** Called when the user clicks the host card. Receives the host. */
|
|
499
547
|
onSelectHost?: (host: PackageHost) => void;
|
|
500
548
|
/** When set, host card renders as `<a href={agencyHrefFor(host)}>` — enables
|
|
@@ -617,7 +665,7 @@ interface DescriptionSectionProps {
|
|
|
617
665
|
DescriptionData: DescriptionData;
|
|
618
666
|
topData: TopData;
|
|
619
667
|
currency?: string;
|
|
620
|
-
onReserve?: (
|
|
668
|
+
onReserve?: (payload: ReservePayload) => void | Promise<void>;
|
|
621
669
|
pkg: TravoriesPackage;
|
|
622
670
|
routes?: PackageRoutesDay[];
|
|
623
671
|
}
|
|
@@ -693,28 +741,23 @@ interface HostAboutProps {
|
|
|
693
741
|
}
|
|
694
742
|
declare const HostAbout: React.FC<HostAboutProps>;
|
|
695
743
|
|
|
696
|
-
type TravelerOption = {
|
|
697
|
-
id: "Adult" | "Senior Citizen" | "Children" | "Infant";
|
|
698
|
-
name: string;
|
|
699
|
-
count: number;
|
|
700
|
-
ageRange?: {
|
|
701
|
-
min: number;
|
|
702
|
-
max: number;
|
|
703
|
-
};
|
|
704
|
-
countInTotal: boolean;
|
|
705
|
-
};
|
|
706
744
|
interface BookingCardLiteProps {
|
|
707
745
|
DescriptionData: DescriptionData;
|
|
708
746
|
currency?: string;
|
|
709
747
|
/** Called when user clicks Book/Reserve. Receives the picked values so the
|
|
710
|
-
* consumer can wire their own booking flow.
|
|
748
|
+
* consumer can wire their own booking flow. Return a `Promise` to make the
|
|
749
|
+
* button show an "Initiating…" state until it resolves. */
|
|
711
750
|
onReserve?: (payload: {
|
|
712
751
|
arrival: string;
|
|
713
752
|
departure: string;
|
|
714
|
-
|
|
753
|
+
/** Same shape `client.bookings.initiate()` accepts. */
|
|
754
|
+
travelers: {
|
|
755
|
+
name: string;
|
|
756
|
+
count: number;
|
|
757
|
+
}[];
|
|
715
758
|
totalCost: number;
|
|
716
759
|
pricePerPerson: number;
|
|
717
|
-
}) => void
|
|
760
|
+
}) => void | Promise<void>;
|
|
718
761
|
}
|
|
719
762
|
/**
|
|
720
763
|
* High-fidelity port of frontend `BookingForm.tsx` — visual only.
|
|
@@ -781,4 +824,4 @@ declare function startingPrice(prices: PackagePriceTier[] | undefined): number;
|
|
|
781
824
|
declare function formatCurrency(amount: number, currency?: string): string;
|
|
782
825
|
declare function formatRating(rating: number | undefined): string;
|
|
783
826
|
|
|
784
|
-
export { AgenciesResource, type AgencyAssociationItem, AgencyAssociations, type AgencyBundle, AgencyDetailView, type AgencyDetailViewProps, type AgencyHostDetails, type AgencyHostResponse, BookingCardLite, type DescriptionData, DescriptionSection, GallerySection, type HomePackageCard, type HomeSectionKey, HomeSections, type HomeSectionsContextValue, type HomeSectionsProps, HomeSectionsProvider, type HomeSectionsProviderProps, type HomeSectionsResponse, HostAbout, HostCard, type HttpClientConfig, type HttpRequestOptions, Itinerary, type MajorAttractionItem, type MajorAttractionsResponse, type MediaItem, type PackageBundle, PackageCard, type PackageDay, type PackageDayLocation, PackageDetailView, type PackageDetailViewProps, type PackageDiscount, PackageExcludedAndToPack, type PackageHost, type PackageHostResponse, PackageIncluded, PackageMap, PackageOverview, type PackagePriceTier, type PackageRoute, type PackageRouteGeometry, type PackageRoutesDay, type PackageRoutesResponse, PackagesCarousel, PackagesResource, PackagesSection, type PackagesSectionProps, type ThingItem, type TopData, TopSection, TravoriesApiError, TravoriesClient, type TravoriesClientConfig, type TravoriesImage, type TravoriesImageUrls, type TravoriesPackage, type UseAgencyBundleResult, type UseHomeSectionsResult, type UsePackageBundleResult, type UsePackageBySlugResult, buildDescriptionData, buildGalleryMedia, buildTopData, createTravoriesClient, formatCurrency, formatRating, pickImageUrl, startingPrice, useAgencyBundle, useHomeSections, useHomeSectionsContext, usePackageBundle, usePackageBySlug };
|
|
827
|
+
export { AgenciesResource, type AgencyAssociationItem, AgencyAssociations, type AgencyBundle, AgencyDetailView, type AgencyDetailViewProps, type AgencyHostDetails, type AgencyHostResponse, BookingCardLite, type BookingInitiateRequest, type BookingInitiateResponse, type BookingTraveler, BookingsResource, type DescriptionData, DescriptionSection, GallerySection, type HomePackageCard, type HomeSectionKey, HomeSections, type HomeSectionsContextValue, type HomeSectionsProps, HomeSectionsProvider, type HomeSectionsProviderProps, type HomeSectionsResponse, HostAbout, HostCard, type HttpClientConfig, type HttpRequestOptions, Itinerary, type MajorAttractionItem, type MajorAttractionsResponse, type MediaItem, type PackageBundle, PackageCard, type PackageDay, type PackageDayLocation, PackageDetailView, type PackageDetailViewProps, type PackageDiscount, PackageExcludedAndToPack, type PackageHost, type PackageHostResponse, PackageIncluded, PackageMap, PackageOverview, type PackagePriceTier, type PackageRoute, type PackageRouteGeometry, type PackageRoutesDay, type PackageRoutesResponse, PackagesCarousel, PackagesResource, PackagesSection, type PackagesSectionProps, type ReservePayload, type ThingItem, type TopData, TopSection, TravoriesApiError, TravoriesClient, type TravoriesClientConfig, type TravoriesImage, type TravoriesImageUrls, type TravoriesPackage, type UseAgencyBundleResult, type UseHomeSectionsResult, type UsePackageBundleResult, type UsePackageBySlugResult, buildDescriptionData, buildGalleryMedia, buildTopData, createTravoriesClient, formatCurrency, formatRating, pickImageUrl, startingPrice, useAgencyBundle, useHomeSections, useHomeSectionsContext, usePackageBundle, usePackageBySlug };
|
package/dist/index.js
CHANGED
|
@@ -316,6 +316,45 @@ var AgenciesResource = class {
|
|
|
316
316
|
}
|
|
317
317
|
};
|
|
318
318
|
|
|
319
|
+
// src/api/bookings.ts
|
|
320
|
+
var BookingsResource = class {
|
|
321
|
+
constructor(http) {
|
|
322
|
+
this.http = http;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Open a booking. The BE returns a booking UUID — combine it with
|
|
326
|
+
* `https://travories.com/package/<id>/payment`
|
|
327
|
+
* to send the user into the existing payment flow.
|
|
328
|
+
*
|
|
329
|
+
* Throws (not silent) so the consumer can surface errors to the user. Wrap
|
|
330
|
+
* in try/catch in your `onReserve` handler.
|
|
331
|
+
*/
|
|
332
|
+
async initiate(payload, options) {
|
|
333
|
+
if (!payload?.packageId) {
|
|
334
|
+
throw new Error("[TravoriesClient] bookings.initiate requires packageId");
|
|
335
|
+
}
|
|
336
|
+
if (!payload?.arrivalDate) {
|
|
337
|
+
throw new Error("[TravoriesClient] bookings.initiate requires arrivalDate");
|
|
338
|
+
}
|
|
339
|
+
if (!payload?.travelers?.length) {
|
|
340
|
+
throw new Error("[TravoriesClient] bookings.initiate requires at least one traveler");
|
|
341
|
+
}
|
|
342
|
+
const res = await this.http.request(
|
|
343
|
+
`/booking/initiate`,
|
|
344
|
+
{
|
|
345
|
+
method: "POST",
|
|
346
|
+
body: payload,
|
|
347
|
+
silent: false,
|
|
348
|
+
...options
|
|
349
|
+
}
|
|
350
|
+
);
|
|
351
|
+
if (!res?.data) {
|
|
352
|
+
throw new Error("[TravoriesClient] bookings.initiate returned no booking id");
|
|
353
|
+
}
|
|
354
|
+
return res;
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
|
|
319
358
|
// src/client/TravoriesClient.ts
|
|
320
359
|
var TravoriesClient = class {
|
|
321
360
|
constructor(config) {
|
|
@@ -328,6 +367,7 @@ var TravoriesClient = class {
|
|
|
328
367
|
this.http = new HttpClient(config);
|
|
329
368
|
this.packages = new PackagesResource(this.http);
|
|
330
369
|
this.agencies = new AgenciesResource(this.http);
|
|
370
|
+
this.bookings = new BookingsResource(this.http);
|
|
331
371
|
}
|
|
332
372
|
};
|
|
333
373
|
function createTravoriesClient(config) {
|
|
@@ -957,16 +997,22 @@ var BookingCardLite = ({
|
|
|
957
997
|
(o) => o.id === id ? { ...o, count: Math.max(0, o.count + (inc ? 1 : -1)) } : o
|
|
958
998
|
)
|
|
959
999
|
);
|
|
1000
|
+
const [isSubmitting, setIsSubmitting] = react.useState(false);
|
|
960
1001
|
const handleReserve = () => {
|
|
961
1002
|
if (!onReserve) return;
|
|
962
1003
|
if (allPeopleCount === 0) return;
|
|
963
|
-
|
|
1004
|
+
const travelers = options.filter((o) => o.count > 0).map((o) => ({ name: o.name, count: o.count }));
|
|
1005
|
+
const result = onReserve({
|
|
964
1006
|
arrival,
|
|
965
1007
|
departure,
|
|
966
|
-
travelers
|
|
1008
|
+
travelers,
|
|
967
1009
|
totalCost,
|
|
968
1010
|
pricePerPerson: currentPrice
|
|
969
1011
|
});
|
|
1012
|
+
if (result && typeof result.then === "function") {
|
|
1013
|
+
setIsSubmitting(true);
|
|
1014
|
+
result.finally(() => setIsSubmitting(false));
|
|
1015
|
+
}
|
|
970
1016
|
};
|
|
971
1017
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full sm:w-full lg:w-[520px] h-fit border rounded-xl shadow-md px-4 sm:px-6 bg-white flex flex-col gap-6 py-8 sm:py-10", children: [
|
|
972
1018
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
@@ -1126,9 +1172,9 @@ var BookingCardLite = ({
|
|
|
1126
1172
|
{
|
|
1127
1173
|
type: "button",
|
|
1128
1174
|
onClick: handleReserve,
|
|
1129
|
-
disabled: allPeopleCount === 0 || !onReserve,
|
|
1175
|
+
disabled: allPeopleCount === 0 || !onReserve || isSubmitting,
|
|
1130
1176
|
className: "w-full py-2 md:py-3 bg-primary-normal text-white font-semibold rounded-lg hover:bg-primary-normal-hover transition text-sm md:text-base disabled:opacity-60 disabled:cursor-not-allowed",
|
|
1131
|
-
children: allPeopleCount === 0 ? "Reserve Now" : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1177
|
+
children: isSubmitting ? "Initiating\u2026" : allPeopleCount === 0 ? "Reserve Now" : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1132
1178
|
"Book Now - ",
|
|
1133
1179
|
formatCurrency(totalCost, currency)
|
|
1134
1180
|
] })
|
|
@@ -2033,7 +2079,7 @@ var DescriptionSection = ({
|
|
|
2033
2079
|
{
|
|
2034
2080
|
DescriptionData,
|
|
2035
2081
|
currency,
|
|
2036
|
-
onReserve: onReserve ? () => onReserve(pkg) : void 0
|
|
2082
|
+
onReserve: onReserve ? (booking) => onReserve({ pkg, ...booking }) : void 0
|
|
2037
2083
|
}
|
|
2038
2084
|
) })
|
|
2039
2085
|
]
|
|
@@ -2745,6 +2791,7 @@ exports.AgenciesResource = AgenciesResource;
|
|
|
2745
2791
|
exports.AgencyAssociations = AgencyAssociations_default;
|
|
2746
2792
|
exports.AgencyDetailView = AgencyDetailView;
|
|
2747
2793
|
exports.BookingCardLite = BookingCardLite_default;
|
|
2794
|
+
exports.BookingsResource = BookingsResource;
|
|
2748
2795
|
exports.DescriptionSection = DescriptionSection_default;
|
|
2749
2796
|
exports.GallerySection = GallerySection_default;
|
|
2750
2797
|
exports.HomeSections = HomeSections;
|