@saasquatch/mint-components 2.1.9-5 → 2.1.9-7

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 (43) hide show
  1. package/dist/cjs/{extractProps-fd93ba62.js → extractProps-e9c55ba8.js} +14 -0
  2. package/dist/cjs/sqm-big-stat_45.cjs.entry.js +4 -5
  3. package/dist/cjs/sqm-email-verification_2.cjs.entry.js +4 -8
  4. package/dist/cjs/sqm-widget-verification.cjs.entry.js +16 -7
  5. package/dist/collection/collection-manifest.json +1 -1
  6. package/dist/collection/components/sqm-partner-info-modal/sqm-partner-info-modal.js +8 -12
  7. package/dist/collection/components/sqm-partner-info-modal/usePartnerInfoModal.js +1 -1
  8. package/dist/collection/components/sqm-widget-verification/useWidgetVerification.js +14 -4
  9. package/dist/esm/{extractProps-ae1afbb3.js → extractProps-54064fb0.js} +14 -1
  10. package/dist/esm/sqm-big-stat_45.entry.js +1 -2
  11. package/dist/esm/sqm-email-verification_2.entry.js +4 -8
  12. package/dist/esm/sqm-widget-verification.entry.js +15 -6
  13. package/dist/esm-es5/extractProps-54064fb0.js +1 -0
  14. package/dist/esm-es5/sqm-big-stat_45.entry.js +1 -1
  15. package/dist/esm-es5/sqm-email-verification_2.entry.js +1 -1
  16. package/dist/esm-es5/sqm-widget-verification.entry.js +1 -1
  17. package/dist/mint-components/mint-components.esm.js +1 -1
  18. package/dist/mint-components/p-0797a946.js +1 -0
  19. package/dist/mint-components/{p-52713f92.entry.js → p-2c962fa2.entry.js} +7 -7
  20. package/dist/mint-components/p-4b365f1f.system.js +1 -1
  21. package/dist/mint-components/p-9b05116b.system.entry.js +1 -0
  22. package/dist/mint-components/p-a1529aef.system.entry.js +1 -0
  23. package/dist/mint-components/p-a9855b29.system.entry.js +1 -0
  24. package/dist/mint-components/{p-5bbdeacd.entry.js → p-c0953cd9.entry.js} +5 -2
  25. package/dist/mint-components/p-e55aafe9.system.js +1 -0
  26. package/dist/mint-components/{p-5a446168.entry.js → p-e6924adb.entry.js} +1 -1
  27. package/dist/types/components/sqm-partner-info-modal/sqm-partner-info-modal.d.ts +3 -3
  28. package/dist/types/components/sqm-partner-info-modal/usePartnerInfoModal.d.ts +1 -0
  29. package/dist/types/components.d.ts +5 -5
  30. package/docs/docs.docx +0 -0
  31. package/docs/raisins.json +1 -1
  32. package/package.json +1 -1
  33. package/dist/cjs/parseStates-d1effc19.js +0 -16
  34. package/dist/esm/parseStates-ed75e224.js +0 -14
  35. package/dist/esm-es5/extractProps-ae1afbb3.js +0 -1
  36. package/dist/esm-es5/parseStates-ed75e224.js +0 -1
  37. package/dist/mint-components/p-115dfc03.system.js +0 -1
  38. package/dist/mint-components/p-13f3a647.js +0 -1
  39. package/dist/mint-components/p-26468242.js +0 -1
  40. package/dist/mint-components/p-a0cd6cc7.system.entry.js +0 -1
  41. package/dist/mint-components/p-a8645c1b.system.js +0 -1
  42. package/dist/mint-components/p-aeb01a77.system.entry.js +0 -1
  43. package/dist/mint-components/p-f5755143.system.entry.js +0 -1
@@ -1,5 +1,18 @@
1
1
  'use strict';
2
2
 
