@faststore/core 2.1.5 → 2.1.9

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 (154) hide show
  1. package/.turbo/turbo-build.log +17 -8
  2. package/cms/faststore/sections.json +131 -7
  3. package/package.json +10 -8
  4. package/src/components/sections/BannerNewsletter/BannerNewsletter.tsx +27 -19
  5. package/src/components/sections/Newsletter/Newsletter.tsx +68 -122
  6. package/src/components/ui/Newsletter/Newsletter.tsx +198 -0
  7. package/src/components/ui/Newsletter/index.ts +2 -0
  8. package/.next/BUILD_ID +0 -1
  9. package/.next/build-manifest.json +0 -123
  10. package/.next/cache/.tsbuildinfo +0 -1
  11. package/.next/cache/config.json +0 -7
  12. package/.next/cache/eslint/.cache_1gneedd +0 -1
  13. package/.next/cache/next-server.js.nft.json +0 -1
  14. package/.next/cache/webpack/client-production/0.pack +0 -0
  15. package/.next/cache/webpack/client-production/index.pack +0 -0
  16. package/.next/cache/webpack/server-production/0.pack +0 -0
  17. package/.next/cache/webpack/server-production/index.pack +0 -0
  18. package/.next/export-marker.json +0 -1
  19. package/.next/images-manifest.json +0 -1
  20. package/.next/next-server.js.nft.json +0 -1
  21. package/.next/package.json +0 -1
  22. package/.next/prerender-manifest.json +0 -1
  23. package/.next/react-loadable-manifest.json +0 -44
  24. package/.next/required-server-files.json +0 -1
  25. package/.next/routes-manifest.json +0 -1
  26. package/.next/server/chunks/123.js +0 -58
  27. package/.next/server/chunks/143.js +0 -106
  28. package/.next/server/chunks/183.js +0 -90
  29. package/.next/server/chunks/184.js +0 -61
  30. package/.next/server/chunks/205.js +0 -722
  31. package/.next/server/chunks/247.js +0 -61
  32. package/.next/server/chunks/253.js +0 -535
  33. package/.next/server/chunks/269.js +0 -516
  34. package/.next/server/chunks/287.js +0 -58
  35. package/.next/server/chunks/289.js +0 -242
  36. package/.next/server/chunks/312.js +0 -697
  37. package/.next/server/chunks/350.js +0 -143
  38. package/.next/server/chunks/378.js +0 -326
  39. package/.next/server/chunks/487.js +0 -9142
  40. package/.next/server/chunks/502.js +0 -626
  41. package/.next/server/chunks/513.js +0 -257
  42. package/.next/server/chunks/576.js +0 -90
  43. package/.next/server/chunks/597.js +0 -211
  44. package/.next/server/chunks/650.js +0 -9142
  45. package/.next/server/chunks/676.js +0 -32
  46. package/.next/server/chunks/701.js +0 -87
  47. package/.next/server/chunks/74.js +0 -3949
  48. package/.next/server/chunks/825.js +0 -4039
  49. package/.next/server/chunks/854.js +0 -72
  50. package/.next/server/chunks/859.js +0 -959
  51. package/.next/server/chunks/886.js +0 -120
  52. package/.next/server/chunks/907.js +0 -1957
  53. package/.next/server/chunks/98.js +0 -124
  54. package/.next/server/chunks/font-manifest.json +0 -1
  55. package/.next/server/font-manifest.json +0 -1
  56. package/.next/server/middleware-build-manifest.js +0 -1
  57. package/.next/server/middleware-manifest.json +0 -6
  58. package/.next/server/middleware-react-loadable-manifest.js +0 -1
  59. package/.next/server/pages/404.js +0 -386
  60. package/.next/server/pages/404.js.nft.json +0 -1
  61. package/.next/server/pages/500.js +0 -388
  62. package/.next/server/pages/500.js.nft.json +0 -1
  63. package/.next/server/pages/[...slug].js +0 -778
  64. package/.next/server/pages/[...slug].js.nft.json +0 -1
  65. package/.next/server/pages/[slug]/p.js +0 -2366
  66. package/.next/server/pages/[slug]/p.js.nft.json +0 -1
  67. package/.next/server/pages/_app.js +0 -281
  68. package/.next/server/pages/_app.js.nft.json +0 -1
  69. package/.next/server/pages/_document.js +0 -340
  70. package/.next/server/pages/_document.js.nft.json +0 -1
  71. package/.next/server/pages/_error.js +0 -164
  72. package/.next/server/pages/_error.js.nft.json +0 -1
  73. package/.next/server/pages/account.js +0 -363
  74. package/.next/server/pages/account.js.nft.json +0 -1
  75. package/.next/server/pages/api/graphql.js +0 -365
  76. package/.next/server/pages/api/graphql.js.nft.json +0 -1
  77. package/.next/server/pages/api/preview.js +0 -119
  78. package/.next/server/pages/api/preview.js.nft.json +0 -1
  79. package/.next/server/pages/checkout.js +0 -363
  80. package/.next/server/pages/checkout.js.nft.json +0 -1
  81. package/.next/server/pages/en-US/404.html +0 -81
  82. package/.next/server/pages/en-US/404.json +0 -1
  83. package/.next/server/pages/en-US/500.html +0 -81
  84. package/.next/server/pages/en-US/500.json +0 -1
  85. package/.next/server/pages/en-US/account.html +0 -81
  86. package/.next/server/pages/en-US/account.json +0 -1
  87. package/.next/server/pages/en-US/checkout.html +0 -81
  88. package/.next/server/pages/en-US/checkout.json +0 -1
  89. package/.next/server/pages/en-US/login.html +0 -81
  90. package/.next/server/pages/en-US/login.json +0 -1
  91. package/.next/server/pages/en-US/s.html +0 -81
  92. package/.next/server/pages/en-US/s.json +0 -1
  93. package/.next/server/pages/en-US.html +0 -81
  94. package/.next/server/pages/en-US.json +0 -1
  95. package/.next/server/pages/index.js +0 -1018
  96. package/.next/server/pages/index.js.nft.json +0 -1
  97. package/.next/server/pages/login.js +0 -368
  98. package/.next/server/pages/login.js.nft.json +0 -1
  99. package/.next/server/pages/s.js +0 -466
  100. package/.next/server/pages/s.js.nft.json +0 -1
  101. package/.next/server/pages-manifest.json +0 -16
  102. package/.next/server/webpack-api-runtime.js +0 -229
  103. package/.next/server/webpack-runtime.js +0 -229
  104. package/.next/static/OUMT7MGCINhxa5_BvNZPx/_buildManifest.js +0 -1
  105. package/.next/static/OUMT7MGCINhxa5_BvNZPx/_ssgManifest.js +0 -1
  106. package/.next/static/chunks/143.dd8a556e6957baa1.js +0 -1
  107. package/.next/static/chunks/234-7d72b0ee52936c13.js +0 -1
  108. package/.next/static/chunks/495.0ecd099878b2a36d.js +0 -1
  109. package/.next/static/chunks/502.ec90d1859d393d34.js +0 -1
  110. package/.next/static/chunks/597.f8d0595b113c70af.js +0 -1
  111. package/.next/static/chunks/64.7ea3677ac3a10e00.js +0 -1
  112. package/.next/static/chunks/651.7142f31ce1e052b3.js +0 -1
  113. package/.next/static/chunks/682-5cfea9ed52851ed1.js +0 -1
  114. package/.next/static/chunks/738-a5ff304828f20cbf.js +0 -1
  115. package/.next/static/chunks/741.52f7fb873418346f.js +0 -1
  116. package/.next/static/chunks/791-727eda8f766aa791.js +0 -1
  117. package/.next/static/chunks/98.97381d2021f86cd9.js +0 -1
  118. package/.next/static/chunks/framework-dfd14d7ce6600b03.js +0 -1
  119. package/.next/static/chunks/main-fd466221927468fd.js +0 -1
  120. package/.next/static/chunks/pages/404-c3b320b915df45bb.js +0 -1
  121. package/.next/static/chunks/pages/500-d37a3a2e931f6995.js +0 -1
  122. package/.next/static/chunks/pages/[...slug]-d4e0a671c6248369.js +0 -1
  123. package/.next/static/chunks/pages/[slug]/p-2ad8b84fd5d98814.js +0 -1
  124. package/.next/static/chunks/pages/_app-79d333aa6001a806.js +0 -1
  125. package/.next/static/chunks/pages/_error-a7a0c1d9bfbb4f38.js +0 -1
  126. package/.next/static/chunks/pages/account-86a1b6e7db03bab6.js +0 -1
  127. package/.next/static/chunks/pages/checkout-c77dbc66c0b35ec3.js +0 -1
  128. package/.next/static/chunks/pages/index-2912eeade1da43bf.js +0 -1
  129. package/.next/static/chunks/pages/login-bbf85bc59afce37c.js +0 -1
  130. package/.next/static/chunks/pages/s-dd486933e8ba7fbf.js +0 -1
  131. package/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js +0 -1
  132. package/.next/static/chunks/webpack-c5cf5350bcb7f6f4.js +0 -1
  133. package/.next/static/css/0f8ce5203de8ae6f.css +0 -1
  134. package/.next/static/css/104f0f3ce3be32c6.css +0 -1
  135. package/.next/static/css/23a9d5dfc051ec6e.css +0 -1
  136. package/.next/static/css/287f5ba239375052.css +0 -1
  137. package/.next/static/css/2e00f7ba49c754b3.css +0 -1
  138. package/.next/static/css/6e41f1b6078c14c1.css +0 -1
  139. package/.next/static/css/7d822a137c54a781.css +0 -1
  140. package/.next/static/css/c7fc1f563fa33060.css +0 -1
  141. package/.next/static/css/d4a0d9df8c6df555.css +0 -1
  142. package/.next/static/css/e02cdad8fc000339.css +0 -1
  143. package/.next/trace +0 -72
  144. package/public/~partytown/debug/partytown-atomics.js +0 -556
  145. package/public/~partytown/debug/partytown-media.js +0 -374
  146. package/public/~partytown/debug/partytown-sandbox-sw.js +0 -543
  147. package/public/~partytown/debug/partytown-sw.js +0 -59
  148. package/public/~partytown/debug/partytown-ww-atomics.js +0 -1789
  149. package/public/~partytown/debug/partytown-ww-sw.js +0 -1781
  150. package/public/~partytown/debug/partytown.js +0 -72
  151. package/public/~partytown/partytown-atomics.js +0 -2
  152. package/public/~partytown/partytown-media.js +0 -2
  153. package/public/~partytown/partytown-sw.js +0 -2
  154. package/public/~partytown/partytown.js +0 -2
