@voyantjs/availability-react 0.106.0 → 0.107.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 +161 -1
- package/dist/admin/availability-index-host.d.ts +12 -0
- package/dist/admin/availability-index-host.d.ts.map +1 -0
- package/dist/admin/availability-index-host.js +125 -0
- package/dist/admin/availability-page-data.d.ts +9 -0
- package/dist/admin/availability-page-data.d.ts.map +1 -0
- package/dist/admin/availability-page-data.js +25 -0
- package/dist/admin/index.d.ts +69 -0
- package/dist/admin/index.d.ts.map +1 -0
- package/dist/admin/index.js +73 -0
- package/dist/admin/option-resource-templates-panel.d.ts +22 -0
- package/dist/admin/option-resource-templates-panel.d.ts.map +1 -0
- package/dist/admin/option-resource-templates-panel.js +251 -0
- package/dist/admin/rule-detail-host.d.ts +14 -0
- package/dist/admin/rule-detail-host.d.ts.map +1 -0
- package/dist/admin/rule-detail-host.js +27 -0
- package/dist/admin/slot-detail-host.d.ts +29 -0
- package/dist/admin/slot-detail-host.d.ts.map +1 -0
- package/dist/admin/slot-detail-host.js +110 -0
- package/dist/admin/start-time-detail-host.d.ts +15 -0
- package/dist/admin/start-time-detail-host.d.ts.map +1 -0
- package/dist/admin/start-time-detail-host.js +37 -0
- package/dist/components/availability-columns.d.ts +42 -0
- package/dist/components/availability-columns.d.ts.map +1 -0
- package/dist/components/availability-columns.js +182 -0
- package/dist/components/availability-dialogs.d.ts +236 -0
- package/dist/components/availability-dialogs.d.ts.map +1 -0
- package/dist/components/availability-dialogs.js +369 -0
- package/dist/components/availability-overview.d.ts +54 -0
- package/dist/components/availability-overview.d.ts.map +1 -0
- package/dist/components/availability-overview.js +50 -0
- package/dist/components/availability-page.d.ts +32 -0
- package/dist/components/availability-page.d.ts.map +1 -0
- package/dist/components/availability-page.js +128 -0
- package/dist/components/availability-rule-detail-page.d.ts +251 -0
- package/dist/components/availability-rule-detail-page.d.ts.map +1 -0
- package/dist/components/availability-rule-detail-page.js +74 -0
- package/dist/components/availability-section-header.d.ts +8 -0
- package/dist/components/availability-section-header.d.ts.map +1 -0
- package/dist/components/availability-section-header.js +7 -0
- package/dist/components/availability-skeletons.d.ts +6 -0
- package/dist/components/availability-skeletons.d.ts.map +1 -0
- package/dist/components/availability-skeletons.js +34 -0
- package/dist/components/availability-slot-detail-page.d.ts +974 -0
- package/dist/components/availability-slot-detail-page.d.ts.map +1 -0
- package/dist/components/availability-slot-detail-page.js +383 -0
- package/dist/components/availability-start-time-detail-page.d.ts +246 -0
- package/dist/components/availability-start-time-detail-page.d.ts.map +1 -0
- package/dist/components/availability-start-time-detail-page.js +83 -0
- package/dist/components/availability-tabs.d.ts +152 -0
- package/dist/components/availability-tabs.d.ts.map +1 -0
- package/dist/components/availability-tabs.js +192 -0
- package/dist/components/slot-status-tone.d.ts +15 -0
- package/dist/components/slot-status-tone.d.ts.map +1 -0
- package/dist/components/slot-status-tone.js +18 -0
- package/dist/form-resolver.d.ts +4 -0
- package/dist/form-resolver.d.ts.map +1 -0
- package/dist/form-resolver.js +40 -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 +2003 -0
- package/dist/i18n/provider.d.ts.map +1 -0
- package/dist/i18n/provider.js +102 -0
- package/dist/ui.d.ts +13 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +12 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +3 -0
- package/package.json +92 -9
- package/src/styles.css +11 -0
|
@@ -0,0 +1,83 @@
|
|
|
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 { Badge, Button, Card, CardContent, CardHeader, CardTitle, cn, } from "@voyantjs/ui/components";
|
|
5
|
+
import { ArrowLeft, Clock3, Package, Trash2 } from "lucide-react";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { useAvailabilityUiI18nOrDefault } from "../i18n/index.js";
|
|
8
|
+
import { availabilityQueryKeys, availabilityStartTimeRecordSchema, fetchWithValidation, getProductQueryOptions, getSlotsQueryOptions, singleEnvelope, slotLocalStart, useAvailabilityStartTimeMutation, useVoyantAvailabilityContext, } from "../index.js";
|
|
9
|
+
import { getSlotStatusLabel } from "./availability-columns.js";
|
|
10
|
+
import { AvailabilityStartTimeDetailSkeleton } from "./availability-skeletons.js";
|
|
11
|
+
const availabilityStartTimeDetailResponse = singleEnvelope(availabilityStartTimeRecordSchema.extend({
|
|
12
|
+
createdAt: z.string().optional(),
|
|
13
|
+
updatedAt: z.string().optional(),
|
|
14
|
+
}));
|
|
15
|
+
export function getAvailabilityStartTimeDetailQueryOptions(client, id) {
|
|
16
|
+
return queryOptions({
|
|
17
|
+
queryKey: availabilityQueryKeys.startTimeDetail(id ?? ""),
|
|
18
|
+
queryFn: async () => {
|
|
19
|
+
if (!id)
|
|
20
|
+
throw new Error("getAvailabilityStartTimeDetailQueryOptions requires an id");
|
|
21
|
+
return fetchWithValidation(`/v1/availability/start-times/${id}`, availabilityStartTimeDetailResponse, client);
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export function getAvailabilityStartTimeSlotsQueryOptions(client, id) {
|
|
26
|
+
return getSlotsQueryOptions(client, { startTimeId: id ?? undefined, limit: 25, offset: 0 });
|
|
27
|
+
}
|
|
28
|
+
export async function loadAvailabilityStartTimeDetailPage(queryClient, client, id) {
|
|
29
|
+
const startTimeData = await queryClient.ensureQueryData(getAvailabilityStartTimeDetailQueryOptions(client, id));
|
|
30
|
+
return Promise.all([
|
|
31
|
+
Promise.resolve(startTimeData),
|
|
32
|
+
queryClient.ensureQueryData(getAvailabilityStartTimeSlotsQueryOptions(client, id)),
|
|
33
|
+
queryClient.ensureQueryData(getProductQueryOptions(client, startTimeData.data.productId)),
|
|
34
|
+
]);
|
|
35
|
+
}
|
|
36
|
+
export function AvailabilityStartTimeDetailPage({ id, className, onBack, onDeleted, onOpenProduct, onOpenSlot, confirmAction = (message) => globalThis.confirm?.(message) ?? true, }) {
|
|
37
|
+
const client = useVoyantAvailabilityContext();
|
|
38
|
+
const i18n = useAvailabilityUiI18nOrDefault();
|
|
39
|
+
const messages = i18n.messages;
|
|
40
|
+
const detailMessages = messages.details;
|
|
41
|
+
const noValue = detailMessages.noValue;
|
|
42
|
+
const startTimeMutation = useAvailabilityStartTimeMutation();
|
|
43
|
+
const { data: startTimeData, isPending } = useQuery(getAvailabilityStartTimeDetailQueryOptions(client, id));
|
|
44
|
+
const startTime = startTimeData?.data;
|
|
45
|
+
const productQuery = useQuery({
|
|
46
|
+
...getProductQueryOptions(client, startTime?.productId ?? ""),
|
|
47
|
+
enabled: Boolean(startTime?.productId),
|
|
48
|
+
});
|
|
49
|
+
const slotsQuery = useQuery(getAvailabilityStartTimeSlotsQueryOptions(client, id));
|
|
50
|
+
if (isPending) {
|
|
51
|
+
return _jsx(AvailabilityStartTimeDetailSkeleton, {});
|
|
52
|
+
}
|
|
53
|
+
if (!startTime) {
|
|
54
|
+
return (_jsx(DetailEmptyState, { message: detailMessages.startTime.notFound, backLabel: detailMessages.backToAvailability, onBack: onBack }));
|
|
55
|
+
}
|
|
56
|
+
async function deleteStartTime(currentStartTime) {
|
|
57
|
+
if (!confirmAction(detailMessages.startTime.deleteConfirm))
|
|
58
|
+
return;
|
|
59
|
+
await startTimeMutation.remove.mutateAsync(currentStartTime.id);
|
|
60
|
+
if (onDeleted)
|
|
61
|
+
onDeleted();
|
|
62
|
+
else
|
|
63
|
+
onBack?.();
|
|
64
|
+
}
|
|
65
|
+
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: startTime.label ?? detailMessages.startTime.fallbackTitle }), _jsxs("div", { className: "mt-1 flex flex-wrap items-center gap-2", children: [_jsx(Badge, { variant: "outline", children: startTime.startTimeLocal }), _jsx(Badge, { variant: startTime.active ? "default" : "secondary", children: startTime.active ? messages.statusActive : messages.statusInactive })] })] })] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [onOpenProduct ? (_jsxs(Button, { variant: "outline", onClick: () => onOpenProduct(startTime.productId), children: [_jsx(Package, { "data-icon": "inline-start", "aria-hidden": "true" }), detailMessages.openProduct] })) : null, _jsxs(Button, { variant: "destructive", onClick: () => void deleteStartTime(startTime), disabled: startTimeMutation.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.startTime.detailsTitle }) }), _jsxs(CardContent, { className: "flex flex-col gap-3 text-sm", children: [_jsx(DetailLine, { label: messages.productLabel, children: productQuery.data?.data.name ?? startTime.productId }), _jsx(DetailLine, { label: messages.labelLabel, children: startTime.label ?? noValue }), _jsx(DetailLine, { label: messages.durationLabel, children: startTime.durationMinutes == null ? noValue : `${startTime.durationMinutes} min` }), _jsx(DetailLine, { label: detailMessages.startTime.sortOrderLabel, children: startTime.sortOrder }), _jsx(DetailLine, { label: detailMessages.createdLabel, children: formatOptionalDateTime(startTime.createdAt, noValue, i18n.formatDateTime) }), _jsx(DetailLine, { label: detailMessages.updatedLabel, children: formatOptionalDateTime(startTime.updatedAt, noValue, i18n.formatDateTime) })] })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "flex flex-row items-center gap-2", children: [_jsx(Clock3, { className: "size-4", "aria-hidden": "true" }), _jsx(CardTitle, { children: detailMessages.startTime.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.startTime.generatedSlotsEmpty })) : (slotsQuery.data?.data.map((slot) => (_jsx(SlotButton, { slot: slot, onOpenSlot: onOpenSlot }, slot.id)))) })] })] })] }));
|
|
66
|
+
}
|
|
67
|
+
function SlotButton({ slot, onOpenSlot, }) {
|
|
68
|
+
const messages = useAvailabilityUiI18nOrDefault().messages;
|
|
69
|
+
const noValue = messages.details.noValue;
|
|
70
|
+
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: [_jsx("div", { className: "font-medium", children: formatSlotLocalDateTime(slotLocalStart(slot)) }), _jsxs("div", { className: "text-muted-foreground", children: [messages.statusLabel, ": ", getSlotStatusLabel(slot.status, messages), " \u00B7", " ", messages.remainingPaxLabel, ": ", slot.remainingPax ?? noValue] })] }));
|
|
71
|
+
}
|
|
72
|
+
function formatSlotLocalDateTime(value) {
|
|
73
|
+
return `${value.date} ${value.time}`;
|
|
74
|
+
}
|
|
75
|
+
function formatOptionalDateTime(value, fallback, formatter) {
|
|
76
|
+
return value ? formatter(value) : fallback;
|
|
77
|
+
}
|
|
78
|
+
function DetailLine({ label, children }) {
|
|
79
|
+
return (_jsxs("div", { children: [_jsxs("span", { className: "text-muted-foreground", children: [label, ":"] }), " ", _jsx("span", { children: children })] }));
|
|
80
|
+
}
|
|
81
|
+
function DetailEmptyState({ message, backLabel, onBack, }) {
|
|
82
|
+
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] }));
|
|
83
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { OnChangeFn, RowSelectionState } from "@tanstack/react-table";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { AvailabilityCloseoutRow, AvailabilityPickupPointRow, AvailabilityRuleRow, AvailabilitySlotRow, AvailabilityStartTimeRow, ProductOption } from "../index.js";
|
|
4
|
+
import { type AvailabilityColumnsMessages } from "./availability-columns.js";
|
|
5
|
+
export interface AvailabilityTabMessages extends AvailabilityColumnsMessages {
|
|
6
|
+
nouns: {
|
|
7
|
+
slotSingular: string;
|
|
8
|
+
slotPlural: string;
|
|
9
|
+
ruleSingular: string;
|
|
10
|
+
rulePlural: string;
|
|
11
|
+
startTimeSingular: string;
|
|
12
|
+
startTimePlural: string;
|
|
13
|
+
closeoutSingular: string;
|
|
14
|
+
closeoutPlural: string;
|
|
15
|
+
pickupPointSingular: string;
|
|
16
|
+
pickupPointPlural: string;
|
|
17
|
+
};
|
|
18
|
+
tabs: {
|
|
19
|
+
slots: AvailabilitySlotTabMessages;
|
|
20
|
+
rules: AvailabilityToggleTabMessages;
|
|
21
|
+
startTimes: AvailabilityToggleTabMessages;
|
|
22
|
+
closeouts: AvailabilityDeleteOnlyTabMessages;
|
|
23
|
+
pickupPoints: AvailabilityToggleTabMessages;
|
|
24
|
+
};
|
|
25
|
+
verbOpened: string;
|
|
26
|
+
verbClosed: string;
|
|
27
|
+
verbActivated: string;
|
|
28
|
+
verbDeactivated: string;
|
|
29
|
+
bulkStatusPlaceholder: string;
|
|
30
|
+
}
|
|
31
|
+
interface AvailabilityBaseTabMessages {
|
|
32
|
+
title: string;
|
|
33
|
+
description: string;
|
|
34
|
+
actionLabel: string;
|
|
35
|
+
emptyMessage: string;
|
|
36
|
+
bulkDeleteButton: string;
|
|
37
|
+
bulkDeleteConfirm: string;
|
|
38
|
+
bulkDeleteTitle: string;
|
|
39
|
+
bulkDeleteDescription: string;
|
|
40
|
+
}
|
|
41
|
+
interface AvailabilitySlotTabMessages extends AvailabilityBaseTabMessages {
|
|
42
|
+
bulkOpenButton: string;
|
|
43
|
+
bulkOpenConfirm: string;
|
|
44
|
+
bulkOpenTitle: string;
|
|
45
|
+
bulkOpenDescription: string;
|
|
46
|
+
bulkCloseButton: string;
|
|
47
|
+
bulkCloseConfirm: string;
|
|
48
|
+
bulkCloseTitle: string;
|
|
49
|
+
bulkCloseDescription: string;
|
|
50
|
+
}
|
|
51
|
+
interface AvailabilityToggleTabMessages extends AvailabilityBaseTabMessages {
|
|
52
|
+
bulkActivateButton: string;
|
|
53
|
+
bulkActivateConfirm: string;
|
|
54
|
+
bulkActivateTitle: string;
|
|
55
|
+
bulkActivateDescription: string;
|
|
56
|
+
bulkDeactivateButton: string;
|
|
57
|
+
bulkDeactivateConfirm: string;
|
|
58
|
+
bulkDeactivateTitle: string;
|
|
59
|
+
bulkDeactivateDescription: string;
|
|
60
|
+
}
|
|
61
|
+
type AvailabilityDeleteOnlyTabMessages = AvailabilityBaseTabMessages;
|
|
62
|
+
export type AvailabilityBulkUpdateFn = (args: {
|
|
63
|
+
ids: string[];
|
|
64
|
+
endpoint: string;
|
|
65
|
+
target: string;
|
|
66
|
+
nounSingular: string;
|
|
67
|
+
nounPlural: string;
|
|
68
|
+
payload: Record<string, unknown>;
|
|
69
|
+
successVerb: string;
|
|
70
|
+
clearSelection: () => void;
|
|
71
|
+
}) => Promise<void>;
|
|
72
|
+
export type AvailabilityBulkDeleteFn = (args: {
|
|
73
|
+
ids: string[];
|
|
74
|
+
endpoint: string;
|
|
75
|
+
target: string;
|
|
76
|
+
nounSingular: string;
|
|
77
|
+
nounPlural: string;
|
|
78
|
+
clearSelection: () => void;
|
|
79
|
+
}) => Promise<void>;
|
|
80
|
+
export declare function AvailabilitySlotsTab(props: {
|
|
81
|
+
messages: AvailabilityTabMessages;
|
|
82
|
+
products: ProductOption[];
|
|
83
|
+
filteredSlots: AvailabilitySlotRow[];
|
|
84
|
+
slotSelection: RowSelectionState;
|
|
85
|
+
setSlotSelection: OnChangeFn<RowSelectionState>;
|
|
86
|
+
bulkActionTarget: string | null;
|
|
87
|
+
handleBulkUpdate: AvailabilityBulkUpdateFn;
|
|
88
|
+
handleBulkDelete: AvailabilityBulkDeleteFn;
|
|
89
|
+
onCreate: () => void;
|
|
90
|
+
onOpenRoute: (slotId: string) => void;
|
|
91
|
+
onEdit: (row: AvailabilitySlotRow) => void;
|
|
92
|
+
toolbar?: ReactNode;
|
|
93
|
+
hideHeader?: boolean;
|
|
94
|
+
asPanel?: boolean;
|
|
95
|
+
hideBulkDelete?: boolean;
|
|
96
|
+
bulkStatusSelect?: boolean;
|
|
97
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
98
|
+
export declare function AvailabilityRulesTab(props: {
|
|
99
|
+
messages: AvailabilityTabMessages;
|
|
100
|
+
products: ProductOption[];
|
|
101
|
+
filteredRules: AvailabilityRuleRow[];
|
|
102
|
+
ruleSelection: RowSelectionState;
|
|
103
|
+
setRuleSelection: OnChangeFn<RowSelectionState>;
|
|
104
|
+
bulkActionTarget: string | null;
|
|
105
|
+
handleBulkUpdate: AvailabilityBulkUpdateFn;
|
|
106
|
+
handleBulkDelete: AvailabilityBulkDeleteFn;
|
|
107
|
+
onCreate: () => void;
|
|
108
|
+
onOpenRoute: (ruleId: string) => void;
|
|
109
|
+
onEdit: (row: AvailabilityRuleRow) => void;
|
|
110
|
+
toolbar?: ReactNode;
|
|
111
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
112
|
+
export declare function AvailabilityStartTimesTab(props: {
|
|
113
|
+
messages: AvailabilityTabMessages;
|
|
114
|
+
products: ProductOption[];
|
|
115
|
+
filteredStartTimes: AvailabilityStartTimeRow[];
|
|
116
|
+
startTimeSelection: RowSelectionState;
|
|
117
|
+
setStartTimeSelection: OnChangeFn<RowSelectionState>;
|
|
118
|
+
bulkActionTarget: string | null;
|
|
119
|
+
handleBulkUpdate: AvailabilityBulkUpdateFn;
|
|
120
|
+
handleBulkDelete: AvailabilityBulkDeleteFn;
|
|
121
|
+
onCreate: () => void;
|
|
122
|
+
onOpenRoute: (startTimeId: string) => void;
|
|
123
|
+
onEdit: (row: AvailabilityStartTimeRow) => void;
|
|
124
|
+
toolbar?: ReactNode;
|
|
125
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
126
|
+
export declare function AvailabilityCloseoutsTab(props: {
|
|
127
|
+
messages: AvailabilityTabMessages;
|
|
128
|
+
products: ProductOption[];
|
|
129
|
+
filteredCloseouts: AvailabilityCloseoutRow[];
|
|
130
|
+
closeoutSelection: RowSelectionState;
|
|
131
|
+
setCloseoutSelection: OnChangeFn<RowSelectionState>;
|
|
132
|
+
bulkActionTarget: string | null;
|
|
133
|
+
handleBulkDelete: AvailabilityBulkDeleteFn;
|
|
134
|
+
onCreate: () => void;
|
|
135
|
+
onEdit: (row: AvailabilityCloseoutRow) => void;
|
|
136
|
+
toolbar?: ReactNode;
|
|
137
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
138
|
+
export declare function AvailabilityPickupPointsTab(props: {
|
|
139
|
+
messages: AvailabilityTabMessages;
|
|
140
|
+
products: ProductOption[];
|
|
141
|
+
filteredPickupPoints: AvailabilityPickupPointRow[];
|
|
142
|
+
pickupPointSelection: RowSelectionState;
|
|
143
|
+
setPickupPointSelection: OnChangeFn<RowSelectionState>;
|
|
144
|
+
bulkActionTarget: string | null;
|
|
145
|
+
handleBulkUpdate: AvailabilityBulkUpdateFn;
|
|
146
|
+
handleBulkDelete: AvailabilityBulkDeleteFn;
|
|
147
|
+
onCreate: () => void;
|
|
148
|
+
onEdit: (row: AvailabilityPickupPointRow) => void;
|
|
149
|
+
toolbar?: ReactNode;
|
|
150
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
151
|
+
export {};
|
|
152
|
+
//# sourceMappingURL=availability-tabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"availability-tabs.d.ts","sourceRoot":"","sources":["../../src/components/availability-tabs.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,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CACpB,2CAsDA;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,QAAQ,EAAE,uBAAuB,CAAA;IACjC,QAAQ,EAAE,aAAa,EAAE,CAAA;IACzB,oBAAoB,EAAE,0BAA0B,EAAE,CAAA;IAClD,oBAAoB,EAAE,iBAAiB,CAAA;IACvC,uBAAuB,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAA;IACtD,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,gBAAgB,EAAE,wBAAwB,CAAA;IAC1C,gBAAgB,EAAE,wBAAwB,CAAA;IAC1C,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,MAAM,EAAE,CAAC,GAAG,EAAE,0BAA0B,KAAK,IAAI,CAAA;IACjD,OAAO,CAAC,EAAE,SAAS,CAAA;CACpB,2CAgGA"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { ConfirmActionButton, SelectionActionBar } from "@voyantjs/ui/components";
|
|
4
|
+
import { DataTable } from "@voyantjs/ui/components/data-table";
|
|
5
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@voyantjs/ui/components/select";
|
|
6
|
+
import { TabsContent } from "@voyantjs/ui/components/tabs";
|
|
7
|
+
import { useAvailabilityUiMessagesOrDefault } from "../i18n/index.js";
|
|
8
|
+
import { formatLocalizedSelectionLabel } from "../utils.js";
|
|
9
|
+
import { availabilityCloseoutColumns, availabilityPickupPointColumns, availabilityRuleColumns, availabilitySlotColumns, availabilityStartTimeColumns, } from "./availability-columns.js";
|
|
10
|
+
import { AvailabilitySectionHeader } from "./availability-section-header.js";
|
|
11
|
+
function formatTemplate(template, values) {
|
|
12
|
+
return template.replace(/\{(\w+)\}/g, (match, key) => {
|
|
13
|
+
const value = values[key];
|
|
14
|
+
return value == null ? match : String(value);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export function AvailabilitySlotsTab(props) {
|
|
18
|
+
useAvailabilityUiMessagesOrDefault();
|
|
19
|
+
const selection = (count) => formatLocalizedSelectionLabel(count, props.messages.nouns.slotSingular, props.messages.nouns.slotPlural);
|
|
20
|
+
const asPanel = props.asPanel ?? true;
|
|
21
|
+
const body = (_jsxs(_Fragment, { children: [!props.hideHeader && (_jsx(AvailabilitySectionHeader, { title: props.messages.tabs.slots.title, description: props.messages.tabs.slots.description, actionLabel: props.messages.tabs.slots.actionLabel, onAction: props.onCreate })), props.toolbar, _jsx(DataTable, { columns: availabilitySlotColumns(props.products, props.onOpenRoute, props.messages, props.onEdit), data: props.filteredSlots, emptyMessage: props.messages.tabs.slots.emptyMessage, enableRowSelection: true, getRowId: (row) => row.id, rowSelection: props.slotSelection, onRowSelectionChange: props.setSlotSelection, renderSelectionActions: ({ selectedRows, clearSelection }) => (_jsxs(SelectionActionBar, { selectedCount: selectedRows.length, onClear: clearSelection, children: [props.bulkStatusSelect ? (_jsxs(Select, { value: "", onValueChange: (value) => {
|
|
22
|
+
if (!value)
|
|
23
|
+
return;
|
|
24
|
+
const verb = value === "open"
|
|
25
|
+
? props.messages.verbOpened
|
|
26
|
+
: value === "closed"
|
|
27
|
+
? props.messages.verbClosed
|
|
28
|
+
: value === "cancelled"
|
|
29
|
+
? props.messages.verbDeactivated
|
|
30
|
+
: props.messages.verbClosed;
|
|
31
|
+
props.handleBulkUpdate({
|
|
32
|
+
ids: selectedRows.map((row) => row.original.id),
|
|
33
|
+
endpoint: "/v1/availability/slots",
|
|
34
|
+
target: `slots-status-${value}`,
|
|
35
|
+
nounSingular: props.messages.nouns.slotSingular,
|
|
36
|
+
nounPlural: props.messages.nouns.slotPlural,
|
|
37
|
+
payload: { status: value },
|
|
38
|
+
successVerb: verb,
|
|
39
|
+
clearSelection,
|
|
40
|
+
});
|
|
41
|
+
}, children: [_jsx(SelectTrigger, { size: "sm", className: "w-44", children: _jsx(SelectValue, { placeholder: props.messages.bulkStatusPlaceholder }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "open", children: props.messages.statusOpen }), _jsx(SelectItem, { value: "closed", children: props.messages.statusClosed }), _jsx(SelectItem, { value: "sold_out", children: props.messages.statusSoldOut }), _jsx(SelectItem, { value: "cancelled", children: props.messages.statusCancelled })] })] })) : (_jsxs(_Fragment, { children: [_jsx(ConfirmActionButton, { buttonLabel: props.messages.tabs.slots.bulkOpenButton, confirmLabel: props.messages.tabs.slots.bulkOpenConfirm, title: formatTemplate(props.messages.tabs.slots.bulkOpenTitle, {
|
|
42
|
+
selection: selection(selectedRows.length),
|
|
43
|
+
}), description: props.messages.tabs.slots.bulkOpenDescription, disabled: props.bulkActionTarget === "slots-open", onConfirm: () => props.handleBulkUpdate({
|
|
44
|
+
ids: selectedRows.map((row) => row.original.id),
|
|
45
|
+
endpoint: "/v1/availability/slots",
|
|
46
|
+
target: "slots-open",
|
|
47
|
+
nounSingular: props.messages.nouns.slotSingular,
|
|
48
|
+
nounPlural: props.messages.nouns.slotPlural,
|
|
49
|
+
payload: { status: "open" },
|
|
50
|
+
successVerb: props.messages.verbOpened,
|
|
51
|
+
clearSelection,
|
|
52
|
+
}) }), _jsx(ConfirmActionButton, { buttonLabel: props.messages.tabs.slots.bulkCloseButton, confirmLabel: props.messages.tabs.slots.bulkCloseConfirm, title: formatTemplate(props.messages.tabs.slots.bulkCloseTitle, {
|
|
53
|
+
selection: selection(selectedRows.length),
|
|
54
|
+
}), description: props.messages.tabs.slots.bulkCloseDescription, disabled: props.bulkActionTarget === "slots-close", onConfirm: () => props.handleBulkUpdate({
|
|
55
|
+
ids: selectedRows.map((row) => row.original.id),
|
|
56
|
+
endpoint: "/v1/availability/slots",
|
|
57
|
+
target: "slots-close",
|
|
58
|
+
nounSingular: props.messages.nouns.slotSingular,
|
|
59
|
+
nounPlural: props.messages.nouns.slotPlural,
|
|
60
|
+
payload: { status: "closed" },
|
|
61
|
+
successVerb: props.messages.verbClosed,
|
|
62
|
+
clearSelection,
|
|
63
|
+
}) })] })), props.hideBulkDelete ? null : (_jsx(ConfirmActionButton, { buttonLabel: props.messages.tabs.slots.bulkDeleteButton, confirmLabel: props.messages.tabs.slots.bulkDeleteConfirm, title: formatTemplate(props.messages.tabs.slots.bulkDeleteTitle, {
|
|
64
|
+
selection: selection(selectedRows.length),
|
|
65
|
+
}), description: props.messages.tabs.slots.bulkDeleteDescription, disabled: props.bulkActionTarget === "slots-delete", variant: "destructive", confirmVariant: "destructive", onConfirm: () => props.handleBulkDelete({
|
|
66
|
+
ids: selectedRows.map((row) => row.original.id),
|
|
67
|
+
endpoint: "/v1/availability/slots",
|
|
68
|
+
target: "slots-delete",
|
|
69
|
+
nounSingular: props.messages.nouns.slotSingular,
|
|
70
|
+
nounPlural: props.messages.nouns.slotPlural,
|
|
71
|
+
clearSelection,
|
|
72
|
+
}) }))] })) })] }));
|
|
73
|
+
return asPanel ? (_jsx(TabsContent, { value: "slots", className: "space-y-4", children: body })) : (_jsx("div", { className: "flex flex-col gap-4", children: body }));
|
|
74
|
+
}
|
|
75
|
+
export function AvailabilityRulesTab(props) {
|
|
76
|
+
const selection = (count) => formatLocalizedSelectionLabel(count, props.messages.nouns.ruleSingular, props.messages.nouns.rulePlural);
|
|
77
|
+
return (_jsxs(TabsContent, { value: "rules", className: "space-y-4", children: [_jsx(AvailabilitySectionHeader, { title: props.messages.tabs.rules.title, description: props.messages.tabs.rules.description, actionLabel: props.messages.tabs.rules.actionLabel, onAction: props.onCreate }), props.toolbar, _jsx(DataTable, { columns: availabilityRuleColumns(props.products, props.onOpenRoute, props.messages), data: props.filteredRules, emptyMessage: props.messages.tabs.rules.emptyMessage, enableRowSelection: true, getRowId: (row) => row.id, rowSelection: props.ruleSelection, onRowSelectionChange: props.setRuleSelection, renderSelectionActions: ({ selectedRows, clearSelection }) => (_jsxs(SelectionActionBar, { selectedCount: selectedRows.length, onClear: clearSelection, children: [_jsx(ConfirmActionButton, { buttonLabel: props.messages.tabs.rules.bulkActivateButton, confirmLabel: props.messages.tabs.rules.bulkActivateConfirm, title: formatTemplate(props.messages.tabs.rules.bulkActivateTitle, {
|
|
78
|
+
selection: selection(selectedRows.length),
|
|
79
|
+
}), description: props.messages.tabs.rules.bulkActivateDescription, disabled: props.bulkActionTarget === "rules-activate", onConfirm: () => props.handleBulkUpdate({
|
|
80
|
+
ids: selectedRows.map((row) => row.original.id),
|
|
81
|
+
endpoint: "/v1/availability/rules",
|
|
82
|
+
target: "rules-activate",
|
|
83
|
+
nounSingular: props.messages.nouns.ruleSingular,
|
|
84
|
+
nounPlural: props.messages.nouns.rulePlural,
|
|
85
|
+
payload: { active: true },
|
|
86
|
+
successVerb: props.messages.verbActivated,
|
|
87
|
+
clearSelection,
|
|
88
|
+
}) }), _jsx(ConfirmActionButton, { buttonLabel: props.messages.tabs.rules.bulkDeactivateButton, confirmLabel: props.messages.tabs.rules.bulkDeactivateConfirm, title: formatTemplate(props.messages.tabs.rules.bulkDeactivateTitle, {
|
|
89
|
+
selection: selection(selectedRows.length),
|
|
90
|
+
}), description: props.messages.tabs.rules.bulkDeactivateDescription, disabled: props.bulkActionTarget === "rules-deactivate", onConfirm: () => props.handleBulkUpdate({
|
|
91
|
+
ids: selectedRows.map((row) => row.original.id),
|
|
92
|
+
endpoint: "/v1/availability/rules",
|
|
93
|
+
target: "rules-deactivate",
|
|
94
|
+
nounSingular: props.messages.nouns.ruleSingular,
|
|
95
|
+
nounPlural: props.messages.nouns.rulePlural,
|
|
96
|
+
payload: { active: false },
|
|
97
|
+
successVerb: props.messages.verbDeactivated,
|
|
98
|
+
clearSelection,
|
|
99
|
+
}) }), _jsx(ConfirmActionButton, { buttonLabel: props.messages.tabs.rules.bulkDeleteButton, confirmLabel: props.messages.tabs.rules.bulkDeleteConfirm, title: formatTemplate(props.messages.tabs.rules.bulkDeleteTitle, {
|
|
100
|
+
selection: selection(selectedRows.length),
|
|
101
|
+
}), description: props.messages.tabs.rules.bulkDeleteDescription, disabled: props.bulkActionTarget === "rules-delete", variant: "destructive", confirmVariant: "destructive", onConfirm: () => props.handleBulkDelete({
|
|
102
|
+
ids: selectedRows.map((row) => row.original.id),
|
|
103
|
+
endpoint: "/v1/availability/rules",
|
|
104
|
+
target: "rules-delete",
|
|
105
|
+
nounSingular: props.messages.nouns.ruleSingular,
|
|
106
|
+
nounPlural: props.messages.nouns.rulePlural,
|
|
107
|
+
clearSelection,
|
|
108
|
+
}) })] })), onRowClick: (row) => props.onEdit(row.original) })] }));
|
|
109
|
+
}
|
|
110
|
+
export function AvailabilityStartTimesTab(props) {
|
|
111
|
+
const selection = (count) => formatLocalizedSelectionLabel(count, props.messages.nouns.startTimeSingular, props.messages.nouns.startTimePlural);
|
|
112
|
+
return (_jsxs(TabsContent, { value: "start-times", className: "space-y-4", children: [_jsx(AvailabilitySectionHeader, { title: props.messages.tabs.startTimes.title, description: props.messages.tabs.startTimes.description, actionLabel: props.messages.tabs.startTimes.actionLabel, onAction: props.onCreate }), props.toolbar, _jsx(DataTable, { columns: availabilityStartTimeColumns(props.products, props.onOpenRoute, props.messages), data: props.filteredStartTimes, emptyMessage: props.messages.tabs.startTimes.emptyMessage, enableRowSelection: true, getRowId: (row) => row.id, rowSelection: props.startTimeSelection, onRowSelectionChange: props.setStartTimeSelection, renderSelectionActions: ({ selectedRows, clearSelection }) => (_jsxs(SelectionActionBar, { selectedCount: selectedRows.length, onClear: clearSelection, children: [_jsx(ConfirmActionButton, { buttonLabel: props.messages.tabs.startTimes.bulkActivateButton, confirmLabel: props.messages.tabs.startTimes.bulkActivateConfirm, title: formatTemplate(props.messages.tabs.startTimes.bulkActivateTitle, {
|
|
113
|
+
selection: selection(selectedRows.length),
|
|
114
|
+
}), description: props.messages.tabs.startTimes.bulkActivateDescription, disabled: props.bulkActionTarget === "start-times-activate", onConfirm: () => props.handleBulkUpdate({
|
|
115
|
+
ids: selectedRows.map((row) => row.original.id),
|
|
116
|
+
endpoint: "/v1/availability/start-times",
|
|
117
|
+
target: "start-times-activate",
|
|
118
|
+
nounSingular: props.messages.nouns.startTimeSingular,
|
|
119
|
+
nounPlural: props.messages.nouns.startTimePlural,
|
|
120
|
+
payload: { active: true },
|
|
121
|
+
successVerb: props.messages.verbActivated,
|
|
122
|
+
clearSelection,
|
|
123
|
+
}) }), _jsx(ConfirmActionButton, { buttonLabel: props.messages.tabs.startTimes.bulkDeactivateButton, confirmLabel: props.messages.tabs.startTimes.bulkDeactivateConfirm, title: formatTemplate(props.messages.tabs.startTimes.bulkDeactivateTitle, {
|
|
124
|
+
selection: selection(selectedRows.length),
|
|
125
|
+
}), description: props.messages.tabs.startTimes.bulkDeactivateDescription, disabled: props.bulkActionTarget === "start-times-deactivate", onConfirm: () => props.handleBulkUpdate({
|
|
126
|
+
ids: selectedRows.map((row) => row.original.id),
|
|
127
|
+
endpoint: "/v1/availability/start-times",
|
|
128
|
+
target: "start-times-deactivate",
|
|
129
|
+
nounSingular: props.messages.nouns.startTimeSingular,
|
|
130
|
+
nounPlural: props.messages.nouns.startTimePlural,
|
|
131
|
+
payload: { active: false },
|
|
132
|
+
successVerb: props.messages.verbDeactivated,
|
|
133
|
+
clearSelection,
|
|
134
|
+
}) }), _jsx(ConfirmActionButton, { buttonLabel: props.messages.tabs.startTimes.bulkDeleteButton, confirmLabel: props.messages.tabs.startTimes.bulkDeleteConfirm, title: formatTemplate(props.messages.tabs.startTimes.bulkDeleteTitle, {
|
|
135
|
+
selection: selection(selectedRows.length),
|
|
136
|
+
}), description: props.messages.tabs.startTimes.bulkDeleteDescription, disabled: props.bulkActionTarget === "start-times-delete", variant: "destructive", confirmVariant: "destructive", onConfirm: () => props.handleBulkDelete({
|
|
137
|
+
ids: selectedRows.map((row) => row.original.id),
|
|
138
|
+
endpoint: "/v1/availability/start-times",
|
|
139
|
+
target: "start-times-delete",
|
|
140
|
+
nounSingular: props.messages.nouns.startTimeSingular,
|
|
141
|
+
nounPlural: props.messages.nouns.startTimePlural,
|
|
142
|
+
clearSelection,
|
|
143
|
+
}) })] })), onRowClick: (row) => props.onEdit(row.original) })] }));
|
|
144
|
+
}
|
|
145
|
+
export function AvailabilityCloseoutsTab(props) {
|
|
146
|
+
const selection = (count) => formatLocalizedSelectionLabel(count, props.messages.nouns.closeoutSingular, props.messages.nouns.closeoutPlural);
|
|
147
|
+
return (_jsxs(TabsContent, { value: "closeouts", className: "space-y-4", children: [_jsx(AvailabilitySectionHeader, { title: props.messages.tabs.closeouts.title, description: props.messages.tabs.closeouts.description, actionLabel: props.messages.tabs.closeouts.actionLabel, onAction: props.onCreate }), props.toolbar, _jsx(DataTable, { columns: availabilityCloseoutColumns(props.products, props.messages), data: props.filteredCloseouts, emptyMessage: props.messages.tabs.closeouts.emptyMessage, enableRowSelection: true, getRowId: (row) => row.id, rowSelection: props.closeoutSelection, onRowSelectionChange: props.setCloseoutSelection, renderSelectionActions: ({ selectedRows, clearSelection }) => (_jsx(SelectionActionBar, { selectedCount: selectedRows.length, onClear: clearSelection, children: _jsx(ConfirmActionButton, { buttonLabel: props.messages.tabs.closeouts.bulkDeleteButton, confirmLabel: props.messages.tabs.closeouts.bulkDeleteConfirm, title: formatTemplate(props.messages.tabs.closeouts.bulkDeleteTitle, {
|
|
148
|
+
selection: selection(selectedRows.length),
|
|
149
|
+
}), description: props.messages.tabs.closeouts.bulkDeleteDescription, disabled: props.bulkActionTarget === "closeouts-delete", variant: "destructive", confirmVariant: "destructive", onConfirm: () => props.handleBulkDelete({
|
|
150
|
+
ids: selectedRows.map((row) => row.original.id),
|
|
151
|
+
endpoint: "/v1/availability/closeouts",
|
|
152
|
+
target: "closeouts-delete",
|
|
153
|
+
nounSingular: props.messages.nouns.closeoutSingular,
|
|
154
|
+
nounPlural: props.messages.nouns.closeoutPlural,
|
|
155
|
+
clearSelection,
|
|
156
|
+
}) }) })), onRowClick: (row) => props.onEdit(row.original) })] }));
|
|
157
|
+
}
|
|
158
|
+
export function AvailabilityPickupPointsTab(props) {
|
|
159
|
+
const selection = (count) => formatLocalizedSelectionLabel(count, props.messages.nouns.pickupPointSingular, props.messages.nouns.pickupPointPlural);
|
|
160
|
+
return (_jsxs(TabsContent, { value: "pickup-points", className: "space-y-4", children: [_jsx(AvailabilitySectionHeader, { title: props.messages.tabs.pickupPoints.title, description: props.messages.tabs.pickupPoints.description, actionLabel: props.messages.tabs.pickupPoints.actionLabel, onAction: props.onCreate }), props.toolbar, _jsx(DataTable, { columns: availabilityPickupPointColumns(props.products, props.messages), data: props.filteredPickupPoints, emptyMessage: props.messages.tabs.pickupPoints.emptyMessage, enableRowSelection: true, getRowId: (row) => row.id, rowSelection: props.pickupPointSelection, onRowSelectionChange: props.setPickupPointSelection, renderSelectionActions: ({ selectedRows, clearSelection }) => (_jsxs(SelectionActionBar, { selectedCount: selectedRows.length, onClear: clearSelection, children: [_jsx(ConfirmActionButton, { buttonLabel: props.messages.tabs.pickupPoints.bulkActivateButton, confirmLabel: props.messages.tabs.pickupPoints.bulkActivateConfirm, title: formatTemplate(props.messages.tabs.pickupPoints.bulkActivateTitle, {
|
|
161
|
+
selection: selection(selectedRows.length),
|
|
162
|
+
}), description: props.messages.tabs.pickupPoints.bulkActivateDescription, disabled: props.bulkActionTarget === "pickup-points-activate", onConfirm: () => props.handleBulkUpdate({
|
|
163
|
+
ids: selectedRows.map((row) => row.original.id),
|
|
164
|
+
endpoint: "/v1/availability/pickup-points",
|
|
165
|
+
target: "pickup-points-activate",
|
|
166
|
+
nounSingular: props.messages.nouns.pickupPointSingular,
|
|
167
|
+
nounPlural: props.messages.nouns.pickupPointPlural,
|
|
168
|
+
payload: { active: true },
|
|
169
|
+
successVerb: props.messages.verbActivated,
|
|
170
|
+
clearSelection,
|
|
171
|
+
}) }), _jsx(ConfirmActionButton, { buttonLabel: props.messages.tabs.pickupPoints.bulkDeactivateButton, confirmLabel: props.messages.tabs.pickupPoints.bulkDeactivateConfirm, title: formatTemplate(props.messages.tabs.pickupPoints.bulkDeactivateTitle, {
|
|
172
|
+
selection: selection(selectedRows.length),
|
|
173
|
+
}), description: props.messages.tabs.pickupPoints.bulkDeactivateDescription, disabled: props.bulkActionTarget === "pickup-points-deactivate", onConfirm: () => props.handleBulkUpdate({
|
|
174
|
+
ids: selectedRows.map((row) => row.original.id),
|
|
175
|
+
endpoint: "/v1/availability/pickup-points",
|
|
176
|
+
target: "pickup-points-deactivate",
|
|
177
|
+
nounSingular: props.messages.nouns.pickupPointSingular,
|
|
178
|
+
nounPlural: props.messages.nouns.pickupPointPlural,
|
|
179
|
+
payload: { active: false },
|
|
180
|
+
successVerb: props.messages.verbDeactivated,
|
|
181
|
+
clearSelection,
|
|
182
|
+
}) }), _jsx(ConfirmActionButton, { buttonLabel: props.messages.tabs.pickupPoints.bulkDeleteButton, confirmLabel: props.messages.tabs.pickupPoints.bulkDeleteConfirm, title: formatTemplate(props.messages.tabs.pickupPoints.bulkDeleteTitle, {
|
|
183
|
+
selection: selection(selectedRows.length),
|
|
184
|
+
}), description: props.messages.tabs.pickupPoints.bulkDeleteDescription, disabled: props.bulkActionTarget === "pickup-points-delete", variant: "destructive", confirmVariant: "destructive", onConfirm: () => props.handleBulkDelete({
|
|
185
|
+
ids: selectedRows.map((row) => row.original.id),
|
|
186
|
+
endpoint: "/v1/availability/pickup-points",
|
|
187
|
+
target: "pickup-points-delete",
|
|
188
|
+
nounSingular: props.messages.nouns.pickupPointSingular,
|
|
189
|
+
nounPlural: props.messages.nouns.pickupPointPlural,
|
|
190
|
+
clearSelection,
|
|
191
|
+
}) })] })), onRowClick: (row) => props.onEdit(row.original) })] }));
|
|
192
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SlotStatusTone } from "../index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Tailwind classes for the color-coded slot status badge. Pair with
|
|
4
|
+
* `<Badge variant="outline" className={slotStatusToneClass[tone]}>`.
|
|
5
|
+
*
|
|
6
|
+
* Kept inside `availability-ui` (not `availability-react`) so the
|
|
7
|
+
* Tailwind `@source` scan in operator/dmc templates picks the class
|
|
8
|
+
* strings up — those templates only glob the UI packages.
|
|
9
|
+
*
|
|
10
|
+
* Palette mirrors `@voyantjs/bookings-react/ui`'s `StatusBadge` so slot
|
|
11
|
+
* statuses sit alongside booking statuses with identical color and
|
|
12
|
+
* weight.
|
|
13
|
+
*/
|
|
14
|
+
export declare const slotStatusToneClass: Record<SlotStatusTone, string>;
|
|
15
|
+
//# sourceMappingURL=slot-status-tone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot-status-tone.d.ts","sourceRoot":"","sources":["../../src/components/slot-status-tone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,cAAc,EAAE,MAAM,CAK9D,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tailwind classes for the color-coded slot status badge. Pair with
|
|
3
|
+
* `<Badge variant="outline" className={slotStatusToneClass[tone]}>`.
|
|
4
|
+
*
|
|
5
|
+
* Kept inside `availability-ui` (not `availability-react`) so the
|
|
6
|
+
* Tailwind `@source` scan in operator/dmc templates picks the class
|
|
7
|
+
* strings up — those templates only glob the UI packages.
|
|
8
|
+
*
|
|
9
|
+
* Palette mirrors `@voyantjs/bookings-react/ui`'s `StatusBadge` so slot
|
|
10
|
+
* statuses sit alongside booking statuses with identical color and
|
|
11
|
+
* weight.
|
|
12
|
+
*/
|
|
13
|
+
export const slotStatusToneClass = {
|
|
14
|
+
success: "border-transparent bg-green-500/10 text-green-600 dark:text-green-400",
|
|
15
|
+
warning: "border-transparent bg-yellow-500/10 text-yellow-700 dark:text-yellow-400",
|
|
16
|
+
danger: "border-transparent bg-red-500/10 text-red-600 dark:text-red-400",
|
|
17
|
+
neutral: "",
|
|
18
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FieldValues, Resolver } from "react-hook-form";
|
|
2
|
+
import type { z } from "zod/v4";
|
|
3
|
+
export declare function zodResolver<TSchema extends z.ZodType<FieldValues, FieldValues>>(schema: TSchema): Resolver<z.input<TSchema>, unknown, z.output<TSchema>>;
|
|
4
|
+
//# sourceMappingURL=form-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-resolver.d.ts","sourceRoot":"","sources":["../src/form-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,WAAW,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACzE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AA+B/B,wBAAgB,WAAW,CAAC,OAAO,SAAS,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC,EAC7E,MAAM,EAAE,OAAO,GACd,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CA8BxD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function setFieldError(target, path, error) {
|
|
2
|
+
let current = target;
|
|
3
|
+
for (let index = 0; index < path.length; index += 1) {
|
|
4
|
+
const key = String(path[index] ?? "root");
|
|
5
|
+
if (index === path.length - 1) {
|
|
6
|
+
current[key] = error;
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const next = current[key];
|
|
10
|
+
if (typeof next !== "object" || next === null) {
|
|
11
|
+
current[key] = {};
|
|
12
|
+
}
|
|
13
|
+
current = current[key];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function zodResolver(schema) {
|
|
17
|
+
// i18n-literal-ok type annotation
|
|
18
|
+
return async (values) => {
|
|
19
|
+
const result = await schema.safeParseAsync(values);
|
|
20
|
+
if (result.success) {
|
|
21
|
+
return {
|
|
22
|
+
values: result.data,
|
|
23
|
+
errors: {},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const errors = {};
|
|
27
|
+
for (const issue of result.error.issues) {
|
|
28
|
+
const path = issue.path.filter((segment) => typeof segment !== "symbol");
|
|
29
|
+
const normalizedPath = path.length > 0 ? path : ["root"];
|
|
30
|
+
setFieldError(errors, normalizedPath, {
|
|
31
|
+
type: issue.code,
|
|
32
|
+
message: issue.message,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
values: {},
|
|
37
|
+
errors: errors,
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { type AvailabilityUiMessageOverrides, type AvailabilityUiMessages, AvailabilityUiMessagesProvider, availabilityUiEn, availabilityUiMessageDefinitions, availabilityUiRo, getAvailabilityUiI18n, resolveAvailabilityUiMessages, useAvailabilityUiI18n, useAvailabilityUiI18nOrDefault, useAvailabilityUiMessages, useAvailabilityUiMessagesOrDefault, } from "./provider.js";
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,EAC3B,8BAA8B,EAC9B,gBAAgB,EAChB,gCAAgC,EAChC,gBAAgB,EAChB,qBAAqB,EACrB,6BAA6B,EAC7B,qBAAqB,EACrB,8BAA8B,EAC9B,yBAAyB,EACzB,kCAAkC,GACnC,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AvailabilityUiMessagesProvider, availabilityUiEn, availabilityUiMessageDefinitions, availabilityUiRo, getAvailabilityUiI18n, resolveAvailabilityUiMessages, useAvailabilityUiI18n, useAvailabilityUiI18nOrDefault, useAvailabilityUiMessages, useAvailabilityUiMessagesOrDefault, } from "./provider.js";
|