@voyant-travel/distribution-react 0.109.8
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/README.md +82 -0
- package/dist/admin/index.d.ts +30 -0
- package/dist/admin/index.d.ts.map +1 -0
- package/dist/admin/index.js +65 -0
- package/dist/client.d.ts +14 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +59 -0
- package/dist/components/booking-link-detail-page.d.ts +10 -0
- package/dist/components/booking-link-detail-page.d.ts.map +1 -0
- package/dist/components/booking-link-detail-page.js +51 -0
- package/dist/components/channel-detail-page.d.ts +12 -0
- package/dist/components/channel-detail-page.d.ts.map +1 -0
- package/dist/components/channel-detail-page.js +41 -0
- package/dist/components/channel-sync-controls.d.ts +15 -0
- package/dist/components/channel-sync-controls.d.ts.map +1 -0
- package/dist/components/channel-sync-controls.js +29 -0
- package/dist/components/channel-sync-deliveries-drawer.d.ts +12 -0
- package/dist/components/channel-sync-deliveries-drawer.d.ts.map +1 -0
- package/dist/components/channel-sync-deliveries-drawer.js +18 -0
- package/dist/components/channel-sync-page-utils.d.ts +99 -0
- package/dist/components/channel-sync-page-utils.d.ts.map +1 -0
- package/dist/components/channel-sync-page-utils.js +85 -0
- package/dist/components/channel-sync-page.d.ts +4 -0
- package/dist/components/channel-sync-page.d.ts.map +1 -0
- package/dist/components/channel-sync-page.js +141 -0
- package/dist/components/channels-page.d.ts +6 -0
- package/dist/components/channels-page.d.ts.map +1 -0
- package/dist/components/channels-page.js +132 -0
- package/dist/components/commission-rule-detail-page.d.ts +10 -0
- package/dist/components/commission-rule-detail-page.d.ts.map +1 -0
- package/dist/components/commission-rule-detail-page.js +57 -0
- package/dist/components/contract-detail-page.d.ts +10 -0
- package/dist/components/contract-detail-page.d.ts.map +1 -0
- package/dist/components/contract-detail-page.js +64 -0
- package/dist/components/distribution-overview.d.ts +19 -0
- package/dist/components/distribution-overview.d.ts.map +1 -0
- package/dist/components/distribution-overview.js +13 -0
- package/dist/components/distribution-page.d.ts +26 -0
- package/dist/components/distribution-page.d.ts.map +1 -0
- package/dist/components/distribution-page.js +190 -0
- package/dist/components/distribution-section-header.d.ts +7 -0
- package/dist/components/distribution-section-header.d.ts.map +1 -0
- package/dist/components/distribution-section-header.js +6 -0
- package/dist/components/distribution-shared.d.ts +32 -0
- package/dist/components/distribution-shared.d.ts.map +1 -0
- package/dist/components/distribution-shared.js +246 -0
- package/dist/components/distribution-tabs-primary.d.ts +57 -0
- package/dist/components/distribution-tabs-primary.d.ts.map +1 -0
- package/dist/components/distribution-tabs-primary.js +89 -0
- package/dist/components/distribution-tabs-secondary.d.ts +58 -0
- package/dist/components/distribution-tabs-secondary.d.ts.map +1 -0
- package/dist/components/distribution-tabs-secondary.js +89 -0
- package/dist/components/mapping-detail-page.d.ts +10 -0
- package/dist/components/mapping-detail-page.d.ts.map +1 -0
- package/dist/components/mapping-detail-page.js +51 -0
- package/dist/components/webhook-event-detail-page.d.ts +9 -0
- package/dist/components/webhook-event-detail-page.d.ts.map +1 -0
- package/dist/components/webhook-event-detail-page.js +46 -0
- package/dist/constants.d.ts +103 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +48 -0
- package/dist/external-refs/client.d.ts +14 -0
- package/dist/external-refs/client.d.ts.map +1 -0
- package/dist/external-refs/client.js +58 -0
- package/dist/external-refs/components/entity-ref-picker.d.ts +21 -0
- package/dist/external-refs/components/entity-ref-picker.d.ts.map +1 -0
- package/dist/external-refs/components/entity-ref-picker.js +38 -0
- package/dist/external-refs/components/external-ref-dialog.d.ts +11 -0
- package/dist/external-refs/components/external-ref-dialog.d.ts.map +1 -0
- package/dist/external-refs/components/external-ref-dialog.js +120 -0
- package/dist/external-refs/components/external-refs-page.d.ts +16 -0
- package/dist/external-refs/components/external-refs-page.d.ts.map +1 -0
- package/dist/external-refs/components/external-refs-page.js +109 -0
- package/dist/external-refs/hooks/index.d.ts +3 -0
- package/dist/external-refs/hooks/index.d.ts.map +1 -0
- package/dist/external-refs/hooks/index.js +2 -0
- package/dist/external-refs/hooks/use-external-ref-mutation.d.ts +57 -0
- package/dist/external-refs/hooks/use-external-ref-mutation.d.ts.map +1 -0
- package/dist/external-refs/hooks/use-external-ref-mutation.js +40 -0
- package/dist/external-refs/hooks/use-external-refs.d.ts +26 -0
- package/dist/external-refs/hooks/use-external-refs.d.ts.map +1 -0
- package/dist/external-refs/hooks/use-external-refs.js +12 -0
- package/dist/external-refs/i18n/en.d.ts +3 -0
- package/dist/external-refs/i18n/en.d.ts.map +1 -0
- package/dist/external-refs/i18n/en.js +92 -0
- package/dist/external-refs/i18n/index.d.ts +5 -0
- package/dist/external-refs/i18n/index.d.ts.map +1 -0
- package/dist/external-refs/i18n/index.js +3 -0
- package/dist/external-refs/i18n/messages.d.ts +85 -0
- package/dist/external-refs/i18n/messages.d.ts.map +1 -0
- package/dist/external-refs/i18n/messages.js +1 -0
- package/dist/external-refs/i18n/provider.d.ts +26 -0
- package/dist/external-refs/i18n/provider.d.ts.map +1 -0
- package/dist/external-refs/i18n/provider.js +44 -0
- package/dist/external-refs/i18n/ro.d.ts +3 -0
- package/dist/external-refs/i18n/ro.d.ts.map +1 -0
- package/dist/external-refs/i18n/ro.js +92 -0
- package/dist/external-refs/index.d.ts +7 -0
- package/dist/external-refs/index.d.ts.map +1 -0
- package/dist/external-refs/index.js +6 -0
- package/dist/external-refs/provider.d.ts +2 -0
- package/dist/external-refs/provider.d.ts.map +1 -0
- package/dist/external-refs/provider.js +1 -0
- package/dist/external-refs/query-keys.d.ts +18 -0
- package/dist/external-refs/query-keys.d.ts.map +1 -0
- package/dist/external-refs/query-keys.js +6 -0
- package/dist/external-refs/query-options.d.ts +159 -0
- package/dist/external-refs/query-options.d.ts.map +1 -0
- package/dist/external-refs/query-options.js +31 -0
- package/dist/external-refs/schemas.d.ts +82 -0
- package/dist/external-refs/schemas.d.ts.map +1 -0
- package/dist/external-refs/schemas.js +20 -0
- package/dist/external-refs/ui.d.ts +5 -0
- package/dist/external-refs/ui.d.ts.map +1 -0
- package/dist/external-refs/ui.js +4 -0
- package/dist/hooks/index.d.ts +12 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +12 -0
- package/dist/hooks/use-booking-links.d.ts +20 -0
- package/dist/hooks/use-booking-links.d.ts.map +1 -0
- package/dist/hooks/use-booking-links.js +9 -0
- package/dist/hooks/use-bookings.d.ts +14 -0
- package/dist/hooks/use-bookings.d.ts.map +1 -0
- package/dist/hooks/use-bookings.js +9 -0
- package/dist/hooks/use-channel-mutation.d.ts +69 -0
- package/dist/hooks/use-channel-mutation.d.ts.map +1 -0
- package/dist/hooks/use-channel-mutation.js +49 -0
- package/dist/hooks/use-channel.d.ts +16 -0
- package/dist/hooks/use-channel.d.ts.map +1 -0
- package/dist/hooks/use-channel.js +13 -0
- package/dist/hooks/use-channels.d.ts +20 -0
- package/dist/hooks/use-channels.d.ts.map +1 -0
- package/dist/hooks/use-channels.js +9 -0
- package/dist/hooks/use-commission-rules.d.ts +23 -0
- package/dist/hooks/use-commission-rules.d.ts.map +1 -0
- package/dist/hooks/use-commission-rules.js +9 -0
- package/dist/hooks/use-contracts.d.ts +22 -0
- package/dist/hooks/use-contracts.d.ts.map +1 -0
- package/dist/hooks/use-contracts.js +9 -0
- package/dist/hooks/use-mappings.d.ts +19 -0
- package/dist/hooks/use-mappings.d.ts.map +1 -0
- package/dist/hooks/use-mappings.js +9 -0
- package/dist/hooks/use-products.d.ts +14 -0
- package/dist/hooks/use-products.d.ts.map +1 -0
- package/dist/hooks/use-products.js +9 -0
- package/dist/hooks/use-suppliers.d.ts +14 -0
- package/dist/hooks/use-suppliers.d.ts.map +1 -0
- package/dist/hooks/use-suppliers.js +9 -0
- package/dist/hooks/use-webhook-events.d.ts +21 -0
- package/dist/hooks/use-webhook-events.d.ts.map +1 -0
- package/dist/hooks/use-webhook-events.js +9 -0
- package/dist/i18n/en.d.ts +592 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +561 -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/messages.d.ts +409 -0
- package/dist/i18n/messages.d.ts.map +1 -0
- package/dist/i18n/messages.js +1 -0
- package/dist/i18n/provider.d.ts +1207 -0
- package/dist/i18n/provider.d.ts.map +1 -0
- package/dist/i18n/provider.js +44 -0
- package/dist/i18n/ro.d.ts +592 -0
- package/dist/i18n/ro.d.ts.map +1 -0
- package/dist/i18n/ro.js +561 -0
- package/dist/i18n/utils.d.ts +4 -0
- package/dist/i18n/utils.d.ts.map +1 -0
- package/dist/i18n/utils.js +8 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -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 +61 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +30 -0
- package/dist/query-options.d.ts +999 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +219 -0
- package/dist/schemas.d.ts +615 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +144 -0
- package/dist/suppliers/admin/index.d.ts +69 -0
- package/dist/suppliers/admin/index.d.ts.map +1 -0
- package/dist/suppliers/admin/index.js +111 -0
- package/dist/suppliers/admin/pages/supplier-detail-page.d.ts +9 -0
- package/dist/suppliers/admin/pages/supplier-detail-page.d.ts.map +1 -0
- package/dist/suppliers/admin/pages/supplier-detail-page.js +11 -0
- package/dist/suppliers/admin/slots.d.ts +19 -0
- package/dist/suppliers/admin/slots.d.ts.map +1 -0
- package/dist/suppliers/admin/slots.js +18 -0
- package/dist/suppliers/admin/supplier-detail-host.d.ts +30 -0
- package/dist/suppliers/admin/supplier-detail-host.d.ts.map +1 -0
- package/dist/suppliers/admin/supplier-detail-host.js +34 -0
- package/dist/suppliers/admin/supplier-detail-skeleton.d.ts +9 -0
- package/dist/suppliers/admin/supplier-detail-skeleton.d.ts.map +1 -0
- package/dist/suppliers/admin/supplier-detail-skeleton.js +20 -0
- package/dist/suppliers/admin/suppliers-host.d.ts +11 -0
- package/dist/suppliers/admin/suppliers-host.d.ts.map +1 -0
- package/dist/suppliers/admin/suppliers-host.js +17 -0
- package/dist/suppliers/admin/suppliers-list-skeleton.d.ts +9 -0
- package/dist/suppliers/admin/suppliers-list-skeleton.d.ts.map +1 -0
- package/dist/suppliers/admin/suppliers-list-skeleton.js +24 -0
- package/dist/suppliers/client.d.ts +14 -0
- package/dist/suppliers/client.d.ts.map +1 -0
- package/dist/suppliers/client.js +59 -0
- package/dist/suppliers/components/message-format.d.ts +2 -0
- package/dist/suppliers/components/message-format.d.ts.map +1 -0
- package/dist/suppliers/components/message-format.js +3 -0
- package/dist/suppliers/components/rate-dialog.d.ts +11 -0
- package/dist/suppliers/components/rate-dialog.d.ts.map +1 -0
- package/dist/suppliers/components/rate-dialog.js +93 -0
- package/dist/suppliers/components/service-dialog.d.ts +10 -0
- package/dist/suppliers/components/service-dialog.d.ts.map +1 -0
- package/dist/suppliers/components/service-dialog.js +69 -0
- package/dist/suppliers/components/supplier-combobox.d.ts +13 -0
- package/dist/suppliers/components/supplier-combobox.d.ts.map +1 -0
- package/dist/suppliers/components/supplier-combobox.js +23 -0
- package/dist/suppliers/components/supplier-detail-page.d.ts +17 -0
- package/dist/suppliers/components/supplier-detail-page.d.ts.map +1 -0
- package/dist/suppliers/components/supplier-detail-page.js +105 -0
- package/dist/suppliers/components/supplier-dialog.d.ts +9 -0
- package/dist/suppliers/components/supplier-dialog.d.ts.map +1 -0
- package/dist/suppliers/components/supplier-dialog.js +118 -0
- package/dist/suppliers/components/supplier-service-row.d.ts +22 -0
- package/dist/suppliers/components/supplier-service-row.d.ts.map +1 -0
- package/dist/suppliers/components/supplier-service-row.js +18 -0
- package/dist/suppliers/components/suppliers-page.d.ts +10 -0
- package/dist/suppliers/components/suppliers-page.d.ts.map +1 -0
- package/dist/suppliers/components/suppliers-page.js +94 -0
- package/dist/suppliers/constants.d.ts +69 -0
- package/dist/suppliers/constants.d.ts.map +1 -0
- package/dist/suppliers/constants.js +34 -0
- package/dist/suppliers/hooks/index.d.ts +10 -0
- package/dist/suppliers/hooks/index.d.ts.map +1 -0
- package/dist/suppliers/hooks/index.js +10 -0
- package/dist/suppliers/hooks/use-supplier-mutation.d.ts +95 -0
- package/dist/suppliers/hooks/use-supplier-mutation.d.ts.map +1 -0
- package/dist/suppliers/hooks/use-supplier-mutation.js +41 -0
- package/dist/suppliers/hooks/use-supplier-note-mutation.d.ts +13 -0
- package/dist/suppliers/hooks/use-supplier-note-mutation.d.ts.map +1 -0
- package/dist/suppliers/hooks/use-supplier-note-mutation.js +20 -0
- package/dist/suppliers/hooks/use-supplier-notes.d.ts +13 -0
- package/dist/suppliers/hooks/use-supplier-notes.d.ts.map +1 -0
- package/dist/suppliers/hooks/use-supplier-notes.js +12 -0
- package/dist/suppliers/hooks/use-supplier-rate-mutation.d.ts +56 -0
- package/dist/suppliers/hooks/use-supplier-rate-mutation.d.ts.map +1 -0
- package/dist/suppliers/hooks/use-supplier-rate-mutation.js +41 -0
- package/dist/suppliers/hooks/use-supplier-service-mutation.d.ts +45 -0
- package/dist/suppliers/hooks/use-supplier-service-mutation.d.ts.map +1 -0
- package/dist/suppliers/hooks/use-supplier-service-mutation.js +44 -0
- package/dist/suppliers/hooks/use-supplier-service-rates.d.ts +20 -0
- package/dist/suppliers/hooks/use-supplier-service-rates.d.ts.map +1 -0
- package/dist/suppliers/hooks/use-supplier-service-rates.js +12 -0
- package/dist/suppliers/hooks/use-supplier-services.d.ts +19 -0
- package/dist/suppliers/hooks/use-supplier-services.d.ts.map +1 -0
- package/dist/suppliers/hooks/use-supplier-services.js +12 -0
- package/dist/suppliers/hooks/use-supplier.d.ts +38 -0
- package/dist/suppliers/hooks/use-supplier.d.ts.map +1 -0
- package/dist/suppliers/hooks/use-supplier.js +9 -0
- package/dist/suppliers/hooks/use-suppliers.d.ts +42 -0
- package/dist/suppliers/hooks/use-suppliers.d.ts.map +1 -0
- package/dist/suppliers/hooks/use-suppliers.js +9 -0
- package/dist/suppliers/i18n/en.d.ts +204 -0
- package/dist/suppliers/i18n/en.d.ts.map +1 -0
- package/dist/suppliers/i18n/en.js +203 -0
- package/dist/suppliers/i18n/index.d.ts +5 -0
- package/dist/suppliers/i18n/index.d.ts.map +1 -0
- package/dist/suppliers/i18n/index.js +3 -0
- package/dist/suppliers/i18n/messages.d.ts +187 -0
- package/dist/suppliers/i18n/messages.d.ts.map +1 -0
- package/dist/suppliers/i18n/messages.js +1 -0
- package/dist/suppliers/i18n/provider.d.ts +430 -0
- package/dist/suppliers/i18n/provider.d.ts.map +1 -0
- package/dist/suppliers/i18n/provider.js +44 -0
- package/dist/suppliers/i18n/ro.d.ts +204 -0
- package/dist/suppliers/i18n/ro.d.ts.map +1 -0
- package/dist/suppliers/i18n/ro.js +203 -0
- package/dist/suppliers/index.d.ts +9 -0
- package/dist/suppliers/index.d.ts.map +1 -0
- package/dist/suppliers/index.js +8 -0
- package/dist/suppliers/provider.d.ts +2 -0
- package/dist/suppliers/provider.d.ts.map +1 -0
- package/dist/suppliers/provider.js +1 -0
- package/dist/suppliers/query-keys.d.ts +29 -0
- package/dist/suppliers/query-keys.d.ts.map +1 -0
- package/dist/suppliers/query-keys.js +12 -0
- package/dist/suppliers/query-options.d.ts +467 -0
- package/dist/suppliers/query-options.d.ts.map +1 -0
- package/dist/suppliers/query-options.js +63 -0
- package/dist/suppliers/schemas.d.ts +363 -0
- package/dist/suppliers/schemas.d.ts.map +1 -0
- package/dist/suppliers/schemas.js +109 -0
- package/dist/suppliers/ui.d.ts +9 -0
- package/dist/suppliers/ui.d.ts.map +1 -0
- package/dist/suppliers/ui.js +8 -0
- package/dist/suppliers/utils.d.ts +4 -0
- package/dist/suppliers/utils.d.ts.map +1 -0
- package/dist/suppliers/utils.js +10 -0
- package/dist/ui.d.ts +16 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +14 -0
- package/dist/utils.d.ts +10 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +44 -0
- package/package.json +263 -0
- package/src/external-refs/styles.css +11 -0
- package/src/styles.css +11 -0
- package/src/suppliers/styles.css +11 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Badge, Button } from "@voyant-travel/ui/components";
|
|
3
|
+
import { ChevronDown, ChevronRight, Pencil, Plus, Trash2 } from "lucide-react";
|
|
4
|
+
import { useSuppliersUiI18nOrDefault } from "../i18n/index.js";
|
|
5
|
+
import { useSupplierServiceRates } from "../index.js";
|
|
6
|
+
export function SupplierServiceRow({ service, supplierId, rates, expanded, onToggle, onEdit, onDelete, onAddRate, onEditRate, onDeleteRate, }) {
|
|
7
|
+
const i18n = useSuppliersUiI18nOrDefault();
|
|
8
|
+
const { messages } = i18n;
|
|
9
|
+
const { data: fetchedRates } = useSupplierServiceRates(supplierId ?? "", service.id, {
|
|
10
|
+
enabled: expanded && !rates && !!supplierId,
|
|
11
|
+
});
|
|
12
|
+
const resolvedRates = rates ?? fetchedRates?.data ?? [];
|
|
13
|
+
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 hover:text-foreground", children: expanded ? _jsx(ChevronDown, { className: "h-4 w-4" }) : _jsx(ChevronRight, { className: "h-4 w-4" }) }), _jsxs("div", { className: "flex-1", children: [_jsx("span", { className: "text-sm font-medium", children: service.name }), _jsxs("div", { className: "mt-0.5 flex items-center gap-2", children: [_jsx(Badge, { variant: "outline", className: "text-xs", children: messages.common.serviceTypeLabels[service.serviceType] }), service.duration ? (_jsx("span", { className: "text-xs text-muted-foreground", children: service.duration })) : null, service.capacity ? (_jsx("span", { className: "text-xs text-muted-foreground", children: messages.common.maxPax.replace("{count}", String(service.capacity)) })) : null, !service.active ? (_jsx(Badge, { variant: "secondary", className: "text-xs", children: messages.common.inactive })) : null] })] }), _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Button, { variant: "ghost", size: "sm", onClick: onEdit, "aria-label": messages.common.edit, title: messages.common.edit, children: _jsx(Pencil, { className: "h-3.5 w-3.5" }) }), _jsx(Button, { variant: "ghost", size: "sm", onClick: onDelete, "aria-label": messages.common.delete, title: messages.common.delete, children: _jsx(Trash2, { className: "h-3.5 w-3.5" }) })] })] }), expanded ? (_jsxs("div", { className: "border-t bg-muted/30 p-3", children: [_jsxs("div", { className: "mb-2 flex items-center justify-between", children: [_jsx("p", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: messages.supplierServiceRow.rates }), _jsxs(Button, { variant: "outline", size: "sm", onClick: onAddRate, children: [_jsx(Plus, { className: "mr-1 h-3 w-3" }), messages.supplierServiceRow.addRate] })] }), resolvedRates.length === 0 ? (_jsx("p", { className: "py-2 text-center text-xs text-muted-foreground", children: messages.supplierServiceRow.noRates })) : (_jsx("div", { className: "rounded border bg-background", children: _jsxs("table", { className: "w-full text-xs", children: [_jsx("thead", { children: _jsxs("tr", { className: "border-b text-muted-foreground", children: [_jsx("th", { className: "p-2 text-left font-medium", children: messages.supplierServiceRow.columns.name }), _jsx("th", { className: "p-2 text-left font-medium", children: messages.supplierServiceRow.columns.amount }), _jsx("th", { className: "p-2 text-left font-medium", children: messages.supplierServiceRow.columns.unit }), _jsx("th", { className: "p-2 text-left font-medium", children: messages.supplierServiceRow.columns.valid }), _jsx("th", { className: "p-2 text-left font-medium", children: messages.supplierServiceRow.columns.pax }), _jsx("th", { className: "w-16 p-2" })] }) }), _jsx("tbody", { children: resolvedRates.map((rate) => (_jsxs("tr", { className: "border-b last:border-b-0", children: [_jsx("td", { className: "p-2", children: rate.name }), _jsx("td", { className: "p-2 font-mono", children: i18n.formatCurrency(rate.amountCents / 100, rate.currency) }), _jsx("td", { className: "p-2", children: messages.common.rateUnitLabels[rate.unit] }), _jsx("td", { className: "p-2", children: rate.validFrom || rate.validTo
|
|
14
|
+
? `${rate.validFrom ?? messages.supplierServiceRow.validFallback} — ${rate.validTo ?? messages.supplierServiceRow.validFallback}`
|
|
15
|
+
: messages.common.none }), _jsx("td", { className: "p-2", children: rate.minPax || rate.maxPax
|
|
16
|
+
? `${rate.minPax ?? messages.common.unknown}-${rate.maxPax ?? messages.common.unknown}`
|
|
17
|
+
: messages.common.none }), _jsx("td", { className: "p-2", children: _jsxs("div", { className: "flex items-center gap-1", children: [_jsx("button", { type: "button", onClick: () => onEditRate(rate), "aria-label": messages.common.edit, title: messages.common.edit, className: "text-muted-foreground hover:text-foreground", children: _jsx(Pencil, { className: "h-3 w-3" }) }), _jsx("button", { type: "button", onClick: () => onDeleteRate(rate.id), "aria-label": messages.common.delete, title: messages.common.delete, className: "text-muted-foreground hover:text-destructive", children: _jsx(Trash2, { className: "h-3 w-3" }) })] }) })] }, rate.id))) })] }) }))] })) : null] }));
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Supplier } from "../index.js";
|
|
2
|
+
export type SuppliersPageProps = {
|
|
3
|
+
pageSize?: number;
|
|
4
|
+
onSupplierOpen?: (supplier: Supplier) => void;
|
|
5
|
+
onSupplierCreated?: (supplier: Supplier) => void;
|
|
6
|
+
initialSearch?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function SuppliersPage({ pageSize, onSupplierOpen, onSupplierCreated, initialSearch, className, }?: SuppliersPageProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=suppliers-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suppliers-page.d.ts","sourceRoot":"","sources":["../../../src/suppliers/components/suppliers-page.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAGL,KAAK,QAAQ,EAKd,MAAM,aAAa,CAAA;AAMpB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAA;IAC7C,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAA;IAChD,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,aAAa,CAAC,EAC5B,QAAa,EACb,cAAc,EACd,iBAAiB,EACjB,aAAkB,EAClB,SAAS,GACV,GAAE,kBAAuB,2CA6TzB"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Badge, Button, Input, Label, Popover, PopoverContent, PopoverTrigger, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@voyant-travel/ui/components";
|
|
4
|
+
import { CurrencyCombobox } from "@voyant-travel/ui/components/currency-combobox";
|
|
5
|
+
import { cn } from "@voyant-travel/ui/lib/utils";
|
|
6
|
+
import { ArrowDown, ArrowUp, ListFilter, Plus, Search, X } from "lucide-react";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { useSuppliersUiMessagesOrDefault } from "../i18n/index.js";
|
|
9
|
+
import { SUPPLIER_STATUSES, SUPPLIER_TYPES, statusVariant, useSuppliers, } from "../index.js";
|
|
10
|
+
import { formatMessage } from "./message-format.js";
|
|
11
|
+
import { SupplierDialog } from "./supplier-dialog.js";
|
|
12
|
+
const ALL = "__all__";
|
|
13
|
+
export function SuppliersPage({ pageSize = 25, onSupplierOpen, onSupplierCreated, initialSearch = "", className, } = {}) {
|
|
14
|
+
const messages = useSuppliersUiMessagesOrDefault();
|
|
15
|
+
const [search, setSearch] = React.useState(initialSearch);
|
|
16
|
+
const [type, setType] = React.useState(ALL);
|
|
17
|
+
const [status, setStatus] = React.useState(ALL);
|
|
18
|
+
const [country, setCountry] = React.useState("");
|
|
19
|
+
const [currency, setCurrency] = React.useState("");
|
|
20
|
+
const [sortBy, setSortBy] = React.useState("name");
|
|
21
|
+
const [sortDir, setSortDir] = React.useState("asc");
|
|
22
|
+
const [pageIndex, setPageIndex] = React.useState(0);
|
|
23
|
+
const [dialogOpen, setDialogOpen] = React.useState(false);
|
|
24
|
+
const [filtersOpen, setFiltersOpen] = React.useState(false);
|
|
25
|
+
const activeFilterCount = (type !== ALL ? 1 : 0) +
|
|
26
|
+
(status !== ALL ? 1 : 0) +
|
|
27
|
+
(country !== "" ? 1 : 0) +
|
|
28
|
+
(currency !== "" ? 1 : 0);
|
|
29
|
+
const hasActiveFilters = activeFilterCount > 0 || search !== "";
|
|
30
|
+
const query = useSuppliers({
|
|
31
|
+
limit: pageSize,
|
|
32
|
+
offset: pageIndex * pageSize,
|
|
33
|
+
search: search || undefined,
|
|
34
|
+
type: type === ALL ? undefined : type,
|
|
35
|
+
status: status === ALL ? undefined : status,
|
|
36
|
+
country: country || undefined,
|
|
37
|
+
defaultCurrency: currency || undefined,
|
|
38
|
+
sortBy,
|
|
39
|
+
sortDir,
|
|
40
|
+
});
|
|
41
|
+
const rows = query.data?.data ?? [];
|
|
42
|
+
const total = query.data?.total ?? 0;
|
|
43
|
+
const pageCount = Math.max(1, Math.ceil(total / pageSize));
|
|
44
|
+
function toggleSort(field) {
|
|
45
|
+
if (sortBy === field) {
|
|
46
|
+
setSortDir((current) => (current === "asc" ? "desc" : "asc"));
|
|
47
|
+
setPageIndex(0);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
setSortBy(field);
|
|
51
|
+
setSortDir("asc");
|
|
52
|
+
setPageIndex(0);
|
|
53
|
+
}
|
|
54
|
+
function clearFilters() {
|
|
55
|
+
setSearch("");
|
|
56
|
+
setType(ALL);
|
|
57
|
+
setStatus(ALL);
|
|
58
|
+
setCountry("");
|
|
59
|
+
setCurrency("");
|
|
60
|
+
}
|
|
61
|
+
return (_jsxs("div", { "data-slot": "suppliers-page", className: cn("flex flex-col gap-6 p-6", className), children: [_jsxs("div", { children: [_jsx("h1", { className: "text-2xl font-bold tracking-tight", children: messages.suppliersPage.title }), _jsx("p", { className: "text-sm text-muted-foreground", children: messages.suppliersPage.description })] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsxs("div", { className: "relative min-w-[14rem] flex-1", children: [_jsx(Label, { htmlFor: "suppliers-search", className: "sr-only", children: messages.suppliersPage.searchPlaceholder }), _jsx(Search, { className: "absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" }), _jsx(Input, { id: "suppliers-search", value: search, onChange: (event) => {
|
|
62
|
+
setSearch(event.target.value);
|
|
63
|
+
setPageIndex(0);
|
|
64
|
+
}, placeholder: messages.suppliersPage.searchPlaceholder, className: "pl-9" })] }), _jsxs(Popover, { open: filtersOpen, onOpenChange: setFiltersOpen, children: [_jsx(PopoverTrigger, { render: _jsxs(Button, { variant: "outline", size: "default", children: [_jsx(ListFilter, { className: "mr-2 size-4" }), messages.suppliersPage.filters, activeFilterCount > 0 && (_jsx(Badge, { variant: "secondary", className: "ml-2 px-1.5", children: activeFilterCount }))] }) }), _jsx(PopoverContent, { align: "start", className: "w-[20rem] p-4", children: _jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "suppliers-filter-type", children: messages.suppliersPage.filterTypeLabel }), _jsxs(Select, { value: type, onValueChange: (value) => {
|
|
65
|
+
setType(value ?? ALL);
|
|
66
|
+
setPageIndex(0);
|
|
67
|
+
}, children: [_jsx(SelectTrigger, { id: "suppliers-filter-type", className: "w-full", children: _jsx(SelectValue, { children: (value) => value === ALL
|
|
68
|
+
? messages.suppliersPage.allTypes
|
|
69
|
+
: messages.common.supplierTypeLabels[value] }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: ALL, children: messages.suppliersPage.allTypes }), SUPPLIER_TYPES.map((item) => (_jsx(SelectItem, { value: item.value, children: messages.common.supplierTypeLabels[item.value] }, item.value)))] })] })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "suppliers-filter-status", children: messages.suppliersPage.filterStatusLabel }), _jsxs(Select, { value: status, onValueChange: (value) => {
|
|
70
|
+
setStatus(value ?? ALL);
|
|
71
|
+
setPageIndex(0);
|
|
72
|
+
}, children: [_jsx(SelectTrigger, { id: "suppliers-filter-status", className: "w-full", children: _jsx(SelectValue, { children: (value) => value === ALL
|
|
73
|
+
? messages.suppliersPage.allStatuses
|
|
74
|
+
: messages.common.supplierStatusLabels[value] }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: ALL, children: messages.suppliersPage.allStatuses }), SUPPLIER_STATUSES.map((item) => (_jsx(SelectItem, { value: item.value, children: messages.common.supplierStatusLabels[item.value] }, item.value)))] })] })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "suppliers-filter-country", children: messages.suppliersPage.filterCountryLabel }), _jsx(Input, { id: "suppliers-filter-country", value: country, onChange: (event) => {
|
|
75
|
+
setCountry(event.target.value.toUpperCase());
|
|
76
|
+
setPageIndex(0);
|
|
77
|
+
}, placeholder: messages.suppliersPage.countryPlaceholder, maxLength: 2 })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "suppliers-filter-currency", children: messages.suppliersPage.filterCurrencyLabel }), _jsx(CurrencyCombobox, { value: currency || null, onChange: (next) => {
|
|
78
|
+
setCurrency(next ?? "");
|
|
79
|
+
setPageIndex(0);
|
|
80
|
+
}, placeholder: messages.suppliersPage.currencyPlaceholder })] })] }) })] }), hasActiveFilters && (_jsxs(Button, { variant: "ghost", size: "sm", onClick: clearFilters, children: [_jsx(X, { className: "mr-1 size-4" }), messages.suppliersPage.clearFilters] })), _jsx("div", { className: "ml-auto", children: _jsxs(Button, { onClick: () => setDialogOpen(true), children: [_jsx(Plus, { className: "mr-1 size-4" }), messages.suppliersPage.create] }) })] }), _jsx("div", { className: "overflow-hidden rounded-md border", children: _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { className: "bg-muted/40 text-left text-muted-foreground", children: _jsxs("tr", { children: [_jsx(SortableHeader, { label: messages.suppliersPage.columns.name, field: "name", sortBy: sortBy, sortDir: sortDir, onSort: toggleSort }), _jsx(SortableHeader, { label: messages.suppliersPage.columns.type, field: "type", sortBy: sortBy, sortDir: sortDir, onSort: toggleSort }), _jsx(SortableHeader, { label: messages.suppliersPage.columns.status, field: "status", sortBy: sortBy, sortDir: sortDir, onSort: toggleSort }), _jsx("th", { className: "px-4 py-3 font-medium", children: messages.suppliersPage.columns.country }), _jsx(SortableHeader, { label: messages.suppliersPage.columns.currency, field: "defaultCurrency", sortBy: sortBy, sortDir: sortDir, onSort: toggleSort })] }) }), _jsx("tbody", { children: query.isPending ? (_jsx(LoadingRows, { columns: 5, rows: 8 })) : query.isError ? (_jsx(MessageRow, { columns: 5, children: messages.suppliersPage.loadFailed })) : rows.length === 0 ? (_jsx(MessageRow, { columns: 5, children: messages.suppliersPage.empty })) : (rows.map((supplier) => (_jsxs("tr", { className: "border-t transition-colors hover:bg-muted/40", onClick: () => onSupplierOpen?.(supplier), children: [_jsxs("td", { className: "px-4 py-3", children: [_jsx("div", { className: "font-medium", children: supplier.name }), supplier.city && (_jsx("div", { className: "text-xs text-muted-foreground", children: supplier.city }))] }), _jsx("td", { className: "px-4 py-3", children: messages.common.supplierTypeLabels[supplier.type] }), _jsx("td", { className: "px-4 py-3", children: _jsx(Badge, { variant: statusVariant[supplier.status], children: messages.common.supplierStatusLabels[supplier.status] }) }), _jsx("td", { className: "px-4 py-3", children: supplier.country ?? messages.common.none }), _jsx("td", { className: "px-4 py-3", children: supplier.defaultCurrency ?? messages.common.none })] }, supplier.id)))) })] }) }), _jsxs("div", { className: "flex flex-col gap-3 text-sm text-muted-foreground sm:flex-row sm:items-center sm:justify-between", children: [_jsx("div", { children: formatMessage(messages.suppliersPage.summary, { shown: rows.length, total }) }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Button, { type: "button", variant: "outline", size: "sm", disabled: pageIndex === 0 || query.isPending, onClick: () => setPageIndex((current) => Math.max(0, current - 1)), children: messages.suppliersPage.previous }), _jsx("span", { children: formatMessage(messages.suppliersPage.page, {
|
|
81
|
+
page: pageIndex + 1,
|
|
82
|
+
pageCount,
|
|
83
|
+
}) }), _jsx(Button, { type: "button", variant: "outline", size: "sm", disabled: pageIndex + 1 >= pageCount || query.isPending, onClick: () => setPageIndex((current) => current + 1), children: messages.suppliersPage.next })] })] }), _jsx(SupplierDialog, { open: dialogOpen, onOpenChange: setDialogOpen, onSuccess: onSupplierCreated })] }));
|
|
84
|
+
}
|
|
85
|
+
function SortableHeader({ label, field, sortBy, sortDir, onSort, }) {
|
|
86
|
+
return (_jsx("th", { className: "px-4 py-3 font-medium", children: _jsxs(Button, { type: "button", variant: "ghost", size: "sm", onClick: () => onSort(field), children: [label, sortBy === field &&
|
|
87
|
+
(sortDir === "asc" ? _jsx(ArrowUp, { "aria-hidden": "true" }) : _jsx(ArrowDown, { "aria-hidden": "true" }))] }) }));
|
|
88
|
+
}
|
|
89
|
+
function LoadingRows({ rows, columns }) {
|
|
90
|
+
return Array.from({ length: rows }, (_, rowIndex) => `row-${rowIndex}`).map((rowKey) => (_jsx("tr", { className: "border-t", children: Array.from({ length: columns }, (__, columnIndex) => `${rowKey}-cell-${columnIndex}`).map((columnKey) => (_jsx("td", { className: "px-4 py-3", children: _jsx("div", { className: "h-4 w-full max-w-32 animate-pulse rounded bg-muted" }) }, columnKey))) }, rowKey)));
|
|
91
|
+
}
|
|
92
|
+
function MessageRow({ columns, children }) {
|
|
93
|
+
return (_jsx("tr", { children: _jsx("td", { colSpan: columns, className: "px-4 py-10 text-center text-muted-foreground", children: children }) }));
|
|
94
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export declare const SUPPLIER_TYPES: readonly [{
|
|
2
|
+
readonly value: "hotel";
|
|
3
|
+
readonly label: "Hotel";
|
|
4
|
+
}, {
|
|
5
|
+
readonly value: "transfer";
|
|
6
|
+
readonly label: "Transfer";
|
|
7
|
+
}, {
|
|
8
|
+
readonly value: "guide";
|
|
9
|
+
readonly label: "Guide";
|
|
10
|
+
}, {
|
|
11
|
+
readonly value: "experience";
|
|
12
|
+
readonly label: "Experience";
|
|
13
|
+
}, {
|
|
14
|
+
readonly value: "airline";
|
|
15
|
+
readonly label: "Airline";
|
|
16
|
+
}, {
|
|
17
|
+
readonly value: "restaurant";
|
|
18
|
+
readonly label: "Restaurant";
|
|
19
|
+
}, {
|
|
20
|
+
readonly value: "other";
|
|
21
|
+
readonly label: "Other";
|
|
22
|
+
}];
|
|
23
|
+
export declare const SUPPLIER_STATUSES: readonly [{
|
|
24
|
+
readonly value: "active";
|
|
25
|
+
readonly label: "Active";
|
|
26
|
+
}, {
|
|
27
|
+
readonly value: "inactive";
|
|
28
|
+
readonly label: "Inactive";
|
|
29
|
+
}, {
|
|
30
|
+
readonly value: "pending";
|
|
31
|
+
readonly label: "Pending";
|
|
32
|
+
}];
|
|
33
|
+
export declare const SERVICE_TYPES: readonly [{
|
|
34
|
+
readonly value: "accommodation";
|
|
35
|
+
readonly label: "Accommodation";
|
|
36
|
+
}, {
|
|
37
|
+
readonly value: "transfer";
|
|
38
|
+
readonly label: "Transfer";
|
|
39
|
+
}, {
|
|
40
|
+
readonly value: "experience";
|
|
41
|
+
readonly label: "Experience";
|
|
42
|
+
}, {
|
|
43
|
+
readonly value: "guide";
|
|
44
|
+
readonly label: "Guide";
|
|
45
|
+
}, {
|
|
46
|
+
readonly value: "meal";
|
|
47
|
+
readonly label: "Meal";
|
|
48
|
+
}, {
|
|
49
|
+
readonly value: "other";
|
|
50
|
+
readonly label: "Other";
|
|
51
|
+
}];
|
|
52
|
+
export declare const RATE_UNITS: readonly [{
|
|
53
|
+
readonly value: "per_person";
|
|
54
|
+
readonly label: "Per Person";
|
|
55
|
+
}, {
|
|
56
|
+
readonly value: "per_group";
|
|
57
|
+
readonly label: "Per Group";
|
|
58
|
+
}, {
|
|
59
|
+
readonly value: "per_night";
|
|
60
|
+
readonly label: "Per Night";
|
|
61
|
+
}, {
|
|
62
|
+
readonly value: "per_vehicle";
|
|
63
|
+
readonly label: "Per Vehicle";
|
|
64
|
+
}, {
|
|
65
|
+
readonly value: "flat";
|
|
66
|
+
readonly label: "Flat";
|
|
67
|
+
}];
|
|
68
|
+
export declare const statusVariant: Record<string, "default" | "secondary" | "outline" | "destructive">;
|
|
69
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/suppliers/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;EAQjB,CAAA;AAEV,eAAO,MAAM,iBAAiB;;;;;;;;;EAIpB,CAAA;AAEV,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;EAOhB,CAAA;AAEV,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;EAMb,CAAA;AAEV,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,aAAa,CAI7F,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const SUPPLIER_TYPES = [
|
|
2
|
+
{ value: "hotel", label: "Hotel" },
|
|
3
|
+
{ value: "transfer", label: "Transfer" },
|
|
4
|
+
{ value: "guide", label: "Guide" },
|
|
5
|
+
{ value: "experience", label: "Experience" },
|
|
6
|
+
{ value: "airline", label: "Airline" },
|
|
7
|
+
{ value: "restaurant", label: "Restaurant" },
|
|
8
|
+
{ value: "other", label: "Other" },
|
|
9
|
+
];
|
|
10
|
+
export const SUPPLIER_STATUSES = [
|
|
11
|
+
{ value: "active", label: "Active" },
|
|
12
|
+
{ value: "inactive", label: "Inactive" },
|
|
13
|
+
{ value: "pending", label: "Pending" },
|
|
14
|
+
];
|
|
15
|
+
export const SERVICE_TYPES = [
|
|
16
|
+
{ value: "accommodation", label: "Accommodation" },
|
|
17
|
+
{ value: "transfer", label: "Transfer" },
|
|
18
|
+
{ value: "experience", label: "Experience" },
|
|
19
|
+
{ value: "guide", label: "Guide" },
|
|
20
|
+
{ value: "meal", label: "Meal" },
|
|
21
|
+
{ value: "other", label: "Other" },
|
|
22
|
+
];
|
|
23
|
+
export const RATE_UNITS = [
|
|
24
|
+
{ value: "per_person", label: "Per Person" },
|
|
25
|
+
{ value: "per_group", label: "Per Group" },
|
|
26
|
+
{ value: "per_night", label: "Per Night" },
|
|
27
|
+
{ value: "per_vehicle", label: "Per Vehicle" },
|
|
28
|
+
{ value: "flat", label: "Flat" },
|
|
29
|
+
];
|
|
30
|
+
export const statusVariant = {
|
|
31
|
+
active: "default",
|
|
32
|
+
inactive: "secondary",
|
|
33
|
+
pending: "outline",
|
|
34
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./use-supplier.js";
|
|
2
|
+
export * from "./use-supplier-mutation.js";
|
|
3
|
+
export * from "./use-supplier-note-mutation.js";
|
|
4
|
+
export * from "./use-supplier-notes.js";
|
|
5
|
+
export * from "./use-supplier-rate-mutation.js";
|
|
6
|
+
export * from "./use-supplier-service-mutation.js";
|
|
7
|
+
export * from "./use-supplier-service-rates.js";
|
|
8
|
+
export * from "./use-supplier-services.js";
|
|
9
|
+
export * from "./use-suppliers.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/suppliers/hooks/index.ts"],"names":[],"mappings":"AAEA,cAAc,mBAAmB,CAAA;AACjC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,yBAAyB,CAAA;AACvC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,oCAAoC,CAAA;AAClD,cAAc,iCAAiC,CAAA;AAC/C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
export * from "./use-supplier.js";
|
|
3
|
+
export * from "./use-supplier-mutation.js";
|
|
4
|
+
export * from "./use-supplier-note-mutation.js";
|
|
5
|
+
export * from "./use-supplier-notes.js";
|
|
6
|
+
export * from "./use-supplier-rate-mutation.js";
|
|
7
|
+
export * from "./use-supplier-service-mutation.js";
|
|
8
|
+
export * from "./use-supplier-service-rates.js";
|
|
9
|
+
export * from "./use-supplier-services.js";
|
|
10
|
+
export * from "./use-suppliers.js";
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type SupplierCustomerPaymentPolicy } from "../schemas.js";
|
|
2
|
+
export interface CreateSupplierInput {
|
|
3
|
+
name: string;
|
|
4
|
+
type: "hotel" | "transfer" | "guide" | "experience" | "airline" | "restaurant" | "other";
|
|
5
|
+
status?: "active" | "inactive" | "pending";
|
|
6
|
+
description?: string | null;
|
|
7
|
+
email?: string | null;
|
|
8
|
+
phone?: string | null;
|
|
9
|
+
website?: string | null;
|
|
10
|
+
address?: string | null;
|
|
11
|
+
city?: string | null;
|
|
12
|
+
country?: string | null;
|
|
13
|
+
defaultCurrency?: string | null;
|
|
14
|
+
contactName?: string | null;
|
|
15
|
+
contactEmail?: string | null;
|
|
16
|
+
contactPhone?: string | null;
|
|
17
|
+
paymentTermsDays?: number | null;
|
|
18
|
+
reservationTimeoutMinutes?: number | null;
|
|
19
|
+
customerPaymentPolicy?: SupplierCustomerPaymentPolicy | null;
|
|
20
|
+
tags?: string[];
|
|
21
|
+
}
|
|
22
|
+
export type UpdateSupplierInput = Partial<CreateSupplierInput>;
|
|
23
|
+
export declare function useSupplierMutation(): {
|
|
24
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
type: "other" | "guide" | "hotel" | "transfer" | "experience" | "airline" | "restaurant";
|
|
28
|
+
status: "active" | "inactive" | "pending";
|
|
29
|
+
description: string | null;
|
|
30
|
+
email: string | null;
|
|
31
|
+
phone: string | null;
|
|
32
|
+
website: string | null;
|
|
33
|
+
address: string | null;
|
|
34
|
+
city: string | null;
|
|
35
|
+
country: string | null;
|
|
36
|
+
defaultCurrency: string | null;
|
|
37
|
+
contactName: string | null;
|
|
38
|
+
contactEmail: string | null;
|
|
39
|
+
contactPhone: string | null;
|
|
40
|
+
tags: string[];
|
|
41
|
+
createdAt: string;
|
|
42
|
+
updatedAt: string;
|
|
43
|
+
paymentTermsDays?: number | null | undefined;
|
|
44
|
+
reservationTimeoutMinutes?: number | null | undefined;
|
|
45
|
+
customerPaymentPolicy?: {
|
|
46
|
+
deposit: {
|
|
47
|
+
kind: "none" | "percent" | "fixed_cents";
|
|
48
|
+
percent?: number | undefined;
|
|
49
|
+
amountCents?: number | undefined;
|
|
50
|
+
};
|
|
51
|
+
minDaysBeforeDepartureForDeposit: number;
|
|
52
|
+
balanceDueDaysBeforeDeparture: number;
|
|
53
|
+
balanceDueMinDaysFromNow: number;
|
|
54
|
+
} | null | undefined;
|
|
55
|
+
}, Error, CreateSupplierInput, unknown>;
|
|
56
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
type: "other" | "guide" | "hotel" | "transfer" | "experience" | "airline" | "restaurant";
|
|
60
|
+
status: "active" | "inactive" | "pending";
|
|
61
|
+
description: string | null;
|
|
62
|
+
email: string | null;
|
|
63
|
+
phone: string | null;
|
|
64
|
+
website: string | null;
|
|
65
|
+
address: string | null;
|
|
66
|
+
city: string | null;
|
|
67
|
+
country: string | null;
|
|
68
|
+
defaultCurrency: string | null;
|
|
69
|
+
contactName: string | null;
|
|
70
|
+
contactEmail: string | null;
|
|
71
|
+
contactPhone: string | null;
|
|
72
|
+
tags: string[];
|
|
73
|
+
createdAt: string;
|
|
74
|
+
updatedAt: string;
|
|
75
|
+
paymentTermsDays?: number | null | undefined;
|
|
76
|
+
reservationTimeoutMinutes?: number | null | undefined;
|
|
77
|
+
customerPaymentPolicy?: {
|
|
78
|
+
deposit: {
|
|
79
|
+
kind: "none" | "percent" | "fixed_cents";
|
|
80
|
+
percent?: number | undefined;
|
|
81
|
+
amountCents?: number | undefined;
|
|
82
|
+
};
|
|
83
|
+
minDaysBeforeDepartureForDeposit: number;
|
|
84
|
+
balanceDueDaysBeforeDeparture: number;
|
|
85
|
+
balanceDueMinDaysFromNow: number;
|
|
86
|
+
} | null | undefined;
|
|
87
|
+
}, Error, {
|
|
88
|
+
id: string;
|
|
89
|
+
input: UpdateSupplierInput;
|
|
90
|
+
}, unknown>;
|
|
91
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
92
|
+
success: boolean;
|
|
93
|
+
}, Error, string, unknown>;
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=use-supplier-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-supplier-mutation.d.ts","sourceRoot":"","sources":["../../../src/suppliers/hooks/use-supplier-mutation.ts"],"names":[],"mappings":"AAOA,OAAO,EAEL,KAAK,6BAA6B,EAEnC,MAAM,eAAe,CAAA;AAEtB,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,OAAO,CAAA;IACxF,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAA;IAC1C,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,yBAAyB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzC,qBAAqB,CAAC,EAAE,6BAA6B,GAAG,IAAI,CAAA;IAC5D,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;AAE9D,wBAAgB,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBS,MAAM;eAAS,mBAAmB;;;;;EAiC7E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantSuppliersContext } from "../provider.js";
|
|
5
|
+
import { suppliersQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { deleteSuccessResponse, supplierDetailResponse, } from "../schemas.js";
|
|
7
|
+
export function useSupplierMutation() {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantSuppliersContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const create = useMutation({
|
|
11
|
+
mutationFn: async (input) => {
|
|
12
|
+
const { data } = await fetchWithValidation("/v1/suppliers", supplierDetailResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
13
|
+
return data;
|
|
14
|
+
},
|
|
15
|
+
onSuccess: (data) => {
|
|
16
|
+
void queryClient.invalidateQueries({ queryKey: suppliersQueryKeys.suppliers() });
|
|
17
|
+
queryClient.setQueryData(suppliersQueryKeys.supplierDetail(data.id), { data });
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const update = useMutation({
|
|
21
|
+
mutationFn: async ({ id, input }) => {
|
|
22
|
+
const { data } = await fetchWithValidation(`/v1/suppliers/${id}`, supplierDetailResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
23
|
+
return data;
|
|
24
|
+
},
|
|
25
|
+
onSuccess: (data) => {
|
|
26
|
+
void queryClient.invalidateQueries({ queryKey: suppliersQueryKeys.suppliers() });
|
|
27
|
+
queryClient.setQueryData(suppliersQueryKeys.supplierDetail(data.id), { data });
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const remove = useMutation({
|
|
31
|
+
mutationFn: async (id) => fetchWithValidation(`/v1/suppliers/${id}`, deleteSuccessResponse, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
32
|
+
onSuccess: (_result, id) => {
|
|
33
|
+
void queryClient.invalidateQueries({ queryKey: suppliersQueryKeys.suppliers() });
|
|
34
|
+
queryClient.removeQueries({ queryKey: suppliersQueryKeys.supplierDetail(id) });
|
|
35
|
+
queryClient.removeQueries({ queryKey: suppliersQueryKeys.supplierServices(id) });
|
|
36
|
+
queryClient.removeQueries({ queryKey: suppliersQueryKeys.supplierNotes(id) });
|
|
37
|
+
void queryClient.invalidateQueries({ queryKey: suppliersQueryKeys.rates() });
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
return { create, update, remove };
|
|
41
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface CreateSupplierNoteInput {
|
|
2
|
+
content: string;
|
|
3
|
+
}
|
|
4
|
+
export declare function useSupplierNoteMutation(supplierId: string): {
|
|
5
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
6
|
+
id: string;
|
|
7
|
+
supplierId: string;
|
|
8
|
+
authorId: string;
|
|
9
|
+
content: string;
|
|
10
|
+
createdAt: string;
|
|
11
|
+
}, Error, CreateSupplierNoteInput, unknown>;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=use-supplier-note-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-supplier-note-mutation.d.ts","sourceRoot":"","sources":["../../../src/suppliers/hooks/use-supplier-note-mutation.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM;;;;;;;;EAoBzD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantSuppliersContext } from "../provider.js";
|
|
5
|
+
import { suppliersQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { supplierNoteResponse } from "../schemas.js";
|
|
7
|
+
export function useSupplierNoteMutation(supplierId) {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantSuppliersContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const create = useMutation({
|
|
11
|
+
mutationFn: async (input) => {
|
|
12
|
+
const { data } = await fetchWithValidation(`/v1/suppliers/${supplierId}/notes`, supplierNoteResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
13
|
+
return data;
|
|
14
|
+
},
|
|
15
|
+
onSuccess: () => {
|
|
16
|
+
void queryClient.invalidateQueries({ queryKey: suppliersQueryKeys.supplierNotes(supplierId) });
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
return { create };
|
|
20
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface UseSupplierNotesOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useSupplierNotes(supplierId: string, options?: UseSupplierNotesOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
data: {
|
|
6
|
+
id: string;
|
|
7
|
+
supplierId: string;
|
|
8
|
+
authorId: string;
|
|
9
|
+
content: string;
|
|
10
|
+
createdAt: string;
|
|
11
|
+
}[];
|
|
12
|
+
}, Error>;
|
|
13
|
+
//# sourceMappingURL=use-supplier-notes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-supplier-notes.d.ts","sourceRoot":"","sources":["../../../src/suppliers/hooks/use-supplier-notes.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B;;;;;;;;UAOzF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantSuppliersContext } from "../provider.js";
|
|
4
|
+
import { getSupplierNotesQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useSupplierNotes(supplierId, options = {}) {
|
|
6
|
+
const client = useVoyantSuppliersContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getSupplierNotesQueryOptions(client, supplierId),
|
|
10
|
+
enabled: enabled && !!supplierId,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export interface CreateSupplierRateInput {
|
|
2
|
+
name: string;
|
|
3
|
+
currency: string;
|
|
4
|
+
amountCents: number;
|
|
5
|
+
unit: "per_person" | "per_group" | "per_night" | "per_vehicle" | "flat";
|
|
6
|
+
validFrom?: string | null;
|
|
7
|
+
validTo?: string | null;
|
|
8
|
+
minPax?: number | null;
|
|
9
|
+
maxPax?: number | null;
|
|
10
|
+
notes?: string | null;
|
|
11
|
+
}
|
|
12
|
+
export type UpdateSupplierRateInput = Partial<CreateSupplierRateInput>;
|
|
13
|
+
export declare function useSupplierRateMutation(supplierId: string): {
|
|
14
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
15
|
+
id: string;
|
|
16
|
+
serviceId: string;
|
|
17
|
+
name: string;
|
|
18
|
+
currency: string;
|
|
19
|
+
amountCents: number;
|
|
20
|
+
unit: "flat" | "per_person" | "per_group" | "per_night" | "per_vehicle";
|
|
21
|
+
validFrom: string | null;
|
|
22
|
+
validTo: string | null;
|
|
23
|
+
minPax: number | null;
|
|
24
|
+
maxPax: number | null;
|
|
25
|
+
notes: string | null;
|
|
26
|
+
createdAt: string;
|
|
27
|
+
}, Error, {
|
|
28
|
+
serviceId: string;
|
|
29
|
+
input: CreateSupplierRateInput;
|
|
30
|
+
}, unknown>;
|
|
31
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
32
|
+
id: string;
|
|
33
|
+
serviceId: string;
|
|
34
|
+
name: string;
|
|
35
|
+
currency: string;
|
|
36
|
+
amountCents: number;
|
|
37
|
+
unit: "flat" | "per_person" | "per_group" | "per_night" | "per_vehicle";
|
|
38
|
+
validFrom: string | null;
|
|
39
|
+
validTo: string | null;
|
|
40
|
+
minPax: number | null;
|
|
41
|
+
maxPax: number | null;
|
|
42
|
+
notes: string | null;
|
|
43
|
+
createdAt: string;
|
|
44
|
+
}, Error, {
|
|
45
|
+
serviceId: string;
|
|
46
|
+
rateId: string;
|
|
47
|
+
input: UpdateSupplierRateInput;
|
|
48
|
+
}, unknown>;
|
|
49
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
50
|
+
success: boolean;
|
|
51
|
+
}, Error, {
|
|
52
|
+
serviceId: string;
|
|
53
|
+
rateId: string;
|
|
54
|
+
}, unknown>;
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=use-supplier-rate-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-supplier-rate-mutation.d.ts","sourceRoot":"","sources":["../../../src/suppliers/hooks/use-supplier-rate-mutation.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,YAAY,GAAG,WAAW,GAAG,WAAW,GAAG,aAAa,GAAG,MAAM,CAAA;IACvE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB;AAED,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;AAEtE,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM;;;;;;;;;;;;;;;mBASzC,MAAM;eACV,uBAAuB;;;;;;;;;;;;;;;;mBAuBnB,MAAM;gBACT,MAAM;eACP,uBAAuB;;;;;mBAkBuB,MAAM;gBAAU,MAAM;;EAehF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantSuppliersContext } from "../provider.js";
|
|
5
|
+
import { suppliersQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { deleteSuccessResponse, supplierRateResponse } from "../schemas.js";
|
|
7
|
+
export function useSupplierRateMutation(supplierId) {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantSuppliersContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const create = useMutation({
|
|
11
|
+
mutationFn: async ({ serviceId, input, }) => {
|
|
12
|
+
const { data } = await fetchWithValidation(`/v1/suppliers/${supplierId}/services/${serviceId}/rates`, supplierRateResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
13
|
+
return data;
|
|
14
|
+
},
|
|
15
|
+
onSuccess: (_data, { serviceId }) => {
|
|
16
|
+
void queryClient.invalidateQueries({
|
|
17
|
+
queryKey: suppliersQueryKeys.supplierServiceRates(supplierId, serviceId),
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
const update = useMutation({
|
|
22
|
+
mutationFn: async ({ serviceId, rateId, input, }) => {
|
|
23
|
+
const { data } = await fetchWithValidation(`/v1/suppliers/${supplierId}/services/${serviceId}/rates/${rateId}`, supplierRateResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
24
|
+
return data;
|
|
25
|
+
},
|
|
26
|
+
onSuccess: (_data, { serviceId }) => {
|
|
27
|
+
void queryClient.invalidateQueries({
|
|
28
|
+
queryKey: suppliersQueryKeys.supplierServiceRates(supplierId, serviceId),
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const remove = useMutation({
|
|
33
|
+
mutationFn: async ({ serviceId, rateId }) => fetchWithValidation(`/v1/suppliers/${supplierId}/services/${serviceId}/rates/${rateId}`, deleteSuccessResponse, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
34
|
+
onSuccess: (_data, { serviceId }) => {
|
|
35
|
+
void queryClient.invalidateQueries({
|
|
36
|
+
queryKey: suppliersQueryKeys.supplierServiceRates(supplierId, serviceId),
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
return { create, update, remove };
|
|
41
|
+
}
|