@saasquatch/mint-components 2.1.8-0 → 2.1.8-1

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 (50) hide show
  1. package/dist/cjs/{ShadowViewAddon-1d15cdf7.js → ShadowViewAddon-5ce32291.js} +89 -0
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/mint-components.cjs.js +1 -1
  4. package/dist/cjs/sqm-banking-info-form_10.cjs.entry.js +2 -16
  5. package/dist/cjs/{sqm-big-stat_45.cjs.entry.js → sqm-big-stat_46.cjs.entry.js} +329 -1
  6. package/dist/cjs/sqm-stencilbook.cjs.entry.js +158 -1
  7. package/dist/collection/collection-manifest.json +1 -0
  8. package/dist/collection/components/sqm-partner-info-modal/PartnerInfoModal.stories.js +143 -0
  9. package/dist/collection/components/sqm-partner-info-modal/sqm-partner-info-modal-view.js +90 -0
  10. package/dist/collection/components/sqm-partner-info-modal/sqm-partner-info-modal.js +462 -0
  11. package/dist/collection/components/sqm-partner-info-modal/usePartnerInfoModal.js +180 -0
  12. package/dist/collection/components/sqm-stencilbook/sqm-stencilbook.js +2 -0
  13. package/dist/collection/components/tax-and-cash/sqm-banking-info-form/useBankingInfoForm.js +2 -16
  14. package/dist/esm/{ShadowViewAddon-53b9090b.js → ShadowViewAddon-9d97b5d5.js} +89 -1
  15. package/dist/esm/loader.js +1 -1
  16. package/dist/esm/mint-components.js +1 -1
  17. package/dist/esm/sqm-banking-info-form_10.entry.js +2 -16
  18. package/dist/esm/{sqm-big-stat_45.entry.js → sqm-big-stat_46.entry.js} +333 -6
  19. package/dist/esm/sqm-stencilbook.entry.js +158 -1
  20. package/dist/esm-es5/{ShadowViewAddon-53b9090b.js → ShadowViewAddon-9d97b5d5.js} +1 -1
  21. package/dist/esm-es5/loader.js +1 -1
  22. package/dist/esm-es5/mint-components.js +1 -1
  23. package/dist/esm-es5/sqm-banking-info-form_10.entry.js +1 -1
  24. package/dist/esm-es5/sqm-big-stat_46.entry.js +1 -0
  25. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  26. package/dist/mint-components/mint-components.esm.js +1 -1
  27. package/dist/mint-components/p-0f036907.system.js +1 -0
  28. package/dist/mint-components/{p-0e6c90b1.entry.js → p-22e39d2c.entry.js} +90 -21
  29. package/dist/mint-components/p-499885aa.entry.js +9 -0
  30. package/dist/mint-components/p-a6621899.system.entry.js +1 -0
  31. package/dist/mint-components/{p-e980472a.js → p-adc4e263.js} +25 -25
  32. package/dist/mint-components/{p-7d16ee0e.entry.js → p-b0253f4c.entry.js} +2 -2
  33. package/dist/mint-components/p-ca098be1.system.js +1 -1
  34. package/dist/mint-components/p-d93e19e9.system.entry.js +1 -0
  35. package/dist/mint-components/p-e45a9966.system.entry.js +1 -0
  36. package/dist/types/components/sqm-partner-info-modal/PartnerInfoModal.stories.d.ts +13 -0
  37. package/dist/types/components/sqm-partner-info-modal/sqm-partner-info-modal-view.d.ts +41 -0
  38. package/dist/types/components/sqm-partner-info-modal/sqm-partner-info-modal.d.ts +80 -0
  39. package/dist/types/components/sqm-partner-info-modal/usePartnerInfoModal.d.ts +16 -0
  40. package/dist/types/components.d.ts +138 -0
  41. package/docs/docs.docx +0 -0
  42. package/docs/raisins.json +1 -1
  43. package/grapesjs/grapesjs.js +1 -1
  44. package/package.json +1 -1
  45. package/dist/esm-es5/sqm-big-stat_45.entry.js +0 -1
  46. package/dist/mint-components/p-17b32de7.system.entry.js +0 -1
  47. package/dist/mint-components/p-54ea8b9b.system.entry.js +0 -1
  48. package/dist/mint-components/p-807ed3bf.system.js +0 -1
  49. package/dist/mint-components/p-de7bb373.entry.js +0 -9
  50. package/dist/mint-components/p-e9258d20.system.entry.js +0 -1