3
+ function parseStates(states) {
4
+ if (typeof states === "string") {
5
+ try {
6
+ return JSON.parse(states);
7
+ }
8
+ catch (e) {
9
+ return undefined;
10
+ }
11
+ }
12
+ if (typeof states === "object")
13
+ return states;
14
+ }
15
+
3
16
  /**
4
17
  * Util function for getting just the props with a certain prefix.
5
18
  * @param props Text props on stencil component
@@ -19,3 +32,4 @@ function extractProps(props, prefix) {
19
32
  }
20
33
 
21
34
  exports.extractProps = extractProps;
35
+ exports.parseStates = parseStates;
@@ -30,8 +30,7 @@ const ErrorView = require('./ErrorView-ee7b0f36.js');
30
30
  const ShadowViewAddon = require('./ShadowViewAddon-d679ec76.js');
31
31
  require('./sqm-portal-container-view-70a47420.js');
32
32
  const data = require('./data-e83f8a41.js');
33
- const parseStates = require('./parseStates-d1effc19.js');
34
- const extractProps = require('./extractProps-fd93ba62.js');
33
+ const extractProps = require('./extractProps-e9c55ba8.js');
35
34
  require('./eventKeys-7af4df4d.js');
36
35
  const usePayoutStatus = require('./usePayoutStatus-cf050a03.js');
37
36
 
@@ -3393,7 +3392,7 @@ const PayoutStatusAlert = class {
3393
3392
  }
3394
3393
  };
3395
3394
  function useDemoPayoutStatusAlert(props) {
3396
- const states = parseStates.parseStates(props.stateController);
3395
+ const states = extractProps.parseStates(props.stateController);
3397
3396
  const formatted = Object.keys(states).reduce((prev, key) => key === "sqm-payout-status-alert"
3398
3397
  ? { ...prev, ...states[key] }
3399
3398
  : { ...prev, [`${key}_stateController`]: states[key] }, {});
@@ -5772,7 +5771,7 @@ function EmptySlot$1() {
5772
5771
  return (index.h("slot", { name: "empty" }, index.h("sqm-empty", { emptyStateImage: "https://res.cloudinary.com/saasquatch/image/upload/v1644360953/squatch-assets/empty_exchange2.png", emptyStateHeader: "Redeem rewards", emptyStateText: "Use your points to redeem rewards once they become available" })));
5773
5772
  }
5774
5773
  function useRewardExchangeListDemo(props) {
5775
- const states = parseStates.parseStates(props.stateController);
5774
+ const states = extractProps.parseStates(props.stateController);
5776
5775
  const formatted = Object.keys(states).reduce((prev, key) => key === "sqm-reward-exchange-list"
5777
5776
  ? { ...prev, ...states[key] }
5778
5777
  : { ...prev, [`${key}_stateController`]: states[key] }, {});
@@ -7736,7 +7735,7 @@ function useDemoTaxAndCash(props) {
7736
7735
  namespace: data.TAX_CONTEXT_NAMESPACE,
7737
7736
  initialValue: "/1",
7738
7737
  });
7739
- const states = parseStates.parseStates(props.stateController);
7738
+ const states = extractProps.parseStates(props.stateController);
7740
7739
  const formatted = Object.keys(states).reduce((prev, key) => key === "sqm-tax-and-cash"
7741
7740
  ? { ...prev, ...states[key] }
7742
7741
  : { ...prev, [`${key}_stateController`]: states[key] }, {});
@@ -11,7 +11,6 @@ const utils = require('./utils-6847bc06.js');
11
11
  const JSS = require('./JSS-8503a151.js');
12
12
  const sqmTextSpanView = require('./sqm-text-span-view-f274fdf2.js');
13
13
  const sqmPartnerInfoModalView = require('./sqm-partner-info-modal-view-e3faede9.js');
14
- const parseStates = require('./parseStates-d1effc19.js');
15
14
  const keys = require('./keys-cff24974.js');
16
15
  const eventKeys = require('./eventKeys-7af4df4d.js');
17
16
  const useVerificationEmail = require('./useVerificationEmail-994bc32f.js');
@@ -625,7 +624,7 @@ function usePartnerInfoModal(props) {
625
624
  open: showModal,
626
625
  loading: userLoading || countriesLoading || currenciesLoading,
627
626
  submitting: connectLoading,
628
- isExistingPartner: (impactConnection === null || impactConnection === void 0 ? void 0 : impactConnection.connected) || (impactConnection === null || impactConnection === void 0 ? void 0 : impactConnection.publisher),
627
+ isExistingPartner: impactConnection === null || impactConnection === void 0 ? void 0 : impactConnection.publisher,
629
628
  countryCode,
630
629
  currency,
631
630
  error,
@@ -727,7 +726,7 @@ const PartnerInfoModal = class {
727
726
  /**
728
727
  * @undocumented
729
728
  * @componentState { "title": "New partner", "props": { "states": { "open": true, "isExistingPartner": false } } }
730
- * @componentState { "title": "Existing partner", "props": { "states": { "open": true, "isExistingPartner": true } } }
729
+ * @componentState { "title": "Existing partner", "props": { "states": { "open": true, "isExistingPartner": true, "countryCode": "US", "currency": "USD" } } }
731
730
  * @componentState { "title": "Connected (hidden)", "props": { "states": { "open": false } } }
732
731
  */
