@bigbinary/neeto-molecules 5.5.0 → 5.5.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.
Files changed (56) hide show
  1. package/dist/Onboarding.js +391 -8
  2. package/dist/Onboarding.js.map +1 -1
  3. package/dist/circle-user-ieD_gMjm.js +19 -0
  4. package/dist/circle-user-ieD_gMjm.js.map +1 -0
  5. package/dist/cjs/Onboarding.js +409 -7
  6. package/dist/cjs/Onboarding.js.map +1 -1
  7. package/dist/cjs/circle-user-D5aGw9mw.js +21 -0
  8. package/dist/cjs/circle-user-D5aGw9mw.js.map +1 -0
  9. package/dist/cjs/v2/AuditLogs.js +2 -16
  10. package/dist/cjs/v2/AuditLogs.js.map +1 -1
  11. package/dist/cjs/v2/Onboarding.js +435 -10
  12. package/dist/cjs/v2/Onboarding.js.map +1 -1
  13. package/dist/v2/AuditLogs.js +1 -15
  14. package/dist/v2/AuditLogs.js.map +1 -1
  15. package/dist/v2/Onboarding.js +418 -12
  16. package/dist/v2/Onboarding.js.map +1 -1
  17. package/package.json +1 -1
  18. package/src/translations/ar.json +24 -6
  19. package/src/translations/bg.json +25 -7
  20. package/src/translations/ca.json +25 -7
  21. package/src/translations/cs.json +24 -6
  22. package/src/translations/da.json +25 -7
  23. package/src/translations/de.json +25 -7
  24. package/src/translations/en.json +14 -7
  25. package/src/translations/es-MX.json +25 -7
  26. package/src/translations/es.json +25 -7
  27. package/src/translations/et.json +25 -7
  28. package/src/translations/fi.json +25 -7
  29. package/src/translations/fil.json +25 -7
  30. package/src/translations/fr.json +25 -7
  31. package/src/translations/he.json +25 -7
  32. package/src/translations/hi.json +24 -6
  33. package/src/translations/hr.json +24 -6
  34. package/src/translations/hu.json +25 -7
  35. package/src/translations/id.json +25 -7
  36. package/src/translations/it.json +25 -7
  37. package/src/translations/ja.json +25 -7
  38. package/src/translations/ko.json +25 -7
  39. package/src/translations/lv.json +25 -7
  40. package/src/translations/nl.json +25 -7
  41. package/src/translations/pl.json +25 -7
  42. package/src/translations/pt-BR.json +25 -7
  43. package/src/translations/pt.json +25 -7
  44. package/src/translations/ro.json +25 -7
  45. package/src/translations/ru.json +24 -6
  46. package/src/translations/sk.json +24 -6
  47. package/src/translations/sl.json +25 -7
  48. package/src/translations/sv.json +25 -7
  49. package/src/translations/th.json +24 -6
  50. package/src/translations/tr.json +25 -7
  51. package/src/translations/uk.json +25 -7
  52. package/src/translations/vi.json +25 -7
  53. package/src/translations/zh-CN.json +24 -6
  54. package/src/translations/zh-TW.json +25 -7
  55. package/types/Onboarding.d.ts +1 -0
  56. package/types/v2/Onboarding.d.ts +1 -0
@@ -1,16 +1,23 @@
1
1
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
2
  import { useState, useLayoutEffect, useEffect, useMemo, useRef } from 'react';
3
- import { Typography, Button, Stepper } from '@bigbinary/neeto-atoms';
3
+ import { Input, Button, Typography, Checkbox, Stepper } from '@bigbinary/neeto-atoms';
4
4
  import classnames from 'classnames';
5
- import { isPresent, capitalize, noop, findIndexBy } from '@bigbinary/neeto-cist';
5
+ import { capitalize, isPresent, noop, findIndexBy } from '@bigbinary/neeto-cist';
6
6
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
7
7
  import { globalProps } from '@bigbinary/neeto-commons-frontend/v2/initializers';
8
8
  import { R as ReactConfetti } from '../react-confetti-BnGq_LBE.js';
9
9
  import { useTranslation, Trans } from 'react-i18next';
10
10
  import { t } from 'i18next';
11
- import useBreakpoints from '@bigbinary/neeto-commons-frontend/v2/react-utils/useBreakpoints';
12
- import { jsxs, jsx } from 'react/jsx-runtime';
11
+ import { assoc, dissoc } from 'ramda';
12
+ import { C as CircleUser } from '../circle-user-ieD_gMjm.js';
13
13
  import { c as createLucideIcon } from '../createLucideIcon--oLqczpc.js';