@@ -0,0 +1,180 @@
1
+ import { useLocale, useMutation, useQuery, useUserIdentity, } from "@saasquatch/component-boilerplate";
2
+ import { useState } from "@saasquatch/universal-hooks";
3
+ import { gql } from "graphql-request";
4
+ import { TAX_FORM_UPDATED_EVENT_KEY } from "../tax-and-cash/eventKeys";
5
+ export const GET_USER_PARTNER_INFO = gql `
6
+ query getUserPartnerInfo {
7
+ user: viewer {
8
+ ... on User {
9
+ id
10
+ firstName
11
+ lastName
12
+ email
13
+ countryCode
14
+ customFields
15
+ impactConnection {
16
+ connected
17
+ publisher {
18
+ countryCode
19
+ currency
20
+ }
21
+ }
22
+ }
23
+ }
24
+ }
25
+ `;
26
+ export const GET_COUNTRIES = gql `
27
+ query getCountries {
28
+ impactPayoutCountries(limit: 1000) {
29
+ data {
30
+ countryCode
31
+ displayName
32
+ }
33
+ }
34
+ }
35
+ `;
36
+ export const GET_CURRENCIES = gql `
37
+ query currencies($locale: RSLocale) {
38
+ currencies(limit: 300) {
39
+ data {
40
+ displayName(locale: $locale)
41
+ currencyCode
42
+ }
43
+ }
44
+ }
45
+ `;
46
+ export const CONNECT_PARTNER = gql `
47
+ mutation createImpactConnection($vars: ImpactConnectionInput!) {
48
+ createImpactConnection(impactConnectionInput: $vars) {
49
+ success
50
+ validationErrors {
51
+ field
52
+ message
53
+ }
54
+ user {
55
+ id
56
+ accountId
57
+ impactConnection {
58
+ connected
59
+ publisher {
60
+ brandedSignup
61
+ requiredTaxDocumentType
62
+ currentTaxDocument {
63
+ type
64
+ status
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ `;
72
+ const GET_BRAND_NAME = gql `
73
+ query getTenantSettings {
74
+ tenantSettings {
75
+ companyName
76
+ }
77
+ }
78
+ `;
79
+ export function usePartnerInfoModal(props) {
80
+ var _a, _b, _c, _d;
81
+ const user = useUserIdentity();
82
+ const locale = useLocale();
83
+ const { data: userData, loading: userLoading, refetch, } = useQuery(GET_USER_PARTNER_INFO, {}, !(user === null || user === void 0 ? void 0 : user.jwt));
84
+ const { data: currenciesData } = useQuery(GET_CURRENCIES, { variables: { locale } }, !(user === null || user === void 0 ? void 0 : user.jwt));
85
+ const { data: countriesData } = useQuery(GET_COUNTRIES, {}, !(user === null || user === void 0 ? void 0 : user.jwt));
86
+ const { data: tenantSettingsData } = useQuery(GET_BRAND_NAME, {});
87
+ const [connectImpactPartner, { loading: connectLoading, errors: connectErrors },] = useMutation(CONNECT_PARTNER);
88
+ const [countryCode, setCountryCode] = useState("");
89
+ const [currency, setCurrency] = useState("");
90
+ const [error, setError] = useState("");
91
+ const [success, setSuccess] = useState(false);
92
+ console.log(user, "user identity in create partner modal"); // TEMP
93
+ console.log(userData, "user data from partner info query"); // TEMP
94
+ const impactConnection = (_a = userData === null || userData === void 0 ? void 0 : userData.user) === null || _a === void 0 ? void 0 : _a.impactConnection;
95
+ function onCountryChange(e) {
96
+ var _a, _b;
97
+ const value = (_b = (_a = e.detail) === null || _a === void 0 ? void 0 : _a.item) === null || _b === void 0 ? void 0 : _b.__value;
98
+ if (!value)
99
+ return;
100
+ setCountryCode(value);
101
+ setCurrency("");
102
+ setError("");
103
+ }
104
+ function onCurrencyChange(e) {
105
+ var _a, _b;
106
+ const value = (_b = (_a = e.detail) === null || _a === void 0 ? void 0 : _a.item) === null || _b === void 0 ? void 0 : _b.__value;
107
+ if (!value)
108
+ return;
109
+ setCurrency(value);
110
+ setError("");
111
+ }
112
+ async function onSubmit() {
113
+ var _a, _b;
114
+ if (!countryCode || !currency) {
115
+ setError(props.missingFieldsErrorText);
116
+ return;
117
+ }
118
+ setError("");
119
+ // AL TODO: How to create impact connection if we dont have address, postalCode, and city?
120
+ try {
121
+ const vars = {
122
+ user: {
123
+ id: user.id,
124
+ accountId: user.accountId,
125
+ },
126
+ firstName: userData.user.firstName,
127
+ lastName: userData.user.lastName,
128
+ countryCode,
129
+ currency,
130
+ };
131
+ const result = await connectImpactPartner({ vars });
132
+ if (!result || ((_a = result) === null || _a === void 0 ? void 0 : _a.message)) {
133
+ setError(props.networkErrorText);
134
+ return;
135
+ }
136
+ const connectionResult = result
137
+ .createImpactConnection;
138
+ console.log(result, connectionResult, "result and connectionResult from creating partner from modal");
139
+ if (!(connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.success)) {
140
+ const validationMsg = (_b = connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.validationErrors) === null || _b === void 0 ? void 0 : _b.map((e) => e.message).join(". ");
141
+ setError(validationMsg || props.networkErrorText);
142
+ console.error("Failed to create Impact connection:", connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.validationErrors);
143
+ return;
144
+ }
145
+ // Success
146
+ window.dispatchEvent(new Event(TAX_FORM_UPDATED_EVENT_KEY));
147
+ await refetch();
148
+ setSuccess(true);
149
+ }
150
+ catch (e) {
151
+ console.error("Partner creation error:", e);
152
+ setError(props.networkErrorText);
153
+ }
154
+ }
155
+ const shouldShow = !success && !userLoading && !(impactConnection === null || impactConnection === void 0 ? void 0 : impactConnection.connected);
156
+ return {
157
+ states: {
158
+ open: shouldShow,
159
+ loading: userLoading,
160
+ submitting: connectLoading,
161
+ isExistingPartner: !!(impactConnection === null || impactConnection === void 0 ? void 0 : impactConnection.connected),
162
+ countryCode,
163
+ currency,
164
+ error,
165
+ success,
166
+ brandName: ((_b = tenantSettingsData === null || tenantSettingsData === void 0 ? void 0 : tenantSettingsData.tenantSettings) === null || _b === void 0 ? void 0 : _b.companyName) || "",
167
+ filteredCountries: ((_c = countriesData === null || countriesData === void 0 ? void 0 : countriesData.impactPayoutCountries) === null || _c === void 0 ? void 0 : _c.data) || [],
168
+ filteredCurrencies: ((_d = currenciesData === null || currenciesData === void 0 ? void 0 : currenciesData.currencies) === null || _d === void 0 ? void 0 : _d.data) || [],
169
+ },
170
+ callbacks: {
171
+ onCountryChange,
172
+ onCurrencyChange,
173
+ onCountrySearch: () => { },
174
+ onCurrencySearch: () => { },
175
+ onSubmit,
176
+ onClose: () => setSuccess(true),
177
+ },
178
+ text: props.getTextProps(),
179
+ };
180
+ }
@@ -107,6 +107,7 @@ import * as LeadFormDropdownField from "../sqm-lead-form/LeadFormDropdownField.s
107
107
  import * as LeadCheckboxField from "../sqm-lead-form/LeadCheckboxField.stories";
