@stokr/components-library 3.1.1 → 3.2.0

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 (35) hide show
  1. package/dist/analytics/index.js +1 -3
  2. package/dist/components/Checklist/ChecklistCard.js +1 -2
  3. package/dist/components/Checklist/ChecklistCard.styles.js +39 -0
  4. package/dist/components/CryptoAddressWrapper/CryptoAddressWrapper.js +1 -3
  5. package/dist/components/FAQ/FAQ.js +1 -3
  6. package/dist/components/Form/Form.js +1 -3
  7. package/dist/components/RefreshButton/RefreshButton.js +3 -5
  8. package/dist/components/SectionTitle/SectionTitle.styles.js +1 -2
  9. package/dist/index.js +34 -71
  10. package/package.json +1 -3
  11. package/dist/api/fetchData.js +0 -27
  12. package/dist/api/fetchDataPublic.js +0 -19
  13. package/dist/components/Newsletter/Newsletter.js +0 -120
  14. package/dist/components/Newsletter/Newsletter.styles.js +0 -186
  15. package/dist/components/ToDoList/ToDoList.js +0 -167
  16. package/dist/components/ToDoList/ToDoList.styles.js +0 -122
  17. package/dist/components/ToDoList/ToDoListTask.js +0 -89
  18. package/dist/components/ToDoList/ToDoListTask.styles.js +0 -119
  19. package/dist/components/taxId/complete.js +0 -45
  20. package/dist/components/taxId/flow.js +0 -63
  21. package/dist/components/taxId/register-taxid.js +0 -189
  22. package/dist/context/Checkbox/CheckboxContext.js +0 -151
  23. package/dist/model/axios.js +0 -10
  24. package/dist/model/axiosPublic.js +0 -9
  25. package/dist/routing/RouterWrapper.js +0 -17
  26. package/dist/routing/navigate-app.js +0 -24
  27. package/dist/runtime-config.js +0 -35
  28. package/dist/utils/app-urls-analytics-backoffice.js +0 -30
  29. package/dist/utils/app-urls.js +0 -10
  30. package/dist/utils/check-todo-status.js +0 -10
  31. package/dist/utils/checklistGenerator.js +0 -196
  32. package/dist/utils/delete-redirect-cookie-and-navigate.js +0 -12
  33. package/dist/utils/get-cookie-domain.js +0 -21
  34. package/dist/utils/redirect-url.js +0 -5
  35. package/dist/utils/set-redirect-cookie.js +0 -16
@@ -1,5 +1,4 @@
1
1
  import mixpanel from "mixpanel-browser";
