@voyantjs/products-ui 0.101.1 → 0.101.2

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.
Files changed (121) hide show
  1. package/dist/components/product-detail/date-picker.d.ts +44 -0
  2. package/dist/components/product-detail/date-picker.d.ts.map +1 -0
  3. package/dist/components/product-detail/date-picker.js +125 -0
  4. package/dist/components/product-detail/host.d.ts +53 -0
  5. package/dist/components/product-detail/host.d.ts.map +1 -0
  6. package/dist/components/product-detail/host.js +24 -0
  7. package/dist/components/product-detail/index.d.ts +6 -0
  8. package/dist/components/product-detail/index.d.ts.map +1 -0
  9. package/dist/components/product-detail/index.js +5 -0
  10. package/dist/components/product-detail/product-activity-section.d.ts +4 -0
  11. package/dist/components/product-detail/product-activity-section.d.ts.map +1 -0
  12. package/dist/components/product-detail/product-activity-section.js +37 -0
  13. package/dist/components/product-detail/product-day-sheet.d.ts +14 -0
  14. package/dist/components/product-detail/product-day-sheet.d.ts.map +1 -0
  15. package/dist/components/product-detail/product-day-sheet.js +75 -0
  16. package/dist/components/product-detail/product-day-translation.d.ts +41 -0
  17. package/dist/components/product-detail/product-day-translation.d.ts.map +1 -0
  18. package/dist/components/product-detail/product-day-translation.js +111 -0
  19. package/dist/components/product-detail/product-departure-dialog.d.ts +11 -0
  20. package/dist/components/product-detail/product-departure-dialog.d.ts.map +1 -0
  21. package/dist/components/product-detail/product-departure-dialog.js +10 -0
  22. package/dist/components/product-detail/product-departure-form.d.ts +25 -0
  23. package/dist/components/product-detail/product-departure-form.d.ts.map +1 -0
  24. package/dist/components/product-detail/product-departure-form.js +217 -0
  25. package/dist/components/product-detail/product-departure-pricing-override-dialog.d.ts +8 -0
  26. package/dist/components/product-detail/product-departure-pricing-override-dialog.d.ts.map +1 -0
  27. package/dist/components/product-detail/product-departure-pricing-override-dialog.js +125 -0
  28. package/dist/components/product-detail/product-detail-day-row.d.ts +14 -0
  29. package/dist/components/product-detail/product-detail-day-row.d.ts.map +1 -0
  30. package/dist/components/product-detail/product-detail-day-row.js +43 -0
  31. package/dist/components/product-detail/product-detail-dialog.d.ts +10 -0
  32. package/dist/components/product-detail/product-detail-dialog.d.ts.map +1 -0
  33. package/dist/components/product-detail/product-detail-dialog.js +10 -0
  34. package/dist/components/product-detail/product-detail-form.d.ts +19 -0
  35. package/dist/components/product-detail/product-detail-form.d.ts.map +1 -0
  36. package/dist/components/product-detail/product-detail-form.js +177 -0
  37. package/dist/components/product-detail/product-detail-header.d.ts +12 -0
  38. package/dist/components/product-detail/product-detail-header.d.ts.map +1 -0
  39. package/dist/components/product-detail/product-detail-header.js +19 -0
  40. package/dist/components/product-detail/product-detail-itinerary-section.d.ts +4 -0
  41. package/dist/components/product-detail/product-detail-itinerary-section.d.ts.map +1 -0
  42. package/dist/components/product-detail/product-detail-itinerary-section.js +201 -0
  43. package/dist/components/product-detail/product-detail-page.d.ts +4 -0
  44. package/dist/components/product-detail/product-detail-page.d.ts.map +1 -0
  45. package/dist/components/product-detail/product-detail-page.js +97 -0
  46. package/dist/components/product-detail/product-detail-sections.d.ts +63 -0
  47. package/dist/components/product-detail/product-detail-sections.d.ts.map +1 -0
  48. package/dist/components/product-detail/product-detail-sections.js +143 -0
  49. package/dist/components/product-detail/product-detail-shared.d.ts +264 -0
  50. package/dist/components/product-detail/product-detail-shared.d.ts.map +1 -0
  51. package/dist/components/product-detail/product-detail-shared.js +157 -0
  52. package/dist/components/product-detail/product-detail-skeleton.d.ts +9 -0
  53. package/dist/components/product-detail/product-detail-skeleton.d.ts.map +1 -0
  54. package/dist/components/product-detail/product-detail-skeleton.js +53 -0
  55. package/dist/components/product-detail/product-extras-section.d.ts +4 -0
  56. package/dist/components/product-detail/product-extras-section.d.ts.map +1 -0
  57. package/dist/components/product-detail/product-extras-section.js +141 -0
  58. package/dist/components/product-detail/product-itinerary-form.d.ts +16 -0
  59. package/dist/components/product-detail/product-itinerary-form.d.ts.map +1 -0
  60. package/dist/components/product-detail/product-itinerary-form.js +38 -0
  61. package/dist/components/product-detail/product-market-rules-section.d.ts +6 -0
  62. package/dist/components/product-detail/product-market-rules-section.d.ts.map +1 -0
  63. package/dist/components/product-detail/product-market-rules-section.js +81 -0
  64. package/dist/components/product-detail/product-media-gallery.d.ts +19 -0
  65. package/dist/components/product-detail/product-media-gallery.d.ts.map +1 -0
  66. package/dist/components/product-detail/product-media-gallery.js +114 -0
  67. package/dist/components/product-detail/product-option-price-rule-dialog.d.ts +12 -0
  68. package/dist/components/product-detail/product-option-price-rule-dialog.d.ts.map +1 -0
  69. package/dist/components/product-detail/product-option-price-rule-dialog.js +10 -0
  70. package/dist/components/product-detail/product-option-price-rule-form.d.ts +29 -0
  71. package/dist/components/product-detail/product-option-price-rule-form.d.ts.map +1 -0
  72. package/dist/components/product-detail/product-option-price-rule-form.js +125 -0
  73. package/dist/components/product-detail/product-options-pricing.d.ts +6 -0
  74. package/dist/components/product-detail/product-options-pricing.d.ts.map +1 -0
  75. package/dist/components/product-detail/product-options-pricing.js +363 -0
  76. package/dist/components/product-detail/product-options-shared.d.ts +609 -0
  77. package/dist/components/product-detail/product-options-shared.d.ts.map +1 -0
  78. package/dist/components/product-detail/product-options-shared.js +34 -0
  79. package/dist/components/product-detail/product-payment-policy-section.d.ts +17 -0
  80. package/dist/components/product-detail/product-payment-policy-section.d.ts.map +1 -0
  81. package/dist/components/product-detail/product-payment-policy-section.js +58 -0
  82. package/dist/components/product-detail/product-schedule-dialog.d.ts +11 -0
  83. package/dist/components/product-detail/product-schedule-dialog.d.ts.map +1 -0
  84. package/dist/components/product-detail/product-schedule-dialog.js +10 -0
  85. package/dist/components/product-detail/product-schedule-form.d.ts +17 -0
  86. package/dist/components/product-detail/product-schedule-form.d.ts.map +1 -0
  87. package/dist/components/product-detail/product-schedule-form.js +222 -0
  88. package/dist/components/product-detail/product-service-dialog.d.ts +12 -0
  89. package/dist/components/product-detail/product-service-dialog.d.ts.map +1 -0
  90. package/dist/components/product-detail/product-service-dialog.js +10 -0
  91. package/dist/components/product-detail/product-service-form.d.ts +22 -0
  92. package/dist/components/product-detail/product-service-form.d.ts.map +1 -0
  93. package/dist/components/product-detail/product-service-form.js +154 -0
  94. package/dist/components/product-detail/product-translation-popover.d.ts +91 -0
  95. package/dist/components/product-detail/product-translation-popover.d.ts.map +1 -0
  96. package/dist/components/product-detail/product-translation-popover.js +217 -0
  97. package/dist/components/product-detail/product-unit-dialog.d.ts +12 -0
  98. package/dist/components/product-detail/product-unit-dialog.d.ts.map +1 -0
  99. package/dist/components/product-detail/product-unit-dialog.js +10 -0
  100. package/dist/components/product-detail/product-unit-form.d.ts +26 -0
  101. package/dist/components/product-detail/product-unit-form.d.ts.map +1 -0
  102. package/dist/components/product-detail/product-unit-form.js +109 -0
  103. package/dist/components/product-detail/product-unit-price-rule-dialog.d.ts +16 -0
  104. package/dist/components/product-detail/product-unit-price-rule-dialog.d.ts.map +1 -0
  105. package/dist/components/product-detail/product-unit-price-rule-dialog.js +10 -0
  106. package/dist/components/product-detail/product-unit-price-rule-form.d.ts +28 -0
  107. package/dist/components/product-detail/product-unit-price-rule-form.d.ts.map +1 -0
  108. package/dist/components/product-detail/product-unit-price-rule-form.js +126 -0
  109. package/dist/components/product-detail/timezone-options.d.ts +9 -0
  110. package/dist/components/product-detail/timezone-options.d.ts.map +1 -0
  111. package/dist/components/product-detail/timezone-options.js +28 -0
  112. package/dist/components/product-detail/use-product-detail-data.d.ts +41 -0
  113. package/dist/components/product-detail/use-product-detail-data.d.ts.map +1 -0
  114. package/dist/components/product-detail/use-product-detail-data.js +143 -0
  115. package/dist/components/product-detail/use-product-detail-dialogs.d.ts +24 -0
  116. package/dist/components/product-detail/use-product-detail-dialogs.d.ts.map +1 -0
  117. package/dist/components/product-detail/use-product-detail-dialogs.js +40 -0
  118. package/dist/components/product-detail/zod-resolver.d.ts +4 -0
  119. package/dist/components/product-detail/zod-resolver.d.ts.map +1 -0
  120. package/dist/components/product-detail/zod-resolver.js +39 -0
  121. package/package.json +38 -19