14
+ import { jsxs, jsx } from 'react/jsx-runtime';
15
+ import { M as Mail } from '../mail-CkquKByM.js';
16
+ import { useMutation } from '@tanstack/react-query';
17
+ import axios from 'axios';
18
+ import { BASE_API_V1_URL } from '@bigbinary/neeto-commons-frontend/v2/constants';
19
+ import * as yup from 'yup';
20
+ import useBreakpoints from '@bigbinary/neeto-commons-frontend/v2/react-utils/useBreakpoints';
14
21
  import { n } from '../inject-css-C2dztUxs.js';
15
22
  import { withT } from '@bigbinary/neeto-commons-frontend/v2/react-utils';
16
23
 
@@ -22,18 +29,384 @@ import { withT } from '@bigbinary/neeto-commons-frontend/v2/react-utils';
22
29
  */
23
30
 
24
31
 
25
- const __iconNode = [
32
+ const __iconNode$1 = [
26
33
  ["path", { d: "M5 12h14", key: "1ays0h" }],
27
34
  ["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
28
35
  ];
29
- const ArrowRight = createLucideIcon("arrow-right", __iconNode);
36
+ const ArrowRight = createLucideIcon("arrow-right", __iconNode$1);
37
+
38
+ /**
39
+ * @license lucide-react v1.24.0 - ISC
40
+ *
41
+ * This source code is licensed under the ISC license.
42
+ * See the LICENSE file in the root directory of this source tree.
43
+ */
44
+
45
+
46
+ const __iconNode = [
47
+ ["path", { d: "M2 6h4", key: "aawbzj" }],
48
+ ["path", { d: "M2 10h4", key: "l0bgd4" }],
49
+ ["path", { d: "M2 14h4", key: "1gsvsf" }],
50
+ ["path", { d: "M2 18h4", key: "1bu2t1" }],
51
+ ["rect", { width: "16", height: "20", x: "4", y: "2", rx: "2", key: "1nb95v" }],
52
+ ["path", { d: "M9.5 8h5", key: "11mslq" }],
53
+ ["path", { d: "M9.5 12H16", key: "ktog6x" }],
54
+ ["path", { d: "M9.5 16H14", key: "p1seyn" }]
55
+ ];
56
+ const NotebookText = createLucideIcon("notebook-text", __iconNode);
57
+
58
+ var COMMUNITY_OPTIONS = [{
59
+ key: "slack",
60
+ icon: CircleUser,
61
+ dataTestid: "onboarding-community-slack-checkbox",
62
+ recipientDataTestids: {
63
+ change: "onboarding-community-slack-email-change-button",
64
+ input: "onboarding-community-slack-email-input",
65
+ save: "onboarding-community-slack-email-save-button",
66
+ cancel: "onboarding-community-slack-email-cancel-button"
67
+ }
68
+ }, {
69
+ key: "blog",
70
+ icon: NotebookText,
71
+ dataTestid: "onboarding-community-blog-checkbox",
72
+ recipientDataTestids: {
73
+ change: "onboarding-community-blog-email-change-button",
74
+ input: "onboarding-community-blog-email-input",
75
+ save: "onboarding-community-blog-email-save-button",
76
+ cancel: "onboarding-community-blog-email-cancel-button"
77
+ }
78
+ }];
79
+
80
+ var EmailRecipient = function EmailRecipient(_ref) {
81
+ var email = _ref.email,
82
+ edit = _ref.edit,
83
+ onStartEditing = _ref.onStartEditing,
84
+ onDraftChange = _ref.onDraftChange,
85
+ onSave = _ref.onSave,
86
+ onCancel = _ref.onCancel,
87
+ recipientKey = _ref.recipientKey,
88
+ inputLabelKey = _ref.inputLabelKey,
89
+ dataTestids = _ref.dataTestids;
90
+ var _useTranslation = useTranslation(),
91
+ t = _useTranslation.t;
92
+ var handleKeyDown = function handleKeyDown(event) {
93
+ if (event.key === "Enter") {
94
+ event.preventDefault();
95
+ onSave();
96
+ }
97
+ if (event.key === "Escape") onCancel();
98
+ };
99
+ if (edit) {
100
+ return /*#__PURE__*/jsxs("div", {
101
+ className: "flex items-start gap-2 ps-6 pt-3",
102
+ children: [/*#__PURE__*/jsx("div", {
103
+ className: "w-72",
104
+ children: /*#__PURE__*/jsx(Input, {
105
+ autoFocus: true,
106
+ "aria-label": t(inputLabelKey),
107
+ "data-testid": dataTestids.input,
108
+ error: edit.error,
109
+ type: "email",
110
+ value: edit.draft,
111
+ onChange: function onChange(event) {
112
+ return onDraftChange(event.target.value);
113
+ },
114
+ onKeyDown: handleKeyDown
115
+ })
116
+ }), /*#__PURE__*/jsx(Button, {
117
+ "data-testid": dataTestids.save,
118
+ label: t("neetoMolecules.common.actions.save"),
119
+ onClick: onSave
120
+ }), /*#__PURE__*/jsx(Button, {
121
+ "data-testid": dataTestids.cancel,
122
+ label: t("neetoMolecules.common.actions.cancel"),
123
+ variant: "ghost",
124
+ onClick: onCancel
125
+ })]
126
+ });
127
+ }
128
+ return /*#__PURE__*/jsxs("div", {
129
+ className: "flex flex-wrap items-center gap-2 ps-6 pt-3",
130
+ children: [/*#__PURE__*/jsx(Mail, {
131
+ "aria-hidden": true,
132
+ className: "text-muted-foreground",
133
+ size: 16
134
+ }), /*#__PURE__*/jsx(Typography, {
135
+ color: "muted",
136
+ variant: "body2",
137
+ children: /*#__PURE__*/jsx(Trans, {
138
+ components: {
139
+ strong: /*#__PURE__*/jsx("strong", {
140
+ className: "text-foreground"
141
+ })
142
+ },
143
+ i18nKey: recipientKey,
144
+ values: {
145
+ email: email
146
+ }
147
+ })
148
+ }), /*#__PURE__*/jsx(Button, {
149
+ "data-testid": dataTestids.change,
150
+ label: t("neetoMolecules.onboarding.communityScreen.changeButton"),
151
+ size: "sm",
152
+ variant: "link",
153
+ onClick: onStartEditing
154
+ })]
155
+ });
156
+ };
157
+
158
+ var joinCommunity = function joinCommunity(communityJoin) {
159
+ return axios.post("".concat(BASE_API_V1_URL, "/community_join"), {
160
+ communityJoin: communityJoin
161
+ }, {
162
+ showToastr: false
163
+ });
164
+ };
165
+ var communityApi = {
166
+ joinCommunity: joinCommunity
167
+ };
168
+
169
+ var useJoinCommunity = function useJoinCommunity() {
170
+ return useMutation({
171
+ mutationFn: communityApi.joinCommunity
172
+ });
173
+ };
174
+
175
+ var isValidEmail = function isValidEmail(email) {
176
+ return !!email && yup.string().email().isValidSync(email);
177
+ };
178
+
179
+ function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
180
+ function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
181
+
182
+ // Tracks the email each option goes to, plus any address being edited, so
183
+ // Continue can pick up a draft the user typed but did not save.
184
+ var useRecipientEmails = function useRecipientEmails(defaultEmail) {
185
+ var _useState = useState({
186
+ slack: defaultEmail,
187
+ blog: defaultEmail
188
+ }),
189
+ _useState2 = _slicedToArray(_useState, 2),
190
+ emails = _useState2[0],
191
+ setEmails = _useState2[1];
192
+
193
+ // { [key]: { draft, error } } for the options whose email field is open.
194
+ var _useState3 = useState({}),
195
+ _useState4 = _slicedToArray(_useState3, 2),
196
+ edits = _useState4[0],
197
+ setEdits = _useState4[1];
198
+ var startEditing = function startEditing(key) {
199
+ return setEdits(assoc(key, {
200
+ draft: emails[key],
201
+ error: ""
202
+ }));
203
+ };
204
+ var changeDraft = function changeDraft(key, draft) {
205
+ return setEdits(assoc(key, {
206
+ draft: draft,
207
+ error: ""
208
+ }));
209
+ };
210
+ var cancel = function cancel(key) {
211
+ return setEdits(dissoc(key));
212
+ };
213
+ var validate = function validate(key) {
214
+ var draft = edits[key].draft.trim();
215
+ return isValidEmail(draft) ? {
216
+ draft: draft
217
+ } : {
218
+ error: t("neetoMolecules.onboarding.communityScreen.invalidEmail")
219
+ };
220
+ };
221
+ var save = function save(key) {
222
+ var _validate = validate(key),
223
+ draft = _validate.draft,
224
+ error = _validate.error;
225
+ if (error) {
226
+ setEdits(assoc(key, _objectSpread$3(_objectSpread$3({}, edits[key]), {}, {
227
+ error: error
228
+ })));
229
+ return;
230
+ }
231
+ setEmails(assoc(key, draft));
232
+ setEdits(dissoc(key));
233
+ };
234
+
235
+ // Applies every open draft of the given options. Returns the final emails,
236
+ // or null when a draft is invalid, after showing its error.
237
+ var applyDrafts = function applyDrafts(keys) {
238
+ var nextEmails = emails;
239
+ var nextEdits = edits;
240
+ keys.filter(function (key) {
241
+ return edits[key];
242
+ }).forEach(function (key) {
243
+ var _validate2 = validate(key),
244
+ draft = _validate2.draft,
245
+ error = _validate2.error;
246
+ if (error) {
247
+ nextEdits = assoc(key, _objectSpread$3(_objectSpread$3({}, edits[key]), {}, {
248
+ error: error
249
+ }), nextEdits);
250
+ } else {
251
+ nextEmails = assoc(key, draft, nextEmails);
252
+ nextEdits = dissoc(key, nextEdits);
253
+ }
254
+ });
255
+ setEmails(nextEmails);
256
+ setEdits(nextEdits);
257
+ var hasInvalidDraft = keys.some(function (key) {
258
+ return nextEdits[key];
259
+ });
260
+ return hasInvalidDraft ? null : nextEmails;
261
+ };
262
+ return {
263
+ emails: emails,
264
+ edits: edits,
265
+ startEditing: startEditing,
266
+ changeDraft: changeDraft,
267
+ cancel: cancel,
268
+ save: save,
269
+ applyDrafts: applyDrafts
270
+ };
271
+ };
30
272
 
31
273
  var GENERAL_ONBOARDING_STEPS = {
32
274
  WELCOME: "welcome",
275
+ COMMUNITY: "community",
33
276
  HELP: "help",
34
277
  FINISH: "finish"
35
278
  };
36
279
 
280
+ function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
281
+ function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
282
+ var Community = function Community(_ref) {
283
+ var _globalProps$user, _globalProps$appName;
284
+ var setCurrentStep = _ref.setCurrentStep,
285
+ communityScreenClassName = _ref.communityScreenClassName;
286
+ var _useTranslation = useTranslation(),
287
+ t = _useTranslation.t;
288
+ var _useState = useState({
289
+ slack: true,
290
+ blog: true
291
+ }),
292
+ _useState2 = _slicedToArray(_useState, 2),
293
+ selected = _useState2[0],
294
+ setSelected = _useState2[1];
295
+
296
+ // Both start at the signed-in user's email; each can be changed separately.
297
+ var recipients = useRecipientEmails((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.email);
298
+ var _useJoinCommunity = useJoinCommunity(),
299
+ joinCommunity = _useJoinCommunity.mutate;
300
+ var appName = capitalize((_globalProps$appName = globalProps.appName) !== null && _globalProps$appName !== void 0 ? _globalProps$appName : "");
301
+ var handleContinue = function handleContinue() {
302
+ var selectedKeys = Object.keys(selected).filter(function (key) {
303
+ return selected[key];
304
+ });
305
+
306
+ // An address typed but not saved still counts; an invalid one keeps the
307
+ // user here with its error showing.
308
+ var emails = recipients.applyDrafts(selectedKeys);
309
+ if (!emails) return;
310
+
311
+ // The Slack invite and blog subscription are both sent by email in the
312
+ // background, so onboarding moves on without waiting for them.
313
+ if (selectedKeys.length > 0) {
314
+ joinCommunity(_objectSpread$2(_objectSpread$2({}, selected), {}, {
315
+ slackEmail: emails.slack,
316
+ blogEmail: emails.blog
317
+ }));
318
+ }
319
+ setCurrentStep(GENERAL_ONBOARDING_STEPS.HELP);
320
+ };
321
+ return /*#__PURE__*/jsxs("div", {
322
+ className: classnames("mx-auto flex w-full max-w-3xl flex-col items-start gap-y-6 px-6 pt-16 pb-6", communityScreenClassName),
323
+ children: [/*#__PURE__*/jsxs("div", {
324
+ className: "space-y-2",
325
+ children: [/*#__PURE__*/jsx(Typography, {
326
+ "data-testid": "onboarding-community-title",
327
+ variant: "h2",
328
+ children: t("neetoMolecules.onboarding.communityScreen.title")
329
+ }), /*#__PURE__*/jsx(Typography, {
330
+ "data-testid": "onboarding-community-description",
331
+ variant: "body1",
332
+ children: t("neetoMolecules.onboarding.communityScreen.description", {
333
+ appName: appName
334
+ })
335
+ })]
336
+ }), /*#__PURE__*/jsx("div", {
337
+ className: "border-border flex w-full flex-col gap-6 rounded-lg border p-3 lg:p-6",
338
+ children: COMMUNITY_OPTIONS.map(function (_ref2) {
339
+ var key = _ref2.key,
340
+ Icon = _ref2.icon,
341
+ dataTestid = _ref2.dataTestid,
342
+ recipientDataTestids = _ref2.recipientDataTestids;
343
+ return /*#__PURE__*/jsxs("div", {
344
+ className: "w-full",
345
+ children: [/*#__PURE__*/jsx(Checkbox, {
346
+ checked: selected[key],
347
+ "data-testid": dataTestid,
348
+ id: dataTestid,
349
+ labelProps: {
350
+ className: "text-xl font-semibold"
351
+ },
352
+ label: /*#__PURE__*/jsxs("span", {
353
+ className: "flex flex-wrap items-center gap-2",
354
+ children: [t("neetoMolecules.onboarding.communityScreen.".concat(key, ".title"), {
355
+ appName: appName
356
+ }), /*#__PURE__*/jsx(Icon, {
357
+ "aria-hidden": true,
358
+ size: 24
359
+ })]
360
+ }),
361
+ onCheckedChange: function onCheckedChange(checked) {
362
+ setSelected(assoc(key, checked));
363
+ if (!checked) recipients.cancel(key);
364
+ }
365
+ }), /*#__PURE__*/jsx(Typography, {
366
+ className: "ps-6 pt-2",
367
+ color: "muted",
368
+ variant: "body1",
369
+ children: t("neetoMolecules.onboarding.communityScreen.".concat(key, ".description"))
370
+ }), selected[key] && /*#__PURE__*/jsx(EmailRecipient, {
371
+ dataTestids: recipientDataTestids,
372
+ edit: recipients.edits[key],
373
+ email: recipients.emails[key],
374
+ inputLabelKey: "neetoMolecules.onboarding.communityScreen.".concat(key, ".emailInputLabel"),
375
+ recipientKey: "neetoMolecules.onboarding.communityScreen.".concat(key, ".recipient"),
376
+ onCancel: function onCancel() {
377
+ return recipients.cancel(key);
378
+ },
379
+ onDraftChange: function onDraftChange(draft) {
380
+ return recipients.changeDraft(key, draft);
381
+ },
382
+ onSave: function onSave() {
383
+ return recipients.save(key);
384
+ },
385
+ onStartEditing: function onStartEditing() {
386
+ return recipients.startEditing(key);
387
+ }
388
+ })]
389
+ }, key);
390
+ })
391
+ }), /*#__PURE__*/jsx(Typography, {
392
+ color: "muted",
393
+ variant: "body2",
394
+ children: t("neetoMolecules.onboarding.communityScreen.unsubscribe")
395
+ }), /*#__PURE__*/jsx(Button, {
396
+ "data-testid": "community-onboarding-continue-button",
397
+ icon: function icon() {
398
+ return /*#__PURE__*/jsx(ArrowRight, {
399
+ className: "rtl:scale-x-[-1]",
400
+ size: 16
401
+ });
402
+ },
403
+ iconPosition: "right",
404
+ label: t("neetoMolecules.onboarding.communityScreen.continueButton"),
405
+ onClick: handleContinue
406
+ })]
407
+ });
408
+ };
409
+
37
410
  var HelpScreen = function HelpScreen(_ref) {
38
411
  var setCurrentStep = _ref.setCurrentStep,
39
412
  helpScreenClassName = _ref.helpScreenClassName;
@@ -84,7 +457,14 @@ var HelpScreen = function HelpScreen(_ref) {
84
457
 
85
458
  function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
86
459
  function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
87
- var createSteps = function createSteps(onboardingSteps, setCurrentStep, currentStep, helpScreenClassName) {
460
+ var createSteps = function createSteps(onboardingSteps, setCurrentStep, currentStep, helpScreenClassName, isCommunityStepVisible) {
461
+ var communityStep = {
462
+ key: GENERAL_ONBOARDING_STEPS.COMMUNITY,
463
+ label: t("neetoMolecules.onboarding.communityLabel"),
464
+ element: /*#__PURE__*/jsx(Community, {
465
+ setCurrentStep: setCurrentStep
466
+ })
467
+ };
88
468
  var helpStep = {
89
469
  key: GENERAL_ONBOARDING_STEPS.HELP,
90
470
  label: t("neetoMolecules.onboarding.helpLabel"),
@@ -94,7 +474,7 @@ var createSteps = function createSteps(onboardingSteps, setCurrentStep, currentS
94
474
  setCurrentStep: setCurrentStep
95
475
  })
96
476
  };
97
- return onboardingSteps.concat(helpStep).map(function (step, idx) {
477
+ return onboardingSteps.concat(isCommunityStepVisible ? [communityStep, helpStep] : helpStep).map(function (step, idx) {
98
478
  return _objectSpread$1(_objectSpread$1({}, step), {}, {
99
479
  id: idx + 1
100
480
  });
@@ -251,11 +631,27 @@ var Onboarding = function Onboarding(_ref) {
251
631
  welcomeScreenClassName = _ref$welcomeScreenCla === void 0 ? "" : _ref$welcomeScreenCla,
252
632
  _ref$completedScreenC = _ref.completedScreenClassName,
253
633
  completedScreenClassName = _ref$completedScreenC === void 0 ? "" : _ref$completedScreenC,
254
- completedScreenSuccessMessage = _ref.completedScreenSuccessMessage;
634
+ completedScreenSuccessMessage = _ref.completedScreenSuccessMessage,
635
+ _ref$isCommunityStepV = _ref.isCommunityStepVisible,
636
+ isCommunityStepVisible = _ref$isCommunityStepV === void 0 ? true : _ref$isCommunityStepV;
255
637
  var steps = useMemo(function () {
256
- return createSteps(onboardingSteps, setCurrentStep, currentStep, helpScreenClassName);
257
- }, [onboardingSteps]);
638
+ return createSteps(onboardingSteps, setCurrentStep, currentStep, helpScreenClassName, isCommunityStepVisible);
639
+ }, [onboardingSteps, isCommunityStepVisible]);
258
640
  var prevStep = useRef(currentStep);
641
+ var isStepperNavigation = useRef(false);
642
+ var isRedirectingToCommunity = useRef(false);
643
+
644
+ // Products move from their last step straight to Help. Send them through
645
+ // the community step first, unless they picked Help in the stepper.
646
+ useLayoutEffect(function () {
647
+ var isFromStepper = isStepperNavigation.current;
648
+ isStepperNavigation.current = false;
649
+ var shouldShowCommunityFirst = isCommunityStepVisible && !isFromStepper && currentStep === GENERAL_ONBOARDING_STEPS.HELP && prevStep.current !== currentStep && prevStep.current !== GENERAL_ONBOARDING_STEPS.COMMUNITY;
650
+ if (shouldShowCommunityFirst) {
651
+ isRedirectingToCommunity.current = true;
652
+ setCurrentStep(GENERAL_ONBOARDING_STEPS.COMMUNITY);
653
+ }
654
+ }, [currentStep]);
259
655
  var _useState = useState(""),
260
656
  _useState2 = _slicedToArray(_useState, 2),
261
657
  direction = _useState2[0],
@@ -267,6 +663,13 @@ var Onboarding = function Onboarding(_ref) {
267
663
  };
268
664
  useEffect(function () {
269
665
  if (currentStep === prevStep.current) return;
666
+
667
+ // Help is skipped over on the way to the community step, so the
668
+ // animation should run from the step before it.
669
+ if (isRedirectingToCommunity.current) {
670
+ isRedirectingToCommunity.current = false;
671
+ return;
672
+ }
270
673
  setDirection(getOnboardingStepIndex(currentStep) > getOnboardingStepIndex(prevStep.current) ? "forward" : "backward");
271
674
  prevStep.current = currentStep;
272
675
  }, [currentStep]);
@@ -286,7 +689,10 @@ var Onboarding = function Onboarding(_ref) {
286
689
  });
287
690
  }
288
691
  var handleStepChange = function handleStepChange(index) {
289
- return setCurrentStep(steps[index].key);
692
+ var stepKey = steps[index].key;
693
+ if (stepKey === currentStep) return;
694
+ isStepperNavigation.current = true;
695
+ setCurrentStep(stepKey);
290
696
  };
291
697
  var isStepperVisible = steps.length > 1;
292
698
  return /*#__PURE__*/jsxs("div", {