@@ -7,10 +7,19 @@ This information is used to shape Next.js' roadmap and prioritize features.
7
7
  You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
8
8
  https://nextjs.org/telemetry
9
9
 
10
+ Browserslist: caniuse-lite is outdated. Please run:
11
+ npx browserslist@latest --update-db
12
+ Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
10
13
  info - Linting and checking validity of types...
11
14
  info - Creating an optimized production build...
12
15
  info - Disabled SWC as replacement for Babel because of custom Babel configuration ".babelrc" https://nextjs.org/docs/messages/swc-disabled
16
+ Browserslist: caniuse-lite is outdated. Please run:
17
+ npx browserslist@latest --update-db
18
+ Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
13
19
  info - Using external babel configuration from /home/runner/work/faststore/faststore/packages/core/.babelrc
20
+ Browserslist: caniuse-lite is outdated. Please run:
21
+ npx update-browserslist-db@latest
22
+ Why you should do it regularly: https://github.com/browserslist/update-db#readme
14
23
  info - Compiled successfully
15
24
  info - Collecting page data...
16
25
  info - Generating static pages (0/7)
@@ -21,18 +30,18 @@ info - Generating static pages (7/7)
21
30
  info - Finalizing page optimization...
22
31
 
23
32
  Route (pages) Size First Load JS
