@voyantjs/pricing-ui 0.16.0 → 0.18.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.
Files changed (67) hide show
  1. package/LICENSE +201 -109
  2. package/README.md +11 -0
  3. package/dist/components/cancellation-policy-combobox.d.ts +1 -1
  4. package/dist/components/cancellation-policy-combobox.d.ts.map +1 -1
  5. package/dist/components/cancellation-policy-combobox.js +6 -4
  6. package/dist/components/cancellation-policy-rule-dialog.d.ts.map +1 -1
  7. package/dist/components/cancellation-policy-rule-dialog.js +23 -15
  8. package/dist/components/dropoff-price-rule-dialog.d.ts.map +1 -1
  9. package/dist/components/dropoff-price-rule-dialog.js +32 -15
  10. package/dist/components/extra-price-rule-dialog.d.ts.map +1 -1
  11. package/dist/components/extra-price-rule-dialog.js +28 -14
  12. package/dist/components/option-price-rule-combobox.d.ts +1 -1
  13. package/dist/components/option-price-rule-combobox.d.ts.map +1 -1
  14. package/dist/components/option-price-rule-combobox.js +6 -4
  15. package/dist/components/option-price-rule-dialog.d.ts.map +1 -1
  16. package/dist/components/option-price-rule-dialog.js +35 -23
  17. package/dist/components/option-start-time-rule-dialog.d.ts.map +1 -1
  18. package/dist/components/option-start-time-rule-dialog.js +33 -14
  19. package/dist/components/option-unit-price-rule-dialog.d.ts.map +1 -1
  20. package/dist/components/option-unit-price-rule-dialog.js +30 -16
  21. package/dist/components/option-unit-tier-dialog.d.ts.map +1 -1
  22. package/dist/components/option-unit-tier-dialog.js +24 -10
  23. package/dist/components/pickup-price-rule-dialog.d.ts.map +1 -1
  24. package/dist/components/pickup-price-rule-dialog.js +29 -13
  25. package/dist/components/price-catalog-combobox.d.ts +1 -1
  26. package/dist/components/price-catalog-combobox.d.ts.map +1 -1
  27. package/dist/components/price-catalog-combobox.js +6 -2
  28. package/dist/components/price-schedule-combobox.d.ts.map +1 -1
  29. package/dist/components/price-schedule-combobox.js +6 -4
  30. package/dist/components/price-schedule-dialog.d.ts.map +1 -1
  31. package/dist/components/price-schedule-dialog.js +26 -15
  32. package/dist/components/pricing-category-combobox.d.ts.map +1 -1
  33. package/dist/components/pricing-category-combobox.js +4 -2
  34. package/dist/components/pricing-category-dependency-dialog.d.ts.map +1 -1
  35. package/dist/components/pricing-category-dependency-dialog.js +5 -1
  36. package/dist/components/pricing-category-dependency-form.d.ts.map +1 -1
  37. package/dist/components/pricing-category-dependency-form.js +17 -8
  38. package/dist/components/pricing-category-dialog.d.ts.map +1 -1
  39. package/dist/components/pricing-category-dialog.js +7 -3
  40. package/dist/components/pricing-category-form.d.ts.map +1 -1
  41. package/dist/components/pricing-category-form.js +20 -13
  42. package/dist/components/pricing-category-list.d.ts.map +1 -1
  43. package/dist/components/pricing-category-list.js +10 -6
  44. package/dist/components/product-combobox.d.ts +1 -1
  45. package/dist/components/product-combobox.d.ts.map +1 -1
  46. package/dist/components/product-combobox.js +6 -2
  47. package/dist/components/product-option-combobox.d.ts.map +1 -1
  48. package/dist/components/product-option-combobox.js +7 -5
  49. package/dist/i18n/en.d.ts +426 -0
  50. package/dist/i18n/en.d.ts.map +1 -0
  51. package/dist/i18n/en.js +425 -0
  52. package/dist/i18n/index.d.ts +5 -0
  53. package/dist/i18n/index.d.ts.map +1 -0
  54. package/dist/i18n/index.js +3 -0
  55. package/dist/i18n/messages.d.ts +391 -0
  56. package/dist/i18n/messages.d.ts.map +1 -0
  57. package/dist/i18n/messages.js +17 -0
  58. package/dist/i18n/provider.d.ts +874 -0
  59. package/dist/i18n/provider.d.ts.map +1 -0
  60. package/dist/i18n/provider.js +44 -0
  61. package/dist/i18n/ro.d.ts +426 -0
  62. package/dist/i18n/ro.d.ts.map +1 -0
  63. package/dist/i18n/ro.js +425 -0
  64. package/dist/index.d.ts +2 -0
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +1 -0
  67. package/package.json +33 -12
@@ -7,6 +7,7 @@ import { Loader2 } from "lucide-react";
7
7
  import { useEffect } from "react";
8
8
  import { useForm } from "react-hook-form";
9
9
  import { z } from "zod/v4";
10
+ import { usePricingUiMessagesOrDefault } from "../i18n/provider";
10
11
  import { OptionPriceRuleCombobox } from "./option-price-rule-combobox";