2
- import { getAnalyticsIngestUrl } from "../utils/app-urls-analytics-backoffice.js";
3
2
  const BLOCKED_FIELDS = /* @__PURE__ */ new Set([
4
3
  // PII
5
4
  "email",
@@ -78,8 +77,7 @@ function initAnalytics({
78
77
  scroll = true,
79
78
  apiHost: apiHostArg
80
79
  } = {}) {
81
- const analyticsUrl = getAnalyticsIngestUrl();
82
- const apiHost = apiHostArg ?? (analyticsUrl || "https://api-eu.mixpanel.com");
80
+ const apiHost = apiHostArg ?? "https://api-eu.mixpanel.com";
83
81
  if (initialized) return;
84
82
  if (!token) return;
85
83
  if (typeof navigator !== "undefined" && /Ghost Inspector/i.test(navigator.userAgent)) {
@@ -2,8 +2,7 @@ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { iconsMap } from "../Icon/Icon.style.js";
5
- import { CardContainer, IconBlock, IconCopy, CardTitle, CardDescription } from "./ChecklistCard.styles.js";
6
- import { Icon } from "../ToDoList/ToDoListTask.styles.js";
5
+ import { CardContainer, IconBlock, IconCopy, CardTitle, CardDescription, Icon } from "./ChecklistCard.styles.js";
7
6
  import { colors } from "../../styles/colors.js";
8
7
  import SvgWarningFilled from "../../static/images/warning-filled.svg.js";
9
8
  import { Link } from "react-router-dom";
@@ -1,5 +1,7 @@
1
1
  import styled from "styled-components";
2
2
  import rwd from "../../styles/rwd.js";
3
+ import { colors } from "../../styles/colors.js";
4
+ import { Icon as Icon$1 } from "../Icon/Icon.style.js";
3
5
  const CardContainer = styled.div.withConfig({
4
6
  shouldForwardProp: (props) => !["isClickable"].includes(props)
5
7
  })`
@@ -73,10 +75,47 @@ const CardDescription = styled.div`
73
75
  letter-spacing: 0.8px;
74
76
  `}
75
77
  `;
78
+ const TaskState = {
79
+ REJECTED: "rejected",
80
+ IN_PROGRESS: "in_progress",
81
+ APPROVED: "approved",
82
+ SKIPPED: "skipped",
83
+ NOT_AVAILABLE: "not_available"
84
+ };
85
+ const Icon = styled(Icon$1).withConfig({
86
+ shouldForwardProp: (props) => !["state"].includes(props)
87
+ })`
88
+ font-size: 20px;
89
+ width: 18px;
90
+ text-align: center;
91
+
92
+ ${(props) => props.state === TaskState.APPROVED && `
93
+ font-size: 13px;
94
+ color: ${colors.freshGreen};
95
+ `}
96
+
97
+ ${(props) => props.state === TaskState.REJECTED && `
98
+ color: ${colors.orangishRed};
99
+ `}
100
+
101
+ ${(props) => props.state === TaskState.IN_PROGRESS && `
102
+ opacity: 0.3;
103
+ `}
104
+
105
+ ${(props) => props.state === TaskState.SKIPPED && `
106
+ font-size: 13px;
107
+ `}
108
+
109
+ ${(props) => props.state === TaskState.NOT_AVAILABLE && `
110
+ font-size: 13px;
111
+ opacity: 0.3;
112
+ `}
113
+ `;
76
114
  export {
77
115
  CardContainer,
78
116
  CardDescription,
79
117
  CardTitle,
118
+ Icon,
80
119
  IconBlock,
81
120
  IconCopy
82
121
  };
@@ -18,8 +18,6 @@ CryptoAddressWrapper.propTypes = {
18
18
  refresh: PropTypes.string,
19
19
  failed: PropTypes.string
20
20
  };
21
- var stdin_default = CryptoAddressWrapper;
22
21
  export {
23
- CryptoAddressWrapper,
24
- stdin_default as default
22
+ CryptoAddressWrapper
25
23
  };
@@ -71,7 +71,6 @@ FAQ.propTypes = {
71
71
  /** Prefix for data-cy: `{prefix}-accordion`, `{prefix}-item-{slug}-toggle`, etc. */
72
72
  dataCyPrefix: PropTypes.string
73
73
  };
74
- var stdin_default = FAQ;
75
74
  export {
76
75
  FAQ,
77
76
  FaqContent,
@@ -79,6 +78,5 @@ export {
79
78
  FaqItem,
80
79
  FaqItems,
81
80
  FaqText,
82
- FaqTitle,
83
- stdin_default as default
81
+ FaqTitle
84
82
  };
@@ -10,12 +10,10 @@ const Form = ({ children, id }) => {
10
10
  Form.propTypes = {
11
11
  children: PropTypes.node.isRequired
12
12
  };
13
- var stdin_default = Form;
14
13
  export {
15
14
  Form,
16
15
  FormContainer,
17
16
  FormError,
18
17
  FormField,
19
- FormInfo,
20
- stdin_default as default
18
+ FormInfo
21
19
  };
@@ -1,20 +1,18 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import "react";
3
3
  import PropTypes from "prop-types";
4
- import stdin_default$1 from "../SvgIcons/RefreshSvg.js";
4
+ import stdin_default from "../SvgIcons/RefreshSvg.js";
5
5
  import { StyledButton, IconWrap, Content } from "./RefreshButton.styles.js";
6
6
  const RefreshButton = (props) => {
7
7
  const { children } = props;
8
8
  return /* @__PURE__ */ jsxs(StyledButton, { ...props, children: [
9
- /* @__PURE__ */ jsx(IconWrap, { children: /* @__PURE__ */ jsx(stdin_default$1, {}) }),
9
+ /* @__PURE__ */ jsx(IconWrap, { children: /* @__PURE__ */ jsx(stdin_default, {}) }),
10
10
  /* @__PURE__ */ jsx(Content, { children })
11
11
  ] });
12
12
  };
13
13
  RefreshButton.propTypes = {
14
14
  children: PropTypes.node.isRequired
15
15
  };
16
- var stdin_default = RefreshButton;
17
16
  export {
18
- RefreshButton,
19
- stdin_default as default
17
+ RefreshButton
20
18
  };
@@ -21,6 +21,5 @@ const SectionTitle = styled.h2`
21
21
  }
22
22
  `;
23
23
  export {
24
- SectionTitle,
25
- SectionTitle as default
24
+ SectionTitle
26
25
  };
package/dist/index.js CHANGED
@@ -22,7 +22,6 @@ import { CryptoAddressWrapper } from "./components/CryptoAddressWrapper/CryptoAd
22
22
  import { DoubleButtons } from "./components/DoubleButton/DoubleButton.styles.js";
23
23
  import { ErrorMessage } from "./components/ErrorMessage/ErrorMessage.styles.js";
24
24
  import { FAQ } from "./components/FAQ/FAQ.js";
25
- import { Newsletter } from "./components/Newsletter/Newsletter.js";
26
25
  import { Form } from "./components/Form/Form.js";
27
26
  import { Card, CardHeader, CardHeaderRegular, CardLeftText, CardRightText, CardTitle, CardTitleContainer } from "./components/Card/Card.styles.js";
28
27
  import { Column, FlexContainer, FlexGrid, PageWrapper, Row, Wrapper } from "./components/Grid/Grid.styles.js";
@@ -81,8 +80,6 @@ import { Tabs } from "./components/Tabs/Tabs.js";
81
80
  import { TeamOverview } from "./components/TeamOverview/TeamOverview.js";
82
81
  import { Text } from "./components/Text/Text.styles.js";
83
82
  import { TextButton, TextLink } from "./components/TextLink/TextLink.styles.js";
84
- import { ToDoList, ToDoModal, ToDoTaskMessage, ToDoTaskState } from "./components/ToDoList/ToDoList.js";
85
- import { ToDoTask } from "./components/ToDoList/ToDoListTask.js";
86
83
  import { TransactionDetails } from "./components/TransactionDetails/TransactionDetails.js";
87
84
  import { TransactionInfo } from "./components/TransactionInfo/TransactionInfo.js";
88
85
  import { QRCode, QRCodeWrapper } from "./components/QRCode/QRCode.js";
@@ -112,11 +109,8 @@ import { AnimatedSpan, LoadingDots, StokrLoader, StokrLoaderBox, loaderGif } fro
112
109
  import { InfoBox } from "./components/InfoBox/InfoBox.js";
113
110
  import { IdentityCountryRow, IdentityResidencyItem, IdentitySectionHeader } from "./components/IdentityInfo/IdentityInfo.js";
114
111
  import { Inner, Outer, ThumbH, ThumbV, TrackH, TrackV } from "./components/ComponentScroll/ComponentScroll.styles.js";
115
- import { CheckboxContext, CheckboxProvider, useCheckboxActions, useCheckboxes } from "./context/Checkbox/CheckboxContext.js";
116
112
  import { alias, getAmountBucket, getTokenBucket, hasOptedIn, identify, initAnalytics, optIn, optOut, reset, setUserProperties, timeEvent, track } from "./analytics/index.js";
117
113
  import { checkSaleTimeLeft } from "./utils/check-sale-time-left.js";
118
- import { checkTodoStatus } from "./utils/check-todo-status.js";
119
- import { generateCoreChecklistTasks, getVerifyIdentityChecklist } from "./utils/checklistGenerator.js";
120
114
  import { CopyToClipBoardTooltip, useCopyToClipboard, withCopyToClipboard } from "./utils/copyToClipboard.js";
121
115
  import { cooldownHOC, useComponentVisible, useContainerSize, useCooldown, useMobileView, usePrevious } from "./utils/customHooks.js";
122
116
  import { fixDecimals, formatDisplayNumber } from "./utils/fix-decimals.js";
@@ -129,10 +123,6 @@ import { openFile, saveAs } from "./utils/saveAs.js";
129
123
  import { ScrollToTop, scrollToElement, useScrollActions } from "./utils/scrollUtils.js";
130
124
  import { useTimer } from "./hooks/useTimer.js";
131
125
  import { useTransactionPolling } from "./hooks/useTransactionPolling.js";
132
- import { resetRuntimeConfig } from "./runtime-config.js";
133
- import { navigateToHref, pathnameIfSameOrigin } from "./routing/navigate-app.js";
134
- import { RouterWrapper } from "./routing/RouterWrapper.js";
135
- import { isAlreadyOnOnboardingFlow } from "./utils/app-urls.js";
136
126
  import { colors } from "./styles/colors.js";
137
127
  import { default as default2 } from "./styles/fonts.js";
138
128
  import { GlobalStyle } from "./styles/global.js";
@@ -183,40 +173,36 @@ import { default as default20 } from "./components/SvgIcons/OneSvg.js";
183
173
  import { default as default21 } from "./components/SvgIcons/PassportSvg.js";
184
174
  import { Reddit } from "./components/icons/Reddit.js";
185
175
  import { default as default22 } from "./components/SvgIcons/RefreshSvg.js";
186
- import { default as default23 } from "./components/taxId/register-taxid.js";
187
- import { default as default24 } from "./components/taxId/complete.js";
188
- import { default as default25 } from "./components/taxId/flow.js";
189
176
  import { SelectContainer, SelectControl, SelectIcon, SelectMenu, SelectMenuList, SelectOption, SelectValueContainer, SelectWrapper } from "./components/Input/Select.styles.js";
190
177
  import { Share } from "./components/icons/Share.js";
191
178
  import { Snackbar } from "./components/Snackbar/Snackbar.js";
192
179
  import { SnackbarContext, SnackbarProvider } from "./components/Snackbar/SnackbarProvider.js";
193
- import { default as default26 } from "./components/SvgIcons/SocialFacebook.js";
194
- import { default as default27 } from "./components/SvgIcons/SocialInstagram.js";
195
- import { default as default28 } from "./components/SvgIcons/SocialLinkedIn.js";
196
- import { default as default29 } from "./components/SvgIcons/SocialMedium.js";
197
- import { default as default30 } from "./components/SvgIcons/SocialReddit.js";
198
- import { default as default31 } from "./components/SvgIcons/SocialTelegram.js";
199
- import { default as default32 } from "./components/SvgIcons/SocialTwitter.js";
200
- import { default as default33 } from "./components/SvgIcons/SocialYoutube.js";
180
+ import { default as default23 } from "./components/SvgIcons/SocialFacebook.js";
181
+ import { default as default24 } from "./components/SvgIcons/SocialInstagram.js";
182
+ import { default as default25 } from "./components/SvgIcons/SocialLinkedIn.js";
183
+ import { default as default26 } from "./components/SvgIcons/SocialMedium.js";
184
+ import { default as default27 } from "./components/SvgIcons/SocialReddit.js";
185
+ import { default as default28 } from "./components/SvgIcons/SocialTelegram.js";
186
+ import { default as default29 } from "./components/SvgIcons/SocialTwitter.js";
187
+ import { default as default30 } from "./components/SvgIcons/SocialYoutube.js";
201
188
  import { StyledReactTable, Styles, TableWrap } from "./components/AdminDashboard/Table/Table.styles.js";
202
189
  import { SuccessModal, SuccessModal as SuccessModal2, showProgress, showSuccess } from "./components/Modal/SuccessModal/SuccessModal.js";
203
190
  import { Tab } from "./components/Tabs/Tabs.styles.js";
204
- import { default as default34 } from "./components/TabsNav/TabNav.js";
191
+ import { default as default31 } from "./components/TabsNav/TabNav.js";
205
192
  import { Telegram } from "./components/icons/Telegram.js";
206
- import { default as default35 } from "./components/SvgIcons/ThreeSvg.js";
193
+ import { default as default32 } from "./components/SvgIcons/ThreeSvg.js";
207
194
  import { Twitter } from "./components/icons/Twitter.js";
208
- import { default as default36 } from "./components/SvgIcons/TwoSidedDocumentSvg.js";
209
- import { default as default37 } from "./components/SvgIcons/TwoSvg.js";
210
- import { default as default38 } from "./components/SvgIcons/UpdateDefaultSvg.js";
211
- import { default as default39 } from "./components/SvgIcons/UpdateHardSvg.js";
212
- import { default as default40 } from "./components/SvgIcons/UpdateSoftSvg.js";
213
- import { default as default41 } from "./components/SvgIcons/UploadSvg.js";
214
- import { default as default42 } from "./components/SvgIcons/VerifiedBadge.js";
195
+ import { default as default33 } from "./components/SvgIcons/TwoSidedDocumentSvg.js";
196
+ import { default as default34 } from "./components/SvgIcons/TwoSvg.js";
197
+ import { default as default35 } from "./components/SvgIcons/UpdateDefaultSvg.js";
198
+ import { default as default36 } from "./components/SvgIcons/UpdateHardSvg.js";
199
+ import { default as default37 } from "./components/SvgIcons/UpdateSoftSvg.js";
200
+ import { default as default38 } from "./components/SvgIcons/UploadSvg.js";
201
+ import { default as default39 } from "./components/SvgIcons/VerifiedBadge.js";
215
202
  import { X } from "./components/icons/X.js";
216
203
  import { Youtube } from "./components/icons/Youtube.js";
217
204
  import { copyTextToClipboard } from "./utils/copy-text-to-clipboard.js";
218
205
  import { format } from "date-fns";
219
- import { getAnalyticsIngestUrl, getBackofficeAppUrl } from "./utils/app-urls-analytics-backoffice.js";
220
206
  import { useSnackbar } from "./components/Snackbar/useSnackbar.js";
221
207
  export {
222
208
  AccountBalance,
@@ -260,9 +246,7 @@ export {
260
246
  Check,
261
247
  CheckBoxCaption,
262
248
  Checkbox,
263
- CheckboxContext,
264
249
  CheckboxDiv,
265
- CheckboxProvider,
266
250
  CheckboxWrapperDiv,
267
251
  ChecklistCard,
268
252
  Chip,
@@ -389,7 +373,6 @@ export {
389
373
  ModalScroll,
390
374
  MultiProgressBar,
391
375
  MultiSelect,
392
- Newsletter,
393
376
  NotificationCounter,
394
377
  Number,
395
378
  NumberWithContainer,
@@ -429,11 +412,7 @@ export {
429
412
  Reddit,
430
413
  RefreshButton,
431
414
  default22 as RefreshSvg,
432
- default23 as RegisterTaxId,
433
- default24 as RegisterTaxIdComplete,
434
- default25 as RegisterTaxIdFlow,
435
415
  RequestDataBox,
436
- RouterWrapper,
437
416
  Row,
438
417
  SEO,
439
418
  SLIDER_HEIGHT,
@@ -460,14 +439,14 @@ export {
460
439
  Snackbar,
461
440
  SnackbarContext,
462
441
  SnackbarProvider,
463
- default26 as SocialFacebook,
464
- default27 as SocialInstagram,
465
- default28 as SocialLinkedIn,
466
- default29 as SocialMedium,
467
- default30 as SocialReddit,
468
- default31 as SocialTelegram,
469
- default32 as SocialTwitter,
470
- default33 as SocialYoutube,
442
+ default23 as SocialFacebook,
443
+ default24 as SocialInstagram,
444
+ default25 as SocialLinkedIn,
445
+ default26 as SocialMedium,
446
+ default27 as SocialReddit,
447
+ default28 as SocialTelegram,
448
+ default29 as SocialTwitter,
449
+ default30 as SocialYoutube,
471
450
  SpanButton,
472
451
  StatusBadge,
473
452
  StatusDot,
@@ -490,7 +469,7 @@ export {
490
469
  Switch,
491
470
  TABLET_MEDIA,
492
471
  Tab,
493
- default34 as TabNav,
472
+ default31 as TabNav,
494
473
  Table,
495
474
  TableFilterDropdown,
496
475
  TableWrap,
@@ -504,17 +483,12 @@ export {
504
483
  TextButton,
505
484
  TextLink,
506
485
  Textarea,
507
- default35 as ThreeSvg,
486
+ default32 as ThreeSvg,
508
487
  ThumbH,
509
488
  ThumbV,
510
489
  Timeline,
511
490
  TimelineStep,
512
491
  TimerComponent,
513
- ToDoList,
514
- ToDoModal,
515
- ToDoTask,
516
- ToDoTaskMessage,
517
- ToDoTaskState,
518
492
  Tooltip,
519
493
  Bubble as TooltipBubble,
520
494
  TooltipIcon,
@@ -524,16 +498,16 @@ export {
524
498
  TransactionInfo,
525
499
  TransactionTypes,
526
500
  Twitter,
527
- default36 as TwoSidedDocumentSvg,
528
- default37 as TwoSvg,
501
+ default33 as TwoSidedDocumentSvg,
502
+ default34 as TwoSvg,
529
503
  USInvestorAcreditationStatuses,
530
- default38 as UpdateDefaultSvg,
531
- default39 as UpdateHardSvg,
532
- default40 as UpdateSoftSvg,
533
- default41 as UploadSvg,
504
+ default35 as UpdateDefaultSvg,
505
+ default36 as UpdateHardSvg,
506
+ default37 as UpdateSoftSvg,
507
+ default38 as UploadSvg,
534
508
  UppercaseText,
535
509
  UserTypes,
536
- default42 as VerifiedBadge,
510
+ default39 as VerifiedBadge,
537
511
  WHITE_HEX,
538
512
  Wrapper,
539
513
  WrapperSlider,
@@ -541,7 +515,6 @@ export {
541
515
  Youtube,
542
516
  alias,
543
517
  checkSaleTimeLeft,
544
- checkTodoStatus,
545
518
  colors,
546
519
  confirm,
547
520
  cooldownHOC,
@@ -554,10 +527,7 @@ export {
554
527
  formatAmountForDisplay,
555
528
  formatCurrencyValue,
556
529
  formatDisplayNumber,
557
- generateCoreChecklistTasks,
558
530
  getAmountBucket,
559
- getAnalyticsIngestUrl,
560
- getBackofficeAppUrl,
561
531
  getCopySource,
562
532
  getCurrencyConfig,
563
533
  getCurrencyIcon,
@@ -568,14 +538,12 @@ export {
568
538
  getPasswordEntropy,
569
539
  getProjectCurrencySign,
570
540
  getTokenBucket,
571
- getVerifyIdentityChecklist,
572
541
  default3 as grid,
573
542
  hasOptedIn,
574
543
  iconsMap,
575
544
  identify,
576
545
  initAnalytics,
577
546
  interpolate,
578
- isAlreadyOnOnboardingFlow,
579
547
  isCopyKey,
580
548
  isExternalUrl,
581
549
  isPasswordValid,
@@ -583,14 +551,11 @@ export {
583
551
  km_ify,
584
552
  loaderGif,
585
553
  momentUtils,
586
- navigateToHref,
587
554
  openFile,
588
555
  optIn,
589
556
  optOut,
590
- pathnameIfSameOrigin,
591
557
  reactTippyStyle,
592
558
  reset,
593
- resetRuntimeConfig,
594
559
  resolveCopy,
595
560
  default4 as rwd,
596
561
  rwdMax,
@@ -609,8 +574,6 @@ export {
609
574
  track,
610
575
  transactionTypeDisplayNames,
611
576
  usCountries,
612
- useCheckboxActions,
613
- useCheckboxes,
614
577
  useComponentVisible,
615
578
  useContainerSize,
616
579
  useCooldown,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "3.1.1",
3
+ "version": "3.2.0",
4
4
  "description": "STOKR - Components Library",
5
5
  "author": "Bilal Hodzic <bilal@stokr.io>",
6
6
  "license": "MIT",
@@ -51,14 +51,12 @@
51
51
  "dependencies": {
52
52
  "@floating-ui/react": "^0.27.20",
53
53
  "@lottiefiles/dotlottie-react": "^0.19.4",
54
- "axios": "^1.13.5",
55
54
  "country-flag-icons": "^1.6.17",
56
55
  "date-fns": "^4.1.0",
57
56
  "date-fns-tz": "^3.2.0",
58
57
  "dompurify": "^3.2.4",
59
58
  "formik": "^2.2.9",
60
59
  "html-react-parser": "^5.0.6",
61
- "js-cookie": "^3.0.5",
62
60
  "mixpanel-browser": "^2.74.0",
63
61
  "moment": "^2.30.1",
64
62
  "moment-timezone": "^0.6.0",
@@ -1,27 +0,0 @@
1
- import Cookies from "js-cookie";
2
- import axiosInstance from "../model/axios.js";
3
- const fetchData = async (url, data) => {
4
- const accessToken = Cookies.get("STOKR_ACCESS_TOKEN");
5
- const parsedData = JSON.stringify(data ?? {});
6
- if (!accessToken) {
7
- console.log("no access token");
8
- }
9
- try {
10
- const result = await axiosInstance({
11
- method: "POST",
12
- url,
13
- data: parsedData,
14
- headers: {
15
- Authorization: `Bearer ${accessToken}`
16
- }
17
- });
18
- return result.data;
19
- } catch (error) {
20
- console.log(`Error: ${error}`);
21
- throw error;
22
- }
23
- };
24
- export {
25
- fetchData as default,
26
- fetchData
27
- };
@@ -1,19 +0,0 @@
1
- import axiosInstance from "../model/axiosPublic.js";
2
- const fetchDataPublic = async (url, data) => {
3
- const parsedData = JSON.stringify(data);
4
- try {
5
- const result = await axiosInstance({
6
- method: "POST",
7
- url,
8
- data: parsedData
9
- });
10
- return result.data;
11
- } catch (error) {
12
- console.log(`Error: ${error}`);
13
- throw error;
14
- }
15
- };
16
- export {
17
- fetchDataPublic as default,
18
- fetchDataPublic
19
- };
@@ -1,120 +0,0 @@
1
- import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
- import { useState } from "react";
3
- import fetchDataPublic from "../../api/fetchDataPublic.js";
4
- import { Subscribe, LayoutWrapper, Container, SubscribeTitle, SubscribeForm, SubscribeInputBox, SubscribeInput, SubscribeInputError, SubscribeSubmit } from "./Newsletter.styles.js";
5
- const Newsletter = () => {
6
- const [formData, setFormData] = useState({
7
- name: "",
8
- email: "",
9
- errorName: "",
10
- errorEmail: "",
11
- submitSuccess: false
12
- });
13
- const validateForm = () => {
14
- const { name, email } = formData;
15
- let errorName = "";
16
- let errorEmail = "";
17
- if (!name) {
18
- errorName = "Oops, this can't be blank";
19
- }
20
- if (!email) {
21
- errorEmail = "Oops, this can't be blank";
22
- } else if (!/.+@.+\..+/.test(email)) {
23
- errorEmail = "Oops, that's not a valid address";
24
- }
25
- setFormData((prev) => ({
26
- ...prev,
27
- errorName,
28
- errorEmail
29
- }));
30
- return !errorName && !errorEmail;
31
- };
32
- const handleChange = (e) => {
33
- const { name, value } = e.target;
34
- setFormData((prev) => ({
35
- ...prev,
36
- [name]: value
37
- }));
38
- };
39
- const handleSubmit = async (e) => {
40
- e.preventDefault();
41
- if (!validateForm()) {
42
- return;
43
- }
44
- try {
45
- await fetchDataPublic("emails/subscribe", {
46
- name: formData.name,
47
- email: formData.email,
48
- listName: "newsletter"
49
- });
50
- setFormData({
51
- name: "",
52
- email: "",
53
- errorName: "",
54
- errorEmail: "",
55
- submitSuccess: true
56
- });
57
- setTimeout(() => {
58
- setFormData((prev) => ({
59
- ...prev,
60
- submitSuccess: false
61
- }));
62
- }, 5e3);
63
- } catch (_error) {
64
- console.log(`
65
- ### ERROR ADDING SUBSCRIBER ###
66
-
67
- ${e}`);
68
- }
69
- };
70
- const isFormValid = () => {
71
- const { name, email } = formData;
72
- return name.trim() !== "" && email.trim() !== "" && /.+@.+\..+/.test(email);
73
- };
74
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Subscribe, { children: /* @__PURE__ */ jsx(LayoutWrapper, { noBorder: true, minimal: true, children: /* @__PURE__ */ jsxs(Container, { compact: true, children: [
75
- /* @__PURE__ */ jsx(SubscribeTitle, { as: "h3", children: "SIGN UP FOR THE STOKR NEWSLETTER" }),
76
- /* @__PURE__ */ jsxs(SubscribeForm, { onSubmit: handleSubmit, id: "newsletter-form", children: [
77
- /* @__PURE__ */ jsxs(SubscribeInputBox, { children: [
78
- /* @__PURE__ */ jsx(
79
- SubscribeInput,
80
- {
81
- name: "name",
82
- type: "text",
83
- placeholder: "Your Name",
84
- value: formData.name,
85
- onChange: handleChange,
86
- "data-id": "newsletter-name-input"
87
- }
88
- ),
89
- formData.errorName && /* @__PURE__ */ jsx(SubscribeInputError, { children: formData.errorName })
90
- ] }),
91
- /* @__PURE__ */ jsxs(SubscribeInputBox, { children: [
92
- /* @__PURE__ */ jsx(
93
- SubscribeInput,
94
- {
95
- name: "email",
96
- type: "email",
97
- placeholder: "Your Email",
98
- value: formData.email,
99
- onChange: handleChange,
100
- "data-id": "newsletter-email-input"
101
- }
102
- ),
103
- formData.errorEmail && /* @__PURE__ */ jsx(SubscribeInputError, { children: formData.errorEmail })
104
- ] }),
105
- /* @__PURE__ */ jsx(
106
- SubscribeSubmit,
107
- {
108
- submitSuccess: formData.submitSuccess,
109
- id: "newsletter-button-submit",
110
- type: "submit",
111
- disabled: !isFormValid(),
112
- children: formData.submitSuccess ? "Success!" : "Submit"
113
- }
114
- )
115
- ] })
116
- ] }) }) }) });
117
- };
118
- export {
119
- Newsletter
120
- };