24
- ┌ ● / 3.47 kB 126 kB
25
- ├ └ css/c7fc1f563fa33060.css 7.18 kB
26
- ├ /_app 0 B 77.8 kB
27
- ├ ● /[...slug] 8.79 kB 134 kB
33
+ ┌ ● / 3.21 kB 197 kB
34
+ ├ └ css/0d62ff2d64099b84.css 6.47 kB
35
+ ├ /_app 0 B 77.9 kB
36
+ ├ ● /[...slug] 8.8 kB 134 kB
28
37
  ├ └ css/6e41f1b6078c14c1.css 7.9 kB
29
- ├ ● /[slug]/p 11.1 kB 134 kB
38
+ ├ ● /[slug]/p 11 kB 204 kB
30
39
  ├ └ css/0f8ce5203de8ae6f.css 11.2 kB
31
40
  ├ ○ /404 1.09 kB 113 kB
32
41
  ├ ● /500 1.11 kB 113 kB
33
42
  ├ ● /account 668 B 113 kB
34
- ├ λ /api/graphql 0 B 77.8 kB
35
- ├ λ /api/preview 0 B 77.8 kB
43
+ ├ λ /api/graphql 0 B 77.9 kB
44
+ ├ λ /api/preview 0 B 77.9 kB
36
45
  ├ ● /checkout 657 B 113 kB
