@saasquatch/mint-components 2.1.9-17 → 2.1.9-18
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.
- package/dist/cjs/{data-e83f8a41.js → data-34bc7549.js} +0 -90
- package/dist/cjs/sqm-banking-info-form_10.cjs.entry.js +85 -33
- package/dist/cjs/sqm-big-stat_46.cjs.entry.js +5 -3
- package/dist/cjs/sqm-email-verification_2.cjs.entry.js +28 -10
- package/dist/cjs/{sqm-partner-info-modal-view-bb64a718.js → sqm-partner-info-modal-view-0821eea3.js} +4 -1
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +38 -37
- package/dist/cjs/{sqm-user-info-form-view-923ff8d9.js → sqm-user-info-form-view-d89bdc04.js} +24 -23
- package/dist/cjs/utils-a8e0bd9b.js +93 -0
- package/dist/collection/components/sqm-partner-info-modal/sqm-partner-info-modal-view.js +4 -1
- package/dist/collection/components/sqm-partner-info-modal/usePartnerInfoModal.js +28 -10
- package/dist/collection/components/sqm-widget-verification/sqm-widget-verification.js +1 -0
- package/dist/collection/components/tax-and-cash/sqm-indirect-tax-form/useIndirectTaxForm.js +49 -11
- package/dist/collection/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.js +27 -14
- package/dist/{mint-components/p-a5912b2f.js → esm/data-2380309a.js} +23 -5
- package/dist/esm/sqm-banking-info-form_10.entry.js +78 -26
- package/dist/esm/sqm-big-stat_46.entry.js +3 -1
- package/dist/esm/sqm-email-verification_2.entry.js +29 -11
- package/dist/esm/{sqm-partner-info-modal-view-b0f31f8a.js → sqm-partner-info-modal-view-78d2bc6e.js} +4 -1
- package/dist/esm/sqm-stencilbook.entry.js +4 -3
- package/dist/esm/{sqm-user-info-form-view-f9026468.js → sqm-user-info-form-view-ff8e47ad.js} +2 -1
- package/dist/esm/utils-8267d3d8.js +85 -0
- package/dist/esm-es5/data-2380309a.js +1 -0
- package/dist/esm-es5/sqm-banking-info-form_10.entry.js +1 -1
- package/dist/esm-es5/sqm-big-stat_46.entry.js +1 -1
- package/dist/esm-es5/sqm-email-verification_2.entry.js +1 -1
- package/dist/esm-es5/{sqm-partner-info-modal-view-b0f31f8a.js → sqm-partner-info-modal-view-78d2bc6e.js} +1 -1
- package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
- package/dist/esm-es5/sqm-user-info-form-view-ff8e47ad.js +1 -0
- package/dist/esm-es5/utils-8267d3d8.js +1 -0
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/p-0152122e.js +115 -0
- package/dist/mint-components/{p-1b2fcd7f.entry.js → p-0305331c.entry.js} +32 -7
- package/dist/mint-components/p-0e05ab3b.system.js +1 -0
- package/dist/mint-components/{p-66e8c1f6.entry.js → p-134df0e0.entry.js} +8 -8
- package/dist/mint-components/p-1c413a06.system.js +1 -1
- package/dist/mint-components/p-37541f60.js +1 -0
- package/dist/mint-components/p-527cb9c6.entry.js +9 -0
- package/dist/mint-components/p-5d40ccd0.system.entry.js +1 -0
- package/dist/mint-components/{p-e302579a.system.js → p-80c3ec2a.system.js} +1 -1
- package/dist/mint-components/{p-e5c554da.entry.js → p-8ccc3449.entry.js} +2 -2
- package/dist/mint-components/p-8ebd2081.system.js +1 -0
- package/dist/mint-components/p-9d89bd75.system.entry.js +1 -0
- package/dist/mint-components/p-a8891ebd.js +1 -0
- package/dist/mint-components/p-a9ff6601.system.entry.js +1 -0
- package/dist/mint-components/{p-7e4a8af3.js → p-af5cd4cf.js} +1 -1
- package/dist/mint-components/p-d4446e58.system.entry.js +1 -0
- package/dist/mint-components/p-ee0f1cf1.system.js +1 -0
- package/dist/types/components/tax-and-cash/sqm-indirect-tax-form/useIndirectTaxForm.d.ts +4 -0
- package/docs/docs.docx +0 -0
- package/package.json +1 -1
- package/dist/esm/data-2b0feb3f.js +0 -216
- package/dist/esm-es5/data-2b0feb3f.js +0 -1
- package/dist/esm-es5/sqm-user-info-form-view-f9026468.js +0 -1
- package/dist/mint-components/p-014977d7.js +0 -1
- package/dist/mint-components/p-1b3224d9.entry.js +0 -9
- package/dist/mint-components/p-54bf015a.system.js +0 -1
- package/dist/mint-components/p-64b56141.system.entry.js +0 -1
- package/dist/mint-components/p-6f13f388.system.entry.js +0 -1
- package/dist/mint-components/p-ae0a0031.system.entry.js +0 -1
- package/dist/mint-components/p-c4b7d9a0.system.entry.js +0 -1
- package/dist/mint-components/p-eaf5d0af.system.js +0 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { useLocale, useMutation, useQuery, useSetParent, } from "@saasquatch/component-boilerplate";
|
|
2
|
-
import { useEffect, useState } from "@saasquatch/universal-hooks";
|
|
2
|
+
import { useEffect, useMemo, useState } from "@saasquatch/universal-hooks";
|
|
3
3
|
import { gql } from "graphql-request";
|
|
4
4
|
import { TAX_FORM_UPDATED_EVENT_KEY } from "../tax-and-cash/eventKeys";
|
|
5
5
|
import { VERIFICATION_PARENT_NAMESPACE } from "../sqm-widget-verification/keys";
|
|
6
|
+
import { GET_FINANCE_NETWORK_SETTINGS, } from "../tax-and-cash/data";
|
|
6
7
|
// new field under impactConnection:{ resolvedByEmail: boolean } - determines if connection came from managed identity
|
|
7
8
|
export const GET_USER_PARTNER_INFO = gql `
|
|
8
9
|
query getUserPartnerInfo {
|
|
@@ -91,7 +92,7 @@ const GET_BRAND_NAME = gql `
|
|
|
91
92
|
}
|
|
92
93
|
`;
|
|
93
94
|
export function usePartnerInfoModal(props) {
|
|
94
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
95
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
95
96
|
const locale = useLocale();
|
|
96
97
|
const setVerificationContext = useSetParent(VERIFICATION_PARENT_NAMESPACE);
|
|
97
98
|
const { data: userData, loading: userLoading, refetch, } = useQuery(GET_USER_PARTNER_INFO, {});
|
|
@@ -99,19 +100,36 @@ export function usePartnerInfoModal(props) {
|
|
|
99
100
|
const { data: currenciesData, loading: currenciesLoading } = useQuery(GET_CURRENCIES, { variables: { locale } });
|
|
100
101
|
const { data: countriesData, loading: countriesLoading } = useQuery(GET_COUNTRIES, {});
|
|
101
102
|
const { data: tenantSettingsData } = useQuery(GET_BRAND_NAME, {});
|
|
103
|
+
const { data: financeNetworkData } = useQuery(GET_FINANCE_NETWORK_SETTINGS, {
|
|
104
|
+
variables: { filter: {} },
|
|
105
|
+
});
|
|
102
106
|
const [connectImpactPartner, { loading: connectLoading, errors: connectErrors },] = useMutation(CONNECT_PARTNER);
|
|
103
|
-
const [countryCode, setCountryCode] = useState(((_b = (_a = user === null || user === void 0 ? void 0 : user.impactConnection) === null || _a === void 0 ? void 0 : _a.publisher) === null || _b === void 0 ? void 0 : _b.countryCode) || "");
|
|
107
|
+
const [countryCode, setCountryCode] = useState(((_b = (_a = user === null || user === void 0 ? void 0 : user.impactConnection) === null || _a === void 0 ? void 0 : _a.publisher) === null || _b === void 0 ? void 0 : _b.countryCode) || "US");
|
|
104
108
|
const [currency, setCurrency] = useState(((_d = (_c = user === null || user === void 0 ? void 0 : user.impactConnection) === null || _c === void 0 ? void 0 : _c.publisher) === null || _d === void 0 ? void 0 : _d.currency) || "");
|
|
109
|
+
const countries = ((_e = countriesData === null || countriesData === void 0 ? void 0 : countriesData.impactPayoutCountries) === null || _e === void 0 ? void 0 : _e.data) || [];
|
|
110
|
+
// copied from useTaxAndCash for displaying currencies based on country - could be in helper?
|
|
111
|
+
const currencies = useMemo(() => {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
const allValidCurrencies = (_b = (_a = financeNetworkData === null || financeNetworkData === void 0 ? void 0 : financeNetworkData.impactFinanceNetworkSettings) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.reduce((agg, settings) => {
|
|
114
|
+
var _a, _b;
|
|
115
|
+
const currency = (_b = (_a = currenciesData === null || currenciesData === void 0 ? void 0 : currenciesData.currencies) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.find((c) => c.currencyCode === settings.currency);
|
|
116
|
+
if (!currency)
|
|
117
|
+
return agg;
|
|
118
|
+
if (agg.find((c) => c.currencyCode === settings.currency))
|
|
119
|
+
return agg;
|
|
120
|
+
if (countryCode && settings.countryCode !== countryCode)
|
|
121
|
+
return agg;
|
|
122
|
+
return [...agg, currency];
|
|
123
|
+
}, []);
|
|
124
|
+
return (allValidCurrencies || []).sort((a, b) => a.displayName.localeCompare(b.displayName));
|
|
125
|
+
}, [financeNetworkData, currenciesData, countryCode]);
|
|
105
126
|
console.log(countryCode, currency, "initial country and currency state"); // TEMP
|
|
106
127
|
const [countrySearch, setCountrySearch] = useState("");
|
|
107
128
|
const [currencySearch, setCurrencySearch] = useState("");
|
|
108
|
-
const [filteredCountries, setFilteredCountries] = useState(((
|
|
109
|
-
const [filteredCurrencies, setFilteredCurrencies] = useState(
|
|
129
|
+
const [filteredCountries, setFilteredCountries] = useState(((_f = countriesData === null || countriesData === void 0 ? void 0 : countriesData.impactPayoutCountries) === null || _f === void 0 ? void 0 : _f.data) || []);
|
|
130
|
+
const [filteredCurrencies, setFilteredCurrencies] = useState(currencies || []);
|
|
110
131
|
const [error, setError] = useState("");
|
|
111
132
|
const [success, setSuccess] = useState(false);
|
|
112
|
-
const countries = ((_g = countriesData === null || countriesData === void 0 ? void 0 : countriesData.impactPayoutCountries) === null || _g === void 0 ? void 0 : _g.data) || [];
|
|
113
|
-
const currencies = ((_h = currenciesData === null || currenciesData === void 0 ? void 0 : currenciesData.currencies) === null || _h === void 0 ? void 0 : _h.data) || [];
|
|
114
|
-
console.log(user, "user data from partner info query"); // TEMP
|
|
115
133
|
useEffect(() => {
|
|
116
134
|
var _a;
|
|
117
135
|
if (userData && ((_a = user.impactConnection) === null || _a === void 0 ? void 0 : _a.publisher)) {
|
|
@@ -201,11 +219,11 @@ export function usePartnerInfoModal(props) {
|
|
|
201
219
|
setError(props.networkErrorText);
|
|
202
220
|
}
|
|
203
221
|
}
|
|
204
|
-
console.log(success, "success state in partner info modal");
|
|
205
222
|
const showModal = !success &&
|
|
206
223
|
!userLoading &&
|
|
207
224
|
(!(impactConnection === null || impactConnection === void 0 ? void 0 : impactConnection.connected) || !(impactConnection === null || impactConnection === void 0 ? void 0 : impactConnection.publisher));
|
|
208
225
|
console.log(showModal, "showModal condition in partner info modal"); // TEMP
|
|
226
|
+
console.log(filteredCurrencies, "filtered curricneis");
|
|
209
227
|
return {
|
|
210
228
|
states: {
|
|
211
229
|
open: showModal,
|
|
@@ -216,7 +234,7 @@ export function usePartnerInfoModal(props) {
|
|
|
216
234
|
currency,
|
|
217
235
|
error,
|
|
218
236
|
success,
|
|
219
|
-
brandName: ((
|
|
237
|
+
brandName: ((_g = tenantSettingsData === null || tenantSettingsData === void 0 ? void 0 : tenantSettingsData.tenantSettings) === null || _g === void 0 ? void 0 : _g.companyName) || "",
|
|
220
238
|
filteredCountries: filteredCountries || [],
|
|
221
239
|
filteredCurrencies: filteredCurrencies || [],
|
|
222
240
|
},
|
|
@@ -211,6 +211,7 @@ export class WidgetVerification {
|
|
|
211
211
|
: useWidgetVerification();
|
|
212
212
|
if (props.loading)
|
|
213
213
|
return h("sl-spinner", null);
|
|
214
|
+
// for handling state previews in content editor
|
|
214
215
|
const partnerState = typeof props["sqm-partner-info-modal_stateController"] === "string"
|
|
215
216
|
? parseStates(props["sqm-partner-info-modal_stateController"])
|
|
216
217
|
: props["sqm-partner-info-modal_stateController"];
|
|
@@ -32,6 +32,32 @@ export const CONNECT_PARTNER = gql `
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
`;
|
|
35
|
+
export const COMPLETE_PARTNER = gql `
|
|
36
|
+
mutation completeImpactConnection($vars: ImpactConnectionInput!) {
|
|
37
|
+
completeImpactConnection(impactConnectionInput: $vars) {
|
|
38
|
+
success
|
|
39
|
+
validationErrors {
|
|
40
|
+
field
|
|
41
|
+
message
|
|
42
|
+
}
|
|
43
|
+
user {
|
|
44
|
+
id
|
|
45
|
+
accountId
|
|
46
|
+
impactConnection {
|
|
47
|
+
connected
|
|
48
|
+
publisher {
|
|
49
|
+
brandedSignup
|
|
50
|
+
requiredTaxDocumentType
|
|
51
|
+
currentTaxDocument {
|
|
52
|
+
type
|
|
53
|
+
status
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
35
61
|
function getOption(countries, countryCode) {
|
|
36
62
|
if (!countries)
|
|
37
63
|
return;
|
|
@@ -50,6 +76,7 @@ export function useIndirectTaxForm(props) {
|
|
|
50
76
|
const context = useParentValue(TAX_FORM_CONTEXT_NAMESPACE);
|
|
51
77
|
const [step, setStep] = useParent(TAX_CONTEXT_NAMESPACE);
|
|
52
78
|
const [connectImpactPartner, { loading: connectLoading, errors: connectErrors },] = useMutation(CONNECT_PARTNER);
|
|
79
|
+
const [completeImpactPartner, { loading: completeLoading, errors: completeErrors },] = useMutation(COMPLETE_PARTNER);
|
|
53
80
|
const userForm = useParentValue(USER_FORM_CONTEXT_NAMESPACE);
|
|
54
81
|
const { data: userData, refetch, errors: userError, } = useParentQueryValue(USER_QUERY_NAMESPACE);
|
|
55
82
|
const { data: _countriesRes, loading: countriesLoading } = useParentQueryValue(COUNTRIES_QUERY_NAMESPACE);
|
|
@@ -112,7 +139,7 @@ export function useIndirectTaxForm(props) {
|
|
|
112
139
|
setFormState((p) => ({ ...p, [field]: value }));
|
|
113
140
|
};
|
|
114
141
|
async function connectPartner(formData) {
|
|
115
|
-
var _a, _b, _c, _d, _e;
|
|
142
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
116
143
|
const vars = {
|
|
117
144
|
user: {
|
|
118
145
|
id: user.id,
|
|
@@ -134,19 +161,30 @@ export function useIndirectTaxForm(props) {
|
|
|
134
161
|
additionalTaxId: formData.qstNumber,
|
|
135
162
|
withholdingTaxId: formData.subRegionTaxNumber,
|
|
136
163
|
};
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (
|
|
164
|
+
//AL: TODO completePartnerMutation might change
|
|
165
|
+
let result = null;
|
|
166
|
+
let connectionResult;
|
|
167
|
+
if ((_b = (_a = userData === null || userData === void 0 ? void 0 : userData.user) === null || _a === void 0 ? void 0 : _a.impactConnection) === null || _b === void 0 ? void 0 : _b.connected) {
|
|
168
|
+
result = await completeImpactPartner({
|
|
169
|
+
vars,
|
|
170
|
+
});
|
|
171
|
+
connectionResult = (_c = result) === null || _c === void 0 ? void 0 : _c.completeImpactConnection;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
result = await connectImpactPartner({
|
|
175
|
+
vars,
|
|
176
|
+
});
|
|
177
|
+
connectionResult = (_d = result) === null || _d === void 0 ? void 0 : _d.createImpactConnection;
|
|
178
|
+
}
|
|
179
|
+
if (!result || ((_e = result) === null || _e === void 0 ? void 0 : _e.message))
|
|
141
180
|
throw new Error();
|
|
142
|
-
if (!(
|
|
181
|
+
if (!(connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.success)) {
|
|
143
182
|
// Output backend errors to console for now
|
|
144
|
-
console.error("Failed to create Impact connection: ",
|
|
183
|
+
console.error("Failed to create Impact connection: ", connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.validationErrors);
|
|
145
184
|
throw new Error();
|
|
146
185
|
}
|
|
147
186
|
await refetch();
|
|
148
|
-
const resultPublisher = (
|
|
149
|
-
.createImpactConnection) === null || _c === void 0 ? void 0 : _c.user) === null || _d === void 0 ? void 0 : _d.impactConnection) === null || _e === void 0 ? void 0 : _e.publisher;
|
|
187
|
+
const resultPublisher = (_g = (_f = connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.user) === null || _f === void 0 ? void 0 : _f.impactConnection) === null || _g === void 0 ? void 0 : _g.publisher;
|
|
150
188
|
const hasValidCurrentDocument = validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) && (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument);
|
|
151
189
|
// Fire form change event
|
|
152
190
|
window.dispatchEvent(new Event(TAX_FORM_UPDATED_EVENT_KEY));
|
|
@@ -212,8 +250,8 @@ export function useIndirectTaxForm(props) {
|
|
|
212
250
|
states: {
|
|
213
251
|
step: step === null || step === void 0 ? void 0 : step.replace("/", ""),
|
|
214
252
|
hideSteps: context.hideSteps,
|
|
215
|
-
disabled: loading || countriesLoading || connectLoading,
|
|
216
|
-
loading: loading || connectLoading || countriesLoading,
|
|
253
|
+
disabled: loading || countriesLoading || connectLoading || completeLoading,
|
|
254
|
+
loading: loading || connectLoading || countriesLoading || completeLoading,
|
|
217
255
|
isPartner: !!((_e = (_d = userData === null || userData === void 0 ? void 0 : userData.user) === null || _d === void 0 ? void 0 : _d.impactConnection) === null || _e === void 0 ? void 0 : _e.publisher),
|
|
218
256
|
loadingError: !!(userError === null || userError === void 0 ? void 0 : userError.message),
|
|
219
257
|
formState: {
|
|
@@ -5,7 +5,7 @@ import { CURRENCIES_NAMESPACE, SORTED_COUNTRIES_NAMESPACE, TAX_CONTEXT_NAMESPACE
|
|
|
5
5
|
import { ADDRESS_REGIONS } from "../subregions";
|
|
6
6
|
import { objectIsFull, validTaxDocument } from "../utils";
|
|
7
7
|
import { TAX_FORM_UPDATED_EVENT_KEY } from "../eventKeys";
|
|
8
|
-
import { CONNECT_PARTNER, } from "../sqm-indirect-tax-form/useIndirectTaxForm";
|
|
8
|
+
import { CONNECT_PARTNER, COMPLETE_PARTNER, } from "../sqm-indirect-tax-form/useIndirectTaxForm";
|
|
9
9
|
import { gql } from "graphql-request";
|
|
10
10
|
const GET_INDIRECT_TAX_COUNTRY_CODE = gql `
|
|
11
11
|
query getIndirectTaxCountryCode {
|
|
@@ -26,6 +26,7 @@ export function useUserInfoForm(props) {
|
|
|
26
26
|
const [userFormContext, setUserFormContext] = useParent(USER_FORM_CONTEXT_NAMESPACE);
|
|
27
27
|
const user = useUserIdentity();
|
|
28
28
|
const [connectImpactPartner, { loading: connectLoading, errors: connectErrors },] = useMutation(CONNECT_PARTNER);
|
|
29
|
+
const [completeImpactPartner, { loading: completeLoading, errors: completeErrors },] = useMutation(COMPLETE_PARTNER);
|
|
29
30
|
const { data: tenantData } = useQuery(GET_INDIRECT_TAX_COUNTRY_CODE, {});
|
|
30
31
|
const { data, loading, refetch, errors: userError, } = useParentQueryValue(USER_QUERY_NAMESPACE);
|
|
31
32
|
const _currencies = useParentValue(CURRENCIES_NAMESPACE);
|
|
@@ -137,7 +138,7 @@ export function useUserInfoForm(props) {
|
|
|
137
138
|
}
|
|
138
139
|
}, [currencySearch, currencies]);
|
|
139
140
|
async function connectPartner(formData) {
|
|
140
|
-
var _a, _b, _c, _d, _e;
|
|
141
|
+
var _a, _b, _c, _d, _e, _f;
|
|
141
142
|
const vars = {
|
|
142
143
|
user: {
|
|
143
144
|
id: user.id,
|
|
@@ -154,20 +155,32 @@ export function useUserInfoForm(props) {
|
|
|
154
155
|
phoneNumber: formData.phoneNumber,
|
|
155
156
|
phoneNumberCountryCode: formData.phoneNumberCountryCode,
|
|
156
157
|
};
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
//AL: TODO completePartnerMutation might change
|
|
159
|
+
// if user already has an impact connection, call completeImpactPartner to update their information instead of connectPartner
|
|
160
|
+
const userData = data === null || data === void 0 ? void 0 : data.user;
|
|
161
|
+
let result = null;
|
|
162
|
+
let connectionResult;
|
|
163
|
+
if ((_a = userData === null || userData === void 0 ? void 0 : userData.impactConnection) === null || _a === void 0 ? void 0 : _a.connected) {
|
|
164
|
+
console.log(vars, "values for completeImpactPartner");
|
|
165
|
+
result = await completeImpactPartner({
|
|
166
|
+
vars,
|
|
167
|
+
});
|
|
168
|
+
connectionResult = (_b = result) === null || _b === void 0 ? void 0 : _b.completeImpactConnection;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
result = await connectImpactPartner({
|
|
172
|
+
vars,
|
|
173
|
+
});
|
|
174
|
+
connectionResult = (_c = result) === null || _c === void 0 ? void 0 : _c.createImpactConnection;
|
|
175
|
+
}
|
|
176
|
+
if (!result || ((_d = result) === null || _d === void 0 ? void 0 : _d.message))
|
|
161
177
|
throw new Error();
|
|
162
|
-
if (!(
|
|
163
|
-
|
|
164
|
-
console.error("Failed to create Impact connection: ", result.createImpactConnection
|
|
165
|
-
.validationErrors);
|
|
178
|
+
if (!(connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.success)) {
|
|
179
|
+
console.error("Failed to create Impact connection: ", connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.validationErrors);
|
|
166
180
|
throw new Error();
|
|
167
181
|
}
|
|
168
182
|
await refetch();
|
|
169
|
-
const resultPublisher = (
|
|
170
|
-
.createImpactConnection) === null || _c === void 0 ? void 0 : _c.user) === null || _d === void 0 ? void 0 : _d.impactConnection) === null || _e === void 0 ? void 0 : _e.publisher;
|
|
183
|
+
const resultPublisher = (_f = (_e = connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.user) === null || _e === void 0 ? void 0 : _e.impactConnection) === null || _f === void 0 ? void 0 : _f.publisher;
|
|
171
184
|
const hasValidCurrentDocument = validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) && (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument);
|
|
172
185
|
// Fire form change event
|
|
173
186
|
window.dispatchEvent(new Event(TAX_FORM_UPDATED_EVENT_KEY));
|
|
@@ -292,9 +305,9 @@ export function useUserInfoForm(props) {
|
|
|
292
305
|
step: step === null || step === void 0 ? void 0 : step.replace("/", ""),
|
|
293
306
|
hideState: !hasStates,
|
|
294
307
|
hideSteps: !!context.hideSteps,
|
|
295
|
-
disabled: loading || connectLoading,
|
|
308
|
+
disabled: loading || connectLoading || completeLoading,
|
|
296
309
|
loadingError: !!(userError === null || userError === void 0 ? void 0 : userError.message),
|
|
297
|
-
loading: loading || connectLoading,
|
|
310
|
+
loading: loading || connectLoading || completeLoading,
|
|
298
311
|
isPartner: !!((_g = (_f = data === null || data === void 0 ? void 0 : data.user) === null || _f === void 0 ? void 0 : _f.impactConnection) === null || _g === void 0 ? void 0 : _g.publisher),
|
|
299
312
|
isUser: !!((_j = (_h = data === null || data === void 0 ? void 0 : data.user) === null || _h === void 0 ? void 0 : _h.impactConnection) === null || _j === void 0 ? void 0 : _j.user),
|
|
300
313
|
formState: {
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { d as dist } from './index.module-cede12c6.js';
|
|
2
|
+
|
|
3
|
+
const TAX_CONTEXT_NAMESPACE = "sq:tax-and-cash";
|
|
4
|
+
const TAX_FORM_CONTEXT_NAMESPACE = "sq:tax-form-context";
|
|
5
|
+
const USER_QUERY_NAMESPACE = "sq:user-info-query";
|
|
6
|
+
const USER_FORM_CONTEXT_NAMESPACE = "sq:user-form-context";
|
|
7
|
+
const FINANCE_NETWORK_SETTINGS_NAMESPACE = "sq:finance-network-settings";
|
|
8
|
+
const COUNTRIES_NAMESPACE = "sq:countries:list";
|
|
9
|
+
const SORTED_COUNTRIES_NAMESPACE = "sq:countries:sorted";
|
|
10
|
+
const COUNTRIES_QUERY_NAMESPACE = "sq:countries:query";
|
|
11
|
+
const CURRENCIES_NAMESPACE = "sq:currencies:list";
|
|
12
|
+
const CURRENCIES_QUERY_NAMESPACE = "sq:currencies:query";
|
|
13
|
+
const GET_USER = dist.gql `
|
|
2
14
|
query getUserTaxInfo {
|
|
3
15
|
user: viewer {
|
|
4
16
|
... on User {
|
|
@@ -76,7 +88,8 @@ import{h as e}from"./p-083180bf.js";import{i as t}from"./p-438f6702.js";import{d
|
|
|
76
88
|
}
|
|
77
89
|
}
|
|
78
90
|
}
|
|
79
|
-
|
|
91
|
+
`;
|
|
92
|
+
const GET_COUNTRIES = dist.gql `
|
|
80
93
|
query getCountries {
|
|
81
94
|
impactPayoutCountries(limit: 1000) {
|
|
82
95
|
data {
|
|
@@ -85,7 +98,8 @@ import{h as e}from"./p-083180bf.js";import{i as t}from"./p-438f6702.js";import{d
|
|
|
85
98
|
}
|
|
86
99
|
}
|
|
87
100
|
}
|
|
88
|
-
|
|
101
|
+
`;
|
|
102
|
+
const GET_CURRENCIES = dist.gql `
|
|
89
103
|
query currencies($locale: RSLocale) {
|
|
90
104
|
currencies(limit: 300) {
|
|
91
105
|
data {
|
|
@@ -94,7 +108,8 @@ import{h as e}from"./p-083180bf.js";import{i as t}from"./p-438f6702.js";import{d
|
|
|
94
108
|
}
|
|
95
109
|
}
|
|
96
110
|
}
|
|
97
|
-
|
|
111
|
+
`;
|
|
112
|
+
const GET_FINANCE_NETWORK_SETTINGS = dist.gql `
|
|
98
113
|
query impactFinanceNetworkSettings(
|
|
99
114
|
$filter: ImpactFinanceNetworkSettingsFilterInput
|
|
100
115
|
) {
|
|
@@ -112,4 +127,7 @@ import{h as e}from"./p-083180bf.js";import{i as t}from"./p-438f6702.js";import{d
|
|
|
112
127
|
totalCount
|
|
113
128
|
}
|
|
114
129
|
}
|
|
115
|
-
|
|
130
|
+
`;
|
|
131
|
+
const FORM_STEPS = 4;
|
|
132
|
+
|
|
133
|
+
export { CURRENCIES_NAMESPACE as C, FORM_STEPS as F, GET_USER as G, SORTED_COUNTRIES_NAMESPACE as S, TAX_CONTEXT_NAMESPACE as T, USER_FORM_CONTEXT_NAMESPACE as U, TAX_FORM_CONTEXT_NAMESPACE as a, COUNTRIES_NAMESPACE as b, USER_QUERY_NAMESPACE as c, COUNTRIES_QUERY_NAMESPACE as d, GET_COUNTRIES as e, FINANCE_NETWORK_SETTINGS_NAMESPACE as f, GET_FINANCE_NETWORK_SETTINGS as g, CURRENCIES_QUERY_NAMESPACE as h, GET_CURRENCIES as i };
|
|
@@ -12,8 +12,9 @@ import { u as useRerenderListener, a as useRequestRerender } from './re-render-7
|
|
|
12
12
|
import { u as useChildElements } from './useChildElements-c26d7347.js';
|
|
13
13
|
import { l as luxon } from './luxon-1be92a8e.js';
|
|
14
14
|
import { g as generateUserError } from './useReferralTable-35e6d4c1.js';
|
|
15
|
-
import { a as INDIRECT_TAX_SPAIN_REGIONS, b as INDIRECT_TAX_PROVINCES, O as OtherRegionSlotView, I as InvoiceTableView, v as vatLabels, A as ADDRESS_REGIONS, U as UserInfoFormView } from './sqm-user-info-form-view-
|
|
16
|
-
import {
|
|
15
|
+
import { a as INDIRECT_TAX_SPAIN_REGIONS, b as INDIRECT_TAX_PROVINCES, O as OtherRegionSlotView, I as InvoiceTableView, v as vatLabels, A as ADDRESS_REGIONS, U as UserInfoFormView } from './sqm-user-info-form-view-ff8e47ad.js';
|
|
16
|
+
import { t as taxTypeToName, a as validTaxDocument, g as getCountryObj, o as objectIsFull } from './utils-8267d3d8.js';
|
|
17
|
+
import { F as FORM_STEPS, a as TAX_FORM_CONTEXT_NAMESPACE, S as SORTED_COUNTRIES_NAMESPACE, c as USER_QUERY_NAMESPACE, T as TAX_CONTEXT_NAMESPACE, f as FINANCE_NETWORK_SETTINGS_NAMESPACE, U as USER_FORM_CONTEXT_NAMESPACE, d as COUNTRIES_QUERY_NAMESPACE, C as CURRENCIES_NAMESPACE } from './data-2380309a.js';
|
|
17
18
|
import { b as VERIFICATION_EVENT_KEY } from './keys-db1897ae.js';
|
|
18
19
|
import { T as TAX_FORM_UPDATED_EVENT_KEY } from './eventKeys-f76b6a03.js';
|
|
19
20
|
import { a as useVeriffApp, g as getStatus, V as VERIFF_COMPLETE_EVENT_KEY } from './usePayoutStatus-fa504d49.js';
|
|
@@ -2867,6 +2868,32 @@ const CONNECT_PARTNER = dist.gql `
|
|
|
2867
2868
|
}
|
|
2868
2869
|
}
|
|
2869
2870
|
`;
|
|
2871
|
+
const COMPLETE_PARTNER = dist.gql `
|
|
2872
|
+
mutation completeImpactConnection($vars: ImpactConnectionInput!) {
|
|
2873
|
+
completeImpactConnection(impactConnectionInput: $vars) {
|
|
2874
|
+
success
|
|
2875
|
+
validationErrors {
|
|
2876
|
+
field
|
|
2877
|
+
message
|
|
2878
|
+
}
|
|
2879
|
+
user {
|
|
2880
|
+
id
|
|
2881
|
+
accountId
|
|
2882
|
+
impactConnection {
|
|
2883
|
+
connected
|
|
2884
|
+
publisher {
|
|
2885
|
+
brandedSignup
|
|
2886
|
+
requiredTaxDocumentType
|
|
2887
|
+
currentTaxDocument {
|
|
2888
|
+
type
|
|
2889
|
+
status
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
`;
|
|
2870
2897
|
function getOption(countries, countryCode) {
|
|
2871
2898
|
if (!countries)
|
|
2872
2899
|
return;
|
|
@@ -2885,6 +2912,7 @@ function useIndirectTaxForm(props) {
|
|
|
2885
2912
|
const context = Fn(TAX_FORM_CONTEXT_NAMESPACE);
|
|
2886
2913
|
const [step, setStep] = Pn(TAX_CONTEXT_NAMESPACE);
|
|
2887
2914
|
const [connectImpactPartner, { loading: connectLoading, errors: connectErrors },] = $e(CONNECT_PARTNER);
|
|
2915
|
+
const [completeImpactPartner, { loading: completeLoading, errors: completeErrors },] = $e(COMPLETE_PARTNER);
|
|
2888
2916
|
const userForm = Fn(USER_FORM_CONTEXT_NAMESPACE);
|
|
2889
2917
|
const { data: userData, refetch, errors: userError, } = $n(USER_QUERY_NAMESPACE);
|
|
2890
2918
|
const { data: _countriesRes, loading: countriesLoading } = $n(COUNTRIES_QUERY_NAMESPACE);
|
|
@@ -2947,7 +2975,7 @@ function useIndirectTaxForm(props) {
|
|
|
2947
2975
|
setFormState((p) => ({ ...p, [field]: value }));
|
|
2948
2976
|
};
|
|
2949
2977
|
async function connectPartner(formData) {
|
|
2950
|
-
var _a, _b, _c, _d, _e;
|
|
2978
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2951
2979
|
const vars = {
|
|
2952
2980
|
user: {
|
|
2953
2981
|
id: user.id,
|
|
@@ -2969,19 +2997,30 @@ function useIndirectTaxForm(props) {
|
|
|
2969
2997
|
additionalTaxId: formData.qstNumber,
|
|
2970
2998
|
withholdingTaxId: formData.subRegionTaxNumber,
|
|
2971
2999
|
};
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
if (
|
|
3000
|
+
//AL: TODO completePartnerMutation might change
|
|
3001
|
+
let result = null;
|
|
3002
|
+
let connectionResult;
|
|
3003
|
+
if ((_b = (_a = userData === null || userData === void 0 ? void 0 : userData.user) === null || _a === void 0 ? void 0 : _a.impactConnection) === null || _b === void 0 ? void 0 : _b.connected) {
|
|
3004
|
+
result = await completeImpactPartner({
|
|
3005
|
+
vars,
|
|
3006
|
+
});
|
|
3007
|
+
connectionResult = (_c = result) === null || _c === void 0 ? void 0 : _c.completeImpactConnection;
|
|
3008
|
+
}
|
|
3009
|
+
else {
|
|
3010
|
+
result = await connectImpactPartner({
|
|
3011
|
+
vars,
|
|
3012
|
+
});
|
|
3013
|
+
connectionResult = (_d = result) === null || _d === void 0 ? void 0 : _d.createImpactConnection;
|
|
3014
|
+
}
|
|
3015
|
+
if (!result || ((_e = result) === null || _e === void 0 ? void 0 : _e.message))
|
|
2976
3016
|
throw new Error();
|
|
2977
|
-
if (!(
|
|
3017
|
+
if (!(connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.success)) {
|
|
2978
3018
|
// Output backend errors to console for now
|
|
2979
|
-
console.error("Failed to create Impact connection: ",
|
|
3019
|
+
console.error("Failed to create Impact connection: ", connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.validationErrors);
|
|
2980
3020
|
throw new Error();
|
|
2981
3021
|
}
|
|
2982
3022
|
await refetch();
|
|
2983
|
-
const resultPublisher = (
|
|
2984
|
-
.createImpactConnection) === null || _c === void 0 ? void 0 : _c.user) === null || _d === void 0 ? void 0 : _d.impactConnection) === null || _e === void 0 ? void 0 : _e.publisher;
|
|
3023
|
+
const resultPublisher = (_g = (_f = connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.user) === null || _f === void 0 ? void 0 : _f.impactConnection) === null || _g === void 0 ? void 0 : _g.publisher;
|
|
2985
3024
|
const hasValidCurrentDocument = validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) && (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument);
|
|
2986
3025
|
// Fire form change event
|
|
2987
3026
|
window.dispatchEvent(new Event(TAX_FORM_UPDATED_EVENT_KEY));
|
|
@@ -3047,8 +3086,8 @@ function useIndirectTaxForm(props) {
|
|
|
3047
3086
|
states: {
|
|
3048
3087
|
step: step === null || step === void 0 ? void 0 : step.replace("/", ""),
|
|
3049
3088
|
hideSteps: context.hideSteps,
|
|
3050
|
-
disabled: loading || countriesLoading || connectLoading,
|
|
3051
|
-
loading: loading || connectLoading || countriesLoading,
|
|
3089
|
+
disabled: loading || countriesLoading || connectLoading || completeLoading,
|
|
3090
|
+
loading: loading || connectLoading || countriesLoading || completeLoading,
|
|
3052
3091
|
isPartner: !!((_e = (_d = userData === null || userData === void 0 ? void 0 : userData.user) === null || _d === void 0 ? void 0 : _d.impactConnection) === null || _e === void 0 ? void 0 : _e.publisher),
|
|
3053
3092
|
loadingError: !!(userError === null || userError === void 0 ? void 0 : userError.message),
|
|
3054
3093
|
formState: {
|
|
@@ -5361,6 +5400,7 @@ function useUserInfoForm(props) {
|
|
|
5361
5400
|
const [userFormContext, setUserFormContext] = Pn(USER_FORM_CONTEXT_NAMESPACE);
|
|
5362
5401
|
const user = J();
|
|
5363
5402
|
const [connectImpactPartner, { loading: connectLoading, errors: connectErrors },] = $e(CONNECT_PARTNER);
|
|
5403
|
+
const [completeImpactPartner, { loading: completeLoading, errors: completeErrors },] = $e(COMPLETE_PARTNER);
|
|
5364
5404
|
const { data: tenantData } = wn(GET_INDIRECT_TAX_COUNTRY_CODE, {});
|
|
5365
5405
|
const { data, loading, refetch, errors: userError, } = $n(USER_QUERY_NAMESPACE);
|
|
5366
5406
|
const _currencies = Fn(CURRENCIES_NAMESPACE);
|
|
@@ -5472,7 +5512,7 @@ function useUserInfoForm(props) {
|
|
|
5472
5512
|
}
|
|
5473
5513
|
}, [currencySearch, currencies]);
|
|
5474
5514
|
async function connectPartner(formData) {
|
|
5475
|
-
var _a, _b, _c, _d, _e;
|
|
5515
|
+
var _a, _b, _c, _d, _e, _f;
|
|
5476
5516
|
const vars = {
|
|
5477
5517
|
user: {
|
|
5478
5518
|
id: user.id,
|
|
@@ -5489,20 +5529,32 @@ function useUserInfoForm(props) {
|
|
|
5489
5529
|
phoneNumber: formData.phoneNumber,
|
|
5490
5530
|
phoneNumberCountryCode: formData.phoneNumberCountryCode,
|
|
5491
5531
|
};
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5532
|
+
//AL: TODO completePartnerMutation might change
|
|
5533
|
+
// if user already has an impact connection, call completeImpactPartner to update their information instead of connectPartner
|
|
5534
|
+
const userData = data === null || data === void 0 ? void 0 : data.user;
|
|
5535
|
+
let result = null;
|
|
5536
|
+
let connectionResult;
|
|
5537
|
+
if ((_a = userData === null || userData === void 0 ? void 0 : userData.impactConnection) === null || _a === void 0 ? void 0 : _a.connected) {
|
|
5538
|
+
console.log(vars, "values for completeImpactPartner");
|
|
5539
|
+
result = await completeImpactPartner({
|
|
5540
|
+
vars,
|
|
5541
|
+
});
|
|
5542
|
+
connectionResult = (_b = result) === null || _b === void 0 ? void 0 : _b.completeImpactConnection;
|
|
5543
|
+
}
|
|
5544
|
+
else {
|
|
5545
|
+
result = await connectImpactPartner({
|
|
5546
|
+
vars,
|
|
5547
|
+
});
|
|
5548
|
+
connectionResult = (_c = result) === null || _c === void 0 ? void 0 : _c.createImpactConnection;
|
|
5549
|
+
}
|
|
5550
|
+
if (!result || ((_d = result) === null || _d === void 0 ? void 0 : _d.message))
|
|
5496
5551
|
throw new Error();
|
|
5497
|
-
if (!(
|
|
5498
|
-
|
|
5499
|
-
console.error("Failed to create Impact connection: ", result.createImpactConnection
|
|
5500
|
-
.validationErrors);
|
|
5552
|
+
if (!(connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.success)) {
|
|
5553
|
+
console.error("Failed to create Impact connection: ", connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.validationErrors);
|
|
5501
5554
|
throw new Error();
|
|
5502
5555
|
}
|
|
5503
5556
|
await refetch();
|
|
5504
|
-
const resultPublisher = (
|
|
5505
|
-
.createImpactConnection) === null || _c === void 0 ? void 0 : _c.user) === null || _d === void 0 ? void 0 : _d.impactConnection) === null || _e === void 0 ? void 0 : _e.publisher;
|
|
5557
|
+
const resultPublisher = (_f = (_e = connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.user) === null || _e === void 0 ? void 0 : _e.impactConnection) === null || _f === void 0 ? void 0 : _f.publisher;
|
|
5506
5558
|
const hasValidCurrentDocument = validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) && (resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument);
|
|
5507
5559
|
// Fire form change event
|
|
5508
5560
|
window.dispatchEvent(new Event(TAX_FORM_UPDATED_EVENT_KEY));
|
|
@@ -5627,9 +5679,9 @@ function useUserInfoForm(props) {
|
|
|
5627
5679
|
step: step === null || step === void 0 ? void 0 : step.replace("/", ""),
|
|
5628
5680
|
hideState: !hasStates,
|
|
5629
5681
|
hideSteps: !!context.hideSteps,
|
|
5630
|
-
disabled: loading || connectLoading,
|
|
5682
|
+
disabled: loading || connectLoading || completeLoading,
|
|
5631
5683
|
loadingError: !!(userError === null || userError === void 0 ? void 0 : userError.message),
|
|
5632
|
-
loading: loading || connectLoading,
|
|
5684
|
+
loading: loading || connectLoading || completeLoading,
|
|
5633
5685
|
isPartner: !!((_g = (_f = data === null || data === void 0 ? void 0 : data.user) === null || _f === void 0 ? void 0 : _f.impactConnection) === null || _g === void 0 ? void 0 : _g.publisher),
|
|
5634
5686
|
isUser: !!((_j = (_h = data === null || data === void 0 ? void 0 : data.user) === null || _h === void 0 ? void 0 : _h.impactConnection) === null || _j === void 0 ? void 0 : _j.user),
|
|
5635
5687
|
formState: {
|
|
@@ -25,7 +25,8 @@ import { i as isEmpty } from './utilities-c9e730ed.js';
|
|
|
25
25
|
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-657d18f0.js';
|
|
27
27
|
import './sqm-portal-container-view-a8c708cd.js';
|
|
28
|
-
import {
|
|
28
|
+
import { g as getCountryObj, L as LoadingView } from './utils-8267d3d8.js';
|
|
29
|
+
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, c as USER_QUERY_NAMESPACE, G as GET_USER$2, d as COUNTRIES_QUERY_NAMESPACE, e as GET_COUNTRIES, f as FINANCE_NETWORK_SETTINGS_NAMESPACE, g as GET_FINANCE_NETWORK_SETTINGS, h as CURRENCIES_QUERY_NAMESPACE, i as GET_CURRENCIES } from './data-2380309a.js';
|
|
29
30
|
import { S as SHOW_CODE_NAMESPACE, a as VERIFICATION_EMAIL_NAMESPACE, V as VERIFICATION_PARENT_NAMESPACE } from './keys-db1897ae.js';
|
|
30
31
|
import './eventKeys-f76b6a03.js';
|
|
31
32
|
import { u as usePayoutStatus } from './usePayoutStatus-fa504d49.js';
|
|
@@ -8225,6 +8226,7 @@ const WidgetVerification = class {
|
|
|
8225
8226
|
: useWidgetVerification();
|
|
8226
8227
|
if (props.loading)
|
|
8227
8228
|
return h$1("sl-spinner", null);
|
|
8229
|
+
// for handling state previews in content editor
|
|
8228
8230
|
const partnerState = typeof props["sqm-partner-info-modal_stateController"] === "string"
|
|
8229
8231
|
? parseStates(props["sqm-partner-info-modal_stateController"])
|
|
8230
8232
|
: props["sqm-partner-info-modal_stateController"];
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { h, r as registerInstance } from './index-38ad4957.js';
|
|
2
2
|
import { i as intl } from './global-39f55ec2.js';
|
|
3
|
-
import { k as useState, f as useEffect, n as h$1 } from './dom-context-hooks.module-50442785.js';
|
|
3
|
+
import { k as useState, f as useEffect, n as h$1, u as useMemo } from './dom-context-hooks.module-50442785.js';
|
|
4
4
|
import { d as dist, t as Pn, w as wn, J, $ as $e, i as isDemo, r as En, L } from './index.module-cede12c6.js';
|
|
5
5
|
import { c as cjs } from './cjs-bdfb4486.js';
|
|
6
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
|
-
import {
|
|
9
|
+
import { g as GET_FINANCE_NETWORK_SETTINGS } from './data-2380309a.js';
|
|
10
|
+
import { a as PartnerInfoModalContentView, P as PartnerInfoModalView } from './sqm-partner-info-modal-view-78d2bc6e.js';
|
|
10
11
|
import { S as SHOW_CODE_NAMESPACE, a as VERIFICATION_EMAIL_NAMESPACE, V as VERIFICATION_PARENT_NAMESPACE } from './keys-db1897ae.js';
|
|
11
12
|
import { T as TAX_FORM_UPDATED_EVENT_KEY } from './eventKeys-f76b6a03.js';
|
|
12
13
|
import { p as parseStates } from './parseStates-ed75e224.js';
|
|
@@ -500,7 +501,7 @@ const GET_BRAND_NAME = dist.gql `
|
|
|
500
501
|
}
|
|
501
502
|
`;
|
|
502
503
|
function usePartnerInfoModal(props) {
|
|
503
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
504
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
504
505
|
const locale = L();
|
|
505
506
|
const setVerificationContext = En(VERIFICATION_PARENT_NAMESPACE);
|
|
506
507
|
const { data: userData, loading: userLoading, refetch, } = wn(GET_USER_PARTNER_INFO, {});
|
|
@@ -508,19 +509,36 @@ function usePartnerInfoModal(props) {
|
|
|
508
509
|
const { data: currenciesData, loading: currenciesLoading } = wn(GET_CURRENCIES, { variables: { locale } });
|
|
509
510
|
const { data: countriesData, loading: countriesLoading } = wn(GET_COUNTRIES, {});
|
|
510
511
|
const { data: tenantSettingsData } = wn(GET_BRAND_NAME, {});
|
|
512
|
+
const { data: financeNetworkData } = wn(GET_FINANCE_NETWORK_SETTINGS, {
|
|
513
|
+
variables: { filter: {} },
|
|
514
|
+
});
|
|
511
515
|
const [connectImpactPartner, { loading: connectLoading, errors: connectErrors },] = $e(CONNECT_PARTNER);
|
|
512
|
-
const [countryCode, setCountryCode] = useState(((_b = (_a = user === null || user === void 0 ? void 0 : user.impactConnection) === null || _a === void 0 ? void 0 : _a.publisher) === null || _b === void 0 ? void 0 : _b.countryCode) || "");
|
|
516
|
+
const [countryCode, setCountryCode] = useState(((_b = (_a = user === null || user === void 0 ? void 0 : user.impactConnection) === null || _a === void 0 ? void 0 : _a.publisher) === null || _b === void 0 ? void 0 : _b.countryCode) || "US");
|
|
513
517
|
const [currency, setCurrency] = useState(((_d = (_c = user === null || user === void 0 ? void 0 : user.impactConnection) === null || _c === void 0 ? void 0 : _c.publisher) === null || _d === void 0 ? void 0 : _d.currency) || "");
|
|
518
|
+
const countries = ((_e = countriesData === null || countriesData === void 0 ? void 0 : countriesData.impactPayoutCountries) === null || _e === void 0 ? void 0 : _e.data) || [];
|
|
519
|
+
// copied from useTaxAndCash for displaying currencies based on country - could be in helper?
|
|
520
|
+
const currencies = useMemo(() => {
|
|
521
|
+
var _a, _b;
|
|
522
|
+
const allValidCurrencies = (_b = (_a = financeNetworkData === null || financeNetworkData === void 0 ? void 0 : financeNetworkData.impactFinanceNetworkSettings) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.reduce((agg, settings) => {
|
|
523
|
+
var _a, _b;
|
|
524
|
+
const currency = (_b = (_a = currenciesData === null || currenciesData === void 0 ? void 0 : currenciesData.currencies) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.find((c) => c.currencyCode === settings.currency);
|
|
525
|
+
if (!currency)
|
|
526
|
+
return agg;
|
|
527
|
+
if (agg.find((c) => c.currencyCode === settings.currency))
|
|
528
|
+
return agg;
|
|
529
|
+
if (countryCode && settings.countryCode !== countryCode)
|
|
530
|
+
return agg;
|
|
531
|
+
return [...agg, currency];
|
|
532
|
+
}, []);
|
|
533
|
+
return (allValidCurrencies || []).sort((a, b) => a.displayName.localeCompare(b.displayName));
|
|
534
|
+
}, [financeNetworkData, currenciesData, countryCode]);
|
|
514
535
|
console.log(countryCode, currency, "initial country and currency state"); // TEMP
|
|
515
536
|
const [countrySearch, setCountrySearch] = useState("");
|
|
516
537
|
const [currencySearch, setCurrencySearch] = useState("");
|
|
517
|
-
const [filteredCountries, setFilteredCountries] = useState(((
|
|
518
|
-
const [filteredCurrencies, setFilteredCurrencies] = useState(
|
|
538
|
+
const [filteredCountries, setFilteredCountries] = useState(((_f = countriesData === null || countriesData === void 0 ? void 0 : countriesData.impactPayoutCountries) === null || _f === void 0 ? void 0 : _f.data) || []);
|
|
539
|
+
const [filteredCurrencies, setFilteredCurrencies] = useState(currencies || []);
|
|
519
540
|
const [error, setError] = useState("");
|
|
520
541
|
const [success, setSuccess] = useState(false);
|
|
521
|
-
const countries = ((_g = countriesData === null || countriesData === void 0 ? void 0 : countriesData.impactPayoutCountries) === null || _g === void 0 ? void 0 : _g.data) || [];
|
|
522
|
-
const currencies = ((_h = currenciesData === null || currenciesData === void 0 ? void 0 : currenciesData.currencies) === null || _h === void 0 ? void 0 : _h.data) || [];
|
|
523
|
-
console.log(user, "user data from partner info query"); // TEMP
|
|
524
542
|
useEffect(() => {
|
|
525
543
|
var _a;
|
|
526
544
|
if (userData && ((_a = user.impactConnection) === null || _a === void 0 ? void 0 : _a.publisher)) {
|
|
@@ -610,11 +628,11 @@ function usePartnerInfoModal(props) {
|
|
|
610
628
|
setError(props.networkErrorText);
|
|
611
629
|
}
|
|
612
630
|
}
|
|
613
|
-
console.log(success, "success state in partner info modal");
|
|
614
631
|
const showModal = !success &&
|
|
615
632
|
!userLoading &&
|
|
616
633
|
(!(impactConnection === null || impactConnection === void 0 ? void 0 : impactConnection.connected) || !(impactConnection === null || impactConnection === void 0 ? void 0 : impactConnection.publisher));
|
|
617
634
|
console.log(showModal, "showModal condition in partner info modal"); // TEMP
|
|
635
|
+
console.log(filteredCurrencies, "filtered curricneis");
|
|
618
636
|
return {
|
|
619
637
|
states: {
|
|
620
638
|
open: showModal,
|
|
@@ -625,7 +643,7 @@ function usePartnerInfoModal(props) {
|
|
|
625
643
|
currency,
|
|
626
644
|
error,
|
|
627
645
|
success,
|
|
628
|
-
brandName: ((
|
|
646
|
+
brandName: ((_g = tenantSettingsData === null || tenantSettingsData === void 0 ? void 0 : tenantSettingsData.tenantSettings) === null || _g === void 0 ? void 0 : _g.companyName) || "",
|
|
629
647
|
filteredCountries: filteredCountries || [],
|
|
630
648
|
filteredCurrencies: filteredCurrencies || [],
|
|
631
649
|
},
|