108
108
  import * as Skeleton from "../sqm-skeleton/Skeleton.stories";
109
109
  import * as UserInfoFormView from "../tax-and-cash/sqm-user-info-form/UserInfoFormView.stories";
110
+ import * as PartnerInfoModal from "../sqm-partner-info-modal/PartnerInfoModal.stories";
110
111
  import { ShadowViewAddon } from "../../ShadowViewAddon";
111
112
  import { CucumberAddon } from "./CucumberAddon";
112
113
  import { HookStoryAddon } from "./HookStoryAddon";
@@ -218,6 +219,7 @@ const stories = [
218
219
  TaxAndCashRewardsTable,
219
220
  TaxAndCashReferralTableRewardsCell,
220
221
  TaxAndCashReferralTable,
222
+ PartnerInfoModal,
221
223
  ];
222
224
  /**
223
225
  * For internal documentation
@@ -27,15 +27,6 @@ const WIRE_PAYMENT_METHOD = 5;
27
27
  const PAYPAL_PAYMENT_METHOD = 7;
28
28
  /**
29
29
  * Maps GraphQL validation error field names to form field names.
30
- *
31
- * The Impact API returns UpperCamelCase field names (e.g. `BankAccountNumber`).
32
- * The GraphQL layer in `UserServiceImpl.java` converts these to lowerCamelCase
33
- * via `CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, errorDto.field)`.
34
- *
35
- * Most converted field names already match the form field names exactly
36
- * (e.g. `bankAccountNumber`, `swiftCode`, `routingCode`). Only entries
37
- * where the GraphQL field name differs from the form field name need
38
- * to be listed here.
39
30
  */
