@shopify/cli-hydrogen 6.0.2 → 7.0.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 (108) hide show
  1. package/dist/commands/hydrogen/build.js +40 -78
  2. package/dist/commands/hydrogen/codegen.js +8 -3
  3. package/dist/commands/hydrogen/deploy.js +173 -37
  4. package/dist/commands/hydrogen/deploy.test.js +192 -20
  5. package/dist/commands/hydrogen/dev.js +56 -31
  6. package/dist/commands/hydrogen/init.js +1 -1
  7. package/dist/commands/hydrogen/init.test.js +155 -53
  8. package/dist/commands/hydrogen/link.js +5 -21
  9. package/dist/commands/hydrogen/link.test.js +10 -10
  10. package/dist/commands/hydrogen/preview.js +22 -11
  11. package/dist/commands/hydrogen/setup.js +0 -4
  12. package/dist/commands/hydrogen/setup.test.js +0 -1
  13. package/dist/commands/hydrogen/shortcut.js +1 -0
  14. package/dist/commands/hydrogen/upgrade.js +720 -0
  15. package/dist/commands/hydrogen/upgrade.test.js +786 -0
  16. package/dist/generator-templates/starter/.graphqlrc.yml +12 -1
  17. package/dist/generator-templates/starter/CHANGELOG.md +126 -0
  18. package/dist/generator-templates/starter/README.md +23 -0
  19. package/dist/generator-templates/starter/app/components/Cart.tsx +1 -1
  20. package/dist/generator-templates/starter/app/components/Footer.tsx +3 -1
  21. package/dist/generator-templates/starter/app/components/Header.tsx +5 -1
  22. package/dist/generator-templates/starter/app/components/Layout.tsx +14 -11
  23. package/dist/generator-templates/starter/app/components/Search.tsx +1 -1
  24. package/dist/generator-templates/starter/app/graphql/customer-account/CustomerAddressMutations.ts +61 -0
  25. package/dist/generator-templates/starter/app/graphql/customer-account/CustomerDetailsQuery.ts +39 -0
  26. package/dist/generator-templates/starter/app/graphql/customer-account/CustomerOrderQuery.ts +87 -0
  27. package/dist/generator-templates/starter/app/graphql/customer-account/CustomerOrdersQuery.ts +58 -0
  28. package/dist/generator-templates/starter/app/graphql/customer-account/CustomerUpdateMutation.ts +24 -0
  29. package/dist/generator-templates/starter/app/lib/fragments.ts +102 -0
  30. package/dist/generator-templates/starter/app/lib/session.ts +67 -0
  31. package/dist/generator-templates/starter/app/root.tsx +11 -45
  32. package/dist/generator-templates/starter/app/routes/[robots.txt].tsx +0 -27
  33. package/dist/generator-templates/starter/app/routes/account.$.tsx +8 -4
  34. package/dist/generator-templates/starter/app/routes/account._index.tsx +5 -0
  35. package/dist/generator-templates/starter/app/routes/account.addresses.tsx +215 -206
  36. package/dist/generator-templates/starter/app/routes/account.orders.$id.tsx +56 -163
  37. package/dist/generator-templates/starter/app/routes/account.orders._index.tsx +32 -109
  38. package/dist/generator-templates/starter/app/routes/account.profile.tsx +40 -180
  39. package/dist/generator-templates/starter/app/routes/account.tsx +20 -135
  40. package/dist/generator-templates/starter/app/routes/account_.authorize.tsx +5 -0
  41. package/dist/generator-templates/starter/app/routes/account_.login.tsx +3 -140
  42. package/dist/generator-templates/starter/app/routes/account_.logout.tsx +5 -24
  43. package/dist/generator-templates/starter/app/routes/cart.tsx +7 -5
  44. package/dist/generator-templates/starter/app/routes/collections.$handle.tsx +1 -1
  45. package/dist/generator-templates/starter/app/routes/products.$handle.tsx +2 -2
  46. package/dist/generator-templates/starter/app/routes/search.tsx +1 -1
  47. package/dist/generator-templates/starter/customer-accountapi.generated.d.ts +506 -0
  48. package/dist/generator-templates/starter/package.json +11 -10
  49. package/dist/generator-templates/starter/remix.config.js +4 -0
  50. package/dist/generator-templates/starter/remix.env.d.ts +6 -11
  51. package/dist/generator-templates/starter/server.ts +24 -167
  52. package/dist/generator-templates/starter/storefrontapi.generated.d.ts +104 -881
  53. package/dist/hooks/init.js +4 -4
  54. package/dist/lib/auth.js +5 -10
  55. package/dist/lib/build.js +6 -1
  56. package/dist/lib/bundle/analyzer.js +36 -26
  57. package/dist/lib/check-lockfile.js +1 -0
  58. package/dist/lib/codegen.js +59 -18
  59. package/dist/lib/defer.js +12 -0
  60. package/dist/lib/file.js +52 -3
  61. package/dist/lib/flags.js +27 -9
  62. package/dist/lib/get-oxygen-deployment-data.test.js +4 -2
  63. package/dist/lib/graphql/admin/client.test.js +2 -2
  64. package/dist/lib/graphql/admin/get-oxygen-data.js +1 -0
  65. package/dist/lib/log.js +32 -14
  66. package/dist/lib/mini-oxygen/assets.js +118 -0
  67. package/dist/lib/mini-oxygen/common.js +2 -1
  68. package/dist/lib/mini-oxygen/index.js +7 -5
  69. package/dist/lib/mini-oxygen/mini-oxygen.test.js +214 -0
  70. package/dist/lib/mini-oxygen/node.js +19 -5
  71. package/dist/lib/mini-oxygen/workerd-inspector-logs.js +227 -0
  72. package/dist/lib/mini-oxygen/workerd-inspector-proxy.js +200 -0
  73. package/dist/lib/mini-oxygen/workerd-inspector.js +62 -235
  74. package/dist/lib/mini-oxygen/workerd.js +74 -50
  75. package/dist/lib/missing-routes.js +6 -3
  76. package/dist/lib/onboarding/common.js +40 -9
  77. package/dist/lib/onboarding/local.js +19 -11
  78. package/dist/lib/onboarding/remote.js +48 -28
  79. package/dist/lib/render-errors.js +2 -0
  80. package/dist/lib/request-events.js +65 -31
  81. package/dist/lib/setups/css/assets.js +1 -46
  82. package/dist/lib/setups/css/css-modules.js +3 -2
  83. package/dist/lib/setups/css/postcss.js +4 -2
  84. package/dist/lib/setups/css/tailwind.js +4 -2
  85. package/dist/lib/setups/css/vanilla-extract.js +3 -2
  86. package/dist/lib/setups/i18n/replacers.test.js +56 -38
  87. package/dist/lib/shell.js +1 -1
  88. package/dist/lib/template-diff.js +89 -0
  89. package/dist/lib/template-downloader.js +3 -2
  90. package/dist/lib/transpile/project.js +1 -1
  91. package/dist/virtual-routes/assets/debug-network.css +592 -0
  92. package/dist/virtual-routes/assets/favicon-dark.svg +20 -0
  93. package/dist/virtual-routes/components/FlameChartWrapper.jsx +8 -10
  94. package/dist/virtual-routes/components/IconClose.jsx +38 -0
  95. package/dist/virtual-routes/components/IconDiscard.jsx +44 -0
  96. package/dist/virtual-routes/components/RequestDetails.jsx +179 -0
  97. package/dist/virtual-routes/components/RequestTable.jsx +92 -0
  98. package/dist/virtual-routes/components/RequestWaterfall.jsx +151 -0
  99. package/dist/virtual-routes/lib/useDebugNetworkServer.jsx +176 -0
  100. package/dist/virtual-routes/routes/subrequest-profiler.jsx +243 -0
  101. package/oclif.manifest.json +134 -59
  102. package/package.json +18 -26
  103. package/dist/generator-templates/starter/app/routes/account_.activate.$id.$activationToken.tsx +0 -161
  104. package/dist/generator-templates/starter/app/routes/account_.recover.tsx +0 -129
  105. package/dist/generator-templates/starter/app/routes/account_.register.tsx +0 -207
  106. package/dist/generator-templates/starter/app/routes/account_.reset.$id.$resetToken.tsx +0 -136
  107. package/dist/virtual-routes/routes/debug-network.jsx +0 -289
  108. /package/dist/generator-templates/starter/app/{utils.ts → lib/variants.ts} +0 -0