37
46
  ├ ● /login 1.01 kB 113 kB
38
47
  └ ● /s 1.11 kB 126 kB
@@ -40,7 +49,7 @@ Route (pages) Size First Load JS
40
49
  ├ chunks/framework-dfd14d7ce6600b03.js 45.3 kB
41
50
  ├ chunks/main-fd466221927468fd.js 23.9 kB
42
51
  ├ chunks/pages/_app-79d333aa6001a806.js 6.38 kB
43
- ├ chunks/webpack-c5cf5350bcb7f6f4.js 2.21 kB
52
+ ├ chunks/webpack-3eefca84f4c29194.js 2.28 kB
44
53
  └ css/104f0f3ce3be32c6.css 2.79 kB
45
54
 
46
55
  λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
@@ -1033,7 +1033,10 @@
1033
1033
  },
1034
1034
  "privacyPolicy": {
1035
1035
  "title": "Privacy Policy Disclaimer",
1036
- "type": "string"
1036
+ "type": "string",
1037
+ "widget": {
1038
+ "ui:widget": "draftjs-rich-text"
1039
+ }
1037
1040
  },
1038
1041
  "emailInputLabel": {
1039
1042
  "title": "Email input label",
@@ -1054,6 +1057,66 @@
1054
1057
  "title": "Subscribe button label",
1055
1058
  "type": "string",
1056
1059
  "default": "Subscribe"
1060
+ },
1061
+ "subscribeButtonLoadingLabel": {
1062
+ "title": "Subscribe button loading label",
1063
+ "type": "string",
1064
+ "default": "Loading..."
1065
+ },
1066
+ "card": {
1067
+ "title": "Newsletter should be in card format?",
1068
+ "type": "boolean",
1069
+ "default": false
1070
+ },
1071
+ "toastSubscribe": {
1072
+ "title": "Toast Subscribe",
1073
+ "type": "object",
1074
+ "properties": {
1075
+ "title": {
1076
+ "title": "Title",
1077
+ "description": "Message Title",
1078
+ "type": "string",
1079
+ "default": "Hooray!"
1080
+ },
1081
+ "message": {
1082
+ "title": "Message",
1083
+ "description": "Message",
1084
+ "type": "string",
1085
+ "default": "Thank for your subscription."
1086
+ },
1087
+ "icon": {
1088
+ "title": "Icon",
1089
+ "type": "string",
1090
+ "enumNames": ["CircleWavyCheck"],
1091
+ "enum": ["CircleWavyCheck"],
1092
+ "default": "CircleWavyCheck"
1093
+ }
1094
+ }
1095
+ },
1096
+ "toastSubscribeError": {
1097
+ "title": "Toast Subscribe Error",
1098
+ "type": "object",
1099
+ "properties": {
1100
+ "title": {
1101
+ "title": "Title",
1102
+ "description": "Message Title",
1103
+ "type": "string",
1104
+ "default": "Oops."
1105
+ },
1106
+ "message": {
1107
+ "title": "Message",
1108
+ "description": "Message",
1109
+ "type": "string",
1110
+ "default": "Something went wrong. Please Try again."
1111
+ },
1112
+ "icon": {
1113
+ "title": "Icon",
1114
+ "type": "string",
1115
+ "enumNames": ["CircleWavyWarning"],
1116
+ "enum": ["CircleWavyWarning"],
1117
+ "default": "CircleWavyWarning"
1118
+ }
1119
+ }
1057
1120
  }
