@voyantjs/availability-ui 0.30.7 → 0.31.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/README.md +77 -7
- package/dist/components/availability-page.d.ts +50 -0
- package/dist/components/availability-page.d.ts.map +1 -0
- package/dist/components/availability-page.js +248 -0
- package/dist/components/availability-rule-detail-page.d.ts +240 -0
- package/dist/components/availability-rule-detail-page.d.ts.map +1 -0
- package/dist/components/availability-rule-detail-page.js +71 -0
- package/dist/components/availability-slot-detail-page.d.ts +583 -0
- package/dist/components/availability-slot-detail-page.d.ts.map +1 -0
- package/dist/components/availability-slot-detail-page.js +105 -0
- package/dist/components/availability-start-time-detail-page.d.ts +235 -0
- package/dist/components/availability-start-time-detail-page.d.ts.map +1 -0
- package/dist/components/availability-start-time-detail-page.js +80 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/provider.d.ts +1504 -0
- package/dist/i18n/provider.d.ts.map +1 -0
- package/dist/i18n/provider.js +88 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/package.json +16 -5
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import type { QueryClient } from "@tanstack/react-query";
|
|
2
|
+
import { type VoyantAvailabilityContextValue } from "@voyantjs/availability-react";
|
|
3
|
+
export interface AvailabilityRuleDetailPageProps {
|
|
4
|
+
id: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
onBack?: () => void;
|
|
7
|
+
onDeleted?: () => void;
|
|
8
|
+
onOpenProduct?: (productId: string) => void;
|
|
9
|
+
onOpenSlot?: (slotId: string) => void;
|
|
10
|
+
confirmAction?: (message: string) => boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function getAvailabilityRuleDetailQueryOptions(client: VoyantAvailabilityContextValue, id: string | null | undefined): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
|
|
13
|
+
data: {
|
|
14
|
+
id: string;
|
|
15
|
+
productId: string;
|
|
16
|
+
optionId: string | null;
|
|
17
|
+
facilityId: string | null;
|
|
18
|
+
timezone: string;
|
|
19
|
+
recurrenceRule: string;
|
|
20
|
+
maxCapacity: number;
|
|
21
|
+
maxPickupCapacity: number | null;
|
|
22
|
+
minTotalPax: number | null;
|
|
23
|
+
cutoffMinutes: number | null;
|
|
24
|
+
earlyBookingLimitMinutes: number | null;
|
|
25
|
+
active: boolean;
|
|
26
|
+
productName?: string | null | undefined;
|
|
27
|
+
};
|
|
28
|
+
}, Error, {
|
|
29
|
+
data: {
|
|
30
|
+
id: string;
|
|
31
|
+
productId: string;
|
|
32
|
+
optionId: string | null;
|
|
33
|
+
facilityId: string | null;
|
|
34
|
+
timezone: string;
|
|
35
|
+
recurrenceRule: string;
|
|
36
|
+
maxCapacity: number;
|
|
37
|
+
maxPickupCapacity: number | null;
|
|
38
|
+
minTotalPax: number | null;
|
|
39
|
+
cutoffMinutes: number | null;
|
|
40
|
+
earlyBookingLimitMinutes: number | null;
|
|
41
|
+
active: boolean;
|
|
42
|
+
productName?: string | null | undefined;
|
|
43
|
+
};
|
|
44
|
+
}, readonly ["voyant", "availability", "rules", "detail", string]>, "queryFn"> & {
|
|
45
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<{
|
|
46
|
+
data: {
|
|
47
|
+
id: string;
|
|
48
|
+
productId: string;
|
|
49
|
+
optionId: string | null;
|
|
50
|
+
facilityId: string | null;
|
|
51
|
+
timezone: string;
|
|
52
|
+
recurrenceRule: string;
|
|
53
|
+
maxCapacity: number;
|
|
54
|
+
maxPickupCapacity: number | null;
|
|
55
|
+
minTotalPax: number | null;
|
|
56
|
+
cutoffMinutes: number | null;
|
|
57
|
+
earlyBookingLimitMinutes: number | null;
|
|
58
|
+
active: boolean;
|
|
59
|
+
productName?: string | null | undefined;
|
|
60
|
+
};
|
|
61
|
+
}, readonly ["voyant", "availability", "rules", "detail", string], never> | undefined;
|
|
62
|
+
} & {
|
|
63
|
+
queryKey: readonly ["voyant", "availability", "rules", "detail", string] & {
|
|
64
|
+
[dataTagSymbol]: {
|
|
65
|
+
data: {
|
|
66
|
+
id: string;
|
|
67
|
+
productId: string;
|
|
68
|
+
optionId: string | null;
|
|
69
|
+
facilityId: string | null;
|
|
70
|
+
timezone: string;
|
|
71
|
+
recurrenceRule: string;
|
|
72
|
+
maxCapacity: number;
|
|
73
|
+
maxPickupCapacity: number | null;
|
|
74
|
+
minTotalPax: number | null;
|
|
75
|
+
cutoffMinutes: number | null;
|
|
76
|
+
earlyBookingLimitMinutes: number | null;
|
|
77
|
+
active: boolean;
|
|
78
|
+
productName?: string | null | undefined;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
[dataTagErrorSymbol]: Error;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export declare function getAvailabilityRuleSlotsQueryOptions(client: VoyantAvailabilityContextValue, id: string | null | undefined): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
|
|
85
|
+
data: {
|
|
86
|
+
id: string;
|
|
87
|
+
productId: string;
|
|
88
|
+
itineraryId: string | null;
|
|
89
|
+
optionId: string | null;
|
|
90
|
+
facilityId: string | null;
|
|
91
|
+
availabilityRuleId: string | null;
|
|
92
|
+
startTimeId: string | null;
|
|
93
|
+
dateLocal: string;
|
|
94
|
+
startsAt: string;
|
|
95
|
+
endsAt: string | null;
|
|
96
|
+
timezone: string;
|
|
97
|
+
status: "cancelled" | "open" | "closed" | "sold_out";
|
|
98
|
+
unlimited: boolean;
|
|
99
|
+
initialPax: number | null;
|
|
100
|
+
remainingPax: number | null;
|
|
101
|
+
nights: number | null;
|
|
102
|
+
days: number | null;
|
|
103
|
+
notes: string | null;
|
|
104
|
+
productName?: string | null | undefined;
|
|
105
|
+
}[];
|
|
106
|
+
total: number;
|
|
107
|
+
limit: number;
|
|
108
|
+
offset: number;
|
|
109
|
+
}, Error, {
|
|
110
|
+
data: {
|
|
111
|
+
id: string;
|
|
112
|
+
productId: string;
|
|
113
|
+
itineraryId: string | null;
|
|
114
|
+
optionId: string | null;
|
|
115
|
+
facilityId: string | null;
|
|
116
|
+
availabilityRuleId: string | null;
|
|
117
|
+
startTimeId: string | null;
|
|
118
|
+
dateLocal: string;
|
|
119
|
+
startsAt: string;
|
|
120
|
+
endsAt: string | null;
|
|
121
|
+
timezone: string;
|
|
122
|
+
status: "cancelled" | "open" | "closed" | "sold_out";
|
|
123
|
+
unlimited: boolean;
|
|
124
|
+
initialPax: number | null;
|
|
125
|
+
remainingPax: number | null;
|
|
126
|
+
nights: number | null;
|
|
127
|
+
days: number | null;
|
|
128
|
+
notes: string | null;
|
|
129
|
+
productName?: string | null | undefined;
|
|
130
|
+
}[];
|
|
131
|
+
total: number;
|
|
132
|
+
limit: number;
|
|
133
|
+
offset: number;
|
|
134
|
+
}, readonly ["voyant", "availability", "slots", "list", import("@voyantjs/availability-react/query-keys").AvailabilitySlotsListFilters]>, "queryFn"> & {
|
|
135
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<{
|
|
136
|
+
data: {
|
|
137
|
+
id: string;
|
|
138
|
+
productId: string;
|
|
139
|
+
itineraryId: string | null;
|
|
140
|
+
optionId: string | null;
|
|
141
|
+
facilityId: string | null;
|
|
142
|
+
availabilityRuleId: string | null;
|
|
143
|
+
startTimeId: string | null;
|
|
144
|
+
dateLocal: string;
|
|
145
|
+
startsAt: string;
|
|
146
|
+
endsAt: string | null;
|
|
147
|
+
timezone: string;
|
|
148
|
+
status: "cancelled" | "open" | "closed" | "sold_out";
|
|
149
|
+
unlimited: boolean;
|
|
150
|
+
initialPax: number | null;
|
|
151
|
+
remainingPax: number | null;
|
|
152
|
+
nights: number | null;
|
|
153
|
+
days: number | null;
|
|
154
|
+
notes: string | null;
|
|
155
|
+
productName?: string | null | undefined;
|
|
156
|
+
}[];
|
|
157
|
+
total: number;
|
|
158
|
+
limit: number;
|
|
159
|
+
offset: number;
|
|
160
|
+
}, readonly ["voyant", "availability", "slots", "list", import("@voyantjs/availability-react/query-keys").AvailabilitySlotsListFilters], never> | undefined;
|
|
161
|
+
} & {
|
|
162
|
+
queryKey: readonly ["voyant", "availability", "slots", "list", import("@voyantjs/availability-react/query-keys").AvailabilitySlotsListFilters] & {
|
|
163
|
+
[dataTagSymbol]: {
|
|
164
|
+
data: {
|
|
165
|
+
id: string;
|
|
166
|
+
productId: string;
|
|
167
|
+
itineraryId: string | null;
|
|
168
|
+
optionId: string | null;
|
|
169
|
+
facilityId: string | null;
|
|
170
|
+
availabilityRuleId: string | null;
|
|
171
|
+
startTimeId: string | null;
|
|
172
|
+
dateLocal: string;
|
|
173
|
+
startsAt: string;
|
|
174
|
+
endsAt: string | null;
|
|
175
|
+
timezone: string;
|
|
176
|
+
status: "cancelled" | "open" | "closed" | "sold_out";
|
|
177
|
+
unlimited: boolean;
|
|
178
|
+
initialPax: number | null;
|
|
179
|
+
remainingPax: number | null;
|
|
180
|
+
nights: number | null;
|
|
181
|
+
days: number | null;
|
|
182
|
+
notes: string | null;
|
|
183
|
+
productName?: string | null | undefined;
|
|
184
|
+
}[];
|
|
185
|
+
total: number;
|
|
186
|
+
limit: number;
|
|
187
|
+
offset: number;
|
|
188
|
+
};
|
|
189
|
+
[dataTagErrorSymbol]: Error;
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
export declare function loadAvailabilityRuleDetailPage(queryClient: QueryClient, client: VoyantAvailabilityContextValue, id: string): Promise<[{
|
|
193
|
+
data: {
|
|
194
|
+
id: string;
|
|
195
|
+
productId: string;
|
|
196
|
+
optionId: string | null;
|
|
197
|
+
facilityId: string | null;
|
|
198
|
+
timezone: string;
|
|
199
|
+
recurrenceRule: string;
|
|
200
|
+
maxCapacity: number;
|
|
201
|
+
maxPickupCapacity: number | null;
|
|
202
|
+
minTotalPax: number | null;
|
|
203
|
+
cutoffMinutes: number | null;
|
|
204
|
+
earlyBookingLimitMinutes: number | null;
|
|
205
|
+
active: boolean;
|
|
206
|
+
productName?: string | null | undefined;
|
|
207
|
+
};
|
|
208
|
+
}, {
|
|
209
|
+
data: {
|
|
210
|
+
id: string;
|
|
211
|
+
productId: string;
|
|
212
|
+
itineraryId: string | null;
|
|
213
|
+
optionId: string | null;
|
|
214
|
+
facilityId: string | null;
|
|
215
|
+
availabilityRuleId: string | null;
|
|
216
|
+
startTimeId: string | null;
|
|
217
|
+
dateLocal: string;
|
|
218
|
+
startsAt: string;
|
|
219
|
+
endsAt: string | null;
|
|
220
|
+
timezone: string;
|
|
221
|
+
status: "cancelled" | "open" | "closed" | "sold_out";
|
|
222
|
+
unlimited: boolean;
|
|
223
|
+
initialPax: number | null;
|
|
224
|
+
remainingPax: number | null;
|
|
225
|
+
nights: number | null;
|
|
226
|
+
days: number | null;
|
|
227
|
+
notes: string | null;
|
|
228
|
+
productName?: string | null | undefined;
|
|
229
|
+
}[];
|
|
230
|
+
total: number;
|
|
231
|
+
limit: number;
|
|
232
|
+
offset: number;
|
|
233
|
+
}, {
|
|
234
|
+
data: {
|
|
235
|
+
id: string;
|
|
236
|
+
name: string;
|
|
237
|
+
};
|
|
238
|
+
}]>;
|
|
239
|
+
export declare function AvailabilityRuleDetailPage({ id, className, onBack, onDeleted, onOpenProduct, onOpenSlot, confirmAction, }: AvailabilityRuleDetailPageProps): import("react/jsx-runtime").JSX.Element;
|
|
240
|
+
//# sourceMappingURL=availability-rule-detail-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"availability-rule-detail-page.d.ts","sourceRoot":"","sources":["../../src/components/availability-rule-detail-page.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,EAWL,KAAK,8BAA8B,EACpC,MAAM,8BAA8B,CAAA;AAgBrC,MAAM,WAAW,+BAA+B;IAC9C,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA;IAC3C,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAA;CAC7C;AAED,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,8BAA8B,EACtC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAa9B;AAED,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,8BAA8B,EACtC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG9B;AAED,wBAAsB,8BAA8B,CAClD,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,8BAA8B,EACtC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAWX;AAED,wBAAgB,0BAA0B,CAAC,EACzC,EAAE,EACF,SAAS,EACT,MAAM,EACN,SAAS,EACT,aAAa,EACb,UAAU,EACV,aAAkE,GACnE,EAAE,+BAA+B,2CAsIjC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { queryOptions, useQuery } from "@tanstack/react-query";
|
|
4
|
+
import { availabilityQueryKeys, availabilityRuleSingleResponse, fetchWithValidation, formatDateTime, getProductQueryOptions, getSlotsQueryOptions, useAvailabilityRuleMutation, useVoyantAvailabilityContext, } from "@voyantjs/availability-react";
|
|
5
|
+
import { Badge, Button, Card, CardContent, CardHeader, CardTitle, cn, } from "@voyantjs/ui/components";
|
|
6
|
+
import { ArrowLeft, CalendarDays, Package, Trash2 } from "lucide-react";
|
|
7
|
+
import { useAvailabilityUiMessagesOrDefault } from "../i18n/index.js";
|
|
8
|
+
import { getSlotStatusLabel } from "./availability-columns.js";
|
|
9
|
+
import { AvailabilityRuleDetailSkeleton } from "./availability-skeletons.js";
|
|
10
|
+
export function getAvailabilityRuleDetailQueryOptions(client, id) {
|
|
11
|
+
return queryOptions({
|
|
12
|
+
queryKey: availabilityQueryKeys.ruleDetail(id ?? ""),
|
|
13
|
+
queryFn: async () => {
|
|
14
|
+
if (!id)
|
|
15
|
+
throw new Error("getAvailabilityRuleDetailQueryOptions requires an id");
|
|
16
|
+
return fetchWithValidation(`/v1/availability/rules/${id}`, availabilityRuleSingleResponse, client);
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export function getAvailabilityRuleSlotsQueryOptions(client, id) {
|
|
21
|
+
return getSlotsQueryOptions(client, { availabilityRuleId: id ?? undefined, limit: 25, offset: 0 });
|
|
22
|
+
}
|
|
23
|
+
export async function loadAvailabilityRuleDetailPage(queryClient, client, id) {
|
|
24
|
+
const ruleData = await queryClient.ensureQueryData(getAvailabilityRuleDetailQueryOptions(client, id));
|
|
25
|
+
return Promise.all([
|
|
26
|
+
Promise.resolve(ruleData),
|
|
27
|
+
queryClient.ensureQueryData(getAvailabilityRuleSlotsQueryOptions(client, id)),
|
|
28
|
+
queryClient.ensureQueryData(getProductQueryOptions(client, ruleData.data.productId)),
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
export function AvailabilityRuleDetailPage({ id, className, onBack, onDeleted, onOpenProduct, onOpenSlot, confirmAction = (message) => globalThis.confirm?.(message) ?? true, }) {
|
|
32
|
+
const client = useVoyantAvailabilityContext();
|
|
33
|
+
const messages = useAvailabilityUiMessagesOrDefault();
|
|
34
|
+
const detailMessages = messages.details;
|
|
35
|
+
const noValue = detailMessages.noValue;
|
|
36
|
+
const ruleMutation = useAvailabilityRuleMutation();
|
|
37
|
+
const { data: ruleData, isPending } = useQuery(getAvailabilityRuleDetailQueryOptions(client, id));
|
|
38
|
+
const rule = ruleData?.data;
|
|
39
|
+
const productQuery = useQuery({
|
|
40
|
+
...getProductQueryOptions(client, rule?.productId ?? ""),
|
|
41
|
+
enabled: Boolean(rule?.productId),
|
|
42
|
+
});
|
|
43
|
+
const slotsQuery = useQuery(getAvailabilityRuleSlotsQueryOptions(client, id));
|
|
44
|
+
if (isPending) {
|
|
45
|
+
return _jsx(AvailabilityRuleDetailSkeleton, {});
|
|
46
|
+
}
|
|
47
|
+
if (!rule) {
|
|
48
|
+
return (_jsx(DetailEmptyState, { message: detailMessages.rule.notFound, backLabel: detailMessages.backToAvailability, onBack: onBack }));
|
|
49
|
+
}
|
|
50
|
+
async function deleteRule(currentRule) {
|
|
51
|
+
if (!confirmAction(detailMessages.rule.deleteConfirm))
|
|
52
|
+
return;
|
|
53
|
+
await ruleMutation.remove.mutateAsync(currentRule.id);
|
|
54
|
+
if (onDeleted)
|
|
55
|
+
onDeleted();
|
|
56
|
+
else
|
|
57
|
+
onBack?.();
|
|
58
|
+
}
|
|
59
|
+
return (_jsxs("div", { className: cn("flex flex-col gap-6 p-6", className), children: [_jsxs("div", { className: "flex flex-col gap-4 md:flex-row md:items-start md:justify-between", children: [_jsxs("div", { className: "flex items-start gap-4", children: [onBack ? (_jsx(Button, { variant: "ghost", size: "icon", onClick: onBack, "aria-label": detailMessages.backToAvailability, children: _jsx(ArrowLeft, { "data-icon": true, "aria-hidden": "true" }) })) : null, _jsxs("div", { className: "flex-1", children: [_jsx("h1", { className: "text-2xl font-bold tracking-tight", children: detailMessages.rule.pageTitle }), _jsxs("div", { className: "mt-1 flex flex-wrap items-center gap-2", children: [_jsx(Badge, { variant: rule.active ? "default" : "secondary", children: rule.active ? messages.statusActive : messages.statusInactive }), _jsx(Badge, { variant: "outline", children: rule.timezone })] })] })] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [onOpenProduct ? (_jsxs(Button, { variant: "outline", onClick: () => onOpenProduct(rule.productId), children: [_jsx(Package, { "data-icon": "inline-start", "aria-hidden": "true" }), detailMessages.openProduct] })) : null, _jsxs(Button, { variant: "destructive", onClick: () => void deleteRule(rule), disabled: ruleMutation.remove.isPending, children: [_jsx(Trash2, { "data-icon": "inline-start", "aria-hidden": "true" }), detailMessages.delete] })] })] }), _jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: detailMessages.rule.detailsTitle }) }), _jsxs(CardContent, { className: "flex flex-col gap-3 text-sm", children: [_jsx(DetailLine, { label: messages.productLabel, children: productQuery.data?.data.name ?? rule.productId }), _jsxs("div", { children: [_jsxs("span", { className: "text-muted-foreground", children: [messages.recurrenceLabel, ":"] }), _jsx("pre", { className: "mt-1 overflow-x-auto rounded-md bg-muted p-3 font-mono text-xs", children: rule.recurrenceRule })] })] })] }), _jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: detailMessages.rule.capacityPolicyTitle }) }), _jsxs(CardContent, { className: "flex flex-col gap-3 text-sm", children: [_jsx(DetailLine, { label: messages.maxPaxLabel, children: rule.maxCapacity }), _jsx(DetailLine, { label: detailMessages.rule.maxPickupCapacityLabel, children: rule.maxPickupCapacity ?? noValue }), _jsx(DetailLine, { label: detailMessages.rule.minTotalPaxLabel, children: rule.minTotalPax ?? noValue }), _jsx(DetailLine, { label: detailMessages.rule.cutoffMinutesLabel, children: rule.cutoffMinutes ?? noValue }), _jsx(DetailLine, { label: detailMessages.rule.earlyBookingLimitLabel, children: rule.earlyBookingLimitMinutes ?? noValue })] })] })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "flex flex-row items-center gap-2", children: [_jsx(CalendarDays, { className: "size-4", "aria-hidden": "true" }), _jsx(CardTitle, { children: detailMessages.rule.generatedSlotsTitle })] }), _jsx(CardContent, { className: "flex flex-col gap-3 text-sm", children: (slotsQuery.data?.data.length ?? 0) === 0 ? (_jsx("p", { className: "text-muted-foreground", children: detailMessages.rule.generatedSlotsEmpty })) : (slotsQuery.data?.data.map((slot) => (_jsx(SlotButton, { slot: slot, onOpenSlot: onOpenSlot }, slot.id)))) })] })] }));
|
|
60
|
+
}
|
|
61
|
+
function SlotButton({ slot, onOpenSlot, }) {
|
|
62
|
+
const messages = useAvailabilityUiMessagesOrDefault();
|
|
63
|
+
const noValue = messages.details.noValue;
|
|
64
|
+
return (_jsxs("button", { type: "button", className: "block w-full rounded-md border p-3 text-left hover:bg-muted/40", onClick: () => onOpenSlot?.(slot.id), children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Badge, { variant: "outline", children: getSlotStatusLabel(slot.status, messages) }), _jsxs("span", { children: [slot.dateLocal, " \u00B7 ", formatDateTime(slot.startsAt)] })] }), _jsxs("div", { className: "mt-2 text-muted-foreground", children: [messages.remainingPaxLabel, ": ", slot.remainingPax ?? noValue] })] }));
|
|
65
|
+
}
|
|
66
|
+
function DetailLine({ label, children }) {
|
|
67
|
+
return (_jsxs("div", { children: [_jsxs("span", { className: "text-muted-foreground", children: [label, ":"] }), " ", _jsx("span", { children: children })] }));
|
|
68
|
+
}
|
|
69
|
+
function DetailEmptyState({ message, backLabel, onBack, }) {
|
|
70
|
+
return (_jsxs("div", { className: "flex flex-col items-center justify-center gap-4 py-12", children: [_jsx("p", { className: "text-muted-foreground", children: message }), onBack ? (_jsx(Button, { variant: "outline", onClick: onBack, children: backLabel })) : null] }));
|
|
71
|
+
}
|