@@ -1,5 +1,8 @@
1
- import type {MailingAddressInput} from '@shopify/hydrogen/storefront-api-types';
2
- import type {AddressFragment, CustomerFragment} from 'storefrontapi.generated';
1
+ import type {CustomerAddressInput} from '@shopify/hydrogen/customer-account-api-types';
2
+ import type {
3
+ AddressFragment,
4
+ CustomerFragment,
5
+ } from 'customer-accountapi.generated';
3
6
  import {
4
7
  json,
5
8
  redirect,
@@ -13,6 +16,11 @@ import {
13
16
  useOutletContext,
14
17
  type MetaFunction,
15
18
  } from '@remix-run/react';
19
+ import {
20
+ UPDATE_ADDRESS_MUTATION,
21
+ DELETE_ADDRESS_MUTATION,
22
+ CREATE_ADDRESS_MUTATION,
23
+ } from '~/graphql/customer-account/CustomerAddressMutations';
16
24
 
17
25
  export type ActionResponse = {
18
26
  addressId?: string | null;
@@ -28,16 +36,20 @@ export const meta: MetaFunction = () => {
28
36
  };
29
37
 
30
38
  export async function loader({context}: LoaderFunctionArgs) {
31
- const {session} = context;
32
- const customerAccessToken = await session.get('customerAccessToken');
33
- if (!customerAccessToken) {
34
- return redirect('/account/login');
35
- }
36
- return json({});
39
+ await context.customerAccount.handleAuthStatus();
40
+
41
+ return json(
42
+ {},
43
+ {
44
+ headers: {
45
+ 'Set-Cookie': await context.session.commit(),
46
+ },
47
+ },
48
+ );
37
49
  }
38
50
 
39
51
  export async function action({request, context}: ActionFunctionArgs) {
40
- const {storefront, session} = context;
52
+ const {customerAccount} = context;
41
53
 
42
54
  try {
43
55
  const form = await request.formData();
@@ -49,26 +61,34 @@ export async function action({request, context}: ActionFunctionArgs) {
49
61
  throw new Error('You must provide an address id.');
50
62
  }
51
63
 
52
- const customerAccessToken = await session.get('customerAccessToken');
53
- if (!customerAccessToken) {
54
- return json({error: {[addressId]: 'Unauthorized'}}, {status: 401});
64
+ // this will ensure redirecting to login never happen for mutatation
65
+ const isLoggedIn = await customerAccount.isLoggedIn();
66
+ if (!isLoggedIn) {
67
+ return json(
68
+ {error: {[addressId]: 'Unauthorized'}},
69
+ {
70
+ status: 401,
71
+ headers: {
72
+ 'Set-Cookie': await context.session.commit(),
73
+ },
74
+ },
75
+ );
55
76
  }
56
- const {accessToken} = customerAccessToken;
57
77
 
58
78
  const defaultAddress = form.has('defaultAddress')
59
79
  ? String(form.get('defaultAddress')) === 'on'
60
- : null;
61
- const address: MailingAddressInput = {};
62
- const keys: (keyof MailingAddressInput)[] = [
80
+ : false;
81
+ const address: CustomerAddressInput = {};
82
+ const keys: (keyof CustomerAddressInput)[] = [
63
83
  'address1',
64
84
  'address2',
65
85
  'city',
66
86
  'company',
67
- 'country',
87
+ 'territoryCode',
68
88
  'firstName',
69
89
  'lastName',
70
- 'phone',
71
- 'province',
90
+ 'phoneNumber',
91
+ 'zoneCode',
72
92
  'zip',
73
93
  ];
74
94
 
@@ -83,134 +103,210 @@ export async function action({request, context}: ActionFunctionArgs) {
83
103
  case 'POST': {
84
104
  // handle new address creation
85
105
  try {
86
- const {customerAddressCreate} = await storefront.mutate(
106
+ const {data, errors} = await customerAccount.mutate(
87
107
  CREATE_ADDRESS_MUTATION,
88
108
  {
89
- variables: {customerAccessToken: accessToken, address},
109
+ variables: {address, defaultAddress},
90
110
  },
91
111
  );
92
112
 
93
- if (customerAddressCreate?.customerUserErrors?.length) {
94
- const error = customerAddressCreate.customerUserErrors[0];
95
- throw new Error(error.message);
113
+ if (errors?.length) {
114
+ throw new Error(errors[0].message);
96
115
  }
97
116
 
98
- const createdAddress = customerAddressCreate?.customerAddress;
99
- if (!createdAddress?.id) {
100
- throw new Error(
101
- 'Expected customer address to be created, but the id is missing',
102
- );
117
+ if (data?.customerAddressCreate?.userErrors?.length) {
118
+ throw new Error(data?.customerAddressCreate?.userErrors[0].message);
103
119
  }
104
120
 
105
- if (defaultAddress) {
106
- const createdAddressId = decodeURIComponent(createdAddress.id);
107
- const {customerDefaultAddressUpdate} = await storefront.mutate(
108
- UPDATE_DEFAULT_ADDRESS_MUTATION,
109
- {
110
- variables: {
111
- customerAccessToken: accessToken,
112
- addressId: createdAddressId,
113
- },
114
- },
115
- );
116
-
117
- if (customerDefaultAddressUpdate?.customerUserErrors?.length) {
118
- const error = customerDefaultAddressUpdate.customerUserErrors[0];
119
- throw new Error(error.message);
120
- }
121
+ if (!data?.customerAddressCreate?.customerAddress) {
122
+ throw new Error('Customer address create failed.');
121
123
  }
122
124
 
123
- return json({error: null, createdAddress, defaultAddress});
125
+ return json(
126
+ {
127
+ error: null,
128
+ createdAddress: data?.customerAddressCreate?.customerAddress,
129
+ defaultAddress,
130
+ },
131
+ {
132
+ headers: {
133
+ 'Set-Cookie': await context.session.commit(),
134
+ },
135
+ },
136
+ );
124
137
  } catch (error: unknown) {
125
138
  if (error instanceof Error) {
126
- return json({error: {[addressId]: error.message}}, {status: 400});
139
+ return json(
140
+ {error: {[addressId]: error.message}},
141
+ {
142
+ status: 400,
143
+ headers: {
144
+ 'Set-Cookie': await context.session.commit(),
145
+ },
146
+ },
147
+ );
127
148
  }
128
- return json({error: {[addressId]: error}}, {status: 400});
149
+ return json(
150
+ {error: {[addressId]: error}},
151
+ {
152
+ status: 400,
153
+ headers: {
154
+ 'Set-Cookie': await context.session.commit(),
155
+ },
156
+ },
157
+ );
129
158
  }
130
159
  }
131
160
 
132
161
  case 'PUT': {
133
162
  // handle address updates
134
163
  try {
135
- const {customerAddressUpdate} = await storefront.mutate(
164
+ const {data, errors} = await customerAccount.mutate(
136
165
  UPDATE_ADDRESS_MUTATION,
137
166
  {
138
167
  variables: {
139
168
  address,
140
- customerAccessToken: accessToken,
141
- id: decodeURIComponent(addressId),
169
+ addressId: decodeURIComponent(addressId),
170
+ defaultAddress,
142
171
  },
143
172
  },
144
173
  );
145
174
 
146
- const updatedAddress = customerAddressUpdate?.customerAddress;
147
-
148
- if (customerAddressUpdate?.customerUserErrors?.length) {
149
- const error = customerAddressUpdate.customerUserErrors[0];
150
- throw new Error(error.message);
175
+ if (errors?.length) {
176
+ throw new Error(errors[0].message);
151
177
  }
152
178
 
153
- if (defaultAddress) {
154
- const {customerDefaultAddressUpdate} = await storefront.mutate(
155
- UPDATE_DEFAULT_ADDRESS_MUTATION,
156
- {
157
- variables: {
158
- customerAccessToken: accessToken,
159
- addressId: decodeURIComponent(addressId),
160
- },
161
- },
162
- );
179
+ if (data?.customerAddressUpdate?.userErrors?.length) {
180
+ throw new Error(data?.customerAddressUpdate?.userErrors[0].message);
181
+ }
163
182
 
164
- if (customerDefaultAddressUpdate?.customerUserErrors?.length) {
165
- const error = customerDefaultAddressUpdate.customerUserErrors[0];
166
- throw new Error(error.message);
167
- }
183
+ if (!data?.customerAddressUpdate?.customerAddress) {
184
+ throw new Error('Customer address update failed.');
168
185
  }
169
186
 
170
- return json({error: null, updatedAddress, defaultAddress});
187
+ return json(
188
+ {
189
+ error: null,
190
+ updatedAddress: address,
191
+ defaultAddress,
192
+ },
193
+ {
194
+ headers: {
195
+ 'Set-Cookie': await context.session.commit(),
196
+ },
197
+ },
198
+ );
171
199
  } catch (error: unknown) {
172
200
  if (error instanceof Error) {
173
- return json({error: {[addressId]: error.message}}, {status: 400});
201
+ return json(
202
+ {error: {[addressId]: error.message}},
203
+ {
204
+ status: 400,
205
+ headers: {
206
+ 'Set-Cookie': await context.session.commit(),
207
+ },
208
+ },
209
+ );
174
210
  }
175
- return json({error: {[addressId]: error}}, {status: 400});
211
+ return json(
212
+ {error: {[addressId]: error}},
213
+ {
214
+ status: 400,
215
+ headers: {
216
+ 'Set-Cookie': await context.session.commit(),
217
+ },
218
+ },
219
+ );
176
220
  }
177
221
  }
178
222
 
179
223
  case 'DELETE': {
180
224
  // handles address deletion
181
225
  try {
182
- const {customerAddressDelete} = await storefront.mutate(
226
+ const {data, errors} = await customerAccount.mutate(
183
227
  DELETE_ADDRESS_MUTATION,
184
228
  {
185
- variables: {customerAccessToken: accessToken, id: addressId},
229
+ variables: {addressId: decodeURIComponent(addressId)},
186
230
  },
187
231
  );
188
232
 
189
- if (customerAddressDelete?.customerUserErrors?.length) {
190
- const error = customerAddressDelete.customerUserErrors[0];
191
- throw new Error(error.message);
233
+ if (errors?.length) {
234
+ throw new Error(errors[0].message);
235
+ }
236
+
237
+ if (data?.customerAddressDelete?.userErrors?.length) {
238
+ throw new Error(data?.customerAddressDelete?.userErrors[0].message);
192
239
  }
193
- return json({error: null, deletedAddress: addressId});
240
+
241
+ if (!data?.customerAddressDelete?.deletedAddressId) {
242
+ throw new Error('Customer address delete failed.');
243
+ }
244
+
245
+ return json(
246
+ {error: null, deletedAddress: addressId},
247
+ {
248
+ headers: {
249
+ 'Set-Cookie': await context.session.commit(),
250
+ },
251
+ },
252
+ );
194
253
  } catch (error: unknown) {
195
254
  if (error instanceof Error) {
196
- return json({error: {[addressId]: error.message}}, {status: 400});
255
+ return json(
256
+ {error: {[addressId]: error.message}},
257
+ {
258
+ status: 400,
259
+ headers: {
260
+ 'Set-Cookie': await context.session.commit(),
261
+ },
262
+ },
263
+ );
197
264
  }
198
- return json({error: {[addressId]: error}}, {status: 400});
265
+ return json(
266
+ {error: {[addressId]: error}},
267
+ {
268
+ status: 400,
269
+ headers: {
270
+ 'Set-Cookie': await context.session.commit(),
271
+ },
272
+ },
273
+ );
199
274
  }
200
275
  }
201
276
 
202
277
  default: {
203
278
  return json(
204
279
  {error: {[addressId]: 'Method not allowed'}},
205
- {status: 405},
280
+ {
281
+ status: 405,
282
+ headers: {
283
+ 'Set-Cookie': await context.session.commit(),
284
+ },
285
+ },
206
286
  );
207
287
  }
208
288
  }
209
289
  } catch (error: unknown) {
210
290
  if (error instanceof Error) {
211
- return json({error: error.message}, {status: 400});
291
+ return json(
292
+ {error: error.message},
293
+ {
294
+ status: 400,
295
+ headers: {
296
+ 'Set-Cookie': await context.session.commit(),
297
+ },
298
+ },
299
+ );
212
300
  }
213
- return json({error}, {status: 400});
301
+ return json(
302
+ {error},
303
+ {
304
+ status: 400,
305
+ headers: {
306
+ 'Set-Cookie': await context.session.commit(),
307
+ },
308
+ },
309
+ );
214
310
  }
215
311
  }
216
312
 
@@ -249,17 +345,21 @@ function NewAddressForm() {
249
345
  address2: '',
250
346
  city: '',
251
347
  company: '',
252
- country: '',
348
+ territoryCode: '',
253
349
  firstName: '',
254
350
  id: 'new',
255
351
  lastName: '',
256
- phone: '',
257
- province: '',
352
+ phoneNumber: '',
353
+ zoneCode: '',
258
354
  zip: '',
259
- } as AddressFragment;
355
+ } as CustomerAddressInput;
260
356
 
261
357
  return (
262
- <AddressForm address={newAddress} defaultAddress={null}>
358
+ <AddressForm
359
+ addressId={'NEW_ADDRESS_ID'}
360
+ address={newAddress}
361
+ defaultAddress={null}
362
+ >
263
363
  {({stateForMethod}) => (
264
364
  <div>
265
365
  <button
@@ -285,6 +385,7 @@ function ExistingAddresses({
285
385
  {addresses.nodes.map((address) => (
286
386
  <AddressForm
287
387
  key={address.id}
388
+ addressId={address.id}
288
389
  address={address}
289
390
  defaultAddress={defaultAddress}
290
391
  >
@@ -313,26 +414,28 @@ function ExistingAddresses({
313
414
  }
314
415
 
315
416
  export function AddressForm({
417
+ addressId,
316
418
  address,
317
419
  defaultAddress,
318
420
  children,
319
421
  }: {
422
+ addressId: AddressFragment['id'];
423
+ address: CustomerAddressInput;
424
+ defaultAddress: CustomerFragment['defaultAddress'];
320
425
  children: (props: {
321
426
  stateForMethod: (
322
427
  method: 'PUT' | 'POST' | 'DELETE',
323
428
  ) => ReturnType<typeof useNavigation>['state'];
324
429
  }) => React.ReactNode;
325
- defaultAddress: CustomerFragment['defaultAddress'];
326
- address: AddressFragment;
327
430
  }) {
328
431
  const {state, formMethod} = useNavigation();
329
432
  const action = useActionData<ActionResponse>();
330
- const error = action?.error?.[address.id];
331
- const isDefaultAddress = defaultAddress?.id === address.id;
433
+ const error = action?.error?.[addressId];
434
+ const isDefaultAddress = defaultAddress?.id === addressId;
332
435
  return (
333
- <Form id={address.id}>
436
+ <Form id={addressId}>
334
437
  <fieldset>
335
- <input type="hidden" name="addressId" defaultValue={address.id} />
438
+ <input type="hidden" name="addressId" defaultValue={addressId} />
336
439
  <label htmlFor="firstName">First name*</label>
337
440
  <input
338
441
  aria-label="First name"
@@ -397,13 +500,13 @@ export function AddressForm({
397
500
  required
398
501
  type="text"
399
502
  />
400
- <label htmlFor="province">State / Province*</label>
503
+ <label htmlFor="zoneCode">State / Province*</label>
401
504
  <input
402
- aria-label="State"
505
+ aria-label="State/Province"
403
506
  autoComplete="address-level1"
404
- defaultValue={address?.province ?? ''}
405
- id="province"
406
- name="province"
507
+ defaultValue={address?.zoneCode ?? ''}
508
+ id="zoneCode"
509
+ name="zoneCode"
407
510
  placeholder="State / Province"
408
511
  required
409
512
  type="text"
@@ -419,24 +522,25 @@ export function AddressForm({
419
522
  required
420
523
  type="text"
421
524
  />
422
- <label htmlFor="country">Country*</label>
525
+ <label htmlFor="territoryCode">Country Code*</label>
423
526
  <input
424
- aria-label="Country"
425
- autoComplete="country-name"
426
- defaultValue={address?.country ?? ''}
427
- id="country"
428
- name="country"
527
+ aria-label="territoryCode"
528
+ autoComplete="country"
529
+ defaultValue={address?.territoryCode ?? ''}
530
+ id="territoryCode"
531
+ name="territoryCode"
429
532
  placeholder="Country"
430
533
  required
431
534
  type="text"
535
+ maxLength={2}
432
536
  />
433
- <label htmlFor="phone">Phone</label>
537
+ <label htmlFor="phoneNumber">Phone</label>
434
538
  <input
435
- aria-label="Phone"
539
+ aria-label="Phone Number"
436
540
  autoComplete="tel"
437
- defaultValue={address?.phone ?? ''}
438
- id="phone"
439
- name="phone"
541
+ defaultValue={address?.phoneNumber ?? ''}
542
+ id="phoneNumber"
543
+ name="phoneNumber"
440
544
  placeholder="+16135551111"
441
545
  pattern="^\+?[1-9]\d{3,14}$"
442
546
  type="tel"
@@ -466,98 +570,3 @@ export function AddressForm({
466
570
  </Form>
467
571
  );
468
572
  }
469
-
470
- // NOTE: https://shopify.dev/docs/api/storefront/2023-04/mutations/customeraddressupdate
471
- const UPDATE_ADDRESS_MUTATION = `#graphql
472
- mutation customerAddressUpdate(
473
- $address: MailingAddressInput!
474
- $customerAccessToken: String!
475
- $id: ID!
476
- $country: CountryCode
477
- $language: LanguageCode
478
- ) @inContext(country: $country, language: $language) {
479
- customerAddressUpdate(
480
- address: $address
481
- customerAccessToken: $customerAccessToken
482
- id: $id
483
- ) {
484
- customerAddress {
485
- id
486
- }
487
- customerUserErrors {
488
- code
489
- field
490
- message
491
- }
492
- }
493
- }
494
- ` as const;
495
-
496
- // NOTE: https://shopify.dev/docs/api/storefront/latest/mutations/customerAddressDelete
497
- const DELETE_ADDRESS_MUTATION = `#graphql
498
- mutation customerAddressDelete(
499
- $customerAccessToken: String!,
500
- $id: ID!,
501
- $country: CountryCode,
502
- $language: LanguageCode
503
- ) @inContext(country: $country, language: $language) {
504
- customerAddressDelete(customerAccessToken: $customerAccessToken, id: $id) {
505
- customerUserErrors {
506
- code
507
- field
508
- message
509
- }
510
- deletedCustomerAddressId
511
- }
512
- }
513
- ` as const;
514
-
515
- // NOTE: https://shopify.dev/docs/api/storefront/latest/mutations/customerdefaultaddressupdate
516
- const UPDATE_DEFAULT_ADDRESS_MUTATION = `#graphql
517
- mutation customerDefaultAddressUpdate(
518
- $addressId: ID!
519
- $customerAccessToken: String!
520
- $country: CountryCode
521
- $language: LanguageCode
522
- ) @inContext(country: $country, language: $language) {
523
- customerDefaultAddressUpdate(
524
- addressId: $addressId
525
- customerAccessToken: $customerAccessToken
526
- ) {
527
- customer {
528
- defaultAddress {
529
- id
530
- }
531
- }
532
- customerUserErrors {
533
- code
534
- field
535
- message
536
- }
537
- }
538
- }
539
- ` as const;
540
-
541
- // NOTE: https://shopify.dev/docs/api/storefront/latest/mutations/customeraddresscreate
542
- const CREATE_ADDRESS_MUTATION = `#graphql
543
- mutation customerAddressCreate(
544
- $address: MailingAddressInput!
545
- $customerAccessToken: String!
546
- $country: CountryCode
547
- $language: LanguageCode
548
- ) @inContext(country: $country, language: $language) {
549
- customerAddressCreate(
550
- address: $address
551
- customerAccessToken: $customerAccessToken
552
- ) {
553
- customerAddress {
554
- id
555
- }
556
- customerUserErrors {
557
- code
558
- field
559
- message
560
- }
561
- }
562
- }
563
- ` as const;