@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,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@voyant-travel/ui/components/dialog";
|
|
4
|
+
import { useProductsUiMessagesOrDefault } from "../i18n/provider.js";
|
|
5
|
+
import { ProductOptionForm } from "./product-option-form.js";
|
|
6
|
+
export function ProductOptionDialog({ open, onOpenChange, productId, option, sortOrder, onSuccess, }) {
|
|
7
|
+
const isEdit = Boolean(option);
|
|
8
|
+
const messages = useProductsUiMessagesOrDefault();
|
|
9
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { "data-slot": "product-option-dialog", className: "sm:max-w-[640px]", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: isEdit
|
|
10
|
+
? messages.productOptionDialog.titles.edit
|
|
11
|
+
: messages.productOptionDialog.titles.create }), _jsx(DialogDescription, { children: isEdit
|
|
12
|
+
? messages.productOptionDialog.descriptions.edit
|
|
13
|
+
: messages.productOptionDialog.descriptions.create })] }), _jsx(ProductOptionForm, { mode: option ? { kind: "edit", option } : { kind: "create", productId, sortOrder }, onSuccess: (saved) => {
|
|
14
|
+
onSuccess?.(saved);
|
|
15
|
+
onOpenChange(false);
|
|
16
|
+
}, onCancel: () => onOpenChange(false) })] }) }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ProductOptionRecord } from "../index.js";
|
|
2
|
+
type Mode = {
|
|
3
|
+
kind: "create";
|
|
4
|
+
productId: string;
|
|
5
|
+
sortOrder?: number;
|
|
6
|
+
} | {
|
|
7
|
+
kind: "edit";
|
|
8
|
+
option: ProductOptionRecord;
|
|
9
|
+
};
|
|
10
|
+
export interface ProductOptionFormProps {
|
|
11
|
+
mode: Mode;
|
|
12
|
+
onSuccess?: (option: ProductOptionRecord) => void;
|
|
13
|
+
onCancel?: () => void;
|
|
14
|
+
}
|
|
15
|
+
export declare function ProductOptionForm({ mode, onSuccess, onCancel }: ProductOptionFormProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=product-option-form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-option-form.d.ts","sourceRoot":"","sources":["../../src/components/product-option-form.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAEL,KAAK,mBAAmB,EAEzB,MAAM,aAAa,CAAA;AAEpB,KAAK,IAAI,GACL;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,mBAAmB,CAAA;CAAE,CAAA;AAEjD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,IAAI,CAAA;IACV,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAA;IACjD,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB;AA2DD,wBAAgB,iBAAiB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,sBAAsB,2CAwKtF"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button } from "@voyant-travel/ui/components/button";
|
|
4
|
+
import { DatePicker } from "@voyant-travel/ui/components/date-picker";
|
|
5
|
+
import { Input } from "@voyant-travel/ui/components/input";
|
|
6
|
+
import { Label } from "@voyant-travel/ui/components/label";
|
|
7
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@voyant-travel/ui/components/select";
|
|
8
|
+
import { Switch } from "@voyant-travel/ui/components/switch";
|
|
9
|
+
import { Textarea } from "@voyant-travel/ui/components/textarea";
|
|
10
|
+
import { Loader2 } from "lucide-react";
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
import { useProductsUiMessagesOrDefault } from "../i18n/provider.js";
|
|
13
|
+
import { useProductOptionMutation, } from "../index.js";
|
|
14
|
+
const OPTION_STATUSES = [{ value: "draft" }, { value: "active" }, { value: "archived" }];
|
|
15
|
+
function initialState(mode) {
|
|
16
|
+
if (mode.kind === "edit") {
|
|
17
|
+
return {
|
|
18
|
+
name: mode.option.name,
|
|
19
|
+
code: mode.option.code ?? "",
|
|
20
|
+
description: mode.option.description ?? "",
|
|
21
|
+
status: mode.option.status,
|
|
22
|
+
isDefault: mode.option.isDefault,
|
|
23
|
+
sortOrder: String(mode.option.sortOrder),
|
|
24
|
+
availableFrom: mode.option.availableFrom ?? "",
|
|
25
|
+
availableTo: mode.option.availableTo ?? "",
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
name: "",
|
|
30
|
+
code: "",
|
|
31
|
+
description: "",
|
|
32
|
+
status: "active",
|
|
33
|
+
isDefault: false,
|
|
34
|
+
sortOrder: String(mode.sortOrder ?? 0),
|
|
35
|
+
availableFrom: "",
|
|
36
|
+
availableTo: "",
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function toOptionalString(value) {
|
|
40
|
+
const trimmed = value.trim();
|
|
41
|
+
return trimmed ? trimmed : null;
|
|
42
|
+
}
|
|
43
|
+
function toPayload(state) {
|
|
44
|
+
return {
|
|
45
|
+
name: state.name.trim(),
|
|
46
|
+
code: toOptionalString(state.code),
|
|
47
|
+
description: toOptionalString(state.description),
|
|
48
|
+
status: state.status,
|
|
49
|
+
isDefault: state.isDefault,
|
|
50
|
+
sortOrder: Number.parseInt(state.sortOrder || "0", 10) || 0,
|
|
51
|
+
availableFrom: toOptionalString(state.availableFrom),
|
|
52
|
+
availableTo: toOptionalString(state.availableTo),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export function ProductOptionForm({ mode, onSuccess, onCancel }) {
|
|
56
|
+
const [state, setState] = React.useState(() => initialState(mode));
|
|
57
|
+
const [error, setError] = React.useState(null);
|
|
58
|
+
const { create, update } = useProductOptionMutation();
|
|
59
|
+
const messages = useProductsUiMessagesOrDefault();
|
|
60
|
+
React.useEffect(() => {
|
|
61
|
+
setState(initialState(mode));
|
|
62
|
+
setError(null);
|
|
63
|
+
}, [mode]);
|
|
64
|
+
const isSubmitting = create.isPending || update.isPending;
|
|
65
|
+
const field = (key) => (value) => {
|
|
66
|
+
setState((prev) => ({ ...prev, [key]: value }));
|
|
67
|
+
};
|
|
68
|
+
const handleSubmit = async (event) => {
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
setError(null);
|
|
71
|
+
if (!state.name.trim()) {
|
|
72
|
+
setError(messages.productOptionForm.validation.nameRequired);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const option = mode.kind === "create"
|
|
77
|
+
? await create.mutateAsync({ productId: mode.productId, ...toPayload(state) })
|
|
78
|
+
: await update.mutateAsync({ id: mode.option.id, input: toPayload(state) });
|
|
79
|
+
onSuccess?.(option);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
setError(err instanceof Error ? err.message : messages.productOptionForm.validation.saveFailed);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
return (_jsxs("form", { "data-slot": "product-option-form", onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [_jsxs("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "product-option-name", children: messages.productOptionForm.fields.name }), _jsx(Input, { id: "product-option-name", required: true, autoFocus: true, value: state.name, onChange: (event) => field("name")(event.target.value), placeholder: messages.productOptionForm.placeholders.name })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "product-option-code", children: messages.productOptionForm.fields.code }), _jsx(Input, { id: "product-option-code", value: state.code, onChange: (event) => field("code")(event.target.value), placeholder: messages.productOptionForm.placeholders.code })] })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "product-option-description", children: messages.productOptionForm.fields.description }), _jsx(Textarea, { id: "product-option-description", value: state.description, onChange: (event) => field("description")(event.target.value), placeholder: messages.productOptionForm.placeholders.description })] }), _jsxs("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { children: messages.productOptionForm.fields.status }), _jsxs(Select, { value: state.status, onValueChange: (value) => value && field("status")(value), items: OPTION_STATUSES.map((status) => ({
|
|
86
|
+
label: messages.common.optionStatusLabels[status.value],
|
|
87
|
+
value: status.value,
|
|
88
|
+
})), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: OPTION_STATUSES.map((status) => (_jsx(SelectItem, { value: status.value, children: messages.common.optionStatusLabels[status.value] }, status.value))) })] })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "product-option-sort-order", children: messages.productOptionForm.fields.sortOrder }), _jsx(Input, { id: "product-option-sort-order", type: "number", value: state.sortOrder, onChange: (event) => field("sortOrder")(event.target.value) })] })] }), _jsxs("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "product-option-available-from", children: messages.productOptionForm.fields.availableFrom }), _jsx(DatePicker, { value: state.availableFrom || null, onChange: (next) => field("availableFrom")(next ?? ""), placeholder: messages.productOptionForm.placeholders.availableFrom, className: "w-full" })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "product-option-available-to", children: messages.productOptionForm.fields.availableTo }), _jsx(DatePicker, { value: state.availableTo || null, onChange: (next) => field("availableTo")(next ?? ""), placeholder: messages.productOptionForm.placeholders.availableTo, className: "w-full" })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Switch, { checked: state.isDefault, onCheckedChange: (checked) => field("isDefault")(checked) }), _jsx(Label, { htmlFor: "product-option-default", children: messages.productOptionForm.fields.defaultOption })] }), error ? _jsx("p", { className: "text-sm text-destructive", children: error }) : null, _jsxs("div", { className: "flex items-center justify-end gap-2", children: [onCancel ? (_jsx(Button, { type: "button", variant: "ghost", onClick: onCancel, disabled: isSubmitting, children: messages.common.cancel })) : null, _jsxs(Button, { type: "submit", disabled: isSubmitting, children: [isSubmitting ? (_jsx(Loader2, { className: "mr-2 size-4 animate-spin", "aria-hidden": "true" })) : null, mode.kind === "create"
|
|
89
|
+
? messages.productOptionForm.actions.createOption
|
|
90
|
+
: messages.common.saveChanges] })] })] }));
|
|
91
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type OptionUnitRecord, type ProductOptionRecord } from "../index.js";
|
|
3
|
+
export declare function optionLooksLikeRoomArrangementLabel(option: Pick<ProductOptionRecord, "code" | "name">): boolean;
|
|
4
|
+
export declare function getRoomArrangementOptionNames(options: ReadonlyArray<Pick<ProductOptionRecord, "code" | "id" | "name" | "status">>, unitsByOptionId: ReadonlyMap<string, readonly Pick<OptionUnitRecord, "unitType">[]>): string[];
|
|
5
|
+
export interface ProductOptionsSectionProps {
|
|
6
|
+
productId: string;
|
|
7
|
+
pageSize?: number;
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
renderOptionDetails?: (option: ProductOptionRecord) => React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare function ProductOptionsSection({ productId, pageSize, title, description, renderOptionDetails, }: ProductOptionsSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=product-options-section.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-options-section.d.ts","sourceRoot":"","sources":["../../src/components/product-options-section.tsx"],"names":[],"mappings":"AAgCA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EAOzB,MAAM,aAAa,CAAA;AAoCpB,wBAAgB,mCAAmC,CACjD,MAAM,EAAE,IAAI,CAAC,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAAC,GACjD,OAAO,CAIT;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,mBAAmB,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,QAAQ,CAAC,CAAC,EACpF,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,EAAE,CAAC,GAClF,MAAM,EAAE,CASV;AA0CD,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,KAAK,CAAC,SAAS,CAAA;CACvE;AAED,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,QAAc,EACd,KAAK,EACL,WAAW,EACX,mBAAmB,GACpB,EAAE,0BAA0B,2CA+J5B"}
|
|
@@ -0,0 +1,200 @@
|
|
|
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 { useQueries } from "@tanstack/react-query";
|
|
5
|
+
import { Alert, AlertDescription, AlertTitle } from "@voyant-travel/ui/components/alert";
|
|
6
|
+
import { Badge } from "@voyant-travel/ui/components/badge";
|
|
7
|
+
import { Button } from "@voyant-travel/ui/components/button";
|
|
8
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@voyant-travel/ui/components/card";
|
|
9
|
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@voyant-travel/ui/components/table";
|
|
10
|
+
import { ChevronDown, ChevronRight, Copy, Loader2, Pencil, Plus, Trash2, TriangleAlert, } from "lucide-react";
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
import { useProductsUiMessagesOrDefault } from "../i18n/provider.js";
|
|
13
|
+
import { getOptionUnitsQueryOptions, useDuplicateProductOptionMutation, useOptionUnitMutation, useOptionUnits, useProductOptionMutation, useProductOptions, useVoyantProductsContext, } from "../index.js";
|
|
14
|
+
import { OptionUnitDialog } from "./option-unit-dialog.js";
|
|
15
|
+
import { useDuplicateOptionPricingMutation } from "./product-detail/commerce-client.js";
|
|
16
|
+
import { ProductOptionDialog } from "./product-option-dialog.js";
|
|
17
|
+
const optionStatusVariant = {
|
|
18
|
+
draft: "outline",
|
|
19
|
+
active: "default",
|
|
20
|
+
archived: "secondary",
|
|
21
|
+
};
|
|
22
|
+
function formatRange(min, max) {
|
|
23
|
+
if (min == null && max == null) {
|
|
24
|
+
return "—";
|
|
25
|
+
}
|
|
26
|
+
return `${min ?? 0}–${max ?? "∞"}`;
|
|
27
|
+
}
|
|
28
|
+
function formatMessage(template, replacements) {
|
|
29
|
+
return Object.entries(replacements).reduce((message, [key, value]) => message.replaceAll(`{${key}}`, String(value)), template);
|
|
30
|
+
}
|
|
31
|
+
const ROOM_ARRANGEMENT_LABEL_PATTERN = /\b(single|sgl|double|dbl|twin|triple|tpl|quad|dubla|tripla|camera)\b/i;
|
|
32
|
+
function normalizeConfigurationLabel(value) {
|
|
33
|
+
return (value ?? "")
|
|
34
|
+
.normalize("NFKD")
|
|
35
|
+
.replace(/[\u0300-\u036f]/g, "")
|
|
36
|
+
.toLowerCase();
|
|
37
|
+
}
|
|
38
|
+
export function optionLooksLikeRoomArrangementLabel(option) {
|
|
39
|
+
return [option.name, option.code].some((value) => ROOM_ARRANGEMENT_LABEL_PATTERN.test(normalizeConfigurationLabel(value)));
|
|
40
|
+
}
|
|
41
|
+
export function getRoomArrangementOptionNames(options, unitsByOptionId) {
|
|
42
|
+
return options
|
|
43
|
+
.filter((option) => option.status !== "archived")
|
|
44
|
+
.filter(optionLooksLikeRoomArrangementLabel)
|
|
45
|
+
.filter((option) => {
|
|
46
|
+
const units = unitsByOptionId.get(option.id) ?? [];
|
|
47
|
+
return units.length > 0 && units.every((unit) => unit.unitType === "room");
|
|
48
|
+
})
|
|
49
|
+
.map((option) => option.name);
|
|
50
|
+
}
|
|
51
|
+
function formatInventory(unit, messages) {
|
|
52
|
+
if (unit.unitType === "room") {
|
|
53
|
+
if (unit.maxQuantity != null && unit.maxQuantity > 0) {
|
|
54
|
+
return formatMessage(messages.unitSummaries.roomsWithCount, { count: unit.maxQuantity });
|
|
55
|
+
}
|
|
56
|
+
return messages.unitSummaries.rooms;
|
|
57
|
+
}
|
|
58
|
+
if (unit.unitType === "vehicle") {
|
|
59
|
+
if (unit.maxQuantity != null && unit.maxQuantity > 0) {
|
|
60
|
+
return formatMessage(messages.unitSummaries.vehiclesWithCount, { count: unit.maxQuantity });
|
|
61
|
+
}
|
|
62
|
+
return messages.unitSummaries.vehicles;
|
|
63
|
+
}
|
|
64
|
+
return formatMessage(messages.unitSummaries.range, {
|
|
65
|
+
range: formatRange(unit.minQuantity, unit.maxQuantity),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function formatOccupancyText(unit, messages) {
|
|
69
|
+
if (unit.occupancyMin == null && unit.occupancyMax == null) {
|
|
70
|
+
return "—";
|
|
71
|
+
}
|
|
72
|
+
if (unit.occupancyMin === unit.occupancyMax) {
|
|
73
|
+
return formatMessage(messages.unitSummaries.sleeps, { count: unit.occupancyMin ?? 0 });
|
|
74
|
+
}
|
|
75
|
+
return formatMessage(messages.unitSummaries.sleepsRange, {
|
|
76
|
+
range: `${unit.occupancyMin ?? 0}–${unit.occupancyMax ?? "∞"}`,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
export function ProductOptionsSection({ productId, pageSize = 100, title, description, renderOptionDetails, }) {
|
|
80
|
+
const messages = useProductsUiMessagesOrDefault();
|
|
81
|
+
const productsClient = useVoyantProductsContext();
|
|
82
|
+
const [expandedOptionId, setExpandedOptionId] = React.useState(null);
|
|
83
|
+
const [dialogOpen, setDialogOpen] = React.useState(false);
|
|
84
|
+
const [editingOption, setEditingOption] = React.useState(undefined);
|
|
85
|
+
const { data, isPending, isError } = useProductOptions({
|
|
86
|
+
productId,
|
|
87
|
+
limit: pageSize,
|
|
88
|
+
});
|
|
89
|
+
const { remove } = useProductOptionMutation();
|
|
90
|
+
const duplicateOption = useDuplicateProductOptionMutation();
|
|
91
|
+
const duplicatePricing = useDuplicateOptionPricingMutation();
|
|
92
|
+
const options = React.useMemo(() => (data?.data ?? []).slice().sort((a, b) => a.sortOrder - b.sortOrder), [data?.data]);
|
|
93
|
+
const optionUnitQueries = useQueries({
|
|
94
|
+
queries: options.map((option) => ({
|
|
95
|
+
...getOptionUnitsQueryOptions(productsClient, {
|
|
96
|
+
optionId: option.id,
|
|
97
|
+
limit: 100,
|
|
98
|
+
}),
|
|
99
|
+
enabled: options.length > 1,
|
|
100
|
+
})),
|
|
101
|
+
});
|
|
102
|
+
const roomArrangementOptionNames = React.useMemo(() => {
|
|
103
|
+
const unitsByOptionId = new Map();
|
|
104
|
+
options.forEach((option, index) => {
|
|
105
|
+
const units = optionUnitQueries[index]?.data?.data;
|
|
106
|
+
if (units)
|
|
107
|
+
unitsByOptionId.set(option.id, units);
|
|
108
|
+
});
|
|
109
|
+
return getRoomArrangementOptionNames(options, unitsByOptionId);
|
|
110
|
+
}, [options, optionUnitQueries]);
|
|
111
|
+
const showRoomArrangementWarning = roomArrangementOptionNames.length >= 2;
|
|
112
|
+
const nextSortOrder = options.length > 0 ? Math.max(...options.map((option) => option.sortOrder)) + 1 : 0;
|
|
113
|
+
const resolvedTitle = title ?? messages.productOptionsSection.titles.default;
|
|
114
|
+
const resolvedDescription = description ?? messages.productOptionsSection.descriptions.default;
|
|
115
|
+
// A product with a single option needs no option chrome — show its pricing
|
|
116
|
+
// table directly. Only flatten when a host injects the details (the grid);
|
|
117
|
+
// bare mounts keep the expandable units table.
|
|
118
|
+
const flattenedOption = renderOptionDetails && options.length === 1 ? options[0] : undefined;
|
|
119
|
+
const editOption = (option) => {
|
|
120
|
+
setEditingOption(option);
|
|
121
|
+
setDialogOpen(true);
|
|
122
|
+
};
|
|
123
|
+
const duplicateOptionFlow = (option) => {
|
|
124
|
+
duplicateOption.mutate({ sourceOptionId: option.id, productId }, {
|
|
125
|
+
onSuccess: async ({ option: duplicatedOption, unitIdMap }) => {
|
|
126
|
+
await duplicatePricing.mutateAsync({
|
|
127
|
+
sourceOptionId: option.id,
|
|
128
|
+
targetOptionId: duplicatedOption.id,
|
|
129
|
+
productId,
|
|
130
|
+
unitIdMap,
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
const deleteOption = (option) => {
|
|
136
|
+
if (confirm(messages.productOptionsSection.deleteConfirm.option.replace("{name}", option.name))) {
|
|
137
|
+
remove.mutate(option.id);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
return (_jsxs(Card, { "data-slot": "product-options-section", children: [_jsxs(CardHeader, { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [_jsxs("div", { className: "space-y-1", children: [_jsx(CardTitle, { children: resolvedTitle }), _jsx(CardDescription, { children: resolvedDescription })] }), _jsxs(Button, { onClick: () => {
|
|
141
|
+
setEditingOption(undefined);
|
|
142
|
+
setDialogOpen(true);
|
|
143
|
+
}, children: [_jsx(Plus, { className: "mr-2 size-4", "aria-hidden": "true" }), messages.productOptionsSection.actions.addOption] })] }), _jsxs(CardContent, { className: "flex flex-col gap-3", children: [showRoomArrangementWarning ? (_jsxs(Alert, { className: "border-amber-500/40 bg-amber-500/10", children: [_jsx(TriangleAlert, { className: "size-4 text-amber-600", "aria-hidden": "true" }), _jsx(AlertTitle, { children: messages.productOptionsSection.configurationWarnings.roomOptionsTitle }), _jsx(AlertDescription, { children: formatMessage(messages.productOptionsSection.configurationWarnings.roomOptionsDescription, { options: roomArrangementOptionNames.join(", ") }) })] })) : null, isPending ? (_jsx("div", { className: "flex min-h-24 items-center justify-center", children: _jsx(Loader2, { className: "size-4 animate-spin text-muted-foreground" }) })) : isError ? (_jsx("p", { className: "text-sm text-destructive", children: messages.productOptionsSection.loadingError.options })) : options.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: messages.productOptionsSection.empty.options })) : flattenedOption ? (
|
|
144
|
+
// A single option needs no chrome at all — show its pricing table
|
|
145
|
+
// directly. Per-option actions (duplicate/edit/delete) only appear
|
|
146
|
+
// once there are 2+ options to disambiguate.
|
|
147
|
+
renderOptionDetails?.(flattenedOption)) : (options.map((option) => (_jsx(OptionRow, { option: option, expanded: expandedOptionId === option.id, onToggle: () => setExpandedOptionId((current) => (current === option.id ? null : option.id)), onEdit: () => editOption(option), onDuplicate: () => duplicateOptionFlow(option), onDelete: () => deleteOption(option), messages: messages, children: renderOptionDetails?.(option) }, option.id)))), _jsx(ProductOptionDialog, { open: dialogOpen, onOpenChange: setDialogOpen, productId: productId, option: editingOption, sortOrder: nextSortOrder, onSuccess: () => {
|
|
148
|
+
setDialogOpen(false);
|
|
149
|
+
setEditingOption(undefined);
|
|
150
|
+
} })] })] }));
|
|
151
|
+
}
|
|
152
|
+
function OptionRow({ option, expanded, onToggle, onEdit, onDuplicate, onDelete, messages, children, }) {
|
|
153
|
+
return (_jsxs("div", { className: "rounded-md border", children: [_jsxs("div", { className: "flex items-center gap-3 p-3", children: [_jsx("button", { type: "button", onClick: onToggle, className: "text-muted-foreground transition-colors hover:text-foreground", children: expanded ? _jsx(ChevronDown, { className: "size-4" }) : _jsx(ChevronRight, { className: "size-4" }) }), _jsxs("div", { className: "flex flex-1 flex-wrap items-center gap-2", children: [_jsx("span", { className: "text-sm font-medium", children: option.name }), option.code ? (_jsx("span", { className: "font-mono text-xs text-muted-foreground", children: option.code })) : null, _jsx(Badge, { variant: optionStatusVariant[option.status] ?? "outline", children: messages.common.optionStatusLabels[option.status] }), option.isDefault ? (_jsx(Badge, { variant: "secondary", children: messages.productOptionsSection.badges.defaultOption })) : null] }), _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Button, { variant: "ghost", size: "icon-sm", onClick: onDuplicate, "aria-label": messages.productOptionsSection.actions.duplicate, children: _jsx(Copy, { className: "size-4", "aria-hidden": "true" }) }), _jsx(Button, { variant: "ghost", size: "icon-sm", onClick: onEdit, "aria-label": messages.productOptionsSection.actions.edit, children: _jsx(Pencil, { className: "size-4", "aria-hidden": "true" }) }), _jsx(Button, { variant: "ghost", size: "icon-sm", onClick: onDelete, "aria-label": messages.productOptionsSection.actions.delete, children: _jsx(Trash2, { className: "size-4", "aria-hidden": "true" }) })] })] }), expanded ? (_jsx("div", { className: "flex flex-col gap-4 border-t bg-muted/30 p-3", children: children ?? _jsx(UnitsPanel, { optionId: option.id, messages: messages }) })) : null] }));
|
|
154
|
+
}
|
|
155
|
+
function UnitsPanel({ optionId, messages, }) {
|
|
156
|
+
const [dialogOpen, setDialogOpen] = React.useState(false);
|
|
157
|
+
const [editingUnit, setEditingUnit] = React.useState(undefined);
|
|
158
|
+
const { data, isPending, isError } = useOptionUnits({ optionId, limit: 100 });
|
|
159
|
+
const { remove } = useOptionUnitMutation();
|
|
160
|
+
const units = React.useMemo(() => (data?.data ?? []).slice().sort((a, b) => a.sortOrder - b.sortOrder), [data?.data]);
|
|
161
|
+
const nextSortOrder = units.length > 0 ? Math.max(...units.map((unit) => unit.sortOrder)) + 1 : 0;
|
|
162
|
+
const isPersonOnly = units.length > 0 && units.every((unit) => unit.unitType === "person");
|
|
163
|
+
const showAge = units.some((unit) => unit.unitType === "person");
|
|
164
|
+
const hasRoomUnits = units.some((unit) => unit.unitType === "room");
|
|
165
|
+
const showOccupancy = units.some((unit) => unit.unitType === "room" || unit.occupancyMin != null || unit.occupancyMax != null);
|
|
166
|
+
const unitsTitle = isPersonOnly
|
|
167
|
+
? messages.productOptionsSection.titles.personUnits
|
|
168
|
+
: hasRoomUnits
|
|
169
|
+
? messages.productOptionsSection.titles.roomUnits
|
|
170
|
+
: messages.productOptionsSection.titles.units;
|
|
171
|
+
const unitsDescription = isPersonOnly
|
|
172
|
+
? messages.productOptionsSection.descriptions.personUnits
|
|
173
|
+
: hasRoomUnits
|
|
174
|
+
? messages.productOptionsSection.descriptions.roomUnits
|
|
175
|
+
: messages.productOptionsSection.descriptions.units;
|
|
176
|
+
const addUnitLabel = isPersonOnly
|
|
177
|
+
? messages.productOptionsSection.actions.addPersonUnit
|
|
178
|
+
: hasRoomUnits
|
|
179
|
+
? messages.productOptionsSection.actions.addRoomUnit
|
|
180
|
+
: messages.productOptionsSection.actions.addUnit;
|
|
181
|
+
const quantityColumnLabel = isPersonOnly
|
|
182
|
+
? messages.productOptionsSection.columns.personQuantity
|
|
183
|
+
: hasRoomUnits
|
|
184
|
+
? messages.productOptionsSection.columns.roomQuantity
|
|
185
|
+
: messages.productOptionsSection.columns.quantity;
|
|
186
|
+
return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { children: [_jsx("p", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: unitsTitle }), _jsx("p", { className: "text-xs text-muted-foreground", children: unitsDescription })] }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => {
|
|
187
|
+
setEditingUnit(undefined);
|
|
188
|
+
setDialogOpen(true);
|
|
189
|
+
}, children: [_jsx(Plus, { className: "mr-2 size-3.5", "aria-hidden": "true" }), addUnitLabel] })] }), isPending ? (_jsx("div", { className: "flex min-h-20 items-center justify-center rounded-md border bg-background", children: _jsx(Loader2, { className: "size-4 animate-spin text-muted-foreground" }) })) : isError ? (_jsx("p", { className: "text-sm text-destructive", children: messages.productOptionsSection.loadingError.units })) : units.length === 0 ? (_jsx("p", { className: "rounded-md border bg-background px-3 py-4 text-sm text-muted-foreground", children: messages.productOptionsSection.empty.units })) : (_jsx("div", { className: "rounded-md border bg-background", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: messages.productOptionsSection.columns.unitType }), _jsx(TableHead, { children: messages.productOptionsSection.columns.unitName }), _jsx(TableHead, { children: quantityColumnLabel }), showAge ? (_jsx(TableHead, { children: messages.productOptionsSection.columns.age })) : null, showOccupancy ? (_jsx(TableHead, { children: messages.productOptionsSection.columns.occupancy })) : null, _jsx(TableHead, { className: "w-[88px] text-right", children: messages.productOptionsSection.columns.actions })] }) }), _jsx(TableBody, { children: units.map((unit) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: _jsx(Badge, { variant: "outline", children: messages.common.optionUnitTypeLabels[unit.unitType] }) }), _jsxs(TableCell, { children: [_jsx("div", { className: "font-medium", children: unit.name }), unit.code ? (_jsx("div", { className: "font-mono text-xs text-muted-foreground", children: unit.code })) : null] }), _jsx(TableCell, { children: _jsx("div", { className: "text-xs", children: formatInventory(unit, messages.productOptionsSection) }) }), showAge ? (_jsx(TableCell, { className: "font-mono text-xs", children: formatRange(unit.minAge, unit.maxAge) })) : null, showOccupancy ? (_jsx(TableCell, { children: _jsx("div", { className: "text-xs", children: formatOccupancyText(unit, messages.productOptionsSection) }) })) : null, _jsx(TableCell, { className: "text-right", children: _jsxs("div", { className: "flex items-center justify-end gap-1", children: [_jsx(Button, { variant: "ghost", size: "icon-sm", onClick: () => {
|
|
190
|
+
setEditingUnit(unit);
|
|
191
|
+
setDialogOpen(true);
|
|
192
|
+
}, "aria-label": messages.productOptionsSection.actions.edit, children: _jsx(Pencil, { className: "size-4", "aria-hidden": "true" }) }), _jsx(Button, { variant: "ghost", size: "icon-sm", onClick: () => {
|
|
193
|
+
if (confirm(messages.productOptionsSection.deleteConfirm.unit.replace("{name}", unit.name))) {
|
|
194
|
+
remove.mutate(unit.id);
|
|
195
|
+
}
|
|
196
|
+
}, "aria-label": messages.productOptionsSection.actions.delete, children: _jsx(Trash2, { className: "size-4", "aria-hidden": "true" }) })] }) })] }, unit.id))) })] }) })), _jsx(OptionUnitDialog, { open: dialogOpen, onOpenChange: setDialogOpen, optionId: optionId, unit: editingUnit, sortOrder: nextSortOrder, onSuccess: () => {
|
|
197
|
+
setDialogOpen(false);
|
|
198
|
+
setEditingUnit(undefined);
|
|
199
|
+
} })] }));
|
|
200
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ProductRecord } from "../index.js";
|
|
2
|
+
export interface ProductQuickViewSheetProps {
|
|
3
|
+
productId: string | null | undefined;
|
|
4
|
+
open: boolean;
|
|
5
|
+
onOpenChange: (open: boolean) => void;
|
|
6
|
+
/**
|
|
7
|
+
* Wired to the "View full product" footer button. Receives the product
|
|
8
|
+
* so the host can route to its detail page. When omitted, the footer
|
|
9
|
+
* action is suppressed.
|
|
10
|
+
*/
|
|
11
|
+
onViewFull?: (product: ProductRecord) => void;
|
|
12
|
+
/** Optional locale override; defaults to the active i18n locale. */
|
|
13
|
+
locale?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Right-side sheet that previews the core info for a product without
|
|
17
|
+
* navigating away. Mirrors `BookingQuickViewSheet` shape (header with
|
|
18
|
+
* status badge + total, sectioned body, "View full" footer) so the
|
|
19
|
+
* pair feels native on the slot detail / allocation views where both
|
|
20
|
+
* sheets coexist.
|
|
21
|
+
*/
|
|
22
|
+
export declare function ProductQuickViewSheet({ productId, open, onOpenChange, onViewFull, locale, }: ProductQuickViewSheetProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
//# sourceMappingURL=product-quick-view-sheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-quick-view-sheet.d.ts","sourceRoot":"","sources":["../../src/components/product-quick-view-sheet.tsx"],"names":[],"mappings":"AAeA,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,aAAa,CAAA;AAEpB,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACpC,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAA;IAC7C,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,MAAM,GACP,EAAE,0BAA0B,2CA0D5B"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { Badge, Button, Sheet, SheetBody, SheetContent, SheetFooter, SheetHeader, SheetTitle, } from "@voyant-travel/ui/components";
|
|
4
|
+
import { ArrowRight, Calendar, ImageIcon, Layers, MapPin, Route, Tag } from "lucide-react";
|
|
5
|
+
import { useProductsUiI18nOrDefault, useProductsUiMessagesOrDefault } from "../i18n/provider.js";
|
|
6
|
+
import { useProduct, useProductDays, useProductMedia, useProductOptions, } from "../index.js";
|
|
7
|
+
/**
|
|
8
|
+
* Right-side sheet that previews the core info for a product without
|
|
9
|
+
* navigating away. Mirrors `BookingQuickViewSheet` shape (header with
|
|
10
|
+
* status badge + total, sectioned body, "View full" footer) so the
|
|
11
|
+
* pair feels native on the slot detail / allocation views where both
|
|
12
|
+
* sheets coexist.
|
|
13
|
+
*/
|
|
14
|
+
export function ProductQuickViewSheet({ productId, open, onOpenChange, onViewFull, locale, }) {
|
|
15
|
+
const i18n = useProductsUiI18nOrDefault();
|
|
16
|
+
const messages = useProductsUiMessagesOrDefault();
|
|
17
|
+
const detail = messages.productDetailPage;
|
|
18
|
+
const resolvedLocale = locale ?? i18n.locale;
|
|
19
|
+
const query = useProduct(productId ?? undefined, {
|
|
20
|
+
enabled: open && Boolean(productId),
|
|
21
|
+
});
|
|
22
|
+
const product = query.data ?? null;
|
|
23
|
+
const isLoading = Boolean(productId) && query.fetchStatus === "fetching" && !product;
|
|
24
|
+
return (_jsx(Sheet, { open: open, onOpenChange: onOpenChange, children: _jsxs(SheetContent, { side: "right", className: "sm:max-w-md", children: [_jsx(SheetHeader, { className: "border-b", children: product ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-start justify-between gap-3", children: [_jsx(SheetTitle, { className: "text-base font-semibold", children: product.name }), _jsx(Badge, { variant: "outline", className: "shrink-0 capitalize", children: messages.common.productStatusLabels[product.status] ?? product.status })] }), _jsx("div", { className: "text-2xl font-semibold tabular-nums", children: formatAmount(product.sellAmountCents, product.sellCurrency, resolvedLocale, detail.states.noDescription) })] })) : (_jsx(SheetTitle, { children: detail.states.loading })) }), _jsx(SheetBody, { className: "flex flex-col gap-5", children: isLoading ? (_jsx("p", { className: "text-sm text-muted-foreground", children: messages.common.loading })) : !product ? (_jsx("p", { className: "text-sm text-muted-foreground", children: detail.states.notFoundDescription })) : (_jsx(QuickViewBody, { product: product, locale: resolvedLocale })) }), onViewFull && product ? (_jsx(SheetFooter, { children: _jsxs(Button, { type: "button", className: "w-full", onClick: () => onViewFull(product), children: ["View full product", _jsx(ArrowRight, { className: "ml-1 h-4 w-4", "aria-hidden": "true" })] }) })) : null] }) }));
|
|
25
|
+
}
|
|
26
|
+
function QuickViewBody({ product, locale }) {
|
|
27
|
+
const messages = useProductsUiMessagesOrDefault();
|
|
28
|
+
const detail = messages.productDetailPage;
|
|
29
|
+
const mediaQuery = useProductMedia(product.id, { limit: 1 });
|
|
30
|
+
const cover = (mediaQuery.data?.data ?? []).find((m) => m.isCover) ?? mediaQuery.data?.data?.[0] ?? null;
|
|
31
|
+
const daysQuery = useProductDays(product.id);
|
|
32
|
+
const days = (daysQuery.data?.data ?? []).slice().sort((a, b) => a.dayNumber - b.dayNumber);
|
|
33
|
+
const optionsQuery = useProductOptions({ productId: product.id, limit: 25 });
|
|
34
|
+
const options = (optionsQuery.data?.data ?? []).slice().sort((a, b) => a.sortOrder - b.sortOrder);
|
|
35
|
+
const dateRange = product.startDate
|
|
36
|
+
? product.endDate && product.endDate !== product.startDate
|
|
37
|
+
? `${formatDate(product.startDate, locale, detail.states.noDescription)} - ${formatDate(product.endDate, locale, detail.states.noDescription)}`
|
|
38
|
+
: formatDate(product.startDate, locale, detail.states.noDescription)
|
|
39
|
+
: null;
|
|
40
|
+
return (_jsxs("div", { className: "flex flex-col gap-5", children: [cover ? (_jsx("div", { className: "overflow-hidden rounded-md border bg-muted", children: _jsx("img", { src: cover.url, alt: product.name, className: "aspect-video w-full object-cover" }) })) : (_jsx("div", { className: "flex aspect-video w-full items-center justify-center rounded-md border bg-muted text-muted-foreground", children: _jsx(ImageIcon, { className: "size-6", "aria-hidden": "true" }) })), _jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [_jsx(Badge, { variant: "outline", className: "capitalize", children: messages.common.productBookingModeLabels[product.bookingMode] ?? product.bookingMode }), _jsx(Badge, { variant: "outline", className: "capitalize", children: messages.common.productCapacityModeLabels[product.capacityMode] ?? product.capacityMode })] }), product.description ? (_jsx("p", { className: "whitespace-pre-wrap text-sm text-muted-foreground", children: product.description })) : null, _jsx("div", { className: "flex flex-col gap-1.5", children: dateRange ? (_jsxs("div", { className: "flex items-center gap-2 text-sm", children: [_jsx(Calendar, { className: "h-4 w-4 text-muted-foreground", "aria-hidden": "true" }), _jsx("span", { children: dateRange })] })) : null }), options.length > 0 ? (_jsx(Section, { icon: _jsx(Layers, { className: "h-3.5 w-3.5" }),
|
|
41
|
+
/* i18n-literal-ok scoped section heading */
|
|
42
|
+
label: "Options", count: String(options.length), children: _jsx("ul", { className: "flex flex-col gap-2", children: options.map((option) => (_jsxs("li", { className: "flex items-start justify-between gap-3 border-l-2 border-border pl-3", children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-0.5", children: [_jsx("span", { className: "truncate text-sm font-medium", children: option.name }), option.description ? (_jsx("span", { className: "line-clamp-2 text-xs text-muted-foreground", children: option.description })) : null] }), _jsxs("div", { className: "flex shrink-0 items-center gap-1.5", children: [option.isDefault ? (_jsx(Badge, { variant: "outline", className: "text-[10px] uppercase", children: "Default" })) : null, _jsx(Badge, { variant: "outline", className: "text-[10px] uppercase", children: messages.common.optionStatusLabels[option.status] ?? option.status })] })] }, option.id))) }) })) : null, days.length > 0 ? (_jsx(Section, { icon: _jsx(Route, { className: "h-3.5 w-3.5" }), label: detail.sections.itinerary.title, count: String(days.length), children: _jsx("ol", { className: "flex flex-col gap-3", children: days.map((day) => (_jsxs("li", { className: "flex flex-col gap-1 border-l-2 border-border pl-3", children: [_jsxs("div", { className: "flex items-baseline gap-2 text-sm font-medium", children: [_jsx("span", { className: "text-muted-foreground", children: `Day ${day.dayNumber}` }), day.title ? _jsx("span", { className: "truncate", children: day.title }) : null] }), day.location ? (_jsxs("div", { className: "flex items-center gap-1.5 text-xs text-muted-foreground", children: [_jsx(MapPin, { className: "h-3 w-3 shrink-0", "aria-hidden": "true" }), _jsx("span", { className: "truncate", children: day.location })] })) : null, day.description ? (_jsx("p", { className: "whitespace-pre-wrap text-xs text-muted-foreground", children: day.description })) : null] }, day.id))) }) })) : null, product.tags.length > 0 ? (_jsx(Section, { icon: _jsx(Tag, { className: "h-3.5 w-3.5" }), label: detail.fields.tags, children: _jsx("div", { className: "flex flex-wrap items-center gap-1.5", children: product.tags.map((tag) => (_jsx(Badge, { variant: "outline", children: tag }, tag))) }) })) : null] }));
|
|
43
|
+
}
|
|
44
|
+
function Section({ icon, label, count, children, }) {
|
|
45
|
+
return (_jsxs("section", { className: "flex flex-col gap-2 border-t pt-4", children: [_jsxs("header", { className: "flex items-center justify-between gap-2 text-xs font-medium uppercase tracking-wide text-muted-foreground", children: [_jsxs("span", { className: "flex items-center gap-1.5", children: [icon, label] }), count ? _jsx("span", { className: "font-mono normal-case", children: count }) : null] }), children] }));
|
|
46
|
+
}
|
|
47
|
+
function formatAmount(cents, currency, locale, empty) {
|
|
48
|
+
if (cents == null)
|
|
49
|
+
return empty;
|
|
50
|
+
return new Intl.NumberFormat(locale, {
|
|
51
|
+
style: "currency",
|
|
52
|
+
currency,
|
|
53
|
+
minimumFractionDigits: 2,
|
|
54
|
+
maximumFractionDigits: 2,
|
|
55
|
+
}).format(cents / 100);
|
|
56
|
+
}
|
|
57
|
+
function formatDate(iso, locale, empty) {
|
|
58
|
+
if (!iso)
|
|
59
|
+
return empty;
|
|
60
|
+
return new Date(iso).toLocaleDateString(locale, {
|
|
61
|
+
month: "short",
|
|
62
|
+
day: "numeric",
|
|
63
|
+
year: "numeric",
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ProductTagRecord } from "../index.js";
|
|
2
|
+
export interface ProductTagDialogProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onOpenChange: (open: boolean) => void;
|
|
5
|
+
tag?: ProductTagRecord;
|
|
6
|
+
onSuccess?: (tag: ProductTagRecord) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function ProductTagDialog({ open, onOpenChange, tag, onSuccess }: ProductTagDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=product-tag-dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-tag-dialog.d.ts","sourceRoot":"","sources":["../../src/components/product-tag-dialog.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAGnD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,GAAG,CAAC,EAAE,gBAAgB,CAAA;IACtB,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,IAAI,CAAA;CAC5C;AAED,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,qBAAqB,2CA8B7F"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@voyant-travel/ui/components/dialog";
|
|
4
|
+
import { useProductsUiMessagesOrDefault } from "../i18n/provider.js";
|
|
5
|
+
import { ProductTagForm } from "./product-tag-form.js";
|
|
6
|
+
export function ProductTagDialog({ open, onOpenChange, tag, onSuccess }) {
|
|
7
|
+
const isEdit = Boolean(tag);
|
|
8
|
+
const messages = useProductsUiMessagesOrDefault();
|
|
9
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { "data-slot": "product-tag-dialog", className: "sm:max-w-[480px]", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: isEdit
|
|
10
|
+
? messages.productTagDialog.titles.edit
|
|
11
|
+
: messages.productTagDialog.titles.create }), _jsx(DialogDescription, { children: isEdit
|
|
12
|
+
? messages.productTagDialog.descriptions.edit
|
|
13
|
+
: messages.productTagDialog.descriptions.create })] }), _jsx(ProductTagForm, { mode: tag ? { kind: "edit", tag } : { kind: "create" }, onSuccess: (saved) => {
|
|
14
|
+
onSuccess?.(saved);
|
|
15
|
+
onOpenChange(false);
|
|
16
|
+
}, onCancel: () => onOpenChange(false) })] }) }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ProductTagRecord } from "../index.js";
|
|
2
|
+
type Mode = {
|
|
3
|
+
kind: "create";
|
|
4
|
+
} | {
|
|
5
|
+
kind: "edit";
|
|
6
|
+
tag: ProductTagRecord;
|
|
7
|
+
};
|
|
8
|
+
export interface ProductTagFormProps {
|
|
9
|
+
mode: Mode;
|
|
10
|
+
onSuccess?: (tag: ProductTagRecord) => void;
|
|
11
|
+
onCancel?: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function ProductTagForm({ mode, onSuccess, onCancel }: ProductTagFormProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=product-tag-form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-tag-form.d.ts","sourceRoot":"","sources":["../../src/components/product-tag-form.tsx"],"names":[],"mappings":"AAQA,OAAO,EAEL,KAAK,gBAAgB,EAEtB,MAAM,aAAa,CAAA;AAEpB,KAAK,IAAI,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,gBAAgB,CAAA;CAAE,CAAA;AAExE,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,IAAI,CAAA;IACV,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,IAAI,CAAA;IAC3C,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB;AAYD,wBAAgB,cAAc,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,mBAAmB,2CAkEhF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button } from "@voyant-travel/ui/components/button";
|
|
4
|
+
import { Input } from "@voyant-travel/ui/components/input";
|
|
5
|
+
import { Label } from "@voyant-travel/ui/components/label";
|
|
6
|
+
import { Loader2 } from "lucide-react";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { useProductsUiMessagesOrDefault } from "../i18n/provider.js";
|
|
9
|
+
import { useProductTagMutation, } from "../index.js";
|
|
10
|
+
function initialState(mode) {
|
|
11
|
+
return {
|
|
12
|
+
name: mode.kind === "edit" ? mode.tag.name : "",
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function toPayload(state) {
|
|
16
|
+
return { name: state.name.trim() };
|
|
17
|
+
}
|
|
18
|
+
export function ProductTagForm({ mode, onSuccess, onCancel }) {
|
|
19
|
+
const [state, setState] = React.useState(() => initialState(mode));
|
|
20
|
+
const [error, setError] = React.useState(null);
|
|
21
|
+
const { create, update } = useProductTagMutation();
|
|
22
|
+
const messages = useProductsUiMessagesOrDefault();
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
setState(initialState(mode));
|
|
25
|
+
setError(null);
|
|
26
|
+
}, [mode]);
|
|
27
|
+
const isSubmitting = create.isPending || update.isPending;
|
|
28
|
+
const handleSubmit = async (event) => {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
setError(null);
|
|
31
|
+
if (!state.name.trim()) {
|
|
32
|
+
setError(messages.productTagForm.validation.nameRequired);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const tag = mode.kind === "create"
|
|
37
|
+
? await create.mutateAsync(toPayload(state))
|
|
38
|
+
: await update.mutateAsync({ id: mode.tag.id, input: toPayload(state) });
|
|
39
|
+
onSuccess?.(tag);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
setError(err instanceof Error ? err.message : messages.productTagForm.validation.saveFailed);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return (_jsxs("form", { "data-slot": "product-tag-form", onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "product-tag-name", children: messages.productTagForm.fields.name }), _jsx(Input, { id: "product-tag-name", required: true, autoFocus: true, value: state.name, onChange: (event) => setState({ name: event.target.value }), placeholder: messages.productTagForm.placeholders.name })] }), error ? _jsx("p", { className: "text-sm text-destructive", children: error }) : null, _jsxs("div", { className: "flex items-center justify-end gap-2", children: [onCancel ? (_jsx(Button, { type: "button", variant: "ghost", onClick: onCancel, children: messages.common.cancel })) : null, _jsxs(Button, { type: "submit", disabled: isSubmitting, children: [isSubmitting ? (_jsx(Loader2, { className: "mr-2 size-4 animate-spin", "aria-hidden": "true" })) : null, mode.kind === "edit"
|
|
46
|
+
? messages.common.saveChanges
|
|
47
|
+
: messages.productTagForm.actions.createTag] })] })] }));
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-tag-list.d.ts","sourceRoot":"","sources":["../../src/components/product-tag-list.tsx"],"names":[],"mappings":"AAyBA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,wBAAgB,cAAc,CAAC,EAAE,QAAc,EAAE,GAAE,mBAAwB,2CAkJ1E"}
|