11
12
  const ADDON_PRICING_MODES = [
12
13
  "included",
@@ -15,21 +16,29 @@ const ADDON_PRICING_MODES = [
15
16
  "on_request",
16
17
  "unavailable",
17
18
  ];
18
- const formSchema = z.object({
19
- optionPriceRuleId: z.string().min(1, "Option price rule is required"),
20
- optionId: z.string().min(1, "Option ID is required"),
21
- pickupPointId: z.string().min(1, "Pickup point is required"),
22
- pricingMode: z.enum(ADDON_PRICING_MODES),
23
- sellAmount: z.coerce.number().min(0).optional().or(z.literal("")).nullable(),
24
- costAmount: z.coerce.number().min(0).optional().or(z.literal("")).nullable(),
25
- active: z.boolean(),
26
- sortOrder: z.coerce.number().int(),
27
- notes: z.string().optional().nullable(),
28
- });
19
+ function createFormSchema(messages) {
20
+ return z.object({
21
+ optionPriceRuleId: z
22
+ .string()
23
+ .min(1, messages.locationPriceRuleDialog.validation.optionPriceRuleRequired),
24
+ optionId: z.string().min(1, messages.locationPriceRuleDialog.validation.optionIdRequired),
25
+ pickupPointId: z
26
+ .string()
27
+ .min(1, messages.locationPriceRuleDialog.validation.pickupPointIdRequired),
28
+ pricingMode: z.enum(ADDON_PRICING_MODES),
29
+ sellAmount: z.coerce.number().min(0).optional().or(z.literal("")).nullable(),
30
+ costAmount: z.coerce.number().min(0).optional().or(z.literal("")).nullable(),
31
+ active: z.boolean(),
32
+ sortOrder: z.coerce.number().int(),
33
+ notes: z.string().optional().nullable(),
34
+ });
35
+ }
29
36
  const toCents = (value) => typeof value === "number" ? Math.round(value * 100) : null;
30
37
  export function PickupPriceRuleDialog({ open, onOpenChange, rule, onSuccess }) {
31
38
  const isEditing = !!rule;
32
39
  const { create, update } = usePickupPriceRuleMutation();
40
+ const messages = usePricingUiMessagesOrDefault();
41
+ const formSchema = createFormSchema(messages);
33
42
  const form = useForm({
34
43
  resolver: zodResolver(formSchema),
35
44
  defaultValues: {
@@ -81,8 +90,15 @@ export function PickupPriceRuleDialog({ open, onOpenChange, rule, onSuccess }) {
81
90
  onOpenChange(false);
82
91
  };
83
92
  const isSubmitting = create.isPending || update.isPending;
84
- return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { size: "lg", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: isEditing ? "Edit Pickup Price Rule" : "Add Pickup Price Rule" }) }), _jsxs("form", { onSubmit: form.handleSubmit(onSubmit), children: [_jsxs(DialogBody, { className: "grid gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: "Option price rule" }), _jsx(OptionPriceRuleCombobox, { value: form.watch("optionPriceRuleId"), onChange: (value) => form.setValue("optionPriceRuleId", value ?? "", {
93
+ return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { size: "lg", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: isEditing
94
+ ? messages.locationPriceRuleDialog.pickup.titles.edit
95
+ : messages.locationPriceRuleDialog.pickup.titles.create }) }), _jsxs("form", { onSubmit: form.handleSubmit(onSubmit), children: [_jsxs(DialogBody, { className: "grid gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.locationPriceRuleDialog.fields.optionPriceRule }), _jsx(OptionPriceRuleCombobox, { value: form.watch("optionPriceRuleId"), onChange: (value) => form.setValue("optionPriceRuleId", value ?? "", {
85
96
  shouldDirty: true,
86
97
  shouldValidate: true,
87
- }), disabled: isEditing }), form.formState.errors.optionPriceRuleId ? (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.optionPriceRuleId.message })) : null] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: "Option ID" }), _jsx(Input, { ...form.register("optionId"), placeholder: "popt_\u2026" })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: "Pickup point ID" }), _jsx(Input, { ...form.register("pickupPointId"), placeholder: "ppnt_\u2026" })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: "Pricing mode" }), _jsxs(Select, { items: ADDON_PRICING_MODES.map((x) => ({ label: x.replace(/_/g, " "), value: x })), value: form.watch("pricingMode"), onValueChange: (value) => form.setValue("pricingMode", value), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: ADDON_PRICING_MODES.map((mode) => (_jsx(SelectItem, { value: mode, className: "capitalize", children: mode.replace(/_/g, " ") }, mode))) })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: "Sell amount" }), _jsx(Input, { ...form.register("sellAmount"), type: "number", step: "0.01", min: "0" })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: "Cost amount" }), _jsx(Input, { ...form.register("costAmount"), type: "number", step: "0.01", min: "0" })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: "Sort order" }), _jsx(Input, { ...form.register("sortOrder"), type: "number" })] }), _jsxs("div", { className: "flex items-center gap-3 pt-6", children: [_jsx(Switch, { checked: form.watch("active"), onCheckedChange: (checked) => form.setValue("active", checked) }), _jsx(Label, { children: "Active" })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: "Notes" }), _jsx(Textarea, { ...form.register("notes") })] })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { type: "button", variant: "ghost", onClick: () => onOpenChange(false), children: "Cancel" }), _jsxs(Button, { type: "submit", disabled: isSubmitting, children: [isSubmitting ? _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : null, isEditing ? "Save Changes" : "Add Rule"] })] })] })] }) }));
98
+ }), disabled: isEditing }), form.formState.errors.optionPriceRuleId ? (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.optionPriceRuleId.message })) : null] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.locationPriceRuleDialog.fields.optionId }), _jsx(Input, { ...form.register("optionId"), placeholder: messages.locationPriceRuleDialog.placeholders.optionId })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.locationPriceRuleDialog.fields.pickupPointId }), _jsx(Input, { ...form.register("pickupPointId"), placeholder: messages.locationPriceRuleDialog.placeholders.pickupPointId })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.locationPriceRuleDialog.fields.pricingMode }), _jsxs(Select, { items: ADDON_PRICING_MODES.map((mode) => ({
99
+ label: messages.common.addonPricingModeLabels[mode],
100
+ value: mode,
101
+ })), value: form.watch("pricingMode"), onValueChange: (value) => form.setValue("pricingMode", value), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: ADDON_PRICING_MODES.map((mode) => (_jsx(SelectItem, { value: mode, children: messages.common.addonPricingModeLabels[mode] }, mode))) })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.locationPriceRuleDialog.fields.sellAmount }), _jsx(Input, { ...form.register("sellAmount"), type: "number", step: "0.01", min: "0" })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.locationPriceRuleDialog.fields.costAmount }), _jsx(Input, { ...form.register("costAmount"), type: "number", step: "0.01", min: "0" })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.locationPriceRuleDialog.fields.sortOrder }), _jsx(Input, { ...form.register("sortOrder"), type: "number" })] }), _jsxs("div", { className: "flex items-center gap-3 pt-6", children: [_jsx(Switch, { checked: form.watch("active"), onCheckedChange: (checked) => form.setValue("active", checked) }), _jsx(Label, { children: messages.locationPriceRuleDialog.fields.active })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.locationPriceRuleDialog.fields.notes }), _jsx(Textarea, { ...form.register("notes") })] })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { type: "button", variant: "ghost", onClick: () => onOpenChange(false), children: messages.common.cancel }), _jsxs(Button, { type: "submit", disabled: isSubmitting, children: [isSubmitting ? _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : null, isEditing
102
+ ? messages.locationPriceRuleDialog.actions.saveRule
103
+ : messages.locationPriceRuleDialog.actions.createRule] })] })] })] }) }));
88
104
  }
@@ -4,6 +4,6 @@ type Props = {
4
4
  placeholder?: string;
5
5
  disabled?: boolean;
6
6
  };
7
- export declare function PriceCatalogCombobox({ value, onChange, placeholder, disabled, }: Props): import("react/jsx-runtime").JSX.Element;
7
+ export declare function PriceCatalogCombobox({ value, onChange, placeholder, disabled }: Props): import("react/jsx-runtime").JSX.Element;
8
8
  export {};
9
9
  //# sourceMappingURL=price-catalog-combobox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"price-catalog-combobox.d.ts","sourceRoot":"","sources":["../../src/components/price-catalog-combobox.tsx"],"names":[],"mappings":"AAYA,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAID,wBAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,QAAQ,EACR,WAAsC,EACtC,QAAQ,GACT,EAAE,KAAK,2CAsEP"}
1
+ {"version":3,"file":"price-catalog-combobox.d.ts","sourceRoot":"","sources":["../../src/components/price-catalog-combobox.tsx"],"names":[],"mappings":"AAcA,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAID,wBAAgB,oBAAoB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,KAAK,2CA4ErF"}
@@ -2,8 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { usePriceCatalog, usePriceCatalogs } from "@voyantjs/pricing-react";
3
3
  import { Combobox, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList, } from "@voyantjs/ui/components/combobox";
4
4
  import * as React from "react";
5
+ import { usePricingUiMessagesOrDefault } from "../i18n/provider";
5
6
  const PAGE_SIZE = 25;