733
732
  this.stateController = "{}";
@@ -749,10 +748,7 @@ function useDemoPartnerInfoModal(props) {
749
748
  const [countryCode, setCountryCode] = domContextHooks_module.useState("US");
750
749
  const [currency, setCurrency] = domContextHooks_module.useState("");
751
750
  const [error, setError] = domContextHooks_module.useState("");
752
- const states = parseStates.parseStates(props.stateController);
753
- const formatted = Object.keys(states).reduce((prev, key) => key === "sqm-partner-info-modal"
754
- ? { ...prev, ...states[key] }
755
- : { ...prev, [`${key}_stateController`]: states[key] }, {});
751
+ // @ts-ignore
756
752
  return cjs.cjs({
757
753
  states: {
758
754
  brandName: "Test Brand",
@@ -806,7 +802,7 @@ function useDemoPartnerInfoModal(props) {
806
802
  supportDescriptionExistingPartner: props.supportDescriptionExistingPartner,
807
803
  modalHeaderExistingPartner: props.modalHeaderExistingPartner,
808
804
  },
809
- }, formatted || {}, { arrayMerge: (_, a) => a });
805
+ }, props.demoData || props.stateController || {}, { arrayMerge: (_, a) => a });
810
806
  }
811
807
 
812
808
  exports.sqm_email_verification = WidgetEmailVerification;
@@ -7,8 +7,7 @@ const domContextHooks_module = require('./dom-context-hooks.module-e7b6727c.js')
7
7
  const index_module = require('./index.module-42d413d9.js');
8
8
  const cjs = require('./cjs-1066ec21.js');
9
9
  const utils = require('./utils-6847bc06.js');
10
- const parseStates = require('./parseStates-d1effc19.js');
11
- const extractProps = require('./extractProps-fd93ba62.js');
10
+ const extractProps = require('./extractProps-e9c55ba8.js');
12
11
  const keys = require('./keys-cff24974.js');
13
12
 
14
13
  const USER_LOOKUP = index_module.dist.gql `
@@ -23,6 +22,9 @@ const USER_LOOKUP = index_module.dist.gql `
23
22
  email
24
23
  emailVerified
25
24
  }
25
+ impactConnection {
26
+ connected
27
+ }
26
28
  }
27
29
  }
28
30
  }
