@voyantjs/products-ui 0.20.0 → 0.21.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-category-form.d.ts","sourceRoot":"","sources":["../../src/components/product-category-form.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"product-category-form.d.ts","sourceRoot":"","sources":["../../src/components/product-category-form.tsx"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,qBAAqB,EAE3B,MAAM,0BAA0B,CAAA;AAYjC,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;AAmDD,wBAAgB,mBAAmB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,wBAAwB,2CAqJ1F"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { PaymentPolicyForm, PaymentPolicyPreview } from "@voyantjs/finance-ui";
|
|
3
4
|
import { useProductCategoryMutation, } from "@voyantjs/products-react";
|
|
4
5
|
import { Button } from "@voyantjs/ui/components/button";
|
|
5
6
|
import { Input } from "@voyantjs/ui/components/input";
|
|
@@ -20,6 +21,7 @@ function initialState(mode) {
|
|
|
20
21
|
description: category.description ?? "",
|
|
21
22
|
sortOrder: String(category.sortOrder),
|
|
22
23
|
active: category.active,
|
|
24
|
+
customerPaymentPolicy: category.customerPaymentPolicy ?? null,
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
27
|
return {
|
|
@@ -29,6 +31,7 @@ function initialState(mode) {
|
|
|
29
31
|
description: "",
|
|
30
32
|
sortOrder: "0",
|
|
31
33
|
active: true,
|
|
34
|
+
customerPaymentPolicy: null,
|
|
32
35
|
};
|
|
33
36
|
}
|
|
34
37
|
function toPayload(state) {
|
|
@@ -39,6 +42,7 @@ function toPayload(state) {
|
|
|
39
42
|
description: state.description.trim() || null,
|
|
40
43
|
sortOrder: Number(state.sortOrder) || 0,
|
|
41
44
|
active: state.active,
|
|
45
|
+
customerPaymentPolicy: state.customerPaymentPolicy ?? null,
|
|
42
46
|
};
|
|
43
47
|
}
|
|
44
48
|
export function ProductCategoryForm({ mode, onSuccess, onCancel }) {
|
|
@@ -72,7 +76,7 @@ export function ProductCategoryForm({ mode, onSuccess, onCancel }) {
|
|
|
72
76
|
setError(err instanceof Error ? err.message : messages.productCategoryForm.validation.saveFailed);
|
|
73
77
|
}
|
|
74
78
|
};
|
|
75
|
-
return (_jsxs("form", { "data-slot": "product-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: "product-category-name", children: messages.productCategoryForm.fields.name }), _jsx(Input, { id: "product-category-name", required: true, autoFocus: true, value: state.name, onChange: (event) => setState((prev) => ({ ...prev, name: event.target.value })), placeholder: messages.productCategoryForm.placeholders.name })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "product-category-slug", children: messages.productCategoryForm.fields.slug }), _jsx(Input, { id: "product-category-slug", required: true, value: state.slug, onChange: (event) => setState((prev) => ({ ...prev, slug: event.target.value })), placeholder: messages.productCategoryForm.placeholders.slug })] })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { children: messages.productCategoryForm.fields.parentCategory }), _jsx(ProductCategoryCombobox, { value: state.parentId === "__none__" ? null : state.parentId, onChange: (value) => setState((prev) => ({ ...prev, parentId: value ?? "__none__" })), excludeId: mode.kind === "edit" ? mode.category.id : null, placeholder: messages.productCategoryForm.placeholders.parentCategory })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "product-category-description", children: messages.productCategoryForm.fields.description }), _jsx(Textarea, { id: "product-category-description", value: state.description, onChange: (event) => setState((prev) => ({ ...prev, description: event.target.value })), placeholder: messages.productCategoryForm.placeholders.description })] }), _jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "product-category-sort-order", children: messages.productCategoryForm.fields.sortOrder }), _jsx(Input, { id: "product-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.productCategoryForm.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"
|
|
79
|
+
return (_jsxs("form", { "data-slot": "product-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: "product-category-name", children: messages.productCategoryForm.fields.name }), _jsx(Input, { id: "product-category-name", required: true, autoFocus: true, value: state.name, onChange: (event) => setState((prev) => ({ ...prev, name: event.target.value })), placeholder: messages.productCategoryForm.placeholders.name })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "product-category-slug", children: messages.productCategoryForm.fields.slug }), _jsx(Input, { id: "product-category-slug", required: true, value: state.slug, onChange: (event) => setState((prev) => ({ ...prev, slug: event.target.value })), placeholder: messages.productCategoryForm.placeholders.slug })] })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { children: messages.productCategoryForm.fields.parentCategory }), _jsx(ProductCategoryCombobox, { value: state.parentId === "__none__" ? null : state.parentId, onChange: (value) => setState((prev) => ({ ...prev, parentId: value ?? "__none__" })), excludeId: mode.kind === "edit" ? mode.category.id : null, placeholder: messages.productCategoryForm.placeholders.parentCategory })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "product-category-description", children: messages.productCategoryForm.fields.description }), _jsx(Textarea, { id: "product-category-description", value: state.description, onChange: (event) => setState((prev) => ({ ...prev, description: event.target.value })), placeholder: messages.productCategoryForm.placeholders.description })] }), _jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { htmlFor: "product-category-sort-order", children: messages.productCategoryForm.fields.sortOrder }), _jsx(Input, { id: "product-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.productCategoryForm.fields.active })] })] }), _jsxs("div", { className: "flex flex-col gap-3 rounded-md border bg-muted/10 p-4", children: [_jsxs("div", { children: [_jsx("h3", { className: "text-sm font-medium", children: "Customer payment policy" }), _jsx("p", { className: "text-muted-foreground text-xs", children: "When set, products in this category inherit these terms unless the listing or booking sets its own override. Wins over the supplier-level policy." })] }), _jsxs("div", { className: "grid gap-4 lg:grid-cols-[2fr_1fr]", children: [_jsx(PaymentPolicyForm, { value: state.customerPaymentPolicy, onChange: (next) => setState((prev) => ({ ...prev, customerPaymentPolicy: next })), inheritable: true, disabled: isSubmitting }), _jsx(PaymentPolicyPreview, { policy: state.customerPaymentPolicy })] })] }), 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"
|
|
76
80
|
? messages.common.saveChanges
|
|
77
81
|
: messages.productCategoryForm.actions.createCategory] })] })] }));
|
|
78
82
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyantjs/products-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,15 +43,17 @@
|
|
|
43
43
|
"@tanstack/react-query": "^5.0.0",
|
|
44
44
|
"react": "^19.0.0",
|
|
45
45
|
"react-dom": "^19.0.0",
|
|
46
|
-
"@voyantjs/availability-react": "0.
|
|
47
|
-
"@voyantjs/catalog-react": "0.
|
|
48
|
-
"@voyantjs/
|
|
49
|
-
"@voyantjs/
|
|
50
|
-
"@voyantjs/
|
|
51
|
-
"@voyantjs/
|
|
46
|
+
"@voyantjs/availability-react": "0.21.0",
|
|
47
|
+
"@voyantjs/catalog-react": "0.21.0",
|
|
48
|
+
"@voyantjs/finance": "0.21.0",
|
|
49
|
+
"@voyantjs/finance-ui": "0.21.0",
|
|
50
|
+
"@voyantjs/pricing-react": "0.21.0",
|
|
51
|
+
"@voyantjs/products-react": "0.21.0",
|
|
52
|
+
"@voyantjs/suppliers-react": "0.21.0",
|
|
53
|
+
"@voyantjs/ui": "0.21.0"
|
|
52
54
|
},
|
|
53
55
|
"dependencies": {
|
|
54
|
-
"@voyantjs/i18n": "0.
|
|
56
|
+
"@voyantjs/i18n": "0.21.0"
|
|
55
57
|
},
|
|
56
58
|
"devDependencies": {
|
|
57
59
|
"@tanstack/react-query": "^5.96.2",
|
|
@@ -62,14 +64,16 @@
|
|
|
62
64
|
"react-dom": "^19.2.4",
|
|
63
65
|
"typescript": "^6.0.2",
|
|
64
66
|
"vitest": "^4.1.2",
|
|
65
|
-
"@voyantjs/availability-react": "0.
|
|
66
|
-
"@voyantjs/catalog-react": "0.
|
|
67
|
-
"@voyantjs/
|
|
68
|
-
"@voyantjs/
|
|
69
|
-
"@voyantjs/
|
|
70
|
-
"@voyantjs/
|
|
67
|
+
"@voyantjs/availability-react": "0.21.0",
|
|
68
|
+
"@voyantjs/catalog-react": "0.21.0",
|
|
69
|
+
"@voyantjs/finance": "0.21.0",
|
|
70
|
+
"@voyantjs/finance-ui": "0.21.0",
|
|
71
|
+
"@voyantjs/i18n": "0.21.0",
|
|
72
|
+
"@voyantjs/pricing-react": "0.21.0",
|
|
73
|
+
"@voyantjs/products-react": "0.21.0",
|
|
74
|
+
"@voyantjs/suppliers-react": "0.21.0",
|
|
71
75
|
"@voyantjs/voyant-typescript-config": "0.1.0",
|
|
72
|
-
"@voyantjs/ui": "0.
|
|
76
|
+
"@voyantjs/ui": "0.21.0"
|
|
73
77
|
},
|
|
74
78
|
"files": [
|
|
75
79
|
"dist",
|