@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,44 @@
|
|
|
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 { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@voyant-travel/ui/components/dropdown-menu";
|
|
5
|
+
import { Input } from "@voyant-travel/ui/components/input";
|
|
6
|
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@voyant-travel/ui/components/table";
|
|
7
|
+
import { Loader2, MoreHorizontal, Pencil, Plus, Search, Trash2 } from "lucide-react";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { useProductsUiMessagesOrDefault } from "../i18n/provider.js";
|
|
10
|
+
import { useProductTagMutation, useProductTags } from "../index.js";
|
|
11
|
+
import { ProductTagDialog } from "./product-tag-dialog.js";
|
|
12
|
+
export function ProductTagList({ pageSize = 200 } = {}) {
|
|
13
|
+
const [search, setSearch] = React.useState("");
|
|
14
|
+
const [offset, setOffset] = React.useState(0);
|
|
15
|
+
const [dialogOpen, setDialogOpen] = React.useState(false);
|
|
16
|
+
const [editing, setEditing] = React.useState(undefined);
|
|
17
|
+
const { data, isPending, isError } = useProductTags({
|
|
18
|
+
search: search || undefined,
|
|
19
|
+
limit: pageSize,
|
|
20
|
+
offset,
|
|
21
|
+
});
|
|
22
|
+
const { remove } = useProductTagMutation();
|
|
23
|
+
const messages = useProductsUiMessagesOrDefault();
|
|
24
|
+
const tags = data?.data ?? [];
|
|
25
|
+
const total = data?.total ?? 0;
|
|
26
|
+
const page = Math.floor(offset / pageSize) + 1;
|
|
27
|
+
const pageCount = Math.max(1, Math.ceil(total / pageSize));
|
|
28
|
+
return (_jsxs("div", { "data-slot": "product-tag-list", className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("div", { className: "relative w-full max-w-sm", children: [_jsx(Search, { className: "absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" }), _jsx(Input, { placeholder: messages.productTagList.searchPlaceholder, value: search, onChange: (event) => {
|
|
29
|
+
setSearch(event.target.value);
|
|
30
|
+
setOffset(0);
|
|
31
|
+
}, className: "pl-9" })] }), _jsxs(Button, { onClick: () => {
|
|
32
|
+
setEditing(undefined);
|
|
33
|
+
setDialogOpen(true);
|
|
34
|
+
}, children: [_jsx(Plus, { className: "mr-2 size-4", "aria-hidden": "true" }), messages.productTagList.addTag] })] }), _jsx("div", { className: "rounded-md border", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: messages.productTagList.columns.name }), _jsx(TableHead, { className: "w-[80px] text-right", children: messages.productTagList.columns.actions })] }) }), _jsx(TableBody, { children: isPending ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 2, className: "h-24 text-center", children: _jsx(Loader2, { className: "mx-auto size-4 animate-spin text-muted-foreground" }) }) })) : isError ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 2, className: "h-24 text-center text-sm text-destructive", children: messages.productTagList.loadingError }) })) : tags.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 2, className: "h-24 text-center text-sm text-muted-foreground", children: messages.productTagList.empty }) })) : (tags.map((tag) => (_jsxs(TableRow, { children: [_jsx(TableCell, { className: "font-medium", children: tag.name }), _jsx(TableCell, { className: "text-right", children: _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { className: "inline-flex size-8 items-center justify-center rounded-md text-muted-foreground outline-hidden hover:bg-accent hover:text-accent-foreground", children: _jsx(MoreHorizontal, { className: "size-4" }) }), _jsxs(DropdownMenuContent, { align: "end", children: [_jsxs(DropdownMenuItem, { onClick: () => {
|
|
35
|
+
setEditing(tag);
|
|
36
|
+
setDialogOpen(true);
|
|
37
|
+
}, children: [_jsx(Pencil, { className: "size-4" }), messages.productTagList.edit] }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { variant: "destructive", onClick: () => {
|
|
38
|
+
if (confirm(messages.productTagList.deleteConfirm)) {
|
|
39
|
+
remove.mutate(tag.id);
|
|
40
|
+
}
|
|
41
|
+
}, children: [_jsx(Trash2, { className: "size-4" }), messages.productTagList.delete] })] })] }) })] }, tag.id)))) })] }) }), _jsxs("div", { className: "flex items-center justify-between text-sm text-muted-foreground", children: [_jsx("span", { children: messages.productTagList.showingSummary
|
|
42
|
+
.replace("{count}", String(tags.length))
|
|
43
|
+
.replace("{total}", String(total)) }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Button, { variant: "outline", size: "sm", disabled: offset === 0, onClick: () => setOffset((prev) => Math.max(0, prev - pageSize)), children: messages.common.previous }), _jsxs("span", { children: [messages.common.page, " ", page, " / ", pageCount] }), _jsx(Button, { variant: "outline", size: "sm", disabled: offset + pageSize >= total, onClick: () => setOffset((prev) => prev + pageSize), children: messages.common.next })] })] }), _jsx(ProductTagDialog, { open: dialogOpen, onOpenChange: setDialogOpen, tag: editing })] }));
|
|
44
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ProductTagListProps } from "./product-tag-list.js";
|
|
2
|
+
export interface ProductTagsPageProps {
|
|
3
|
+
pageSize?: ProductTagListProps["pageSize"];
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function ProductTagsPage({ pageSize, className }?: ProductTagsPageProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=product-tags-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-tags-page.d.ts","sourceRoot":"","sources":["../../src/components/product-tags-page.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAEhF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAA;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAE,oBAAyB,2CAajF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "@voyant-travel/ui/lib/utils";
|
|
4
|
+
import { useProductsUiMessagesOrDefault } from "../i18n/index.js";
|
|
5
|
+
import { ProductTagList } from "./product-tag-list.js";
|
|
6
|
+
export function ProductTagsPage({ pageSize, className } = {}) {
|
|
7
|
+
const messages = useProductsUiMessagesOrDefault().productTagsPage;
|
|
8
|
+
return (_jsxs("div", { "data-slot": "product-tags-page", className: cn("flex flex-col gap-6 p-6", className), children: [_jsxs("div", { children: [_jsx("h2", { className: "text-lg font-semibold tracking-tight", children: messages.title }), _jsx("p", { className: "text-sm text-muted-foreground", children: messages.description })] }), _jsx(ProductTagList, { pageSize: pageSize })] }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
value: string | null | undefined;
|
|
3
|
+
onChange: (value: string | null) => void;
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function ProductTaxClassCombobox({ value, onChange, placeholder, disabled }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=product-tax-class-combobox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-tax-class-combobox.d.ts","sourceRoot":"","sources":["../../src/components/product-tax-class-combobox.tsx"],"names":[],"mappings":"AAiBA,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AA4DD,wBAAgB,uBAAuB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,KAAK,2CAiFxF"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useQuery } from "@tanstack/react-query";
|
|
4
|
+
import { Combobox, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList, } from "@voyant-travel/ui/components/combobox";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { useProductsUiMessagesOrDefault } from "../i18n/provider.js";
|
|
8
|
+
import { fetchWithValidation, useVoyantProductsContext } from "../index.js";
|
|
9
|
+
const PAGE_SIZE = 100;
|
|
10
|
+
const taxClassRecordSchema = z
|
|
11
|
+
.object({
|
|
12
|
+
id: z.string(),
|
|
13
|
+
code: z.string(),
|
|
14
|
+
label: z.string(),
|
|
15
|
+
description: z.string().nullable().optional(),
|
|
16
|
+
active: z.boolean(),
|
|
17
|
+
})
|
|
18
|
+
.passthrough();
|
|
19
|
+
const taxClassListResponse = z.object({
|
|
20
|
+
data: z.array(taxClassRecordSchema),
|
|
21
|
+
total: z.number().int(),
|
|
22
|
+
limit: z.number().int(),
|
|
23
|
+
offset: z.number().int(),
|
|
24
|
+
});
|
|
25
|
+
const taxClassSingleResponse = z.object({ data: taxClassRecordSchema });
|
|
26
|
+
function useTaxClassOptions() {
|
|
27
|
+
const { baseUrl, fetcher } = useVoyantProductsContext();
|
|
28
|
+
return useQuery({
|
|
29
|
+
queryKey: ["voyant", "products-ui", "tax-class-combobox", "list"],
|
|
30
|
+
queryFn: () => {
|
|
31
|
+
const params = new URLSearchParams();
|
|
32
|
+
params.set("limit", String(PAGE_SIZE));
|
|
33
|
+
params.set("active", "true");
|
|
34
|
+
return fetchWithValidation(`/v1/finance/tax-classes?${params}`, taxClassListResponse, {
|
|
35
|
+
baseUrl,
|
|
36
|
+
fetcher,
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function useSelectedTaxClass(id) {
|
|
42
|
+
const { baseUrl, fetcher } = useVoyantProductsContext();
|
|
43
|
+
return useQuery({
|
|
44
|
+
queryKey: ["voyant", "products-ui", "tax-class-combobox", "detail", id],
|
|
45
|
+
queryFn: async () => {
|
|
46
|
+
if (!id)
|
|
47
|
+
throw new Error("useSelectedTaxClass requires an id");
|
|
48
|
+
const { data } = await fetchWithValidation(`/v1/finance/tax-classes/${id}`, taxClassSingleResponse, { baseUrl, fetcher });
|
|
49
|
+
return data;
|
|
50
|
+
},
|
|
51
|
+
enabled: Boolean(id),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export function ProductTaxClassCombobox({ value, onChange, placeholder, disabled }) {
|
|
55
|
+
const messages = useProductsUiMessagesOrDefault();
|
|
56
|
+
const [search, setSearch] = React.useState("");
|
|
57
|
+
const listQuery = useTaxClassOptions();
|
|
58
|
+
const selectedQuery = useSelectedTaxClass(value);
|
|
59
|
+
const items = React.useMemo(() => {
|
|
60
|
+
const map = new Map();
|
|
61
|
+
for (const item of listQuery.data?.data ?? [])
|
|
62
|
+
map.set(item.id, item);
|
|
63
|
+
if (selectedQuery.data)
|
|
64
|
+
map.set(selectedQuery.data.id, selectedQuery.data);
|
|
65
|
+
const normalizedSearch = search.trim().toLowerCase();
|
|
66
|
+
const values = Array.from(map.values());
|
|
67
|
+
if (!normalizedSearch)
|
|
68
|
+
return values;
|
|
69
|
+
return values.filter((item) => item.label.toLowerCase().includes(normalizedSearch) ||
|
|
70
|
+
item.code.toLowerCase().includes(normalizedSearch));
|
|
71
|
+
}, [listQuery.data?.data, search, selectedQuery.data]);
|
|
72
|
+
const itemMap = React.useMemo(() => new Map(items.map((item) => [item.id, item])), [items]);
|
|
73
|
+
const selected = value ? itemMap.get(value) : selectedQuery.data;
|
|
74
|
+
const selectedLabel = selected ? `${selected.label} · ${selected.code}` : "";
|
|
75
|
+
const [inputValue, setInputValue] = React.useState(selectedLabel);
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
setInputValue(selectedLabel);
|
|
78
|
+
}, [selectedLabel]);
|
|
79
|
+
return (_jsxs(Combobox, { items: items.map((item) => item.id), value: value ?? null, inputValue: inputValue, autoHighlight: true, disabled: disabled, itemToStringValue: (id) => {
|
|
80
|
+
const item = itemMap.get(id);
|
|
81
|
+
return item ? `${item.label} · ${item.code}` : "";
|
|
82
|
+
}, onInputValueChange: (next) => {
|
|
83
|
+
setInputValue(next);
|
|
84
|
+
setSearch(next);
|
|
85
|
+
if (!next)
|
|
86
|
+
onChange(null);
|
|
87
|
+
}, onValueChange: (next) => {
|
|
88
|
+
const id = next ?? null;
|
|
89
|
+
onChange(id);
|
|
90
|
+
const item = id ? itemMap.get(id) : null;
|
|
91
|
+
setInputValue(item ? `${item.label} · ${item.code}` : "");
|
|
92
|
+
}, children: [_jsx(ComboboxInput, { placeholder: placeholder ?? messages.comboboxes.taxClass.placeholder, showClear: !!value }), _jsxs(ComboboxContent, { children: [_jsx(ComboboxEmpty, { children: listQuery.isPending || selectedQuery.isPending
|
|
93
|
+
? messages.common.loading
|
|
94
|
+
: messages.comboboxes.taxClass.empty }), _jsx(ComboboxList, { children: _jsx(ComboboxCollection, { children: (id) => {
|
|
95
|
+
const item = itemMap.get(id);
|
|
96
|
+
if (!item)
|
|
97
|
+
return null;
|
|
98
|
+
return (_jsx(ComboboxItem, { value: item.id, children: _jsxs("div", { className: "flex min-w-0 flex-col", children: [_jsx("span", { className: "truncate font-medium", children: item.label }), _jsx("span", { className: "truncate text-xs text-muted-foreground", children: item.code })] }) }, item.id));
|
|
99
|
+
} }) })] })] }));
|
|
100
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ProductRecord } from "../index.js";
|
|
2
|
+
export interface ProductTranslationsCardProps {
|
|
3
|
+
product: ProductRecord;
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function ProductTranslationsCard({ product, className }: ProductTranslationsCardProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=product-translations-card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-translations-card.d.ts","sourceRoot":"","sources":["../../src/components/product-translations-card.tsx"],"names":[],"mappings":"AAyBA,OAAO,EAEL,KAAK,aAAa,EAKnB,MAAM,aAAa,CAAA;AAEpB,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,aAAa,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AA8ED,wBAAgB,uBAAuB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,4BAA4B,2CA4W3F"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Badge } from "@voyant-travel/ui/components/badge";
|
|
4
|
+
import { Button } from "@voyant-travel/ui/components/button";
|
|
5
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@voyant-travel/ui/components/card";
|
|
6
|
+
import { Input } from "@voyant-travel/ui/components/input";
|
|
7
|
+
import { Label } from "@voyant-travel/ui/components/label";
|
|
8
|
+
import { RichTextEditor } from "@voyant-travel/ui/components/rich-text-editor";
|
|
9
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@voyant-travel/ui/components/select";
|
|
10
|
+
import { Textarea } from "@voyant-travel/ui/components/textarea";
|
|
11
|
+
import { Copy, Languages, Loader2, Plus, Save, Trash2 } from "lucide-react";
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import { useProductsUiMessagesOrDefault } from "../i18n/provider.js";
|
|
14
|
+
import { useProductTranslationMutation, useProductTranslations, } from "../index.js";
|
|
15
|
+
function emptyTranslationState(languageTag = "") {
|
|
16
|
+
return {
|
|
17
|
+
languageTag,
|
|
18
|
+
slug: "",
|
|
19
|
+
name: "",
|
|
20
|
+
shortDescription: "",
|
|
21
|
+
description: "",
|
|
22
|
+
inclusionsHtml: "",
|
|
23
|
+
exclusionsHtml: "",
|
|
24
|
+
termsHtml: "",
|
|
25
|
+
seoTitle: "",
|
|
26
|
+
seoDescription: "",
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function translationToState(translation) {
|
|
30
|
+
return {
|
|
31
|
+
languageTag: translation.languageTag,
|
|
32
|
+
slug: translation.slug ?? "",
|
|
33
|
+
name: translation.name,
|
|
34
|
+
shortDescription: translation.shortDescription ?? "",
|
|
35
|
+
description: translation.description ?? "",
|
|
36
|
+
inclusionsHtml: translation.inclusionsHtml ?? "",
|
|
37
|
+
exclusionsHtml: translation.exclusionsHtml ?? "",
|
|
38
|
+
termsHtml: translation.termsHtml ?? "",
|
|
39
|
+
seoTitle: translation.seoTitle ?? "",
|
|
40
|
+
seoDescription: translation.seoDescription ?? "",
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function normalizeOptional(value) {
|
|
44
|
+
const trimmed = value.trim();
|
|
45
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
46
|
+
}
|
|
47
|
+
function normalizeLanguageTag(value) {
|
|
48
|
+
const trimmed = value.trim();
|
|
49
|
+
if (!trimmed)
|
|
50
|
+
return "";
|
|
51
|
+
try {
|
|
52
|
+
return Intl.getCanonicalLocales(trimmed)[0] ?? trimmed;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return trimmed;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function toPayload(state) {
|
|
59
|
+
return {
|
|
60
|
+
languageTag: normalizeLanguageTag(state.languageTag),
|
|
61
|
+
slug: normalizeOptional(state.slug),
|
|
62
|
+
name: state.name.trim(),
|
|
63
|
+
shortDescription: normalizeOptional(state.shortDescription),
|
|
64
|
+
description: normalizeOptional(state.description),
|
|
65
|
+
inclusionsHtml: normalizeOptional(state.inclusionsHtml),
|
|
66
|
+
exclusionsHtml: normalizeOptional(state.exclusionsHtml),
|
|
67
|
+
termsHtml: normalizeOptional(state.termsHtml),
|
|
68
|
+
seoTitle: normalizeOptional(state.seoTitle),
|
|
69
|
+
seoDescription: normalizeOptional(state.seoDescription),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function ProductTranslationsCard({ product, className }) {
|
|
73
|
+
const messages = useProductsUiMessagesOrDefault();
|
|
74
|
+
const cardMessages = messages.productTranslationsCard;
|
|
75
|
+
const translationsQuery = useProductTranslations(product.id, { limit: 100 });
|
|
76
|
+
const mutations = useProductTranslationMutation();
|
|
77
|
+
const translations = translationsQuery.data?.data ?? [];
|
|
78
|
+
const [selectedLanguageTag, setSelectedLanguageTag] = React.useState("");
|
|
79
|
+
const [newLanguageTag, setNewLanguageTag] = React.useState("");
|
|
80
|
+
const [state, setState] = React.useState(() => emptyTranslationState());
|
|
81
|
+
const [error, setError] = React.useState(null);
|
|
82
|
+
const baseId = React.useId();
|
|
83
|
+
const selectedTranslation = translations.find((translation) => translation.languageTag === selectedLanguageTag) ?? null;
|
|
84
|
+
const isSaving = mutations.create.isPending || mutations.update.isPending;
|
|
85
|
+
const isDeleting = mutations.remove.isPending;
|
|
86
|
+
React.useEffect(() => {
|
|
87
|
+
if (!selectedLanguageTag && translations.length > 0) {
|
|
88
|
+
setSelectedLanguageTag(translations[0]?.languageTag ?? "");
|
|
89
|
+
}
|
|
90
|
+
}, [selectedLanguageTag, translations]);
|
|
91
|
+
React.useEffect(() => {
|
|
92
|
+
if (selectedTranslation) {
|
|
93
|
+
setState(translationToState(selectedTranslation));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (selectedLanguageTag) {
|
|
97
|
+
setState(emptyTranslationState(selectedLanguageTag));
|
|
98
|
+
}
|
|
99
|
+
}, [selectedLanguageTag, selectedTranslation]);
|
|
100
|
+
const field = (key) => (value) => {
|
|
101
|
+
setState((prev) => ({ ...prev, [key]: value }));
|
|
102
|
+
};
|
|
103
|
+
const handleAddLanguage = () => {
|
|
104
|
+
setError(null);
|
|
105
|
+
const normalized = normalizeLanguageTag(newLanguageTag);
|
|
106
|
+
if (!normalized) {
|
|
107
|
+
setError(cardMessages.states.languageRequired);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
setSelectedLanguageTag(normalized);
|
|
111
|
+
setState(emptyTranslationState(normalized));
|
|
112
|
+
setNewLanguageTag("");
|
|
113
|
+
};
|
|
114
|
+
const handleCopyBase = () => {
|
|
115
|
+
setState((prev) => ({
|
|
116
|
+
...prev,
|
|
117
|
+
name: product.name,
|
|
118
|
+
shortDescription: "",
|
|
119
|
+
description: product.description ?? "",
|
|
120
|
+
inclusionsHtml: product.inclusionsHtml ?? "",
|
|
121
|
+
exclusionsHtml: product.exclusionsHtml ?? "",
|
|
122
|
+
termsHtml: product.termsHtml ?? "",
|
|
123
|
+
seoTitle: product.name,
|
|
124
|
+
seoDescription: product.description ?? "",
|
|
125
|
+
}));
|
|
126
|
+
};
|
|
127
|
+
const handleSubmit = async (event) => {
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
setError(null);
|
|
130
|
+
const languageTag = normalizeLanguageTag(state.languageTag);
|
|
131
|
+
if (!languageTag) {
|
|
132
|
+
setError(cardMessages.states.languageRequired);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (!state.name.trim()) {
|
|
136
|
+
setError(cardMessages.states.nameRequired);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
const payload = toPayload({ ...state, languageTag });
|
|
141
|
+
if (selectedTranslation) {
|
|
142
|
+
const { translation } = await mutations.update.mutateAsync({
|
|
143
|
+
productId: product.id,
|
|
144
|
+
translationId: selectedTranslation.id,
|
|
145
|
+
input: payload,
|
|
146
|
+
});
|
|
147
|
+
setSelectedLanguageTag(translation.languageTag);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
const translation = await mutations.create.mutateAsync({
|
|
151
|
+
productId: product.id,
|
|
152
|
+
input: payload,
|
|
153
|
+
});
|
|
154
|
+
setSelectedLanguageTag(translation.languageTag);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
catch (err) {
|
|
158
|
+
setError(err instanceof Error ? err.message : cardMessages.states.saveFailed);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const handleDelete = async () => {
|
|
162
|
+
if (!selectedTranslation)
|
|
163
|
+
return;
|
|
164
|
+
setError(null);
|
|
165
|
+
if (!confirm(cardMessages.states.deleteConfirm.replace("{languageTag}", selectedTranslation.languageTag))) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
await mutations.remove.mutateAsync({
|
|
170
|
+
productId: product.id,
|
|
171
|
+
translationId: selectedTranslation.id,
|
|
172
|
+
});
|
|
173
|
+
const next = translations.find((translation) => translation.id !== selectedTranslation.id);
|
|
174
|
+
setSelectedLanguageTag(next?.languageTag ?? "");
|
|
175
|
+
setState(emptyTranslationState(next?.languageTag ?? ""));
|
|
176
|
+
}
|
|
177
|
+
catch (err) {
|
|
178
|
+
setError(err instanceof Error ? err.message : cardMessages.states.deleteFailed);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
return (_jsxs(Card, { "data-slot": "product-translations-card", className: className, children: [_jsx(CardHeader, { children: _jsxs("div", { className: "flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between", children: [_jsxs("div", { className: "space-y-1.5", children: [_jsx(CardTitle, { children: cardMessages.title }), _jsx(CardDescription, { children: cardMessages.description })] }), _jsxs("div", { className: "flex flex-col gap-2 sm:flex-row sm:items-end", children: [_jsxs("div", { className: "flex min-w-40 flex-col gap-1.5", children: [_jsx(Label, { htmlFor: `${baseId}-language-select`, children: cardMessages.languageSelectLabel }), _jsxs(Select, { value: selectedLanguageTag, onValueChange: (value) => {
|
|
182
|
+
setError(null);
|
|
183
|
+
setSelectedLanguageTag(value ?? "");
|
|
184
|
+
}, disabled: translations.length === 0 && !selectedLanguageTag, children: [_jsx(SelectTrigger, { id: `${baseId}-language-select`, className: "w-full", children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { children: [translations.map((translation) => (_jsx(SelectItem, { value: translation.languageTag, children: translation.languageTag }, translation.id))), selectedLanguageTag &&
|
|
185
|
+
!translations.some((translation) => translation.languageTag === selectedLanguageTag) ? (_jsx(SelectItem, { value: selectedLanguageTag, children: selectedLanguageTag })) : null] })] })] }), _jsxs("div", { className: "flex flex-1 flex-col gap-1.5 sm:min-w-40", children: [_jsx(Label, { htmlFor: `${baseId}-new-language`, children: cardMessages.newLanguageLabel }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Input, { id: `${baseId}-new-language`, value: newLanguageTag, onChange: (event) => setNewLanguageTag(event.target.value), placeholder: cardMessages.placeholders.newLanguage }), _jsxs(Button, { type: "button", variant: "outline", onClick: handleAddLanguage, children: [_jsx(Plus, { className: "size-4", "aria-hidden": "true" }), cardMessages.actions.addLanguage] })] })] })] })] }) }), _jsxs(CardContent, { className: "space-y-4", children: [translationsQuery.isPending ? (_jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [_jsx(Loader2, { className: "size-4 animate-spin", "aria-hidden": "true" }), cardMessages.states.loading] })) : null, translationsQuery.isError ? (_jsx("p", { className: "text-sm text-destructive", children: translationsQuery.error instanceof Error
|
|
186
|
+
? translationsQuery.error.message
|
|
187
|
+
: cardMessages.states.loadFailed })) : null, !translationsQuery.isPending && translations.length === 0 && !selectedLanguageTag ? (_jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [_jsx(Languages, { className: "size-4", "aria-hidden": "true" }), cardMessages.states.noTranslations] })) : null, translations.length > 0 ? (_jsx("div", { className: "flex flex-wrap gap-2", children: translations.map((translation) => (_jsx(Badge, { variant: translation.languageTag === selectedLanguageTag ? "default" : "outline", children: translation.languageTag }, translation.id))) })) : null, _jsxs("form", { onSubmit: handleSubmit, className: "space-y-4", children: [_jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: `${baseId}-language-tag`, children: cardMessages.fields.languageTag }), _jsx(Input, { id: `${baseId}-language-tag`, required: true, value: state.languageTag, onChange: (event) => field("languageTag")(event.target.value), placeholder: cardMessages.placeholders.languageTag })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: `${baseId}-slug`, children: cardMessages.fields.slug }), _jsx(Input, { id: `${baseId}-slug`, value: state.slug, onChange: (event) => field("slug")(event.target.value), placeholder: cardMessages.placeholders.slug })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: `${baseId}-name`, children: cardMessages.fields.name }), _jsx(Input, { id: `${baseId}-name`, required: true, value: state.name, onChange: (event) => field("name")(event.target.value), placeholder: cardMessages.placeholders.name })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: `${baseId}-short-description`, children: cardMessages.fields.shortDescription }), _jsx(Input, { id: `${baseId}-short-description`, value: state.shortDescription, onChange: (event) => field("shortDescription")(event.target.value), placeholder: cardMessages.placeholders.shortDescription })] })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: `${baseId}-description`, children: cardMessages.fields.description }), _jsx(Textarea, { id: `${baseId}-description`, value: state.description, onChange: (event) => field("description")(event.target.value), placeholder: cardMessages.placeholders.description })] }), _jsxs("div", { className: "grid gap-4", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { children: cardMessages.fields.inclusions }), _jsx(RichTextEditor, { value: state.inclusionsHtml, onChange: field("inclusionsHtml"), placeholder: cardMessages.placeholders.inclusions, editorClassName: "max-h-[320px] overflow-y-auto" })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { children: cardMessages.fields.exclusions }), _jsx(RichTextEditor, { value: state.exclusionsHtml, onChange: field("exclusionsHtml"), placeholder: cardMessages.placeholders.exclusions, editorClassName: "max-h-[320px] overflow-y-auto" })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { children: cardMessages.fields.terms }), _jsx(RichTextEditor, { value: state.termsHtml, onChange: field("termsHtml"), placeholder: cardMessages.placeholders.terms, editorClassName: "max-h-[320px] overflow-y-auto" })] })] }), _jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: `${baseId}-seo-title`, children: cardMessages.fields.seoTitle }), _jsx(Input, { id: `${baseId}-seo-title`, value: state.seoTitle, onChange: (event) => field("seoTitle")(event.target.value), placeholder: cardMessages.placeholders.seoTitle })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: `${baseId}-seo-description`, children: cardMessages.fields.seoDescription }), _jsx(Textarea, { id: `${baseId}-seo-description`, value: state.seoDescription, onChange: (event) => field("seoDescription")(event.target.value), placeholder: cardMessages.placeholders.seoDescription })] })] }), error ? _jsx("p", { className: "text-sm text-destructive", children: error }) : null, _jsxs("div", { className: "flex flex-wrap justify-end gap-2", children: [_jsxs(Button, { type: "button", variant: "outline", onClick: handleCopyBase, children: [_jsx(Copy, { className: "size-4", "aria-hidden": "true" }), cardMessages.actions.copyBase] }), selectedTranslation ? (_jsxs(Button, { type: "button", variant: "destructive", disabled: isDeleting, onClick: () => void handleDelete(), children: [isDeleting ? (_jsx(Loader2, { className: "size-4 animate-spin", "aria-hidden": "true" })) : (_jsx(Trash2, { className: "size-4", "aria-hidden": "true" })), isDeleting ? cardMessages.actions.deleting : cardMessages.actions.delete] })) : null, _jsxs(Button, { type: "submit", disabled: isSaving, children: [isSaving ? (_jsx(Loader2, { className: "size-4 animate-spin", "aria-hidden": "true" })) : (_jsx(Save, { className: "size-4", "aria-hidden": "true" })), isSaving ? cardMessages.actions.saving : cardMessages.actions.save] })] })] })] })] }));
|
|
188
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
value: string | null | undefined;
|
|
3
|
+
onChange: (value: string | null) => void;
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function ProductTypeCombobox({ value, onChange, placeholder, disabled }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=product-type-combobox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-type-combobox.d.ts","sourceRoot":"","sources":["../../src/components/product-type-combobox.tsx"],"names":[],"mappings":"AAaA,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAID,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,KAAK,2CA0EpF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Combobox, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList, } from "@voyant-travel/ui/components/combobox";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useProductsUiMessagesOrDefault } from "../i18n/provider.js";
|
|
5
|
+
import { useProductType, useProductTypes } from "../index.js";
|
|
6
|
+
const PAGE_SIZE = 25;
|
|
7
|
+
export function ProductTypeCombobox({ value, onChange, placeholder, disabled }) {
|
|
8
|
+
const messages = useProductsUiMessagesOrDefault();
|
|
9
|
+
const [search, setSearch] = React.useState("");
|
|
10
|
+
const listQuery = useProductTypes({ active: true, search: search || undefined, limit: PAGE_SIZE });
|
|
11
|
+
const selectedQuery = useProductType(value, { enabled: !!value });
|
|
12
|
+
const items = React.useMemo(() => {
|
|
13
|
+
const map = new Map();
|
|
14
|
+
for (const item of listQuery.data?.data ?? [])
|
|
15
|
+
map.set(item.id, item);
|
|
16
|
+
if (selectedQuery.data)
|
|
17
|
+
map.set(selectedQuery.data.id, selectedQuery.data);
|
|
18
|
+
return Array.from(map.values());
|
|
19
|
+
}, [listQuery.data?.data, selectedQuery.data]);
|
|
20
|
+
const itemMap = React.useMemo(() => new Map(items.map((item) => [item.id, item])), [items]);
|
|
21
|
+
const selected = value ? itemMap.get(value) : undefined;
|
|
22
|
+
const selectedLabel = selected ? `${selected.name} · ${selected.code}` : "";
|
|
23
|
+
const [inputValue, setInputValue] = React.useState(selectedLabel);
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
setInputValue(selectedLabel);
|
|
26
|
+
}, [selectedLabel]);
|
|
27
|
+
return (_jsxs(Combobox, { items: items.map((item) => item.id), value: value ?? null, inputValue: inputValue, autoHighlight: true, disabled: disabled, itemToStringValue: (id) => {
|
|
28
|
+
const item = itemMap.get(id);
|
|
29
|
+
return item ? `${item.name} · ${item.code}` : "";
|
|
30
|
+
}, onInputValueChange: (next) => {
|
|
31
|
+
setInputValue(next);
|
|
32
|
+
setSearch(next);
|
|
33
|
+
if (!next)
|
|
34
|
+
onChange(null);
|
|
35
|
+
}, onValueChange: (next) => {
|
|
36
|
+
const id = next ?? null;
|
|
37
|
+
onChange(id);
|
|
38
|
+
const item = id ? itemMap.get(id) : null;
|
|
39
|
+
setInputValue(item ? `${item.name} · ${item.code}` : "");
|
|
40
|
+
}, children: [_jsx(ComboboxInput, { placeholder: placeholder ?? messages.comboboxes.productType.placeholder, showClear: !!value }), _jsxs(ComboboxContent, { children: [_jsx(ComboboxEmpty, { children: listQuery.isPending || selectedQuery.isPending
|
|
41
|
+
? messages.common.loading
|
|
42
|
+
: messages.comboboxes.productType.empty }), _jsx(ComboboxList, { children: _jsx(ComboboxCollection, { children: (id) => {
|
|
43
|
+
const item = itemMap.get(id);
|
|
44
|
+
if (!item)
|
|
45
|
+
return null;
|
|
46
|
+
return (_jsx(ComboboxItem, { value: item.id, children: _jsxs("div", { className: "flex min-w-0 flex-col", children: [_jsx("span", { className: "truncate font-medium", children: item.name }), _jsx("span", { className: "truncate text-xs text-muted-foreground", children: item.code })] }) }, item.id));
|
|
47
|
+
} }) })] })] }));
|
|
48
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface ProductTypesPageProps {
|
|
2
|
+
pageSize?: number;
|
|
3
|
+
className?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function ProductTypesPage({ pageSize, className, }?: ProductTypesPageProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=product-types-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-types-page.d.ts","sourceRoot":"","sources":["../../src/components/product-types-page.tsx"],"names":[],"mappings":"AAmCA,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAgBD,wBAAgB,gBAAgB,CAAC,EAC/B,QAA4B,EAC5B,SAAS,GACV,GAAE,qBAA0B,2CAyI5B"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Badge, Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, Input, Label, Sheet, SheetBody, SheetContent, SheetFooter, SheetHeader, SheetTitle, Switch, Textarea, } from "@voyant-travel/ui/components";
|
|
4
|
+
import { cn } from "@voyant-travel/ui/lib/utils";
|
|
5
|
+
import { zodResolver } from "@voyant-travel/ui/lib/zod-resolver";
|
|
6
|
+
import { Loader2, MoreHorizontal, Pencil, Plus, Trash2 } from "lucide-react";
|
|
7
|
+
import { useEffect, useMemo, useState } from "react";
|
|
8
|
+
import { useForm } from "react-hook-form";
|
|
9
|
+
import { z } from "zod/v4";
|
|
10
|
+
import { useProductsUiMessagesOrDefault } from "../i18n/index.js";
|
|
11
|
+
import { useProductTypeMutation, useProductTypes } from "../index.js";
|
|
12
|
+
const DEFAULT_PAGE_SIZE = 25;
|
|
13
|
+
function getFormSchema(messages) {
|
|
14
|
+
return z.object({
|
|
15
|
+
name: z.string().min(1, messages.validation.nameRequired).max(255),
|
|
16
|
+
code: z.string().min(1, messages.validation.codeRequired).max(100),
|
|
17
|
+
description: z.string().optional().nullable(),
|
|
18
|
+
sortOrder: z.coerce.number().int().default(0),
|
|
19
|
+
active: z.boolean().default(true),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export function ProductTypesPage({ pageSize = DEFAULT_PAGE_SIZE, className, } = {}) {
|
|
23
|
+
const messages = useProductsUiMessagesOrDefault();
|
|
24
|
+
const pageMessages = messages.productTypesPage;
|
|
25
|
+
const [sheetOpen, setSheetOpen] = useState(false);
|
|
26
|
+
const [editing, setEditing] = useState();
|
|
27
|
+
const [pageIndex, setPageIndex] = useState(0);
|
|
28
|
+
const { data, isPending, refetch } = useProductTypes({
|
|
29
|
+
limit: pageSize,
|
|
30
|
+
offset: pageIndex * pageSize,
|
|
31
|
+
});
|
|
32
|
+
const { remove } = useProductTypeMutation();
|
|
33
|
+
const items = data?.data ?? [];
|
|
34
|
+
const total = data?.total ?? 0;
|
|
35
|
+
const pageCount = Math.max(1, Math.ceil(total / pageSize));
|
|
36
|
+
return (_jsxs("div", { "data-slot": "product-types-page", className: cn("flex flex-col gap-6 p-6", className), children: [_jsxs("div", { className: "flex items-center justify-between gap-4", children: [_jsxs("div", { children: [_jsx("h2", { className: "text-lg font-semibold tracking-tight", children: pageMessages.title }), _jsx("p", { className: "text-sm text-muted-foreground", children: pageMessages.description })] }), _jsxs(Button, { size: "sm", onClick: () => {
|
|
37
|
+
setEditing(undefined);
|
|
38
|
+
setSheetOpen(true);
|
|
39
|
+
}, children: [_jsx(Plus, { className: "mr-1.5 size-3.5" }), pageMessages.addType] })] }), isPending ? (_jsx(ProductTypesListLoading, { loadingLabel: messages.common.loading })) : (_jsx("div", { className: "rounded-lg border bg-card text-card-foreground shadow-sm", children: items.length === 0 ? (_jsx("p", { className: "py-12 text-center text-sm text-muted-foreground", children: pageMessages.empty })) : (_jsx("div", { className: "flex flex-col divide-y", children: items.map((item) => (_jsxs("div", { className: "flex items-center justify-between gap-4 px-6 py-3", children: [_jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("span", { className: "text-sm font-medium", children: item.name }), _jsx("span", { className: "font-mono text-xs text-muted-foreground", children: item.code }), !item.active ? (_jsx(Badge, { variant: "secondary", className: "text-xs", children: messages.common.inactive })) : null] }), item.description ? (_jsx("p", { className: "text-xs text-muted-foreground", children: item.description })) : null] }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", className: "size-8 text-muted-foreground", children: _jsx(MoreHorizontal, { className: "size-4" }) }) }), _jsxs(DropdownMenuContent, { align: "end", children: [_jsxs(DropdownMenuItem, { onClick: () => {
|
|
40
|
+
setEditing(item);
|
|
41
|
+
setSheetOpen(true);
|
|
42
|
+
}, children: [_jsx(Pencil, { className: "size-4" }), pageMessages.edit] }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { variant: "destructive", onClick: () => {
|
|
43
|
+
if (confirm(pageMessages.deleteConfirm)) {
|
|
44
|
+
remove.mutate(item.id, { onSuccess: () => void refetch() });
|
|
45
|
+
}
|
|
46
|
+
}, children: [_jsx(Trash2, { className: "size-4" }), pageMessages.delete] })] })] })] }, item.id))) })) })), _jsxs("div", { className: "flex items-center justify-between text-sm text-muted-foreground", children: [_jsx("span", { children: pageMessages.showingSummary
|
|
47
|
+
.replace("{count}", String(items.length))
|
|
48
|
+
.replace("{total}", String(total)) }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Button, { variant: "outline", size: "sm", disabled: pageIndex === 0, onClick: () => setPageIndex((current) => Math.max(0, current - 1)), children: messages.common.previous }), _jsxs("span", { children: [messages.common.page, " ", pageIndex + 1, " / ", pageCount] }), _jsx(Button, { variant: "outline", size: "sm", disabled: (pageIndex + 1) * pageSize >= total, onClick: () => setPageIndex((current) => current + 1), children: messages.common.next })] })] }), _jsx(ProductTypeSheet, { open: sheetOpen, onOpenChange: setSheetOpen, item: editing, onSuccess: () => {
|
|
49
|
+
setSheetOpen(false);
|
|
50
|
+
setEditing(undefined);
|
|
51
|
+
void refetch();
|
|
52
|
+
} })] }));
|
|
53
|
+
}
|
|
54
|
+
function ProductTypesListLoading({ loadingLabel }) {
|
|
55
|
+
return (_jsx("div", { className: "rounded-lg border bg-card text-card-foreground shadow-sm", children: _jsxs("div", { className: "flex h-32 items-center justify-center text-sm text-muted-foreground", children: [_jsx(Loader2, { className: "mr-2 size-4 animate-spin" }), loadingLabel] }) }));
|
|
56
|
+
}
|
|
57
|
+
function ProductTypeSheet({ open, onOpenChange, item, onSuccess, }) {
|
|
58
|
+
const messages = useProductsUiMessagesOrDefault().productTypesPage;
|
|
59
|
+
const { create, update } = useProductTypeMutation();
|
|
60
|
+
const formSchema = useMemo(() => getFormSchema(messages), [messages]);
|
|
61
|
+
const form = useForm({
|
|
62
|
+
resolver: zodResolver(formSchema),
|
|
63
|
+
defaultValues: {
|
|
64
|
+
name: "",
|
|
65
|
+
code: "",
|
|
66
|
+
description: "",
|
|
67
|
+
sortOrder: 0,
|
|
68
|
+
active: true,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (open && item) {
|
|
73
|
+
form.reset({
|
|
74
|
+
name: item.name,
|
|
75
|
+
code: item.code,
|
|
76
|
+
description: item.description ?? "",
|
|
77
|
+
sortOrder: item.sortOrder,
|
|
78
|
+
active: item.active,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
else if (open) {
|
|
82
|
+
form.reset();
|
|
83
|
+
}
|
|
84
|
+
}, [open, item, form]);
|
|
85
|
+
const isSubmitting = create.isPending || update.isPending;
|
|
86
|
+
const onSubmit = async (values) => {
|
|
87
|
+
const payload = {
|
|
88
|
+
name: values.name,
|
|
89
|
+
code: values.code,
|
|
90
|
+
description: values.description || null,
|
|
91
|
+
sortOrder: values.sortOrder,
|
|
92
|
+
active: values.active,
|
|
93
|
+
};
|
|
94
|
+
if (item) {
|
|
95
|
+
await update.mutateAsync({ id: item.id, input: payload });
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
await create.mutateAsync(payload);
|
|
99
|
+
}
|
|
100
|
+
onSuccess();
|
|
101
|
+
};
|
|
102
|
+
return (_jsx(Sheet, { open: open, onOpenChange: onOpenChange, children: _jsxs(SheetContent, { side: "right", size: "lg", children: [_jsx(SheetHeader, { children: _jsx(SheetTitle, { children: item ? messages.editSheetTitle : messages.newSheetTitle }) }), _jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-1 flex-col overflow-hidden", children: [_jsxs(SheetBody, { 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: messages.nameLabel }), _jsx(Input, { ...form.register("name"), placeholder: messages.namePlaceholder, autoFocus: true }), form.formState.errors.name ? (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.name.message })) : null] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.codeLabel }), _jsx(Input, { ...form.register("code"), placeholder: messages.codePlaceholder }), form.formState.errors.code ? (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.code.message })) : null] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.descriptionLabel }), _jsx(Textarea, { ...form.register("description"), placeholder: messages.descriptionPlaceholder })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.sortOrderLabel }), _jsx(Input, { ...form.register("sortOrder"), type: "number" })] }), _jsxs("div", { className: "flex items-center gap-2 pt-6", children: [_jsx(Switch, { checked: form.watch("active"), onCheckedChange: (checked) => form.setValue("active", checked) }), _jsx(Label, { children: messages.activeLabel })] })] })] }), _jsxs(SheetFooter, { children: [_jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: () => onOpenChange(false), children: messages.cancel }), _jsxs(Button, { type: "submit", size: "sm", disabled: isSubmitting, children: [isSubmitting ? _jsx(Loader2, { className: "mr-2 size-4 animate-spin" }) : null, item ? messages.saveChanges : messages.createType] })] })] })] }) }));
|
|
103
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ProductVersionDialogProps {
|
|
2
|
+
open: boolean;
|
|
3
|
+
onOpenChange: (open: boolean) => void;
|
|
4
|
+
productId: string;
|
|
5
|
+
onSuccess?: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function ProductVersionDialog({ open, onOpenChange, productId, onSuccess, }: ProductVersionDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=product-version-dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-version-dialog.d.ts","sourceRoot":"","sources":["../../src/components/product-version-dialog.tsx"],"names":[],"mappings":"AAiBA,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB;AAED,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,SAAS,GACV,EAAE,yBAAyB,2CAqE3B"}
|