6
- export function PriceCatalogCombobox({ value, onChange, placeholder = "Search price catalogs…", disabled, }) {
7
+ export function PriceCatalogCombobox({ value, onChange, placeholder, disabled }) {
8
+ const messages = usePricingUiMessagesOrDefault();
7
9
  const [search, setSearch] = React.useState("");
8
10
  const listQuery = usePriceCatalogs({ search: search || undefined, limit: PAGE_SIZE });
9
11
  const selectedQuery = usePriceCatalog(value, { enabled: !!value });
@@ -36,7 +38,9 @@ export function PriceCatalogCombobox({ value, onChange, placeholder = "Search pr
36
38
  onChange(id);
37
39
  const item = id ? itemMap.get(id) : null;
38
40
  setInputValue(item ? `${item.name} · ${item.code}` : "");
39
- }, children: [_jsx(ComboboxInput, { placeholder: placeholder, showClear: !!value }), _jsxs(ComboboxContent, { children: [_jsx(ComboboxEmpty, { children: listQuery.isPending || selectedQuery.isPending ? "Loading…" : "No price catalogs found." }), _jsx(ComboboxList, { children: _jsx(ComboboxCollection, { children: (id) => {
41
+ }, children: [_jsx(ComboboxInput, { placeholder: placeholder ?? messages.comboboxes.priceCatalog.placeholder, showClear: !!value }), _jsxs(ComboboxContent, { children: [_jsx(ComboboxEmpty, { children: listQuery.isPending || selectedQuery.isPending
42
+ ? messages.common.loading
43
+ : messages.comboboxes.priceCatalog.empty }), _jsx(ComboboxList, { children: _jsx(ComboboxCollection, { children: (id) => {
40
44
  const item = itemMap.get(id);
41
45
  if (!item)
42
46
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"price-schedule-combobox.d.ts","sourceRoot":"","sources":["../../src/components/price-schedule-combobox.tsx"],"names":[],"mappings":"AAgBA,KAAK,KAAK,GAAG;IACX,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAID,wBAAgB,qBAAqB,CAAC,EACpC,cAAc,EACd,KAAK,EACL,QAAQ,EACR,WAAuC,EACvC,QAAQ,GACT,EAAE,KAAK,2CAyEP"}
1
+ {"version":3,"file":"price-schedule-combobox.d.ts","sourceRoot":"","sources":["../../src/components/price-schedule-combobox.tsx"],"names":[],"mappings":"AAkBA,KAAK,KAAK,GAAG;IACX,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAID,wBAAgB,qBAAqB,CAAC,EACpC,cAAc,EACd,KAAK,EACL,QAAQ,EACR,WAAW,EACX,QAAQ,GACT,EAAE,KAAK,2CA6EP"}
@@ -2,8 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { usePriceSchedule, usePriceSchedules, } from "@voyantjs/pricing-react";
3
3
  import { Combobox, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList, } from "@voyantjs/ui/components/combobox";
4
4
  import * as React from "react";
5
+ import { usePricingUiMessagesOrDefault } from "../i18n/provider";
5
6
  const PAGE_SIZE = 25;
6
- export function PriceScheduleCombobox({ priceCatalogId, value, onChange, placeholder = "Search price schedules…", disabled, }) {
7
+ export function PriceScheduleCombobox({ priceCatalogId, value, onChange, placeholder, disabled, }) {
8
+ const messages = usePricingUiMessagesOrDefault();
7
9
  const [search, setSearch] = React.useState("");
8
10
  const listQuery = usePriceSchedules({
9
11
  priceCatalogId: priceCatalogId || undefined,
@@ -37,9 +39,9 @@ export function PriceScheduleCombobox({ priceCatalogId, value, onChange, placeho
37
39
  const id = next ?? null;
38
40
  onChange(id);
39
41
  setInputValue(id ? (itemMap.get(id)?.name ?? "") : "");
40
- }, children: [_jsx(ComboboxInput, { placeholder: placeholder, showClear: !!value }), _jsxs(ComboboxContent, { children: [_jsx(ComboboxEmpty, { children: listQuery.isPending || selectedQuery.isPending
41
- ? "Loading…"
42
- : "No price schedules found." }), _jsx(ComboboxList, { children: _jsx(ComboboxCollection, { children: (id) => {
42
+ }, children: [_jsx(ComboboxInput, { placeholder: placeholder ?? messages.comboboxes.priceSchedule.placeholder, showClear: !!value }), _jsxs(ComboboxContent, { children: [_jsx(ComboboxEmpty, { children: listQuery.isPending || selectedQuery.isPending
43
+ ? messages.common.loading
44
+ : messages.comboboxes.priceSchedule.empty }), _jsx(ComboboxList, { children: _jsx(ComboboxCollection, { children: (id) => {
43
45
  const item = itemMap.get(id);
44
46
  if (!item)
45
47
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"price-schedule-dialog.d.ts","sourceRoot":"","sources":["../../src/components/price-schedule-dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,mBAAmB,EAA4B,MAAM,yBAAyB,CAAA;AAuC5F,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,QAAQ,CAAC,EAAE,mBAAmB,CAAA;IAC9B,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAA;CACpD;AAED,wBAAgB,mBAAmB,CAAC,EAClC,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,SAAS,GACV,EAAE,wBAAwB,2CAqL1B"}
1
+ {"version":3,"file":"price-schedule-dialog.d.ts","sourceRoot":"","sources":["../../src/components/price-schedule-dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,mBAAmB,EAA4B,MAAM,yBAAyB,CAAA;AA6C5F,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,QAAQ,CAAC,EAAE,mBAAmB,CAAA;IAC9B,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAA;CACpD;AAED,wBAAgB,mBAAmB,CAAC,EAClC,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,SAAS,GACV,EAAE,wBAAwB,2CAuM1B"}
@@ -8,29 +8,36 @@ import { Loader2 } from "lucide-react";
8
8
  import { useEffect } from "react";
9
9
  import { useForm } from "react-hook-form";
10
10
  import { z } from "zod/v4";
11
+ import { usePricingUiMessagesOrDefault } from "../i18n/provider";
11
12
  import { PriceCatalogCombobox } from "./price-catalog-combobox";
12
- const scheduleFormSchema = z.object({
13
- priceCatalogId: z.string().min(1, "Catalog is required"),
14
- name: z.string().min(1, "Name is required").max(255),
15
- code: z.string().max(100).optional().nullable(),
16
- recurrenceRule: z.string().min(1, "RRULE is required"),
17
- timezone: z.string().max(100).optional().nullable(),
18
- validFrom: z.string().optional().nullable(),
19
- validTo: z.string().optional().nullable(),
20
- priority: z.coerce.number().int(),
21
- active: z.boolean(),
22
- notes: z.string().optional().nullable(),
23
- });
13
+ function createScheduleFormSchema(messages) {
14
+ return z.object({
15
+ priceCatalogId: z.string().min(1, messages.priceScheduleDialog.validation.catalogRequired),
16
+ name: z.string().min(1, messages.priceScheduleDialog.validation.nameRequired).max(255),
17
+ code: z.string().max(100).optional().nullable(),
18
+ recurrenceRule: z
19
+ .string()
20
+ .min(1, messages.priceScheduleDialog.validation.recurrenceRuleRequired),
21
+ timezone: z.string().max(100).optional().nullable(),
22
+ validFrom: z.string().optional().nullable(),
23
+ validTo: z.string().optional().nullable(),
24
+ priority: z.coerce.number().int(),
25
+ active: z.boolean(),
26
+ notes: z.string().optional().nullable(),
27
+ });
28
+ }
24
29
  export function PriceScheduleDialog({ open, onOpenChange, schedule, onSuccess, }) {
25
30
  const isEditing = !!schedule;
26
31
  const { create, update } = usePriceScheduleMutation();
32
+ const messages = usePricingUiMessagesOrDefault();
33
+ const scheduleFormSchema = createScheduleFormSchema(messages);
27
34
  const form = useForm({
28
35
  resolver: zodResolver(scheduleFormSchema),
29
36
  defaultValues: {
30
37
  priceCatalogId: "",
31
38
  name: "",
32
39
  code: "",
33
- recurrenceRule: "FREQ=YEARLY;BYMONTH=6,7,8",
40
+ recurrenceRule: messages.priceScheduleDialog.placeholders.recurrenceRule,
34
41
  timezone: "",
35
42
  validFrom: "",
36
43
  validTo: "",
@@ -80,8 +87,12 @@ export function PriceScheduleDialog({ open, onOpenChange, schedule, onSuccess, }
80
87
  const validFrom = form.watch("validFrom");
81
88
  const validTo = form.watch("validTo");
82
89
  const isSubmitting = create.isPending || update.isPending;
83
- return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { size: "lg", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: isEditing ? "Edit Price Schedule" : "New Price Schedule" }) }), _jsxs("form", { onSubmit: form.handleSubmit(onSubmit), children: [_jsxs(DialogBody, { className: "grid gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: "Catalog" }), _jsx(PriceCatalogCombobox, { value: form.watch("priceCatalogId"), onChange: (value) => form.setValue("priceCatalogId", value ?? "", {
90
+ return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { size: "lg", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: isEditing
91
+ ? messages.priceScheduleDialog.titles.edit
92
+ : messages.priceScheduleDialog.titles.create }) }), _jsxs("form", { onSubmit: form.handleSubmit(onSubmit), children: [_jsxs(DialogBody, { className: "grid gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.priceScheduleDialog.fields.catalog }), _jsx(PriceCatalogCombobox, { value: form.watch("priceCatalogId"), onChange: (value) => form.setValue("priceCatalogId", value ?? "", {
84
93
  shouldDirty: true,
85
94
  shouldValidate: true,
86
- }) }), form.formState.errors.priceCatalogId ? (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.priceCatalogId.message })) : null] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: "Name" }), _jsx(Input, { ...form.register("name"), placeholder: "High Season" }), form.formState.errors.name ? (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.name.message })) : null] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: "Code" }), _jsx(Input, { ...form.register("code"), placeholder: "high-season" })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: "Recurrence rule (RRULE)" }), _jsx(Textarea, { ...form.register("recurrenceRule"), placeholder: "FREQ=YEARLY;BYMONTH=6,7,8", rows: 2, className: "font-mono text-xs" }), _jsxs("p", { className: "text-xs text-muted-foreground", children: ["e.g. ", _jsx("code", { children: "FREQ=YEARLY;BYMONTH=6,7,8" }), " for June-August."] }), form.formState.errors.recurrenceRule ? (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.recurrenceRule.message })) : null] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: "Valid from" }), _jsx(DatePicker, { value: typeof validFrom === "string" && validFrom.length > 0 ? validFrom : null, onChange: (value) => form.setValue("validFrom", value ?? "", { shouldDirty: true }), placeholder: "Optional" })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: "Valid to" }), _jsx(DatePicker, { value: typeof validTo === "string" && validTo.length > 0 ? validTo : null, onChange: (value) => form.setValue("validTo", value ?? "", { shouldDirty: true }), placeholder: "Optional" })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: "Timezone" }), _jsx(Input, { ...form.register("timezone"), placeholder: "Europe/Istanbul" })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: "Priority" }), _jsx(Input, { ...form.register("priority"), type: "number" })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Switch, { checked: form.watch("active"), onCheckedChange: (checked) => form.setValue("active", checked) }), _jsx(Label, { children: "Active" })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: "Notes" }), _jsx(Textarea, { ...form.register("notes") })] })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { type: "button", variant: "ghost", onClick: () => onOpenChange(false), children: "Cancel" }), _jsxs(Button, { type: "submit", disabled: isSubmitting, children: [isSubmitting ? _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : null, isEditing ? "Save Changes" : "Create Schedule"] })] })] })] }) }));
95
+ }), placeholder: messages.priceScheduleDialog.placeholders.catalog }), form.formState.errors.priceCatalogId ? (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.priceCatalogId.message })) : null] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.priceScheduleDialog.fields.name }), _jsx(Input, { ...form.register("name"), placeholder: messages.priceScheduleDialog.placeholders.name }), form.formState.errors.name ? (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.name.message })) : null] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.priceScheduleDialog.fields.code }), _jsx(Input, { ...form.register("code"), placeholder: messages.priceScheduleDialog.placeholders.code })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.priceScheduleDialog.fields.recurrenceRule }), _jsx(Textarea, { ...form.register("recurrenceRule"), placeholder: messages.priceScheduleDialog.placeholders.recurrenceRule, rows: 2, className: "font-mono text-xs" }), _jsx("p", { className: "text-xs text-muted-foreground", children: messages.priceScheduleDialog.helpText.recurrenceRuleExample }), form.formState.errors.recurrenceRule ? (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.recurrenceRule.message })) : null] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.priceScheduleDialog.fields.validFrom }), _jsx(DatePicker, { value: typeof validFrom === "string" && validFrom.length > 0 ? validFrom : null, onChange: (value) => form.setValue("validFrom", value ?? "", { shouldDirty: true }), placeholder: messages.priceScheduleDialog.placeholders.validFrom })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.priceScheduleDialog.fields.validTo }), _jsx(DatePicker, { value: typeof validTo === "string" && validTo.length > 0 ? validTo : null, onChange: (value) => form.setValue("validTo", value ?? "", { shouldDirty: true }), placeholder: messages.priceScheduleDialog.placeholders.validTo })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.priceScheduleDialog.fields.timezone }), _jsx(Input, { ...form.register("timezone"), placeholder: messages.priceScheduleDialog.placeholders.timezone })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.priceScheduleDialog.fields.priority }), _jsx(Input, { ...form.register("priority"), type: "number" })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Switch, { checked: form.watch("active"), onCheckedChange: (checked) => form.setValue("active", checked) }), _jsx(Label, { children: messages.priceScheduleDialog.fields.active })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.priceScheduleDialog.fields.notes }), _jsx(Textarea, { ...form.register("notes") })] })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { type: "button", variant: "ghost", onClick: () => onOpenChange(false), children: messages.common.cancel }), _jsxs(Button, { type: "submit", disabled: isSubmitting, children: [isSubmitting ? _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : null, isEditing
96
+ ? messages.common.saveChanges
97
+ : messages.priceScheduleDialog.actions.create] })] })] })] }) }));
87
98
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pricing-category-combobox.d.ts","sourceRoot":"","sources":["../../src/components/pricing-category-combobox.tsx"],"names":[],"mappings":"AAcA,KAAK,4BAA4B,GAAG;IAClC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAID,wBAAgB,uBAAuB,CAAC,EACtC,KAAK,EACL,QAAQ,EACR,WAA0C,EAC1C,QAAQ,GACT,EAAE,4BAA4B,2CA4E9B"}
1
+ {"version":3,"file":"pricing-category-combobox.d.ts","sourceRoot":"","sources":["../../src/components/pricing-category-combobox.tsx"],"names":[],"mappings":"AAgBA,KAAK,4BAA4B,GAAG;IAClC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAID,wBAAgB,uBAAuB,CAAC,EACtC,KAAK,EACL,QAAQ,EACR,WAAW,EACX,QAAQ,GACT,EAAE,4BAA4B,2CAkF9B"}
@@ -3,8 +3,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { usePricingCategories } from "@voyantjs/pricing-react";
4
4
  import { Combobox, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList, } from "@voyantjs/ui/components/combobox";
