@voyantjs/bookings-ui 0.75.0 → 0.75.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"booking-quick-view-sheet.d.ts","sourceRoot":"","sources":["../../src/components/booking-quick-view-sheet.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,0BAA0B,CAAA;AAuBjC,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACpC,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC;;+BAE2B;IAC3B,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAA;IAC7C,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,MAAM,GACP,EAAE,0BAA0B,2CA6D5B"}
1
+ {"version":3,"file":"booking-quick-view-sheet.d.ts","sourceRoot":"","sources":["../../src/components/booking-quick-view-sheet.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,0BAA0B,CAAA;AA0CjC,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACpC,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC;;+BAE2B;IAC3B,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAA;IAC7C,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,MAAM,GACP,EAAE,0BAA0B,2CA6D5B"}
@@ -2,10 +2,10 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { bookingStatusBadgeVariant, useBooking, useTravelers, } from "@voyantjs/bookings-react";
4
4
  import { useOrganization, usePerson } from "@voyantjs/crm-react";
5
- import { useAdminBookingPayments, useBookingPaymentSchedules, useInvoices, } from "@voyantjs/finance-react";
6
- import { useLegalContracts } from "@voyantjs/legal-react";
5
+ import { useAdminBookingPayments, useBookingPaymentSchedules, useInvoiceAttachments, useInvoices, useVoyantFinanceContext, } from "@voyantjs/finance-react";
6
+ import { useLegalContractAttachments, useLegalContracts, useVoyantLegalContext, } from "@voyantjs/legal-react";
7
7
  import { Badge, Button, Sheet, SheetBody, SheetContent, SheetFooter, SheetHeader, SheetTitle, } from "@voyantjs/ui/components";
8
- import { ArrowRight, Calendar, CreditCard, FileText, Phone, ScrollText, Users } from "lucide-react";
8
+ import { ArrowRight, Calendar, CreditCard, ExternalLink, FileText, Phone, ScrollText, Users, } from "lucide-react";
9
9
  import { useBookingsUiI18nOrDefault, useBookingsUiMessagesOrDefault } from "../i18n/index.js";
10
10
  export function BookingQuickViewSheet({ bookingId, open, onOpenChange, onViewFull, locale, }) {
11
11
  const i18n = useBookingsUiI18nOrDefault();
@@ -87,11 +87,17 @@ function InvoicesSection({ booking }) {
87
87
  const quick = messages.bookingQuickViewSheet;
88
88
  const { data } = useInvoices({ bookingId: booking.id, limit: 20 });
89
89
  const invoices = data?.data ?? [];
90
- return (_jsx(Section, { icon: _jsx(FileText, { className: "h-3.5 w-3.5" }), label: quick.sectionInvoices, count: String(invoices.length), children: invoices.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: quick.invoicesEmpty })) : (_jsx("ul", { className: "flex flex-col", children: invoices.map((invoice) => {
91
- const statusLabel = quick.invoiceStatusLabels[invoice.status] ??
92
- invoice.status;
93
- return (_jsxs("li", { className: "flex items-center justify-between gap-3 py-1 font-mono text-sm", children: [_jsx("span", { className: "truncate", children: invoice.invoiceNumber }), _jsx(Badge, { variant: "outline", className: "font-sans text-[10px] uppercase", children: statusLabel })] }, invoice.id));
94
- }) })) }));
90
+ return (_jsx(Section, { icon: _jsx(FileText, { className: "h-3.5 w-3.5" }), label: quick.sectionInvoices, count: String(invoices.length), children: invoices.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: quick.invoicesEmpty })) : (_jsx("ul", { className: "flex flex-col", children: invoices.map((invoice) => (_jsx(InvoiceRow, { invoice: invoice }, invoice.id))) })) }));
91
+ }
92
+ function InvoiceRow({ invoice }) {
93
+ const messages = useBookingsUiMessagesOrDefault();
94
+ const quick = messages.bookingQuickViewSheet;
95
+ const { baseUrl } = useVoyantFinanceContext();
96
+ const { data } = useInvoiceAttachments(invoice.id);
97
+ const attachment = latestAttachment(data?.data ?? []);
98
+ const statusLabel = quick.invoiceStatusLabels[invoice.status] ??
99
+ invoice.status;
100
+ return (_jsxs("li", { className: "flex items-center justify-between gap-3 py-1 font-mono text-sm", children: [_jsx(LinkedRowTitle, { href: attachment ? getDefaultInvoiceAttachmentDownloadHref(baseUrl, attachment) : null, label: invoice.invoiceNumber }), _jsx(Badge, { variant: "outline", className: "shrink-0 font-sans text-[10px] uppercase", children: statusLabel })] }));
95
101
  }
