@ticketboothapp/booking 0.1.11 → 0.1.13
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 +2 -1
- package/src/app/photo-sessions/photo-packages.ts +75 -0
- package/src/assets/icons/partner-logos/getyourguide.svg +8 -0
- package/src/assets/icons/plus.svg +3 -0
- package/src/colours.css +23 -0
- package/src/components/BookingDetails.module.css +1591 -0
- package/src/components/BookingDetails.tsx +2072 -354
- package/src/components/BookingWidget.tsx +28 -248
- package/src/components/JobApplicationDialog.module.css +440 -0
- package/src/components/JobApplicationDialog.tsx +620 -0
- package/src/components/ManageBookingView.tsx +28 -36
- package/src/components/PhoneInputWithCountry.module.css +131 -0
- package/src/components/PhoneInputWithCountry.tsx +44 -0
- package/src/components/PickupLocationDialog.module.css +360 -0
- package/src/components/PickupLocationDialog.tsx +357 -0
- package/src/components/PickupLocationMap.tsx +110 -0
- package/src/components/PostBookingDependentAddOnUpsell.module.css +174 -0
- package/src/components/PostBookingDependentAddOnUpsell.tsx +407 -0
- package/src/components/accordion.css +27 -0
- package/src/components/accordion.tsx +29 -0
- package/src/components/analytics/AnalyticsConsentRestore.tsx +19 -0
- package/src/components/analytics/AnalyticsScripts.tsx +106 -0
- package/src/components/analytics/CookieConsentBanner.css +86 -0
- package/src/components/analytics/CookieConsentBanner.tsx +102 -0
- package/src/components/booking/AddOnsSection.module.css +10 -0
- package/src/components/booking/AddOnsSection.tsx +184 -0
- package/src/components/booking/AdminPaymentChoiceModal.tsx +98 -0
- package/src/components/booking/BookingDialog.module.css +643 -0
- package/src/components/booking/BookingDialog.tsx +356 -0
- package/src/components/booking/BookingFlow.tsx +4385 -0
- package/src/components/booking/BookingFlowCollage.module.css +148 -0
- package/src/components/booking/BookingFlowCollage.tsx +184 -0
- package/src/components/booking/BookingFlowPlaceholder.module.css +27 -0
- package/src/components/booking/BookingFlowPlaceholder.tsx +25 -0
- package/src/components/booking/BookingFlowPreview.tsx +51 -0
- package/src/components/booking/BookingProductGrid.module.css +359 -0
- package/src/components/booking/BookingProductGrid.tsx +497 -0
- package/src/components/booking/Calendar.module.css +616 -0
- package/src/components/{Calendar.tsx → booking/Calendar.tsx} +464 -247
- package/src/components/booking/CancellationPolicySelector.module.css +124 -0
- package/src/components/booking/CancellationPolicySelector.tsx +142 -0
- package/src/components/booking/ChangeBookingDialog.tsx +562 -0
- package/src/components/booking/CheckoutForm.module.css +244 -0
- package/src/components/booking/CheckoutForm.tsx +364 -0
- package/src/components/{CheckoutModal.tsx → booking/CheckoutModal.tsx} +176 -19
- package/src/components/booking/DapFlowCollage.tsx +88 -0
- package/src/components/booking/DapTourDescription.tsx +35 -0
- package/src/components/booking/DependentAddOnBookingDialog.tsx +1350 -0
- package/src/components/booking/DependentAddOnPaymentForm.tsx +124 -0
- package/src/components/booking/InfoTooltip.tsx +108 -0
- package/src/components/booking/ItineraryBox.module.css +258 -0
- package/src/components/booking/ItineraryBox.tsx +550 -0
- package/src/components/{ItineraryBuilder.tsx → booking/ItineraryBuilder.tsx} +1 -2
- package/src/components/booking/ItineraryPlaceholder.module.css +45 -0
- package/src/components/booking/ItineraryPlaceholder.tsx +26 -0
- package/src/components/{MealDrinkAddOnSelector.tsx → booking/MealDrinkAddOnSelector.tsx} +21 -13
- package/src/components/booking/PickupLocationSelector.module.css +124 -0
- package/src/components/{PickupLocationSelector.tsx → booking/PickupLocationSelector.tsx} +315 -290
- package/src/components/booking/PickupTimeSelector.module.css +134 -0
- package/src/components/booking/PickupTimeSelector.tsx +112 -0
- package/src/components/{PriceBreakdown.tsx → booking/PriceBreakdown.tsx} +3 -3
- package/src/components/{PriceSummary.tsx → booking/PriceSummary.tsx} +51 -28
- package/src/components/booking/PrivateShuttleBookingFlow.module.css +357 -0
- package/src/components/booking/PrivateShuttleBookingFlow.tsx +2662 -0
- package/src/components/booking/PromoCodeInput.module.css +166 -0
- package/src/components/booking/PromoCodeInput.tsx +99 -0
- package/src/components/booking/ReturnTimeSelector.module.css +173 -0
- package/src/components/booking/ReturnTimeSelector.tsx +145 -0
- package/src/components/{TermsAcceptance.tsx → booking/TermsAcceptance.tsx} +9 -8
- package/src/components/booking/TicketSelector.module.css +164 -0
- package/src/components/booking/TicketSelector.tsx +199 -0
- package/src/components/booking/TourDescription.module.css +304 -0
- package/src/components/booking/TourDescription.tsx +273 -0
- package/src/components/booking/booking-flow-ui.ts +15 -1
- package/src/components/booking/booking-flow.css +944 -0
- package/src/components/bottom-sheet.module.css +78 -0
- package/src/components/bottom-sheet.tsx +60 -0
- package/src/components/breadcrumb.module.css +40 -0
- package/src/components/breadcrumb.tsx +36 -0
- package/src/components/button.css +245 -0
- package/src/components/button.tsx +152 -0
- package/src/components/client-bottom-sheet.tsx +14 -0
- package/src/components/colorable-svg.tsx +29 -0
- package/src/components/conditional-footer.tsx +27 -0
- package/src/components/contact-us.module.css +147 -0
- package/src/components/contact-us.tsx +49 -0
- package/src/components/email-signup.css +151 -0
- package/src/components/email-signup.tsx +63 -0
- package/src/components/faq-wrapper.module.css +47 -0
- package/src/components/faq-wrapper.tsx +15 -0
- package/src/components/footer.css +187 -0
- package/src/components/footer.tsx +143 -0
- package/src/components/global-simple-modal.tsx +33 -0
- package/src/components/google-review-summary.module.css +77 -0
- package/src/components/google-review-summary.tsx +50 -0
- package/src/components/hero-image.css +13 -0
- package/src/components/hero-image.tsx +44 -0
- package/src/components/image.css +29 -0
- package/src/components/image.tsx +113 -0
- package/src/components/language-aware-link.tsx +72 -0
- package/src/components/language-switcher.module.css +124 -0
- package/src/components/language-switcher.tsx +75 -0
- package/src/components/map-section.css +59 -0
- package/src/components/map-section.tsx +63 -0
- package/src/components/navbar.module.css +152 -0
- package/src/components/navbar.tsx +125 -0
- package/src/components/parallax-provider.tsx +11 -0
- package/src/components/partner/PartnerBookingPage.module.css +130 -0
- package/src/components/partner/PartnerBookingPage.tsx +390 -0
- package/src/components/partner/PartnerBookingPageWithBrowserMetadata.tsx +19 -35
- package/src/components/product-tag.module.css +30 -0
- package/src/components/product-tag.tsx +34 -0
- package/src/components/product-theme-pages/best-option.module.css +70 -0
- package/src/components/product-theme-pages/best-option.tsx +35 -0
- package/src/components/product-theme-pages/extended-tour-options.module.css +22 -0
- package/src/components/product-theme-pages/extended-tour-options.tsx +11 -0
- package/src/components/product-theme-pages/image-modal.tsx +248 -0
- package/src/components/product-theme-pages/photo-gallery.module.css +200 -0
- package/src/components/product-theme-pages/photo-gallery.tsx +90 -0
- package/src/components/product-theme-pages/product-theme-page-layout.module.css +13 -0
- package/src/components/product-theme-pages/product-theme-page-layout.tsx +67 -0
- package/src/components/product-theme-pages/top-of-fold.module.css +179 -0
- package/src/components/product-theme-pages/top-of-fold.tsx +80 -0
- package/src/components/product-tile/image-only-product-tile-desktop.module.css +106 -0
- package/src/components/product-tile/image-only-product-tile-desktop.tsx +56 -0
- package/src/components/product-tile/image-only-product-tile-mobile.module.css +122 -0
- package/src/components/product-tile/image-only-product-tile-mobile.tsx +89 -0
- package/src/components/product-tile/image-only-product-tile.tsx +44 -0
- package/src/components/product-tile/product-tile-card.module.css +84 -0
- package/src/components/product-tile/product-tile-card.tsx +61 -0
- package/src/components/review-highlights-section.css +85 -0
- package/src/components/review-highlights-section.tsx +127 -0
- package/src/components/season-closure-overlay.module.css +99 -0
- package/src/components/season-closure-overlay.tsx +98 -0
- package/src/components/simple-modal.tsx +69 -0
- package/src/components/simple-top-of-fold.module.css +76 -0
- package/src/components/simple-top-of-fold.tsx +34 -0
- package/src/components/spacer.css +41 -0
- package/src/components/spacer.tsx +23 -0
- package/src/components/star-rating.module.css +74 -0
- package/src/components/star-rating.tsx +48 -0
- package/src/components/terms/TermsContent.tsx +178 -0
- package/src/components/title-subtitle.module.css +10 -0
- package/src/components/title-subtitle.tsx +30 -0
- package/src/components/translatable-reviews.tsx +75 -0
- package/src/components/value-pill.module.css +59 -0
- package/src/components/value-pill.tsx +46 -0
- package/src/components/value-props.css +185 -0
- package/src/components/value-props.tsx +88 -0
- package/src/constants/booking-guide-quiz.ts +64 -0
- package/src/constants/contact-info.ts +2 -0
- package/src/constants/faq.ts +44 -0
- package/src/constants/images.ts +556 -0
- package/src/constants/json-ld/faq-json-ld.tsx +170 -0
- package/src/constants/json-ld/homepage-json-ld.tsx +138 -0
- package/src/constants/json-ld/job-posting-json-ld.tsx +92 -0
- package/src/constants/json-ld/organization-json-ld.tsx +62 -0
- package/src/constants/json-ld/page-json-ld.tsx +6 -0
- package/src/constants/json-ld/product-json-ld.tsx +154 -0
- package/src/constants/json-ld/review-json-ld.tsx +377 -0
- package/src/constants/navigation-links/footer-links.ts +48 -0
- package/src/constants/navigation-links/nav-bar-links.ts +41 -0
- package/src/constants/navigation-links/navigation-link.ts +6 -0
- package/src/constants/pill-values.ts +210 -0
- package/src/constants/products.ts +155 -0
- package/src/constants/quiz-recommendations.ts +506 -0
- package/src/constants/reviews.ts +75 -0
- package/src/constants/staff.ts +197 -0
- package/src/constants/value-props.ts +58 -0
- package/src/data/dap-descriptions/session-couples-families-friends.en.json +61 -0
- package/src/data/dap-descriptions/session-elopements.en.json +60 -0
- package/src/data/dap-descriptions/session-proposals.en.json +60 -0
- package/src/data/product-descriptions/afternoon-delight.en.json +35 -0
- package/src/data/product-descriptions/emerald-lake-escape.en.json +68 -0
- package/src/data/product-descriptions/lake-louise-adventure.en.json +74 -0
- package/src/data/product-descriptions/moraine-lake-adventure.en.json +78 -0
- package/src/data/product-descriptions/moraine-lake-sunrise-lake-louise-golden-hour.en.json +65 -0
- package/src/data/product-descriptions/moraine-lake-sunrise.en.json +64 -0
- package/src/data/product-descriptions/private-tour.en.json +80 -0
- package/src/data/product-descriptions/two-lakes-combo.en.json +65 -0
- package/src/data/products-config.json +101 -0
- package/src/hooks/use-bottom-sheet.tsx +15 -0
- package/src/hooks/use-simple-modal.tsx +27 -0
- package/src/hooks/useBookingSourceMetadataFromLocation.ts +21 -0
- package/src/hooks/useEmailSubscription.tsx +103 -0
- package/src/hooks/useEmbeddedInIframe.ts +16 -0
- package/src/hooks/useIsBookingLaunchLive.ts +49 -0
- package/src/hooks/useQuiz.tsx +210 -0
- package/src/index.ts +27 -2
- package/src/lib/analytics.ts +197 -0
- package/src/lib/booking/booking-source.ts +20 -2
- package/src/lib/{checkout-breakdown.ts → booking/checkout-breakdown.ts} +1 -1
- package/src/lib/booking/correlation-id.ts +46 -0
- package/src/lib/{i18n → booking/i18n}/messages/en.json +48 -4
- package/src/lib/{i18n → booking/i18n}/messages/fr.json +48 -4
- package/src/lib/booking/itinerary-display.ts +36 -0
- package/src/lib/{itinerary-labels.ts → booking/itinerary-labels.ts} +1 -1
- package/src/lib/{location-calculations.ts → booking/location-calculations.ts} +4 -4
- package/src/lib/{location-utils.ts → booking/location-utils.ts} +26 -0
- package/src/lib/{map-utils.ts → booking/map-utils.ts} +3 -3
- package/src/lib/booking/normalize-booking-product-id.ts +7 -0
- package/src/lib/{pickup-location-types.ts → booking/pickup-location-types.ts} +2 -2
- package/src/lib/{pricing.ts → booking/pricing.ts} +2 -2
- package/src/lib/booking/product-option-id.ts +35 -0
- package/src/lib/booking/source-metadata.ts +72 -7
- package/src/lib/booking/sunday-week.ts +14 -0
- package/src/lib/booking/trace-context.ts +62 -0
- package/src/lib/booking-api.ts +1793 -0
- package/src/lib/{constants.ts → booking-constants.ts} +11 -5
- package/src/lib/booking-types.ts +36 -0
- package/src/lib/currency.ts +38 -45
- package/src/lib/dap-descriptions.ts +50 -0
- package/src/lib/dap-itinerary-preview.ts +315 -0
- package/src/lib/dependent-add-on-api.ts +434 -0
- package/src/lib/env.ts +89 -5
- package/src/lib/firebase.ts +20 -0
- package/src/lib/job-application-api.ts +83 -0
- package/src/lib/manage-booking-embed-print.ts +16 -0
- package/src/lib/manage-booking-post-checkout.ts +68 -0
- package/src/lib/photo-dap-config.ts +228 -0
- package/src/lib/pickup/map-utils.ts +56 -0
- package/src/lib/pickup/marker-icons.ts +19 -0
- package/src/lib/product-descriptions.ts +66 -0
- package/src/lib/products-config.ts +73 -0
- package/src/providers/booking-dialog-provider.tsx +107 -38
- package/src/providers/bottom-sheet-provider.tsx +40 -0
- package/src/providers/dependent-add-on-dialog-provider.tsx +105 -0
- package/src/radius.css +5 -0
- package/src/spacing.css +7 -0
- package/src/strings/en.json +1774 -0
- package/src/strings/es.json +1573 -0
- package/src/strings/fr.json +1573 -0
- package/src/strings/index.js +23 -0
- package/src/text-style.css +97 -0
- package/src/types/fareharbor.d.ts +12 -0
- package/src/types/quiz.ts +59 -0
- package/src/utils/currency-converter.ts +101 -0
- package/src/components/BookingFlow.tsx +0 -2952
- package/src/components/LanguageSwitcher.tsx +0 -30
- package/src/components/PrivateShuttleBookingFlow.tsx +0 -2290
- package/src/components/ProductList.tsx +0 -78
- package/src/components/WhatsAppPhoneInput.tsx +0 -224
- package/src/components/index.ts +0 -31
- package/src/lib/api.ts +0 -801
- package/src/lib/booking-api-auth.ts +0 -9
- package/src/lib/checkout-breakdown.test.ts +0 -70
- package/src/types/google-maps.d.ts +0 -2
- /package/src/components/{CurrencySwitcher.tsx → booking/CurrencySwitcher.tsx} +0 -0
- /package/src/components/{ErrorBoundary.tsx → booking/ErrorBoundary.tsx} +0 -0
- /package/src/lib/{i18n → booking/i18n}/config.ts +0 -0
- /package/src/lib/{i18n → booking/i18n}/index.tsx +0 -0
- /package/src/lib/{marker-icons.ts → booking/marker-icons.ts} +0 -0
- /package/src/lib/{places-api.ts → booking/places-api.ts} +0 -0
- /package/src/lib/{theme.ts → booking/theme.ts} +0 -0
- /package/src/lib/{utils.ts → booking/utils.ts} +0 -0
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import type { Product } from '@/lib/api';
|
|
4
|
-
import { useTranslations, useLocale } from '@/lib/i18n';
|
|
5
|
-
import type { Currency } from '@/components/CurrencySwitcher';
|
|
6
|
-
import { formatCurrencyAmount } from '@/lib/currency';
|
|
7
|
-
|
|
8
|
-
/** Lowest base price in display currency from ticketbooth-product-prices (minPriceByCurrency). No conversion; CAD fallback from option pricing only. */
|
|
9
|
-
function getProductFromPrice(product: Product, currency: Currency): number | undefined {
|
|
10
|
-
const fromApi = product.minPriceByCurrency?.[currency];
|
|
11
|
-
if (fromApi != null) return fromApi;
|
|
12
|
-
if (currency !== 'CAD') return undefined;
|
|
13
|
-
const activeOptions = product.options?.filter((opt) => opt.status === 'ACTIVE') || [];
|
|
14
|
-
const adultPricesCAD = activeOptions
|
|
15
|
-
.map((opt) => opt.pricing?.ADULT)
|
|
16
|
-
.filter((price): price is number => price != null);
|
|
17
|
-
return adultPricesCAD.length > 0 ? Math.min(...adultPricesCAD) : undefined;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface ProductListProps {
|
|
21
|
-
products: Product[];
|
|
22
|
-
onSelect: (product: Product) => void;
|
|
23
|
-
currency: Currency;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function ProductList({ products, onSelect, currency }: ProductListProps) {
|
|
27
|
-
const { t } = useTranslations();
|
|
28
|
-
const { locale } = useLocale();
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<div className="space-y-4">
|
|
32
|
-
{products.map((product) => {
|
|
33
|
-
const fromPrice = getProductFromPrice(product, currency);
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<button
|
|
37
|
-
key={product.productId}
|
|
38
|
-
onClick={() => onSelect(product)}
|
|
39
|
-
className="w-full text-left p-6 bg-white rounded-xl border border-stone-200 hover:border-emerald-400 hover:shadow-lg transition-all group"
|
|
40
|
-
>
|
|
41
|
-
<div className="flex items-start justify-between">
|
|
42
|
-
<div className="flex-1">
|
|
43
|
-
<div className="flex items-center gap-2">
|
|
44
|
-
<h3 className="text-lg font-semibold text-stone-900 group-hover:text-emerald-700 transition-colors">
|
|
45
|
-
{product.name}
|
|
46
|
-
</h3>
|
|
47
|
-
{product.mostPopular && (
|
|
48
|
-
<span className="inline-flex items-center rounded-full bg-[#ff4d00] text-white text-[10px] font-semibold px-1.5 py-0.5">
|
|
49
|
-
{t('booking.mostPopular') ?? 'Most popular'}
|
|
50
|
-
</span>
|
|
51
|
-
)}
|
|
52
|
-
</div>
|
|
53
|
-
{product.description && (
|
|
54
|
-
<p className="mt-1 text-sm text-stone-500 line-clamp-2">
|
|
55
|
-
{product.description}
|
|
56
|
-
</p>
|
|
57
|
-
)}
|
|
58
|
-
{fromPrice != null && (
|
|
59
|
-
<p className="mt-3 text-sm font-medium text-emerald-600">
|
|
60
|
-
{t('products.from')} {formatCurrencyAmount(fromPrice, currency, locale)}
|
|
61
|
-
</p>
|
|
62
|
-
)}
|
|
63
|
-
</div>
|
|
64
|
-
<div className="ml-4 text-stone-400 group-hover:text-emerald-600 transition-colors">
|
|
65
|
-
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
66
|
-
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
|
|
67
|
-
</svg>
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
</button>
|
|
71
|
-
);
|
|
72
|
-
})}
|
|
73
|
-
</div>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useMemo, useState, useEffect, useRef } from 'react';
|
|
4
|
-
|
|
5
|
-
const COUNTRY_OPTIONS: { code: string; dial: string; flag: string }[] = [
|
|
6
|
-
{ code: 'CA', dial: '+1', flag: '🇨🇦' },
|
|
7
|
-
{ code: 'US', dial: '+1', flag: '🇺🇸' },
|
|
8
|
-
{ code: 'GB', dial: '+44', flag: '🇬🇧' },
|
|
9
|
-
{ code: 'AU', dial: '+61', flag: '🇦🇺' },
|
|
10
|
-
{ code: 'DE', dial: '+49', flag: '🇩🇪' },
|
|
11
|
-
{ code: 'FR', dial: '+33', flag: '🇫🇷' },
|
|
12
|
-
{ code: 'ES', dial: '+34', flag: '🇪🇸' },
|
|
13
|
-
{ code: 'IT', dial: '+39', flag: '🇮🇹' },
|
|
14
|
-
{ code: 'MX', dial: '+52', flag: '🇲🇽' },
|
|
15
|
-
{ code: 'IN', dial: '+91', flag: '🇮🇳' },
|
|
16
|
-
{ code: 'JP', dial: '+81', flag: '🇯🇵' },
|
|
17
|
-
{ code: 'BR', dial: '+55', flag: '🇧🇷' },
|
|
18
|
-
{ code: 'NL', dial: '+31', flag: '🇳🇱' },
|
|
19
|
-
{ code: 'IE', dial: '+353', flag: '🇮🇪' },
|
|
20
|
-
{ code: 'NZ', dial: '+64', flag: '🇳🇿' },
|
|
21
|
-
{ code: 'ZA', dial: '+27', flag: '🇿🇦' },
|
|
22
|
-
{ code: 'SG', dial: '+65', flag: '🇸🇬' },
|
|
23
|
-
{ code: 'HK', dial: '+852', flag: '🇭🇰' },
|
|
24
|
-
{ code: 'PH', dial: '+63', flag: '🇵🇭' },
|
|
25
|
-
{ code: 'PL', dial: '+48', flag: '🇵🇱' },
|
|
26
|
-
{ code: 'SE', dial: '+46', flag: '🇸🇪' },
|
|
27
|
-
{ code: 'CH', dial: '+41', flag: '🇨🇭' },
|
|
28
|
-
{ code: 'AT', dial: '+43', flag: '🇦🇹' },
|
|
29
|
-
{ code: 'BE', dial: '+32', flag: '🇧🇪' },
|
|
30
|
-
{ code: 'PT', dial: '+351', flag: '🇵🇹' },
|
|
31
|
-
{ code: 'GR', dial: '+30', flag: '🇬🇷' },
|
|
32
|
-
{ code: 'CZ', dial: '+420', flag: '🇨🇿' },
|
|
33
|
-
{ code: 'RO', dial: '+40', flag: '🇷🇴' },
|
|
34
|
-
{ code: 'HU', dial: '+36', flag: '🇭🇺' },
|
|
35
|
-
{ code: 'TR', dial: '+90', flag: '🇹🇷' },
|
|
36
|
-
{ code: 'IL', dial: '+972', flag: '🇮🇱' },
|
|
37
|
-
{ code: 'AE', dial: '+971', flag: '🇦🇪' },
|
|
38
|
-
{ code: 'SA', dial: '+966', flag: '🇸🇦' },
|
|
39
|
-
{ code: 'CN', dial: '+86', flag: '🇨🇳' },
|
|
40
|
-
{ code: 'KR', dial: '+82', flag: '🇰🇷' },
|
|
41
|
-
{ code: 'TH', dial: '+66', flag: '🇹🇭' },
|
|
42
|
-
{ code: 'MY', dial: '+60', flag: '🇲🇾' },
|
|
43
|
-
{ code: 'ID', dial: '+62', flag: '🇮🇩' },
|
|
44
|
-
{ code: 'VN', dial: '+84', flag: '🇻🇳' },
|
|
45
|
-
{ code: 'AR', dial: '+54', flag: '🇦🇷' },
|
|
46
|
-
{ code: 'CL', dial: '+56', flag: '🇨🇱' },
|
|
47
|
-
{ code: 'CO', dial: '+57', flag: '🇨🇴' },
|
|
48
|
-
{ code: 'PE', dial: '+51', flag: '🇵🇪' },
|
|
49
|
-
{ code: 'EG', dial: '+20', flag: '🇪🇬' },
|
|
50
|
-
{ code: 'NG', dial: '+234', flag: '🇳🇬' },
|
|
51
|
-
{ code: 'KE', dial: '+254', flag: '🇰🇪' },
|
|
52
|
-
{ code: 'RU', dial: '+7', flag: '🇷🇺' },
|
|
53
|
-
{ code: 'UA', dial: '+380', flag: '🇺🇦' },
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
const DIAL_TO_COUNTRIES = COUNTRY_OPTIONS.reduce<Record<string, string[]>>((acc, c) => {
|
|
57
|
-
if (!acc[c.dial]) acc[c.dial] = [];
|
|
58
|
-
acc[c.dial].push(c.code);
|
|
59
|
-
return acc;
|
|
60
|
-
}, {});
|
|
61
|
-
|
|
62
|
-
function parsePhoneValue(value: string): { dial: string; local: string; countryCode: string | null } {
|
|
63
|
-
if (!value || typeof value !== 'string') return { dial: '+1', local: '', countryCode: null };
|
|
64
|
-
const trimmed = value.trim();
|
|
65
|
-
|
|
66
|
-
if (trimmed.match(/^\+\d+$/)) {
|
|
67
|
-
const dial = trimmed;
|
|
68
|
-
const codes = DIAL_TO_COUNTRIES[dial];
|
|
69
|
-
return { dial, local: '', countryCode: codes?.length === 1 ? codes[0]! : null };
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const digitsOnly = trimmed.replace(/\D/g, '');
|
|
73
|
-
if (!digitsOnly) return { dial: '+1', local: '', countryCode: null };
|
|
74
|
-
|
|
75
|
-
const sortedByDialLength = [...COUNTRY_OPTIONS].sort((a, b) => {
|
|
76
|
-
const aDigits = a.dial.replace(/\D/g, '').length;
|
|
77
|
-
const bDigits = b.dial.replace(/\D/g, '').length;
|
|
78
|
-
return bDigits - aDigits;
|
|
79
|
-
});
|
|
80
|
-
const dialDigits = (d: string) => d.replace(/\D/g, '');
|
|
81
|
-
for (const c of sortedByDialLength) {
|
|
82
|
-
const d = dialDigits(c.dial);
|
|
83
|
-
if (digitsOnly.startsWith(d)) {
|
|
84
|
-
const codes = DIAL_TO_COUNTRIES[c.dial];
|
|
85
|
-
return {
|
|
86
|
-
dial: c.dial,
|
|
87
|
-
local: digitsOnly.slice(d.length),
|
|
88
|
-
countryCode: codes?.length === 1 ? codes[0]! : null,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return { dial: '+1', local: digitsOnly, countryCode: null };
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function formatLocal(local: string, dial: string): string {
|
|
96
|
-
const d = local.replace(/\D/g, '');
|
|
97
|
-
if (!d) return '';
|
|
98
|
-
|
|
99
|
-
if (dial === '+1') {
|
|
100
|
-
if (d.length <= 3) return d;
|
|
101
|
-
if (d.length <= 6) return `(${d.slice(0, 3)}) ${d.slice(3)}`;
|
|
102
|
-
return `(${d.slice(0, 3)}) ${d.slice(3, 6)}-${d.slice(6, 10)}`;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const parts: string[] = [];
|
|
106
|
-
for (let i = 0; i < d.length; i += 3) {
|
|
107
|
-
parts.push(d.slice(i, i + 3));
|
|
108
|
-
}
|
|
109
|
-
return parts.join(' ').trim();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export interface WhatsAppPhoneInputProps {
|
|
113
|
-
value: string;
|
|
114
|
-
onChange: (value: string) => void;
|
|
115
|
-
placeholder?: string;
|
|
116
|
-
label?: string;
|
|
117
|
-
optional?: boolean;
|
|
118
|
-
error?: string;
|
|
119
|
-
'data-testid'?: string;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export function WhatsAppPhoneInput({
|
|
123
|
-
value,
|
|
124
|
-
onChange,
|
|
125
|
-
placeholder = '(555) 123-4567',
|
|
126
|
-
label = 'WhatsApp Number',
|
|
127
|
-
optional = true,
|
|
128
|
-
error,
|
|
129
|
-
'data-testid': dataTestId,
|
|
130
|
-
}: WhatsAppPhoneInputProps) {
|
|
131
|
-
const parsed = useMemo(() => parsePhoneValue(value), [value]);
|
|
132
|
-
const { local, countryCode: derivedCountry } = parsed;
|
|
133
|
-
|
|
134
|
-
const [selectedCountryCode, setSelectedCountryCode] = useState<string>(() => {
|
|
135
|
-
if (derivedCountry) return derivedCountry;
|
|
136
|
-
return 'CA';
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
const [localDigits, setLocalDigits] = useState(() => local);
|
|
140
|
-
const lastEmitted = useRef(value);
|
|
141
|
-
const justEmitted = useRef(false);
|
|
142
|
-
|
|
143
|
-
useEffect(() => {
|
|
144
|
-
if (derivedCountry) setSelectedCountryCode(derivedCountry);
|
|
145
|
-
}, [derivedCountry]);
|
|
146
|
-
|
|
147
|
-
useEffect(() => {
|
|
148
|
-
if (justEmitted.current) {
|
|
149
|
-
justEmitted.current = false;
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
if (value !== lastEmitted.current) {
|
|
153
|
-
lastEmitted.current = value;
|
|
154
|
-
setLocalDigits(local);
|
|
155
|
-
}
|
|
156
|
-
}, [value, local]);
|
|
157
|
-
|
|
158
|
-
const selected = COUNTRY_OPTIONS.find((c) => c.code === selectedCountryCode) ?? COUNTRY_OPTIONS[0];
|
|
159
|
-
|
|
160
|
-
const handleCountryChange = (code: string) => {
|
|
161
|
-
setSelectedCountryCode(code);
|
|
162
|
-
const c = COUNTRY_OPTIONS.find((x) => x.code === code) ?? COUNTRY_OPTIONS[0];
|
|
163
|
-
const digits = localDigits.replace(/\D/g, '').slice(0, 15);
|
|
164
|
-
const full = `${c.dial}${digits}`;
|
|
165
|
-
lastEmitted.current = full;
|
|
166
|
-
justEmitted.current = true;
|
|
167
|
-
onChange(full);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
const handleLocalChange = (input: string) => {
|
|
171
|
-
const digits = input.replace(/\D/g, '').slice(0, 15);
|
|
172
|
-
setLocalDigits(digits);
|
|
173
|
-
const full = `${selected.dial}${digits}`;
|
|
174
|
-
lastEmitted.current = full;
|
|
175
|
-
justEmitted.current = true;
|
|
176
|
-
onChange(full);
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
const displayLocal = formatLocal(localDigits || local, selected.dial);
|
|
180
|
-
|
|
181
|
-
return (
|
|
182
|
-
<div className="space-y-1">
|
|
183
|
-
{label && (
|
|
184
|
-
<label className="block text-sm font-medium text-stone-700 mb-2">
|
|
185
|
-
{label}
|
|
186
|
-
{optional && <span className="text-stone-400 text-xs font-normal ml-1">(optional)</span>}
|
|
187
|
-
</label>
|
|
188
|
-
)}
|
|
189
|
-
<div
|
|
190
|
-
data-testid={dataTestId}
|
|
191
|
-
className={`flex rounded-lg border bg-white overflow-hidden transition-shadow ${
|
|
192
|
-
error
|
|
193
|
-
? 'border-red-400 focus-within:ring-2 focus-within:ring-red-500 focus-within:border-red-500'
|
|
194
|
-
: 'border-stone-300 focus-within:ring-2 focus-within:ring-emerald-500 focus-within:border-emerald-500'
|
|
195
|
-
}`}
|
|
196
|
-
>
|
|
197
|
-
<select
|
|
198
|
-
value={selected.code}
|
|
199
|
-
onChange={(e) => handleCountryChange(e.target.value)}
|
|
200
|
-
className="w-20 min-w-0 shrink-0 pl-2 pr-6 py-3 bg-stone-50 border-r border-stone-200 text-stone-900 text-sm font-medium focus:outline-none cursor-pointer appearance-none bg-[length:10px] bg-[right_4px_center] bg-no-repeat"
|
|
201
|
-
style={{
|
|
202
|
-
backgroundImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23787571'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E")`,
|
|
203
|
-
}}
|
|
204
|
-
>
|
|
205
|
-
{COUNTRY_OPTIONS.map((c) => (
|
|
206
|
-
<option key={c.code} value={c.code}>
|
|
207
|
-
{c.flag} {c.dial}
|
|
208
|
-
</option>
|
|
209
|
-
))}
|
|
210
|
-
</select>
|
|
211
|
-
<input
|
|
212
|
-
type="tel"
|
|
213
|
-
inputMode="numeric"
|
|
214
|
-
autoComplete="tel-national"
|
|
215
|
-
value={displayLocal}
|
|
216
|
-
onChange={(e) => handleLocalChange(e.target.value)}
|
|
217
|
-
placeholder={placeholder}
|
|
218
|
-
className="flex-1 min-w-0 py-3 px-4 text-stone-900 placeholder-stone-400 focus:outline-none text-sm"
|
|
219
|
-
/>
|
|
220
|
-
</div>
|
|
221
|
-
{error && <p className="text-xs text-red-600 mt-1">{error}</p>}
|
|
222
|
-
</div>
|
|
223
|
-
);
|
|
224
|
-
}
|
package/src/components/index.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Booking Widget Components
|
|
3
|
-
*
|
|
4
|
-
* Exports embeddable components for use in other React applications
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export { BookingWidget } from './BookingWidget';
|
|
8
|
-
export type { BookingWidgetProps } from './BookingWidget';
|
|
9
|
-
export type { BookingAppMode, BookingAppPermissions, ViewerRole, ManageParams } from '../contexts/BookingAppContext';
|
|
10
|
-
export { ManageBookingView } from './ManageBookingView';
|
|
11
|
-
export type { ManageBookingViewProps, StaffBookingAttribution } from './ManageBookingView';
|
|
12
|
-
|
|
13
|
-
export { BookingFlow } from './BookingFlow';
|
|
14
|
-
export { Calendar } from './Calendar';
|
|
15
|
-
export type { DateAvailability } from './Calendar';
|
|
16
|
-
export { PickupLocationSelector } from './PickupLocationSelector';
|
|
17
|
-
export type { CustomPickupLocation } from './PickupLocationSelector';
|
|
18
|
-
export { BookingDetails } from './BookingDetails';
|
|
19
|
-
export { PriceBreakdown } from './PriceBreakdown';
|
|
20
|
-
export type { PriceBreakdownProps } from './PriceBreakdown';
|
|
21
|
-
export { ProductList } from './ProductList';
|
|
22
|
-
export { CurrencySwitcher, useCurrency } from './CurrencySwitcher';
|
|
23
|
-
export type { Currency } from './CurrencySwitcher';
|
|
24
|
-
|
|
25
|
-
// Re-export types from API for convenience
|
|
26
|
-
export type { Product, Availability } from '@/lib/api';
|
|
27
|
-
|
|
28
|
-
// Theme: host can pass partial theme to customize colours, fonts, etc.
|
|
29
|
-
export type { BookingTheme } from '../lib/theme';
|
|
30
|
-
export { DEFAULT_BOOKING_THEME, mergeTheme } from '../lib/theme';
|
|
31
|
-
|