40
31
  const API_FIELD_TO_FORM_FIELD = {
41
32
  // bankProvinceState → form uses bankState
@@ -44,11 +35,6 @@ const API_FIELD_TO_FORM_FIELD = {
44
35
  /**
45
36
  * Maps Impact API error code paths (from validationErrors[].errorPath) to short,
46
37
  * readable frontend error codes used in the ICU select props.
47
- *
48
- * The Impact API returns a stable dot-delimited error path (e.g.
49
- * "withdrawal.settings.error.routingcode") alongside the human-readable message.
50
- * The GraphQL layer exposes this as `errorPath`. The keys below match those paths
51
- * to short frontend codes used in the ICU `{errorCode, select, ...}` props.
52
38
  */
53
39
  const API_ERROR_PATH_TO_FRONTEND = {
54
40
  // Beneficiary account name
@@ -151,7 +137,7 @@ const SAVE_WITHDRAWAL_SETTINGS = gql `
151
137
  validationErrors {
152
138
  field
153
139
  message
154
- errorPath
140
+ code
155
141
  }
156
142
  }
157
143
  }
@@ -167,7 +153,7 @@ const UPDATE_WITHDRAWAL_SETTINGS = gql `
167
153
  validationErrors {
168
154
  field
169
155
  message
170
- errorPath
156
+ code
171
157
  }
172
158
  }
173
159
  }
@@ -4463,6 +4463,94 @@ function LeadDropdownFieldView(props) {
4463
4463
  })))));
4464
4464
  }
4465
4465
 