1058
1121
  }
1059
1122
  }
@@ -1081,11 +1144,13 @@
1081
1144
  "properties": {
1082
1145
  "title": {
1083
1146
  "title": "Title",
1084
- "type": "string"
1147
+ "type": "string",
1148
+ "default": "Get to Know Our Next Release"
1085
1149
  },
1086
1150
  "caption": {
1087
1151
  "title": "Caption",
1088
- "type": "string"
1152
+ "type": "string",
1153
+ "default": "Discover cutting-edge tech, advanced features, and a seamless user experience. Get ready for the future!"
1089
1154
  },
1090
1155
  "link": {
1091
1156
  "title": "Call to Action",
@@ -1094,11 +1159,13 @@
1094
1159
  "properties": {
1095
1160
  "text": {
1096
1161
  "title": "Text",
1097
- "type": "string"
1162
+ "type": "string",
1163
+ "default": "Shop now"
1098
1164
  },
1099
1165
  "url": {
1100
1166
  "title": "URL",
1101
- "type": "string"
1167
+ "type": "string",
1168
+ "default": "/"
1102
1169
  }
1103
1170
  }
1104
1171
  },
@@ -1106,13 +1173,15 @@
1106
1173
  "title": "Color variant",
1107
1174
  "type": "string",
1108
1175
  "enumNames": ["Main", "Light", "Accent"],
1109
- "enum": ["main", "light", "accent"]
1176
+ "enum": ["main", "light", "accent"],
1177
+ "default": "light"
1110
1178
  },
1111
1179
  "variant": {
1112
1180
  "title": "Variant",
1113
1181
  "type": "string",
1114
1182
  "enumNames": ["Primary", "Secondary"],
1115
- "enum": ["primary", "secondary"]
1183
+ "enum": ["primary", "secondary"],
1184
+ "default": "secondary"
1116
1185
  }
1117
1186
  }
1118
1187
  },
@@ -1121,6 +1190,24 @@
1121
1190
  "type": "object",
1122
1191
  "required": ["title", "description"],
1123
1192
  "properties": {
1193
+ "icon": {
1194
+ "title": "Icon",
1195
+ "type": "object",
1196
+ "properties": {
1197
+ "icon": {
1198
+ "title": "Icon",
1199
+ "type": "string",
1200
+ "enumNames": ["Envelop"],
1201
+ "enum": ["Envelop"],
1202
+ "default": "Envelop"
1203
+ },
1204
+ "alt": {
1205
+ "type": "string",
1206
+ "title": "Alternative Label",
1207
+ "default": "Envelop"
1208
+ }
1209
+ }
1210
+ },
1124
1211
  "title": {
1125
1212
  "title": "Title",
1126
1213
  "type": "string",
@@ -1130,6 +1217,43 @@
1130
1217
  "title": "Description",
1131
1218
  "type": "string",
1132
1219
  "default": "Receive our news and promotions in advance"
1220
+ },
1221
+ "privacyPolicy": {
1222
+ "title": "Privacy Policy Disclaimer",
1223
+ "type": "string",
1224
+ "widget": {
1225
+ "ui:widget": "draftjs-rich-text"
1226
+ }
1227
+ },
1228
+ "emailInputLabel": {
1229
+ "title": "Email input label",
1230
+ "type": "string",
1231
+ "default": "Your Email"
1232
+ },
1233
+ "displayNameInput": {
1234
+ "title": "Request name?",
1235
+ "type": "boolean",
1236
+ "default": true
1237
+ },
1238
+ "nameInputLabel": {
1239
+ "title": "Name input label",
1240
+ "type": "string",
1241
+ "default": "Your Name"
1242
+ },
1243
+ "subscribeButtonLabel": {
1244
+ "title": "Subscribe button label",
1245
+ "type": "string",
1246
+ "default": "Subscribe"
1247
+ },
1248
+ "subscribeButtonLoadingLabel": {
1249
+ "title": "Subscribe button loading label",
1250
+ "type": "string",
1251
+ "default": "Loading..."
1252
+ },
1253
+ "card": {
1254
+ "title": "Newsletter should be in card format?",
1255
+ "type": "boolean",
1256
+ "default": true
1133
1257
  }
1134
1258
  }