5
5
  import * as React from "react";
6
+ import { usePricingUiMessagesOrDefault } from "../i18n/provider";
6
7
  const PAGE_SIZE = 25;
7
- export function PricingCategoryCombobox({ value, onChange, placeholder = "Search pricing categories…", disabled, }) {
8
+ export function PricingCategoryCombobox({ value, onChange, placeholder, disabled, }) {
9
+ const messages = usePricingUiMessagesOrDefault();
8
10
  const [search, setSearch] = React.useState("");
9
11
  const { data, isPending } = usePricingCategories({
10
12
  search: search || undefined,
@@ -45,7 +47,7 @@ export function PricingCategoryCombobox({ value, onChange, placeholder = "Search
45
47
  const item = itemMap.get(id);
46
48
  const label = item ? `${item.name}${item.code ? ` (${item.code})` : ""}` : "";
47
49
  setInputValue(label);
48
- }, children: [_jsx(ComboboxInput, { placeholder: placeholder, showClear: !!value }), _jsxs(ComboboxContent, { children: [_jsx(ComboboxEmpty, { children: isPending ? "Loading…" : "No pricing categories found." }), _jsx(ComboboxList, { children: _jsx(ComboboxCollection, { children: (id) => {
50
+ }, children: [_jsx(ComboboxInput, { placeholder: placeholder ?? messages.comboboxes.pricingCategory.placeholder, showClear: !!value }), _jsxs(ComboboxContent, { children: [_jsx(ComboboxEmpty, { children: isPending ? messages.common.loading : messages.comboboxes.pricingCategory.empty }), _jsx(ComboboxList, { children: _jsx(ComboboxCollection, { children: (id) => {
49
51
  const item = itemMap.get(id);
50
52
  if (!item)
51
53
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"pricing-category-dependency-dialog.d.ts","sourceRoot":"","sources":["../../src/components/pricing-category-dependency-dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAA;AAY9E,MAAM,WAAW,oCAAoC;IACnD,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,UAAU,CAAC,EAAE,+BAA+B,CAAA;IAC5C,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,+BAA+B,KAAK,IAAI,CAAA;CAClE;AAED,wBAAgB,+BAA+B,CAAC,EAC9C,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,SAAS,GACV,EAAE,oCAAoC,2CAyBtC"}
1
+ {"version":3,"file":"pricing-category-dependency-dialog.d.ts","sourceRoot":"","sources":["../../src/components/pricing-category-dependency-dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAA;AAa9E,MAAM,WAAW,oCAAoC;IACnD,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,UAAU,CAAC,EAAE,+BAA+B,CAAA;IAC5C,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,+BAA+B,KAAK,IAAI,CAAA;CAClE;AAED,wBAAgB,+BAA+B,CAAC,EAC9C,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,SAAS,GACV,EAAE,oCAAoC,2CA4BtC"}
@@ -1,10 +1,14 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@voyantjs/ui/components/dialog";
4
+ import { usePricingUiMessagesOrDefault } from "../i18n/provider";
4
5
  import { PricingCategoryDependencyForm } from "./pricing-category-dependency-form";
5
6
  export function PricingCategoryDependencyDialog({ open, onOpenChange, dependency, onSuccess, }) {
6
7
  const isEdit = Boolean(dependency);
7
- return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { "data-slot": "pricing-category-dependency-dialog", className: "sm:max-w-[720px]", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: isEdit ? "Edit category dependency" : "Add category dependency" }), _jsx(DialogDescription, { children: "Rules between pricing categories such as requires, excludes, and quantity limits." })] }), _jsx(PricingCategoryDependencyForm, { mode: dependency ? { kind: "edit", dependency } : { kind: "create" }, onSuccess: (saved) => {
8
+ const messages = usePricingUiMessagesOrDefault();
9
+ return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { "data-slot": "pricing-category-dependency-dialog", className: "sm:max-w-[720px]", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: isEdit
10
+ ? messages.pricingCategoryDependencyDialog.titles.edit
11
+ : messages.pricingCategoryDependencyDialog.titles.create }), _jsx(DialogDescription, { children: messages.pricingCategoryDependencyDialog.description })] }), _jsx(PricingCategoryDependencyForm, { mode: dependency ? { kind: "edit", dependency } : { kind: "create" }, onSuccess: (saved) => {
8
12
  onSuccess?.(saved);
9
13
  onOpenChange(false);
10
14
  }, onCancel: () => onOpenChange(false) })] }) }));
@@ -1 +1 @@
1
- {"version":3,"file":"pricing-category-dependency-form.d.ts","sourceRoot":"","sources":["../../src/components/pricing-category-dependency-form.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,+BAA+B,EAErC,MAAM,yBAAyB,CAAA;AAiBhC,KAAK,IAAI,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,+BAA+B,CAAA;CAAE,CAAA;AAE9F,MAAM,WAAW,kCAAkC;IACjD,IAAI,EAAE,IAAI,CAAA;IACV,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,+BAA+B,KAAK,IAAI,CAAA;IACjE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB;AA+DD,wBAAgB,6BAA6B,CAAC,EAC5C,IAAI,EACJ,SAAS,EACT,QAAQ,GACT,EAAE,kCAAkC,2CAmJpC"}
1
+ {"version":3,"file":"pricing-category-dependency-form.d.ts","sourceRoot":"","sources":["../../src/components/pricing-category-dependency-form.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,+BAA+B,EAErC,MAAM,yBAAyB,CAAA;AAmBhC,KAAK,IAAI,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,+BAA+B,CAAA;CAAE,CAAA;AAE9F,MAAM,WAAW,kCAAkC;IACjD,IAAI,EAAE,IAAI,CAAA;IACV,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,+BAA+B,KAAK,IAAI,CAAA;IACjE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB;AA+DD,wBAAgB,6BAA6B,CAAC,EAC5C,IAAI,EACJ,SAAS,EACT,QAAQ,GACT,EAAE,kCAAkC,2CAmKpC"}
@@ -9,12 +9,13 @@ import { Switch } from "@voyantjs/ui/components/switch";
9
9
  import { Textarea } from "@voyantjs/ui/components/textarea";
10
10
  import { Loader2 } from "lucide-react";
11
11
  import * as React from "react";
12
+ import { usePricingUiMessagesOrDefault } from "../i18n/provider";
12
13
  import { PricingCategoryCombobox } from "./pricing-category-combobox";
13
14
  const DEPENDENCY_TYPES = [
14
- { value: "requires", label: "Requires" },
15
- { value: "limits_per_master", label: "Limits per master" },
16
- { value: "limits_sum", label: "Limits sum" },
17
- { value: "excludes", label: "Excludes" },
15
+ { value: "requires" },
16
+ { value: "limits_per_master" },
17
+ { value: "limits_sum" },
18
+ { value: "excludes" },
18
19
  ];
19
20
  function initialState(mode) {
20
21
  if (mode.kind === "edit") {
@@ -61,6 +62,7 @@ export function PricingCategoryDependencyForm({ mode, onSuccess, onCancel, }) {
61
62
  const [state, setState] = React.useState(() => initialState(mode));
62
63
  const [error, setError] = React.useState(null);
63
64
  const { create, update } = usePricingCategoryDependencyMutation();
65
+ const messages = usePricingUiMessagesOrDefault();
64
66
  React.useEffect(() => {
65
67
  setState(initialState(mode));
66
68
  setError(null);
@@ -70,7 +72,7 @@ export function PricingCategoryDependencyForm({ mode, onSuccess, onCancel, }) {
70
72
  event.preventDefault();
71
73
  setError(null);
72
74
  if (!state.masterPricingCategoryId || !state.pricingCategoryId) {
73
- setError("Both master and dependent categories are required.");
75
+ setError(messages.pricingCategoryDependencyForm.validation.categoriesRequired);
74
76
  return;
75
77
  }
76
78
  try {
@@ -80,11 +82,18 @@ export function PricingCategoryDependencyForm({ mode, onSuccess, onCancel, }) {
80
82
  onSuccess?.(dependency);
81
83
  }
82
84
  catch (err) {
83
- setError(err instanceof Error ? err.message : "Failed to save category dependency.");
85
+ setError(err instanceof Error
86
+ ? err.message
87
+ : messages.pricingCategoryDependencyForm.validation.saveFailed);
84
88
  }
85
89
  };
86
- return (_jsxs("form", { "data-slot": "pricing-category-dependency-form", onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [_jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { children: "Master category" }), _jsx(PricingCategoryCombobox, { value: state.masterPricingCategoryId, onChange: (value) => setState((prev) => ({ ...prev, masterPricingCategoryId: value ?? "" })), placeholder: "Search category" })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { children: "Dependent category" }), _jsx(PricingCategoryCombobox, { value: state.pricingCategoryId, onChange: (value) => setState((prev) => ({ ...prev, pricingCategoryId: value ?? "" })), placeholder: "Search category" })] })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { children: "Dependency type" }), _jsxs(Select, { items: DEPENDENCY_TYPES, value: state.dependencyType, onValueChange: (value) => setState((prev) => ({
90
+ return (_jsxs("form", { "data-slot": "pricing-category-dependency-form", onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [_jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { children: messages.pricingCategoryDependencyForm.fields.masterCategory }), _jsx(PricingCategoryCombobox, { value: state.masterPricingCategoryId, onChange: (value) => setState((prev) => ({ ...prev, masterPricingCategoryId: value ?? "" })), placeholder: messages.pricingCategoryDependencyForm.placeholders.categorySearch })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { children: messages.pricingCategoryDependencyForm.fields.dependentCategory }), _jsx(PricingCategoryCombobox, { value: state.pricingCategoryId, onChange: (value) => setState((prev) => ({ ...prev, pricingCategoryId: value ?? "" })), placeholder: messages.pricingCategoryDependencyForm.placeholders.categorySearch })] })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { children: messages.pricingCategoryDependencyForm.fields.dependencyType }), _jsxs(Select, { items: DEPENDENCY_TYPES.map((type) => ({
91
+ label: messages.common.dependencyTypeLabels[type.value],
92
+ value: type.value,
93
+ })), value: state.dependencyType, onValueChange: (value) => setState((prev) => ({
87
94
  ...prev,
88
95
  dependencyType: value,
89
- })), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: DEPENDENCY_TYPES.map((type) => (_jsx(SelectItem, { value: type.value, children: type.label }, type.value))) })] })] }), _jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-dependency-max-per-master", children: "Max per master" }), _jsx(Input, { id: "pricing-category-dependency-max-per-master", type: "number", min: "0", value: state.maxPerMaster, onChange: (event) => setState((prev) => ({ ...prev, maxPerMaster: event.target.value })) })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-dependency-max-dependent-sum", children: "Max dependent sum" }), _jsx(Input, { id: "pricing-category-dependency-max-dependent-sum", type: "number", min: "0", value: state.maxDependentSum, onChange: (event) => setState((prev) => ({ ...prev, maxDependentSum: event.target.value })) })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Switch, { checked: state.active, onCheckedChange: (active) => setState((prev) => ({ ...prev, active })) }), _jsx(Label, { children: "Active" })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-dependency-notes", children: "Notes" }), _jsx(Textarea, { id: "pricing-category-dependency-notes", value: state.notes, onChange: (event) => setState((prev) => ({ ...prev, notes: event.target.value })) })] }), error ? _jsx("p", { className: "text-sm text-destructive", children: error }) : null, _jsxs("div", { className: "flex items-center justify-end gap-2", children: [onCancel ? (_jsx(Button, { type: "button", variant: "ghost", onClick: onCancel, children: "Cancel" })) : null, _jsxs(Button, { type: "submit", disabled: isSubmitting, children: [isSubmitting ? (_jsx(Loader2, { className: "mr-2 size-4 animate-spin", "aria-hidden": "true" })) : null, mode.kind === "edit" ? "Save changes" : "Add dependency"] })] })] }));
96
+ })), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: DEPENDENCY_TYPES.map((type) => (_jsx(SelectItem, { value: type.value, children: messages.common.dependencyTypeLabels[type.value] }, type.value))) })] })] }), _jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-dependency-max-per-master", children: messages.pricingCategoryDependencyForm.fields.maxPerMaster }), _jsx(Input, { id: "pricing-category-dependency-max-per-master", type: "number", min: "0", value: state.maxPerMaster, onChange: (event) => setState((prev) => ({ ...prev, maxPerMaster: event.target.value })) })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-dependency-max-dependent-sum", children: messages.pricingCategoryDependencyForm.fields.maxDependentSum }), _jsx(Input, { id: "pricing-category-dependency-max-dependent-sum", type: "number", min: "0", value: state.maxDependentSum, onChange: (event) => setState((prev) => ({ ...prev, maxDependentSum: event.target.value })) })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Switch, { checked: state.active, onCheckedChange: (active) => setState((prev) => ({ ...prev, active })) }), _jsx(Label, { children: messages.pricingCategoryDependencyForm.fields.active })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-dependency-notes", children: messages.pricingCategoryDependencyForm.fields.notes }), _jsx(Textarea, { id: "pricing-category-dependency-notes", value: state.notes, onChange: (event) => setState((prev) => ({ ...prev, notes: event.target.value })) })] }), error ? _jsx("p", { className: "text-sm text-destructive", children: error }) : null, _jsxs("div", { className: "flex items-center justify-end gap-2", children: [onCancel ? (_jsx(Button, { type: "button", variant: "ghost", onClick: onCancel, children: messages.common.cancel })) : null, _jsxs(Button, { type: "submit", disabled: isSubmitting, children: [isSubmitting ? (_jsx(Loader2, { className: "mr-2 size-4 animate-spin", "aria-hidden": "true" })) : null, mode.kind === "edit"
97
+ ? messages.common.saveChanges
98
+ : messages.pricingCategoryDependencyForm.actions.create] })] })] }));
90
99
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pricing-category-dialog.d.ts","sourceRoot":"","sources":["../../src/components/pricing-category-dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAYpE,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,QAAQ,CAAC,EAAE,qBAAqB,CAAA;IAChC,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,qBAAqB,KAAK,IAAI,CAAA;CACtD;AAED,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,SAAS,GACV,EAAE,0BAA0B,2CAyB5B"}
1
+ {"version":3,"file":"pricing-category-dialog.d.ts","sourceRoot":"","sources":["../../src/components/pricing-category-dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAapE,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,QAAQ,CAAC,EAAE,qBAAqB,CAAA;IAChC,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,qBAAqB,KAAK,IAAI,CAAA;CACtD;AAED,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,SAAS,GACV,EAAE,0BAA0B,2CA8B5B"}
@@ -1,12 +1,16 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@voyantjs/ui/components/dialog";
4
+ import { usePricingUiMessagesOrDefault } from "../i18n/provider";
4
5
  import { PricingCategoryForm } from "./pricing-category-form";
5
6
  export function PricingCategoryDialog({ open, onOpenChange, category, onSuccess, }) {
6
7
  const isEdit = Boolean(category);
7
- return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { "data-slot": "pricing-category-dialog", className: "sm:max-w-[720px]", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: isEdit ? "Edit pricing category" : "New pricing category" }), _jsx(DialogDescription, { children: isEdit
8
- ? "Update reusable pricing category rules and eligibility."
9
- : "Create a reusable pricing category for products and options." })] }), _jsx(PricingCategoryForm, { mode: category ? { kind: "edit", category } : { kind: "create" }, onSuccess: (saved) => {
8
+ const messages = usePricingUiMessagesOrDefault();
9
+ return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { "data-slot": "pricing-category-dialog", className: "sm:max-w-[720px]", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: isEdit
10
+ ? messages.pricingCategoryDialog.titles.edit
11
+ : messages.pricingCategoryDialog.titles.create }), _jsx(DialogDescription, { children: isEdit
12
+ ? messages.pricingCategoryDialog.descriptions.edit
13
+ : messages.pricingCategoryDialog.descriptions.create })] }), _jsx(PricingCategoryForm, { mode: category ? { kind: "edit", category } : { kind: "create" }, onSuccess: (saved) => {
10
14
  onSuccess?.(saved);
11
15
  onOpenChange(false);
12
16
  }, onCancel: () => onOpenChange(false) })] }) }));
