pixelize-design-library 2.2.78 → 2.2.80
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,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ProductCardProps } from "./ProductCardProps";
|
|
3
|
-
declare const ProductCard: ({ id, label, productImage, rating, reviews, tags, options, button, batch, description, avalabilitys, onAddToCart, onNotifyMe, onClick, addToCart, goToCart, OnGoToCart, size, }: ProductCardProps) => React.JSX.Element;
|
|
3
|
+
declare const ProductCard: ({ id, label, productImage, rating, reviews, tags, options, button, batch, description, avalabilitys, onAddToCart, onNotifyMe, onClick, onOptionChange, addToCart, goToCart, OnGoToCart, size, }: ProductCardProps) => React.JSX.Element;
|
|
4
4
|
export default ProductCard;
|
|
@@ -37,11 +37,15 @@ var useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
|
37
37
|
var lucide_react_1 = require("lucide-react");
|
|
38
38
|
var ProductCard = function (_a) {
|
|
39
39
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
40
|
-
var id = _a.id, label = _a.label, productImage = _a.productImage, rating = _a.rating, reviews = _a.reviews, tags = _a.tags, options = _a.options, button = _a.button, batch = _a.batch, description = _a.description, avalabilitys = _a.avalabilitys, onAddToCart = _a.onAddToCart, onNotifyMe = _a.onNotifyMe, onClick = _a.onClick, addToCart = _a.addToCart, goToCart = _a.goToCart, OnGoToCart = _a.OnGoToCart, _o = _a.size, size = _o === void 0 ? "sm" : _o;
|
|
40
|
+
var id = _a.id, label = _a.label, productImage = _a.productImage, rating = _a.rating, reviews = _a.reviews, tags = _a.tags, options = _a.options, button = _a.button, batch = _a.batch, description = _a.description, avalabilitys = _a.avalabilitys, onAddToCart = _a.onAddToCart, onNotifyMe = _a.onNotifyMe, onClick = _a.onClick, onOptionChange = _a.onOptionChange, addToCart = _a.addToCart, goToCart = _a.goToCart, OnGoToCart = _a.OnGoToCart, _o = _a.size, size = _o === void 0 ? "sm" : _o;
|
|
41
41
|
var _p = (0, react_1.useState)(false), hover = _p[0], setHover = _p[1];
|
|
42
42
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
43
43
|
var _q = (0, react_1.useState)(options === null || options === void 0 ? void 0 : options[0]), selectedOption = _q[0], setSelectedOption = _q[1];
|
|
44
44
|
var _r = (0, react_1.useState)(1), qty = _r[0], setQty = _r[1];
|
|
45
|
+
var handleOptionSelect = function (option) {
|
|
46
|
+
setSelectedOption(option);
|
|
47
|
+
onOptionChange === null || onOptionChange === void 0 ? void 0 : onOptionChange(option);
|
|
48
|
+
};
|
|
45
49
|
var handleIncrement = function (e) {
|
|
46
50
|
e.stopPropagation();
|
|
47
51
|
if ((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.stocks) && qty < selectedOption.stocks) {
|
|
@@ -86,7 +90,7 @@ var ProductCard = function (_a) {
|
|
|
86
90
|
react_1.default.createElement(react_2.Box, { onClick: onClick, cursor: "pointer" },
|
|
87
91
|
react_1.default.createElement(ProductLabel_1.default, { label: label, description: description, size: size })),
|
|
88
92
|
tags && react_1.default.createElement(ProductTags_1.default, { tags: tags, size: size }),
|
|
89
|
-
options && react_1.default.createElement(ProductPrice_1.default, { options: options, size: size, onSelect:
|
|
93
|
+
options && react_1.default.createElement(ProductPrice_1.default, { options: options, size: size, onSelect: handleOptionSelect }),
|
|
90
94
|
typeof (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.stocks) === "number" && (react_1.default.createElement(react_2.Badge, { colorScheme: ((_d = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.stocks) !== null && _d !== void 0 ? _d : 0) >= 5
|
|
91
95
|
? "green"
|
|
92
96
|
: ((_e = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.stocks) !== null && _e !== void 0 ? _e : 0) > 0
|
|
@@ -96,12 +100,12 @@ var ProductCard = function (_a) {
|
|
|
96
100
|
: ((_g = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.stocks) !== null && _g !== void 0 ? _g : 0) > 0
|
|
97
101
|
? "".concat(selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.stocks, " IN STOCK")
|
|
98
102
|
: "OUT OF STOCK")),
|
|
99
|
-
(
|
|
100
|
-
addToCart && (((_j = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.stocks) !== null && _j !== void 0 ? _j : 1) > 0) && (react_1.default.createElement(react_2.HStack, { w: "full", justify: "space-between", mb: 2 },
|
|
103
|
+
addToCart && (((_h = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.stocks) !== null && _h !== void 0 ? _h : 1) > 0) && (react_1.default.createElement(react_2.HStack, { w: "full", justify: "space-between", mb: 2 },
|
|
101
104
|
react_1.default.createElement(react_2.HStack, null,
|
|
102
105
|
react_1.default.createElement(react_2.IconButton, { icon: react_1.default.createElement(lucide_react_1.Minus, { size: 16 }), "aria-label": "Decrease quantity", size: "xs", onClick: handleDecrement, isDisabled: qty <= 1, isRound: true, variant: "outline", colorScheme: "red" }),
|
|
103
106
|
react_1.default.createElement(react_2.Text, { fontWeight: "bold", w: 8, textAlign: "center" }, qty),
|
|
104
|
-
react_1.default.createElement(react_2.IconButton, { icon: react_1.default.createElement(lucide_react_1.Plus, { size: 16 }), "aria-label": "Increase quantity", size: "xs", onClick: handleIncrement, isDisabled: qty >= ((
|
|
107
|
+
react_1.default.createElement(react_2.IconButton, { icon: react_1.default.createElement(lucide_react_1.Plus, { size: 16 }), "aria-label": "Increase quantity", size: "xs", onClick: handleIncrement, isDisabled: qty >= ((_j = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.stocks) !== null && _j !== void 0 ? _j : 1), isRound: true, variant: "outline", colorScheme: "red" })))),
|
|
108
|
+
(button === null || button === void 0 ? void 0 : button.onClick) && (react_1.default.createElement(Button_1.default, { colorScheme: "red", size: safeSize, width: "100%", onClick: button === null || button === void 0 ? void 0 : button.onClick }, (_k = button.label) !== null && _k !== void 0 ? _k : "Add to Cart")),
|
|
105
109
|
addToCart && (((_l = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.stocks) !== null && _l !== void 0 ? _l : 1) > 0) && (react_1.default.createElement(Button_1.default, { width: "100%", size: safeSize, onClick: function () { return (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.var_id) !== undefined && (onAddToCart === null || onAddToCart === void 0 ? void 0 : onAddToCart(id, selectedOption.var_id, qty)); }, colorScheme: "red" }, "Add to Cart")),
|
|
106
110
|
addToCart && (((_m = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.stocks) !== null && _m !== void 0 ? _m : 1) <= 0) && (react_1.default.createElement(Button_1.default, { width: "100%", size: safeSize, onClick: function () { return (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.var_id) !== undefined && (onNotifyMe === null || onNotifyMe === void 0 ? void 0 : onNotifyMe(id, selectedOption.var_id)); }, colorScheme: "red", variant: "outline" }, "Notify Me")),
|
|
107
111
|
goToCart && (react_1.default.createElement(Button_1.default, { width: "100%", size: safeSize, onClick: OnGoToCart, colorScheme: "red" }, "Go to Cart")))));
|
|
@@ -15,6 +15,7 @@ export type ProductCardProps = {
|
|
|
15
15
|
};
|
|
16
16
|
onAddToCart?: (id: string | number, var_id: number, qty?: number) => void;
|
|
17
17
|
onNotifyMe?: (id: string | number, var_id: number) => void;
|
|
18
|
+
onOptionChange?: (option: options) => void;
|
|
18
19
|
addToCart?: boolean;
|
|
19
20
|
goToCart?: boolean;
|
|
20
21
|
OnGoToCart?: () => void;
|
|
@@ -3,7 +3,7 @@ import { options, SizeType } from './ProductCardProps';
|
|
|
3
3
|
type ProductPriceProps = {
|
|
4
4
|
options: options[];
|
|
5
5
|
size: SizeType;
|
|
6
|
-
onSelect?:
|
|
6
|
+
onSelect?: (option: options) => void;
|
|
7
7
|
};
|
|
8
8
|
declare const ProductPrice: ({ options, size, onSelect }: ProductPriceProps) => React.JSX.Element;
|
|
9
9
|
export default ProductPrice;
|