1135
1259
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/core",
3
- "version": "2.1.5",
3
+ "version": "2.1.9",
4
4
  "license": "MIT",
5
5
  "browserslist": "supports es6-module and not dead",
6
6
  "scripts": {
@@ -29,16 +29,18 @@
29
29
  "@envelop/graphql-jit": "^1.1.1",
30
30
  "@envelop/parser-cache": "^2.2.0",
31
31
  "@envelop/validation-cache": "^2.2.0",
32
- "@faststore/api": "^2.1.1",
33
- "@faststore/components": "^2.1.4",
34
- "@faststore/graphql-utils": "^2.1.1",
35
- "@faststore/sdk": "^2.1.1",
36
- "@faststore/ui": "^2.1.4",
32
+ "@faststore/api": "^2.1.9",
33
+ "@faststore/components": "^2.1.9",
34
+ "@faststore/graphql-utils": "^2.1.9",
35
+ "@faststore/sdk": "^2.1.9",
36
+ "@faststore/ui": "^2.1.9",
37
37
  "@types/react": "^18.0.14",
38
38
  "@vtex/client-cms": "^0.2.12",
39
39
  "autoprefixer": "^10.4.0",
40
40
  "chalk": "^5.2.0",
41
41
  "css-loader": "^6.7.1",
42
+ "draft-js": "^0.11.7",
43
+ "draft-js-export-html": "^1.4.1",
42
44
  "graphql": "^15.0.0",
43
45
  "include-media": "^1.4.10",
44
46
  "msw": "^0.43.1",
@@ -59,7 +61,7 @@
59
61
  },
60
62
  "devDependencies": {
61
63
  "@cypress/code-coverage": "^3.9.10",
62
- "@faststore/eslint-config": "^2.1.1",
64
+ "@faststore/eslint-config": "^2.1.9",
63
65
  "@faststore/lighthouse": "^1.12.32",
64
66
  "@graphql-codegen/cli": "^2.6.2",
65
67
  "@graphql-codegen/typescript": "^2.5.1",
@@ -108,5 +110,5 @@
108
110
  "msw": {
109
111
  "workerDirectory": "public"
110
112
  },
111
- "gitHead": "4ff1ab24fa4280397a532c9362741bd97f4a38d9"
113
+ "gitHead": "e8c0051ff4e990fcf9375bc8a22f76570967e1af"
112
114
  }
@@ -1,31 +1,39 @@
1
- import {
2
- Banner as UIBanner,
3
- BannerContent as UIBannerContent,
4
- } from '@faststore/ui'
5
- import Newsletter from '../Newsletter'
1
+ import BannerText, { BannerTextProps } from 'src/components/sections/BannerText'
2
+ import Newsletter, { NewsletterProps } from 'src/components/sections/Newsletter'
6
3
  import Section from '../Section'
7
4
  import styles from './section.module.scss'
8
5
 