@@ -43,15 +45,22 @@ function useWidgetVerification() {
43
45
  const [fetch] = index_module.Xe(USER_LOOKUP);
44
46
  domContextHooks_module.useEffect(() => {
45
47
  const checkUser = async () => {
46
- var _a, _b, _c;
48
+ var _a, _b, _c, _d, _e;
47
49
  try {
48
50
  const res = await fetch({});
49
51
  if (!res || res instanceof Error)
50
52
  throw new Error();
51
- if ((_a = res === null || res === void 0 ? void 0 : res.viewer) === null || _a === void 0 ? void 0 : _a.emailVerified)
52
- setContext(true);
53
- else if ((_c = (_b = res === null || res === void 0 ? void 0 : res.viewer) === null || _b === void 0 ? void 0 : _b.managedIdentity) === null || _c === void 0 ? void 0 : _c.emailVerified)
53
+ // Flow changed to send email -> verify code -> show early partner creation modal
54
+ const emailVerified = ((_a = res === null || res === void 0 ? void 0 : res.viewer) === null || _a === void 0 ? void 0 : _a.emailVerified) || ((_c = (_b = res === null || res === void 0 ? void 0 : res.viewer) === null || _b === void 0 ? void 0 : _b.managedIdentity) === null || _c === void 0 ? void 0 : _c.emailVerified);
55
+ const isConnected = (_e = (_d = res === null || res === void 0 ? void 0 : res.viewer) === null || _d === void 0 ? void 0 : _d.impactConnection) === null || _e === void 0 ? void 0 : _e.connected;
56
+ if (isConnected) {
57
+ // Partner already created, show widget content
54
58
  setContext(true);
59
+ }
60
+ else if (emailVerified) {
61
+ // Email verified but no partner yet, show partner modal
62
+ setShowPartnerModal(true);
63
+ }
55
64
  }
56
65
  catch (e) {
57
66
  console.error("Could not fetch user information:", e);
@@ -286,7 +295,7 @@ function useDemoWidgetVerificationInternal(props) {
286
295
  initialValue: undefined,
287
296
  });
288
297
  const setContext = index_module.En(keys.VERIFICATION_PARENT_NAMESPACE);
289
- const states = parseStates.parseStates(props.stateController);
298
+ const states = extractProps.parseStates(props.stateController);
290
299
  const formatted = Object.keys(states).reduce((prev, key) => key === "sqm-widget-verification"
291
300
  ? { ...prev, ...states[key] }
292
301
  : { ...prev, [`${key}_stateController`]: states[key] }, {});
@@ -5,6 +5,7 @@
5
5
  "./components/tax-and-cash/sqm-indirect-tax-form/sqm-indirect-tax-form.js",
6
6
  "./components/sqm-referral-codes/sqm-referral-codes.js",
7
7
  "./components/sqm-pagination/sqm-pagination.js",
8
+ "./components/sqm-partner-info-modal/sqm-partner-info-modal.js",
8
9
  "./components/sqm-password-field/sqm-password-field.js",
9
10
  "./components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert.js",
10
11
  "./components/sqm-referral-table/sqm-referral-table.js",
@@ -54,7 +55,6 @@
54
55
  "./components/sqm-navigation-menu/sqm-navigation-menu.js",
55
56
  "./components/sqm-navigation-sidebar/sqm-navigation-sidebar.js",
56
57
  "./components/sqm-navigation-sidebar-item/sqm-navigation-sidebar-item.js",
57
- "./components/sqm-partner-info-modal/sqm-partner-info-modal.js",
58
58
  "./components/sqm-payout-button-scroll/sqm-payout-button-scroll.js",
59
59
  "./components/sqm-popup-container/sqm-popup-container.js",
60
60
  "./components/sqm-portal-change-marketing/sqm-portal-change-marketing.js",
@@ -2,10 +2,9 @@ import { isDemo } from "@saasquatch/component-boilerplate";
2
2
  import { useState, withHooks } from "@saasquatch/stencil-hooks";
3
3
  import { Component, Prop, h } from "@stencil/core";
4
4
  import deepmerge from "deepmerge";
5
- import { parseStates } from "../../utils/parseStates";
6
5
  import { getProps } from "../../utils/utils";
7
6
  import { PartnerInfoModalView, } from "./sqm-partner-info-modal-view";
8
- import { usePartnerInfoModal } from "./usePartnerInfoModal";
7
+ import { usePartnerInfoModal, } from "./usePartnerInfoModal";
9
8
  /**
10
9
  * @uiName Partner Info Modal
11
10
  * @exampleGroup Tax and Cash
@@ -92,7 +91,7 @@ export class PartnerInfoModal {
92
91
  /**
93
92
  * @undocumented
94
93
  * @componentState { "title": "New partner", "props": { "states": { "open": true, "isExistingPartner": false } } }
95
- * @componentState { "title": "Existing partner", "props": { "states": { "open": true, "isExistingPartner": true } } }
94
+ * @componentState { "title": "Existing partner", "props": { "states": { "open": true, "isExistingPartner": true, "countryCode": "US", "currency": "USD" } } }
96
95
  * @componentState { "title": "Connected (hidden)", "props": { "states": { "open": false } } }
97
96
  */
98
97
  this.stateController = "{}";
@@ -445,7 +444,7 @@ export class PartnerInfoModal {
445
444
  "text": "{ \"title\": \"New partner\", \"props\": { \"states\": { \"open\": true, \"isExistingPartner\": false } } }",
446
445
  "name": "componentState"
447
446
  }, {
448
- "text": "{ \"title\": \"Existing partner\", \"props\": { \"states\": { \"open\": true, \"isExistingPartner\": true } } }",
447
+ "text": "{ \"title\": \"Existing partner\", \"props\": { \"states\": { \"open\": true, \"isExistingPartner\": true, \"countryCode\": \"US\", \"currency\": \"USD\" } } }",
449
448
  "name": "componentState"
450
449
  }, {
451
450
  "text": "{ \"title\": \"Connected (hidden)\", \"props\": { \"states\": { \"open\": false } } }",
@@ -461,16 +460,16 @@ export class PartnerInfoModal {
461
460
  "type": "unknown",
462
461
  "mutable": false,
463
462
  "complexType": {
464
- "original": "DemoData<PartnerInfoModalViewProps>",
463
+ "original": "DemoData<PartnerInfoModalResult>",
465
464
  "resolved": "{ states?: { open: boolean; loading: boolean; submitting: boolean; isExistingPartner: boolean; countryCode: string; currency: string; error: string; success: boolean; brandName: string; filteredCountries: { countryCode: string; displayName: string; }[]; filteredCurrencies: { currencyCode: string; displayName: string; }[]; }; }",
466
465
  "references": {
467
466
  "DemoData": {
468
467
  "location": "import",
469
468
  "path": "../../global/demo"
470
469
  },
471
- "PartnerInfoModalViewProps": {
470
+ "PartnerInfoModalResult": {
472
471
  "location": "import",
473
- "path": "./sqm-partner-info-modal-view"
472
+ "path": "./usePartnerInfoModal"
474
473
  }
475
474
  }
476
475
  },
@@ -493,10 +492,7 @@ function useDemoPartnerInfoModal(props) {
493
492
  const [countryCode, setCountryCode] = useState("US");
494
493
  const [currency, setCurrency] = useState("");
495
494
  const [error, setError] = useState("");
496
- const states = parseStates(props.stateController);
497
- const formatted = Object.keys(states).reduce((prev, key) => key === "sqm-partner-info-modal"
498
- ? { ...prev, ...states[key] }
499
- : { ...prev, [`${key}_stateController`]: states[key] }, {});
495
+ // @ts-ignore
500
496
  return deepmerge({
501
497
  states: {
502
498
  brandName: "Test Brand",
@@ -550,5 +546,5 @@ function useDemoPartnerInfoModal(props) {
550
546
  supportDescriptionExistingPartner: props.supportDescriptionExistingPartner,
551
547
  modalHeaderExistingPartner: props.modalHeaderExistingPartner,
552
548
  },
553
- }, formatted || {}, { arrayMerge: (_, a) => a });
549
+ }, props.demoData || props.stateController || {}, { arrayMerge: (_, a) => a });
554
550
  }
@@ -210,7 +210,7 @@ export function usePartnerInfoModal(props) {
210
210
  open: showModal,
211
211
  loading: userLoading || countriesLoading || currenciesLoading,
212
212
  submitting: connectLoading,
213
- isExistingPartner: (impactConnection === null || impactConnection === void 0 ? void 0 : impactConnection.connected) || (impactConnection === null || impactConnection === void 0 ? void 0 : impactConnection.publisher),
213
+ isExistingPartner: impactConnection === null || impactConnection === void 0 ? void 0 : impactConnection.publisher,
214
214
  countryCode,
215
215
  currency,
216
216
  error,
@@ -15,6 +15,9 @@ const USER_LOOKUP = gql `
15
15
  email
16
16
  emailVerified
17
17
  }
18
+ impactConnection {
19
+ connected
20
+ }
18
21
  }
19
22
  }
20
23
  }
@@ -35,15 +38,22 @@ export function useWidgetVerification() {
35
38
  const [fetch] = useLazyQuery(USER_LOOKUP);
36
39
  useEffect(() => {
37
40
  const checkUser = async () => {
38
- var _a, _b, _c;
41
+ var _a, _b, _c, _d, _e;
39
42
  try {
40
43
  const res = await fetch({});
41
44
  if (!res || res instanceof Error)
42
45
  throw new Error();
43
- if ((_a = res === null || res === void 0 ? void 0 : res.viewer) === null || _a === void 0 ? void 0 : _a.emailVerified)
44
- setContext(true);
45
- else if ((_c = (_b = res === null || res === void 0 ? void 0 : res.viewer) === null || _b === void 0 ? void 0 : _b.managedIdentity) === null || _c === void 0 ? void 0 : _c.emailVerified)
46
+ // Flow changed to send email -> verify code -> show early partner creation modal
47
+ const emailVerified = ((_a = res === null || res === void 0 ? void 0 : res.viewer) === null || _a === void 0 ? void 0 : _a.emailVerified) || ((_c = (_b = res === null || res === void 0 ? void 0 : res.viewer) === null || _b === void 0 ? void 0 : _b.managedIdentity) === null || _c === void 0 ? void 0 : _c.emailVerified);
48
+ const isConnected = (_e = (_d = res === null || res === void 0 ? void 0 : res.viewer) === null || _d === void 0 ? void 0 : _d.impactConnection) === null || _e === void 0 ? void 0 : _e.connected;
49
+ if (isConnected) {
50
+ // Partner already created, show widget content
46
51
  setContext(true);
52
+ }
53
+ else if (emailVerified) {
54
+ // Email verified but no partner yet, show partner modal
55
+ setShowPartnerModal(true);
56
+ }
47
57
  }
48
58
  catch (e) {
49
59
  console.error("Could not fetch user information:", e);
@@ -1,3 +1,16 @@
1
+ function parseStates(states) {
2
+ if (typeof states === "string") {
3
+ try {
4
+ return JSON.parse(states);
5
+ }
6
+ catch (e) {
7
+ return undefined;
8
+ }
9
+ }
10
+ if (typeof states === "object")
11
+ return states;
12
+ }
13
+
1
14
  /**
2
15
  * Util function for getting just the props with a certain prefix.
3
16
  * @param props Text props on stencil component
@@ -16,4 +29,4 @@ function extractProps(props, prefix) {
16
29
  return formattedProps;
17
30
  }
18
31
 
19
- export { extractProps as e };
32
+ export { extractProps as e, parseStates as p };
@@ -26,8 +26,7 @@ import { E as ErrorView } from './ErrorView-74cb3af8.js';
26
26
  import { u as useDemoBigStat, V as useBigStat, B as BigStatView, C as CardFeedView, d as CheckboxFieldView, e as CouponCodeView, D as DropdownFieldView, E as EditProfileView, H as HeroView, I as InputFieldView, Q as LeadDropdownFieldView, O as LeadFormView, W as withShadowView, L as LeaderboardView, N as NameFieldsView, f as ChangeMarktingView, P as PortalChangePasswordView, g as PortalFooterView, h as PortalFrameView, c as BaseRegistrationFormView, R as ReferralIframeView, i as RewardExchangeView, X as demoRewardExchange, G as useShareButton, a as ShareButtonView, J as useShareLink, S as StatContainerView, T as TaskCardView } from './ShadowViewAddon-d382a63e.js';
27
27
  import './sqm-portal-container-view-a8c708cd.js';
28
28
  import { T as TAX_CONTEXT_NAMESPACE, a as TAX_FORM_CONTEXT_NAMESPACE, U as USER_FORM_CONTEXT_NAMESPACE, C as CURRENCIES_NAMESPACE, b as COUNTRIES_NAMESPACE, S as SORTED_COUNTRIES_NAMESPACE, g as getCountryObj, c as USER_QUERY_NAMESPACE, G as GET_USER$2, d as COUNTRIES_QUERY_NAMESPACE, e as GET_COUNTRIES, h as FINANCE_NETWORK_SETTINGS_NAMESPACE, i as GET_FINANCE_NETWORK_SETTINGS, j as CURRENCIES_QUERY_NAMESPACE, k as GET_CURRENCIES, L as LoadingView } from './data-a6752028.js';
29
- import { p as parseStates } from './parseStates-ed75e224.js';
30
- import { e as extractProps } from './extractProps-ae1afbb3.js';
29
+ import { p as parseStates, e as extractProps } from './extractProps-54064fb0.js';
31
30
  import './eventKeys-f76b6a03.js';
32
31
  import { u as usePayoutStatus } from './usePayoutStatus-24145412.js';
33
32
 
@@ -7,7 +7,6 @@ import { g as getProps } from './utils-334c1e34.js';
7
7
  import { c as createStyleSheet } from './JSS-67b5cff8.js';
8
8
  import { T as TextSpanView } from './sqm-text-span-view-738acfb3.js';
9
9
  import { P as PartnerInfoModalView } from './sqm-partner-info-modal-view-77c231af.js';
10
- import { p as parseStates } from './parseStates-ed75e224.js';
11
10
  import { S as SHOW_CODE_NAMESPACE, V as VERIFICATION_EMAIL_NAMESPACE, a as VERIFICATION_PARENT_NAMESPACE } from './keys-406491dc.js';
12
11
  import { T as TAX_FORM_UPDATED_EVENT_KEY } from './eventKeys-f76b6a03.js';
13
12
  import { u as useVerificationEmail } from './useVerificationEmail-5c6cd733.js';
@@ -621,7 +620,7 @@ function usePartnerInfoModal(props) {
621
620
  open: showModal,
622
621
  loading: userLoading || countriesLoading || currenciesLoading,
623
622
  submitting: connectLoading,
624
- isExistingPartner: (impactConnection === null || impactConnection === void 0 ? void 0 : impactConnection.connected) || (impactConnection === null || impactConnection === void 0 ? void 0 : impactConnection.publisher),
623
+ isExistingPartner: impactConnection === null || impactConnection === void 0 ? void 0 : impactConnection.publisher,
625
624
  countryCode,
626
625
  currency,
627
626
  error,
@@ -723,7 +722,7 @@ const PartnerInfoModal = class {
723
722
  /**
724
723
  * @undocumented
725
724
  * @componentState { "title": "New partner", "props": { "states": { "open": true, "isExistingPartner": false } } }
726
- * @componentState { "title": "Existing partner", "props": { "states": { "open": true, "isExistingPartner": true } } }
725
+ * @componentState { "title": "Existing partner", "props": { "states": { "open": true, "isExistingPartner": true, "countryCode": "US", "currency": "USD" } } }
727
726
  * @componentState { "title": "Connected (hidden)", "props": { "states": { "open": false } } }
728
727
  */
729
728
  this.stateController = "{}";
@@ -745,10 +744,7 @@ function useDemoPartnerInfoModal(props) {
745
744
  const [countryCode, setCountryCode] = useState("US");
746
745
  const [currency, setCurrency] = useState("");
747
746
  const [error, setError] = useState("");
748
- const states = parseStates(props.stateController);
749
- const formatted = Object.keys(states).reduce((prev, key) => key === "sqm-partner-info-modal"
750
- ? { ...prev, ...states[key] }
751
- : { ...prev, [`${key}_stateController`]: states[key] }, {});
747
+ // @ts-ignore
752
748
  return cjs({
753
749
  states: {
754
750
  brandName: "Test Brand",
@@ -802,7 +798,7 @@ function useDemoPartnerInfoModal(props) {
802
798
  supportDescriptionExistingPartner: props.supportDescriptionExistingPartner,
803
799
  modalHeaderExistingPartner: props.modalHeaderExistingPartner,
804
800
  },
805
- }, formatted || {}, { arrayMerge: (_, a) => a });
801
+ }, props.demoData || props.stateController || {}, { arrayMerge: (_, a) => a });
806
802
  }
807
803
 
808
804
  export { WidgetEmailVerification as sqm_email_verification, PartnerInfoModal as sqm_partner_info_modal };
@@ -3,8 +3,7 @@ import { k as useState, f as useEffect, n as h } from './dom-context-hooks.modul
3
3
  import { d as dist, J, I as In, q as En, X as Xe, i as isDemo } from './index.module-e266b4d7.js';
4
4
  import { c as cjs } from './cjs-bdfb4486.js';
5
5
  import { g as getProps } from './utils-334c1e34.js';
6
- import { p as parseStates } from './parseStates-ed75e224.js';
7
- import { e as extractProps } from './extractProps-ae1afbb3.js';
6
+ import { e as extractProps, p as parseStates } from './extractProps-54064fb0.js';
8
7
  import { S as SHOW_CODE_NAMESPACE, V as VERIFICATION_EMAIL_NAMESPACE, a as VERIFICATION_PARENT_NAMESPACE } from './keys-406491dc.js';
9
8
 
10
9
  const USER_LOOKUP = dist.gql `
@@ -19,6 +18,9 @@ const USER_LOOKUP = dist.gql `
19
18
  email
20
19
  emailVerified
21
20
  }
21
+ impactConnection {
22
+ connected
23
+ }
22
24
  }
23
25
  }
24
26
  }
@@ -39,15 +41,22 @@ function useWidgetVerification() {
39
41
  const [fetch] = Xe(USER_LOOKUP);
40
42
  useEffect(() => {
41
43
  const checkUser = async () => {
42
- var _a, _b, _c;
44
+ var _a, _b, _c, _d, _e;
43
45
  try {
44
46
  const res = await fetch({});
45
47
  if (!res || res instanceof Error)
46
48
  throw new Error();
47
- if ((_a = res === null || res === void 0 ? void 0 : res.viewer) === null || _a === void 0 ? void 0 : _a.emailVerified)
48
- setContext(true);
49
- else if ((_c = (_b = res === null || res === void 0 ? void 0 : res.viewer) === null || _b === void 0 ? void 0 : _b.managedIdentity) === null || _c === void 0 ? void 0 : _c.emailVerified)
49
+ // Flow changed to send email -> verify code -> show early partner creation modal
50
+ const emailVerified = ((_a = res === null || res === void 0 ? void 0 : res.viewer) === null || _a === void 0 ? void 0 : _a.emailVerified) || ((_c = (_b = res === null || res === void 0 ? void 0 : res.viewer) === null || _b === void 0 ? void 0 : _b.managedIdentity) === null || _c === void 0 ? void 0 : _c.emailVerified);
51
+ const isConnected = (_e = (_d = res === null || res === void 0 ? void 0 : res.viewer) === null || _d === void 0 ? void 0 : _d.impactConnection) === null || _e === void 0 ? void 0 : _e.connected;
52
+ if (isConnected) {
53
+ // Partner already created, show widget content
50
54
  setContext(true);
55
+ }
56
+ else if (emailVerified) {
57
+ // Email verified but no partner yet, show partner modal
58
+ setShowPartnerModal(true);
59
+ }
51
60
  }
52
61
  catch (e) {
53
62
  console.error("Could not fetch user information:", e);
@@ -0,0 +1 @@
1
+ var __assign=this&&this.__assign||function(){__assign=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++){r=arguments[e];for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s))t[s]=r[s]}return t};return __assign.apply(this,arguments)};function parseStates(t){if(typeof t==="string"){try{return JSON.parse(t)}catch(t){return undefined}}if(typeof t==="object")return t}function extractProps(t,r){var e=Object.keys(t).filter((function(t){return t.startsWith(r)}));var n=e.reduce((function(e,n){var s;var a=n.replace(r,"");return __assign(__assign({},e),(s={},s[a]=t[n],s))}),{});return n}export{extractProps as e,parseStates as p};