@@ -1 +1 @@
1
- {"version":3,"file":"pricing-category-form.d.ts","sourceRoot":"","sources":["../../src/components/pricing-category-form.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,qBAAqB,EAE3B,MAAM,yBAAyB,CAAA;AAehC,KAAK,IAAI,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,qBAAqB,CAAA;CAAE,CAAA;AAElF,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,IAAI,CAAA;IACV,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,qBAAqB,KAAK,IAAI,CAAA;IACrD,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB;AAqFD,wBAAgB,mBAAmB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,wBAAwB,2CAyK1F"}
1
+ {"version":3,"file":"pricing-category-form.d.ts","sourceRoot":"","sources":["../../src/components/pricing-category-form.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,qBAAqB,EAE3B,MAAM,yBAAyB,CAAA;AAiBhC,KAAK,IAAI,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,qBAAqB,CAAA;CAAE,CAAA;AAElF,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,IAAI,CAAA;IACV,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,qBAAqB,KAAK,IAAI,CAAA;IACrD,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB;AAqFD,wBAAgB,mBAAmB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,wBAAwB,2CAyL1F"}
@@ -8,16 +8,17 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "
8
8
  import { Switch } from "@voyantjs/ui/components/switch";
9
9
  import { Loader2 } from "lucide-react";
10
10
  import * as React from "react";
11
+ import { usePricingUiMessagesOrDefault } from "../i18n/provider";
11
12
  const CATEGORY_TYPES = [
12
- { value: "adult", label: "Adult" },
13
- { value: "child", label: "Child" },
14
- { value: "infant", label: "Infant" },
15
- { value: "senior", label: "Senior" },
16
- { value: "group", label: "Group" },
17
- { value: "room", label: "Room" },
18
- { value: "vehicle", label: "Vehicle" },
19
- { value: "service", label: "Service" },
20
- { value: "other", label: "Other" },
13
+ { value: "adult" },
14
+ { value: "child" },
15
+ { value: "infant" },
16
+ { value: "senior" },
17
+ { value: "group" },
18
+ { value: "room" },
19
+ { value: "vehicle" },
20
+ { value: "service" },
21
+ { value: "other" },
21
22
  ];
22
23
  function initialState(mode) {
23
24
  if (mode.kind === "edit") {
@@ -70,6 +71,7 @@ export function PricingCategoryForm({ mode, onSuccess, onCancel }) {
70
71
  const [state, setState] = React.useState(() => initialState(mode));
71
72
  const [error, setError] = React.useState(null);
72
73
  const { create, update } = usePricingCategoryMutation();
74
+ const messages = usePricingUiMessagesOrDefault();
73
75
  React.useEffect(() => {
74
76
  setState(initialState(mode));
75
77
  setError(null);
@@ -79,7 +81,7 @@ export function PricingCategoryForm({ mode, onSuccess, onCancel }) {
79
81
  event.preventDefault();
80
82
  setError(null);
81
83
  if (!state.name.trim()) {
82
- setError("Category name is required.");
84
+ setError(messages.pricingCategoryForm.validation.nameRequired);
83
85
  return;
84
86
  }
85
87
  try {
@@ -89,11 +91,16 @@ export function PricingCategoryForm({ mode, onSuccess, onCancel }) {
89
91
  onSuccess?.(category);
90
92
  }
91
93
  catch (err) {
92
- setError(err instanceof Error ? err.message : "Failed to save pricing category.");
94
+ setError(err instanceof Error ? err.message : messages.pricingCategoryForm.validation.saveFailed);
93
95
  }
94
96
  };
95
- return (_jsxs("form", { "data-slot": "pricing-category-form", onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [_jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-name", children: "Name" }), _jsx(Input, { id: "pricing-category-name", required: true, autoFocus: true, value: state.name, onChange: (event) => setState((prev) => ({ ...prev, name: event.target.value })), placeholder: "Adult" })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-code", children: "Code" }), _jsx(Input, { id: "pricing-category-code", value: state.code, onChange: (event) => setState((prev) => ({ ...prev, code: event.target.value })), placeholder: "adult" })] })] }), _jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { children: "Type" }), _jsxs(Select, { items: CATEGORY_TYPES, value: state.categoryType, onValueChange: (value) => setState((prev) => ({
97
+ return (_jsxs("form", { "data-slot": "pricing-category-form", onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [_jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-name", children: messages.pricingCategoryForm.fields.name }), _jsx(Input, { id: "pricing-category-name", required: true, autoFocus: true, value: state.name, onChange: (event) => setState((prev) => ({ ...prev, name: event.target.value })), placeholder: messages.pricingCategoryForm.placeholders.name })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-code", children: messages.pricingCategoryForm.fields.code }), _jsx(Input, { id: "pricing-category-code", value: state.code, onChange: (event) => setState((prev) => ({ ...prev, code: event.target.value })), placeholder: messages.pricingCategoryForm.placeholders.code })] })] }), _jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { children: messages.pricingCategoryForm.fields.type }), _jsxs(Select, { items: CATEGORY_TYPES.map((type) => ({
98
+ label: messages.common.categoryTypeLabels[type.value],
99
+ value: type.value,
100
+ })), value: state.categoryType, onValueChange: (value) => setState((prev) => ({
96
101
  ...prev,
97
102
  categoryType: value,
98
- })), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: CATEGORY_TYPES.map((type) => (_jsx(SelectItem, { value: type.value, children: type.label }, type.value))) })] })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-seat-occupancy", children: "Seat occupancy" }), _jsx(Input, { id: "pricing-category-seat-occupancy", type: "number", min: "0", value: state.seatOccupancy, onChange: (event) => setState((prev) => ({ ...prev, seatOccupancy: event.target.value })) })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Switch, { checked: state.isAgeQualified, onCheckedChange: (isAgeQualified) => setState((prev) => ({ ...prev, isAgeQualified })) }), _jsx(Label, { children: "Age qualified" })] }), state.isAgeQualified ? (_jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-min-age", children: "Min age" }), _jsx(Input, { id: "pricing-category-min-age", type: "number", min: "0", value: state.minAge, onChange: (event) => setState((prev) => ({ ...prev, minAge: event.target.value })) })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-max-age", children: "Max age" }), _jsx(Input, { id: "pricing-category-max-age", type: "number", min: "0", value: state.maxAge, onChange: (event) => setState((prev) => ({ ...prev, maxAge: event.target.value })) })] })] })) : null, _jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-sort-order", children: "Sort order" }), _jsx(Input, { id: "pricing-category-sort-order", type: "number", value: state.sortOrder, onChange: (event) => setState((prev) => ({ ...prev, sortOrder: event.target.value })) })] }), _jsxs("div", { className: "flex items-center gap-2 pt-7", children: [_jsx(Switch, { checked: state.active, onCheckedChange: (active) => setState((prev) => ({ ...prev, active })) }), _jsx(Label, { children: "Active" })] })] }), error ? _jsx("p", { className: "text-sm text-destructive", children: error }) : null, _jsxs("div", { className: "flex items-center justify-end gap-2", children: [onCancel ? (_jsx(Button, { type: "button", variant: "ghost", onClick: onCancel, children: "Cancel" })) : null, _jsxs(Button, { type: "submit", disabled: isSubmitting, children: [isSubmitting ? (_jsx(Loader2, { className: "mr-2 size-4 animate-spin", "aria-hidden": "true" })) : null, mode.kind === "edit" ? "Save changes" : "Create category"] })] })] }));
103
+ })), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: CATEGORY_TYPES.map((type) => (_jsx(SelectItem, { value: type.value, children: messages.common.categoryTypeLabels[type.value] }, type.value))) })] })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-seat-occupancy", children: messages.pricingCategoryForm.fields.seatOccupancy }), _jsx(Input, { id: "pricing-category-seat-occupancy", type: "number", min: "0", value: state.seatOccupancy, onChange: (event) => setState((prev) => ({ ...prev, seatOccupancy: event.target.value })) })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Switch, { checked: state.isAgeQualified, onCheckedChange: (isAgeQualified) => setState((prev) => ({ ...prev, isAgeQualified })) }), _jsx(Label, { children: messages.pricingCategoryForm.fields.ageQualified })] }), state.isAgeQualified ? (_jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-min-age", children: messages.pricingCategoryForm.fields.minAge }), _jsx(Input, { id: "pricing-category-min-age", type: "number", min: "0", value: state.minAge, onChange: (event) => setState((prev) => ({ ...prev, minAge: event.target.value })) })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-max-age", children: messages.pricingCategoryForm.fields.maxAge }), _jsx(Input, { id: "pricing-category-max-age", type: "number", min: "0", value: state.maxAge, onChange: (event) => setState((prev) => ({ ...prev, maxAge: event.target.value })) })] })] })) : null, _jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "pricing-category-sort-order", children: messages.pricingCategoryForm.fields.sortOrder }), _jsx(Input, { id: "pricing-category-sort-order", type: "number", value: state.sortOrder, onChange: (event) => setState((prev) => ({ ...prev, sortOrder: event.target.value })) })] }), _jsxs("div", { className: "flex items-center gap-2 pt-7", children: [_jsx(Switch, { checked: state.active, onCheckedChange: (active) => setState((prev) => ({ ...prev, active })) }), _jsx(Label, { children: messages.pricingCategoryForm.fields.active })] })] }), error ? _jsx("p", { className: "text-sm text-destructive", children: error }) : null, _jsxs("div", { className: "flex items-center justify-end gap-2", children: [onCancel ? (_jsx(Button, { type: "button", variant: "ghost", onClick: onCancel, children: messages.common.cancel })) : null, _jsxs(Button, { type: "submit", disabled: isSubmitting, children: [isSubmitting ? (_jsx(Loader2, { className: "mr-2 size-4 animate-spin", "aria-hidden": "true" })) : null, mode.kind === "edit"
104
+ ? messages.common.saveChanges
105
+ : messages.pricingCategoryForm.actions.create] })] })] }));
99
106
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pricing-category-list.d.ts","sourceRoot":"","sources":["../../src/components/pricing-category-list.tsx"],"names":[],"mappings":"AA8BA,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,wBAAgB,mBAAmB,CAAC,EAAE,QAAa,EAAE,GAAE,wBAA6B,2CAyKnF"}
1
+ {"version":3,"file":"pricing-category-list.d.ts","sourceRoot":"","sources":["../../src/components/pricing-category-list.tsx"],"names":[],"mappings":"AA+BA,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,wBAAgB,mBAAmB,CAAC,EAAE,QAAa,EAAE,GAAE,wBAA6B,2CAyLnF"}
@@ -8,8 +8,10 @@ import { Input } from "@voyantjs/ui/components/input";
8
8
  import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@voyantjs/ui/components/table";