96
102
  function PaymentScheduleSection({ booking, locale }) {
97
103
  const messages = useBookingsUiMessagesOrDefault();
@@ -111,10 +117,37 @@ function ContractsSection({ bookingId }) {
111
117
  const quick = messages.bookingQuickViewSheet;
112
118
  const { data } = useLegalContracts({ bookingId, limit: 20 });
113
119
  const contracts = data?.data ?? [];
114
- return (_jsx(Section, { icon: _jsx(ScrollText, { className: "h-3.5 w-3.5" }), label: quick.sectionContracts, count: String(contracts.length), children: contracts.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: quick.contractsEmpty })) : (_jsx("ul", { className: "flex flex-col", children: contracts.map((contract) => {
115
- const statusLabel = quick.contractStatusLabels[contract.status] ?? contract.status;
116
- return (_jsxs("li", { className: "flex items-center justify-between gap-3 py-1 text-sm", children: [_jsx("span", { className: "truncate font-mono", children: contract.contractNumber ?? contract.title }), _jsx(Badge, { variant: "outline", className: "font-sans text-[10px] uppercase", children: statusLabel })] }, contract.id));
117
- }) })) }));
120
+ return (_jsx(Section, { icon: _jsx(ScrollText, { className: "h-3.5 w-3.5" }), label: quick.sectionContracts, count: String(contracts.length), children: contracts.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: quick.contractsEmpty })) : (_jsx("ul", { className: "flex flex-col", children: contracts.map((contract) => (_jsx(ContractRow, { contract: contract }, contract.id))) })) }));
121
+ }
122
+ function ContractRow({ contract }) {
123
+ const messages = useBookingsUiMessagesOrDefault();
124
+ const quick = messages.bookingQuickViewSheet;
125
+ const { baseUrl } = useVoyantLegalContext();
126
+ const { data } = useLegalContractAttachments({ contractId: contract.id });
127
+ const attachment = latestAttachment(data);
128
+ const statusLabel = quick.contractStatusLabels[contract.status] ??
129
+ contract.status;
130
+ return (_jsxs("li", { className: "flex items-center justify-between gap-3 py-1 text-sm", children: [_jsx(LinkedRowTitle, { href: attachment ? getDefaultLegalContractAttachmentDownloadHref(baseUrl, attachment) : null, label: contract.contractNumber ?? contract.title }), _jsx(Badge, { variant: "outline", className: "shrink-0 font-sans text-[10px] uppercase", children: statusLabel })] }));
131
+ }
132
+ function LinkedRowTitle({ href, label }) {
133
+ if (!href) {
134
+ return _jsx("span", { className: "min-w-0 truncate font-mono", children: label });
135
+ }
136
+ return (_jsxs("a", { href: href, target: "_blank", rel: "noopener noreferrer", className: "inline-flex min-w-0 items-center gap-1 font-mono text-primary hover:underline", children: [_jsx("span", { className: "truncate", children: label }), _jsx(ExternalLink, { className: "h-3 w-3 shrink-0", "aria-hidden": "true" })] }));
137
+ }
138
+ function latestAttachment(attachments) {
139
+ return (attachments ?? []).reduce((latest, attachment) => !latest || attachment.createdAt > latest.createdAt ? attachment : latest, null);
140
+ }
141
+ function withApiBaseUrl(baseUrl, path) {
142
+ const trimmedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
143
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`;
144
+ return `${trimmedBase}${normalizedPath}`;
145
+ }
146
+ function getDefaultInvoiceAttachmentDownloadHref(baseUrl, attachment) {
147
+ return withApiBaseUrl(baseUrl, `/v1/admin/finance/invoice-attachments/${attachment.id}/download`);
148
+ }
149
+ function getDefaultLegalContractAttachmentDownloadHref(baseUrl, attachment) {
150
+ return withApiBaseUrl(baseUrl, `/v1/admin/legal/contracts/attachments/${attachment.id}/download`);
118
151
  }
119
152
  function Section({ icon, label, count, children, }) {
120
153
  return (_jsxs("section", { className: "flex flex-col gap-2 border-t pt-4", children: [_jsxs("header", { className: "flex items-center justify-between gap-2 text-xs font-medium text-muted-foreground uppercase tracking-wide", children: [_jsxs("span", { className: "flex items-center gap-1.5", children: [icon, label] }), _jsx("span", { className: "font-mono normal-case", children: count })] }), children] }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/bookings-ui",
3
- "version": "0.75.0",
3
+ "version": "0.75.3",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -51,23 +51,23 @@
51
51
  "react-dom": "^19.0.0",
52
52
  "react-hook-form": "^7.60.0",
53
53
  "zod": "^4.3.6",
54
- "@voyantjs/availability-react": "0.75.0",
55
- "@voyantjs/bookings-react": "0.75.0",
56
- "@voyantjs/catalog": "0.75.0",
57
- "@voyantjs/catalog-react": "0.75.0",
58
- "@voyantjs/crm-react": "0.75.0",
59
- "@voyantjs/crm-ui": "0.75.0",
60
- "@voyantjs/extras-react": "0.75.0",
61
- "@voyantjs/finance-react": "0.75.0",
62
- "@voyantjs/identity-react": "0.75.0",
63
- "@voyantjs/legal-react": "0.75.0",
64
- "@voyantjs/pricing-react": "0.75.0",
65
- "@voyantjs/products-react": "0.75.0",
66
- "@voyantjs/suppliers-react": "0.75.0",
67
- "@voyantjs/ui": "0.75.0"
54
+ "@voyantjs/availability-react": "0.75.3",
55
+ "@voyantjs/bookings-react": "0.75.3",
56
+ "@voyantjs/catalog": "0.75.3",
57
+ "@voyantjs/catalog-react": "0.75.3",
58
+ "@voyantjs/crm-react": "0.75.3",
59
+ "@voyantjs/crm-ui": "0.75.3",
60
+ "@voyantjs/extras-react": "0.75.3",
61
+ "@voyantjs/finance-react": "0.75.3",
62
+ "@voyantjs/identity-react": "0.75.3",
63
+ "@voyantjs/legal-react": "0.75.3",
64
+ "@voyantjs/pricing-react": "0.75.3",
65
+ "@voyantjs/products-react": "0.75.3",
66
+ "@voyantjs/suppliers-react": "0.75.3",
67
+ "@voyantjs/ui": "0.75.3"
68
68
  },
69
69
  "dependencies": {
70
- "@voyantjs/i18n": "0.75.0"
70
+ "@voyantjs/i18n": "0.75.3"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@tanstack/react-query": "^5.100.11",
@@ -80,20 +80,20 @@
80
80
  "typescript": "^6.0.2",
81
81
  "vitest": "^4.1.2",
82
82
  "zod": "^4.3.6",
83
- "@voyantjs/availability-react": "0.75.0",
84
- "@voyantjs/bookings-react": "0.75.0",
85
- "@voyantjs/catalog": "0.75.0",
86
- "@voyantjs/catalog-react": "0.75.0",
87
- "@voyantjs/crm-react": "0.75.0",
88
- "@voyantjs/crm-ui": "0.75.0",
89
- "@voyantjs/extras-react": "0.75.0",
90
- "@voyantjs/finance-react": "0.75.0",
91
- "@voyantjs/identity-react": "0.75.0",
92
- "@voyantjs/legal-react": "0.75.0",
93
- "@voyantjs/pricing-react": "0.75.0",
94
- "@voyantjs/products-react": "0.75.0",
95
- "@voyantjs/suppliers-react": "0.75.0",
96
- "@voyantjs/ui": "0.75.0",
83
+ "@voyantjs/availability-react": "0.75.3",
84
+ "@voyantjs/bookings-react": "0.75.3",
85
+ "@voyantjs/catalog": "0.75.3",
86
+ "@voyantjs/catalog-react": "0.75.3",
87
+ "@voyantjs/crm-react": "0.75.3",
88
+ "@voyantjs/crm-ui": "0.75.3",
89
+ "@voyantjs/extras-react": "0.75.3",
90
+ "@voyantjs/finance-react": "0.75.3",
91
+ "@voyantjs/identity-react": "0.75.3",
92
+ "@voyantjs/legal-react": "0.75.3",
93
+ "@voyantjs/pricing-react": "0.75.3",
94
+ "@voyantjs/products-react": "0.75.3",
95
+ "@voyantjs/suppliers-react": "0.75.3",
96
+ "@voyantjs/ui": "0.75.3",
97
97
  "@voyantjs/voyant-typescript-config": "0.1.0"
98
98
  },
99
99
  "files": [