@graphcommerce/magento-store 3.4.11 → 4.0.1
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 +131 -100
- package/Money.tsx +2 -2
- package/PageMeta.tsx +2 -2
- package/components/GlobalHead/GlobalHead.tsx +13 -0
- package/components/StoreSwitcherButton/StoreSwitcherButton.tsx +30 -0
- package/{switcher → components/StoreSwitcherList}/StoreSwitcherList.graphql +0 -0
- package/{switcher → components/StoreSwitcherList}/StoreSwitcherList.tsx +29 -37
- package/hooks/useFindCountry.ts +1 -1
- package/index.ts +9 -17
- package/link/createStoreLink.ts +2 -2
- package/localeToStore.ts +1 -0
- package/package.json +15 -20
- package/switcher/CountryLocale.graphql +0 -5
- package/switcher/StoreLocale.graphql +0 -8
- package/switcher/StoreSwitcherButton.tsx +0 -34
package/CHANGELOG.md
CHANGED
|
@@ -1,170 +1,201 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
3
|
+
## 4.0.1
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Features
|
|
5
|
+
### Patch Changes
|
|
10
6
|
|
|
11
|
-
|
|
7
|
+
- [`0cbaa878b`](https://github.com/ho-nl/m2-pwa/commit/0cbaa878b8a844d5abbeb1797b625a33130e6514)
|
|
8
|
+
Thanks [@paales](https://github.com/paales)! - Added homepage and repository package.json files,
|
|
9
|
+
so that the packages link to back to the website and repository
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
[[`0cbaa878b`](https://github.com/ho-nl/m2-pwa/commit/0cbaa878b8a844d5abbeb1797b625a33130e6514)]:
|
|
12
|
+
- @graphcommerce/graphql@3.0.1
|
|
13
|
+
- @graphcommerce/image@3.0.1
|
|
14
|
+
- @graphcommerce/next-ui@4.0.1
|
|
12
15
|
|
|
16
|
+
## 4.0.0
|
|
13
17
|
|
|
18
|
+
### Major Changes
|
|
14
19
|
|
|
20
|
+
- [#1258](https://github.com/ho-nl/m2-pwa/pull/1258)
|
|
21
|
+
[`ad36382a4`](https://github.com/ho-nl/m2-pwa/commit/ad36382a4d55d83d9e47b7eb6a02671a2a631a05)
|
|
22
|
+
Thanks [@paales](https://github.com/paales)! - Upgraded to Material UI 5
|
|
15
23
|
|
|
24
|
+
### Patch Changes
|
|
16
25
|
|
|
17
|
-
|
|
26
|
+
- Updated dependencies
|
|
27
|
+
[[`ad36382a4`](https://github.com/ho-nl/m2-pwa/commit/ad36382a4d55d83d9e47b7eb6a02671a2a631a05)]:
|
|
28
|
+
- @graphcommerce/graphql@3.0.0
|
|
29
|
+
- @graphcommerce/image@3.0.0
|
|
30
|
+
- @graphcommerce/next-ui@4.0.0
|
|
18
31
|
|
|
32
|
+
All notable changes to this project will be documented in this file. See
|
|
33
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
19
34
|
|
|
20
|
-
|
|
35
|
+
# [3.4.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-store@3.3.31...@graphcommerce/magento-store@3.4.0) (2022-01-03)
|
|
21
36
|
|
|
22
|
-
|
|
37
|
+
### Features
|
|
23
38
|
|
|
39
|
+
- **framer-next-pages:** reduce rerenders when navigating to a new page
|
|
40
|
+
([5cf3301](https://github.com/ho-nl/m2-pwa/commit/5cf330130bb3527057da015e3c4a6fa295d7262e))
|
|
24
41
|
|
|
42
|
+
## [3.3.11](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-store@3.3.10...@graphcommerce/magento-store@3.3.11) (2021-12-06)
|
|
25
43
|
|
|
44
|
+
### Bug Fixes
|
|
26
45
|
|
|
46
|
+
- use Locale to set storeSwitcher icons
|
|
47
|
+
([65ea397](https://github.com/ho-nl/m2-pwa/commit/65ea397ec53aa27f545b43feda8e35227e119ebe))
|
|
27
48
|
|
|
28
49
|
# [3.3.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-store@3.2.20...@graphcommerce/magento-store@3.3.0) (2021-11-12)
|
|
29
50
|
|
|
30
|
-
|
|
31
51
|
### Features
|
|
32
52
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
53
|
+
- added tons of translations
|
|
54
|
+
([9bb0ac7](https://github.com/ho-nl/m2-pwa/commit/9bb0ac709b58df6ea6141e92e4923a5ca9ae2963))
|
|
38
55
|
|
|
39
56
|
# [3.2.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-store@3.1.8...@graphcommerce/magento-store@3.2.0) (2021-11-02)
|
|
40
57
|
|
|
41
|
-
|
|
42
58
|
### Features
|
|
43
59
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
60
|
+
- darkTheme
|
|
61
|
+
([968f4f1](https://github.com/ho-nl/m2-pwa/commit/968f4f1360417bf7daa36454c19e6bc5cf53ae90))
|
|
49
62
|
|
|
50
63
|
# [3.1.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-store@3.0.31...@graphcommerce/magento-store@3.1.0) (2021-10-27)
|
|
51
64
|
|
|
52
|
-
|
|
53
65
|
### Features
|
|
54
66
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
- **nextjs:** upgraded to nextjs 12
|
|
68
|
+
([9331bc8](https://github.com/ho-nl/m2-pwa/commit/9331bc801f6419522115cc47d291d49d608d5a90))
|
|
60
69
|
|
|
61
70
|
## [3.0.29](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-store@3.0.28...@graphcommerce/magento-store@3.0.29) (2021-10-21)
|
|
62
71
|
|
|
63
|
-
|
|
64
72
|
### Bug Fixes
|
|
65
73
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
- compatibility with venia theme
|
|
75
|
+
([c0bcdd5](https://github.com/ho-nl/m2-pwa/commit/c0bcdd511de5679f185f0984816b1f0cafa449e0))
|
|
71
76
|
|
|
72
77
|
## [3.0.7](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-store@3.0.6...@graphcommerce/magento-store@3.0.7) (2021-09-30)
|
|
73
78
|
|
|
74
|
-
|
|
75
79
|
### Bug Fixes
|
|
76
80
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
- with the latest version of graphql codegen the preresovled types inlined Maybe, make sure we
|
|
82
|
+
reflect that
|
|
83
|
+
([7cb27b0](https://github.com/ho-nl/m2-pwa/commit/7cb27b04cbe31bee5ef4000d408f08bc9ac505c5))
|
|
82
84
|
|
|
83
85
|
## [3.0.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-store@3.0.0...@graphcommerce/magento-store@3.0.1) (2021-09-27)
|
|
84
86
|
|
|
85
87
|
**Note:** Version bump only for package @graphcommerce/magento-store
|
|
86
88
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
89
|
# 3.0.0 (2021-09-27)
|
|
92
90
|
|
|
93
|
-
|
|
94
91
|
### Bug Fixes
|
|
95
92
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
93
|
+
- canonical urls
|
|
94
|
+
([9ff8d3f](https://github.com/ho-nl/m2-pwa/commit/9ff8d3f950098fb28440f31f5dd93a835dce0bda))
|
|
95
|
+
- change href's from faq to service
|
|
96
|
+
([cb9875b](https://github.com/ho-nl/m2-pwa/commit/cb9875bce43db5953f227ee60f8d5dfe339f50b5))
|
|
97
|
+
- code consistency
|
|
98
|
+
([a310f0e](https://github.com/ho-nl/m2-pwa/commit/a310f0e548907c044b016b9473641ecd378b313f))
|
|
99
|
+
- **country-switcher:** navigate back to correct locale
|
|
100
|
+
([579d146](https://github.com/ho-nl/m2-pwa/commit/579d146e1b658a343b1514d8e8a45c01a507c084))
|
|
101
|
+
- duplicated (meta) tags in document head
|
|
102
|
+
([d52e962](https://github.com/ho-nl/m2-pwa/commit/d52e9629036ccab1f266ddd01600a0bd45930149))
|
|
103
|
+
- footer country flag
|
|
104
|
+
([8c6bf20](https://github.com/ho-nl/m2-pwa/commit/8c6bf206f85d44289a8d11d9bcd2178af6cc3445))
|
|
105
|
+
- get more data from store locale
|
|
106
|
+
([455245c](https://github.com/ho-nl/m2-pwa/commit/455245cf88d4a0cfbe197c97739306af8d8ff211))
|
|
107
|
+
- ignore md files from triggering version updates
|
|
108
|
+
([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
|
|
109
|
+
- implement next-ui barrel imports
|
|
110
|
+
([75bea70](https://github.com/ho-nl/m2-pwa/commit/75bea703dba898f18a2a1dfa3243ebd0a4e6f0e1))
|
|
111
|
+
- lint error
|
|
112
|
+
([be542af](https://github.com/ho-nl/m2-pwa/commit/be542afc466209c79cb776aac494abb7cab24bf7))
|
|
113
|
+
- **magento-store:** move useCountry/useRegion to magento-store and rename to
|
|
114
|
+
useFindCountry/useFindRegion
|
|
115
|
+
([3fed1c5](https://github.com/ho-nl/m2-pwa/commit/3fed1c53f975977e2681a9b80bb283332d9ad5ec))
|
|
116
|
+
- make storeswitcher a button
|
|
117
|
+
([a7dc452](https://github.com/ho-nl/m2-pwa/commit/a7dc45297e565be9c5d72c03e3d8c4a61c415c8a))
|
|
118
|
+
- prices wouldn’t render if the price wasn’t an integer
|
|
119
|
+
([0866881](https://github.com/ho-nl/m2-pwa/commit/08668813699065b168e3d9b1fe2410c5cd073c89))
|
|
120
|
+
- prop types
|
|
121
|
+
([caccb1a](https://github.com/ho-nl/m2-pwa/commit/caccb1ab4c459642b64498dde22c372fd890f0c7))
|
|
122
|
+
- remove button from store-switcher in footer
|
|
123
|
+
([43f6d52](https://github.com/ho-nl/m2-pwa/commit/43f6d5227edff809effa46b658afc0d3c4268f3f))
|
|
124
|
+
- remove canonical metatag when no canonical is given
|
|
125
|
+
([167b7f0](https://github.com/ho-nl/m2-pwa/commit/167b7f080f98a10ff35cbd760b24b8198aac6518))
|
|
126
|
+
- search not submitting after empying the field
|
|
127
|
+
([a15b5cf](https://github.com/ho-nl/m2-pwa/commit/a15b5cf94f4619e0087c8871a98617ab160f671a))
|
|
128
|
+
- secure base link url in store config
|
|
129
|
+
([ecba5c2](https://github.com/ho-nl/m2-pwa/commit/ecba5c2b2c109b027916872ca860c566b031d8a4))
|
|
130
|
+
- since all links are of next/link we need to add passHref for custom components
|
|
131
|
+
([16fb931](https://github.com/ho-nl/m2-pwa/commit/16fb93100d367203ea79bb4f93357221253f2ecd))
|
|
132
|
+
- yarn workspace packages hot reload
|
|
133
|
+
([d03fc9f](https://github.com/ho-nl/m2-pwa/commit/d03fc9fdda3486476761786f2b56a934cc92befc))
|
|
117
134
|
|
|
118
135
|
### Features
|
|
119
136
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
- add getFilterTypes to shared client, faster generation
|
|
138
|
+
([beccfde](https://github.com/ho-nl/m2-pwa/commit/beccfde6ebc8aaf6223f0e8b33fabf4f5039efed))
|
|
139
|
+
- added footer buttons
|
|
140
|
+
([65610cc](https://github.com/ho-nl/m2-pwa/commit/65610cc1db2929b9203a3b7b25375a8324bc8ce9))
|
|
141
|
+
- added store switcher route
|
|
142
|
+
([64b04b3](https://github.com/ho-nl/m2-pwa/commit/64b04b3c1488c93395b228ac04c9d3c3912391a2))
|
|
143
|
+
- better 404 handling and simplified getStaticProps
|
|
144
|
+
([321ace1](https://github.com/ho-nl/m2-pwa/commit/321ace1850642ee3eddfa674c37e6fca8adcdb74))
|
|
145
|
+
- canonical urls using abstract page meta component
|
|
146
|
+
([5f09b6f](https://github.com/ho-nl/m2-pwa/commit/5f09b6f89f4c39f5465869b86468c384de73faba))
|
|
147
|
+
- created stacked-pages package
|
|
148
|
+
([d86008e](https://github.com/ho-nl/m2-pwa/commit/d86008ee659ccb25b194a41d624b394a1ddbd088))
|
|
149
|
+
- **graphql:** introduced new graphql package that holds all generated files
|
|
150
|
+
([a3e7aa0](https://github.com/ho-nl/m2-pwa/commit/a3e7aa05540540533b5ced9a95f1f802ecbe499f))
|
|
151
|
+
- i18n routing added (/ and /fr for demo)
|
|
152
|
+
([bb3b339](https://github.com/ho-nl/m2-pwa/commit/bb3b339fbc9fceddd264a891ad81f00327a241ae))
|
|
153
|
+
- **image:** introduced completely rewritten Image component
|
|
154
|
+
([e3413b3](https://github.com/ho-nl/m2-pwa/commit/e3413b3a57392d6571ea64cb8d9c8dca05ea31df))
|
|
155
|
+
- introduces framer-next-pages and framer-sheet to next-ui and soxbase package
|
|
156
|
+
([e04ad8a](https://github.com/ho-nl/m2-pwa/commit/e04ad8a94cd1fd5a7c5575c9db7916b6e8a88f16))
|
|
157
|
+
- major performance refactor
|
|
158
|
+
([03f8e2f](https://github.com/ho-nl/m2-pwa/commit/03f8e2fa16ef919bd6bd6eadd36922d0245ed960))
|
|
159
|
+
- move to category_uid instead of category_id
|
|
160
|
+
([a2efe8d](https://github.com/ho-nl/m2-pwa/commit/a2efe8daac6ebe949070108fc4bcf8cc0919c1c7))
|
|
161
|
+
- next.js 11
|
|
162
|
+
([7d61407](https://github.com/ho-nl/m2-pwa/commit/7d614075a778f488045034f74be4f75b93f63c43))
|
|
163
|
+
- **playwright:** added new playwright package to enable browser testing
|
|
164
|
+
([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
|
|
165
|
+
- renamed all packages to use [@graphcommerce](https://github.com/graphcommerce) instead of
|
|
166
|
+
[@reachdigital](https://github.com/reachdigital)
|
|
167
|
+
([491e4ce](https://github.com/ho-nl/m2-pwa/commit/491e4cec9a2686472dac36b79f999257c0811ffe))
|
|
168
|
+
- support reviews store config variables
|
|
169
|
+
([532e849](https://github.com/ho-nl/m2-pwa/commit/532e84926c97affcd21ade56773bc06a02060b3a))
|
|
170
|
+
- upgrade to node 14
|
|
171
|
+
([d079a75](https://github.com/ho-nl/m2-pwa/commit/d079a751e9bfd8dc7f5009d2c9f31c336a0c96ab))
|
|
172
|
+
- upgraded to nextjs 11
|
|
173
|
+
([0053beb](https://github.com/ho-nl/m2-pwa/commit/0053beb7ef597c190add7264256a0eaec35868da))
|
|
174
|
+
- useFormMutationCart and simpler imports
|
|
175
|
+
([012f090](https://github.com/ho-nl/m2-pwa/commit/012f090e8f54d09f35d393c61ad1e2319f5a90ff))
|
|
140
176
|
|
|
141
177
|
### Reverts
|
|
142
178
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
179
|
+
- Revert "chore: upgrade @apollo/client"
|
|
180
|
+
([55ff24e](https://github.com/ho-nl/m2-pwa/commit/55ff24ede0e56c85b8095edadadd1ec5e0b1b8d2))
|
|
146
181
|
|
|
147
182
|
## 2.0.8 (2020-10-28)
|
|
148
183
|
|
|
149
|
-
|
|
150
184
|
### Bug Fixes
|
|
151
185
|
|
|
152
|
-
|
|
153
|
-
|
|
186
|
+
- make sure themes extensions are found
|
|
187
|
+
([5aa18db](https://github.com/ho-nl/m2-pwa/commit/5aa18db514fd2e2f50681367e39523f8e742ece0))
|
|
154
188
|
|
|
155
189
|
### Features
|
|
156
190
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
191
|
+
- added generated graphql.ts files
|
|
192
|
+
([3e44415](https://github.com/ho-nl/m2-pwa/commit/3e44415b018e74b502e9e98479aa5e84041f337d))
|
|
193
|
+
- split into packages
|
|
194
|
+
([2ee7fd6](https://github.com/ho-nl/m2-pwa/commit/2ee7fd6c0056f467d114f04d92c6c0ddf622d151))
|
|
160
195
|
|
|
161
196
|
### BREAKING CHANGES
|
|
162
197
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
198
|
+
- huge folder structure refactor, please read README to reinstall
|
|
168
199
|
|
|
169
200
|
# Change Log
|
|
170
201
|
|
package/Money.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { useQuery } from '@
|
|
1
|
+
import { useQuery } from '@graphcommerce/graphql'
|
|
2
2
|
import React, { useMemo } from 'react'
|
|
3
3
|
import { MoneyFragment } from './Money.gql'
|
|
4
4
|
import { StoreConfigDocument } from './StoreConfig.gql'
|
|
5
5
|
|
|
6
6
|
export type MoneyProps = MoneyFragment & { round?: boolean }
|
|
7
7
|
|
|
8
|
-
export
|
|
8
|
+
export function Money({ currency, value, round = false }: MoneyProps) {
|
|
9
9
|
const { data: config } = useQuery(StoreConfigDocument)
|
|
10
10
|
const locale = config?.storeConfig?.locale
|
|
11
11
|
|
package/PageMeta.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useQuery } from '@
|
|
1
|
+
import { useQuery } from '@graphcommerce/graphql'
|
|
2
2
|
import {
|
|
3
3
|
PageMeta as NextPageMeta,
|
|
4
4
|
PageMetaProps as NextPageMetaProps,
|
|
@@ -9,7 +9,7 @@ type PageMetaProps = Pick<NextPageMetaProps, 'title' | 'metaDescription' | 'meta
|
|
|
9
9
|
canonical?: string
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export function PageMeta(props: PageMetaProps) {
|
|
13
13
|
const { title, canonical = '', ...pageMetaProps } = props
|
|
14
14
|
const config = useQuery(StoreConfigDocument)
|
|
15
15
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useQuery } from '@graphcommerce/graphql'
|
|
2
|
+
import {
|
|
3
|
+
GlobalHead as GlobalHeadBase,
|
|
4
|
+
GlobalHeadProps as GlobalHeadPropsBase,
|
|
5
|
+
} from '@graphcommerce/next-ui'
|
|
6
|
+
import { StoreConfigDocument } from '../../StoreConfig.gql'
|
|
7
|
+
|
|
8
|
+
export type GlobalHeadProps = Omit<GlobalHeadPropsBase, 'name'>
|
|
9
|
+
|
|
10
|
+
export function GlobalHead(props: GlobalHeadProps) {
|
|
11
|
+
const name = useQuery(StoreConfigDocument).data?.storeConfig?.website_name ?? ''
|
|
12
|
+
return <GlobalHeadBase name={name} {...props} />
|
|
13
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useQuery } from '@graphcommerce/graphql'
|
|
2
|
+
import { FlagAvatar, extendableComponent } from '@graphcommerce/next-ui'
|
|
3
|
+
import { Button, SxProps, Theme } from '@mui/material'
|
|
4
|
+
import PageLink from 'next/link'
|
|
5
|
+
import { StoreConfigDocument } from '../../StoreConfig.gql'
|
|
6
|
+
|
|
7
|
+
export type StoreSwitcherButtonProps = { sx?: SxProps<Theme> }
|
|
8
|
+
|
|
9
|
+
const name = 'StoreSwitcherButton' as const
|
|
10
|
+
const parts = ['root', 'avatar'] as const
|
|
11
|
+
const { classes } = extendableComponent(name, parts)
|
|
12
|
+
|
|
13
|
+
export function StoreSwitcherButton(props: StoreSwitcherButtonProps) {
|
|
14
|
+
const { sx } = props
|
|
15
|
+
const config = useQuery(StoreConfigDocument)
|
|
16
|
+
const country = config.data?.storeConfig?.locale?.split('_')?.[1]?.toLowerCase() ?? ''
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<PageLink href='/switch-stores' passHref>
|
|
20
|
+
<Button variant='text' size='medium' className={classes.root} sx={sx}>
|
|
21
|
+
<FlagAvatar
|
|
22
|
+
country={country}
|
|
23
|
+
className={classes.avatar}
|
|
24
|
+
sx={{ height: 20, width: 20, marginRight: '10px' }}
|
|
25
|
+
/>
|
|
26
|
+
{config.data?.storeConfig?.store_name} - {config.data?.storeConfig?.base_currency_code}
|
|
27
|
+
</Button>
|
|
28
|
+
</PageLink>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
File without changes
|
|
@@ -1,51 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { extendableComponent, FlagAvatar } from '@graphcommerce/next-ui'
|
|
2
2
|
import {
|
|
3
3
|
List,
|
|
4
4
|
ListItem,
|
|
5
5
|
ListItemText,
|
|
6
|
-
makeStyles,
|
|
7
|
-
Theme,
|
|
8
6
|
Collapse,
|
|
9
7
|
ListItemAvatar,
|
|
10
|
-
|
|
8
|
+
SxProps,
|
|
9
|
+
Theme,
|
|
10
|
+
} from '@mui/material'
|
|
11
11
|
import PageLink from 'next/link'
|
|
12
12
|
import React from 'react'
|
|
13
|
-
import { localeToStore, storeToLocale } from '
|
|
13
|
+
import { localeToStore, storeToLocale } from '../../localeToStore'
|
|
14
14
|
import { StoreSwitcherListQuery } from './StoreSwitcherList.gql'
|
|
15
15
|
|
|
16
|
-
const useStyles = makeStyles(
|
|
17
|
-
(theme: Theme) => ({
|
|
18
|
-
list: {},
|
|
19
|
-
listItem: {
|
|
20
|
-
borderTop: `1px solid ${theme.palette.divider}`,
|
|
21
|
-
cursor: 'pointer',
|
|
22
|
-
},
|
|
23
|
-
listItemIndented: {
|
|
24
|
-
paddingLeft: 30,
|
|
25
|
-
cursor: 'pointer',
|
|
26
|
-
},
|
|
27
|
-
groupIcon: {
|
|
28
|
-
fontSize: 29,
|
|
29
|
-
lineHeight: 1,
|
|
30
|
-
minWidth: 40,
|
|
31
|
-
color: theme.palette.text.primary,
|
|
32
|
-
},
|
|
33
|
-
avatar: {
|
|
34
|
-
width: 30,
|
|
35
|
-
height: 30,
|
|
36
|
-
},
|
|
37
|
-
}),
|
|
38
|
-
{ name: 'StoreSwitcherList' },
|
|
39
|
-
)
|
|
40
|
-
|
|
41
16
|
type Store = NonNullable<NonNullable<StoreSwitcherListQuery['availableStores']>[0]>
|
|
42
17
|
|
|
43
|
-
export type StoreSwitcherListProps = {
|
|
44
|
-
|
|
18
|
+
export type StoreSwitcherListProps = {
|
|
19
|
+
locale: string | undefined
|
|
20
|
+
sx?: SxProps<Theme>
|
|
21
|
+
} & StoreSwitcherListQuery
|
|
22
|
+
|
|
23
|
+
const name = 'StoreSwitcherList' as const
|
|
24
|
+
const parts = ['list', 'listItem', 'listItemIndented', 'avatar'] as const
|
|
25
|
+
const { classes } = extendableComponent(name, parts)
|
|
45
26
|
|
|
46
|
-
export
|
|
47
|
-
const { availableStores, locale } = props
|
|
48
|
-
const classes = useStyles(props)
|
|
27
|
+
export function StoreSwitcherList(props: StoreSwitcherListProps) {
|
|
28
|
+
const { availableStores, locale, sx } = props
|
|
49
29
|
|
|
50
30
|
const groupedStores = Object.entries(
|
|
51
31
|
(availableStores ?? []).reduce<{
|
|
@@ -62,7 +42,7 @@ export default function StoreSwitcherList(props: StoreSwitcherListProps) {
|
|
|
62
42
|
)
|
|
63
43
|
|
|
64
44
|
return (
|
|
65
|
-
<List className={classes.list}>
|
|
45
|
+
<List className={classes.list} sx={sx}>
|
|
66
46
|
{groupedStores.map(([code, group]) => (
|
|
67
47
|
<React.Fragment key={code}>
|
|
68
48
|
<PageLink
|
|
@@ -81,9 +61,17 @@ export default function StoreSwitcherList(props: StoreSwitcherListProps) {
|
|
|
81
61
|
}
|
|
82
62
|
color='inherit'
|
|
83
63
|
className={classes.listItem}
|
|
64
|
+
sx={(theme) => ({
|
|
65
|
+
borderTop: `1px solid ${theme.palette.divider}`,
|
|
66
|
+
cursor: 'pointer',
|
|
67
|
+
})}
|
|
84
68
|
>
|
|
85
69
|
<ListItemAvatar>
|
|
86
|
-
<FlagAvatar
|
|
70
|
+
<FlagAvatar
|
|
71
|
+
country={code}
|
|
72
|
+
className={classes.avatar}
|
|
73
|
+
sx={{ width: 30, height: 30 }}
|
|
74
|
+
/>
|
|
87
75
|
</ListItemAvatar>
|
|
88
76
|
<ListItemText>
|
|
89
77
|
{group.name}
|
|
@@ -113,6 +101,10 @@ export default function StoreSwitcherList(props: StoreSwitcherListProps) {
|
|
|
113
101
|
selected={localeToStore(locale) === store.locale}
|
|
114
102
|
color='inherit'
|
|
115
103
|
className={classes.listItemIndented}
|
|
104
|
+
sx={{
|
|
105
|
+
paddingLeft: '30px',
|
|
106
|
+
cursor: 'pointer',
|
|
107
|
+
}}
|
|
116
108
|
>
|
|
117
109
|
<ListItemText inset>
|
|
118
110
|
{store.store_name}
|
package/hooks/useFindCountry.ts
CHANGED
package/index.ts
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './components/GlobalHead/GlobalHead'
|
|
2
|
+
export * from './hooks/useFindCountry'
|
|
3
|
+
export * from './hooks/useFindRegion'
|
|
4
4
|
export * from './link/createStoreLink'
|
|
5
|
-
|
|
6
|
-
export { default as StoreSwitcherButton } from './switcher/StoreSwitcherButton'
|
|
7
|
-
export * from './switcher/StoreSwitcherButton'
|
|
8
|
-
|
|
9
|
-
export { default as StoreSwitcherList } from './switcher/StoreSwitcherList'
|
|
10
|
-
export * from './switcher/StoreSwitcherList'
|
|
11
|
-
export * from './switcher/StoreSwitcherList.gql'
|
|
12
|
-
|
|
5
|
+
export * from './localeToStore'
|
|
13
6
|
export * from './Money'
|
|
14
|
-
export { default as Money } from './Money'
|
|
15
|
-
|
|
16
7
|
export * from './Money.gql'
|
|
17
|
-
|
|
8
|
+
export * from './PageMeta'
|
|
18
9
|
export * from './queries/CountryRegions.gql'
|
|
19
|
-
|
|
20
|
-
export * from './
|
|
21
|
-
export * from './
|
|
10
|
+
export * from './StoreConfig.gql'
|
|
11
|
+
export * from './components/StoreSwitcherButton/StoreSwitcherButton'
|
|
12
|
+
export * from './components/StoreSwitcherList/StoreSwitcherList'
|
|
13
|
+
export * from './components/StoreSwitcherList/StoreSwitcherList.gql'
|
package/link/createStoreLink.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { setContext } from '@
|
|
1
|
+
import { setContext } from '@graphcommerce/graphql'
|
|
2
2
|
import { localeToStore } from '../localeToStore'
|
|
3
3
|
|
|
4
4
|
/** Apollo link to set the store header in the context */
|
|
5
|
-
export const createStoreLink = (locale
|
|
5
|
+
export const createStoreLink = (locale?: string) =>
|
|
6
6
|
setContext((_, context) => {
|
|
7
7
|
if (!context.headers) context.headers = {}
|
|
8
8
|
context.headers.store = localeToStore(locale)
|
package/localeToStore.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphcommerce/magento-store",
|
|
3
|
-
"
|
|
3
|
+
"homepage": "https://www.graphcommerce.org/",
|
|
4
|
+
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
+
"version": "4.0.1",
|
|
4
6
|
"sideEffects": false,
|
|
5
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
6
|
-
"browserslist": [
|
|
7
|
-
"extends @graphcommerce/browserslist-config-pwa"
|
|
8
|
-
],
|
|
9
8
|
"eslintConfig": {
|
|
10
9
|
"extends": "@graphcommerce/eslint-config-pwa",
|
|
11
10
|
"parserOptions": {
|
|
@@ -13,24 +12,20 @@
|
|
|
13
12
|
}
|
|
14
13
|
},
|
|
15
14
|
"devDependencies": {
|
|
16
|
-
"@graphcommerce/
|
|
17
|
-
"@graphcommerce/
|
|
18
|
-
"@graphcommerce/
|
|
19
|
-
"@
|
|
20
|
-
"@playwright/test": "^1.17.1"
|
|
15
|
+
"@graphcommerce/eslint-config-pwa": "^4.0.1",
|
|
16
|
+
"@graphcommerce/prettier-config-pwa": "^4.0.1",
|
|
17
|
+
"@graphcommerce/typescript-config-pwa": "^4.0.1",
|
|
18
|
+
"@playwright/test": "^1.18.1"
|
|
21
19
|
},
|
|
22
20
|
"dependencies": {
|
|
23
|
-
"@
|
|
24
|
-
"@graphcommerce/
|
|
25
|
-
"@graphcommerce/
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
28
|
-
"
|
|
29
|
-
"@material-ui/lab": "^4.0.0-alpha.60",
|
|
30
|
-
"next": "^12.0.7",
|
|
21
|
+
"@graphcommerce/graphql": "^3.0.1",
|
|
22
|
+
"@graphcommerce/image": "^3.0.1",
|
|
23
|
+
"@graphcommerce/next-ui": "^4.0.1",
|
|
24
|
+
"@lingui/macro": "^3.13.2",
|
|
25
|
+
"@mui/material": "^5.4.1",
|
|
26
|
+
"next": "^12.0.10",
|
|
31
27
|
"react": "^17.0.2",
|
|
32
28
|
"react-dom": "^17.0.2",
|
|
33
|
-
"type-fest": "^2.
|
|
34
|
-
}
|
|
35
|
-
"gitHead": "110ddb032ee3ce6e363b9f5f7d21af71fb51b527"
|
|
29
|
+
"type-fest": "^2.11.2"
|
|
30
|
+
}
|
|
36
31
|
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useQuery } from '@apollo/client'
|
|
2
|
-
import { FlagAvatar, UseStyles } from '@graphcommerce/next-ui'
|
|
3
|
-
import { Button, makeStyles } from '@material-ui/core'
|
|
4
|
-
import PageLink from 'next/link'
|
|
5
|
-
import React from 'react'
|
|
6
|
-
import { StoreConfigDocument } from '../StoreConfig.gql'
|
|
7
|
-
|
|
8
|
-
const useStyles = makeStyles(
|
|
9
|
-
() => ({
|
|
10
|
-
avatar: {
|
|
11
|
-
height: 20,
|
|
12
|
-
width: 20,
|
|
13
|
-
marginRight: 10,
|
|
14
|
-
},
|
|
15
|
-
}),
|
|
16
|
-
{ name: 'StoreSwitcherButton' },
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
export type StoreSwitcherButtonProps = UseStyles<typeof useStyles>
|
|
20
|
-
|
|
21
|
-
export default function StoreSwitcherButton(props) {
|
|
22
|
-
const config = useQuery(StoreConfigDocument)
|
|
23
|
-
const country = config.data?.storeConfig?.locale?.split('_')?.[1]?.toLowerCase() ?? ''
|
|
24
|
-
|
|
25
|
-
const classes = useStyles(props)
|
|
26
|
-
return (
|
|
27
|
-
<PageLink href='/switch-stores' passHref>
|
|
28
|
-
<Button variant='text' size='medium'>
|
|
29
|
-
<FlagAvatar country={country} classes={{ root: classes.avatar }} />
|
|
30
|
-
{config.data?.storeConfig?.store_name} - {config.data?.storeConfig?.base_currency_code}
|
|
31
|
-
</Button>
|
|
32
|
-
</PageLink>
|
|
33
|
-
)
|
|
34
|
-
}
|