@shopify/cli 3.63.1 → 3.64.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.
- package/dist/assets/cli-ruby/lib/shopify_cli/reporting_configuration_controller.rb +2 -37
- package/dist/assets/cli-ruby/lib/shopify_cli/theme/file.rb +12 -30
- package/dist/assets/dev-console/extensions/dev-console/assets/index-Cgb-oKsM.css +1 -0
- package/dist/assets/dev-console/extensions/dev-console/assets/{index-Dui3DO9f.js → index-D7F9wNys.js} +12 -12
- package/dist/assets/dev-console/index.html +2 -2
- package/dist/assets/hydrogen/starter/CHANGELOG.md +98 -5
- package/dist/assets/hydrogen/starter/app/components/AddToCartButton.tsx +37 -0
- package/dist/assets/hydrogen/starter/app/components/CartLineItem.tsx +150 -0
- package/dist/assets/hydrogen/starter/app/components/CartMain.tsx +68 -0
- package/dist/assets/hydrogen/starter/app/components/CartSummary.tsx +101 -0
- package/dist/assets/hydrogen/starter/app/components/Header.tsx +3 -3
- package/dist/assets/hydrogen/starter/app/components/PageLayout.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/ProductForm.tsx +80 -0
- package/dist/assets/hydrogen/starter/app/components/ProductImage.tsx +23 -0
- package/dist/assets/hydrogen/starter/app/components/ProductPrice.tsx +27 -0
- package/dist/assets/hydrogen/starter/app/components/Search.tsx +1 -0
- package/dist/assets/hydrogen/starter/app/root.tsx +11 -17
- package/dist/assets/hydrogen/starter/app/routes/cart.tsx +2 -2
- package/dist/assets/hydrogen/starter/app/routes/products.$handle.tsx +51 -232
- package/dist/assets/hydrogen/starter/package.json +11 -11
- package/dist/assets/hydrogen/tailwind/package.json +1 -6
- package/dist/assets/hydrogen/tailwind/tailwind.css +6 -3
- package/dist/assets/hydrogen/vanilla-extract/package.json +2 -3
- package/dist/assets/hydrogen/virtual-routes/components/{Layout.jsx → PageLayout.jsx} +2 -2
- package/dist/assets/hydrogen/virtual-routes/virtual-root.jsx +8 -30
- package/dist/{chunk-TD4ZV7BS.js → chunk-2TZRSXDZ.js} +3 -3
- package/dist/{chunk-EARPFFS7.js → chunk-5A6QTLMF.js} +241 -4
- package/dist/{chunk-SRLLZENE.js → chunk-6LPAIJ4Y.js} +2 -2
- package/dist/{chunk-TYOQQCHN.js → chunk-6TPBPH6V.js} +905 -896
- package/dist/{chunk-UZ3EKGD4.js → chunk-7GYETEC3.js} +3 -3
- package/dist/{chunk-UNPXLODI.js → chunk-B7RN7IRD.js} +3 -4
- package/dist/{chunk-SML7F4EL.js → chunk-BKBHZTOE.js} +3 -3
- package/dist/{chunk-A2UVOX6O.js → chunk-C2AKAEMR.js} +7066 -6051
- package/dist/{chunk-HZUY7I72.js → chunk-CLBFKLWA.js} +4 -4
- package/dist/{chunk-6UDFXWNE.js → chunk-EJITPGUJ.js} +21 -4
- package/dist/{chunk-SCKZAIMH.js → chunk-G4TC4KHZ.js} +3 -3
- package/dist/{chunk-ZSWSHFDT.js → chunk-GEAZ65AU.js} +1429 -2847
- package/dist/{chunk-HCYSYR53.js → chunk-GUB3OCYR.js} +4 -4
- package/dist/{chunk-QCB66M7L.js → chunk-H66NIXGL.js} +9 -14
- package/dist/chunk-I6HNYSMO.js +29 -0
- package/dist/{chunk-GICOHCP4.js → chunk-JSLLI5MY.js} +3 -3
- package/dist/{chunk-N5XLVLT2.js → chunk-KDK32T2A.js} +5 -5
- package/dist/{chunk-CBNQDBKA.js → chunk-L5WUZYLP.js} +5 -5
- package/dist/{chunk-OVW3UN2A.js → chunk-LHP5F5LY.js} +4 -4
- package/dist/{chunk-TOO3W2BY.js → chunk-LP2H26NY.js} +3 -3
- package/dist/{chunk-NIEJLNRY.js → chunk-LQX3GDBO.js} +2 -2
- package/dist/{chunk-WJ6UGHRU.js → chunk-LVLKZYIC.js} +3 -3
- package/dist/{chunk-WADS2TV5.js → chunk-NO7MYZEO.js} +5 -4
- package/dist/{chunk-LH533WG4.js → chunk-NPH2SXRO.js} +2 -2
- package/dist/{chunk-IJ3PP7ZN.js → chunk-PIJQNKK6.js} +5 -5
- package/dist/{chunk-S4VBXFXP.js → chunk-PWYMBX34.js} +220 -16
- package/dist/{chunk-DIRL62CL.js → chunk-QCK4QLB3.js} +17912 -17444
- package/dist/{chunk-5D3LUZSS.js → chunk-QI5O2CU6.js} +5 -5
- package/dist/{chunk-BZUV56IY.js → chunk-RX7VCI62.js} +4 -4
- package/dist/{chunk-HULX6T4O.js → chunk-T7DHXEC7.js} +3 -3
- package/dist/{chunk-VB3O7QTH.js → chunk-TCQUNDAY.js} +3 -3
- package/dist/{chunk-CM4H6QMH.js → chunk-TSZPIP7J.js} +3 -3
- package/dist/{chunk-OHZL7KKD.js → chunk-UTXBNNRZ.js} +4 -4
- package/dist/{chunk-QAB3YP77.js → chunk-VPPZXHAK.js} +2 -2
- package/dist/{chunk-ARLG6JTK.js → chunk-W26344X5.js} +3 -3
- package/dist/{chunk-EQPYUHNM.js → chunk-WIG6CPGR.js} +1497 -112
- package/dist/{chunk-MMRWTLF3.js → chunk-X34BQYQP.js} +2 -2
- package/dist/chunk-YLPSXWEZ.js +12 -0
- package/dist/cli/commands/auth/logout.js +14 -19
- package/dist/cli/commands/auth/logout.test.js +17 -21
- package/dist/cli/commands/debug/command-flags.js +11 -15
- package/dist/cli/commands/demo/catalog.js +13 -18
- package/dist/cli/commands/demo/generate-file.js +13 -18
- package/dist/cli/commands/demo/index.js +13 -18
- package/dist/cli/commands/demo/print-ai-prompt.js +13 -18
- package/dist/cli/commands/docs/generate.js +11 -15
- package/dist/cli/commands/docs/generate.test.js +11 -15
- package/dist/cli/commands/help.js +11 -15
- package/dist/cli/commands/kitchen-sink/async.js +12 -16
- package/dist/cli/commands/kitchen-sink/async.test.js +12 -16
- package/dist/cli/commands/kitchen-sink/index.js +14 -18
- package/dist/cli/commands/kitchen-sink/index.test.js +14 -18
- package/dist/cli/commands/kitchen-sink/prompts.js +12 -16
- package/dist/cli/commands/kitchen-sink/prompts.test.js +12 -16
- package/dist/cli/commands/kitchen-sink/static.js +12 -16
- package/dist/cli/commands/kitchen-sink/static.test.js +12 -16
- package/dist/cli/commands/search.js +12 -16
- package/dist/cli/commands/upgrade.js +11 -15
- package/dist/cli/commands/version.js +12 -16
- package/dist/cli/commands/version.test.js +12 -16
- package/dist/cli/services/commands/search.js +4 -4
- package/dist/cli/services/commands/search.test.js +4 -4
- package/dist/cli/services/commands/version.js +6 -7
- package/dist/cli/services/commands/version.test.js +7 -8
- package/dist/cli/services/demo.js +5 -6
- package/dist/cli/services/demo.test.js +5 -6
- package/dist/cli/services/kitchen-sink/async.js +4 -4
- package/dist/cli/services/kitchen-sink/prompts.js +4 -4
- package/dist/cli/services/kitchen-sink/static.js +4 -4
- package/dist/cli/services/upgrade.js +5 -6
- package/dist/cli/services/upgrade.test.js +7 -8
- package/dist/{constants-3CLHB4LQ.js → constants-EVER32LA.js} +3 -3
- package/dist/{custom-oclif-loader-T44V63XJ.js → custom-oclif-loader-F5UKFNJS.js} +13 -6
- package/dist/{error-handler-5KEL3EJC.js → error-handler-GCSQB44R.js} +10 -8
- package/dist/hooks/postrun.js +12 -14
- package/dist/hooks/prerun.js +8 -11
- package/dist/index.js +7708 -7452
- package/dist/{local-LBAOYPL4.js → local-VDSO2Y52.js} +4 -4
- package/dist/{morph-6NYGHGNT.js → morph-DQWX4LPS.js} +9 -9
- package/dist/{node-3X5EZ2GL.js → node-3B62KLPY.js} +21 -19
- package/dist/{node-package-manager-BU3KHLYT.js → node-package-manager-QLAS6UPG.js} +5 -6
- package/dist/{path-JVVXOELJ.js → path-KUSF6CYC.js} +2 -2
- package/dist/{system-GPQDWNIQ.js → system-CPU6ZDBW.js} +4 -4
- package/dist/templates/ui-extensions/projects/web_pixel_extension/package.json.liquid +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{ui-4ZQNF2YQ.js → ui-Y4GW3DUK.js} +4 -4
- package/dist/{workerd-66AMV47V.js → workerd-LSXMDY5M.js} +22 -19
- package/oclif.manifest.json +265 -4
- package/package.json +7 -10
- package/dist/assets/dev-console/extensions/dev-console/assets/index-Bi7y6lI5.css +0 -1
- package/dist/assets/hydrogen/css-modules/package.json +0 -6
- package/dist/assets/hydrogen/postcss/package.json +0 -10
- package/dist/assets/hydrogen/postcss/postcss.config.js +0 -8
- package/dist/assets/hydrogen/starter/app/components/Cart.tsx +0 -364
- package/dist/assets/hydrogen/tailwind/postcss.config.js +0 -10
- package/dist/assets/hydrogen/tailwind/tailwind.config.js +0 -8
- package/dist/chunk-6EIVOQYP.js +0 -1070
- package/dist/chunk-GITQBCE5.js +0 -4385
- package/dist/chunk-HNAZOLMG.js +0 -1453
- package/dist/chunk-MO3UHUJB.js +0 -221
- package/dist/chunk-NBSFQYKI.js +0 -496
- package/dist/chunk-NVFSN34M.js +0 -265
- package/dist/chunk-QOUOFEGO.js +0 -35
- package/dist/chunk-WLZZJLBE.js +0 -12
- package/dist/error-handler-QVRMTAG7.js +0 -43
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CartForm,
|
|
3
|
-
Image,
|
|
4
|
-
Money,
|
|
5
|
-
useOptimisticCart,
|
|
6
|
-
type OptimisticCart,
|
|
7
|
-
} from '@shopify/hydrogen';
|
|
8
|
-
import type {CartLineUpdateInput} from '@shopify/hydrogen/storefront-api-types';
|
|
9
|
-
import {Link} from '@remix-run/react';
|
|
10
|
-
import type {CartApiQueryFragment} from 'storefrontapi.generated';
|
|
11
|
-
import {useVariantUrl} from '~/lib/variants';
|
|
12
|
-
|
|
13
|
-
type CartLine = OptimisticCart<CartApiQueryFragment>['lines']['nodes'][0];
|
|
14
|
-
|
|
15
|
-
type CartMainProps = {
|
|
16
|
-
cart: CartApiQueryFragment | null;
|
|
17
|
-
layout: 'page' | 'aside';
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export function CartMain({layout, cart: originalCart}: CartMainProps) {
|
|
21
|
-
const cart = useOptimisticCart(originalCart);
|
|
22
|
-
|
|
23
|
-
const linesCount = Boolean(cart?.lines?.nodes?.length || 0);
|
|
24
|
-
const withDiscount =
|
|
25
|
-
cart &&
|
|
26
|
-
Boolean(cart?.discountCodes?.filter((code) => code.applicable)?.length);
|
|
27
|
-
const className = `cart-main ${withDiscount ? 'with-discount' : ''}`;
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<div className={className}>
|
|
31
|
-
<CartEmpty hidden={linesCount} layout={layout} />
|
|
32
|
-
<CartDetails cart={cart} layout={layout} />
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function CartDetails({
|
|
38
|
-
layout,
|
|
39
|
-
cart,
|
|
40
|
-
}: {
|
|
41
|
-
cart: OptimisticCart<CartApiQueryFragment>;
|
|
42
|
-
layout: 'page' | 'aside';
|
|
43
|
-
}) {
|
|
44
|
-
const cartHasItems = !!cart && cart.totalQuantity > 0;
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<div className="cart-details">
|
|
48
|
-
<CartLines lines={cart?.lines?.nodes} layout={layout} />
|
|
49
|
-
{cartHasItems && (
|
|
50
|
-
<CartSummary cost={cart.cost} layout={layout}>
|
|
51
|
-
<CartDiscounts discountCodes={cart.discountCodes} />
|
|
52
|
-
<CartCheckoutActions checkoutUrl={cart.checkoutUrl} />
|
|
53
|
-
</CartSummary>
|
|
54
|
-
)}
|
|
55
|
-
</div>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function CartLines({
|
|
60
|
-
lines,
|
|
61
|
-
layout,
|
|
62
|
-
}: {
|
|
63
|
-
layout: CartMainProps['layout'];
|
|
64
|
-
lines: CartLine[];
|
|
65
|
-
}) {
|
|
66
|
-
if (!lines) return null;
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<div aria-labelledby="cart-lines">
|
|
70
|
-
<ul>
|
|
71
|
-
{lines.map((line) => (
|
|
72
|
-
<CartLineItem key={line.id} line={line} layout={layout} />
|
|
73
|
-
))}
|
|
74
|
-
</ul>
|
|
75
|
-
</div>
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function CartLineItem({
|
|
80
|
-
layout,
|
|
81
|
-
line,
|
|
82
|
-
}: {
|
|
83
|
-
layout: CartMainProps['layout'];
|
|
84
|
-
line: CartLine;
|
|
85
|
-
}) {
|
|
86
|
-
const {id, merchandise} = line;
|
|
87
|
-
const {product, title, image, selectedOptions} = merchandise;
|
|
88
|
-
const lineItemUrl = useVariantUrl(product.handle, selectedOptions);
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<li key={id} className="cart-line">
|
|
92
|
-
{image && (
|
|
93
|
-
<Image
|
|
94
|
-
alt={title}
|
|
95
|
-
aspectRatio="1/1"
|
|
96
|
-
data={image}
|
|
97
|
-
height={100}
|
|
98
|
-
loading="lazy"
|
|
99
|
-
width={100}
|
|
100
|
-
/>
|
|
101
|
-
)}
|
|
102
|
-
|
|
103
|
-
<div>
|
|
104
|
-
<Link
|
|
105
|
-
prefetch="intent"
|
|
106
|
-
to={lineItemUrl}
|
|
107
|
-
onClick={() => {
|
|
108
|
-
if (layout === 'aside') {
|
|
109
|
-
// close the drawer
|
|
110
|
-
window.location.href = lineItemUrl;
|
|
111
|
-
}
|
|
112
|
-
}}
|
|
113
|
-
>
|
|
114
|
-
<p>
|
|
115
|
-
<strong>{product.title}</strong>
|
|
116
|
-
</p>
|
|
117
|
-
</Link>
|
|
118
|
-
<CartLinePrice line={line} as="span" />
|
|
119
|
-
<ul>
|
|
120
|
-
{selectedOptions.map((option) => (
|
|
121
|
-
<li key={option.name}>
|
|
122
|
-
<small>
|
|
123
|
-
{option.name}: {option.value}
|
|
124
|
-
</small>
|
|
125
|
-
</li>
|
|
126
|
-
))}
|
|
127
|
-
</ul>
|
|
128
|
-
<CartLineQuantity line={line} />
|
|
129
|
-
</div>
|
|
130
|
-
</li>
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function CartCheckoutActions({checkoutUrl}: {checkoutUrl: string}) {
|
|
135
|
-
if (!checkoutUrl) return null;
|
|
136
|
-
|
|
137
|
-
return (
|
|
138
|
-
<div>
|
|
139
|
-
<a href={checkoutUrl} target="_self">
|
|
140
|
-
<p>Continue to Checkout →</p>
|
|
141
|
-
</a>
|
|
142
|
-
<br />
|
|
143
|
-
</div>
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export function CartSummary({
|
|
148
|
-
cost,
|
|
149
|
-
layout,
|
|
150
|
-
children = null,
|
|
151
|
-
}: {
|
|
152
|
-
children?: React.ReactNode;
|
|
153
|
-
cost: CartApiQueryFragment['cost'];
|
|
154
|
-
layout: CartMainProps['layout'];
|
|
155
|
-
}) {
|
|
156
|
-
const className =
|
|
157
|
-
layout === 'page' ? 'cart-summary-page' : 'cart-summary-aside';
|
|
158
|
-
|
|
159
|
-
return (
|
|
160
|
-
<div aria-labelledby="cart-summary" className={className}>
|
|
161
|
-
<h4>Totals</h4>
|
|
162
|
-
<dl className="cart-subtotal">
|
|
163
|
-
<dt>Subtotal</dt>
|
|
164
|
-
<dd>
|
|
165
|
-
{cost?.subtotalAmount?.amount ? (
|
|
166
|
-
<Money data={cost?.subtotalAmount} />
|
|
167
|
-
) : (
|
|
168
|
-
'-'
|
|
169
|
-
)}
|
|
170
|
-
</dd>
|
|
171
|
-
</dl>
|
|
172
|
-
{children}
|
|
173
|
-
</div>
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function CartLineRemoveButton({
|
|
178
|
-
lineIds,
|
|
179
|
-
disabled,
|
|
180
|
-
}: {
|
|
181
|
-
lineIds: string[];
|
|
182
|
-
disabled: boolean;
|
|
183
|
-
}) {
|
|
184
|
-
return (
|
|
185
|
-
<CartForm
|
|
186
|
-
route="/cart"
|
|
187
|
-
action={CartForm.ACTIONS.LinesRemove}
|
|
188
|
-
inputs={{lineIds}}
|
|
189
|
-
>
|
|
190
|
-
<button disabled={disabled} type="submit">
|
|
191
|
-
Remove
|
|
192
|
-
</button>
|
|
193
|
-
</CartForm>
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function CartLineQuantity({line}: {line: CartLine}) {
|
|
198
|
-
if (!line || typeof line?.quantity === 'undefined') return null;
|
|
199
|
-
const {id: lineId, quantity, isOptimistic} = line;
|
|
200
|
-
const prevQuantity = Number(Math.max(0, quantity - 1).toFixed(0));
|
|
201
|
-
const nextQuantity = Number((quantity + 1).toFixed(0));
|
|
202
|
-
|
|
203
|
-
return (
|
|
204
|
-
<div className="cart-line-quantity">
|
|
205
|
-
<small>Quantity: {quantity} </small>
|
|
206
|
-
<CartLineUpdateButton lines={[{id: lineId, quantity: prevQuantity}]}>
|
|
207
|
-
<button
|
|
208
|
-
aria-label="Decrease quantity"
|
|
209
|
-
disabled={quantity <= 1 || !!isOptimistic}
|
|
210
|
-
name="decrease-quantity"
|
|
211
|
-
value={prevQuantity}
|
|
212
|
-
>
|
|
213
|
-
<span>− </span>
|
|
214
|
-
</button>
|
|
215
|
-
</CartLineUpdateButton>
|
|
216
|
-
|
|
217
|
-
<CartLineUpdateButton lines={[{id: lineId, quantity: nextQuantity}]}>
|
|
218
|
-
<button
|
|
219
|
-
aria-label="Increase quantity"
|
|
220
|
-
name="increase-quantity"
|
|
221
|
-
value={nextQuantity}
|
|
222
|
-
disabled={!!isOptimistic}
|
|
223
|
-
>
|
|
224
|
-
<span>+</span>
|
|
225
|
-
</button>
|
|
226
|
-
</CartLineUpdateButton>
|
|
227
|
-
|
|
228
|
-
<CartLineRemoveButton lineIds={[lineId]} disabled={!!isOptimistic} />
|
|
229
|
-
</div>
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function CartLinePrice({
|
|
234
|
-
line,
|
|
235
|
-
priceType = 'regular',
|
|
236
|
-
...passthroughProps
|
|
237
|
-
}: {
|
|
238
|
-
line: CartLine;
|
|
239
|
-
priceType?: 'regular' | 'compareAt';
|
|
240
|
-
[key: string]: any;
|
|
241
|
-
}) {
|
|
242
|
-
if (!line?.cost?.amountPerQuantity || !line?.cost?.totalAmount)
|
|
243
|
-
return <div style={{visibility: 'hidden'}}> </div>;
|
|
244
|
-
|
|
245
|
-
const moneyV2 =
|
|
246
|
-
priceType === 'regular'
|
|
247
|
-
? line.cost.totalAmount
|
|
248
|
-
: line.cost.compareAtAmountPerQuantity;
|
|
249
|
-
|
|
250
|
-
if (moneyV2 == null) {
|
|
251
|
-
return <div style={{visibility: 'hidden'}}> </div>;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return (
|
|
255
|
-
<div>
|
|
256
|
-
<Money withoutTrailingZeros {...passthroughProps} data={moneyV2} />
|
|
257
|
-
</div>
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export function CartEmpty({
|
|
262
|
-
hidden = false,
|
|
263
|
-
layout = 'aside',
|
|
264
|
-
}: {
|
|
265
|
-
hidden: boolean;
|
|
266
|
-
layout?: CartMainProps['layout'];
|
|
267
|
-
}) {
|
|
268
|
-
return (
|
|
269
|
-
<div hidden={hidden}>
|
|
270
|
-
<br />
|
|
271
|
-
<p>
|
|
272
|
-
Looks like you haven’t added anything yet, let’s get you
|
|
273
|
-
started!
|
|
274
|
-
</p>
|
|
275
|
-
<br />
|
|
276
|
-
<Link
|
|
277
|
-
to="/collections"
|
|
278
|
-
onClick={() => {
|
|
279
|
-
if (layout === 'aside') {
|
|
280
|
-
window.location.href = '/collections';
|
|
281
|
-
}
|
|
282
|
-
}}
|
|
283
|
-
>
|
|
284
|
-
Continue shopping →
|
|
285
|
-
</Link>
|
|
286
|
-
</div>
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function CartDiscounts({
|
|
291
|
-
discountCodes,
|
|
292
|
-
}: {
|
|
293
|
-
discountCodes: CartApiQueryFragment['discountCodes'];
|
|
294
|
-
}) {
|
|
295
|
-
const codes: string[] =
|
|
296
|
-
discountCodes
|
|
297
|
-
?.filter((discount) => discount.applicable)
|
|
298
|
-
?.map(({code}) => code) || [];
|
|
299
|
-
|
|
300
|
-
return (
|
|
301
|
-
<div>
|
|
302
|
-
{/* Have existing discount, display it with a remove option */}
|
|
303
|
-
<dl hidden={!codes.length}>
|
|
304
|
-
<div>
|
|
305
|
-
<dt>Discount(s)</dt>
|
|
306
|
-
<UpdateDiscountForm>
|
|
307
|
-
<div className="cart-discount">
|
|
308
|
-
<code>{codes?.join(', ')}</code>
|
|
309
|
-
|
|
310
|
-
<button>Remove</button>
|
|
311
|
-
</div>
|
|
312
|
-
</UpdateDiscountForm>
|
|
313
|
-
</div>
|
|
314
|
-
</dl>
|
|
315
|
-
|
|
316
|
-
{/* Show an input to apply a discount */}
|
|
317
|
-
<UpdateDiscountForm discountCodes={codes}>
|
|
318
|
-
<div>
|
|
319
|
-
<input type="text" name="discountCode" placeholder="Discount code" />
|
|
320
|
-
|
|
321
|
-
<button type="submit">Apply</button>
|
|
322
|
-
</div>
|
|
323
|
-
</UpdateDiscountForm>
|
|
324
|
-
</div>
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
function UpdateDiscountForm({
|
|
329
|
-
discountCodes,
|
|
330
|
-
children,
|
|
331
|
-
}: {
|
|
332
|
-
discountCodes?: string[];
|
|
333
|
-
children: React.ReactNode;
|
|
334
|
-
}) {
|
|
335
|
-
return (
|
|
336
|
-
<CartForm
|
|
337
|
-
route="/cart"
|
|
338
|
-
action={CartForm.ACTIONS.DiscountCodesUpdate}
|
|
339
|
-
inputs={{
|
|
340
|
-
discountCodes: discountCodes || [],
|
|
341
|
-
}}
|
|
342
|
-
>
|
|
343
|
-
{children}
|
|
344
|
-
</CartForm>
|
|
345
|
-
);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
function CartLineUpdateButton({
|
|
349
|
-
children,
|
|
350
|
-
lines,
|
|
351
|
-
}: {
|
|
352
|
-
children: React.ReactNode;
|
|
353
|
-
lines: CartLineUpdateInput[];
|
|
354
|
-
}) {
|
|
355
|
-
return (
|
|
356
|
-
<CartForm
|
|
357
|
-
route="/cart"
|
|
358
|
-
action={CartForm.ACTIONS.LinesUpdate}
|
|
359
|
-
inputs={{lines}}
|
|
360
|
-
>
|
|
361
|
-
{children}
|
|
362
|
-
</CartForm>
|
|
363
|
-
);
|
|
364
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import formsPlugin from '@tailwindcss/forms';
|
|
2
|
-
import typographyPlugin from '@tailwindcss/typography';
|
|
3
|
-
|
|
4
|
-
/** @type {import('tailwindcss').Config} */
|
|
5
|
-
export default {
|
|
6
|
-
content: ['./{src-dir}/**/*.{js,ts,jsx,tsx}'],
|
|
7
|
-
plugins: [formsPlugin, typographyPlugin],
|
|
8
|
-
};
|