@graphcommerce/magento-store 8.1.0-canary.8 → 9.0.0-canary.100

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/CHANGELOG.md CHANGED
@@ -1,5 +1,209 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.0.0-canary.100
4
+
5
+ ## 9.0.0-canary.99
6
+
7
+ ## 9.0.0-canary.98
8
+
9
+ ## 9.0.0-canary.97
10
+
11
+ ## 9.0.0-canary.96
12
+
13
+ ## 9.0.0-canary.95
14
+
15
+ ## 9.0.0-canary.94
16
+
17
+ ## 9.0.0-canary.93
18
+
19
+ ## 9.0.0-canary.92
20
+
21
+ ## 9.0.0-canary.91
22
+
23
+ ### Patch Changes
24
+
25
+ - [#2367](https://github.com/graphcommerce-org/graphcommerce/pull/2367) [`71d412d`](https://github.com/graphcommerce-org/graphcommerce/commit/71d412d202bc94a0e676745547de5d809a7a850b) - When a user access a category page which is beyond the available total_pages, the user will be redirected to the last available page. ([@paales](https://github.com/paales))
26
+
27
+ ## 9.0.0-canary.90
28
+
29
+ ## 9.0.0-canary.89
30
+
31
+ ## 9.0.0-canary.88
32
+
33
+ ## 9.0.0-canary.87
34
+
35
+ ## 9.0.0-canary.86
36
+
37
+ ## 9.0.0-canary.85
38
+
39
+ ## 9.0.0-canary.84
40
+
41
+ ## 9.0.0-canary.83
42
+
43
+ ### Patch Changes
44
+
45
+ - [#2374](https://github.com/graphcommerce-org/graphcommerce/pull/2374) [`e61e1f4`](https://github.com/graphcommerce-org/graphcommerce/commit/e61e1f4fb1086f7a6341b42502135abf1839e43d) - Default to permanent redirects unless specified ([@hnsr](https://github.com/hnsr))
46
+
47
+ ## 9.0.0-canary.82
48
+
49
+ ## 9.0.0-canary.81
50
+
51
+ ### Minor Changes
52
+
53
+ - [#2373](https://github.com/graphcommerce-org/graphcommerce/pull/2373) [`53ffc91`](https://github.com/graphcommerce-org/graphcommerce/commit/53ffc91f9bfbe1183c002c62b1fe0c3f415d7b94) - Handle the case where one switches from using the default .html URL suffix, to not using one ([@hnsr](https://github.com/hnsr))
54
+
55
+ ## 9.0.0-canary.80
56
+
57
+ ## 9.0.0-canary.79
58
+
59
+ ## 9.0.0-canary.78
60
+
61
+ ## 9.0.0-canary.77
62
+
63
+ ## 9.0.0-canary.76
64
+
65
+ ## 9.0.0-canary.75
66
+
67
+ ## 9.0.0-canary.74
68
+
69
+ ## 9.0.0-canary.73
70
+
71
+ ## 9.0.0-canary.72
72
+
73
+ ## 9.0.0-canary.71
74
+
75
+ ## 9.0.0-canary.70
76
+
77
+ ## 9.0.0-canary.69
78
+
79
+ ## 9.0.0-canary.68
80
+
81
+ ## 9.0.0-canary.67
82
+
83
+ ## 9.0.0-canary.66
84
+
85
+ ## 9.0.0-canary.65
86
+
87
+ ## 9.0.0-canary.64
88
+
89
+ ## 9.0.0-canary.63
90
+
91
+ ## 9.0.0-canary.62
92
+
93
+ ## 9.0.0-canary.61
94
+
95
+ ### Minor Changes
96
+
97
+ - [#2327](https://github.com/graphcommerce-org/graphcommerce/pull/2327) [`be719fc`](https://github.com/graphcommerce-org/graphcommerce/commit/be719fc465c8804ddcb720a93813262e3a292b69) - Implement CancelOrder mutation, add cancel order overlay to account section ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
98
+
99
+ ## 9.0.0-canary.60
100
+
101
+ ## 9.0.0-canary.59
102
+
103
+ ## 9.0.0-canary.58
104
+
105
+ ## 9.0.0-canary.57
106
+
107
+ ## 9.0.0-canary.56
108
+
109
+ ## 9.0.0-canary.55
110
+
111
+ ## 9.0.0-canary.54
112
+
113
+ ## 8.1.0-canary.53
114
+
115
+ ## 8.1.0-canary.52
116
+
117
+ ## 8.1.0-canary.51
118
+
119
+ ## 8.1.0-canary.50
120
+
121
+ ## 8.1.0-canary.49
122
+
123
+ ## 8.1.0-canary.48
124
+
125
+ ## 8.1.0-canary.47
126
+
127
+ ## 8.1.0-canary.46
128
+
129
+ ## 8.1.0-canary.45
130
+
131
+ ## 8.1.0-canary.44
132
+
133
+ ## 8.1.0-canary.43
134
+
135
+ ## 8.1.0-canary.42
136
+
137
+ ## 8.1.0-canary.41
138
+
139
+ ## 8.1.0-canary.40
140
+
141
+ ## 8.1.0-canary.39
142
+
143
+ ## 8.1.0-canary.38
144
+
145
+ ## 8.1.0-canary.37
146
+
147
+ ## 8.1.0-canary.36
148
+
149
+ ## 8.1.0-canary.35
150
+
151
+ ### Minor Changes
152
+
153
+ - [#2301](https://github.com/graphcommerce-org/graphcommerce/pull/2301) [`47bb47b`](https://github.com/graphcommerce-org/graphcommerce/commit/47bb47bac4b3689a6859afbc587274d813e0b072) - Implement confirm email functionality ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
154
+
155
+ ## 8.1.0-canary.34
156
+
157
+ ## 8.1.0-canary.33
158
+
159
+ ## 8.1.0-canary.32
160
+
161
+ ## 8.1.0-canary.31
162
+
163
+ ## 8.1.0-canary.30
164
+
165
+ ## 8.1.0-canary.29
166
+
167
+ ## 8.1.0-canary.28
168
+
169
+ ## 8.1.0-canary.27
170
+
171
+ ## 8.1.0-canary.26
172
+
173
+ ## 8.1.0-canary.25
174
+
175
+ ## 8.1.0-canary.24
176
+
177
+ ## 8.1.0-canary.23
178
+
179
+ ## 8.1.0-canary.22
180
+
181
+ ## 8.1.0-canary.21
182
+
183
+ ## 8.1.0-canary.20
184
+
185
+ ## 8.1.0-canary.19
186
+
187
+ ## 8.1.0-canary.18
188
+
189
+ ## 8.1.0-canary.17
190
+
191
+ ## 8.1.0-canary.16
192
+
193
+ ## 8.1.0-canary.15
194
+
195
+ ## 8.1.0-canary.14
196
+
197
+ ## 8.1.0-canary.13
198
+
199
+ ## 8.1.0-canary.12
200
+
201
+ ## 8.1.0-canary.11
202
+
203
+ ## 8.1.0-canary.10
204
+
205
+ ## 8.1.0-canary.9
206
+
3
207
  ## 8.1.0-canary.8
4
208
 
5
209
  ## 8.1.0-canary.7
@@ -78,8 +282,7 @@
78
282
 
79
283
  ### Patch Changes
80
284
 
81
- - [#2187](https://github.com/graphcommerce-org/graphcommerce/pull/2187) [`61f90af`](https://github.com/graphcommerce-org/graphcommerce/commit/61f90afc8bc229b2cd4793f724509783af138deb) - redirectOrNotFound would log the incorrect request URL
82
- ([@paales](https://github.com/paales))
285
+ - [#2187](https://github.com/graphcommerce-org/graphcommerce/pull/2187) [`61f90af`](https://github.com/graphcommerce-org/graphcommerce/commit/61f90afc8bc229b2cd4793f724509783af138deb) - redirectOrNotFound would log the incorrect request URL ([@paales](https://github.com/paales))
83
286
 
84
287
  ## 8.0.1-canary.4
85
288
 
@@ -93,18 +296,15 @@
93
296
 
94
297
  ### Patch Changes
95
298
 
96
- - [#2187](https://github.com/graphcommerce-org/graphcommerce/pull/2187) [`61f90af`](https://github.com/graphcommerce-org/graphcommerce/commit/61f90afc8bc229b2cd4793f724509783af138deb) - redirectOrNotFound would log the incorrect request URL
97
- ([@paales](https://github.com/paales))
299
+ - [#2187](https://github.com/graphcommerce-org/graphcommerce/pull/2187) [`61f90af`](https://github.com/graphcommerce-org/graphcommerce/commit/61f90afc8bc229b2cd4793f724509783af138deb) - redirectOrNotFound would log the incorrect request URL ([@paales](https://github.com/paales))
98
300
 
99
301
  ## 8.0.0
100
302
 
101
303
  ### Patch Changes
102
304
 
103
- - [#2067](https://github.com/graphcommerce-org/graphcommerce/pull/2067) [`3406794`](https://github.com/graphcommerce-org/graphcommerce/commit/340679434e0ff1033c8158ef03a091e06e20e6a9) - Prevent HandleRedirect errors by filtering out empty URL values from the candidates array.
104
- ([@carlocarels90](https://github.com/carlocarels90))
305
+ - [#2067](https://github.com/graphcommerce-org/graphcommerce/pull/2067) [`3406794`](https://github.com/graphcommerce-org/graphcommerce/commit/340679434e0ff1033c8158ef03a091e06e20e6a9) - Prevent HandleRedirect errors by filtering out empty URL values from the candidates array. ([@carlocarels90](https://github.com/carlocarels90))
105
306
 
106
- - [#2140](https://github.com/graphcommerce-org/graphcommerce/pull/2140) [`b34d85c`](https://github.com/graphcommerce-org/graphcommerce/commit/b34d85c8c5403c6f49b506b714ee314b8344fd99) - Solve incorrect redirect when locale has own domain
107
- ([@hnsr](https://github.com/hnsr))
307
+ - [#2140](https://github.com/graphcommerce-org/graphcommerce/pull/2140) [`b34d85c`](https://github.com/graphcommerce-org/graphcommerce/commit/b34d85c8c5403c6f49b506b714ee314b8344fd99) - Solve incorrect redirect when locale has own domain ([@hnsr](https://github.com/hnsr))
108
308
 
109
309
  ## 8.0.0-canary.100
110
310
 
@@ -148,8 +348,7 @@
148
348
 
149
349
  ### Patch Changes
150
350
 
151
- - [#2140](https://github.com/graphcommerce-org/graphcommerce/pull/2140) [`b34d85c`](https://github.com/graphcommerce-org/graphcommerce/commit/b34d85c8c5403c6f49b506b714ee314b8344fd99) - Fix incorrect redirect when locale has own domain
152
- ([@hnsr](https://github.com/hnsr))
351
+ - [#2140](https://github.com/graphcommerce-org/graphcommerce/pull/2140) [`b34d85c`](https://github.com/graphcommerce-org/graphcommerce/commit/b34d85c8c5403c6f49b506b714ee314b8344fd99) - Fix incorrect redirect when locale has own domain ([@hnsr](https://github.com/hnsr))
153
352
 
154
353
  ## 8.0.0-canary.80
155
354
 
@@ -1294,31 +1493,31 @@
1294
1493
  All occurences of `<Trans>` and `t` need to be replaced:
1295
1494
 
1296
1495
  ```tsx
1297
- import { Trans, t } from "@lingui/macro";
1496
+ import { Trans, t } from '@lingui/macro'
1298
1497
 
1299
1498
  function MyComponent() {
1300
- const foo = "bar";
1499
+ const foo = 'bar'
1301
1500
  return (
1302
1501
  <div aria-label={t`Account ${foo}`}>
1303
1502
  <Trans>My Translation {foo}</Trans>
1304
1503
  </div>
1305
- );
1504
+ )
1306
1505
  }
1307
1506
  ```
1308
1507
 
1309
1508
  Needs to be replaced with:
1310
1509
 
1311
1510
  ```tsx
1312
- import { Trans } from "@lingui/react";
1313
- import { i18n } from "@lingui/core";
1511
+ import { Trans } from '@lingui/react'
1512
+ import { i18n } from '@lingui/core'
1314
1513
 
1315
1514
  function MyComponent() {
1316
- const foo = "bar";
1515
+ const foo = 'bar'
1317
1516
  return (
1318
1517
  <div aria-label={i18n._(/* i18n */ `Account {foo}`, { foo })}>
1319
- <Trans key="My Translation {foo}" values={{ foo }}></Trans>
1518
+ <Trans key='My Translation {foo}' values={{ foo }}></Trans>
1320
1519
  </div>
1321
- );
1520
+ )
1322
1521
  }
1323
1522
  ```
1324
1523
 
@@ -1455,11 +1654,11 @@
1455
1654
  defaultProps: {
1456
1655
  round: true,
1457
1656
  formatOptions: {
1458
- style: "decimal",
1657
+ style: 'decimal',
1459
1658
  },
1460
1659
  },
1461
1660
  },
1462
- });
1661
+ })
1463
1662
  ```
1464
1663
 
1465
1664
  ### Patch Changes
package/Money.tsx CHANGED
@@ -1,50 +1,29 @@
1
1
  import { useQuery } from '@graphcommerce/graphql'
2
- import { ExtendableComponent, useNumberFormat } from '@graphcommerce/next-ui'
3
- import { useThemeProps } from '@mui/material'
4
- import { useMemo } from 'react'
2
+ import { CurrencyFormat, CurrencyFormatProps } from '@graphcommerce/next-ui'
5
3
  import { MoneyFragment } from './Money.gql'
6
4
  import { StoreConfigDocument } from './StoreConfig.gql'
7
5
 
8
6
  type OverridableProps = {
9
- // eslint-disable-next-line react/no-unused-prop-types
10
7
  round?: boolean
11
- /** @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#parameters */
12
- // eslint-disable-next-line react/no-unused-prop-types
13
- formatOptions?: Intl.NumberFormatOptions
8
+ formatOptions?: Omit<CurrencyFormatProps, 'currency'>
14
9
  }
15
10
 
16
11
  export type MoneyProps = MoneyFragment & OverridableProps
17
12
 
18
- const name = 'Money'
19
-
20
- /** Expose the component to be exendable in your theme.components */
21
- declare module '@mui/material/styles/components' {
22
- interface Components {
23
- Money?: Pick<ExtendableComponent<OverridableProps>, 'defaultProps'>
24
- }
25
- }
26
-
27
13
  export function Money(props: MoneyProps) {
28
- const { currency, value, round = false, formatOptions } = useThemeProps({ name, props })
29
-
14
+ const { currency, value, round = false, formatOptions } = props
30
15
  const { data: config } = useQuery(StoreConfigDocument)
31
-
32
16
  const digits = (value ?? 0) % 1 !== 0
33
17
 
34
- const options: Intl.NumberFormatOptions = useMemo(
35
- () => ({
36
- style: 'currency',
37
- currency: currency ?? config?.storeConfig?.base_currency_code ?? '',
38
- ...(round && !digits && { minimumFractionDigits: 0 }),
39
- ...(round && digits && { minimumFractionDigits: 2 }),
40
- ...(!round && { minimumFractionDigits: 2 }),
41
- ...formatOptions,
42
- }),
43
- [config?.storeConfig?.base_currency_code, currency, digits, formatOptions, round],
44
- )
45
- const numberFormatter = useNumberFormat(options)
46
-
47
18
  if (typeof value === 'undefined' || value === null) return null
48
19
 
49
- return <>{numberFormatter.format(value)}</>
20
+ return (
21
+ <CurrencyFormat
22
+ currency={currency ?? config?.storeConfig?.base_currency_code ?? ''}
23
+ maximumFractionDigits={round && !digits ? 0 : 2}
24
+ {...formatOptions}
25
+ >
26
+ {value}
27
+ </CurrencyFormat>
28
+ )
50
29
  }
@@ -1,4 +1,4 @@
1
- fragment StoreConfigFragment on StoreConfig @injectable {
1
+ fragment StoreConfigFragment on StoreConfig {
2
2
  website_name
3
3
  store_code
4
4
  store_name
@@ -30,4 +30,9 @@ fragment StoreConfigFragment on StoreConfig @injectable {
30
30
  grid_per_page
31
31
  grid_per_page_values
32
32
  list_per_page
33
+ create_account_confirmation
34
+ order_cancellation_enabled
35
+ order_cancellation_reasons {
36
+ description
37
+ }
33
38
  }
package/index.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from './components/GlobalHead/GlobalHead'
2
2
  export * from './hooks/useFindCountry'
3
3
  export * from './hooks/useFindRegion'
4
- export * from './link/createStoreLink'
5
4
  export * from './localeToStore'
6
5
  export * from './Money'
7
6
  export * from './Money.gql'
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-store",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "8.1.0-canary.8",
5
+ "version": "9.0.0-canary.100",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -12,13 +12,13 @@
12
12
  }
13
13
  },
14
14
  "peerDependencies": {
15
- "@graphcommerce/eslint-config-pwa": "^8.1.0-canary.8",
16
- "@graphcommerce/graphql": "^8.1.0-canary.8",
17
- "@graphcommerce/graphql-mesh": "^8.1.0-canary.8",
18
- "@graphcommerce/image": "^8.1.0-canary.8",
19
- "@graphcommerce/next-ui": "^8.1.0-canary.8",
20
- "@graphcommerce/prettier-config-pwa": "^8.1.0-canary.8",
21
- "@graphcommerce/typescript-config-pwa": "^8.1.0-canary.8",
15
+ "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.100",
16
+ "@graphcommerce/graphql": "^9.0.0-canary.100",
17
+ "@graphcommerce/graphql-mesh": "^9.0.0-canary.100",
18
+ "@graphcommerce/image": "^9.0.0-canary.100",
19
+ "@graphcommerce/next-ui": "^9.0.0-canary.100",
20
+ "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.100",
21
+ "@graphcommerce/typescript-config-pwa": "^9.0.0-canary.100",
22
22
  "@lingui/core": "^4.2.1",
23
23
  "@lingui/macro": "^4.2.1",
24
24
  "@lingui/react": "^4.2.1",
@@ -1,13 +1,39 @@
1
- import type { graphqlConfig as graphqlConfigType } from '@graphcommerce/graphql'
1
+ import { setContext, type graphqlConfig as graphqlConfigType } from '@graphcommerce/graphql'
2
2
  import type { FunctionPlugin, PluginConfig } from '@graphcommerce/next-config'
3
- import { createStoreLink } from '../link/createStoreLink'
4
3
 
5
4
  export const config: PluginConfig = {
6
5
  type: 'function',
7
6
  module: '@graphcommerce/graphql',
8
7
  }
9
8
 
9
+ declare module '@graphcommerce/graphql/config' {
10
+ interface PreviewData {
11
+ magentoPreviewVersion?: string
12
+ }
13
+ }
14
+
10
15
  export const graphqlConfig: FunctionPlugin<typeof graphqlConfigType> = (prev, conf) => {
11
16
  const results = prev(conf)
12
- return { ...results, links: [...results.links, createStoreLink(conf.storefront.locale)] }
17
+
18
+ const previewVersion = conf.previewData?.magentoPreviewVersion
19
+
20
+ return {
21
+ ...results,
22
+ links: [
23
+ ...results.links,
24
+ setContext((_, context) => {
25
+ if (!context.headers) context.headers = {}
26
+ context.headers.store = conf.storefront.magentoStoreCode
27
+ if (conf.preview) {
28
+ // To disable caching from the backend, we provide a bogus cache ID.
29
+ context.headers['x-magento-cache-id'] =
30
+ `random-cache-id${Math.random().toString(36).slice(2)}`
31
+ if (previewVersion) {
32
+ context.headers['preview-version'] = previewVersion
33
+ }
34
+ }
35
+ return context
36
+ }),
37
+ ],
38
+ }
13
39
  }
@@ -23,6 +23,25 @@ const notFound = (from: string, reason: string) => {
23
23
  return { notFound: true, revalidate: 60 * 20 } as const
24
24
  }
25
25
 
26
+ const urlPrefix = (locale?: string) => {
27
+ const localeHasDomain = Boolean(storefrontConfig(locale)?.domain)
28
+ return localeHasDomain || locale === defaultLocale() ? '' : `/${locale}`
29
+ }
30
+
31
+ export const redirectTo = (
32
+ to: string,
33
+ permanent: boolean,
34
+ locale?: string,
35
+ ): { redirect: Redirect; revalidate?: number | boolean } => {
36
+ console.log(
37
+ `[redirectTo]: ${permanent ? 'Permanent' : 'Temporary'} redirect to ${urlPrefix(locale)}${to}`,
38
+ )
39
+ return {
40
+ redirect: { destination: `${urlPrefix(locale)}${to}`, permanent },
41
+ revalidate: 60 * 20,
42
+ }
43
+ }
44
+
26
45
  const redirect = (from: string, to: string, permanent: boolean, locale?: string) => {
27
46
  const localeHasDomain = Boolean(storefrontConfig(locale)?.domain)
28
47
  const prefix = localeHasDomain || locale === defaultLocale() ? '' : `/${locale}`
@@ -68,6 +87,11 @@ export async function redirectOrNotFound(
68
87
  candidates.add(from.endsWith(suffix) ? from.slice(0, -suffix.length) : `${from}${suffix}`)
69
88
  })
70
89
 
90
+ // Handle the case where we transition from using the default .html suffix, to not using one
91
+ if (from.endsWith('.html')) {
92
+ candidates.add(from.slice(0, -('.html'.length)))
93
+ }
94
+
71
95
  const routePromises = [...candidates].filter(Boolean).map(
72
96
  async (url) =>
73
97
  (
@@ -100,8 +124,8 @@ export async function redirectOrNotFound(
100
124
  ? routeData.route.relative_url
101
125
  : undefined
102
126
 
103
- // There is a URL, so we need to check if it can be found in the database.
104
- const permanent = routeData.route?.redirect_code === 301
127
+ // For implicit redirects, always use permanent, otherwise use the given redirect type
128
+ const permanent = !routeData.route?.redirect_code || routeData.route?.redirect_code === 301
105
129
 
106
130
  if (
107
131
  isTypename(routeData.route, [
@@ -1,10 +0,0 @@
1
- import { setContext } from '@graphcommerce/graphql'
2
- import { localeToStore } from '../localeToStore'
3
-
4
- /** Apollo link to set the store header in the context */
5
- export const createStoreLink = (locale?: string) =>
6
- setContext((_, context) => {
7
- if (!context.headers) context.headers = {}
8
- context.headers.store = localeToStore(locale)
9
- return context
10
- })