9
- function BannerNewsletter() {
6
+ function BannerNewsletter({
7
+ banner,
8
+ newsletter,
9
+ }: {
10
+ banner: BannerTextProps
11
+ newsletter: NewsletterProps
12
+ }) {
10
13
  return (
11
14
  <Section
12
15
  className={`${styles.section} section-banner-newsletter layout__content`}
13
16
  >
14
17
  <div data-fs-banner-newsletter>
15
- <UIBanner variant="secondary" colorVariant="light">
16
- <UIBannerContent
17
- title="Get to Know Our Next Release"
18
- caption="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam elit nisi, vehicula in turpis sit amet, posuere aliquam nisl. "
19
- link="/"
20
- linkText="Shop Now"
21
- />
22
- </UIBanner>
23
-
18
+ <BannerText
19
+ title={banner.title}
20
+ caption={banner.caption}
21
+ link={banner?.link}
22
+ variant={banner.variant}
23
+ colorVariant={banner.colorVariant}
24
+ />
24
25
  <Newsletter
25
- title="Get News and Special Offers!"
26
- description="Receive our news and promotions in advance. Enjoy and get 10% off your first purchase. For more information click here."
27
- card
28
- lite
26
+ title={newsletter.title}
27
+ description={newsletter.description}
28
+ icon={newsletter.icon}
29
+ privacyPolicy={newsletter.privacyPolicy}
30
+ emailInputLabel={newsletter.emailInputLabel}
31
+ displayNameInput={newsletter.displayNameInput}
32
+ nameInputLabel={newsletter.nameInputLabel}
33
+ subscribeButtonLabel={newsletter.subscribeButtonLabel}
34
+ toastSubscribe={newsletter.toastSubscribe}
35
+ toastSubscribeError={newsletter.toastSubscribeError}
36
+ card={newsletter.card}
29
37
  />
30
38
  </div>
31
39
  </Section>
@@ -1,143 +1,89 @@
1
- import { Button as UIButton, InputField as UIInputField } from '@faststore/ui'
2
- import type { ComponentPropsWithRef, FormEvent, ReactNode } from 'react'
3
- import { forwardRef, useRef } from 'react'
4
-
5
- import { Icon, useUI } from '@faststore/ui'
6
- import Link from 'src/components/ui/Link'
7
- import { useNewsletter } from 'src/sdk/newsletter/useNewsletter'
1
+ import { ComponentPropsWithRef } from 'react'
2
+ import UINewsletter from 'src/components/ui/Newsletter'
3
+ import { SubscribeMessage } from 'src/components/ui/Newsletter/Newsletter'
8
4
 
9
5
  import Section from '../Section'
10
6
  import styles from './section.module.scss'
11
7
 
12
8
  export interface NewsletterProps
13
9
  extends Omit<ComponentPropsWithRef<'form'>, 'title' | 'onSubmit'> {
10
+ /**
11
+ * Icon for the section.
12
+ */
13
+ icon: {
14
+ icon: string
15
+ alt: string
16
+ }
14
17
  /**
15
18
  * Title for the section.
16
19
  */
17
- title: ReactNode
20
+ title: string
18
21
  /**
19
22
  * A description for the section.
20
23
  */
21
- description?: ReactNode
24
+ description?: string
22
25
  /**
23
- * The card Variant
26
+ * The Privacy Policy disclaimer.
24
27
  */
25
- card?: boolean
28
+ privacyPolicy?: string
26
29
  /**
27
- * The compact version of the Newsletter component
30
+ * The email input label.
28
31
  */
29
- lite?: boolean
30
- }
31
-
32
- const Newsletter = forwardRef<HTMLFormElement, NewsletterProps>(
33
- function Newsletter({ title, description, card = false, lite = false }, ref) {
34
- const { subscribeUser, loading, data } = useNewsletter()
35
- const nameInputRef = useRef<HTMLInputElement>(null)
36
- const emailInputRef = useRef<HTMLInputElement>(null)
37
-
38
- const { pushToast } = useUI()
39
-
40
- const handleSubmit = (event: FormEvent) => {
41
- event.preventDefault()
42
- subscribeUser({
43
- data: {
44
- name: nameInputRef.current?.value ?? '',
45
- email: emailInputRef.current?.value ?? '',
46
- },
47
- })
48
-
49
- if (data?.subscribeToNewsletter?.id) {
50
- pushToast({
51
- title: 'Hooray!',
52
- message: 'Thank for your subscription.',
53
- status: 'INFO',
54
- icon: <Icon name="CircleWavyCheck" width={30} height={30} />,
55
- })
56
- } else {
57
- pushToast({
58
- title: 'Oops.',
59
- message: 'Something went wrong. Please Try again.',
60
- status: 'ERROR',
61
- icon: <Icon name="CircleWavyWarning" width={30} height={30} />,
62
- })
63
- }
64
-
65
- const formElement = event.currentTarget as HTMLFormElement
32
+ emailInputLabel?: string
33
+ /**
34
+ * The name input visibility.
35
+ */
36
+ displayNameInput?: boolean
37
+ /**
38
+ * The name input label.
39
+ */
40
+ nameInputLabel?: string
41
+ /**
42
+ * The subscribe button label.
43
+ */
44
+ subscribeButtonLabel?: string
45
+ /**
46
+ * The card Variant
47
+ */
48
+ card: Boolean
66
49
 
67
- formElement.reset()
68
- }
50
+ toastSubscribe: SubscribeMessage
69
51
 
70
- return (
71
- <Section className={`${styles.section} section-newsletter`}>
72
- <div data-fs-newsletter={card ? 'card' : ''}>
73
- <form
74
- ref={ref}
75
- data-fs-newsletter-form
76
- onSubmit={handleSubmit}
77
- className="layout__content"
78
- >
79
- <header data-fs-newsletter-header>
80
- <h3>
81
- <Icon name="Envelop" width={32} height={32} />
82
- {title}
83
- </h3>
84
- {description && <span> {description}</span>}
85
- </header>
52
+ toastSubscribeError: SubscribeMessage
53
+ }
86
54
 
87
- <div data-fs-newsletter-controls>
88
- {lite ? (
89
- <>
90
- <UIInputField
91
- inputRef={emailInputRef}
92
- id="newsletter-email"
93
- label="Your Email"
94
- type="email"
95
- required
96
- actionable
97
- onSubmit={() => undefined}
98
- onClear={() => undefined}
99
- buttonActionText="Subscribe"
100
- displayClearButton={false}
101
- />
102
- <span data-fs-newsletter-addendum>
103
- By subscribing to our newsletter you agree to to our{' '}
104
- <Link href="/" inverse variant="inline">
105
- Privacy Policy.
106
- </Link>
107
- </span>
108
- </>
109
- ) : (
110
- <>
111
- <UIInputField
112
- inputRef={nameInputRef}
113
- id="newsletter-name"
114
- label="Your Name"
115
- required
116
- />
117
- <UIInputField
118
- inputRef={emailInputRef}
119
- id="newsletter-email"
120
- label="Your Email"
121
- type="email"
122
- required
123
- />
124
- <span data-fs-newsletter-addendum>
125
- By subscribing to our newsletter you agree to to our{' '}
126
- <Link href="/" inverse variant="inline">
127
- Privacy Policy.
128
- </Link>
129
- </span>
130
- <UIButton variant="secondary" inverse type="submit">
131
- {loading ? 'Loading...' : 'Subscribe'}
132
- </UIButton>
133
- </>
134
- )}
135
- </div>
136
- </form>
137
- </div>
138
- </Section>
139
- )
140
- }
141
- )
55
+ const Newsletter = function Newsletter({
56
+ icon,
57
+ title,
58
+ description,
59
+ privacyPolicy,
60
+ emailInputLabel,
61
+ displayNameInput,
62
+ nameInputLabel,
63
+ subscribeButtonLabel,
64
+ card,
65
+ toastSubscribe,
66
+ toastSubscribeError,
67
+ ...otherProps
68
+ }: NewsletterProps) {
69
+ return (
70
+ <Section className={`${styles.section} section-newsletter`}>
71
+ <UINewsletter
72
+ icon={icon}
73
+ title={title}
74
+ description={description}
75
+ privacyPolicy={privacyPolicy}
76
+ emailInputLabel={emailInputLabel}
77
+ displayNameInput={displayNameInput}
78
+ nameInputLabel={nameInputLabel}
79
+ subscribeButtonLabel={subscribeButtonLabel}
80
+ toastSubscribe={toastSubscribe}
81
+ toastSubscribeError={toastSubscribeError}
82
+ card={card}
83
+ {...otherProps}
84
+ />
85
+ </Section>
86
+ )
87
+ }
142
88
 
143
89
  export default Newsletter