@gem-sdk/plugin-cart-drawer 1.0.5 → 1.5.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/CartDiscountCode.js +83 -39
- package/dist/cjs/components/CartDrawer.js +126 -35
- package/dist/cjs/components/CartFooter.js +58 -34
- package/dist/cjs/components/CartLineItem.js +158 -64
- package/dist/cjs/components/CartLineItemQuantity.js +46 -10
- package/dist/cjs/components/CartLineQuantityAdjustButton.js +195 -147
- package/dist/cjs/components/CartOrderNote.js +61 -35
- package/dist/cjs/components/DiscountCodeItem.js +108 -67
- package/dist/cjs/components/LoadingIcon.js +21 -1
- package/dist/cjs/components/icons/Trash.js +20 -1
- package/dist/esm/components/CartDiscountCode.js +83 -39
- package/dist/esm/components/CartDrawer.js +126 -35
- package/dist/esm/components/CartFooter.js +59 -35
- package/dist/esm/components/CartLineItem.js +158 -64
- package/dist/esm/components/CartLineItemQuantity.js +46 -10
- package/dist/esm/components/CartLineQuantityAdjustButton.js +195 -147
- package/dist/esm/components/CartOrderNote.js +61 -35
- package/dist/esm/components/DiscountCodeItem.js +108 -67
- package/dist/esm/components/LoadingIcon.js +21 -1
- package/dist/esm/components/icons/Trash.js +20 -1
- package/package.json +1 -1
|
@@ -7,153 +7,201 @@ var core = require('@gem-sdk/core');
|
|
|
7
7
|
var components = require('@gem-sdk/components');
|
|
8
8
|
var Trash = require('./icons/Trash.js');
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* The `CartLineQuantityAdjustButton` component renders a button that adjusts the cart line's quantity when pressed.
|
|
12
|
-
* It must be a descendent of a `CartLineProvider` component.
|
|
13
|
-
*/
|
|
14
|
-
const
|
|
15
|
-
const { isMutating:
|
|
16
|
-
const {
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The `CartLineQuantityAdjustButton` component renders a button that adjusts the cart line's quantity when pressed.
|
|
12
|
+
* It must be a descendent of a `CartLineProvider` component.
|
|
13
|
+
*/ const CartLineQuantityAdjustButton = ({ children , adjust , className , style })=>{
|
|
14
|
+
const { isMutating: updateLoading , trigger: updateLines } = core.useUpdateCartItem();
|
|
15
|
+
const { isMutating: removeLoading , trigger: removeLines } = core.useRemoveCartItem();
|
|
16
|
+
const { cartId } = core.useCartId();
|
|
17
|
+
const cartLine = core.useCartLine();
|
|
18
|
+
const isLoading = updateLoading || removeLoading;
|
|
19
|
+
return /*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
20
|
+
"aria-label": "Adjust quantity",
|
|
21
|
+
className,
|
|
22
|
+
style,
|
|
23
|
+
disabled: isLoading,
|
|
24
|
+
onClick: ()=>{
|
|
25
|
+
if (cartId && cartLine.id) {
|
|
26
|
+
if (adjust === 'remove') {
|
|
27
|
+
components.openConfirm({
|
|
28
|
+
title: /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
29
|
+
className: "flex w-full flex-col items-center gap-4",
|
|
30
|
+
children: [
|
|
31
|
+
/*#__PURE__*/ jsxRuntime.jsx(Trash.default, {}),
|
|
32
|
+
/*#__PURE__*/ jsxRuntime.jsx("p", {
|
|
33
|
+
className: "font-g-body text-xl font-semibold",
|
|
34
|
+
children: "Are you sure ?"
|
|
35
|
+
})
|
|
36
|
+
]
|
|
37
|
+
}),
|
|
38
|
+
content: /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
39
|
+
className: "text-center",
|
|
40
|
+
children: [
|
|
41
|
+
/*#__PURE__*/ jsxRuntime.jsx("p", {
|
|
42
|
+
children: "Do you really want to delete this item?"
|
|
43
|
+
}),
|
|
44
|
+
/*#__PURE__*/ jsxRuntime.jsx("p", {
|
|
45
|
+
children: "This process cannot be undone."
|
|
46
|
+
})
|
|
47
|
+
]
|
|
48
|
+
}),
|
|
49
|
+
className: 'w-full max-w-[572px] gap-4 rounded',
|
|
50
|
+
buttons: [
|
|
51
|
+
{
|
|
52
|
+
label: 'Cancel',
|
|
53
|
+
className: 'w-[130px]',
|
|
54
|
+
styles: {
|
|
55
|
+
backgroundColor: {
|
|
56
|
+
normal: 'bg-1'
|
|
57
|
+
},
|
|
58
|
+
roundedBtn: {
|
|
59
|
+
normal: {
|
|
60
|
+
radiusType: 'small'
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
btnSpacing: {
|
|
64
|
+
type: 'small'
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
label: 'Delete',
|
|
70
|
+
className: 'w-[130px]',
|
|
71
|
+
styles: {
|
|
72
|
+
textColor: {
|
|
73
|
+
normal: 'text-3'
|
|
74
|
+
},
|
|
75
|
+
backgroundColor: {
|
|
76
|
+
normal: 'error'
|
|
77
|
+
},
|
|
78
|
+
roundedBtn: {
|
|
79
|
+
normal: {
|
|
80
|
+
radiusType: 'small'
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
btnSpacing: {
|
|
84
|
+
type: 'small'
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
onClick: ()=>{
|
|
88
|
+
if (cartLine.id) {
|
|
89
|
+
removeLines({
|
|
90
|
+
cartId,
|
|
91
|
+
lineId: cartLine.id
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
});
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const quantity = adjust === 'decrease' ? cartLine.quantity - 1 : cartLine.quantity + 1;
|
|
101
|
+
if (quantity <= 0) {
|
|
102
|
+
components.openConfirm({
|
|
103
|
+
title: /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
104
|
+
className: "flex w-full flex-col items-center gap-4",
|
|
105
|
+
children: [
|
|
106
|
+
/*#__PURE__*/ jsxRuntime.jsx(Trash.default, {}),
|
|
107
|
+
/*#__PURE__*/ jsxRuntime.jsx("p", {
|
|
108
|
+
className: "font-g-body text-xl font-semibold",
|
|
109
|
+
children: "Are you sure ?"
|
|
110
|
+
})
|
|
111
|
+
]
|
|
112
|
+
}),
|
|
113
|
+
content: /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
114
|
+
className: "text-center",
|
|
115
|
+
children: [
|
|
116
|
+
/*#__PURE__*/ jsxRuntime.jsx("p", {
|
|
117
|
+
children: "Do you really want to delete this item?"
|
|
118
|
+
}),
|
|
119
|
+
/*#__PURE__*/ jsxRuntime.jsx("p", {
|
|
120
|
+
children: "This process cannot be undone."
|
|
121
|
+
})
|
|
122
|
+
]
|
|
123
|
+
}),
|
|
124
|
+
className: 'w-full max-w-[572px] gap-4 rounded',
|
|
125
|
+
buttons: [
|
|
126
|
+
{
|
|
127
|
+
label: 'Cancel',
|
|
128
|
+
className: 'w-[130px]',
|
|
129
|
+
styles: {
|
|
130
|
+
backgroundColor: {
|
|
131
|
+
normal: 'bg-1'
|
|
132
|
+
},
|
|
133
|
+
roundedBtn: {
|
|
134
|
+
normal: {
|
|
135
|
+
radiusType: 'small'
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
btnSpacing: {
|
|
139
|
+
type: 'small'
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
label: 'Delete',
|
|
145
|
+
className: 'w-[130px]',
|
|
146
|
+
styles: {
|
|
147
|
+
textColor: {
|
|
148
|
+
normal: 'text-3'
|
|
149
|
+
},
|
|
150
|
+
backgroundColor: {
|
|
151
|
+
normal: 'error'
|
|
152
|
+
},
|
|
153
|
+
roundedBtn: {
|
|
154
|
+
normal: {
|
|
155
|
+
radiusType: 'small'
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
btnSpacing: {
|
|
159
|
+
type: 'small'
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
onClick: ()=>{
|
|
163
|
+
if (cartLine.id) {
|
|
164
|
+
removeLines({
|
|
165
|
+
cartId,
|
|
166
|
+
lineId: cartLine.id
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
});
|
|
173
|
+
return;
|
|
174
|
+
} else {
|
|
175
|
+
updateLines({
|
|
176
|
+
cartId,
|
|
177
|
+
line: {
|
|
178
|
+
id: cartLine.id,
|
|
179
|
+
variantId: cartLine.variant.id,
|
|
180
|
+
quantity,
|
|
181
|
+
productId: cartLine.productId
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
children: isLoading ? /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
188
|
+
className: "flex gap-1",
|
|
189
|
+
children: [
|
|
190
|
+
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
191
|
+
className: "aspect-square h-1 animate-[flashing_500ms_infinite_alternate] rounded-full bg-g-brand"
|
|
192
|
+
}),
|
|
193
|
+
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
194
|
+
className: "aspect-square h-1 animate-[flashing_500ms_infinite_200ms_linear_alternate] rounded-full bg-g-brand"
|
|
195
|
+
}),
|
|
196
|
+
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
197
|
+
className: "aspect-square h-1 animate-[flashing_500ms_infinite_500ms_alternate] rounded-full bg-g-brand"
|
|
198
|
+
})
|
|
199
|
+
]
|
|
200
|
+
}) : children
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
CartLineQuantityAdjustButton.defaultProps = {
|
|
204
|
+
adjust: 'increase'
|
|
157
205
|
};
|
|
158
206
|
|
|
159
207
|
exports.default = CartLineQuantityAdjustButton;
|
|
@@ -6,41 +6,67 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
6
6
|
var core = require('@gem-sdk/core');
|
|
7
7
|
var react = require('react');
|
|
8
8
|
|
|
9
|
-
const CartOrderNote = ({ triggerUpdate, debounce, placeholder
|
|
10
|
-
const textRef = react.useRef(null);
|
|
11
|
-
const timeout = react.useRef(null);
|
|
12
|
-
const abortControllerRef = react.useRef(new AbortController());
|
|
13
|
-
const { data: cart
|
|
14
|
-
const { cartId
|
|
15
|
-
const { trigger: updateCartNote
|
|
16
|
-
const updateNote = react.useCallback((note)
|
|
17
|
-
if (cartId && cart?.note !== note) {
|
|
18
|
-
updateCartNote({
|
|
19
|
-
cartId,
|
|
20
|
-
note
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}, [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
9
|
+
const CartOrderNote = ({ triggerUpdate , debounce , placeholder })=>{
|
|
10
|
+
const textRef = react.useRef(null);
|
|
11
|
+
const timeout = react.useRef(null);
|
|
12
|
+
const abortControllerRef = react.useRef(new AbortController());
|
|
13
|
+
const { data: cart } = core.useCartData();
|
|
14
|
+
const { cartId } = core.useCartId();
|
|
15
|
+
const { trigger: updateCartNote } = core.useCartNoteUpdate();
|
|
16
|
+
const updateNote = react.useCallback((note)=>{
|
|
17
|
+
if (cartId && cart?.note !== note) {
|
|
18
|
+
updateCartNote({
|
|
19
|
+
cartId,
|
|
20
|
+
note
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}, [
|
|
24
|
+
cart?.note,
|
|
25
|
+
cartId,
|
|
26
|
+
updateCartNote
|
|
27
|
+
]);
|
|
28
|
+
const onBlur = (e)=>{
|
|
29
|
+
if (abortControllerRef.current.signal.aborted) {
|
|
30
|
+
abortControllerRef.current = new AbortController();
|
|
31
|
+
}
|
|
32
|
+
updateNote(e.target.value);
|
|
33
|
+
};
|
|
34
|
+
const onChange = ()=>{
|
|
35
|
+
if (timeout.current) {
|
|
36
|
+
if (!abortControllerRef.current.signal.aborted) {
|
|
37
|
+
abortControllerRef.current.abort();
|
|
38
|
+
}
|
|
39
|
+
clearTimeout(timeout.current);
|
|
40
|
+
}
|
|
41
|
+
timeout.current = setTimeout(()=>{
|
|
42
|
+
abortControllerRef.current = new AbortController();
|
|
43
|
+
updateNote(textRef.current?.value ?? '');
|
|
44
|
+
}, debounce ?? 1000);
|
|
45
|
+
};
|
|
46
|
+
const inputProps = triggerUpdate === 'blur' ? {
|
|
47
|
+
onBlur
|
|
48
|
+
} : {
|
|
49
|
+
onChange
|
|
50
|
+
};
|
|
51
|
+
return /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
52
|
+
className: "flex flex-col",
|
|
53
|
+
children: [
|
|
54
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
55
|
+
className: "mb-4 border-b border-b-[#F1F3F4] pb-3",
|
|
56
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
57
|
+
className: "font-semibold text-[#424242]",
|
|
58
|
+
children: "Order Note"
|
|
59
|
+
})
|
|
60
|
+
}),
|
|
61
|
+
/*#__PURE__*/ jsxRuntime.jsx("textarea", {
|
|
62
|
+
defaultValue: cart?.note,
|
|
63
|
+
placeholder: placeholder,
|
|
64
|
+
ref: textRef,
|
|
65
|
+
className: "w-full rounded border p-4 outline-none",
|
|
66
|
+
...inputProps
|
|
67
|
+
})
|
|
68
|
+
]
|
|
69
|
+
});
|
|
44
70
|
};
|
|
45
71
|
|
|
46
72
|
exports.default = CartOrderNote;
|
|
@@ -9,73 +9,114 @@ var react = require('react');
|
|
|
9
9
|
var Trash = require('./icons/Trash.js');
|
|
10
10
|
var LoadingIcon = require('./LoadingIcon.js');
|
|
11
11
|
|
|
12
|
-
const DiscountCodeItem = ({ item
|
|
13
|
-
const { cartId
|
|
14
|
-
const { trigger: updateCartDiscountCode, isMutating
|
|
15
|
-
const { data: cart
|
|
16
|
-
const currentCode = react.useMemo(()
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
normal:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
12
|
+
const DiscountCodeItem = ({ item })=>{
|
|
13
|
+
const { cartId } = core.useCartId();
|
|
14
|
+
const { trigger: updateCartDiscountCode , isMutating } = core.useCartDiscountCodesUpdate();
|
|
15
|
+
const { data: cart } = core.useCartData();
|
|
16
|
+
const currentCode = react.useMemo(()=>cart?.discounts?.map((v)=>v.code).filter(core.isDefined) ?? [], [
|
|
17
|
+
cart?.discounts
|
|
18
|
+
]);
|
|
19
|
+
const removeCode = react.useCallback((code)=>{
|
|
20
|
+
components.openConfirm({
|
|
21
|
+
title: /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
22
|
+
className: "flex w-full flex-col items-center gap-4",
|
|
23
|
+
children: [
|
|
24
|
+
/*#__PURE__*/ jsxRuntime.jsx(Trash.default, {}),
|
|
25
|
+
/*#__PURE__*/ jsxRuntime.jsx("p", {
|
|
26
|
+
className: "font-g-body text-xl font-semibold",
|
|
27
|
+
children: "Are you sure ?"
|
|
28
|
+
})
|
|
29
|
+
]
|
|
30
|
+
}),
|
|
31
|
+
content: /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
32
|
+
className: "text-center",
|
|
33
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("p", {
|
|
34
|
+
children: "Do you really want to delete this code?"
|
|
35
|
+
})
|
|
36
|
+
}),
|
|
37
|
+
className: 'w-full max-w-[572px] gap-4 rounded',
|
|
38
|
+
buttons: [
|
|
39
|
+
{
|
|
40
|
+
label: 'Cancel',
|
|
41
|
+
className: 'w-[130px]',
|
|
42
|
+
styles: {
|
|
43
|
+
backgroundColor: {
|
|
44
|
+
normal: 'bg-1'
|
|
45
|
+
},
|
|
46
|
+
roundedBtn: {
|
|
47
|
+
normal: {
|
|
48
|
+
radiusType: 'small'
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
btnSpacing: {
|
|
52
|
+
type: 'small'
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: 'Delete',
|
|
58
|
+
className: 'w-[130px]',
|
|
59
|
+
styles: {
|
|
60
|
+
textColor: {
|
|
61
|
+
normal: 'text-3'
|
|
62
|
+
},
|
|
63
|
+
backgroundColor: {
|
|
64
|
+
normal: 'error'
|
|
65
|
+
},
|
|
66
|
+
roundedBtn: {
|
|
67
|
+
normal: {
|
|
68
|
+
radiusType: 'small'
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
btnSpacing: {
|
|
72
|
+
type: 'small'
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
onClick: ()=>{
|
|
76
|
+
if (cartId) {
|
|
77
|
+
updateCartDiscountCode({
|
|
78
|
+
cartId,
|
|
79
|
+
discountCodes: currentCode.filter((v)=>v !== code)
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
});
|
|
86
|
+
}, [
|
|
87
|
+
cartId,
|
|
88
|
+
updateCartDiscountCode,
|
|
89
|
+
currentCode
|
|
90
|
+
]);
|
|
91
|
+
return /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
92
|
+
className: "flex h-8 items-center gap-2 rounded-sm border pl-2",
|
|
93
|
+
children: [
|
|
94
|
+
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
95
|
+
className: core.cls('flex-1', {
|
|
96
|
+
'text-g-error line-through': !item.applicable,
|
|
97
|
+
'text-g-success': item.applicable
|
|
98
|
+
}),
|
|
99
|
+
children: item.code
|
|
100
|
+
}),
|
|
101
|
+
/*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
102
|
+
disabled: isMutating,
|
|
103
|
+
onClick: ()=>removeCode(item.code),
|
|
104
|
+
className: "flex aspect-square h-full items-center justify-center",
|
|
105
|
+
children: isMutating ? /*#__PURE__*/ jsxRuntime.jsx(LoadingIcon.default, {
|
|
106
|
+
className: "text-g-brand"
|
|
107
|
+
}) : /*#__PURE__*/ jsxRuntime.jsx("svg", {
|
|
108
|
+
className: "w-4",
|
|
109
|
+
fill: "none",
|
|
110
|
+
viewBox: "0 0 24 24",
|
|
111
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
112
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
113
|
+
d: "m4.397 4.554.073-.084a.75.75 0 0 1 .976-.073l.084.073L12 10.939l6.47-6.47a.75.75 0 1 1 1.06 1.061L13.061 12l6.47 6.47a.75.75 0 0 1 .072.976l-.073.084a.75.75 0 0 1-.976.073l-.084-.073L12 13.061l-6.47 6.47a.75.75 0 0 1-1.06-1.061L10.939 12l-6.47-6.47a.75.75 0 0 1-.072-.976l.073-.084-.073.084Z",
|
|
114
|
+
fill: "currentColor"
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
]
|
|
119
|
+
}, item.code);
|
|
79
120
|
};
|
|
80
121
|
|
|
81
122
|
exports.default = DiscountCodeItem;
|