@@ -0,0 +1,177 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { Badge, Button, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@voyantjs/ui/components";
4
+ import { Combobox, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList, } from "@voyantjs/ui/components/combobox";
5
+ import { currencies } from "@voyantjs/utils/currencies";
6
+ import { Loader2, X } from "lucide-react";
7
+ import { useEffect, useState } from "react";
8
+ import { useForm } from "react-hook-form";
9
+ import { z } from "zod/v4";
10
+ import { useProductDetailApi, useProductDetailMessages, useProductLocale } from "./host.js";
11
+ import { ContentLanguageSwitcher, LanguageCombobox, TranslatableField, useProductTranslationDrafts, } from "./product-translation-popover.js";
12
+ import { zodResolver } from "./zod-resolver.js";
13
+ const CURRENCY_OPTIONS = Object.values(currencies).map((c) => ({
14
+ value: c.code,
15
+ label: `${c.code} — ${c.name} (${c.symbol})`,
16
+ }));
17
+ function initialValues(product) {
18
+ if (product) {
19
+ return {
20
+ name: product.name,
21
+ status: product.status,
22
+ description: product.description ?? "",
23
+ bookingMode: product.bookingMode,
24
+ productTypeId: product.productTypeId ?? "",
25
+ taxClassId: product.taxClassId ?? "",
26
+ sellCurrency: product.sellCurrency,
27
+ tags: product.tags ?? [],
28
+ defaultLanguageTag: product.defaultLanguageTag ?? "",
29
+ };
30
+ }
31
+ return {
32
+ name: "",
33
+ status: "draft",
34
+ description: "",
35
+ bookingMode: "itinerary",
36
+ productTypeId: "",
37
+ taxClassId: "",
38
+ sellCurrency: "EUR",
39
+ tags: [],
40
+ defaultLanguageTag: "",
41
+ };
42
+ }
43
+ export function ProductDetailForm({ product, onSuccess, onCancel }) {
44
+ const messages = useProductDetailMessages();
45
+ const api = useProductDetailApi();
46
+ const productMessages = messages.products.core;
47
+ const isEditing = !!product;
48
+ const productFormSchema = z.object({
49
+ name: z.string().min(1, productMessages.validationNameRequired),
50
+ status: z.enum(["draft", "active", "archived"]),
51
+ description: z.string().optional().nullable(),
52
+ bookingMode: z.enum(["date", "date_time", "open", "stay", "transfer", "itinerary", "other"]),
53
+ productTypeId: z.string().optional().nullable(),
54
+ taxClassId: z.string().optional().nullable(),
55
+ sellCurrency: z
56
+ .string()
57
+ .min(3, productMessages.validationIsoCurrency)
58
+ .max(3, productMessages.validationIsoCurrency),
59
+ tags: z.array(z.string()).default([]),
60
+ defaultLanguageTag: z.string().optional().nullable(),
61
+ });
62
+ const productStatuses = [
63
+ { value: "draft", label: productMessages.statusDraft },
64
+ { value: "active", label: productMessages.statusActive },
65
+ { value: "archived", label: productMessages.statusArchived },
66
+ ];
67
+ const bookingModes = [
68
+ { value: "date", label: productMessages.bookingModeDate },
69
+ { value: "date_time", label: productMessages.bookingModeDateTime },
70
+ { value: "open", label: productMessages.bookingModeOpen },
71
+ { value: "stay", label: productMessages.bookingModeStay },
72
+ { value: "transfer", label: productMessages.bookingModeTransfer },
73
+ { value: "itinerary", label: productMessages.bookingModeItinerary },
74
+ { value: "other", label: productMessages.bookingModeOther },
75
+ ];
76
+ const form = useForm({
77
+ resolver: zodResolver(productFormSchema),
78
+ defaultValues: initialValues(product),
79
+ });
80
+ const translations = useProductTranslationDrafts(product?.id ?? null);
81
+ const resolvedLocale = useProductLocale();
82
+ const adminBaseLocale = resolvedLocale.split("-")[0]?.toLowerCase() || "en";
83
+ const defaultLanguageTag = form.watch("defaultLanguageTag")?.trim() || adminBaseLocale;
84
+ const [activeLanguage, setActiveLanguage] = useState(defaultLanguageTag);
85
+ // Following the default language keeps the active field in sync when the
86
+ // product changes (form.reset) or the default-language setting is edited.
87
+ useEffect(() => {
88
+ setActiveLanguage(defaultLanguageTag);
89
+ }, [defaultLanguageTag]);
90
+ const [tagInput, setTagInput] = useState("");
91
+ const { data: typesData } = useQuery({
92
+ queryKey: ["product-types"],
93
+ queryFn: () => api.get("/v1/products/product-types?limit=25&active=true"),
94
+ });
95
+ const { data: taxClassesData } = useQuery({
96
+ queryKey: ["tax-classes"],
97
+ queryFn: () => api.get("/v1/admin/finance/tax-classes?limit=100&active=true"),
98
+ });
99
+ const productTypes = typesData?.data ?? [];
100
+ const taxClasses = taxClassesData?.data ?? [];
101
+ useEffect(() => {
102
+ form.reset(initialValues(product));
103
+ setTagInput("");
104
+ }, [product, form]);
105
+ const onSubmit = async (values) => {
106
+ const resolvedDefaultLanguage = values.defaultLanguageTag?.trim() || adminBaseLocale;
107
+ const payload = {
108
+ name: values.name,
109
+ status: values.status,
110
+ description: values.description || null,
111
+ bookingMode: values.bookingMode,
112
+ productTypeId: values.productTypeId || null,
113
+ taxClassId: values.taxClassId || null,
114
+ sellCurrency: values.sellCurrency,
115
+ tags: values.tags,
116
+ defaultLanguageTag: resolvedDefaultLanguage,
117
+ };
118
+ const persistOptions = {
119
+ defaultLanguageTag: resolvedDefaultLanguage,
120
+ baseName: values.name,
121
+ baseDescription: values.description ?? "",
122
+ };
123
+ if (isEditing) {
124
+ await api.patch(`/v1/products/${product.id}`, payload);
125
+ await translations.persist(product.id, persistOptions);
126
+ onSuccess();
127
+ }
128
+ else {
129
+ const result = await api.post("/v1/products", payload);
130
+ await translations.persist(result.id, persistOptions);
131
+ onSuccess(result.id);
132
+ }
133
+ };
134
+ return (_jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-1 flex-col gap-4 overflow-hidden", children: [_jsxs("div", { className: "grid gap-4", children: [_jsx(ContentLanguageSwitcher, { activeLanguage: activeLanguage, defaultLanguageTag: defaultLanguageTag, languageTags: translations.drafts.map((draft) => draft.languageTag), messages: productMessages, onSelect: setActiveLanguage, onAddLanguage: (code) => {
135
+ translations.addLanguage(code);
136
+ setActiveLanguage(code);
137
+ }, onRemoveLanguage: (code) => {
138
+ translations.removeLanguage(code);
139
+ if (activeLanguage === code)
140
+ setActiveLanguage(defaultLanguageTag);
141
+ } }), _jsx(TranslatableField, { label: productMessages.nameLabel, type: "text", field: "name", activeLanguage: activeLanguage, defaultLanguageTag: defaultLanguageTag, base: {
142
+ value: form.watch("name") ?? "",
143
+ onChange: (value) => form.setValue("name", value, { shouldDirty: true, shouldValidate: true }),
144
+ }, translations: translations, messages: productMessages, placeholder: productMessages.namePlaceholder, autoFocus: true, error: form.formState.errors.name?.message }), _jsx(TranslatableField, { label: productMessages.descriptionLabel, type: "richtext", field: "description", activeLanguage: activeLanguage, defaultLanguageTag: defaultLanguageTag, base: {
145
+ value: form.watch("description") ?? "",
146
+ onChange: (value) => form.setValue("description", value, { shouldDirty: true }),
147
+ }, translations: translations, messages: productMessages, placeholder: productMessages.descriptionPlaceholder }), _jsx(TranslatableField, { label: productMessages.slugLabel, type: "text", field: "slug", activeLanguage: activeLanguage, defaultLanguageTag: defaultLanguageTag, translations: translations, messages: productMessages, placeholder: productMessages.slugPlaceholder }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: productMessages.defaultLanguageLabel }), _jsx(LanguageCombobox, { value: form.watch("defaultLanguageTag")?.trim() || adminBaseLocale, onValueChange: (code) => form.setValue("defaultLanguageTag", code, { shouldDirty: true }), placeholder: productMessages.translationLanguageSearch, emptyLabel: productMessages.translationLanguageEmpty }), _jsx("p", { className: "text-xs text-muted-foreground", children: productMessages.defaultLanguageHint })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: productMessages.tagsLabel }), _jsx("div", { className: "flex flex-wrap gap-1.5", children: (form.watch("tags") ?? []).map((tag) => (_jsxs(Badge, { variant: "secondary", className: "gap-1 text-xs", children: [tag, _jsx("button", { type: "button", className: "ml-0.5 rounded-full hover:text-destructive", onClick: () => {
148
+ const current = form.getValues("tags") ?? [];
149
+ form.setValue("tags", current.filter((t) => t !== tag), { shouldDirty: true });
150
+ }, children: _jsx(X, { className: "h-3 w-3" }) })] }, tag))) }), _jsx(Input, { value: tagInput, onChange: (e) => setTagInput(e.target.value), onKeyDown: (e) => {
151
+ if (e.key === "Enter" || e.key === ",") {
152
+ e.preventDefault();
153
+ const value = tagInput.trim().replace(/,+$/, "");
154
+ const current = form.getValues("tags") ?? [];
155
+ if (value && !current.includes(value)) {
156
+ form.setValue("tags", [...current, value], { shouldDirty: true });
157
+ }
158
+ setTagInput("");
159
+ }
160
+ }, placeholder: productMessages.tagInputPlaceholder })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: productMessages.bookingModeLabel }), _jsxs(Select, { value: form.watch("bookingMode"), onValueChange: (v) => form.setValue("bookingMode", v), items: bookingModes, children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: bookingModes.map((m) => (_jsx(SelectItem, { value: m.value, children: m.label }, m.value))) })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: productMessages.productTypeLabel }), _jsxs(Select, { value: form.watch("productTypeId") ?? "", onValueChange: (v) => form.setValue("productTypeId", v === "__none__" ? null : v, {
161
+ shouldDirty: true,
162
+ }), items: [
163
+ { value: "__none__", label: productMessages.productTypeNone },
164
+ ...productTypes.map((t) => ({ value: t.id, label: t.name })),
165
+ ], children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, { placeholder: productMessages.productTypeNone }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "__none__", children: productMessages.productTypeNone }), productTypes.map((t) => (_jsx(SelectItem, { value: t.id, children: t.name }, t.id)))] })] })] })] }), isEditing && (_jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: productMessages.statusLabel }), _jsxs(Select, { value: form.watch("status"), onValueChange: (v) => form.setValue("status", v), items: productStatuses, children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: productStatuses.map((s) => (_jsx(SelectItem, { value: s.value, children: s.label }, s.value))) })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: productMessages.taxClassLabel }), _jsxs(Select, { value: form.watch("taxClassId") ?? "", onValueChange: (v) => form.setValue("taxClassId", v === "__none__" ? null : v, {
166
+ shouldDirty: true,
167
+ }), items: [
168
+ { value: "__none__", label: productMessages.taxClassNone },
169
+ ...taxClasses.map((taxClass) => ({
170
+ value: taxClass.id,
171
+ label: taxClass.label,
172
+ })),
173
+ ], children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, { placeholder: productMessages.taxClassNone }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "__none__", children: productMessages.taxClassNone }), taxClasses.map((taxClass) => (_jsx(SelectItem, { value: taxClass.id, children: taxClass.label }, taxClass.id)))] })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: productMessages.sellCurrencyLabel }), _jsx(CurrencyCombobox, { value: form.watch("sellCurrency"), onChange: (v) => form.setValue("sellCurrency", v, { shouldDirty: true }), messages: productMessages }), form.formState.errors.sellCurrency && (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.sellCurrency.message }))] })] }))] }), _jsxs("div", { className: "flex items-center justify-end gap-2", children: [onCancel ? (_jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: onCancel, children: productMessages.cancel })) : null, _jsxs(Button, { type: "submit", size: "sm", disabled: form.formState.isSubmitting, children: [form.formState.isSubmitting && _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }), isEditing ? productMessages.saveChanges : productMessages.createProduct] })] })] }));
174
+ }
175
+ function CurrencyCombobox({ value, onChange, messages, }) {
176
+ return (_jsxs(Combobox, { value: value, onValueChange: (v) => onChange(v ?? ""), children: [_jsx(ComboboxInput, { placeholder: messages.currencySearchPlaceholder, className: "w-full" }), _jsx(ComboboxContent, { children: _jsxs(ComboboxList, { children: [CURRENCY_OPTIONS.map((c) => (_jsxs(ComboboxItem, { value: c.value, children: [_jsx("span", { className: "font-mono text-xs", children: c.value }), _jsx("span", { className: "truncate text-muted-foreground", children: c.label.split(" — ")[1] })] }, c.value))), _jsx(ComboboxEmpty, { children: messages.currencyEmpty })] }) })] }));
177
+ }
@@ -0,0 +1,12 @@
1
+ import type { ProductRecord } from "./product-detail-shared.js";
2
+ export interface ProductDetailHeaderProps {
3
+ product: ProductRecord;
4
+ isDuplicating: boolean;
5
+ isDeleting: boolean;
6
+ onEdit: () => void;
7
+ onAddBooking: () => void;
8
+ onDuplicate: () => void;
9
+ onDelete: () => void;
10
+ }
11
+ export declare function ProductDetailHeader({ product, isDuplicating, isDeleting, onEdit, onAddBooking, onDuplicate, onDelete, }: ProductDetailHeaderProps): import("react/jsx-runtime").JSX.Element;
12
+ //# sourceMappingURL=product-detail-header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-detail-header.d.ts","sourceRoot":"","sources":["../../../src/components/product-detail/product-detail-header.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAG/D,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,aAAa,CAAA;IACtB,aAAa,EAAE,OAAO,CAAA;IACtB,UAAU,EAAE,OAAO,CAAA;IACnB,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,YAAY,EAAE,MAAM,IAAI,CAAA;IACxB,WAAW,EAAE,MAAM,IAAI,CAAA;IACvB,QAAQ,EAAE,MAAM,IAAI,CAAA;CACrB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,aAAa,EACb,UAAU,EACV,MAAM,EACN,YAAY,EACZ,WAAW,EACX,QAAQ,GACT,EAAE,wBAAwB,2CAwC1B"}
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Badge, Button, DropdownMenuItem } from "@voyantjs/ui/components";
3
+ import { CalendarPlus, Copy, Pencil, Trash2 } from "lucide-react";
4
+ import { useEffect } from "react";
5
+ import { useProductDetailHost, useProductDetailMessages } from "./host.js";
6
+ import { ActionMenu } from "./product-detail-sections.js";
7
+ import { getProductStatusLabel, statusVariant } from "./product-detail-shared.js";
8
+ export function ProductDetailHeader({ product, isDuplicating, isDeleting, onEdit, onAddBooking, onDuplicate, onDelete, }) {
9
+ const messages = useProductDetailMessages();
10
+ const productMessages = messages.products.core;
11
+ const { setBreadcrumbs } = useProductDetailHost();
12
+ useEffect(() => {
13
+ setBreadcrumbs?.([
14
+ { label: productMessages.breadcrumbProducts, href: "/products" },
15
+ { label: product.name },
16
+ ]);
17
+ }, [setBreadcrumbs, productMessages.breadcrumbProducts, product.name]);
18
+ return (_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("h1", { className: "text-2xl font-bold tracking-tight", children: product.name }), _jsx(Badge, { variant: statusVariant[product.status] ?? "secondary", children: getProductStatusLabel(product.status, messages) })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsxs(Button, { variant: "outline", size: "sm", onClick: onEdit, children: [_jsx(Pencil, { className: "h-4 w-4" }), productMessages.edit] }), _jsxs(Button, { variant: "outline", size: "sm", onClick: onAddBooking, children: [_jsx(CalendarPlus, { className: "h-4 w-4" }), productMessages.addBooking] }), _jsxs(ActionMenu, { children: [_jsxs(DropdownMenuItem, { disabled: isDuplicating, onClick: onDuplicate, children: [_jsx(Copy, { className: "h-4 w-4" }), productMessages.duplicate] }), _jsxs(DropdownMenuItem, { variant: "destructive", disabled: isDeleting, onClick: onDelete, children: [_jsx(Trash2, { className: "h-4 w-4" }), productMessages.delete] })] })] })] }));
19
+ }
@@ -0,0 +1,4 @@
1
+ export declare function ProductDetailItinerarySection({ productId }: {
2
+ productId: string;
3
+ }): import("react/jsx-runtime").JSX.Element;
4
+ //# sourceMappingURL=product-detail-itinerary-section.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-detail-itinerary-section.d.ts","sourceRoot":"","sources":["../../../src/components/product-detail/product-detail-itinerary-section.tsx"],"names":[],"mappings":"AA6EA,wBAAgB,6BAA6B,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,2CAsXjF"}
@@ -0,0 +1,201 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useQueryClient } from "@tanstack/react-query";
3
+ import { formatMessage } from "@voyantjs/i18n";
4
+ import { productsQueryKeys, useProductDayMutation, useProductItineraries, useProductItineraryDays, useProductItineraryMutation, } from "@voyantjs/products-react";
5
+ import { Badge, Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@voyantjs/ui/components";
6
+ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@voyantjs/ui/components/alert-dialog";
7
+ import { Copy, MoreHorizontal, Pencil, Plus, Star, Trash2 } from "lucide-react";
8
+ import { useEffect, useMemo, useState } from "react";
9
+ import { ProductItineraryDialog } from "../product-itinerary-dialog.js";
10
+ import { useProductDetailApi, useProductDetailMessages } from "./host.js";
11
+ import { ProductDaySheet } from "./product-day-sheet.js";
12
+ import { ProductDetailDayRow } from "./product-detail-day-row.js";
13
+ import { ActionMenu, EmptyState, Section } from "./product-detail-sections.js";
14
+ import { ServiceDialog } from "./product-service-dialog.js";
15
+ /**
16
+ * Storage-only upload handler for the day media tray. The tray does its
17
+ * own DB insert via `useProductMediaMutation.create` after this returns,
18
+ * so this handler must NOT call the products API — only the R2 upload
19
+ * endpoint — otherwise we'd write two media rows per file.
20
+ */
21
+ const uploadDayMediaToStorage = async (file) => {
22
+ const formData = new FormData();
23
+ formData.append("file", file);
24
+ const res = await fetch("/api/v1/uploads", {
25
+ method: "POST",
26
+ body: formData,
27
+ credentials: "include",
28
+ });
29
+ if (!res.ok)
30
+ throw new Error(`Upload failed (${res.status})`);
31
+ const upload = (await res.json());
32
+ const mediaType = upload.mimeType.startsWith("video/")
33
+ ? "video"
34
+ : upload.mimeType.startsWith("image/")
35
+ ? "image"
36
+ : "document";
37
+ return {
38
+ url: upload.url,
39
+ name: file.name,
40
+ storageKey: upload.key,
41
+ mimeType: upload.mimeType,
42
+ fileSize: upload.size,
43
+ mediaType,
44
+ };
45
+ };
46
+ export function ProductDetailItinerarySection({ productId }) {
47
+ const messages = useProductDetailMessages();
48
+ const api = useProductDetailApi();
49
+ const productMessages = messages.products.core;
50
+ const queryClient = useQueryClient();
51
+ const itineraryQuery = useProductItineraries(productId);
52
+ const itineraryMutation = useProductItineraryMutation();
53
+ const dayMutation = useProductDayMutation();
54
+ const productActionLedgerQueryKey = [...productsQueryKeys.product(productId), "action-ledger"];
55
+ const invalidateProductActionLedger = () => queryClient.invalidateQueries({ queryKey: productActionLedgerQueryKey });
56
+ const [expandedDayId, setExpandedDayId] = useState(null);
57
+ const [selectedItineraryId, setSelectedItineraryId] = useState(null);
58
+ const [dayDialogOpen, setDayDialogOpen] = useState(false);
59
+ const [editingDay, setEditingDay] = useState();
60
+ const [serviceDialogOpen, setServiceDialogOpen] = useState(false);
61
+ const [serviceDialogDayId, setServiceDialogDayId] = useState("");
62
+ const [editingService, setEditingService] = useState();
63
+ const [itineraryDialogOpen, setItineraryDialogOpen] = useState(false);
64
+ const [editingItinerary, setEditingItinerary] = useState();
65
+ const [deleteItineraryTarget, setDeleteItineraryTarget] = useState(null);
66
+ const itineraries = useMemo(() => itineraryQuery.data?.data ?? [], [itineraryQuery.data?.data]);
67
+ const hasMultiple = itineraries.length > 1;
68
+ useEffect(() => {
69
+ if (itineraries.length === 0) {
70
+ setSelectedItineraryId(null);
71
+ return;
72
+ }
73
+ setSelectedItineraryId((current) => {
74
+ if (current && itineraries.some((itinerary) => itinerary.id === current)) {
75
+ return current;
76
+ }
77
+ return itineraries.find((itinerary) => itinerary.isDefault)?.id ?? itineraries[0]?.id ?? null;
78
+ });
79
+ }, [itineraries]);
80
+ const selectedItinerary = useMemo(() => itineraries.find((itinerary) => itinerary.id === selectedItineraryId), [itineraries, selectedItineraryId]);
81
+ const daysQuery = useProductItineraryDays(productId, selectedItineraryId, {
82
+ enabled: Boolean(selectedItineraryId),
83
+ });
84
+ const days = useMemo(() => (daysQuery.data?.data ?? []).slice().sort((left, right) => left.dayNumber - right.dayNumber), [daysQuery.data?.data]);
85
+ const nextDayNumber = days.length > 0 ? Math.max(...days.map((day) => day.dayNumber)) + 1 : 1;
86
+ const openCreateItinerary = () => {
87
+ setEditingItinerary(undefined);
88
+ setItineraryDialogOpen(true);
89
+ };
90
+ const openRenameItinerary = (itinerary) => {
91
+ setEditingItinerary(itinerary);
92
+ setItineraryDialogOpen(true);
93
+ };
94
+ const handleSetDefault = async (itinerary) => {
95
+ if (itinerary.isDefault)
96
+ return;
97
+ await itineraryMutation.update.mutateAsync({
98
+ productId,
99
+ itineraryId: itinerary.id,
100
+ input: { isDefault: true },
101
+ });
102
+ void invalidateProductActionLedger();
103
+ };
104
+ const handleDuplicate = async (itinerary) => {
105
+ const result = await itineraryMutation.duplicate.mutateAsync({
106
+ productId,
107
+ itineraryId: itinerary.id,
108
+ });
109
+ setExpandedDayId(null);
110
+ setSelectedItineraryId(result.itinerary.id);
111
+ void invalidateProductActionLedger();
112
+ };
113
+ const handleConfirmDelete = async () => {
114
+ if (!deleteItineraryTarget)
115
+ return;
116
+ await itineraryMutation.remove.mutateAsync({
117
+ productId,
118
+ itineraryId: deleteItineraryTarget.id,
119
+ });
120
+ setDeleteItineraryTarget(null);
121
+ void invalidateProductActionLedger();
122
+ };
123
+ const sectionTitle = hasMultiple
124
+ ? productMessages.itinerariesTitle
125
+ : productMessages.itineraryTitle;
126
+ return (_jsxs(_Fragment, { children: [_jsx(Section, { title: sectionTitle, actions: _jsxs("div", { className: "flex items-center gap-2", children: [_jsxs(Button, { size: "sm", disabled: !selectedItinerary, onClick: () => {
127
+ setEditingDay(undefined);
128
+ setDayDialogOpen(true);
129
+ }, children: [_jsx(Plus, { className: "mr-2 h-4 w-4" }), productMessages.addDay] }), _jsxs(ActionMenu, { children: [_jsxs(DropdownMenuItem, { onClick: openCreateItinerary, children: [_jsx(Plus, { className: "h-4 w-4" }), productMessages.newItinerary] }), selectedItinerary && !hasMultiple ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: () => openRenameItinerary(selectedItinerary), children: [_jsx(Pencil, { className: "h-4 w-4" }), productMessages.renameItinerary] }), _jsxs(DropdownMenuItem, { onClick: () => void handleDuplicate(selectedItinerary), children: [_jsx(Copy, { className: "h-4 w-4" }), productMessages.duplicateItinerary] })] })) : null] })] }), children: itineraryQuery.isPending ? (_jsx(EmptyState, { message: "\u2026" })) : itineraryQuery.isError ? (_jsx("p", { className: "py-6 text-center text-sm text-destructive", children: "Failed to load itineraries." })) : itineraries.length === 0 ? (_jsxs("div", { className: "flex flex-col items-start gap-3 rounded-md border border-dashed p-6", children: [_jsx("p", { className: "text-sm text-muted-foreground", children: productMessages.noItinerariesYet }), _jsxs(Button, { variant: "outline", size: "sm", onClick: openCreateItinerary, children: [_jsx(Plus, { className: "mr-2 h-4 w-4" }), productMessages.newItinerary] })] })) : (_jsxs("div", { className: "flex flex-col gap-4", children: [hasMultiple ? (_jsx("div", { className: "flex flex-wrap items-center gap-1 rounded-md border bg-muted/30 p-1", children: itineraries.map((itinerary) => {
130
+ const isSelected = itinerary.id === selectedItineraryId;
131
+ return (_jsxs("div", { className: `flex items-center gap-1 rounded-sm pl-2 pr-1 transition-colors ${isSelected ? "bg-background shadow-sm" : "hover:bg-background/60"}`, children: [_jsxs("button", { type: "button", onClick: () => {
132
+ setExpandedDayId(null);
133
+ setSelectedItineraryId(itinerary.id);
134
+ }, className: "flex items-center gap-2 py-1.5 text-sm", children: [_jsx("span", { className: isSelected ? "font-medium" : "text-muted-foreground", children: itinerary.name }), itinerary.isDefault ? (_jsx(Badge, { variant: "secondary", className: "h-5 px-1.5 text-[10px]", children: productMessages.defaultBadge })) : null] }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": formatMessage(productMessages.itineraryRowOptionsLabel, {
135
+ name: itinerary.name,
136
+ }), className: "h-6 w-6 text-muted-foreground", children: _jsx(MoreHorizontal, { className: "h-3.5 w-3.5" }) }) }), _jsxs(DropdownMenuContent, { align: "end", children: [_jsxs(DropdownMenuItem, { onClick: () => openRenameItinerary(itinerary), children: [_jsx(Pencil, { className: "h-4 w-4" }), productMessages.renameItinerary] }), _jsxs(DropdownMenuItem, { onClick: () => void handleDuplicate(itinerary), children: [_jsx(Copy, { className: "h-4 w-4" }), productMessages.duplicateItinerary] }), _jsxs(DropdownMenuItem, { disabled: itinerary.isDefault, onClick: () => handleSetDefault(itinerary), children: [_jsx(Star, { className: "h-4 w-4" }), productMessages.setDefaultItinerary] }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { variant: "destructive", disabled: itinerary.isDefault && itineraries.length > 1, onClick: () => setDeleteItineraryTarget(itinerary), children: [_jsx(Trash2, { className: "h-4 w-4" }), productMessages.deleteItinerary] })] })] })] }, itinerary.id));
137
+ }) })) : null, daysQuery.isPending ? (_jsx(EmptyState, { message: "\u2026" })) : daysQuery.isError ? (_jsx("p", { className: "py-6 text-center text-sm text-destructive", children: messages.products.operations.itineraries.daysLoadFailed })) : days.length === 0 ? (_jsx(EmptyState, { message: productMessages.itineraryEmpty })) : (_jsx("div", { className: "flex flex-col gap-2", children: days.map((day) => (_jsx(ProductDetailDayRow, { day: day, productId: productId, expanded: expandedDayId === day.id, onToggle: () => setExpandedDayId((current) => (current === day.id ? null : day.id)), onEdit: () => {
138
+ setEditingDay(day);
139
+ setDayDialogOpen(true);
140
+ }, onDelete: () => {
141
+ if (window.confirm(productMessages.deleteDayConfirm)) {
142
+ dayMutation.remove.mutate({
143
+ productId,
144
+ itineraryId: selectedItineraryId ?? undefined,
145
+ dayId: day.id,
146
+ }, {
147
+ onSuccess: () => void invalidateProductActionLedger(),
148
+ });
149
+ }
150
+ }, onAddService: () => {
151
+ setServiceDialogDayId(day.id);
152
+ setEditingService(undefined);
153
+ setServiceDialogOpen(true);
154
+ }, onEditService: (service) => {
155
+ setServiceDialogDayId(day.id);
156
+ setEditingService(service);
157
+ setServiceDialogOpen(true);
158
+ }, onDeleteService: (serviceId) => {
159
+ if (window.confirm(productMessages.deleteServiceConfirm)) {
160
+ void api
161
+ .delete(`/v1/products/${productId}/days/${day.id}/services/${serviceId}`)
162
+ .then(async () => {
163
+ await queryClient.invalidateQueries({
164
+ queryKey: ["product-day-services", productId, day.id],
165
+ });
166
+ await invalidateProductActionLedger();
167
+ });
168
+ }
169
+ } }, day.id))) }))] })) }), _jsx(ProductDaySheet, { open: dayDialogOpen, onOpenChange: setDayDialogOpen, productId: productId, itineraryId: selectedItineraryId ?? "", day: editingDay, nextDayNumber: nextDayNumber, uploadMedia: uploadDayMediaToStorage, onSuccess: () => {
170
+ setDayDialogOpen(false);
171
+ setEditingDay(undefined);
172
+ if (selectedItineraryId) {
173
+ void queryClient.invalidateQueries({
174
+ queryKey: ["products", productId, "itineraries", selectedItineraryId, "days"],
175
+ });
176
+ }
177
+ void invalidateProductActionLedger();
178
+ } }), _jsx(ServiceDialog, { open: serviceDialogOpen, onOpenChange: setServiceDialogOpen, productId: productId, dayId: serviceDialogDayId, service: editingService, onSuccess: () => {
179
+ setServiceDialogOpen(false);
180
+ setEditingService(undefined);
181
+ void queryClient.invalidateQueries({
182
+ queryKey: ["product-day-services", productId, serviceDialogDayId],
183
+ });
184
+ void invalidateProductActionLedger();
185
+ } }), _jsx(ProductItineraryDialog, { open: itineraryDialogOpen, onOpenChange: (open) => {
186
+ setItineraryDialogOpen(open);
187
+ if (!open)
188
+ setEditingItinerary(undefined);
189
+ }, productId: productId, itinerary: editingItinerary, itineraryCount: itineraries.length, onSuccess: (itineraryId) => {
190
+ if (!editingItinerary)
191
+ setSelectedItineraryId(itineraryId);
192
+ void invalidateProductActionLedger();
193
+ } }), _jsx(AlertDialog, { open: !!deleteItineraryTarget, onOpenChange: (open) => {
194
+ if (!open)
195
+ setDeleteItineraryTarget(null);
196
+ }, children: _jsxs(AlertDialogContent, { size: "sm", children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: productMessages.deleteItineraryTitle }), _jsx(AlertDialogDescription, { children: deleteItineraryTarget
197
+ ? formatMessage(productMessages.deleteItineraryDescription, {
198
+ name: deleteItineraryTarget.name,
199
+ })
200
+ : null })] }), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogCancel, { children: productMessages.cancel }), _jsx(AlertDialogAction, { variant: "destructive", onClick: () => void handleConfirmDelete(), children: productMessages.confirmDelete })] })] }) })] }));
201
+ }
@@ -0,0 +1,4 @@
1
+ export declare function ProductDetailPage({ id }: {
2
+ id: string;
3
+ }): import("react/jsx-runtime").JSX.Element;
4
+ //# sourceMappingURL=product-detail-page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-detail-page.d.ts","sourceRoot":"","sources":["../../../src/components/product-detail/product-detail-page.tsx"],"names":[],"mappings":"AAgCA,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,EAAE,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,2CAgNvD"}
@@ -0,0 +1,97 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useQueries } from "@tanstack/react-query";
3
+ import { useVoyantProductsContext } from "@voyantjs/products-react";
4
+ import { Button } from "@voyantjs/ui/components";
5
+ import { useMemo } from "react";
6
+ import { ProductsUiMessagesProvider } from "../../i18n/index.js";
7
+ import { ProductOptionsSection } from "../product-options-section.js";
8
+ import { useProductDetailHost, useProductDetailMessages, useProductLocale } from "./host.js";
9
+ import { ProductActivitySection } from "./product-activity-section.js";
10
+ import { DepartureDialog } from "./product-departure-dialog.js";
11
+ import { DeparturePricingOverrideDialog } from "./product-departure-pricing-override-dialog.js";
12
+ import { ProductDialog } from "./product-detail-dialog.js";
13
+ import { ProductDetailHeader } from "./product-detail-header.js";
14
+ import { ProductDetailItinerarySection } from "./product-detail-itinerary-section.js";
15
+ import { ProductBrochureSection, ProductChannelsSection, ProductDeparturesSection, ProductDetailsSection, ProductMediaSection, ProductOrganizeSection, ProductSchedulesSection, } from "./product-detail-sections.js";
16
+ import { ProductDetailSkeleton } from "./product-detail-skeleton.js";
17
+ import { ProductExtrasSection } from "./product-extras-section.js";
18
+ import { ProductMarketRulesSection } from "./product-market-rules-section.js";
19
+ import { PricingPanel } from "./product-options-pricing.js";
20
+ import { getDeparturePriceOverridesQueryOptions } from "./product-options-shared.js";
21
+ import { ProductPaymentPolicySection } from "./product-payment-policy-section.js";
22
+ import { ScheduleDialog } from "./product-schedule-dialog.js";
23
+ import { useProductDetailData } from "./use-product-detail-data.js";
24
+ import { useProductDetailDialogs } from "./use-product-detail-dialogs.js";
25
+ export function ProductDetailPage({ id }) {
26
+ const messages = useProductDetailMessages();
27
+ const productMessages = messages.products.core;
28
+ const { navigate, renderOptionExtras } = useProductDetailHost();
29
+ const resolvedLocale = useProductLocale();
30
+ const client = useVoyantProductsContext();
31
+ const data = useProductDetailData(id);
32
+ const dialogs = useProductDetailDialogs();
33
+ const { product, isPending, slots, rules, channels, mappings, media, itineraryNameById } = data;
34
+ const { mutations, refetch, invalidateProduct } = data;
35
+ const overrideQueries = useQueries({
36
+ queries: slots.map((slot) => ({
37
+ ...getDeparturePriceOverridesQueryOptions(client, slot.id),
38
+ enabled: !!slot.id,
39
+ })),
40
+ });
41
+ const slotIdsWithOverrides = useMemo(() => {
42
+ const set = new Set();
43
+ slots.forEach((slot, index) => {
44
+ const result = overrideQueries[index];
45
+ const items = result?.data?.data ?? [];
46
+ if (items.some((o) => o.active))
47
+ set.add(slot.id);
48
+ });
49
+ return set;
50
+ }, [slots, overrideQueries]);
51
+ const brochure = media.find((item) => item.isBrochure && item.isBrochureCurrent) ??
52
+ media.find((item) => item.isBrochure) ??
53
+ null;
54
+ const galleryMedia = media.filter((item) => !item.isBrochure);
55
+ if (isPending) {
56
+ return _jsx(ProductDetailSkeleton, {});
57
+ }
58
+ if (!product) {
59
+ return (_jsxs("div", { className: "flex flex-col items-center justify-center gap-4 py-12", children: [_jsx("p", { className: "text-muted-foreground", children: productMessages.detailNotFound }), _jsx(Button, { variant: "outline", onClick: () => navigate.toProducts(), children: productMessages.backToProducts })] }));
60
+ }
61
+ return (_jsxs("div", { className: "flex flex-col gap-6 p-6", children: [_jsx(ProductDetailHeader, { product: product, isDuplicating: mutations.duplicateProduct.isPending, isDeleting: mutations.deleteProduct.isPending, onEdit: dialogs.edit.openNow, onAddBooking: () => navigate.toNewBooking(id), onDuplicate: () => {
62
+ mutations.duplicateProduct.mutate(undefined, {
63
+ onSuccess: (result) => {
64
+ navigate.toProduct(result.data.id);
65
+ },
66
+ });
67
+ }, onDelete: () => {
68
+ if (confirm(productMessages.deleteConfirm)) {
69
+ mutations.deleteProduct.mutate(undefined, {
70
+ onSuccess: () => navigate.toProducts(),
71
+ });
72
+ }
73
+ } }), _jsxs("div", { className: "grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_320px]", children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-6", children: [_jsx(ProductDetailsSection, { product: product, onEdit: dialogs.edit.openNow }), _jsx(ProductMediaSection, { productId: id, media: galleryMedia, isUploading: mutations.uploadMedia.isPending, onUpload: (file) => mutations.uploadMedia.mutate({ file }), onSetCover: (mediaId) => mutations.setCover.mutate(mediaId), onDelete: (mediaId) => {
74
+ if (confirm(productMessages.deleteMediaConfirm)) {
75
+ mutations.deleteMedia.mutate(mediaId);
76
+ }
77
+ } }), _jsx(ProductDeparturesSection, { slots: slots, itineraryNameById: itineraryNameById, slotIdsWithOverrides: slotIdsWithOverrides, onCreate: dialogs.departure.openNew, onEdit: dialogs.departure.openEdit, onOverridePrice: dialogs.departureOverride.openEdit, onManageAvailability: (slot) => navigate.toAvailability(slot.id), onDelete: (slotId) => {
78
+ if (confirm(productMessages.deleteDepartureConfirm)) {
79
+ mutations.deleteSlot.mutate(slotId);
80
+ }
81
+ } }), _jsx(ProductSchedulesSection, { rules: rules, onCreate: dialogs.schedule.openNew, onEdit: dialogs.schedule.openEdit, onDelete: (ruleId) => {
82
+ if (confirm(productMessages.deleteScheduleConfirm)) {
83
+ mutations.deleteRule.mutate(ruleId);
84
+ }
85
+ } }), _jsx(ProductDetailItinerarySection, { productId: id }), _jsx(ProductsUiMessagesProvider, { locale: resolvedLocale, children: _jsx(ProductOptionsSection, { productId: id, renderOptionDetails: (option) => (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(PricingPanel, { productId: id, optionId: option.id, productCurrency: product.sellCurrency }), renderOptionExtras?.(id, option.id)] })) }) }), _jsx(ProductExtrasSection, { productId: id }), _jsx(ProductPaymentPolicySection, { product: product, onSuccess: invalidateProduct }), _jsx(ProductMarketRulesSection, { productId: id })] }), _jsxs("div", { className: "flex flex-col gap-6", children: [_jsx(ProductChannelsSection, { allChannels: channels, mappings: mappings, onAddChannel: (channelId) => mutations.addChannelMapping.mutate(channelId), onRemoveChannel: (mappingId) => mutations.removeChannelMapping.mutate(mappingId) }), _jsx(ProductOrganizeSection, { product: product, onEdit: dialogs.edit.openNow }), _jsx(ProductBrochureSection, { brochure: brochure, isGenerating: mutations.generateBrochure.isPending, onGenerate: () => mutations.generateBrochure.mutate() }), _jsx(ProductActivitySection, { productId: id })] })] }), _jsx(ProductDialog, { open: dialogs.edit.open, onOpenChange: dialogs.edit.setOpen, product: product, onSuccess: () => {
86
+ dialogs.edit.close();
87
+ invalidateProduct();
88
+ } }), _jsx(DepartureDialog, { open: dialogs.departure.open, onOpenChange: dialogs.departure.setOpen, productId: id, slot: dialogs.departure.editing, onSuccess: () => {
89
+ dialogs.departure.close();
90
+ refetch.slots();
91
+ } }), _jsx(ScheduleDialog, { open: dialogs.schedule.open, onOpenChange: dialogs.schedule.setOpen, productId: id, rule: dialogs.schedule.editing, onSuccess: () => {
92
+ dialogs.schedule.close();
93
+ refetch.rules();
94
+ } }), _jsx(DeparturePricingOverrideDialog, { open: dialogs.departureOverride.open, onOpenChange: dialogs.departureOverride.setOpen, departureId: dialogs.departureOverride.editing?.id ?? null, optionId: dialogs.departureOverride.editing?.optionId ?? null, onSuccess: () => {
95
+ dialogs.departureOverride.close();
96
+ } })] }));
97
+ }
@@ -0,0 +1,63 @@
1
+ import { type ReactNode } from "react";
2
+ import type { DepartureSlot } from "./product-departure-dialog.js";
3
+ import { type AvailabilityRule, type ChannelInfo, type ChannelProductMapping, type ProductMediaItem, type ProductRecord } from "./product-detail-shared.js";
4
+ export declare function Section({ title, actions, children, contentClassName, }: {
5
+ title: string;
6
+ actions?: ReactNode;
7
+ children: ReactNode;
8
+ contentClassName?: string;
9
+ }): import("react/jsx-runtime").JSX.Element;
10
+ export declare function DetailRow({ label, value }: {
11
+ label: string;
12
+ value: ReactNode;
13
+ }): import("react/jsx-runtime").JSX.Element;
14
+ export declare function ActionMenu({ children }: {
15
+ children: ReactNode;
16
+ }): import("react/jsx-runtime").JSX.Element;
17
+ export declare function EmptyState({ message }: {
18
+ message: string;
19
+ }): import("react/jsx-runtime").JSX.Element;
20
+ export declare function ProductDetailsSection({ product, onEdit, }: {
21
+ product: ProductRecord;
22
+ onEdit: () => void;
23
+ }): import("react/jsx-runtime").JSX.Element;
24
+ export declare function ProductDeparturesSection({ slots, itineraryNameById, slotIdsWithOverrides, onCreate, onEdit, onOverridePrice, onManageAvailability, onDelete, }: {
25
+ slots: DepartureSlot[];
26
+ itineraryNameById: Map<string, string>;
27
+ slotIdsWithOverrides?: ReadonlySet<string>;
28
+ onCreate: () => void;
29
+ onEdit: (slot: DepartureSlot) => void;
30
+ onOverridePrice?: (slot: DepartureSlot) => void;
31
+ onManageAvailability?: (slot: DepartureSlot) => void;
32
+ onDelete: (slotId: string) => void;
33
+ }): import("react/jsx-runtime").JSX.Element;
34
+ export declare function ProductSchedulesSection({ rules, onCreate, onEdit, onDelete, }: {
35
+ rules: AvailabilityRule[];
36
+ onCreate: () => void;
37
+ onEdit: (rule: AvailabilityRule) => void;
38
+ onDelete: (ruleId: string) => void;
39
+ }): import("react/jsx-runtime").JSX.Element;
40
+ export declare function ProductChannelsSection({ allChannels, mappings, onAddChannel, onRemoveChannel, }: {
41
+ allChannels: ChannelInfo[];
42
+ mappings: ChannelProductMapping[];
43
+ onAddChannel: (channelId: string) => void;
44
+ onRemoveChannel: (mappingId: string) => void;
45
+ }): import("react/jsx-runtime").JSX.Element;
46
+ export declare function ProductOrganizeSection({ product, onEdit, }: {
47
+ product: ProductRecord;
48
+ onEdit: () => void;
49
+ }): import("react/jsx-runtime").JSX.Element;
50
+ export declare function ProductBrochureSection({ brochure, isGenerating, onGenerate, }: {
51
+ brochure: ProductMediaItem | null;
52
+ isGenerating: boolean;
53
+ onGenerate: () => void;
54
+ }): import("react/jsx-runtime").JSX.Element;
55
+ export declare function ProductMediaSection({ productId, media, isUploading, onUpload, onSetCover, onDelete, }: {
56
+ productId: string;
57
+ media: ProductMediaItem[];
58
+ isUploading: boolean;
59
+ onUpload: (file: File) => void;
60
+ onSetCover: (mediaId: string) => void;
61
+ onDelete: (mediaId: string) => void;
62
+ }): import("react/jsx-runtime").JSX.Element;
63
+ //# sourceMappingURL=product-detail-sections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-detail-sections.d.ts","sourceRoot":"","sources":["../../../src/components/product-detail/product-detail-sections.tsx"],"names":[],"mappings":"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"}