4466
+ const style$b = {
4467
+ Dialog: {
4468
+ "&::part(panel)": {
4469
+ maxWidth: "480px",
4470
+ },
4471
+ "&::part(title)": {
4472
+ fontSize: "var(--sl-font-size-x-large)",
4473
+ fontWeight: "600",
4474
+ padding: "var(--sl-spacing-x-large) var(--sl-spacing-x-large) 0 var(--sl-spacing-x-large)",
4475
+ },
4476
+ "&::part(body)": {
4477
+ padding: "var(--sl-spacing-small) var(--sl-spacing-x-large)",
4478
+ fontSize: "var(--sl-font-size-small)",
4479
+ overflow: "visible",
4480
+ },
4481
+ "&::part(footer)": {
4482
+ display: "flex",
4483
+ flexDirection: "column",
4484
+ gap: "var(--sl-spacing-small)",
4485
+ padding: "var(--sl-spacing-small) var(--sl-spacing-x-large) var(--sl-spacing-x-large)",
4486
+ },
4487
+ "&::part(overlay)": {
4488
+ background: "rgba(0, 0, 0, 0.5)",
4489
+ },
4490
+ "&::part(close-button)": {
4491
+ display: "none",
4492
+ },
4493
+ },
4494
+ FormFields: {
4495
+ display: "flex",
4496
+ gap: "var(--sl-spacing-medium)",
4497
+ marginTop: "var(--sl-spacing-medium)",
4498
+ "& > *": {
4499
+ flex: 1,
4500
+ },
4501
+ },
4502
+ ErrorMessage: {
4503
+ color: "var(--sqm-danger-color-text, #d32f2f)",
4504
+ fontSize: "var(--sl-font-size-small)",
4505
+ marginTop: "var(--sl-spacing-x-small)",
4506
+ },
4507
+ SearchInput: {
4508
+ "&::part(base)": {
4509
+ border: "none",
4510
+ borderBottom: "1px solid var(--sl-color-neutral-300)",
4511
+ borderRadius: "0",
4512
+ },
4513
+ },
4514
+ };
4515
+ function PartnerInfoModalView(props) {
4516
+ var _a, _b;
4517
+ const { states, callbacks, text } = props;
4518
+ const sheet = createStyleSheet(style$b);
4519
+ const styleString = sheet.toString();
4520
+ const description = states.isExistingPartner
4521
+ ? text.descriptionExistingPartner
4522
+ : text.descriptionNewPartner;
4523
+ const buttonLabel = states.isExistingPartner
4524
+ ? text.confirmButtonLabel
4525
+ : text.submitButtonLabel;
4526
+ return (h("sl-dialog", { class: sheet.classes.Dialog, open: states.open, noHeader: false, label: intl.formatMessage({
4527
+ id: "modalBrandHeader",
4528
+ defaultMessage: text.modalBrandHeader,
4529
+ }, { brandName: states.brandName }), "onSl-request-close": (e) => {
4530
+ e.preventDefault();
4531
+ }, "onSl-hide": (e) => {
4532
+ var _a;
4533
+ // Prevent closing when clicking outside the dialog but not dropdowns
4534
+ if (((_a = e.target) === null || _a === void 0 ? void 0 : _a.tagName) === "SL-DIALOG") {
4535
+ e.preventDefault();
4536
+ }
4537
+ } },
4538
+ h("style", { type: "text/css" }, styleString),
4539
+ h("p", null, description),
4540
+ h("div", { class: sheet.classes.FormFields },
4541
+ h("sl-select", { exportparts: "label: input-label, base: input-base", label: text.countryLabel, value: states.countryCode, disabled: states.submitting, required: true, "onSl-select": callbacks.onCountryChange },
4542
+ h("sl-input", { class: sheet.classes.SearchInput, placeholder: text.searchCountryPlaceholder, onKeyDown: (e) => e.stopPropagation(), "onSl-input": (e) => { var _a; return callbacks.onCountrySearch(((_a = e.target) === null || _a === void 0 ? void 0 : _a.value) || ""); } }), (_a = states.filteredCountries) === null || _a === void 0 ? void 0 :
4543
+ _a.map((c) => (h("sl-menu-item", { value: c.countryCode }, c.displayName)))),
4544
+ h("sl-select", { exportparts: "label: input-label, base: input-base", label: text.currencyLabel, value: states.currency, disabled: states.submitting, required: true, "onSl-select": callbacks.onCurrencyChange },
4545
+ h("sl-input", { class: sheet.classes.SearchInput, placeholder: text.searchCurrencyPlaceholder, onKeyDown: (e) => e.stopPropagation(), "onSl-input": (e) => { var _a; return callbacks.onCurrencySearch(((_a = e.target) === null || _a === void 0 ? void 0 : _a.value) || ""); } }), (_b = states.filteredCurrencies) === null || _b === void 0 ? void 0 :
4546
+ _b.map((c) => (h("sl-menu-item", { value: c.currencyCode },
4547
+ c.currencyCode,
4548
+ " - ",
4549
+ c.displayName))))),
4550
+ states.error && h("p", { class: sheet.classes.ErrorMessage }, states.error),
4551
+ h("sl-button", { slot: "footer", type: "primary", loading: states.submitting, disabled: states.submitting || !states.countryCode || !states.currency, onClick: callbacks.onSubmit, style: { width: "100%" }, exportparts: "base: primarybutton-base" }, buttonLabel)));
4552
+ }
4553
+
4466
4554
  const map = new Map();
