@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,122 @@
|
|
|
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 { CancellationPolicyCombobox, PriceCatalogCombobox, PriceScheduleCombobox, useOptionPriceRuleMutation, } from "./commerce-client.js";
|
|
8
|
+
import { useProductDetailMessages } from "./host.js";
|
|
9
|
+
import { zodResolver } from "./zod-resolver.js";
|
|
10
|
+
const buildRuleFormSchema = (messages) => z.object({
|
|
11
|
+
priceCatalogId: z.string().min(1, messages.validationCatalogRequired),
|
|
12
|
+
priceScheduleId: z.string().optional().nullable(),
|
|
13
|
+
cancellationPolicyId: z.string().optional().nullable(),
|
|
14
|
+
name: z.string().min(1, messages.validationNameRequired).max(255),
|
|
15
|
+
code: z.string().max(100).optional().nullable(),
|
|
16
|
+
description: z.string().optional().nullable(),
|
|
17
|
+
pricingMode: z.enum(["per_person", "per_booking", "starting_from", "free", "on_request"]),
|
|
18
|
+
baseSell: z.coerce.number().min(0),
|
|
19
|
+
baseCost: z.coerce.number().min(0),
|
|
20
|
+
minPerBooking: z.coerce.number().int().min(0).optional().or(z.literal("")).nullable(),
|
|
21
|
+
maxPerBooking: z.coerce.number().int().min(0).optional().or(z.literal("")).nullable(),
|
|
22
|
+
allPricingCategories: z.boolean(),
|
|
23
|
+
isDefault: z.boolean(),
|
|
24
|
+
active: z.boolean(),
|
|
25
|
+
notes: z.string().optional().nullable(),
|
|
26
|
+
});
|
|
27
|
+
function initialValues(rule) {
|
|
28
|
+
if (rule) {
|
|
29
|
+
return {
|
|
30
|
+
priceCatalogId: rule.priceCatalogId,
|
|
31
|
+
priceScheduleId: rule.priceScheduleId ?? "",
|
|
32
|
+
cancellationPolicyId: rule.cancellationPolicyId ?? "",
|
|
33
|
+
name: rule.name,
|
|
34
|
+
code: rule.code ?? "",
|
|
35
|
+
description: rule.description ?? "",
|
|
36
|
+
pricingMode: rule.pricingMode,
|
|
37
|
+
baseSell: (rule.baseSellAmountCents ?? 0) / 100,
|
|
38
|
+
baseCost: (rule.baseCostAmountCents ?? 0) / 100,
|
|
39
|
+
minPerBooking: rule.minPerBooking ?? "",
|
|
40
|
+
maxPerBooking: rule.maxPerBooking ?? "",
|
|
41
|
+
allPricingCategories: rule.allPricingCategories,
|
|
42
|
+
isDefault: rule.isDefault,
|
|
43
|
+
active: rule.active,
|
|
44
|
+
notes: rule.notes ?? "",
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
priceCatalogId: "",
|
|
49
|
+
priceScheduleId: "",
|
|
50
|
+
cancellationPolicyId: "",
|
|
51
|
+
name: "",
|
|
52
|
+
code: "",
|
|
53
|
+
description: "",
|
|
54
|
+
pricingMode: "per_person",
|
|
55
|
+
baseSell: 0,
|
|
56
|
+
baseCost: 0,
|
|
57
|
+
minPerBooking: "",
|
|
58
|
+
maxPerBooking: "",
|
|
59
|
+
allPricingCategories: true,
|
|
60
|
+
isDefault: false,
|
|
61
|
+
active: true,
|
|
62
|
+
notes: "",
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export function OptionPriceRuleForm({ productId, optionId, rule, onSuccess, onCancel, }) {
|
|
66
|
+
const messages = useProductDetailMessages();
|
|
67
|
+
const productMessages = messages.products.core;
|
|
68
|
+
const priceRuleMessages = messages.products.operations.priceRules;
|
|
69
|
+
const isEditing = !!rule;
|
|
70
|
+
const { create, update } = useOptionPriceRuleMutation();
|
|
71
|
+
const ruleFormSchema = buildRuleFormSchema(priceRuleMessages);
|
|
72
|
+
const pricingModes = [
|
|
73
|
+
{ value: "per_person", label: priceRuleMessages.pricingModePerPerson },
|
|
74
|
+
{ value: "per_booking", label: priceRuleMessages.pricingModePerBooking },
|
|
75
|
+
{ value: "starting_from", label: priceRuleMessages.pricingModeStartingFrom },
|
|
76
|
+
{ value: "free", label: priceRuleMessages.pricingModeFree },
|
|
77
|
+
{ value: "on_request", label: priceRuleMessages.pricingModeOnRequest },
|
|
78
|
+
];
|
|
79
|
+
const form = useForm({
|
|
80
|
+
resolver: zodResolver(ruleFormSchema),
|
|
81
|
+
defaultValues: initialValues(rule),
|
|
82
|
+
});
|
|
83
|
+
const watchedCatalogId = form.watch("priceCatalogId");
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
form.reset(initialValues(rule));
|
|
86
|
+
}, [rule, form]);
|
|
87
|
+
const onSubmit = async (values) => {
|
|
88
|
+
const payload = {
|
|
89
|
+
productId,
|
|
90
|
+
optionId,
|
|
91
|
+
priceCatalogId: values.priceCatalogId,
|
|
92
|
+
priceScheduleId: values.priceScheduleId || null,
|
|
93
|
+
cancellationPolicyId: values.cancellationPolicyId || null,
|
|
94
|
+
name: values.name,
|
|
95
|
+
code: values.code || null,
|
|
96
|
+
description: values.description || null,
|
|
97
|
+
pricingMode: values.pricingMode,
|
|
98
|
+
baseSellAmountCents: Math.round(values.baseSell * 100),
|
|
99
|
+
baseCostAmountCents: Math.round(values.baseCost * 100),
|
|
100
|
+
minPerBooking: typeof values.minPerBooking === "number" ? values.minPerBooking : null,
|
|
101
|
+
maxPerBooking: typeof values.maxPerBooking === "number" ? values.maxPerBooking : null,
|
|
102
|
+
allPricingCategories: values.allPricingCategories,
|
|
103
|
+
isDefault: values.isDefault,
|
|
104
|
+
active: values.active,
|
|
105
|
+
notes: values.notes || null,
|
|
106
|
+
};
|
|
107
|
+
if (isEditing) {
|
|
108
|
+
await update.mutateAsync({ id: rule.id, input: payload });
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
await create.mutateAsync(payload);
|
|
112
|
+
}
|
|
113
|
+
onSuccess();
|
|
114
|
+
};
|
|
115
|
+
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: priceRuleMessages.catalogLabel }), _jsx(PriceCatalogCombobox, { value: form.watch("priceCatalogId"), onChange: (value) => {
|
|
116
|
+
form.setValue("priceCatalogId", value ?? "", {
|
|
117
|
+
shouldDirty: true,
|
|
118
|
+
shouldValidate: true,
|
|
119
|
+
});
|
|
120
|
+
form.setValue("priceScheduleId", "", { shouldDirty: true });
|
|
121
|
+
} }), form.formState.errors.priceCatalogId && (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.priceCatalogId.message }))] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: priceRuleMessages.nameLabel }), _jsx(Input, { ...form.register("name"), placeholder: priceRuleMessages.namePlaceholder }), form.formState.errors.name && (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.name.message }))] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: priceRuleMessages.scheduleLabel }), _jsx(PriceScheduleCombobox, { priceCatalogId: watchedCatalogId, value: form.watch("priceScheduleId"), onChange: (value) => form.setValue("priceScheduleId", value ?? "", { shouldDirty: true }) })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: priceRuleMessages.cancellationPolicyLabel }), _jsx(CancellationPolicyCombobox, { value: form.watch("cancellationPolicyId"), onChange: (value) => form.setValue("cancellationPolicyId", value ?? "", { shouldDirty: true }) })] })] }), _jsxs("div", { className: "grid grid-cols-3 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: priceRuleMessages.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: "flex flex-col gap-2", children: [_jsx(Label, { children: priceRuleMessages.baseSellInputLabel }), _jsx(Input, { ...form.register("baseSell"), type: "number", step: "0.01", min: "0" })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: priceRuleMessages.baseCostInputLabel }), _jsx(Input, { ...form.register("baseCost"), type: "number", step: "0.01", min: "0" })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: priceRuleMessages.codeLabel }), _jsx(Input, { ...form.register("code"), placeholder: priceRuleMessages.codePlaceholder })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: priceRuleMessages.descriptionLabel }), _jsx(Input, { ...form.register("description") })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: priceRuleMessages.minPerBookingLabel }), _jsx(Input, { ...form.register("minPerBooking"), type: "number", min: "0" })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: priceRuleMessages.maxPerBookingLabel }), _jsx(Input, { ...form.register("maxPerBooking"), type: "number", min: "0" })] })] }), _jsxs("div", { className: "grid grid-cols-3 gap-4", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Switch, { checked: form.watch("allPricingCategories"), onCheckedChange: (v) => form.setValue("allPricingCategories", v) }), _jsx(Label, { children: priceRuleMessages.allCategoriesSwitchLabel })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Switch, { checked: form.watch("isDefault"), onCheckedChange: (v) => form.setValue("isDefault", v) }), _jsx(Label, { children: priceRuleMessages.defaultSwitchLabel })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Switch, { checked: form.watch("active"), onCheckedChange: (v) => form.setValue("active", v) }), _jsx(Label, { children: priceRuleMessages.activeSwitchLabel })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: priceRuleMessages.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 : priceRuleMessages.create] })] })] }));
|
|
122
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type OptionPricingLayout } from "./product-options-shared.js";
|
|
2
|
+
export interface OptionPricingGridProps {
|
|
3
|
+
productId: string;
|
|
4
|
+
optionId: string;
|
|
5
|
+
optionName: string;
|
|
6
|
+
productCurrency: string;
|
|
7
|
+
layout: OptionPricingLayout;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The everyday pricing surface for a booking option: one table that merges
|
|
11
|
+
* inventory (rooms / traveler types) with what each traveler pays. The single
|
|
12
|
+
* default rate plan is auto-managed and hidden — agents never see catalogs or
|
|
13
|
+
* rate-plan chrome here (that lives under Advanced).
|
|
14
|
+
*/
|
|
15
|
+
export declare function OptionPricingGrid({ productId, optionId, optionName, productCurrency, layout, }: OptionPricingGridProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
//# sourceMappingURL=product-option-pricing-grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-option-pricing-grid.d.ts","sourceRoot":"","sources":["../../../src/components/product-detail/product-option-pricing-grid.tsx"],"names":[],"mappings":"AA0BA,OAAO,EAML,KAAK,mBAAmB,EACzB,MAAM,6BAA6B,CAAA;AA8BpC,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,mBAAmB,CAAA;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,QAAQ,EACR,UAAU,EACV,eAAe,EACf,MAAM,GACP,EAAE,sBAAsB,2CA0bxB"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
// agent-quality: file-size exception -- owner: inventory-react; existing UI surface stays co-located until a dedicated split preserves behavior and tests.
|
|
2
|
+
"use client";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
5
|
+
import { formatMessage } from "@voyant-travel/i18n";
|
|
6
|
+
import { Button } from "@voyant-travel/ui/components/button";
|
|
7
|
+
import { Pencil, Plus, Trash2 } from "lucide-react";
|
|
8
|
+
import { useState } from "react";
|
|
9
|
+
import { useOptionUnitMutation, useVoyantProductsContext } from "../../index.js";
|
|
10
|
+
import { useOptionPriceRuleMutation, useOptionUnitPriceRuleMutation, usePriceCatalogMutation, usePricingCategoryMutation, } from "./commerce-client.js";
|
|
11
|
+
import { useProductDetailApi, useProductDetailMessages } from "./host.js";
|
|
12
|
+
import { categoryAppliesToUnit, ExtraPriceRulesPanel, formatProductMoney, getCategoryCondition, isTravelerCategory, TravelerCategoryDialog, } from "./product-options-pricing.js";
|
|
13
|
+
import { getOptionPriceRulesQueryOptions, getOptionUnitPriceRulesQueryOptions, getOptionUnitsQueryOptions, getPriceCatalogsQueryOptions, getPricingCategoriesQueryOptions, } from "./product-options-shared.js";
|
|
14
|
+
import { UnitDialog } from "./product-unit-dialog.js";
|
|
15
|
+
import { UnitPriceRuleDialog, } from "./product-unit-price-rule-dialog.js";
|
|
16
|
+
function formatAvailability(unit, messages) {
|
|
17
|
+
if (unit.maxQuantity != null && unit.maxQuantity > 0) {
|
|
18
|
+
return formatMessage(messages.perDeparture, { count: unit.maxQuantity });
|
|
19
|
+
}
|
|
20
|
+
return "—";
|
|
21
|
+
}
|
|
22
|
+
function unitSubtitle(unit, layout, messages) {
|
|
23
|
+
if (layout === "rooms") {
|
|
24
|
+
const sleeps = unit.occupancyMax ?? unit.occupancyMin;
|
|
25
|
+
return sleeps != null ? formatMessage(messages.sleeps, { count: sleeps }) : null;
|
|
26
|
+
}
|
|
27
|
+
if (unit.minAge != null || unit.maxAge != null) {
|
|
28
|
+
return `${unit.minAge ?? 0}–${unit.maxAge ?? "∞"}`;
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The everyday pricing surface for a booking option: one table that merges
|
|
34
|
+
* inventory (rooms / traveler types) with what each traveler pays. The single
|
|
35
|
+
* default rate plan is auto-managed and hidden — agents never see catalogs or
|
|
36
|
+
* rate-plan chrome here (that lives under Advanced).
|
|
37
|
+
*/
|
|
38
|
+
export function OptionPricingGrid({ productId, optionId, optionName, productCurrency, layout, }) {
|
|
39
|
+
const productsClient = useVoyantProductsContext();
|
|
40
|
+
const api = useProductDetailApi();
|
|
41
|
+
const messages = useProductDetailMessages();
|
|
42
|
+
const t = messages.products.operations.pricingGrid;
|
|
43
|
+
const priceRuleMessages = messages.products.operations.priceRules;
|
|
44
|
+
const { data: unitsData, refetch: refetchUnits } = useQuery(getOptionUnitsQueryOptions(productsClient, optionId));
|
|
45
|
+
const { data: rulesData, refetch: refetchRules } = useQuery(getOptionPriceRulesQueryOptions(api, optionId));
|
|
46
|
+
const { data: categoriesData, refetch: refetchCategories } = useQuery(getPricingCategoriesQueryOptions(api));
|
|
47
|
+
const { data: catalogsData } = useQuery(getPriceCatalogsQueryOptions(api));
|
|
48
|
+
const rules = rulesData?.data ?? [];
|
|
49
|
+
const defaultRule = rules.find((rule) => rule.isDefault) ?? rules[0];
|
|
50
|
+
const { data: cellsData, refetch: refetchCells } = useQuery({
|
|
51
|
+
...getOptionUnitPriceRulesQueryOptions(api, defaultRule?.id ?? "__none__"),
|
|
52
|
+
enabled: Boolean(defaultRule?.id),
|
|
53
|
+
});
|
|
54
|
+
const { remove: removeUnit } = useOptionUnitMutation();
|
|
55
|
+
const { remove: removeCell } = useOptionUnitPriceRuleMutation();
|
|
56
|
+
const { create: createRule } = useOptionPriceRuleMutation();
|
|
57
|
+
const { create: createCatalog } = usePriceCatalogMutation();
|
|
58
|
+
const { remove: removeCategory } = usePricingCategoryMutation();
|
|
59
|
+
const deleteUnitMutation = useMutation({
|
|
60
|
+
mutationFn: (id) => removeUnit.mutateAsync(id),
|
|
61
|
+
onSuccess: () => {
|
|
62
|
+
void refetchUnits();
|
|
63
|
+
void refetchCells();
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
const deleteCellMutation = useMutation({
|
|
67
|
+
mutationFn: (id) => removeCell.mutateAsync(id),
|
|
68
|
+
onSuccess: () => void refetchCells(),
|
|
69
|
+
});
|
|
70
|
+
const [unitDialogOpen, setUnitDialogOpen] = useState(false);
|
|
71
|
+
const [editingUnit, setEditingUnit] = useState();
|
|
72
|
+
const [defaultUnitType, setDefaultUnitType] = useState("room");
|
|
73
|
+
const [categoryDialogOpen, setCategoryDialogOpen] = useState(false);
|
|
74
|
+
const [editingCategory, setEditingCategory] = useState();
|
|
75
|
+
const [cellDialogOpen, setCellDialogOpen] = useState(false);
|
|
76
|
+
const [cellRuleId, setCellRuleId] = useState();
|
|
77
|
+
const [editingCell, setEditingCell] = useState();
|
|
78
|
+
const [preselectedUnitId, setPreselectedUnitId] = useState();
|
|
79
|
+
const [preselectedCategoryId, setPreselectedCategoryId] = useState();
|
|
80
|
+
const units = (unitsData?.data ?? [])
|
|
81
|
+
.filter((unit) => !unit.isHidden)
|
|
82
|
+
.slice()
|
|
83
|
+
.sort((a, b) => a.sortOrder - b.sortOrder);
|
|
84
|
+
// Inventory wins over the booking-mode hint: an option that actually holds
|
|
85
|
+
// rooms (or vehicles/groups) is always priced as a rooms grid, even if the
|
|
86
|
+
// product's booking mode was set to a per-person type. The `layout` prop only
|
|
87
|
+
// decides the shape for a brand-new option that has no inventory yet.
|
|
88
|
+
const hasRoomLikeUnits = units.some((unit) => unit.unitType === "room" || unit.unitType === "vehicle" || unit.unitType === "group");
|
|
89
|
+
const hasPersonUnits = units.some((unit) => unit.unitType === "person");
|
|
90
|
+
const effectiveLayout = hasRoomLikeUnits
|
|
91
|
+
? "rooms"
|
|
92
|
+
: hasPersonUnits
|
|
93
|
+
? "seats"
|
|
94
|
+
: layout;
|
|
95
|
+
const cells = cellsData?.data ?? [];
|
|
96
|
+
const referencedCategoryIds = new Set(cells.flatMap((cell) => (cell.pricingCategoryId ? [cell.pricingCategoryId] : [])));
|
|
97
|
+
const categories = (categoriesData?.data ?? [])
|
|
98
|
+
.filter((category) => category.active &&
|
|
99
|
+
((isTravelerCategory(category) &&
|
|
100
|
+
(category.productId == null || category.productId === productId) &&
|
|
101
|
+
(category.optionId == null || category.optionId === optionId)) ||
|
|
102
|
+
referencedCategoryIds.has(category.id)))
|
|
103
|
+
.slice()
|
|
104
|
+
.sort((a, b) => a.sortOrder - b.sortOrder);
|
|
105
|
+
// Traveler-type columns. Seats layout prices each traveler-type row once
|
|
106
|
+
// (single price column). Rooms layout splits price by traveler category once
|
|
107
|
+
// any exist, else shows a single base-price column per room.
|
|
108
|
+
const columns = effectiveLayout === "rooms" && categories.length > 0
|
|
109
|
+
? categories.map((category) => ({
|
|
110
|
+
id: category.id,
|
|
111
|
+
name: category.name,
|
|
112
|
+
metadata: category.metadata,
|
|
113
|
+
}))
|
|
114
|
+
: [{ id: null, name: t.priceColumn }];
|
|
115
|
+
const nextUnitSortOrder = units.length > 0 ? Math.max(...units.map((u) => u.sortOrder)) + 1 : 0;
|
|
116
|
+
const findCell = (unitId, categoryId) => cells.find((cell) => cell.unitId === unitId && (cell.pricingCategoryId ?? null) === categoryId) ?? null;
|
|
117
|
+
// Lazily materialize the hidden default rate plan (and a default catalog if
|
|
118
|
+
// the tenant has none) the first time the agent enters a price. Keeps the
|
|
119
|
+
// common path free of any rate-plan/catalog ceremony.
|
|
120
|
+
async function ensureRatePlanId() {
|
|
121
|
+
if (defaultRule?.id)
|
|
122
|
+
return defaultRule.id;
|
|
123
|
+
const catalogs = catalogsData?.data ?? [];
|
|
124
|
+
const existingCatalog = catalogs.find((catalog) => catalog.isDefault) ?? catalogs[0];
|
|
125
|
+
const catalogId = existingCatalog?.id ??
|
|
126
|
+
(await createCatalog.mutateAsync({
|
|
127
|
+
code: "default",
|
|
128
|
+
name: t.priceColumn,
|
|
129
|
+
catalogType: "public",
|
|
130
|
+
isDefault: true,
|
|
131
|
+
})).id;
|
|
132
|
+
const created = await createRule.mutateAsync({
|
|
133
|
+
productId,
|
|
134
|
+
optionId,
|
|
135
|
+
priceCatalogId: catalogId,
|
|
136
|
+
name: optionName,
|
|
137
|
+
pricingMode: "per_person",
|
|
138
|
+
baseSellAmountCents: 0,
|
|
139
|
+
baseCostAmountCents: 0,
|
|
140
|
+
allPricingCategories: effectiveLayout === "seats",
|
|
141
|
+
isDefault: true,
|
|
142
|
+
active: true,
|
|
143
|
+
});
|
|
144
|
+
await refetchRules();
|
|
145
|
+
return created.id;
|
|
146
|
+
}
|
|
147
|
+
async function openCellDialog(unit, categoryId) {
|
|
148
|
+
const ruleId = await ensureRatePlanId();
|
|
149
|
+
setCellRuleId(ruleId);
|
|
150
|
+
setEditingCell(undefined);
|
|
151
|
+
setPreselectedUnitId(unit.id);
|
|
152
|
+
setPreselectedCategoryId(categoryId);
|
|
153
|
+
setCellDialogOpen(true);
|
|
154
|
+
}
|
|
155
|
+
const addRoomOrTraveler = () => {
|
|
156
|
+
setEditingUnit(undefined);
|
|
157
|
+
setDefaultUnitType(effectiveLayout === "rooms" ? "room" : "person");
|
|
158
|
+
setUnitDialogOpen(true);
|
|
159
|
+
};
|
|
160
|
+
const editTravelerType = (category) => {
|
|
161
|
+
setEditingCategory(category);
|
|
162
|
+
setCategoryDialogOpen(true);
|
|
163
|
+
};
|
|
164
|
+
async function removeTravelerType(category) {
|
|
165
|
+
if (!confirm(formatMessage(messages.products.operations.priceRules.travelerCategoryDeleteConfirm, {
|
|
166
|
+
name: category.name,
|
|
167
|
+
}))) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
// Categories this product/option owns are deleted outright. A global
|
|
171
|
+
// category only shows here because some cell references it, so removing
|
|
172
|
+
// its prices drops the column from this option without touching the
|
|
173
|
+
// shared category.
|
|
174
|
+
if (category.productId === productId || category.optionId === optionId) {
|
|
175
|
+
await removeCategory.mutateAsync(category.id);
|
|
176
|
+
void refetchCategories();
|
|
177
|
+
void refetchCells();
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
for (const cell of cells.filter((entry) => entry.pricingCategoryId === category.id)) {
|
|
181
|
+
await removeCell.mutateAsync(cell.id);
|
|
182
|
+
}
|
|
183
|
+
void refetchCells();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const unitColumnLabel = effectiveLayout === "rooms" ? t.roomColumn : t.travelerColumn;
|
|
187
|
+
return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: "flex items-start justify-between gap-3", children: [_jsxs("div", { children: [_jsx("p", { className: "text-sm font-medium", children: effectiveLayout === "rooms" ? t.roomsTitle : t.seatsTitle }), _jsx("p", { className: "text-xs text-muted-foreground", children: effectiveLayout === "rooms" ? t.roomsDescription : t.seatsDescription })] }), _jsxs("div", { className: "flex items-center gap-2", children: [effectiveLayout === "rooms" ? (_jsxs(Button, { variant: "outline", size: "sm", onClick: () => {
|
|
188
|
+
setEditingCategory(undefined);
|
|
189
|
+
setCategoryDialogOpen(true);
|
|
190
|
+
}, children: [_jsx(Plus, { className: "mr-1 h-3.5 w-3.5" }), t.addTravelerType] })) : null, _jsxs(Button, { variant: "outline", size: "sm", onClick: addRoomOrTraveler, children: [_jsx(Plus, { className: "mr-1 h-3.5 w-3.5" }), effectiveLayout === "rooms" ? t.addRoom : t.addTravelerType] })] })] }), units.length === 0 ? (_jsx("p", { className: "rounded-md border bg-background px-3 py-6 text-center text-sm text-muted-foreground", children: effectiveLayout === "rooms" ? t.emptyRooms : t.emptySeats })) : (_jsx("div", { className: "overflow-x-auto rounded-md border bg-background", children: _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { children: _jsxs("tr", { className: "border-b bg-muted/40 text-muted-foreground", children: [_jsx("th", { className: "p-2.5 text-left font-medium", children: unitColumnLabel }), _jsx("th", { className: "p-2.5 text-left font-medium", children: t.availableColumn }), columns.map((column) => {
|
|
191
|
+
const condition = getCategoryCondition(column.metadata);
|
|
192
|
+
const category = column.id
|
|
193
|
+
? categories.find((entry) => entry.id === column.id)
|
|
194
|
+
: undefined;
|
|
195
|
+
return (_jsx("th", { className: "group p-2.5 text-left font-medium", children: _jsxs("div", { className: "flex items-start justify-between gap-2", children: [_jsxs("div", { children: [_jsx("div", { children: column.name }), condition ? (_jsx("div", { className: "mt-0.5 max-w-[220px] text-[10px] font-normal normal-case leading-snug text-muted-foreground", children: condition })) : null] }), category ? (_jsxs("div", { className: "flex shrink-0 items-center gap-0.5 opacity-0 transition group-hover:opacity-100", children: [_jsx("button", { type: "button", "aria-label": priceRuleMessages.travelerCategoryEdit, onClick: () => editTravelerType(category), className: "text-muted-foreground hover:text-foreground", children: _jsx(Pencil, { className: "h-3 w-3" }) }), _jsx("button", { type: "button", "aria-label": priceRuleMessages.travelerCategoryDelete, onClick: () => void removeTravelerType(category), className: "text-muted-foreground hover:text-destructive", children: _jsx(Trash2, { className: "h-3 w-3" }) })] })) : null] }) }, column.id ?? "__base__"));
|
|
196
|
+
}), _jsx("th", { className: "w-[72px] p-2.5 text-right font-medium" })] }) }), _jsx("tbody", { children: units.map((unit) => {
|
|
197
|
+
const subtitle = unitSubtitle(unit, effectiveLayout, t);
|
|
198
|
+
return (_jsxs("tr", { className: "border-b last:border-b-0", children: [_jsxs("td", { className: "p-2.5", children: [_jsx("div", { className: "font-medium", children: unit.name }), subtitle ? (_jsx("div", { className: "text-[11px] text-muted-foreground", children: subtitle })) : null] }), _jsx("td", { className: "p-2.5 text-muted-foreground", children: formatAvailability(unit, t) }), columns.map((column) => {
|
|
199
|
+
const cell = findCell(unit.id, column.id);
|
|
200
|
+
const canPrice = categoryAppliesToUnit(column, unit);
|
|
201
|
+
return (_jsx("td", { className: "p-2.5", children: cell ? (_jsxs("div", { className: "flex items-center gap-1.5", children: [_jsx("button", { type: "button", onClick: () => {
|
|
202
|
+
setCellRuleId(defaultRule?.id);
|
|
203
|
+
setEditingCell(cell);
|
|
204
|
+
setPreselectedUnitId(undefined);
|
|
205
|
+
setPreselectedCategoryId(undefined);
|
|
206
|
+
setCellDialogOpen(true);
|
|
207
|
+
}, className: "font-mono text-foreground hover:underline", children: formatProductMoney(cell.sellAmountCents, productCurrency) }), _jsx("button", { type: "button", "aria-label": t.deleteRoom, onClick: () => deleteCellMutation.mutate(cell.id), className: "text-muted-foreground hover:text-destructive", children: _jsx(Trash2, { className: "h-3 w-3" }) })] })) : canPrice ? (_jsxs("button", { type: "button", onClick: () => void openCellDialog(unit, column.id), className: "inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground", children: [_jsx(Plus, { className: "h-3 w-3" }), t.setPrice] })) : (_jsx("span", { className: "text-muted-foreground", children: "\u2014" })) }, column.id ?? "__base__"));
|
|
208
|
+
}), _jsx("td", { className: "p-2.5", children: _jsxs("div", { className: "flex items-center justify-end gap-1", children: [_jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": t.editRoom, onClick: () => {
|
|
209
|
+
setEditingUnit(unit);
|
|
210
|
+
setDefaultUnitType(unit.unitType);
|
|
211
|
+
setUnitDialogOpen(true);
|
|
212
|
+
}, children: _jsx(Pencil, { className: "h-4 w-4" }) }), _jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": t.deleteRoom, onClick: () => {
|
|
213
|
+
if (confirm(formatMessage(t.deleteRoomConfirm, { name: unit.name }))) {
|
|
214
|
+
deleteUnitMutation.mutate(unit.id);
|
|
215
|
+
}
|
|
216
|
+
}, children: _jsx(Trash2, { className: "h-4 w-4" }) })] }) })] }, unit.id));
|
|
217
|
+
}) })] }) })), _jsx(ExtraPriceRulesPanel, { productId: productId, optionId: optionId, optionPriceRuleId: defaultRule?.id, ensureOptionPriceRuleId: ensureRatePlanId, productCurrency: productCurrency }), _jsx(UnitDialog, { open: unitDialogOpen, onOpenChange: setUnitDialogOpen, optionId: optionId, unit: editingUnit, defaultUnitType: editingUnit ? undefined : defaultUnitType, lockUnitType: true, nextSortOrder: nextUnitSortOrder, onSuccess: () => {
|
|
218
|
+
setUnitDialogOpen(false);
|
|
219
|
+
setEditingUnit(undefined);
|
|
220
|
+
void refetchUnits();
|
|
221
|
+
} }), _jsx(TravelerCategoryDialog, { open: categoryDialogOpen, onOpenChange: (open) => {
|
|
222
|
+
setCategoryDialogOpen(open);
|
|
223
|
+
if (!open)
|
|
224
|
+
setEditingCategory(undefined);
|
|
225
|
+
}, productId: productId, units: units, category: editingCategory, nextSortOrder: categories.length > 0 ? Math.max(...categories.map((c) => c.sortOrder)) + 1 : 0, onSuccess: () => {
|
|
226
|
+
setCategoryDialogOpen(false);
|
|
227
|
+
setEditingCategory(undefined);
|
|
228
|
+
void refetchCategories();
|
|
229
|
+
} }), _jsx(UnitPriceRuleDialog, { open: cellDialogOpen, onOpenChange: setCellDialogOpen, optionPriceRuleId: cellRuleId ?? defaultRule?.id ?? "", optionId: optionId, units: units, productCurrency: productCurrency, preselectedUnitId: preselectedUnitId, preselectedCategoryId: preselectedCategoryId, cell: editingCell, onSuccess: () => {
|
|
230
|
+
setCellDialogOpen(false);
|
|
231
|
+
setEditingCell(undefined);
|
|
232
|
+
setPreselectedUnitId(undefined);
|
|
233
|
+
setPreselectedCategoryId(undefined);
|
|
234
|
+
void refetchCells();
|
|
235
|
+
} })] }));
|
|
236
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function ExtraPriceRulesPanel({ productId, optionId, optionPriceRuleId, ensureOptionPriceRuleId, productCurrency, }: {
|
|
2
|
+
productId: string;
|
|
3
|
+
optionId: string;
|
|
4
|
+
optionPriceRuleId?: string;
|
|
5
|
+
ensureOptionPriceRuleId?: () => Promise<string>;
|
|
6
|
+
productCurrency: string;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=product-options-extra-price-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-options-extra-price-rules.d.ts","sourceRoot":"","sources":["../../../src/components/product-detail/product-options-extra-price-rules.tsx"],"names":[],"mappings":"AAmCA,wBAAgB,oBAAoB,CAAC,EACnC,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,GAChB,EAAE;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAIhB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,uBAAuB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IAC/C,eAAe,EAAE,MAAM,CAAA;CACxB,2CAwJA"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { formatMessage } from "@voyant-travel/i18n";
|
|
3
|
+
import { Badge, Button, Dialog, DialogBody, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@voyant-travel/ui/components";
|
|
4
|
+
import { Pencil, Plus, Trash2 } from "lucide-react";
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
|
+
import { useProductExtraMutation, useProductExtras, } from "../../extras-compat.js";
|
|
7
|
+
import { useExtraPriceRuleMutation, useExtraPriceRules, } from "./commerce-client.js";
|
|
8
|
+
import { useProductDetailMessages } from "./host.js";
|
|
9
|
+
import { getExtraPricingModeLabel, ProductExtraDialog } from "./product-extra-dialog.js";
|
|
10
|
+
import { formatProductMoney } from "./product-options-pricing-helpers.js";
|
|
11
|
+
export function ExtraPriceRulesPanel({ productId, optionId, optionPriceRuleId, ensureOptionPriceRuleId, productCurrency, }) {
|
|
12
|
+
const messages = useProductDetailMessages();
|
|
13
|
+
const extraPriceMessages = messages.products.operations.extraPrices;
|
|
14
|
+
const extraMessages = messages.products.operations.extras;
|
|
15
|
+
const extrasQuery = useProductExtras({ productId, limit: 100 });
|
|
16
|
+
const rulesQuery = useExtraPriceRules({
|
|
17
|
+
optionPriceRuleId: optionPriceRuleId ?? "__none__",
|
|
18
|
+
optionId,
|
|
19
|
+
active: true,
|
|
20
|
+
limit: 100,
|
|
21
|
+
enabled: !!optionPriceRuleId,
|
|
22
|
+
});
|
|
23
|
+
const { remove: removeExtra } = useProductExtraMutation();
|
|
24
|
+
const [pricingExtraId, setPricingExtraId] = useState(null);
|
|
25
|
+
const [pricingRuleId, setPricingRuleId] = useState(optionPriceRuleId);
|
|
26
|
+
const [definitionDialogOpen, setDefinitionDialogOpen] = useState(false);
|
|
27
|
+
const [editingExtra, setEditingExtra] = useState();
|
|
28
|
+
const extras = (extrasQuery.data?.data ?? []).slice().sort((a, b) => a.sortOrder - b.sortOrder);
|
|
29
|
+
const rules = rulesQuery.data?.data ?? [];
|
|
30
|
+
const ruleByExtraId = new Map(rules.flatMap((rule) => (rule.productExtraId ? [[rule.productExtraId, rule]] : [])));
|
|
31
|
+
const pricingExtra = extras.find((extra) => extra.id === pricingExtraId) ?? null;
|
|
32
|
+
return (_jsxs("div", { className: "mt-4 border-t pt-3", children: [_jsxs("div", { className: "mb-2 flex items-center justify-between gap-2", children: [_jsx("div", { className: "text-[10px] font-medium uppercase tracking-wide text-muted-foreground", children: extraMessages.sectionTitle }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => {
|
|
33
|
+
setEditingExtra(undefined);
|
|
34
|
+
setDefinitionDialogOpen(true);
|
|
35
|
+
}, children: [_jsx(Plus, { className: "mr-1 h-3 w-3" }), extraMessages.addAction] })] }), extras.length === 0 ? (_jsx("p", { className: "py-2 text-center text-xs text-muted-foreground", children: extraMessages.empty })) : (_jsx("div", { className: "flex flex-col gap-2", children: extras.map((extra) => {
|
|
36
|
+
const rule = ruleByExtraId.get(extra.id);
|
|
37
|
+
return (_jsxs("div", { className: "flex items-center justify-between gap-3 rounded border px-2 py-1.5 text-xs", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [_jsx("span", { className: "font-medium", children: extra.name }), _jsx(Badge, { variant: "secondary", className: "text-[10px]", children: getExtraPricingModeLabel(extra.pricingMode, extraMessages) }), extra.pricedPerPerson ? (_jsx("span", { className: "text-muted-foreground", children: extraPriceMessages.perTraveler })) : null] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "font-mono", children: rule?.sellAmountCents != null
|
|
38
|
+
? formatProductMoney(rule.sellAmountCents, productCurrency)
|
|
39
|
+
: extraPriceMessages.noAmount }), _jsx(Button, { variant: "outline", size: "sm", onClick: () => {
|
|
40
|
+
void (async () => {
|
|
41
|
+
const ruleId = optionPriceRuleId ??
|
|
42
|
+
(ensureOptionPriceRuleId ? await ensureOptionPriceRuleId() : undefined);
|
|
43
|
+
if (!ruleId)
|
|
44
|
+
return;
|
|
45
|
+
setPricingRuleId(ruleId);
|
|
46
|
+
setPricingExtraId(extra.id);
|
|
47
|
+
})();
|
|
48
|
+
}, children: extraPriceMessages.setPrice }), _jsx("button", { type: "button", "aria-label": extraMessages.editAction, onClick: () => {
|
|
49
|
+
setEditingExtra(extra);
|
|
50
|
+
setDefinitionDialogOpen(true);
|
|
51
|
+
}, className: "text-muted-foreground hover:text-foreground", children: _jsx(Pencil, { className: "h-3 w-3" }) }), _jsx("button", { type: "button", "aria-label": extraMessages.deleteAction, onClick: () => {
|
|
52
|
+
if (confirm(formatMessage(extraMessages.deleteConfirm, { name: extra.name }))) {
|
|
53
|
+
removeExtra.mutate(extra.id, {
|
|
54
|
+
onSuccess: () => void extrasQuery.refetch(),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}, className: "text-muted-foreground hover:text-destructive", children: _jsx(Trash2, { className: "h-3 w-3" }) })] })] }, extra.id));
|
|
58
|
+
}) })), _jsx(ProductExtraDialog, { open: definitionDialogOpen, onOpenChange: (open) => {
|
|
59
|
+
setDefinitionDialogOpen(open);
|
|
60
|
+
if (!open)
|
|
61
|
+
setEditingExtra(undefined);
|
|
62
|
+
}, productId: productId, extra: editingExtra, nextSortOrder: extras.length, onSuccess: () => {
|
|
63
|
+
setDefinitionDialogOpen(false);
|
|
64
|
+
setEditingExtra(undefined);
|
|
65
|
+
void extrasQuery.refetch();
|
|
66
|
+
} }), pricingExtra && (pricingRuleId ?? optionPriceRuleId) ? (_jsx(ExtraPriceRuleDialog, { open: !!pricingExtra, onOpenChange: (open) => {
|
|
67
|
+
if (!open)
|
|
68
|
+
setPricingExtraId(null);
|
|
69
|
+
}, optionPriceRuleId: (pricingRuleId ?? optionPriceRuleId), optionId: optionId, extra: pricingExtra, existingRule: ruleByExtraId.get(pricingExtra.id), nextSortOrder: rules.length, productCurrency: productCurrency, onSuccess: () => {
|
|
70
|
+
setPricingExtraId(null);
|
|
71
|
+
void rulesQuery.refetch();
|
|
72
|
+
} })) : null] }));
|
|
73
|
+
}
|
|
74
|
+
function ExtraPriceRuleDialog({ open, onOpenChange, optionPriceRuleId, optionId, extra, existingRule, nextSortOrder, productCurrency, onSuccess, }) {
|
|
75
|
+
const messages = useProductDetailMessages();
|
|
76
|
+
const extraPriceMessages = messages.products.operations.extraPrices;
|
|
77
|
+
const { create, update } = useExtraPriceRuleMutation();
|
|
78
|
+
const [amount, setAmount] = useState("");
|
|
79
|
+
const [pricingMode, setPricingMode] = useState("per_booking");
|
|
80
|
+
const isEditing = !!existingRule;
|
|
81
|
+
const pricingModes = [
|
|
82
|
+
{ value: "per_booking", label: extraPriceMessages.pricingPerBooking },
|
|
83
|
+
{ value: "per_person", label: extraPriceMessages.pricingPerPerson },
|
|
84
|
+
{ value: "included", label: extraPriceMessages.pricingIncluded },
|
|
85
|
+
{ value: "on_request", label: extraPriceMessages.pricingOnRequest },
|
|
86
|
+
{ value: "unavailable", label: extraPriceMessages.pricingUnavailable },
|
|
87
|
+
];
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
setAmount(existingRule?.sellAmountCents != null ? String(existingRule.sellAmountCents / 100) : "");
|
|
90
|
+
setPricingMode(existingRule?.pricingMode ?? defaultExtraPriceRuleMode(extra));
|
|
91
|
+
}, [existingRule, extra]);
|
|
92
|
+
const save = async () => {
|
|
93
|
+
const parsedAmount = amount.trim() === "" ? null : Math.round(Number(amount) * 100);
|
|
94
|
+
if (parsedAmount != null && (!Number.isFinite(parsedAmount) || parsedAmount < 0))
|
|
95
|
+
return;
|
|
96
|
+
const payload = {
|
|
97
|
+
optionPriceRuleId,
|
|
98
|
+
optionId,
|
|
99
|
+
productExtraId: extra.id,
|
|
100
|
+
optionExtraConfigId: null,
|
|
101
|
+
pricingMode,
|
|
102
|
+
sellAmountCents: parsedAmount,
|
|
103
|
+
costAmountCents: null,
|
|
104
|
+
active: true,
|
|
105
|
+
sortOrder: existingRule?.sortOrder ?? nextSortOrder,
|
|
106
|
+
};
|
|
107
|
+
if (existingRule)
|
|
108
|
+
await update.mutateAsync({ id: existingRule.id, input: payload });
|
|
109
|
+
else
|
|
110
|
+
await create.mutateAsync(payload);
|
|
111
|
+
onSuccess();
|
|
112
|
+
};
|
|
113
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: isEditing ? extraPriceMessages.editTitle : extraPriceMessages.newTitle }), _jsx(DialogDescription, { children: extra.name })] }), _jsxs(DialogBody, { className: "grid gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: extraPriceMessages.pricingModeLabel }), _jsxs(Select, { value: pricingMode, onValueChange: (value) => setPricingMode((value ?? "per_booking")), items: pricingModes, children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: pricingModes.map((mode) => (_jsx(SelectItem, { value: mode.value, children: mode.label }, mode.value))) })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: extraPriceMessages.sellAmountLabel }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Input, { value: amount, type: "number", min: "0", step: "0.01", onChange: (event) => setAmount(event.target.value) }), _jsx("span", { className: "min-w-12 text-muted-foreground text-sm", children: productCurrency })] })] })] }), _jsxs(DialogFooter, { className: "-mx-6 -mb-6", children: [_jsx(Button, { variant: "ghost", onClick: () => onOpenChange(false), children: extraPriceMessages.cancel }), _jsx(Button, { onClick: () => void save(), children: extraPriceMessages.save })] })] }) }));
|
|
114
|
+
}
|
|
115
|
+
function defaultExtraPriceRuleMode(extra) {
|
|
116
|
+
if (extra.pricedPerPerson || extra.pricingMode === "per_person")
|
|
117
|
+
return "per_person";
|
|
118
|
+
if (extra.pricingMode === "included" || extra.pricingMode === "free")
|
|
119
|
+
return "included";
|
|
120
|
+
if (extra.pricingMode === "on_request")
|
|
121
|
+
return "on_request";
|
|
122
|
+
return "per_booking";
|
|
123
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PricingCategoryRecord } from "./commerce-client.js";
|
|
2
|
+
import type { useProductDetailMessages } from "./host.js";
|
|
3
|
+
import type { OptionUnitData } from "./product-unit-dialog.js";
|
|
4
|
+
export declare function getUnitTypeLabel(type: OptionUnitData["unitType"], messages: ReturnType<typeof useProductDetailMessages>["products"]["operations"]["units"]): string;
|
|
5
|
+
export declare function isTravelerCategory(category: {
|
|
6
|
+
categoryType: PricingCategoryRecord["categoryType"];
|
|
7
|
+
}): boolean;
|
|
8
|
+
export declare function getCategoryCondition(metadata: Record<string, unknown> | null | undefined): string | null;
|
|
9
|
+
export declare function categoryAppliesToUnit(category: {
|
|
10
|
+
id: string | null;
|
|
11
|
+
metadata?: Record<string, unknown> | null;
|
|
12
|
+
}, unit: OptionUnitData): boolean;
|
|
13
|
+
export declare function formatProductMoney(amountCents: number | null | undefined, currency: string): string;
|
|
14
|
+
//# sourceMappingURL=product-options-pricing-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-options-pricing-helpers.d.ts","sourceRoot":"","sources":["../../../src/components/product-detail/product-options-pricing-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAE9D,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,EAChC,QAAQ,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,UAkBzF;AAcD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE;IAC3C,YAAY,EAAE,qBAAqB,CAAC,cAAc,CAAC,CAAA;CACpD,WAEA;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,iBAGxF;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE;IAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;CAAE,EAC1E,IAAI,EAAE,cAAc,WAMrB;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,UAG1F"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export function getUnitTypeLabel(type, messages) {
|
|
2
|
+
switch (type) {
|
|
3
|
+
case "person":
|
|
4
|
+
return messages.typePerson;
|
|
5
|
+
case "group":
|
|
6
|
+
return messages.typeGroup;
|
|
7
|
+
case "room":
|
|
8
|
+
return messages.typeRoom;
|
|
9
|
+
case "vehicle":
|
|
10
|
+
return messages.typeVehicle;
|
|
11
|
+
case "service":
|
|
12
|
+
return messages.typeService;
|
|
13
|
+
case "other":
|
|
14
|
+
return messages.typeOther;
|
|
15
|
+
default:
|
|
16
|
+
return type;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// Pricing categories that describe the *unit* dimension (room/vehicle — already
|
|
20
|
+
// the grid's rows) or a standalone add-on (`service`, handled by the extras
|
|
21
|
+
// panel) are not per-traveler price columns. Excluding them stops a product
|
|
22
|
+
// whose data carries such categories — e.g. legacy data migrated with a
|
|
23
|
+
// "Double room" pricing category alongside the real Adult/Child split — from
|
|
24
|
+
// rendering one bogus price column per room next to the traveler columns.
|
|
25
|
+
const NON_TRAVELER_CATEGORY_TYPES = new Set([
|
|
26
|
+
"room",
|
|
27
|
+
"vehicle",
|
|
28
|
+
"service",
|
|
29
|
+
]);
|
|
30
|
+
export function isTravelerCategory(category) {
|
|
31
|
+
return !NON_TRAVELER_CATEGORY_TYPES.has(category.categoryType);
|
|
32
|
+
}
|
|
33
|
+
export function getCategoryCondition(metadata) {
|
|
34
|
+
const condition = metadata?.condition;
|
|
35
|
+
return typeof condition === "string" && condition.trim().length > 0 ? condition : null;
|
|
36
|
+
}
|
|
37
|
+
export function categoryAppliesToUnit(category, unit) {
|
|
38
|
+
if (!category.id)
|
|
39
|
+
return true;
|
|
40
|
+
const allowedUnitIds = category.metadata?.allowedUnitIds;
|
|
41
|
+
if (!Array.isArray(allowedUnitIds) || allowedUnitIds.length === 0)
|
|
42
|
+
return true;
|
|
43
|
+
return allowedUnitIds.includes(unit.id);
|
|
44
|
+
}
|
|
45
|
+
export function formatProductMoney(amountCents, currency) {
|
|
46
|
+
if (amountCents == null)
|
|
47
|
+
return "-";
|
|
48
|
+
return `${(amountCents / 100).toFixed(2)} ${currency}`;
|
|
49
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { type OptionPricingLayout } from "./product-options-shared.js";
|
|
3
|
+
/**
|
|
4
|
+
* Per-option pricing surface. The everyday view is the merged rooms/seats
|
|
5
|
+
* grid; the full rate-plan machinery (multiple plans, catalogs, cost prices,
|
|
6
|
+
* cancellation) plus any injected per-departure inventory live behind an
|
|
7
|
+
* Advanced disclosure so low-tech agents never have to see them.
|
|
8
|
+
*/
|
|
9
|
+
export declare function PricingPanel({ productId, optionId, optionName, productCurrency, layout, extras, }: {
|
|
10
|
+
productId: string;
|
|
11
|
+
optionId: string;
|
|
12
|
+
optionName: string;
|
|
13
|
+
productCurrency: string;
|
|
14
|
+
layout: OptionPricingLayout;
|
|
15
|
+
extras?: React.ReactNode;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=product-options-pricing-panel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-options-pricing-panel.d.ts","sourceRoot":"","sources":["../../../src/components/product-detail/product-options-pricing-panel.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAA;AASnC,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,6BAA6B,CAAA;AAoCpC;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAC3B,SAAS,EACT,QAAQ,EACR,UAAU,EACV,eAAe,EACf,MAAM,EACN,MAAM,GACP,EAAE;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,mBAAmB,CAAA;IAC3B,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CACzB,2CA+CA"}
|