@ticketboothapp/booking 0.1.3 → 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/package.json
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useMemo, type CSSProperties } from 'react';
|
|
4
|
+
import type { BookingFlowUiOptions } from './booking/booking-flow-ui';
|
|
5
|
+
import type { BookingSourceMetadata } from '../lib/booking/source-metadata';
|
|
6
|
+
import type { BookingAppMode, BookingAppPermissions, ManageParams } from '../contexts/BookingAppContext';
|
|
7
|
+
|
|
8
|
+
export interface BookingWidgetProps {
|
|
9
|
+
initialProductId?: string;
|
|
10
|
+
authToken?: string | null;
|
|
11
|
+
onBookingSuccess?: (data: { reservationReference: string; sessionId?: string }) => void;
|
|
12
|
+
onBack?: () => void;
|
|
13
|
+
className?: string;
|
|
14
|
+
mode?: BookingAppMode;
|
|
15
|
+
permissions?: Partial<BookingAppPermissions>;
|
|
16
|
+
googleMapsApiKey?: string;
|
|
17
|
+
onShowManage?: (params: ManageParams) => void;
|
|
18
|
+
getSuccessUrl?: (params: { reservationRef: string; lastName: string; focusDate?: string }) => string;
|
|
19
|
+
showLanguageSelector?: boolean;
|
|
20
|
+
flowUi?: BookingFlowUiOptions;
|
|
21
|
+
bookingSourceAttribution?: Partial<BookingSourceMetadata>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const getBookingHost = (): string => process.env.NEXT_PUBLIC_BOOKING_WIDGET_URL || 'https://booking.viaviamorainelake.com';
|
|
25
|
+
|
|
26
|
+
export function BookingWidget({
|
|
27
|
+
initialProductId,
|
|
28
|
+
className = '',
|
|
29
|
+
mode = 'standalone',
|
|
30
|
+
showLanguageSelector = true,
|
|
31
|
+
googleMapsApiKey,
|
|
32
|
+
flowUi,
|
|
33
|
+
bookingSourceAttribution,
|
|
34
|
+
}: BookingWidgetProps) {
|
|
35
|
+
const src = useMemo(() => {
|
|
36
|
+
const url = new URL('/', getBookingHost());
|
|
37
|
+
if (initialProductId) url.searchParams.set('productId', initialProductId);
|
|
38
|
+
if (!showLanguageSelector) url.searchParams.set('showLanguageSelector', '0');
|
|
39
|
+
if (googleMapsApiKey) url.searchParams.set('gmapsKey', googleMapsApiKey);
|
|
40
|
+
if (mode) url.searchParams.set('embedMode', mode);
|
|
41
|
+
if (flowUi?.partnerDeferredInvoice) url.searchParams.set('partnerDeferredInvoice', '1');
|
|
42
|
+
if (bookingSourceAttribution?.utmSource) url.searchParams.set('utm_source', bookingSourceAttribution.utmSource);
|
|
43
|
+
if (bookingSourceAttribution?.utmCampaign) url.searchParams.set('utm_campaign', bookingSourceAttribution.utmCampaign);
|
|
44
|
+
if (bookingSourceAttribution?.utmMedium) url.searchParams.set('utm_medium', bookingSourceAttribution.utmMedium);
|
|
45
|
+
if (bookingSourceAttribution?.partnerId) url.searchParams.set('partnerId', bookingSourceAttribution.partnerId);
|
|
46
|
+
if (bookingSourceAttribution?.agentId) url.searchParams.set('agentId', bookingSourceAttribution.agentId);
|
|
47
|
+
return url.toString();
|
|
48
|
+
}, [bookingSourceAttribution, flowUi?.partnerDeferredInvoice, googleMapsApiKey, initialProductId, mode, showLanguageSelector]);
|
|
49
|
+
|
|
50
|
+
const frameStyle: CSSProperties = {
|
|
51
|
+
width: '100%',
|
|
52
|
+
minHeight: '900px',
|
|
53
|
+
border: 0,
|
|
54
|
+
display: 'block',
|
|
55
|
+
backgroundColor: 'transparent',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div className={className}>
|
|
60
|
+
<iframe title="Customer booking" src={src} style={frameStyle} loading="lazy" />
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useMemo, type CSSProperties } from 'react';
|
|
4
|
+
|
|
5
|
+
export interface StaffBookingAttribution {
|
|
6
|
+
reportingSource: string;
|
|
7
|
+
partnerBookingPortal: boolean;
|
|
8
|
+
partnerId?: string | null;
|
|
9
|
+
partnerName?: string | null;
|
|
10
|
+
agentId?: string | null;
|
|
11
|
+
agentDisplay?: string | null;
|
|
12
|
+
commissionRate?: number | null;
|
|
13
|
+
commissionBaseAmount?: number | null;
|
|
14
|
+
commissionAmount?: number | null;
|
|
15
|
+
bookingCurrency: string;
|
|
16
|
+
commissionUsesPartnerRate?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ManageBookingViewProps {
|
|
20
|
+
initialRef?: string;
|
|
21
|
+
initialLastName?: string;
|
|
22
|
+
initialReservationRef?: string;
|
|
23
|
+
initialPaymentSuccess?: boolean;
|
|
24
|
+
replaceUrl?: (url: string) => void;
|
|
25
|
+
onClose?: () => void;
|
|
26
|
+
showCloseButton?: boolean;
|
|
27
|
+
fetchStaffAttribution?: (bookingReference: string) => Promise<StaffBookingAttribution | null>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const getBookingHost = (): string => process.env.NEXT_PUBLIC_BOOKING_WIDGET_URL || 'https://booking.viaviamorainelake.com';
|
|
31
|
+
|
|
32
|
+
export function ManageBookingView({
|
|
33
|
+
initialRef = '',
|
|
34
|
+
initialLastName = '',
|
|
35
|
+
initialReservationRef = '',
|
|
36
|
+
initialPaymentSuccess = false,
|
|
37
|
+
onClose,
|
|
38
|
+
showCloseButton = true,
|
|
39
|
+
}: ManageBookingViewProps) {
|
|
40
|
+
const src = useMemo(() => {
|
|
41
|
+
const url = new URL('/manage-booking', getBookingHost());
|
|
42
|
+
if (initialRef) url.searchParams.set('ref', initialRef);
|
|
43
|
+
if (initialLastName) url.searchParams.set('lastName', initialLastName);
|
|
44
|
+
if (initialReservationRef) url.searchParams.set('reservationRef', initialReservationRef);
|
|
45
|
+
if (initialPaymentSuccess) url.searchParams.set('payment', 'balance_success');
|
|
46
|
+
return url.toString();
|
|
47
|
+
}, [initialLastName, initialPaymentSuccess, initialRef, initialReservationRef]);
|
|
48
|
+
|
|
49
|
+
const frameStyle: CSSProperties = {
|
|
50
|
+
width: '100%',
|
|
51
|
+
minHeight: '700px',
|
|
52
|
+
border: 0,
|
|
53
|
+
display: 'block',
|
|
54
|
+
backgroundColor: 'transparent',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div className="w-full">
|
|
59
|
+
{onClose && showCloseButton ? (
|
|
60
|
+
<div className="mb-2 flex justify-end">
|
|
61
|
+
<button
|
|
62
|
+
type="button"
|
|
63
|
+
onClick={onClose}
|
|
64
|
+
className="rounded border border-stone-300 px-3 py-1 text-sm hover:bg-stone-100"
|
|
65
|
+
>
|
|
66
|
+
Close
|
|
67
|
+
</button>
|
|
68
|
+
</div>
|
|
69
|
+
) : null}
|
|
70
|
+
<iframe title="Manage booking" src={src} style={frameStyle} loading="lazy" />
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -78,3 +78,14 @@ export {
|
|
|
78
78
|
type PartnerBookingPageWithBrowserMetadataProps,
|
|
79
79
|
type PartnerBookingPageRenderProps,
|
|
80
80
|
} from './components/partner/PartnerBookingPageWithBrowserMetadata';
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
BookingWidget,
|
|
84
|
+
type BookingWidgetProps,
|
|
85
|
+
} from './components/BookingWidget';
|
|
86
|
+
|
|
87
|
+
export {
|
|
88
|
+
ManageBookingView,
|
|
89
|
+
type ManageBookingViewProps,
|
|
90
|
+
type StaffBookingAttribution,
|
|
91
|
+
} from './components/ManageBookingView';
|