@graphcommerce/magento-store 3.4.12 → 4.0.2
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 +157 -96
- 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 +18 -21
- 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,231 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
3
|
+
## 4.0.2
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Features
|
|
5
|
+
### Patch Changes
|
|
10
6
|
|
|
11
|
-
|
|
7
|
+
- [#1276](https://github.com/ho-nl/m2-pwa/pull/1276)
|
|
8
|
+
[`ce09388e0`](https://github.com/ho-nl/m2-pwa/commit/ce09388e0d7ef33aee660612340f6fbae15ceec2)
|
|
9
|
+
Thanks [@paales](https://github.com/paales)! - We've moved lots of internal packages from
|
|
10
|
+
`dependencies` to `peerDependencies`. The result of this is that there will be significantly less
|
|
11
|
+
duplicate packages in the node_modules folders.
|
|
12
12
|
|
|
13
|
+
* [#1276](https://github.com/ho-nl/m2-pwa/pull/1276)
|
|
14
|
+
[`52a45bba4`](https://github.com/ho-nl/m2-pwa/commit/52a45bba4dc6dd6df3c81f5023df7d23ed8a534d)
|
|
15
|
+
Thanks [@paales](https://github.com/paales)! - Upgraded to
|
|
16
|
+
[NextJS 12.1](https://nextjs.org/blog/next-12-1)! This is just for compatibility, but we'll be
|
|
17
|
+
implementing
|
|
18
|
+
[On-demand Incremental Static Regeneration](https://nextjs.org/blog/next-12-1#on-demand-incremental-static-regeneration-beta)
|
|
19
|
+
soon.
|
|
13
20
|
|
|
21
|
+
This will greatly reduce the requirement to rebuid stuff and we'll add a management UI on the
|
|
22
|
+
frontend to be able to revalidate pages manually.
|
|
14
23
|
|
|
24
|
+
* Updated dependencies
|
|
25
|
+
[[`381e4c86a`](https://github.com/ho-nl/m2-pwa/commit/381e4c86a8321ce96e1fa5c7d3c0a0c0ff3e02c7),
|
|
26
|
+
[`ce09388e0`](https://github.com/ho-nl/m2-pwa/commit/ce09388e0d7ef33aee660612340f6fbae15ceec2),
|
|
27
|
+
[`e7c8e2756`](https://github.com/ho-nl/m2-pwa/commit/e7c8e2756d637cbcd2e793d62ef5721d35d9fa7b),
|
|
28
|
+
[`52a45bba4`](https://github.com/ho-nl/m2-pwa/commit/52a45bba4dc6dd6df3c81f5023df7d23ed8a534d)]:
|
|
29
|
+
- @graphcommerce/next-ui@4.1.1
|
|
30
|
+
- @graphcommerce/graphql@3.0.2
|
|
31
|
+
- @graphcommerce/image@3.0.2
|
|
15
32
|
|
|
33
|
+
## 4.0.1
|
|
16
34
|
|
|
17
|
-
|
|
18
|
-
|
|
35
|
+
### Patch Changes
|
|
19
36
|
|
|
20
|
-
|
|
37
|
+
- [`0cbaa878b`](https://github.com/ho-nl/m2-pwa/commit/0cbaa878b8a844d5abbeb1797b625a33130e6514)
|
|
38
|
+
Thanks [@paales](https://github.com/paales)! - Added homepage and repository package.json files,
|
|
39
|
+
so that the packages link to back to the website and repository
|
|
40
|
+
- Updated dependencies
|
|
41
|
+
[[`0cbaa878b`](https://github.com/ho-nl/m2-pwa/commit/0cbaa878b8a844d5abbeb1797b625a33130e6514)]:
|
|
42
|
+
- @graphcommerce/graphql@3.0.1
|
|
43
|
+
- @graphcommerce/image@3.0.1
|
|
44
|
+
- @graphcommerce/next-ui@4.0.1
|
|
21
45
|
|
|
22
|
-
|
|
46
|
+
## 4.0.0
|
|
23
47
|
|
|
48
|
+
### Major Changes
|
|
24
49
|
|
|
50
|
+
- [#1258](https://github.com/ho-nl/m2-pwa/pull/1258)
|
|
51
|
+
[`ad36382a4`](https://github.com/ho-nl/m2-pwa/commit/ad36382a4d55d83d9e47b7eb6a02671a2a631a05)
|
|
52
|
+
Thanks [@paales](https://github.com/paales)! - Upgraded to Material UI 5
|
|
25
53
|
|
|
54
|
+
### Patch Changes
|
|
26
55
|
|
|
56
|
+
- Updated dependencies
|
|
57
|
+
[[`ad36382a4`](https://github.com/ho-nl/m2-pwa/commit/ad36382a4d55d83d9e47b7eb6a02671a2a631a05)]:
|
|
58
|
+
- @graphcommerce/graphql@3.0.0
|
|
59
|
+
- @graphcommerce/image@3.0.0
|
|
60
|
+
- @graphcommerce/next-ui@4.0.0
|
|
27
61
|
|
|
28
|
-
|
|
62
|
+
All notable changes to this project will be documented in this file. See
|
|
63
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
29
64
|
|
|
65
|
+
# [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)
|
|
30
66
|
|
|
31
67
|
### Features
|
|
32
68
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
69
|
+
- **framer-next-pages:** reduce rerenders when navigating to a new page
|
|
70
|
+
([5cf3301](https://github.com/ho-nl/m2-pwa/commit/5cf330130bb3527057da015e3c4a6fa295d7262e))
|
|
36
71
|
|
|
72
|
+
## [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)
|
|
37
73
|
|
|
74
|
+
### Bug Fixes
|
|
38
75
|
|
|
39
|
-
|
|
76
|
+
- use Locale to set storeSwitcher icons
|
|
77
|
+
([65ea397](https://github.com/ho-nl/m2-pwa/commit/65ea397ec53aa27f545b43feda8e35227e119ebe))
|
|
40
78
|
|
|
79
|
+
# [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)
|
|
41
80
|
|
|
42
81
|
### Features
|
|
43
82
|
|
|
44
|
-
|
|
45
|
-
|
|
83
|
+
- added tons of translations
|
|
84
|
+
([9bb0ac7](https://github.com/ho-nl/m2-pwa/commit/9bb0ac709b58df6ea6141e92e4923a5ca9ae2963))
|
|
46
85
|
|
|
86
|
+
# [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)
|
|
47
87
|
|
|
88
|
+
### Features
|
|
48
89
|
|
|
90
|
+
- darkTheme
|
|
91
|
+
([968f4f1](https://github.com/ho-nl/m2-pwa/commit/968f4f1360417bf7daa36454c19e6bc5cf53ae90))
|
|
49
92
|
|
|
50
93
|
# [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
94
|
|
|
52
|
-
|
|
53
95
|
### Features
|
|
54
96
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
97
|
+
- **nextjs:** upgraded to nextjs 12
|
|
98
|
+
([9331bc8](https://github.com/ho-nl/m2-pwa/commit/9331bc801f6419522115cc47d291d49d608d5a90))
|
|
60
99
|
|
|
61
100
|
## [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
101
|
|
|
63
|
-
|
|
64
102
|
### Bug Fixes
|
|
65
103
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
104
|
+
- compatibility with venia theme
|
|
105
|
+
([c0bcdd5](https://github.com/ho-nl/m2-pwa/commit/c0bcdd511de5679f185f0984816b1f0cafa449e0))
|
|
71
106
|
|
|
72
107
|
## [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
108
|
|
|
74
|
-
|
|
75
109
|
### Bug Fixes
|
|
76
110
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
111
|
+
- with the latest version of graphql codegen the preresovled types inlined Maybe, make sure we
|
|
112
|
+
reflect that
|
|
113
|
+
([7cb27b0](https://github.com/ho-nl/m2-pwa/commit/7cb27b04cbe31bee5ef4000d408f08bc9ac505c5))
|
|
82
114
|
|
|
83
115
|
## [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
116
|
|
|
85
117
|
**Note:** Version bump only for package @graphcommerce/magento-store
|
|
86
118
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
119
|
# 3.0.0 (2021-09-27)
|
|
92
120
|
|
|
93
|
-
|
|
94
121
|
### Bug Fixes
|
|
95
122
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
123
|
+
- canonical urls
|
|
124
|
+
([9ff8d3f](https://github.com/ho-nl/m2-pwa/commit/9ff8d3f950098fb28440f31f5dd93a835dce0bda))
|
|
125
|
+
- change href's from faq to service
|
|
126
|
+
([cb9875b](https://github.com/ho-nl/m2-pwa/commit/cb9875bce43db5953f227ee60f8d5dfe339f50b5))
|
|
127
|
+
- code consistency
|
|
128
|
+
([a310f0e](https://github.com/ho-nl/m2-pwa/commit/a310f0e548907c044b016b9473641ecd378b313f))
|
|
129
|
+
- **country-switcher:** navigate back to correct locale
|
|
130
|
+
([579d146](https://github.com/ho-nl/m2-pwa/commit/579d146e1b658a343b1514d8e8a45c01a507c084))
|
|
131
|
+
- duplicated (meta) tags in document head
|
|
132
|
+
([d52e962](https://github.com/ho-nl/m2-pwa/commit/d52e9629036ccab1f266ddd01600a0bd45930149))
|
|
133
|
+
- footer country flag
|
|
134
|
+
([8c6bf20](https://github.com/ho-nl/m2-pwa/commit/8c6bf206f85d44289a8d11d9bcd2178af6cc3445))
|
|
135
|
+
- get more data from store locale
|
|
136
|
+
([455245c](https://github.com/ho-nl/m2-pwa/commit/455245cf88d4a0cfbe197c97739306af8d8ff211))
|
|
137
|
+
- ignore md files from triggering version updates
|
|
138
|
+
([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
|
|
139
|
+
- implement next-ui barrel imports
|
|
140
|
+
([75bea70](https://github.com/ho-nl/m2-pwa/commit/75bea703dba898f18a2a1dfa3243ebd0a4e6f0e1))
|
|
141
|
+
- lint error
|
|
142
|
+
([be542af](https://github.com/ho-nl/m2-pwa/commit/be542afc466209c79cb776aac494abb7cab24bf7))
|
|
143
|
+
- **magento-store:** move useCountry/useRegion to magento-store and rename to
|
|
144
|
+
useFindCountry/useFindRegion
|
|
145
|
+
([3fed1c5](https://github.com/ho-nl/m2-pwa/commit/3fed1c53f975977e2681a9b80bb283332d9ad5ec))
|
|
146
|
+
- make storeswitcher a button
|
|
147
|
+
([a7dc452](https://github.com/ho-nl/m2-pwa/commit/a7dc45297e565be9c5d72c03e3d8c4a61c415c8a))
|
|
148
|
+
- prices wouldn’t render if the price wasn’t an integer
|
|
149
|
+
([0866881](https://github.com/ho-nl/m2-pwa/commit/08668813699065b168e3d9b1fe2410c5cd073c89))
|
|
150
|
+
- prop types
|
|
151
|
+
([caccb1a](https://github.com/ho-nl/m2-pwa/commit/caccb1ab4c459642b64498dde22c372fd890f0c7))
|
|
152
|
+
- remove button from store-switcher in footer
|
|
153
|
+
([43f6d52](https://github.com/ho-nl/m2-pwa/commit/43f6d5227edff809effa46b658afc0d3c4268f3f))
|
|
154
|
+
- remove canonical metatag when no canonical is given
|
|
155
|
+
([167b7f0](https://github.com/ho-nl/m2-pwa/commit/167b7f080f98a10ff35cbd760b24b8198aac6518))
|
|
156
|
+
- search not submitting after empying the field
|
|
157
|
+
([a15b5cf](https://github.com/ho-nl/m2-pwa/commit/a15b5cf94f4619e0087c8871a98617ab160f671a))
|
|
158
|
+
- secure base link url in store config
|
|
159
|
+
([ecba5c2](https://github.com/ho-nl/m2-pwa/commit/ecba5c2b2c109b027916872ca860c566b031d8a4))
|
|
160
|
+
- since all links are of next/link we need to add passHref for custom components
|
|
161
|
+
([16fb931](https://github.com/ho-nl/m2-pwa/commit/16fb93100d367203ea79bb4f93357221253f2ecd))
|
|
162
|
+
- yarn workspace packages hot reload
|
|
163
|
+
([d03fc9f](https://github.com/ho-nl/m2-pwa/commit/d03fc9fdda3486476761786f2b56a934cc92befc))
|
|
117
164
|
|
|
118
165
|
### Features
|
|
119
166
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
167
|
+
- add getFilterTypes to shared client, faster generation
|
|
168
|
+
([beccfde](https://github.com/ho-nl/m2-pwa/commit/beccfde6ebc8aaf6223f0e8b33fabf4f5039efed))
|
|
169
|
+
- added footer buttons
|
|
170
|
+
([65610cc](https://github.com/ho-nl/m2-pwa/commit/65610cc1db2929b9203a3b7b25375a8324bc8ce9))
|
|
171
|
+
- added store switcher route
|
|
172
|
+
([64b04b3](https://github.com/ho-nl/m2-pwa/commit/64b04b3c1488c93395b228ac04c9d3c3912391a2))
|
|
173
|
+
- better 404 handling and simplified getStaticProps
|
|
174
|
+
([321ace1](https://github.com/ho-nl/m2-pwa/commit/321ace1850642ee3eddfa674c37e6fca8adcdb74))
|
|
175
|
+
- canonical urls using abstract page meta component
|
|
176
|
+
([5f09b6f](https://github.com/ho-nl/m2-pwa/commit/5f09b6f89f4c39f5465869b86468c384de73faba))
|
|
177
|
+
- created stacked-pages package
|
|
178
|
+
([d86008e](https://github.com/ho-nl/m2-pwa/commit/d86008ee659ccb25b194a41d624b394a1ddbd088))
|
|
179
|
+
- **graphql:** introduced new graphql package that holds all generated files
|
|
180
|
+
([a3e7aa0](https://github.com/ho-nl/m2-pwa/commit/a3e7aa05540540533b5ced9a95f1f802ecbe499f))
|
|
181
|
+
- i18n routing added (/ and /fr for demo)
|
|
182
|
+
([bb3b339](https://github.com/ho-nl/m2-pwa/commit/bb3b339fbc9fceddd264a891ad81f00327a241ae))
|
|
183
|
+
- **image:** introduced completely rewritten Image component
|
|
184
|
+
([e3413b3](https://github.com/ho-nl/m2-pwa/commit/e3413b3a57392d6571ea64cb8d9c8dca05ea31df))
|
|
185
|
+
- introduces framer-next-pages and framer-sheet to next-ui and soxbase package
|
|
186
|
+
([e04ad8a](https://github.com/ho-nl/m2-pwa/commit/e04ad8a94cd1fd5a7c5575c9db7916b6e8a88f16))
|
|
187
|
+
- major performance refactor
|
|
188
|
+
([03f8e2f](https://github.com/ho-nl/m2-pwa/commit/03f8e2fa16ef919bd6bd6eadd36922d0245ed960))
|
|
189
|
+
- move to category_uid instead of category_id
|
|
190
|
+
([a2efe8d](https://github.com/ho-nl/m2-pwa/commit/a2efe8daac6ebe949070108fc4bcf8cc0919c1c7))
|
|
191
|
+
- next.js 11
|
|
192
|
+
([7d61407](https://github.com/ho-nl/m2-pwa/commit/7d614075a778f488045034f74be4f75b93f63c43))
|
|
193
|
+
- **playwright:** added new playwright package to enable browser testing
|
|
194
|
+
([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
|
|
195
|
+
- renamed all packages to use [@graphcommerce](https://github.com/graphcommerce) instead of
|
|
196
|
+
[@reachdigital](https://github.com/reachdigital)
|
|
197
|
+
([491e4ce](https://github.com/ho-nl/m2-pwa/commit/491e4cec9a2686472dac36b79f999257c0811ffe))
|
|
198
|
+
- support reviews store config variables
|
|
199
|
+
([532e849](https://github.com/ho-nl/m2-pwa/commit/532e84926c97affcd21ade56773bc06a02060b3a))
|
|
200
|
+
- upgrade to node 14
|
|
201
|
+
([d079a75](https://github.com/ho-nl/m2-pwa/commit/d079a751e9bfd8dc7f5009d2c9f31c336a0c96ab))
|
|
202
|
+
- upgraded to nextjs 11
|
|
203
|
+
([0053beb](https://github.com/ho-nl/m2-pwa/commit/0053beb7ef597c190add7264256a0eaec35868da))
|
|
204
|
+
- useFormMutationCart and simpler imports
|
|
205
|
+
([012f090](https://github.com/ho-nl/m2-pwa/commit/012f090e8f54d09f35d393c61ad1e2319f5a90ff))
|
|
140
206
|
|
|
141
207
|
### Reverts
|
|
142
208
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
209
|
+
- Revert "chore: upgrade @apollo/client"
|
|
210
|
+
([55ff24e](https://github.com/ho-nl/m2-pwa/commit/55ff24ede0e56c85b8095edadadd1ec5e0b1b8d2))
|
|
146
211
|
|
|
147
212
|
## 2.0.8 (2020-10-28)
|
|
148
213
|
|
|
149
|
-
|
|
150
214
|
### Bug Fixes
|
|
151
215
|
|
|
152
|
-
|
|
153
|
-
|
|
216
|
+
- make sure themes extensions are found
|
|
217
|
+
([5aa18db](https://github.com/ho-nl/m2-pwa/commit/5aa18db514fd2e2f50681367e39523f8e742ece0))
|
|
154
218
|
|
|
155
219
|
### Features
|
|
156
220
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
221
|
+
- added generated graphql.ts files
|
|
222
|
+
([3e44415](https://github.com/ho-nl/m2-pwa/commit/3e44415b018e74b502e9e98479aa5e84041f337d))
|
|
223
|
+
- split into packages
|
|
224
|
+
([2ee7fd6](https://github.com/ho-nl/m2-pwa/commit/2ee7fd6c0056f467d114f04d92c6c0ddf622d151))
|
|
160
225
|
|
|
161
226
|
### BREAKING CHANGES
|
|
162
227
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
228
|
+
- huge folder structure refactor, please read README to reinstall
|
|
168
229
|
|
|
169
230
|
# Change Log
|
|
170
231
|
|
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.2",
|
|
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,22 @@
|
|
|
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.2",
|
|
16
|
+
"@graphcommerce/prettier-config-pwa": "^4.0.1",
|
|
17
|
+
"@graphcommerce/typescript-config-pwa": "^4.0.1",
|
|
18
|
+
"@playwright/test": "^1.19.1"
|
|
21
19
|
},
|
|
22
20
|
"dependencies": {
|
|
23
|
-
"@
|
|
24
|
-
"@graphcommerce/
|
|
25
|
-
"@graphcommerce/
|
|
26
|
-
"
|
|
27
|
-
"@lingui/macro": "^3.13.0",
|
|
28
|
-
"@material-ui/core": "^4.12.3",
|
|
29
|
-
"@material-ui/lab": "^4.0.0-alpha.60",
|
|
30
|
-
"next": "^12.0.7",
|
|
31
|
-
"react": "^17.0.2",
|
|
32
|
-
"react-dom": "^17.0.2",
|
|
33
|
-
"type-fest": "^2.8.0"
|
|
21
|
+
"@graphcommerce/graphql": "^3.0.2",
|
|
22
|
+
"@graphcommerce/image": "^3.0.2",
|
|
23
|
+
"@graphcommerce/next-ui": "^4.1.1",
|
|
24
|
+
"type-fest": "^2.11.2"
|
|
34
25
|
},
|
|
35
|
-
"
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@lingui/macro": "^3.13.2",
|
|
28
|
+
"@mui/material": "^5.4.1",
|
|
29
|
+
"next": "^12.0.10",
|
|
30
|
+
"react": "^17.0.2",
|
|
31
|
+
"react-dom": "^17.0.2"
|
|
32
|
+
}
|
|
36
33
|
}
|
|
@@ -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
|
-
}
|