4467
4555
  function withShadowView(component) {
4468
4556
  // TODO: Could only do this if rendered in a Stencilbook environment to prevent unintended side-effects
@@ -4497,4 +4585,4 @@ const ShadowViewAddon = ({ story }, children) => {
4497
4585
  h(TagName, { "stencilbook-shadow-view": randomInt })));
4498
4586
  };
4499
4587
 
4500
- export { empty as A, BigStatView as B, CardFeedView as C, DropdownFieldView as D, EditProfileView as E, rewardExchange as F, useShareButton as G, HeroView as H, InputFieldView as I, useShareLink as J, ProgressBarView as K, LeaderboardView as L, ProgressBar as M, NameFieldsView as N, LeadFormView as O, PortalChangePasswordView as P, LeadDropdownFieldView as Q, ReferralIframeView as R, StatContainerView as S, TaskCardView as T, ShadowViewAddon as U, useBigStat as V, withShadowView as W, demoRewardExchange as X, ShareButtonView as a, PoweredByImg as b, BaseRegistrationFormView as c, CheckboxFieldView as d, CouponCodeView as e, ChangeMarktingView as f, PortalFooterView as g, PortalFrameView as h, RewardExchangeView as i, rewardExchangeLongText as j, rewardExchangeSelected as k, chooseAmountFixed as l, chooseAmountFixedNoDescription as m, chooseAmountVariable as n, chooseAmountVariableNoDescription as o, chooseAmountVariableDisabled as p, chooseAmountVariableUnavailable as q, rewardExchangeCustomErrorMsg as r, confirmFixed as s, confirmVariable as t, useDemoBigStat as u, redemptionError as v, queryError as w, success as x, successVariable as y, loading as z };
4588
+ export { empty as A, BigStatView as B, CardFeedView as C, DropdownFieldView as D, EditProfileView as E, rewardExchange as F, useShareButton as G, HeroView as H, InputFieldView as I, useShareLink as J, ProgressBarView as K, LeaderboardView as L, ProgressBar as M, NameFieldsView as N, LeadFormView as O, PortalChangePasswordView as P, LeadDropdownFieldView as Q, ReferralIframeView as R, StatContainerView as S, TaskCardView as T, PartnerInfoModalView as U, ShadowViewAddon as V, useBigStat as W, withShadowView as X, demoRewardExchange as Y, ShareButtonView as a, PoweredByImg as b, BaseRegistrationFormView as c, CheckboxFieldView as d, CouponCodeView as e, ChangeMarktingView as f, PortalFooterView as g, PortalFrameView as h, RewardExchangeView as i, rewardExchangeLongText as j, rewardExchangeSelected as k, chooseAmountFixed as l, chooseAmountFixedNoDescription as m, chooseAmountVariable as n, chooseAmountVariableNoDescription as o, chooseAmountVariableDisabled as p, chooseAmountVariableUnavailable as q, rewardExchangeCustomErrorMsg as r, confirmFixed as s, confirmVariable as t, useDemoBigStat as u, redemptionError as v, queryError as w, success as x, successVariable as y, loading as z };