9
9
  import { Loader2, MoreHorizontal, Pencil, Plus, Search, Trash2 } from "lucide-react";
10
10
  import * as React from "react";
11
+ import { usePricingUiMessagesOrDefault } from "../i18n/provider";
11
12
  import { PricingCategoryDialog } from "./pricing-category-dialog";
12
13
  export function PricingCategoryList({ pageSize = 25 } = {}) {
14
+ const messages = usePricingUiMessagesOrDefault();
13
15
  const [dialogOpen, setDialogOpen] = React.useState(false);
14
16
  const [editing, setEditing] = React.useState(undefined);
15
17
  const [search, setSearch] = React.useState("");
@@ -25,20 +27,22 @@ export function PricingCategoryList({ pageSize = 25 } = {}) {
25
27
  const total = data?.total ?? 0;
26
28
  const page = Math.floor(offset / pageSize) + 1;
27
29
  const pageCount = Math.max(1, Math.ceil(total / pageSize));
28
- return (_jsxs("div", { "data-slot": "pricing-category-list", className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("div", { className: "relative w-full max-w-sm", children: [_jsx(Search, { className: "absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" }), _jsx(Input, { placeholder: "Search pricing categories\u2026", value: search, onChange: (event) => {
30
+ return (_jsxs("div", { "data-slot": "pricing-category-list", className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("div", { className: "relative w-full max-w-sm", children: [_jsx(Search, { className: "absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" }), _jsx(Input, { placeholder: messages.pricingCategoryList.searchPlaceholder, value: search, onChange: (event) => {
29
31
  setSearch(event.target.value);
30
32
  setOffset(0);
31
33
  }, className: "pl-9" })] }), _jsxs(Button, { onClick: () => {
32
34
  setEditing(undefined);
33
35
  setDialogOpen(true);
34
- }, children: [_jsx(Plus, { className: "mr-2 size-4" }), "New category"] })] }), _jsx("div", { className: "rounded-md border", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Name" }), _jsx(TableHead, { children: "Code" }), _jsx(TableHead, { children: "Type" }), _jsx(TableHead, { children: "Age" }), _jsx(TableHead, { children: "Seat" }), _jsx(TableHead, { children: "Sort" }), _jsx(TableHead, { children: "Status" }), _jsx(TableHead, { className: "w-[80px] text-right", children: "Actions" })] }) }), _jsx(TableBody, { children: isPending ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 8, className: "h-24 text-center", children: _jsx(Loader2, { className: "mx-auto size-4 animate-spin text-muted-foreground" }) }) })) : isError ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 8, className: "h-24 text-center text-sm text-destructive", children: "Failed to load pricing categories." }) })) : categories.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 8, className: "h-24 text-center text-sm text-muted-foreground", children: "No pricing categories found." }) })) : (categories.map((category) => (_jsxs(TableRow, { children: [_jsx(TableCell, { className: "font-medium", children: category.name }), _jsx(TableCell, { className: "font-mono text-xs text-muted-foreground", children: category.code ?? "—" }), _jsx(TableCell, { children: _jsx(Badge, { variant: "outline", className: "capitalize", children: category.categoryType }) }), _jsx(TableCell, { className: "text-xs text-muted-foreground", children: category.isAgeQualified
36
+ }, children: [_jsx(Plus, { className: "mr-2 size-4" }), messages.pricingCategoryList.add] })] }), _jsx("div", { className: "rounded-md border", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: messages.pricingCategoryList.columns.name }), _jsx(TableHead, { children: messages.pricingCategoryList.columns.code }), _jsx(TableHead, { children: messages.pricingCategoryList.columns.type }), _jsx(TableHead, { children: messages.pricingCategoryList.columns.age }), _jsx(TableHead, { children: messages.pricingCategoryList.columns.seat }), _jsx(TableHead, { children: messages.pricingCategoryList.columns.sort }), _jsx(TableHead, { children: messages.pricingCategoryList.columns.status }), _jsx(TableHead, { className: "w-[80px] text-right", children: messages.pricingCategoryList.columns.actions })] }) }), _jsx(TableBody, { children: isPending ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 8, className: "h-24 text-center", children: _jsx(Loader2, { className: "mx-auto size-4 animate-spin text-muted-foreground" }) }) })) : isError ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 8, className: "h-24 text-center text-sm text-destructive", children: messages.pricingCategoryList.loadingError }) })) : categories.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 8, className: "h-24 text-center text-sm text-muted-foreground", children: messages.pricingCategoryList.empty }) })) : (categories.map((category) => (_jsxs(TableRow, { children: [_jsx(TableCell, { className: "font-medium", children: category.name }), _jsx(TableCell, { className: "font-mono text-xs text-muted-foreground", children: category.code ?? messages.common.none }), _jsx(TableCell, { children: _jsx(Badge, { variant: "outline", children: messages.common.categoryTypeLabels[category.categoryType] }) }), _jsx(TableCell, { className: "text-xs text-muted-foreground", children: category.isAgeQualified
35
37
  ? `${category.minAge ?? 0}–${category.maxAge ?? "∞"}`
36
- : "—" }), _jsx(TableCell, { className: "font-mono", children: category.seatOccupancy }), _jsx(TableCell, { className: "font-mono", children: category.sortOrder }), _jsx(TableCell, { children: _jsx(Badge, { variant: category.active ? "default" : "outline", children: category.active ? "Active" : "Inactive" }) }), _jsx(TableCell, { className: "text-right", children: _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { className: "inline-flex size-8 items-center justify-center rounded-md text-muted-foreground outline-hidden hover:bg-accent hover:text-accent-foreground", children: _jsx(MoreHorizontal, { className: "size-4" }) }), _jsxs(DropdownMenuContent, { align: "end", children: [_jsxs(DropdownMenuItem, { onClick: () => {
38
+ : messages.common.none }), _jsx(TableCell, { className: "font-mono", children: category.seatOccupancy }), _jsx(TableCell, { className: "font-mono", children: category.sortOrder }), _jsx(TableCell, { children: _jsx(Badge, { variant: category.active ? "default" : "outline", children: category.active ? messages.common.active : messages.common.inactive }) }), _jsx(TableCell, { className: "text-right", children: _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { className: "inline-flex size-8 items-center justify-center rounded-md text-muted-foreground outline-hidden hover:bg-accent hover:text-accent-foreground", children: _jsx(MoreHorizontal, { className: "size-4" }) }), _jsxs(DropdownMenuContent, { align: "end", children: [_jsxs(DropdownMenuItem, { onClick: () => {
37
39
  setEditing(category);
38
40
  setDialogOpen(true);
39
- }, children: [_jsx(Pencil, { className: "size-4" }), "Edit"] }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { variant: "destructive", onClick: () => {
40
- if (confirm(`Delete category "${category.name}"?`)) {
41
+ }, children: [_jsx(Pencil, { className: "size-4" }), messages.pricingCategoryList.edit] }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { variant: "destructive", onClick: () => {
42
+ if (confirm(messages.pricingCategoryList.deleteConfirm.replace("{name}", category.name))) {
41
43
  remove.mutate(category.id);
42
44
  }
43
- }, children: [_jsx(Trash2, { className: "size-4" }), "Delete"] })] })] }) })] }, category.id)))) })] }) }), _jsxs("div", { className: "flex items-center justify-between text-sm text-muted-foreground", children: [_jsxs("span", { children: ["Showing ", categories.length, " of ", total] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Button, { variant: "outline", size: "sm", disabled: offset === 0, onClick: () => setOffset((prev) => Math.max(0, prev - pageSize)), children: "Previous" }), _jsxs("span", { children: ["Page ", page, " / ", pageCount] }), _jsx(Button, { variant: "outline", size: "sm", disabled: offset + pageSize >= total, onClick: () => setOffset((prev) => prev + pageSize), children: "Next" })] })] }), _jsx(PricingCategoryDialog, { open: dialogOpen, onOpenChange: setDialogOpen, category: editing })] }));
45
+ }, children: [_jsx(Trash2, { className: "size-4" }), messages.pricingCategoryList.delete] })] })] }) })] }, category.id)))) })] }) }), _jsxs("div", { className: "flex items-center justify-between text-sm text-muted-foreground", children: [_jsx("span", { children: messages.pricingCategoryList.showingSummary
46
+ .replace("{count}", String(categories.length))
47
+ .replace("{total}", String(total)) }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Button, { variant: "outline", size: "sm", disabled: offset === 0, onClick: () => setOffset((prev) => Math.max(0, prev - pageSize)), children: messages.common.previous }), _jsxs("span", { children: [messages.common.page, " ", page, " / ", pageCount] }), _jsx(Button, { variant: "outline", size: "sm", disabled: offset + pageSize >= total, onClick: () => setOffset((prev) => prev + pageSize), children: messages.common.next })] })] }), _jsx(PricingCategoryDialog, { open: dialogOpen, onOpenChange: setDialogOpen, category: editing })] }));
44
48
  }
@@ -4,6 +4,6 @@ type Props = {
4
4
  placeholder?: string;
5
5
  disabled?: boolean;
6
6
  };
7
- export declare function ProductCombobox({ value, onChange, placeholder, disabled, }: Props): import("react/jsx-runtime").JSX.Element;
7
+ export declare function ProductCombobox({ value, onChange, placeholder, disabled }: Props): import("react/jsx-runtime").JSX.Element;
8
8
  export {};
9
9
  //# sourceMappingURL=product-combobox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"product-combobox.d.ts","sourceRoot":"","sources":["../../src/components/product-combobox.tsx"],"names":[],"mappings":"AAYA,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAID,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,QAAQ,EACR,WAAgC,EAChC,QAAQ,GACT,EAAE,KAAK,2CAkEP"}
1
+ {"version":3,"file":"product-combobox.d.ts","sourceRoot":"","sources":["../../src/components/product-combobox.tsx"],"names":[],"mappings":"AAcA,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAID,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,KAAK,2CAwEhF"}