@voyant-travel/inventory-react 0.1.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/LICENSE +201 -0
- package/dist/admin/index.d.ts +91 -0
- package/dist/admin/index.d.ts.map +1 -0
- package/dist/admin/index.js +132 -0
- package/dist/admin/pages/product-detail-page.d.ts +18 -0
- package/dist/admin/pages/product-detail-page.d.ts.map +1 -0
- package/dist/admin/pages/product-detail-page.js +63 -0
- package/dist/admin/product-categories-host.d.ts +7 -0
- package/dist/admin/product-categories-host.d.ts.map +1 -0
- package/dist/admin/product-categories-host.js +11 -0
- package/dist/admin/product-detail-api.d.ts +22 -0
- package/dist/admin/product-detail-api.d.ts.map +1 -0
- package/dist/admin/product-detail-api.js +58 -0
- package/dist/admin/products-host.d.ts +11 -0
- package/dist/admin/products-host.d.ts.map +1 -0
- package/dist/admin/products-host.js +17 -0
- package/dist/admin/products-list-skeleton.d.ts +10 -0
- package/dist/admin/products-list-skeleton.d.ts.map +1 -0
- package/dist/admin/products-list-skeleton.js +23 -0
- package/dist/client.d.ts +16 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +79 -0
- package/dist/components/option-unit-dialog.d.ts +11 -0
- package/dist/components/option-unit-dialog.d.ts.map +1 -0
- package/dist/components/option-unit-dialog.js +17 -0
- package/dist/components/option-unit-form.d.ts +17 -0
- package/dist/components/option-unit-form.d.ts.map +1 -0
- package/dist/components/option-unit-form.js +123 -0
- package/dist/components/product-action-ledger-card.d.ts +17 -0
- package/dist/components/product-action-ledger-card.d.ts.map +1 -0
- package/dist/components/product-action-ledger-card.js +73 -0
- package/dist/components/product-catalog-card.d.ts +14 -0
- package/dist/components/product-catalog-card.d.ts.map +1 -0
- package/dist/components/product-catalog-card.js +44 -0
- package/dist/components/product-categories-page.d.ts +7 -0
- package/dist/components/product-categories-page.d.ts.map +1 -0
- package/dist/components/product-categories-page.js +9 -0
- package/dist/components/product-category-combobox.d.ts +10 -0
- package/dist/components/product-category-combobox.d.ts.map +1 -0
- package/dist/components/product-category-combobox.js +47 -0
- package/dist/components/product-category-dialog.d.ts +9 -0
- package/dist/components/product-category-dialog.d.ts.map +1 -0
- package/dist/components/product-category-dialog.js +17 -0
- package/dist/components/product-category-form.d.ts +15 -0
- package/dist/components/product-category-form.d.ts.map +1 -0
- package/dist/components/product-category-form.js +82 -0
- package/dist/components/product-category-list.d.ts +5 -0
- package/dist/components/product-category-list.d.ts.map +1 -0
- package/dist/components/product-category-list.js +48 -0
- package/dist/components/product-combobox.d.ts +13 -0
- package/dist/components/product-combobox.d.ts.map +1 -0
- package/dist/components/product-combobox.js +23 -0
- package/dist/components/product-contract-template-combobox.d.ts +9 -0
- package/dist/components/product-contract-template-combobox.d.ts.map +1 -0
- package/dist/components/product-contract-template-combobox.js +97 -0
- package/dist/components/product-day-dialog.d.ts +20 -0
- package/dist/components/product-day-dialog.d.ts.map +1 -0
- package/dist/components/product-day-dialog.js +20 -0
- package/dist/components/product-day-form.d.ts +19 -0
- package/dist/components/product-day-form.d.ts.map +1 -0
- package/dist/components/product-day-form.js +77 -0
- package/dist/components/product-day-media-tray.d.ts +11 -0
- package/dist/components/product-day-media-tray.d.ts.map +1 -0
- package/dist/components/product-day-media-tray.js +74 -0
- package/dist/components/product-day-service-dialog.d.ts +14 -0
- package/dist/components/product-day-service-dialog.d.ts.map +1 -0
- package/dist/components/product-day-service-dialog.js +19 -0
- package/dist/components/product-day-service-form.d.ts +44 -0
- package/dist/components/product-day-service-form.d.ts.map +1 -0
- package/dist/components/product-day-service-form.js +152 -0
- package/dist/components/product-detail/commerce-client.d.ts +314 -0
- package/dist/components/product-detail/commerce-client.d.ts.map +1 -0
- package/dist/components/product-detail/commerce-client.js +261 -0
- package/dist/components/product-detail/host.d.ts +54 -0
- package/dist/components/product-detail/host.d.ts.map +1 -0
- package/dist/components/product-detail/host.js +27 -0
- package/dist/components/product-detail/index.d.ts +6 -0
- package/dist/components/product-detail/index.d.ts.map +1 -0
- package/dist/components/product-detail/index.js +5 -0
- package/dist/components/product-detail/product-activity-section.d.ts +4 -0
- package/dist/components/product-detail/product-activity-section.d.ts.map +1 -0
- package/dist/components/product-detail/product-activity-section.js +37 -0
- package/dist/components/product-detail/product-day-sheet.d.ts +14 -0
- package/dist/components/product-detail/product-day-sheet.d.ts.map +1 -0
- package/dist/components/product-detail/product-day-sheet.js +75 -0
- package/dist/components/product-detail/product-day-translation.d.ts +41 -0
- package/dist/components/product-detail/product-day-translation.d.ts.map +1 -0
- package/dist/components/product-detail/product-day-translation.js +111 -0
- package/dist/components/product-detail/product-departure-dialog.d.ts +11 -0
- package/dist/components/product-detail/product-departure-dialog.d.ts.map +1 -0
- package/dist/components/product-detail/product-departure-dialog.js +10 -0
- package/dist/components/product-detail/product-departure-form.d.ts +25 -0
- package/dist/components/product-detail/product-departure-form.d.ts.map +1 -0
- package/dist/components/product-detail/product-departure-form.js +241 -0
- package/dist/components/product-detail/product-departure-pricing-override-dialog.d.ts +8 -0
- package/dist/components/product-detail/product-departure-pricing-override-dialog.d.ts.map +1 -0
- package/dist/components/product-detail/product-departure-pricing-override-dialog.js +126 -0
- package/dist/components/product-detail/product-detail-availability-sections.d.ts +19 -0
- package/dist/components/product-detail/product-detail-availability-sections.d.ts.map +1 -0
- package/dist/components/product-detail/product-detail-availability-sections.js +29 -0
- package/dist/components/product-detail/product-detail-channel-section.d.ts +8 -0
- package/dist/components/product-detail/product-detail-channel-section.d.ts.map +1 -0
- package/dist/components/product-detail/product-detail-channel-section.js +16 -0
- package/dist/components/product-detail/product-detail-day-row.d.ts +14 -0
- package/dist/components/product-detail/product-detail-day-row.d.ts.map +1 -0
- package/dist/components/product-detail/product-detail-day-row.js +43 -0
- package/dist/components/product-detail/product-detail-dialog.d.ts +10 -0
- package/dist/components/product-detail/product-detail-dialog.d.ts.map +1 -0
- package/dist/components/product-detail/product-detail-dialog.js +10 -0
- package/dist/components/product-detail/product-detail-form.d.ts +22 -0
- package/dist/components/product-detail/product-detail-form.d.ts.map +1 -0
- package/dist/components/product-detail/product-detail-form.js +205 -0
- package/dist/components/product-detail/product-detail-header.d.ts +12 -0
- package/dist/components/product-detail/product-detail-header.d.ts.map +1 -0
- package/dist/components/product-detail/product-detail-header.js +19 -0
- package/dist/components/product-detail/product-detail-itinerary-section.d.ts +4 -0
- package/dist/components/product-detail/product-detail-itinerary-section.d.ts.map +1 -0
- package/dist/components/product-detail/product-detail-itinerary-section.js +201 -0
- package/dist/components/product-detail/product-detail-media-sections.d.ts +15 -0
- package/dist/components/product-detail/product-detail-media-sections.d.ts.map +1 -0
- package/dist/components/product-detail/product-detail-media-sections.js +19 -0
- package/dist/components/product-detail/product-detail-organize-section.d.ts +6 -0
- package/dist/components/product-detail/product-detail-organize-section.d.ts.map +1 -0
- package/dist/components/product-detail/product-detail-organize-section.js +18 -0
- package/dist/components/product-detail/product-detail-page.d.ts +4 -0
- package/dist/components/product-detail/product-detail-page.d.ts.map +1 -0
- package/dist/components/product-detail/product-detail-page.js +95 -0
- package/dist/components/product-detail/product-detail-section-shell.d.ts +19 -0
- package/dist/components/product-detail/product-detail-section-shell.d.ts.map +1 -0
- package/dist/components/product-detail/product-detail-section-shell.js +23 -0
- package/dist/components/product-detail/product-detail-sections.d.ts +7 -0
- package/dist/components/product-detail/product-detail-sections.d.ts.map +1 -0
- package/dist/components/product-detail/product-detail-sections.js +6 -0
- package/dist/components/product-detail/product-detail-shared.d.ts +264 -0
- package/dist/components/product-detail/product-detail-shared.d.ts.map +1 -0
- package/dist/components/product-detail/product-detail-shared.js +157 -0
- package/dist/components/product-detail/product-detail-skeleton.d.ts +9 -0
- package/dist/components/product-detail/product-detail-skeleton.d.ts.map +1 -0
- package/dist/components/product-detail/product-detail-skeleton.js +53 -0
- package/dist/components/product-detail/product-detail-summary-section.d.ts +6 -0
- package/dist/components/product-detail/product-detail-summary-section.d.ts.map +1 -0
- package/dist/components/product-detail/product-detail-summary-section.js +66 -0
- package/dist/components/product-detail/product-extra-dialog.d.ts +21 -0
- package/dist/components/product-detail/product-extra-dialog.d.ts.map +1 -0
- package/dist/components/product-detail/product-extra-dialog.js +131 -0
- package/dist/components/product-detail/product-itinerary-form.d.ts +16 -0
- package/dist/components/product-detail/product-itinerary-form.d.ts.map +1 -0
- package/dist/components/product-detail/product-itinerary-form.js +38 -0
- package/dist/components/product-detail/product-market-rules-section.d.ts +6 -0
- package/dist/components/product-detail/product-market-rules-section.d.ts.map +1 -0
- package/dist/components/product-detail/product-market-rules-section.js +81 -0
- package/dist/components/product-detail/product-media-gallery.d.ts +19 -0
- package/dist/components/product-detail/product-media-gallery.d.ts.map +1 -0
- package/dist/components/product-detail/product-media-gallery.js +114 -0
- package/dist/components/product-detail/product-option-price-rule-dialog.d.ts +12 -0
- package/dist/components/product-detail/product-option-price-rule-dialog.d.ts.map +1 -0
- package/dist/components/product-detail/product-option-price-rule-dialog.js +10 -0
- package/dist/components/product-detail/product-option-price-rule-form.d.ts +29 -0
- package/dist/components/product-detail/product-option-price-rule-form.d.ts.map +1 -0
- package/dist/components/product-detail/product-option-price-rule-form.js +122 -0
- package/dist/components/product-detail/product-option-pricing-grid.d.ts +16 -0
- package/dist/components/product-detail/product-option-pricing-grid.d.ts.map +1 -0
- package/dist/components/product-detail/product-option-pricing-grid.js +236 -0
- package/dist/components/product-detail/product-options-extra-price-rules.d.ts +8 -0
- package/dist/components/product-detail/product-options-extra-price-rules.d.ts.map +1 -0
- package/dist/components/product-detail/product-options-extra-price-rules.js +123 -0
- package/dist/components/product-detail/product-options-pricing-helpers.d.ts +14 -0
- package/dist/components/product-detail/product-options-pricing-helpers.d.ts.map +1 -0
- package/dist/components/product-detail/product-options-pricing-helpers.js +49 -0
- package/dist/components/product-detail/product-options-pricing-panel.d.ts +17 -0
- package/dist/components/product-detail/product-options-pricing-panel.d.ts.map +1 -0
- package/dist/components/product-detail/product-options-pricing-panel.js +88 -0
- package/dist/components/product-detail/product-options-pricing.d.ts +5 -0
- package/dist/components/product-detail/product-options-pricing.d.ts.map +1 -0
- package/dist/components/product-detail/product-options-pricing.js +4 -0
- package/dist/components/product-detail/product-options-shared.d.ts +236 -0
- package/dist/components/product-detail/product-options-shared.d.ts.map +1 -0
- package/dist/components/product-detail/product-options-shared.js +57 -0
- package/dist/components/product-detail/product-options-traveler-category-dialog.d.ts +12 -0
- package/dist/components/product-detail/product-options-traveler-category-dialog.d.ts.map +1 -0
- package/dist/components/product-detail/product-options-traveler-category-dialog.js +132 -0
- package/dist/components/product-detail/product-options-unit-price-matrix.d.ts +10 -0
- package/dist/components/product-detail/product-options-unit-price-matrix.d.ts.map +1 -0
- package/dist/components/product-detail/product-options-unit-price-matrix.js +103 -0
- package/dist/components/product-detail/product-payment-policy-section.d.ts +17 -0
- package/dist/components/product-detail/product-payment-policy-section.d.ts.map +1 -0
- package/dist/components/product-detail/product-payment-policy-section.js +58 -0
- package/dist/components/product-detail/product-schedule-dialog.d.ts +11 -0
- package/dist/components/product-detail/product-schedule-dialog.d.ts.map +1 -0
- package/dist/components/product-detail/product-schedule-dialog.js +10 -0
- package/dist/components/product-detail/product-schedule-form.d.ts +17 -0
- package/dist/components/product-detail/product-schedule-form.d.ts.map +1 -0
- package/dist/components/product-detail/product-schedule-form.js +223 -0
- package/dist/components/product-detail/product-service-dialog.d.ts +12 -0
- package/dist/components/product-detail/product-service-dialog.d.ts.map +1 -0
- package/dist/components/product-detail/product-service-dialog.js +10 -0
- package/dist/components/product-detail/product-service-form.d.ts +22 -0
- package/dist/components/product-detail/product-service-form.d.ts.map +1 -0
- package/dist/components/product-detail/product-service-form.js +154 -0
- package/dist/components/product-detail/product-translation-popover.d.ts +94 -0
- package/dist/components/product-detail/product-translation-popover.d.ts.map +1 -0
- package/dist/components/product-detail/product-translation-popover.js +238 -0
- package/dist/components/product-detail/product-unit-dialog.d.ts +14 -0
- package/dist/components/product-detail/product-unit-dialog.d.ts.map +1 -0
- package/dist/components/product-detail/product-unit-dialog.js +10 -0
- package/dist/components/product-detail/product-unit-form.d.ts +34 -0
- package/dist/components/product-detail/product-unit-form.d.ts.map +1 -0
- package/dist/components/product-detail/product-unit-form.js +139 -0
- package/dist/components/product-detail/product-unit-price-rule-dialog.d.ts +17 -0
- package/dist/components/product-detail/product-unit-price-rule-dialog.d.ts.map +1 -0
- package/dist/components/product-detail/product-unit-price-rule-dialog.js +10 -0
- package/dist/components/product-detail/product-unit-price-rule-form.d.ts +29 -0
- package/dist/components/product-detail/product-unit-price-rule-form.d.ts.map +1 -0
- package/dist/components/product-detail/product-unit-price-rule-form.js +144 -0
- package/dist/components/product-detail/rrule-labels.d.ts +2 -0
- package/dist/components/product-detail/rrule-labels.d.ts.map +1 -0
- package/dist/components/product-detail/rrule-labels.js +65 -0
- package/dist/components/product-detail/timezone-options.d.ts +9 -0
- package/dist/components/product-detail/timezone-options.d.ts.map +1 -0
- package/dist/components/product-detail/timezone-options.js +28 -0
- package/dist/components/product-detail/use-product-detail-data.d.ts +41 -0
- package/dist/components/product-detail/use-product-detail-data.d.ts.map +1 -0
- package/dist/components/product-detail/use-product-detail-data.js +143 -0
- package/dist/components/product-detail/use-product-detail-dialogs.d.ts +24 -0
- package/dist/components/product-detail/use-product-detail-dialogs.d.ts.map +1 -0
- package/dist/components/product-detail/use-product-detail-dialogs.js +40 -0
- package/dist/components/product-detail/zod-resolver.d.ts +4 -0
- package/dist/components/product-detail/zod-resolver.d.ts.map +1 -0
- package/dist/components/product-detail/zod-resolver.js +39 -0
- package/dist/components/product-detail-page.d.ts +57 -0
- package/dist/components/product-detail-page.d.ts.map +1 -0
- package/dist/components/product-detail-page.js +118 -0
- package/dist/components/product-detail.d.ts +2 -0
- package/dist/components/product-detail.d.ts.map +1 -0
- package/dist/components/product-detail.js +1 -0
- package/dist/components/product-dialog.d.ts +9 -0
- package/dist/components/product-dialog.d.ts.map +1 -0
- package/dist/components/product-dialog.js +13 -0
- package/dist/components/product-facility-combobox.d.ts +9 -0
- package/dist/components/product-facility-combobox.d.ts.map +1 -0
- package/dist/components/product-facility-combobox.js +94 -0
- package/dist/components/product-form.d.ts +14 -0
- package/dist/components/product-form.d.ts.map +1 -0
- package/dist/components/product-form.js +191 -0
- package/dist/components/product-itinerary-day-row.d.ts +22 -0
- package/dist/components/product-itinerary-day-row.d.ts.map +1 -0
- package/dist/components/product-itinerary-day-row.js +17 -0
- package/dist/components/product-itinerary-dialog.d.ts +16 -0
- package/dist/components/product-itinerary-dialog.d.ts.map +1 -0
- package/dist/components/product-itinerary-dialog.js +85 -0
- package/dist/components/product-itinerary-section.d.ts +16 -0
- package/dist/components/product-itinerary-section.d.ts.map +1 -0
- package/dist/components/product-itinerary-section.js +105 -0
- package/dist/components/product-list.d.ts +7 -0
- package/dist/components/product-list.d.ts.map +1 -0
- package/dist/components/product-list.js +155 -0
- package/dist/components/product-media-dialog.d.ts +11 -0
- package/dist/components/product-media-dialog.d.ts.map +1 -0
- package/dist/components/product-media-dialog.js +17 -0
- package/dist/components/product-media-form.d.ts +17 -0
- package/dist/components/product-media-form.d.ts.map +1 -0
- package/dist/components/product-media-form.js +101 -0
- package/dist/components/product-media-lightbox.d.ts +7 -0
- package/dist/components/product-media-lightbox.d.ts.map +1 -0
- package/dist/components/product-media-lightbox.js +31 -0
- package/dist/components/product-media-section.d.ts +27 -0
- package/dist/components/product-media-section.d.ts.map +1 -0
- package/dist/components/product-media-section.js +130 -0
- package/dist/components/product-media-tile.d.ts +17 -0
- package/dist/components/product-media-tile.d.ts.map +1 -0
- package/dist/components/product-media-tile.js +16 -0
- package/dist/components/product-option-dialog.d.ts +11 -0
- package/dist/components/product-option-dialog.d.ts.map +1 -0
- package/dist/components/product-option-dialog.js +17 -0
- package/dist/components/product-option-form.d.ts +17 -0
- package/dist/components/product-option-form.d.ts.map +1 -0
- package/dist/components/product-option-form.js +91 -0
- package/dist/components/product-options-section.d.ts +13 -0
- package/dist/components/product-options-section.d.ts.map +1 -0
- package/dist/components/product-options-section.js +200 -0
- package/dist/components/product-quick-view-sheet.d.ts +23 -0
- package/dist/components/product-quick-view-sheet.d.ts.map +1 -0
- package/dist/components/product-quick-view-sheet.js +65 -0
- package/dist/components/product-tag-dialog.d.ts +9 -0
- package/dist/components/product-tag-dialog.d.ts.map +1 -0
- package/dist/components/product-tag-dialog.js +17 -0
- package/dist/components/product-tag-form.d.ts +15 -0
- package/dist/components/product-tag-form.d.ts.map +1 -0
- package/dist/components/product-tag-form.js +48 -0
- package/dist/components/product-tag-list.d.ts +5 -0
- package/dist/components/product-tag-list.d.ts.map +1 -0
- package/dist/components/product-tag-list.js +44 -0
- package/dist/components/product-tags-page.d.ts +7 -0
- package/dist/components/product-tags-page.d.ts.map +1 -0
- package/dist/components/product-tags-page.js +9 -0
- package/dist/components/product-tax-class-combobox.d.ts +9 -0
- package/dist/components/product-tax-class-combobox.d.ts.map +1 -0
- package/dist/components/product-tax-class-combobox.js +100 -0
- package/dist/components/product-translations-card.d.ts +7 -0
- package/dist/components/product-translations-card.d.ts.map +1 -0
- package/dist/components/product-translations-card.js +188 -0
- package/dist/components/product-type-combobox.d.ts +9 -0
- package/dist/components/product-type-combobox.d.ts.map +1 -0
- package/dist/components/product-type-combobox.js +48 -0
- package/dist/components/product-types-page.d.ts +6 -0
- package/dist/components/product-types-page.d.ts.map +1 -0
- package/dist/components/product-types-page.js +103 -0
- package/dist/components/product-version-dialog.d.ts +8 -0
- package/dist/components/product-version-dialog.d.ts.map +1 -0
- package/dist/components/product-version-dialog.js +39 -0
- package/dist/components/product-versions-section.d.ts +7 -0
- package/dist/components/product-versions-section.d.ts.map +1 -0
- package/dist/components/product-versions-section.js +19 -0
- package/dist/components/products-page.d.ts +8 -0
- package/dist/components/products-page.d.ts.map +1 -0
- package/dist/components/products-page.js +8 -0
- package/dist/extras/client.d.ts +14 -0
- package/dist/extras/client.d.ts.map +1 -0
- package/dist/extras/client.js +58 -0
- package/dist/extras/components/extra-catalog-card.d.ts +13 -0
- package/dist/extras/components/extra-catalog-card.d.ts.map +1 -0
- package/dist/extras/components/extra-catalog-card.js +52 -0
- package/dist/extras/components/product-combobox.d.ts +9 -0
- package/dist/extras/components/product-combobox.d.ts.map +1 -0
- package/dist/extras/components/product-combobox.js +46 -0
- package/dist/extras/hooks/index.d.ts +4 -0
- package/dist/extras/hooks/index.d.ts.map +1 -0
- package/dist/extras/hooks/index.js +3 -0
- package/dist/extras/hooks/use-product-extra-mutation.d.ts +70 -0
- package/dist/extras/hooks/use-product-extra-mutation.d.ts.map +1 -0
- package/dist/extras/hooks/use-product-extra-mutation.js +38 -0
- package/dist/extras/hooks/use-product-extra.d.ts +24 -0
- package/dist/extras/hooks/use-product-extra.d.ts.map +1 -0
- package/dist/extras/hooks/use-product-extra.js +12 -0
- package/dist/extras/hooks/use-product-extras.d.ts +30 -0
- package/dist/extras/hooks/use-product-extras.d.ts.map +1 -0
- package/dist/extras/hooks/use-product-extras.js +12 -0
- package/dist/extras/i18n/en.d.ts +52 -0
- package/dist/extras/i18n/en.d.ts.map +1 -0
- package/dist/extras/i18n/en.js +51 -0
- package/dist/extras/i18n/index.d.ts +5 -0
- package/dist/extras/i18n/index.d.ts.map +1 -0
- package/dist/extras/i18n/index.js +3 -0
- package/dist/extras/i18n/messages.d.ts +37 -0
- package/dist/extras/i18n/messages.d.ts.map +1 -0
- package/dist/extras/i18n/messages.js +1 -0
- package/dist/extras/i18n/provider.d.ts +126 -0
- package/dist/extras/i18n/provider.d.ts.map +1 -0
- package/dist/extras/i18n/provider.js +44 -0
- package/dist/extras/i18n/ro.d.ts +52 -0
- package/dist/extras/i18n/ro.d.ts.map +1 -0
- package/dist/extras/i18n/ro.js +51 -0
- package/dist/extras/index.d.ts +7 -0
- package/dist/extras/index.d.ts.map +1 -0
- package/dist/extras/index.js +6 -0
- package/dist/extras/provider.d.ts +2 -0
- package/dist/extras/provider.d.ts.map +1 -0
- package/dist/extras/provider.js +1 -0
- package/dist/extras/query-keys.d.ts +16 -0
- package/dist/extras/query-keys.d.ts.map +1 -0
- package/dist/extras/query-keys.js +8 -0
- package/dist/extras/query-options.d.ts +455 -0
- package/dist/extras/query-options.d.ts.map +1 -0
- package/dist/extras/query-options.js +44 -0
- package/dist/extras/schemas.d.ts +416 -0
- package/dist/extras/schemas.d.ts.map +1 -0
- package/dist/extras/schemas.js +89 -0
- package/dist/extras/ui.d.ts +3 -0
- package/dist/extras/ui.d.ts.map +1 -0
- package/dist/extras/ui.js +2 -0
- package/dist/extras-compat.d.ts +3 -0
- package/dist/extras-compat.d.ts.map +1 -0
- package/dist/extras-compat.js +1 -0
- package/dist/extras.d.ts +10 -0
- package/dist/extras.d.ts.map +1 -0
- package/dist/extras.js +9 -0
- package/dist/hooks/index.d.ts +36 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +35 -0
- package/dist/hooks/use-duplicate-product-option-mutation.d.ts +19 -0
- package/dist/hooks/use-duplicate-product-option-mutation.d.ts.map +1 -0
- package/dist/hooks/use-duplicate-product-option-mutation.js +65 -0
- package/dist/hooks/use-option-unit-mutation.d.ts +60 -0
- package/dist/hooks/use-option-unit-mutation.d.ts.map +1 -0
- package/dist/hooks/use-option-unit-mutation.js +41 -0
- package/dist/hooks/use-option-unit.d.ts +21 -0
- package/dist/hooks/use-option-unit.d.ts.map +1 -0
- package/dist/hooks/use-option-unit.js +12 -0
- package/dist/hooks/use-option-units.d.ts +27 -0
- package/dist/hooks/use-option-units.d.ts.map +1 -0
- package/dist/hooks/use-option-units.js +12 -0
- package/dist/hooks/use-product-action-ledger.d.ts +48 -0
- package/dist/hooks/use-product-action-ledger.d.ts.map +1 -0
- package/dist/hooks/use-product-action-ledger.js +12 -0
- package/dist/hooks/use-product-categories.d.ts +32 -0
- package/dist/hooks/use-product-categories.d.ts.map +1 -0
- package/dist/hooks/use-product-categories.js +29 -0
- package/dist/hooks/use-product-category-mutation.d.ts +65 -0
- package/dist/hooks/use-product-category-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-category-mutation.js +39 -0
- package/dist/hooks/use-product-category.d.ts +26 -0
- package/dist/hooks/use-product-category.d.ts.map +1 -0
- package/dist/hooks/use-product-category.js +18 -0
- package/dist/hooks/use-product-day-mutation.d.ts +43 -0
- package/dist/hooks/use-product-day-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-day-mutation.js +54 -0
- package/dist/hooks/use-product-day-service-mutation.d.ts +66 -0
- package/dist/hooks/use-product-day-service-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-day-service-mutation.js +41 -0
- package/dist/hooks/use-product-day-services.d.ts +21 -0
- package/dist/hooks/use-product-day-services.d.ts.map +1 -0
- package/dist/hooks/use-product-day-services.js +12 -0
- package/dist/hooks/use-product-day-translation-mutation.d.ts +49 -0
- package/dist/hooks/use-product-day-translation-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-day-translation-mutation.js +38 -0
- package/dist/hooks/use-product-day-translations.d.ts +19 -0
- package/dist/hooks/use-product-day-translations.d.ts.map +1 -0
- package/dist/hooks/use-product-day-translations.js +20 -0
- package/dist/hooks/use-product-days.d.ts +16 -0
- package/dist/hooks/use-product-days.d.ts.map +1 -0
- package/dist/hooks/use-product-days.js +12 -0
- package/dist/hooks/use-product-itineraries.d.ts +15 -0
- package/dist/hooks/use-product-itineraries.d.ts.map +1 -0
- package/dist/hooks/use-product-itineraries.js +12 -0
- package/dist/hooks/use-product-itinerary-days.d.ts +16 -0
- package/dist/hooks/use-product-itinerary-days.d.ts.map +1 -0
- package/dist/hooks/use-product-itinerary-days.js +12 -0
- package/dist/hooks/use-product-itinerary-mutation.d.ts +54 -0
- package/dist/hooks/use-product-itinerary-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-itinerary-mutation.js +63 -0
- package/dist/hooks/use-product-media-mutation.d.ts +101 -0
- package/dist/hooks/use-product-media-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-media-mutation.js +69 -0
- package/dist/hooks/use-product-media.d.ts +26 -0
- package/dist/hooks/use-product-media.d.ts.map +1 -0
- package/dist/hooks/use-product-media.js +12 -0
- package/dist/hooks/use-product-mutation.d.ts +121 -0
- package/dist/hooks/use-product-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-mutation.js +44 -0
- package/dist/hooks/use-product-option-mutation.d.ts +49 -0
- package/dist/hooks/use-product-option-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-option-mutation.js +39 -0
- package/dist/hooks/use-product-option.d.ts +18 -0
- package/dist/hooks/use-product-option.d.ts.map +1 -0
- package/dist/hooks/use-product-option.js +12 -0
- package/dist/hooks/use-product-options.d.ts +24 -0
- package/dist/hooks/use-product-options.d.ts.map +1 -0
- package/dist/hooks/use-product-options.js +12 -0
- package/dist/hooks/use-product-tag-mutation.d.ts +25 -0
- package/dist/hooks/use-product-tag-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-tag-mutation.js +39 -0
- package/dist/hooks/use-product-tag.d.ts +10 -0
- package/dist/hooks/use-product-tag.d.ts.map +1 -0
- package/dist/hooks/use-product-tag.js +18 -0
- package/dist/hooks/use-product-tags.d.ts +16 -0
- package/dist/hooks/use-product-tags.d.ts.map +1 -0
- package/dist/hooks/use-product-tags.js +25 -0
- package/dist/hooks/use-product-translation-mutation.d.ts +52 -0
- package/dist/hooks/use-product-translation-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-translation-mutation.js +47 -0
- package/dist/hooks/use-product-translations.d.ts +28 -0
- package/dist/hooks/use-product-translations.d.ts.map +1 -0
- package/dist/hooks/use-product-translations.js +24 -0
- package/dist/hooks/use-product-type-mutation.d.ts +50 -0
- package/dist/hooks/use-product-type-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-type-mutation.js +47 -0
- package/dist/hooks/use-product-type.d.ts +15 -0
- package/dist/hooks/use-product-type.d.ts.map +1 -0
- package/dist/hooks/use-product-type.js +12 -0
- package/dist/hooks/use-product-types.d.ts +21 -0
- package/dist/hooks/use-product-types.d.ts.map +1 -0
- package/dist/hooks/use-product-types.js +9 -0
- package/dist/hooks/use-product-version-mutation.d.ts +16 -0
- package/dist/hooks/use-product-version-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-version-mutation.js +22 -0
- package/dist/hooks/use-product-versions.d.ts +15 -0
- package/dist/hooks/use-product-versions.d.ts.map +1 -0
- package/dist/hooks/use-product-versions.js +12 -0
- package/dist/hooks/use-product.d.ts +45 -0
- package/dist/hooks/use-product.d.ts.map +1 -0
- package/dist/hooks/use-product.js +23 -0
- package/dist/hooks/use-products.d.ts +51 -0
- package/dist/hooks/use-products.d.ts.map +1 -0
- package/dist/hooks/use-products.js +38 -0
- package/dist/i18n/en-catalog.d.ts +199 -0
- package/dist/i18n/en-catalog.d.ts.map +1 -0
- package/dist/i18n/en-catalog.js +198 -0
- package/dist/i18n/en-core.d.ts +323 -0
- package/dist/i18n/en-core.d.ts.map +1 -0
- package/dist/i18n/en-core.js +322 -0
- package/dist/i18n/en-operations.d.ts +287 -0
- package/dist/i18n/en-operations.d.ts.map +1 -0
- package/dist/i18n/en-operations.js +286 -0
- package/dist/i18n/en.d.ts +803 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +8 -0
- package/dist/i18n/index.d.ts +5 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +3 -0
- package/dist/i18n/message-shared.d.ts +6 -0
- package/dist/i18n/message-shared.d.ts.map +1 -0
- package/dist/i18n/message-shared.js +1 -0
- package/dist/i18n/messages-catalog.d.ts +199 -0
- package/dist/i18n/messages-catalog.d.ts.map +1 -0
- package/dist/i18n/messages-catalog.js +1 -0
- package/dist/i18n/messages-core.d.ts +304 -0
- package/dist/i18n/messages-core.d.ts.map +1 -0
- package/dist/i18n/messages-core.js +1 -0
- package/dist/i18n/messages-operations.d.ts +287 -0
- package/dist/i18n/messages-operations.d.ts.map +1 -0
- package/dist/i18n/messages-operations.js +1 -0
- package/dist/i18n/messages.d.ts +6 -0
- package/dist/i18n/messages.d.ts.map +1 -0
- package/dist/i18n/messages.js +1 -0
- package/dist/i18n/provider.d.ts +1628 -0
- package/dist/i18n/provider.d.ts.map +1 -0
- package/dist/i18n/provider.js +44 -0
- package/dist/i18n/ro-catalog.d.ts +199 -0
- package/dist/i18n/ro-catalog.d.ts.map +1 -0
- package/dist/i18n/ro-catalog.js +198 -0
- package/dist/i18n/ro-core.d.ts +323 -0
- package/dist/i18n/ro-core.d.ts.map +1 -0
- package/dist/i18n/ro-core.js +322 -0
- package/dist/i18n/ro-operations.d.ts +287 -0
- package/dist/i18n/ro-operations.d.ts.map +1 -0
- package/dist/i18n/ro-operations.js +286 -0
- package/dist/i18n/ro.d.ts +803 -0
- package/dist/i18n/ro.d.ts.map +1 -0
- package/dist/i18n/ro.js +8 -0
- package/dist/i18n-en.d.ts +2 -0
- package/dist/i18n-en.d.ts.map +1 -0
- package/dist/i18n-en.js +1 -0
- package/dist/i18n-ro.d.ts +2 -0
- package/dist/i18n-ro.d.ts.map +1 -0
- package/dist/i18n-ro.js +1 -0
- package/dist/i18n.d.ts +2 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.js +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/operations.d.ts +53 -0
- package/dist/operations.d.ts.map +1 -0
- package/dist/operations.js +13 -0
- package/dist/provider.d.ts +2 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +1 -0
- package/dist/query-keys.d.ts +114 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +34 -0
- package/dist/query-options-action-ledger.d.ts +194 -0
- package/dist/query-options-action-ledger.d.ts.map +1 -0
- package/dist/query-options-action-ledger.js +20 -0
- package/dist/query-options.d.ts +1313 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +281 -0
- package/dist/schemas.d.ts +1098 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +320 -0
- package/dist/ui.d.ts +44 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +42 -0
- package/package.json +159 -0
- package/src/styles.css +12 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Switch, Textarea, } from "@voyant-travel/ui/components";
|
|
3
|
+
import { Loader2 } from "lucide-react";
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
import { useForm } from "react-hook-form";
|
|
6
|
+
import { z } from "zod/v4";
|
|
7
|
+
import { useOptionUnitMutation } from "../../index.js";
|
|
8
|
+
import { useProductDetailMessages } from "./host.js";
|
|
9
|
+
import { zodResolver } from "./zod-resolver.js";
|
|
10
|
+
// "Min/Max quantity" is meaningless to an agent — phrase it in terms of the
|
|
11
|
+
// thing being counted (rooms / vehicles / travelers) for the selected type.
|
|
12
|
+
function quantityLabels(unitType, m) {
|
|
13
|
+
switch (unitType) {
|
|
14
|
+
case "room":
|
|
15
|
+
return { min: m.quantityRoomMin, max: m.quantityRoomMax };
|
|
16
|
+
case "vehicle":
|
|
17
|
+
return { min: m.quantityVehicleMin, max: m.quantityVehicleMax };
|
|
18
|
+
case "person":
|
|
19
|
+
return { min: m.quantityPersonMin, max: m.quantityPersonMax };
|
|
20
|
+
default:
|
|
21
|
+
return { min: m.minQuantityLabel, max: m.maxQuantityLabel };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// Occupancy = how many people fit in one unit (guests per room, seats per
|
|
25
|
+
// vehicle, group size). Label it for the selected type.
|
|
26
|
+
function occupancyLabels(unitType, m) {
|
|
27
|
+
switch (unitType) {
|
|
28
|
+
case "room":
|
|
29
|
+
return { min: m.occupancyRoomMin, max: m.occupancyRoomMax };
|
|
30
|
+
case "vehicle":
|
|
31
|
+
return { min: m.occupancyVehicleMin, max: m.occupancyVehicleMax };
|
|
32
|
+
case "group":
|
|
33
|
+
return { min: m.occupancyGroupMin, max: m.occupancyGroupMax };
|
|
34
|
+
default:
|
|
35
|
+
return { min: m.occupancyMinLabel, max: m.occupancyMaxLabel };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const buildUnitFormSchema = (messages) => z.object({
|
|
39
|
+
name: z.string().min(1, messages.validationNameRequired).max(255),
|
|
40
|
+
code: z.string().max(100).optional().nullable(),
|
|
41
|
+
description: z.string().optional().nullable(),
|
|
42
|
+
unitType: z.enum(["person", "group", "room", "vehicle", "service", "other"]),
|
|
43
|
+
minQuantity: z.coerce.number().int().min(0).optional().or(z.literal("")).nullable(),
|
|
44
|
+
maxQuantity: z.coerce.number().int().min(0).optional().or(z.literal("")).nullable(),
|
|
45
|
+
minAge: z.coerce.number().int().min(0).optional().or(z.literal("")).nullable(),
|
|
46
|
+
maxAge: z.coerce.number().int().min(0).optional().or(z.literal("")).nullable(),
|
|
47
|
+
occupancyMin: z.coerce.number().int().min(0).optional().or(z.literal("")).nullable(),
|
|
48
|
+
occupancyMax: z.coerce.number().int().min(0).optional().or(z.literal("")).nullable(),
|
|
49
|
+
isRequired: z.boolean(),
|
|
50
|
+
isHidden: z.boolean(),
|
|
51
|
+
sortOrder: z.coerce.number().int(),
|
|
52
|
+
});
|
|
53
|
+
function initialValues(unit, nextSortOrder, defaultUnitType) {
|
|
54
|
+
if (unit) {
|
|
55
|
+
return {
|
|
56
|
+
name: unit.name,
|
|
57
|
+
code: unit.code ?? "",
|
|
58
|
+
description: unit.description ?? "",
|
|
59
|
+
unitType: unit.unitType,
|
|
60
|
+
minQuantity: unit.minQuantity ?? "",
|
|
61
|
+
maxQuantity: unit.maxQuantity ?? "",
|
|
62
|
+
minAge: unit.minAge ?? "",
|
|
63
|
+
maxAge: unit.maxAge ?? "",
|
|
64
|
+
occupancyMin: unit.occupancyMin ?? "",
|
|
65
|
+
occupancyMax: unit.occupancyMax ?? "",
|
|
66
|
+
isRequired: unit.isRequired,
|
|
67
|
+
isHidden: unit.isHidden,
|
|
68
|
+
sortOrder: unit.sortOrder,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
name: "",
|
|
73
|
+
code: "",
|
|
74
|
+
description: "",
|
|
75
|
+
unitType: defaultUnitType ?? "person",
|
|
76
|
+
minQuantity: "",
|
|
77
|
+
maxQuantity: "",
|
|
78
|
+
minAge: "",
|
|
79
|
+
maxAge: "",
|
|
80
|
+
occupancyMin: "",
|
|
81
|
+
occupancyMax: "",
|
|
82
|
+
isRequired: false,
|
|
83
|
+
isHidden: false,
|
|
84
|
+
sortOrder: nextSortOrder ?? 0,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export function UnitForm({ optionId, unit, defaultUnitType, lockUnitType, nextSortOrder, onSuccess, onCancel, }) {
|
|
88
|
+
const messages = useProductDetailMessages();
|
|
89
|
+
const productMessages = messages.products.core;
|
|
90
|
+
const unitMessages = messages.products.operations.units;
|
|
91
|
+
const isEditing = !!unit;
|
|
92
|
+
const { create, update } = useOptionUnitMutation();
|
|
93
|
+
const unitFormSchema = buildUnitFormSchema(unitMessages);
|
|
94
|
+
const unitTypes = [
|
|
95
|
+
{ value: "person", label: unitMessages.typePerson },
|
|
96
|
+
{ value: "group", label: unitMessages.typeGroup },
|
|
97
|
+
{ value: "room", label: unitMessages.typeRoom },
|
|
98
|
+
{ value: "vehicle", label: unitMessages.typeVehicle },
|
|
99
|
+
{ value: "service", label: unitMessages.typeService },
|
|
100
|
+
{ value: "other", label: unitMessages.typeOther },
|
|
101
|
+
];
|
|
102
|
+
const form = useForm({
|
|
103
|
+
resolver: zodResolver(unitFormSchema),
|
|
104
|
+
defaultValues: initialValues(unit, nextSortOrder, defaultUnitType),
|
|
105
|
+
});
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
form.reset(initialValues(unit, nextSortOrder, defaultUnitType));
|
|
108
|
+
}, [unit, nextSortOrder, defaultUnitType, form]);
|
|
109
|
+
const onSubmit = async (values) => {
|
|
110
|
+
const canHaveAge = values.unitType === "person";
|
|
111
|
+
const canHaveOccupancy = values.unitType === "group" || values.unitType === "room" || values.unitType === "vehicle";
|
|
112
|
+
const payload = {
|
|
113
|
+
name: values.name,
|
|
114
|
+
code: values.code || null,
|
|
115
|
+
description: values.description || null,
|
|
116
|
+
unitType: values.unitType,
|
|
117
|
+
minQuantity: typeof values.minQuantity === "number" ? values.minQuantity : null,
|
|
118
|
+
maxQuantity: typeof values.maxQuantity === "number" ? values.maxQuantity : null,
|
|
119
|
+
minAge: canHaveAge && typeof values.minAge === "number" ? values.minAge : null,
|
|
120
|
+
maxAge: canHaveAge && typeof values.maxAge === "number" ? values.maxAge : null,
|
|
121
|
+
occupancyMin: canHaveOccupancy && typeof values.occupancyMin === "number" ? values.occupancyMin : null,
|
|
122
|
+
occupancyMax: canHaveOccupancy && typeof values.occupancyMax === "number" ? values.occupancyMax : null,
|
|
123
|
+
isRequired: values.isRequired,
|
|
124
|
+
isHidden: values.isHidden,
|
|
125
|
+
sortOrder: values.sortOrder,
|
|
126
|
+
};
|
|
127
|
+
if (isEditing) {
|
|
128
|
+
await update.mutateAsync({ id: unit.id, input: payload });
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
await create.mutateAsync({ optionId, ...payload });
|
|
132
|
+
}
|
|
133
|
+
onSuccess();
|
|
134
|
+
};
|
|
135
|
+
const unitType = form.watch("unitType");
|
|
136
|
+
const qtyLabels = quantityLabels(unitType, unitMessages);
|
|
137
|
+
const occLabels = occupancyLabels(unitType, unitMessages);
|
|
138
|
+
return (_jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-1 flex-col gap-4 overflow-hidden", children: [_jsxs("div", { className: "grid gap-4", children: [_jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: unitMessages.nameLabel }), _jsx(Input, { ...form.register("name"), placeholder: unitMessages.namePlaceholder }), form.formState.errors.name && (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.name.message }))] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: unitMessages.codeLabel }), _jsx(Input, { ...form.register("code"), placeholder: unitMessages.codePlaceholder })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [lockUnitType ? null : (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: unitMessages.typeLabel }), _jsxs(Select, { value: unitType, onValueChange: (v) => form.setValue("unitType", v), items: unitTypes, children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: unitTypes.map((t) => (_jsx(SelectItem, { value: t.value, children: t.label }, t.value))) })] })] })), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: unitMessages.sortOrderLabel }), _jsx(Input, { ...form.register("sortOrder"), type: "number" })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: qtyLabels.min }), _jsx(Input, { ...form.register("minQuantity"), type: "number", min: "0" })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: qtyLabels.max }), _jsx(Input, { ...form.register("maxQuantity"), type: "number", min: "0" })] })] }), unitType === "person" && (_jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: unitMessages.minAgeLabel }), _jsx(Input, { ...form.register("minAge"), type: "number", min: "0" })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: unitMessages.maxAgeLabel }), _jsx(Input, { ...form.register("maxAge"), type: "number", min: "0" })] })] })), (unitType === "room" || unitType === "vehicle" || unitType === "group") && (_jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: occLabels.min }), _jsx(Input, { ...form.register("occupancyMin"), type: "number", min: "0" })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: occLabels.max }), _jsx(Input, { ...form.register("occupancyMax"), type: "number", min: "0" })] })] })), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: unitMessages.descriptionLabel }), _jsx(Textarea, { ...form.register("description") })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Switch, { checked: form.watch("isRequired"), onCheckedChange: (v) => form.setValue("isRequired", v) }), _jsx(Label, { children: unitMessages.requiredLabel })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Switch, { checked: form.watch("isHidden"), onCheckedChange: (v) => form.setValue("isHidden", v) }), _jsx(Label, { children: unitMessages.hiddenLabel })] })] })] }), _jsxs("div", { className: "flex items-center justify-end gap-2", children: [onCancel ? (_jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: onCancel, children: productMessages.cancel })) : null, _jsxs(Button, { type: "submit", size: "sm", disabled: form.formState.isSubmitting || create.isPending || update.isPending, children: [(form.formState.isSubmitting || create.isPending || update.isPending) && (_jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" })), isEditing ? productMessages.saveChanges : unitMessages.create] })] })] }));
|
|
139
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { OptionUnitData } from "./product-unit-form.js";
|
|
2
|
+
import { type OptionUnitPriceRuleData } from "./product-unit-price-rule-form.js";
|
|
3
|
+
export type { OptionUnitPriceRuleData };
|
|
4
|
+
type UnitPriceRuleDialogProps = {
|
|
5
|
+
open: boolean;
|
|
6
|
+
onOpenChange: (open: boolean) => void;
|
|
7
|
+
optionPriceRuleId: string;
|
|
8
|
+
optionId: string;
|
|
9
|
+
units: OptionUnitData[];
|
|
10
|
+
productCurrency?: string;
|
|
11
|
+
preselectedUnitId?: string;
|
|
12
|
+
preselectedCategoryId?: string | null;
|
|
13
|
+
cell?: OptionUnitPriceRuleData;
|
|
14
|
+
onSuccess: () => void;
|
|
15
|
+
};
|
|
16
|
+
export declare function UnitPriceRuleDialog({ open, onOpenChange, optionPriceRuleId, optionId, units, productCurrency, preselectedUnitId, preselectedCategoryId, cell, onSuccess, }: UnitPriceRuleDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=product-unit-price-rule-dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-unit-price-rule-dialog.d.ts","sourceRoot":"","sources":["../../../src/components/product-detail/product-unit-price-rule-dialog.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,KAAK,uBAAuB,EAAqB,MAAM,mCAAmC,CAAA;AAEnG,YAAY,EAAE,uBAAuB,EAAE,CAAA;AAEvC,KAAK,wBAAwB,GAAG;IAC9B,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,iBAAiB,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,cAAc,EAAE,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrC,IAAI,CAAC,EAAE,uBAAuB,CAAA;IAC9B,SAAS,EAAE,MAAM,IAAI,CAAA;CACtB,CAAA;AAED,wBAAgB,mBAAmB,CAAC,EAClC,IAAI,EACJ,YAAY,EACZ,iBAAiB,EACjB,QAAQ,EACR,KAAK,EACL,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,IAAI,EACJ,SAAS,GACV,EAAE,wBAAwB,2CA6B1B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Sheet, SheetBody, SheetContent, SheetHeader, SheetTitle, } from "@voyant-travel/ui/components";
|
|
3
|
+
import { useProductDetailMessages } from "./host.js";
|
|
4
|
+
import { UnitPriceRuleForm } from "./product-unit-price-rule-form.js";
|
|
5
|
+
export function UnitPriceRuleDialog({ open, onOpenChange, optionPriceRuleId, optionId, units, productCurrency, preselectedUnitId, preselectedCategoryId, cell, onSuccess, }) {
|
|
6
|
+
const messages = useProductDetailMessages();
|
|
7
|
+
const unitPriceMessages = messages.products.operations.unitPrices;
|
|
8
|
+
const isEditing = !!cell;
|
|
9
|
+
return (_jsx(Sheet, { open: open, onOpenChange: onOpenChange, children: _jsxs(SheetContent, { side: "right", children: [_jsx(SheetHeader, { children: _jsx(SheetTitle, { children: isEditing ? unitPriceMessages.editTitle : unitPriceMessages.newTitle }) }), _jsx(SheetBody, { children: _jsx(UnitPriceRuleForm, { optionPriceRuleId: optionPriceRuleId, optionId: optionId, units: units, productCurrency: productCurrency, preselectedUnitId: preselectedUnitId, preselectedCategoryId: preselectedCategoryId, cell: cell, onSuccess: onSuccess, onCancel: () => onOpenChange(false) }) })] }) }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { OptionUnitData } from "./product-unit-form.js";
|
|
2
|
+
export type OptionUnitPriceRuleData = {
|
|
3
|
+
id: string;
|
|
4
|
+
optionPriceRuleId: string;
|
|
5
|
+
optionId: string;
|
|
6
|
+
unitId: string;
|
|
7
|
+
pricingCategoryId: string | null;
|
|
8
|
+
pricingMode: "per_unit" | "per_person" | "per_booking" | "included" | "free" | "on_request";
|
|
9
|
+
sellAmountCents: number | null;
|
|
10
|
+
costAmountCents: number | null;
|
|
11
|
+
minQuantity: number | null;
|
|
12
|
+
maxQuantity: number | null;
|
|
13
|
+
sortOrder: number;
|
|
14
|
+
active: boolean;
|
|
15
|
+
notes: string | null;
|
|
16
|
+
};
|
|
17
|
+
export interface UnitPriceRuleFormProps {
|
|
18
|
+
optionPriceRuleId: string;
|
|
19
|
+
optionId: string;
|
|
20
|
+
units: OptionUnitData[];
|
|
21
|
+
productCurrency?: string;
|
|
22
|
+
preselectedUnitId?: string;
|
|
23
|
+
preselectedCategoryId?: string | null;
|
|
24
|
+
cell?: OptionUnitPriceRuleData;
|
|
25
|
+
onSuccess: () => void;
|
|
26
|
+
onCancel?: () => void;
|
|
27
|
+
}
|
|
28
|
+
export declare function UnitPriceRuleForm({ optionPriceRuleId, optionId, units, productCurrency, preselectedUnitId, preselectedCategoryId, cell, onSuccess, onCancel, }: UnitPriceRuleFormProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
//# sourceMappingURL=product-unit-price-rule-form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-unit-price-rule-form.d.ts","sourceRoot":"","sources":["../../../src/components/product-detail/product-unit-price-rule-form.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AA2E5D,MAAM,MAAM,uBAAuB,GAAG;IACpC,EAAE,EAAE,MAAM,CAAA;IACV,iBAAiB,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,WAAW,EAAE,UAAU,GAAG,YAAY,GAAG,aAAa,GAAG,UAAU,GAAG,MAAM,GAAG,YAAY,CAAA;IAC3F,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB,CAAA;AAED,MAAM,WAAW,sBAAsB;IACrC,iBAAiB,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,cAAc,EAAE,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrC,IAAI,CAAC,EAAE,uBAAuB,CAAA;IAC9B,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB;AAmCD,wBAAgB,iBAAiB,CAAC,EAChC,iBAAiB,EACjB,QAAQ,EACR,KAAK,EACL,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,IAAI,EACJ,SAAS,EACT,QAAQ,GACT,EAAE,sBAAsB,2CAoLxB"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Switch, Textarea, } from "@voyant-travel/ui/components";
|
|
3
|
+
import { CurrencyInput } from "@voyant-travel/ui/components/currency-input";
|
|
4
|
+
import { Loader2 } from "lucide-react";
|
|
5
|
+
import { useEffect } from "react";
|
|
6
|
+
import { useForm } from "react-hook-form";
|
|
7
|
+
import { z } from "zod/v4";
|
|
8
|
+
import { PricingCategoryCombobox, useOptionUnitPriceRuleMutation } from "./commerce-client.js";
|
|
9
|
+
import { useProductDetailMessages, useProductLocale } from "./host.js";
|
|
10
|
+
import { zodResolver } from "./zod-resolver.js";
|
|
11
|
+
function getUnitTypeLabel(type, messages) {
|
|
12
|
+
switch (type) {
|
|
13
|
+
case "person":
|
|
14
|
+
return messages.typePerson;
|
|
15
|
+
case "group":
|
|
16
|
+
return messages.typeGroup;
|
|
17
|
+
case "room":
|
|
18
|
+
return messages.typeRoom;
|
|
19
|
+
case "vehicle":
|
|
20
|
+
return messages.typeVehicle;
|
|
21
|
+
case "service":
|
|
22
|
+
return messages.typeService;
|
|
23
|
+
case "other":
|
|
24
|
+
return messages.typeOther;
|
|
25
|
+
default:
|
|
26
|
+
return type;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// "Min/Max quantity" means different things per pricing mode — travelers for
|
|
30
|
+
// per-person, units for per-unit, the whole booking for per-booking. Label it
|
|
31
|
+
// for what's actually being counted.
|
|
32
|
+
function cellQuantityLabels(pricingMode, m) {
|
|
33
|
+
switch (pricingMode) {
|
|
34
|
+
case "per_person":
|
|
35
|
+
return { min: m.minQuantityPerson, max: m.maxQuantityPerson };
|
|
36
|
+
case "per_unit":
|
|
37
|
+
return { min: m.minQuantityUnit, max: m.maxQuantityUnit };
|
|
38
|
+
case "per_booking":
|
|
39
|
+
return { min: m.minQuantityBooking, max: m.maxQuantityBooking };
|
|
40
|
+
default:
|
|
41
|
+
return { min: m.minQuantityLabel, max: m.maxQuantityLabel };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const buildCellFormSchema = (messages) => z.object({
|
|
45
|
+
unitId: z.string().min(1, messages.validationUnitRequired),
|
|
46
|
+
pricingCategoryId: z.string().optional().nullable(),
|
|
47
|
+
pricingMode: z.enum([
|
|
48
|
+
"per_unit",
|
|
49
|
+
"per_person",
|
|
50
|
+
"per_booking",
|
|
51
|
+
"included",
|
|
52
|
+
"free",
|
|
53
|
+
"on_request",
|
|
54
|
+
]),
|
|
55
|
+
// Stored in minor units (cents) so CurrencyInput can render the currency
|
|
56
|
+
// prefix and parse locale-formatted amounts directly.
|
|
57
|
+
sell: z.number().int().min(0),
|
|
58
|
+
cost: z.number().int().min(0),
|
|
59
|
+
minQuantity: z.coerce.number().int().min(0).optional().or(z.literal("")).nullable(),
|
|
60
|
+
maxQuantity: z.coerce.number().int().min(0).optional().or(z.literal("")).nullable(),
|
|
61
|
+
sortOrder: z.coerce.number().int(),
|
|
62
|
+
active: z.boolean(),
|
|
63
|
+
notes: z.string().optional().nullable(),
|
|
64
|
+
});
|
|
65
|
+
function initialValues(cell, preselectedUnitId, preselectedCategoryId) {
|
|
66
|
+
if (cell) {
|
|
67
|
+
return {
|
|
68
|
+
unitId: cell.unitId,
|
|
69
|
+
pricingCategoryId: cell.pricingCategoryId ?? "",
|
|
70
|
+
pricingMode: cell.pricingMode,
|
|
71
|
+
sell: cell.sellAmountCents ?? 0,
|
|
72
|
+
cost: cell.costAmountCents ?? 0,
|
|
73
|
+
minQuantity: cell.minQuantity ?? "",
|
|
74
|
+
maxQuantity: cell.maxQuantity ?? "",
|
|
75
|
+
sortOrder: cell.sortOrder,
|
|
76
|
+
active: cell.active,
|
|
77
|
+
notes: cell.notes ?? "",
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
unitId: preselectedUnitId ?? "",
|
|
82
|
+
pricingCategoryId: preselectedCategoryId ?? "",
|
|
83
|
+
pricingMode: "per_person",
|
|
84
|
+
sell: 0,
|
|
85
|
+
cost: 0,
|
|
86
|
+
minQuantity: "",
|
|
87
|
+
maxQuantity: "",
|
|
88
|
+
sortOrder: 0,
|
|
89
|
+
active: true,
|
|
90
|
+
notes: "",
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export function UnitPriceRuleForm({ optionPriceRuleId, optionId, units, productCurrency, preselectedUnitId, preselectedCategoryId, cell, onSuccess, onCancel, }) {
|
|
94
|
+
const messages = useProductDetailMessages();
|
|
95
|
+
const productMessages = messages.products.core;
|
|
96
|
+
const unitPriceMessages = messages.products.operations.unitPrices;
|
|
97
|
+
const unitMessages = messages.products.operations.units;
|
|
98
|
+
const locale = useProductLocale();
|
|
99
|
+
const isEditing = !!cell;
|
|
100
|
+
const { create, update } = useOptionUnitPriceRuleMutation();
|
|
101
|
+
const cellFormSchema = buildCellFormSchema(unitPriceMessages);
|
|
102
|
+
const pricingModes = [
|
|
103
|
+
{ value: "per_unit", label: unitPriceMessages.pricingModePerUnit },
|
|
104
|
+
{ value: "per_person", label: unitPriceMessages.pricingModePerPerson },
|
|
105
|
+
{ value: "per_booking", label: unitPriceMessages.pricingModePerBooking },
|
|
106
|
+
{ value: "included", label: unitPriceMessages.pricingModeIncluded },
|
|
107
|
+
{ value: "free", label: unitPriceMessages.pricingModeFree },
|
|
108
|
+
{ value: "on_request", label: unitPriceMessages.pricingModeOnRequest },
|
|
109
|
+
];
|
|
110
|
+
const form = useForm({
|
|
111
|
+
resolver: zodResolver(cellFormSchema),
|
|
112
|
+
defaultValues: initialValues(cell, preselectedUnitId, preselectedCategoryId),
|
|
113
|
+
});
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
form.reset(initialValues(cell, preselectedUnitId, preselectedCategoryId));
|
|
116
|
+
}, [cell, preselectedUnitId, preselectedCategoryId, form]);
|
|
117
|
+
const onSubmit = async (values) => {
|
|
118
|
+
const payload = {
|
|
119
|
+
optionPriceRuleId,
|
|
120
|
+
optionId,
|
|
121
|
+
unitId: values.unitId,
|
|
122
|
+
pricingCategoryId: values.pricingCategoryId || null,
|
|
123
|
+
pricingMode: values.pricingMode,
|
|
124
|
+
sellAmountCents: Math.round(values.sell),
|
|
125
|
+
costAmountCents: Math.round(values.cost),
|
|
126
|
+
minQuantity: typeof values.minQuantity === "number" ? values.minQuantity : null,
|
|
127
|
+
maxQuantity: typeof values.maxQuantity === "number" ? values.maxQuantity : null,
|
|
128
|
+
sortOrder: values.sortOrder,
|
|
129
|
+
active: values.active,
|
|
130
|
+
notes: values.notes || null,
|
|
131
|
+
};
|
|
132
|
+
if (isEditing) {
|
|
133
|
+
await update.mutateAsync({ id: cell.id, input: payload });
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
await create.mutateAsync(payload);
|
|
137
|
+
}
|
|
138
|
+
onSuccess();
|
|
139
|
+
};
|
|
140
|
+
return (_jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-1 flex-col gap-4 overflow-hidden", children: [_jsxs("div", { className: "grid gap-4", children: [_jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: unitPriceMessages.unitLabel }), _jsxs(Select, { value: form.watch("unitId") || undefined, onValueChange: (v) => form.setValue("unitId", v ?? "", { shouldValidate: true }), items: units.map((u) => ({
|
|
141
|
+
value: u.id,
|
|
142
|
+
label: `${u.name} (${getUnitTypeLabel(u.unitType, unitMessages)})`,
|
|
143
|
+
})), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, { placeholder: unitPriceMessages.unitPlaceholder }) }), _jsx(SelectContent, { children: units.map((u) => (_jsxs(SelectItem, { value: u.id, children: [u.name, " (", getUnitTypeLabel(u.unitType, unitMessages), ")"] }, u.id))) })] }), form.formState.errors.unitId && (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.unitId.message }))] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: unitPriceMessages.categoryLabel }), _jsx(PricingCategoryCombobox, { value: form.watch("pricingCategoryId"), onChange: (value) => form.setValue("pricingCategoryId", value ?? "", { shouldDirty: true }), placeholder: unitPriceMessages.categoryPlaceholder })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: unitPriceMessages.pricingModeLabel }), _jsxs(Select, { value: form.watch("pricingMode"), onValueChange: (v) => form.setValue("pricingMode", v), items: pricingModes, children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: pricingModes.map((m) => (_jsx(SelectItem, { value: m.value, children: m.label }, m.value))) })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: unitPriceMessages.sellLabel }), _jsx(CurrencyInput, { value: form.watch("sell"), onChange: (value) => form.setValue("sell", value ?? 0, { shouldValidate: true }), currency: productCurrency, locale: locale })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: unitPriceMessages.costLabel }), _jsx(CurrencyInput, { value: form.watch("cost"), onChange: (value) => form.setValue("cost", value ?? 0, { shouldValidate: true }), currency: productCurrency, locale: locale })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: cellQuantityLabels(form.watch("pricingMode"), unitPriceMessages).min }), _jsx(Input, { ...form.register("minQuantity"), type: "number", min: "0" })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: cellQuantityLabels(form.watch("pricingMode"), unitPriceMessages).max }), _jsx(Input, { ...form.register("maxQuantity"), type: "number", min: "0" })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: unitPriceMessages.sortOrderLabel }), _jsx(Input, { ...form.register("sortOrder"), type: "number" })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Switch, { checked: form.watch("active"), onCheckedChange: (v) => form.setValue("active", v) }), _jsx(Label, { children: unitPriceMessages.activeLabel })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: unitPriceMessages.notesLabel }), _jsx(Textarea, { ...form.register("notes") })] })] }), _jsxs("div", { className: "flex items-center justify-end gap-2", children: [onCancel ? (_jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: onCancel, children: productMessages.cancel })) : null, _jsxs(Button, { type: "submit", size: "sm", disabled: form.formState.isSubmitting, children: [form.formState.isSubmitting && _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }), isEditing ? productMessages.saveChanges : unitPriceMessages.create] })] })] }));
|
|
144
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rrule-labels.d.ts","sourceRoot":"","sources":["../../../src/components/product-detail/rrule-labels.ts"],"names":[],"mappings":"AA2DA,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAsBnD"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const WEEKDAYS = ["MO", "TU", "WE", "TH", "FR", "SA", "SU"];
|
|
2
|
+
const WEEKDAY_LABELS = {
|
|
3
|
+
MO: "Mon",
|
|
4
|
+
TU: "Tue",
|
|
5
|
+
WE: "Wed",
|
|
6
|
+
TH: "Thu",
|
|
7
|
+
FR: "Fri",
|
|
8
|
+
SA: "Sat",
|
|
9
|
+
SU: "Sun",
|
|
10
|
+
};
|
|
11
|
+
const WEEKDAY_FULL_LABELS = {
|
|
12
|
+
MO: "Monday",
|
|
13
|
+
TU: "Tuesday",
|
|
14
|
+
WE: "Wednesday",
|
|
15
|
+
TH: "Thursday",
|
|
16
|
+
FR: "Friday",
|
|
17
|
+
SA: "Saturday",
|
|
18
|
+
SU: "Sunday",
|
|
19
|
+
};
|
|
20
|
+
function parseRRule(rrule) {
|
|
21
|
+
const parts = rrule
|
|
22
|
+
.split(";")
|
|
23
|
+
.map((part) => part.trim())
|
|
24
|
+
.filter(Boolean);
|
|
25
|
+
const map = new Map();
|
|
26
|
+
for (const part of parts) {
|
|
27
|
+
const [key, value] = part.split("=");
|
|
28
|
+
if (key && value !== undefined)
|
|
29
|
+
map.set(key.toUpperCase(), value);
|
|
30
|
+
}
|
|
31
|
+
const rawFrequency = (map.get("FREQ") ?? "DAILY").toUpperCase();
|
|
32
|
+
const frequency = rawFrequency === "WEEKLY" || rawFrequency === "MONTHLY" ? rawFrequency : "DAILY";
|
|
33
|
+
const interval = Number.parseInt(map.get("INTERVAL") ?? "1", 10) || 1;
|
|
34
|
+
const byWeekdays = (map.get("BYDAY") ?? "")
|
|
35
|
+
.split(",")
|
|
36
|
+
.map((day) => day.trim().toUpperCase())
|
|
37
|
+
.filter((day) => WEEKDAYS.includes(day));
|
|
38
|
+
const byMonthDays = (map.get("BYMONTHDAY") ?? "")
|
|
39
|
+
.split(",")
|
|
40
|
+
.map((day) => Number.parseInt(day.trim(), 10))
|
|
41
|
+
.filter((day) => Number.isFinite(day) && day >= 1 && day <= 31);
|
|
42
|
+
return { frequency, interval, byWeekdays, byMonthDays };
|
|
43
|
+
}
|
|
44
|
+
export function describeRRule(rrule) {
|
|
45
|
+
const { frequency, interval, byWeekdays, byMonthDays } = parseRRule(rrule);
|
|
46
|
+
const unit = frequency === "DAILY" ? "day" : frequency === "WEEKLY" ? "week" : "month";
|
|
47
|
+
const cadence = interval > 1 ? `Every ${interval} ${unit}s` : `Every ${unit}`;
|
|
48
|
+
if (frequency === "WEEKLY") {
|
|
49
|
+
if (byWeekdays.length === 0)
|
|
50
|
+
return `${cadence} (no weekdays)`;
|
|
51
|
+
const ordered = WEEKDAYS.filter((day) => byWeekdays.includes(day));
|
|
52
|
+
const first = ordered[0];
|
|
53
|
+
if (interval === 1 && ordered.length === 1 && first) {
|
|
54
|
+
return `Every ${WEEKDAY_FULL_LABELS[first]}`;
|
|
55
|
+
}
|
|
56
|
+
return `${cadence} on ${ordered.map((day) => WEEKDAY_LABELS[day]).join(", ")}`;
|
|
57
|
+
}
|
|
58
|
+
if (frequency === "MONTHLY") {
|
|
59
|
+
if (byMonthDays.length === 0)
|
|
60
|
+
return `${cadence} (no days)`;
|
|
61
|
+
const ordered = [...byMonthDays].sort((a, b) => a - b);
|
|
62
|
+
return `${cadence} on day${ordered.length === 1 ? "" : "s"} ${ordered.join(", ")}`;
|
|
63
|
+
}
|
|
64
|
+
return cadence;
|
|
65
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type TimezoneOption = {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
offset: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const TIMEZONE_OPTIONS: TimezoneOption[];
|
|
7
|
+
export declare const TIMEZONE_IDS: string[];
|
|
8
|
+
export declare function getTimezoneLabel(id: string): string;
|
|
9
|
+
//# sourceMappingURL=timezone-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone-options.d.ts","sourceRoot":"","sources":["../../../src/components/product-detail/timezone-options.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAsBD,eAAO,MAAM,gBAAgB,kBAAyB,CAAA;AACtD,eAAO,MAAM,YAAY,UAAoC,CAAA;AAI7D,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAGnD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { timezones } from "@voyant-travel/utils/timezones";
|
|
2
|
+
function buildTimezoneOptions() {
|
|
3
|
+
const seen = new Map();
|
|
4
|
+
for (const tz of timezones) {
|
|
5
|
+
for (const id of tz.utc) {
|
|
6
|
+
if (seen.has(id))
|
|
7
|
+
continue;
|
|
8
|
+
seen.set(id, { id, label: tz.text, offset: tz.offset });
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
// Include the browser-resolved zone if not already present
|
|
12
|
+
const browserZone = typeof Intl !== "undefined" ? Intl.DateTimeFormat().resolvedOptions().timeZone : null;
|
|
13
|
+
if (browserZone && !seen.has(browserZone)) {
|
|
14
|
+
seen.set(browserZone, { id: browserZone, label: browserZone, offset: 0 });
|
|
15
|
+
}
|
|
16
|
+
return Array.from(seen.values()).sort((a, b) => {
|
|
17
|
+
if (a.offset !== b.offset)
|
|
18
|
+
return a.offset - b.offset;
|
|
19
|
+
return a.id.localeCompare(b.id);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export const TIMEZONE_OPTIONS = buildTimezoneOptions();
|
|
23
|
+
export const TIMEZONE_IDS = TIMEZONE_OPTIONS.map((t) => t.id);
|
|
24
|
+
const TIMEZONE_BY_ID = new Map(TIMEZONE_OPTIONS.map((t) => [t.id, t]));
|
|
25
|
+
export function getTimezoneLabel(id) {
|
|
26
|
+
const tz = TIMEZONE_BY_ID.get(id);
|
|
27
|
+
return tz ? `${id} — ${tz.label}` : id;
|
|
28
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useMutation } from "@tanstack/react-query";
|
|
2
|
+
import { useProduct } from "../../index.js";
|
|
3
|
+
import { type AvailabilityRule, type ChannelInfo, type ChannelProductMapping, type DepartureSlot, type ProductMediaItem } from "./product-detail-shared.js";
|
|
4
|
+
export interface UseProductDetailDataResult {
|
|
5
|
+
product: ReturnType<typeof useProduct>["data"];
|
|
6
|
+
isPending: boolean;
|
|
7
|
+
slots: DepartureSlot[];
|
|
8
|
+
rules: AvailabilityRule[];
|
|
9
|
+
channels: ChannelInfo[];
|
|
10
|
+
mappings: ChannelProductMapping[];
|
|
11
|
+
media: ProductMediaItem[];
|
|
12
|
+
itineraryNameById: Map<string, string>;
|
|
13
|
+
refetch: {
|
|
14
|
+
slots: () => void;
|
|
15
|
+
rules: () => void;
|
|
16
|
+
mappings: () => void;
|
|
17
|
+
media: () => void;
|
|
18
|
+
};
|
|
19
|
+
mutations: {
|
|
20
|
+
addChannelMapping: ReturnType<typeof useMutation<unknown, Error, string>>;
|
|
21
|
+
removeChannelMapping: ReturnType<typeof useMutation<unknown, Error, string>>;
|
|
22
|
+
duplicateProduct: ReturnType<typeof useMutation<{
|
|
23
|
+
data: {
|
|
24
|
+
id: string;
|
|
25
|
+
};
|
|
26
|
+
}, Error, void>>;
|
|
27
|
+
deleteProduct: ReturnType<typeof useMutation<unknown, Error, void>>;
|
|
28
|
+
deleteSlot: ReturnType<typeof useMutation<unknown, Error, string>>;
|
|
29
|
+
deleteRule: ReturnType<typeof useMutation<unknown, Error, string>>;
|
|
30
|
+
uploadMedia: ReturnType<typeof useMutation<unknown, Error, {
|
|
31
|
+
file: File;
|
|
32
|
+
dayId?: string;
|
|
33
|
+
}>>;
|
|
34
|
+
deleteMedia: ReturnType<typeof useMutation<unknown, Error, string>>;
|
|
35
|
+
setCover: ReturnType<typeof useMutation<unknown, Error, string>>;
|
|
36
|
+
generateBrochure: ReturnType<typeof useMutation<unknown, Error, void>>;
|
|
37
|
+
};
|
|
38
|
+
invalidateProduct: () => void;
|
|
39
|
+
}
|
|
40
|
+
export declare function useProductDetailData(productId: string): UseProductDetailDataResult;
|
|
41
|
+
//# sourceMappingURL=use-product-detail-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-product-detail-data.d.ts","sourceRoot":"","sources":["../../../src/components/product-detail/use-product-detail-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA4B,MAAM,uBAAuB,CAAA;AAE7E,OAAO,EAAqB,UAAU,EAAyB,MAAM,gBAAgB,CAAA;AAIrF,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAMlB,KAAK,gBAAgB,EACtB,MAAM,4BAA4B,CAAA;AAEnC,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;IAC9C,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,aAAa,EAAE,CAAA;IACtB,KAAK,EAAE,gBAAgB,EAAE,CAAA;IACzB,QAAQ,EAAE,WAAW,EAAE,CAAA;IACvB,QAAQ,EAAE,qBAAqB,EAAE,CAAA;IACjC,KAAK,EAAE,gBAAgB,EAAE,CAAA;IACzB,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,IAAI,CAAA;QACjB,KAAK,EAAE,MAAM,IAAI,CAAA;QACjB,QAAQ,EAAE,MAAM,IAAI,CAAA;QACpB,KAAK,EAAE,MAAM,IAAI,CAAA;KAClB,CAAA;IACD,SAAS,EAAE;QACT,iBAAiB,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;QACzE,oBAAoB,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;QAC5E,gBAAgB,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC;YAAE,IAAI,EAAE;gBAAE,EAAE,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA;QACvF,aAAa,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA;QACnE,UAAU,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;QAClE,UAAU,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;QAClE,WAAW,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE;YAAE,IAAI,EAAE,IAAI,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC,CAAA;QAC3F,WAAW,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;QACnE,QAAQ,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;QAChE,gBAAgB,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA;KACvE,CAAA;IACD,iBAAiB,EAAE,MAAM,IAAI,CAAA;CAC9B;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,0BAA0B,CAiKlF"}
|