@saasquatch/mint-components 2.0.2-12 → 2.0.2-14

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.
@@ -6337,8 +6337,18 @@ const UserInfoFormView = (props) => {
6337
6337
  index.h("sl-button", { type: "primary", disabled: states.disabled, submit: true, exportparts: "base: primarybutton-base" }, text.continueButton))))));
6338
6338
  };
6339
6339
 
6340
+ const GET_INDIRECT_TAX_COUNTRY_CODE = index_module.dist.gql `
6341
+ query getIndirectTaxCountryCode {
6342
+ tenant {
6343
+ settings {
6344
+ impactBrandCountryCode
6345
+ impactBrandIndirectTaxCountryCode
6346
+ }
6347
+ }
6348
+ }
6349
+ `;
6340
6350
  function useUserInfoForm(props) {
6341
- var _a, _b, _c, _d, _e, _f;
6351
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
6342
6352
  const currencyRef = domContextHooks_module.useRef(undefined);
6343
6353
  const phoneCountryRef = domContextHooks_module.useRef(undefined);
6344
6354
  const formRef = domContextHooks_module.useRef(null);
@@ -6348,6 +6358,7 @@ function useUserInfoForm(props) {
6348
6358
  const [userFormContext, setUserFormContext] = index_module.Pn(usePayoutStatus.USER_FORM_CONTEXT_NAMESPACE);
6349
6359
  const user = index_module.J();
6350
6360
  const [connectImpactPartner, { loading: connectLoading, errors: connectErrors },] = index_module.$e(CONNECT_PARTNER);
6361
+ const { data: tenantData } = index_module.wn(GET_INDIRECT_TAX_COUNTRY_CODE, {});
6351
6362
  const { data, loading, refetch, errors: userError, } = index_module.$n(usePayoutStatus.USER_QUERY_NAMESPACE);
6352
6363
  const _currencies = index_module.Fn(usePayoutStatus.CURRENCIES_NAMESPACE);
6353
6364
  const currencies = domContextHooks_module.useMemo(() => [...(_currencies || [])].sort((a, b) => a.displayName.localeCompare(b.displayName)), [_currencies]);
@@ -6561,10 +6572,16 @@ function useUserInfoForm(props) {
6561
6572
  const nextStep = context.overrideNextStep || skipNextStep ? "/3" : "/2";
6562
6573
  setStep(nextStep);
6563
6574
  }
6575
+ const brandCountry = (_b = (_a = tenantData === null || tenantData === void 0 ? void 0 : tenantData.tenant) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.impactBrandCountryCode;
6576
+ const hasIndirectTax = !!((_d = (_c = tenantData === null || tenantData === void 0 ? void 0 : tenantData.tenant) === null || _c === void 0 ? void 0 : _c.settings) === null || _d === void 0 ? void 0 : _d.impactBrandIndirectTaxCountryCode);
6564
6577
  function getSkipNextStep(userData) {
6565
6578
  if (userData.countryCode === "US")
6566
6579
  return true;
6567
- return true;
6580
+ if (!hasIndirectTax)
6581
+ return true;
6582
+ if (hasIndirectTax && userData.countryCode !== brandCountry)
6583
+ return true;
6584
+ return false;
6568
6585
  }
6569
6586
  const hasStates = ["ES", "AU", "US", "CA"].includes(userFormContext.countryCode);
6570
6587
  const regionObj = hasStates
@@ -6593,7 +6610,7 @@ function useUserInfoForm(props) {
6593
6610
  allCountries: countries,
6594
6611
  regionLabelEnum: regionObj === null || regionObj === void 0 ? void 0 : regionObj.labelEnum,
6595
6612
  regions: (regionObj === null || regionObj === void 0 ? void 0 : regionObj.regions) || [],
6596
- partnerData: (_b = (_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.impactConnection) === null || _b === void 0 ? void 0 : _b.publisher,
6613
+ partnerData: (_f = (_e = data === null || data === void 0 ? void 0 : data.user) === null || _e === void 0 ? void 0 : _e.impactConnection) === null || _f === void 0 ? void 0 : _f.publisher,
6597
6614
  },
6598
6615
  states: {
6599
6616
  step: step === null || step === void 0 ? void 0 : step.replace("/", ""),
@@ -6602,8 +6619,8 @@ function useUserInfoForm(props) {
6602
6619
  disabled: loading || connectLoading,
6603
6620
  loadingError: !!(userError === null || userError === void 0 ? void 0 : userError.message),
6604
6621
  loading: loading || connectLoading,
6605
- isPartner: !!((_d = (_c = data === null || data === void 0 ? void 0 : data.user) === null || _c === void 0 ? void 0 : _c.impactConnection) === null || _d === void 0 ? void 0 : _d.publisher),
6606
- isUser: !!((_f = (_e = data === null || data === void 0 ? void 0 : data.user) === null || _e === void 0 ? void 0 : _e.impactConnection) === null || _f === void 0 ? void 0 : _f.user),
6622
+ isPartner: !!((_h = (_g = data === null || data === void 0 ? void 0 : data.user) === null || _g === void 0 ? void 0 : _g.impactConnection) === null || _h === void 0 ? void 0 : _h.publisher),
6623
+ isUser: !!((_k = (_j = data === null || data === void 0 ? void 0 : data.user) === null || _j === void 0 ? void 0 : _j.impactConnection) === null || _k === void 0 ? void 0 : _k.user),
6607
6624
  formState: {
6608
6625
  ...userFormContext,
6609
6626
  errors: formErrors,
@@ -1,4 +1,4 @@
1
- import { useMutation, useParent, useParentQueryValue, useParentValue, useUserIdentity, } from "@saasquatch/component-boilerplate";
1
+ import { useMutation, useParent, useParentQueryValue, useParentValue, useQuery, useUserIdentity, } from "@saasquatch/component-boilerplate";
2
2
  import { useEffect, useMemo, useRef, useState, } from "@saasquatch/universal-hooks";
3
3
  import jsonpointer from "jsonpointer";
4
4
  import { CURRENCIES_NAMESPACE, SORTED_COUNTRIES_NAMESPACE, TAX_CONTEXT_NAMESPACE, TAX_FORM_CONTEXT_NAMESPACE, USER_FORM_CONTEXT_NAMESPACE, USER_QUERY_NAMESPACE, } from "../data";
@@ -6,8 +6,19 @@ import { ADDRESS_REGIONS } from "../subregions";
6
6
  import { objectIsFull, validTaxDocument } from "../utils";
7
7
  import { TAX_FORM_UPDATED_EVENT_KEY } from "../eventKeys";
8
8
  import { CONNECT_PARTNER, } from "../sqm-indirect-tax-form/useIndirectTaxForm";
9
+ import { gql } from "graphql-request";
10
+ const GET_INDIRECT_TAX_COUNTRY_CODE = gql `
11
+ query getIndirectTaxCountryCode {
12
+ tenant {
13
+ settings {
14
+ impactBrandCountryCode
15
+ impactBrandIndirectTaxCountryCode
16
+ }
17
+ }
18
+ }
19
+ `;
9
20
  export function useUserInfoForm(props) {
10
- var _a, _b, _c, _d, _e, _f;
21
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
11
22
  const currencyRef = useRef(undefined);
12
23
  const phoneCountryRef = useRef(undefined);
13
24
  const formRef = useRef(null);
@@ -17,6 +28,7 @@ export function useUserInfoForm(props) {
17
28
  const [userFormContext, setUserFormContext] = useParent(USER_FORM_CONTEXT_NAMESPACE);
18
29
  const user = useUserIdentity();
19
30
  const [connectImpactPartner, { loading: connectLoading, errors: connectErrors },] = useMutation(CONNECT_PARTNER);
31
+ const { data: tenantData } = useQuery(GET_INDIRECT_TAX_COUNTRY_CODE, {});
20
32
  const { data, loading, refetch, errors: userError, } = useParentQueryValue(USER_QUERY_NAMESPACE);
21
33
  const _currencies = useParentValue(CURRENCIES_NAMESPACE);
22
34
  const currencies = useMemo(() => [...(_currencies || [])].sort((a, b) => a.displayName.localeCompare(b.displayName)), [_currencies]);
@@ -230,9 +242,8 @@ export function useUserInfoForm(props) {
230
242
  const nextStep = context.overrideNextStep || skipNextStep ? "/3" : "/2";
231
243
  setStep(nextStep);
232
244
  }
233
- // TODO: get from backend
234
- const hasIndirectTax = false;
235
- const brandCountry = "";
245
+ const brandCountry = (_b = (_a = tenantData === null || tenantData === void 0 ? void 0 : tenantData.tenant) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.impactBrandCountryCode;
246
+ const hasIndirectTax = !!((_d = (_c = tenantData === null || tenantData === void 0 ? void 0 : tenantData.tenant) === null || _c === void 0 ? void 0 : _c.settings) === null || _d === void 0 ? void 0 : _d.impactBrandIndirectTaxCountryCode);
236
247
  function getSkipNextStep(userData) {
237
248
  if (userData.countryCode === "US")
238
249
  return true;
@@ -269,7 +280,7 @@ export function useUserInfoForm(props) {
269
280
  allCountries: countries,
270
281
  regionLabelEnum: regionObj === null || regionObj === void 0 ? void 0 : regionObj.labelEnum,
271
282
  regions: (regionObj === null || regionObj === void 0 ? void 0 : regionObj.regions) || [],
272
- partnerData: (_b = (_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.impactConnection) === null || _b === void 0 ? void 0 : _b.publisher,
283
+ partnerData: (_f = (_e = data === null || data === void 0 ? void 0 : data.user) === null || _e === void 0 ? void 0 : _e.impactConnection) === null || _f === void 0 ? void 0 : _f.publisher,
273
284
  },
274
285
  states: {
275
286
  step: step === null || step === void 0 ? void 0 : step.replace("/", ""),
@@ -278,8 +289,8 @@ export function useUserInfoForm(props) {
278
289
  disabled: loading || connectLoading,
279
290
  loadingError: !!(userError === null || userError === void 0 ? void 0 : userError.message),
280
291
  loading: loading || connectLoading,
281
- isPartner: !!((_d = (_c = data === null || data === void 0 ? void 0 : data.user) === null || _c === void 0 ? void 0 : _c.impactConnection) === null || _d === void 0 ? void 0 : _d.publisher),
282
- isUser: !!((_f = (_e = data === null || data === void 0 ? void 0 : data.user) === null || _e === void 0 ? void 0 : _e.impactConnection) === null || _f === void 0 ? void 0 : _f.user),
292
+ isPartner: !!((_h = (_g = data === null || data === void 0 ? void 0 : data.user) === null || _g === void 0 ? void 0 : _g.impactConnection) === null || _h === void 0 ? void 0 : _h.publisher),
293
+ isUser: !!((_k = (_j = data === null || data === void 0 ? void 0 : data.user) === null || _j === void 0 ? void 0 : _j.impactConnection) === null || _k === void 0 ? void 0 : _k.user),
283
294
  formState: {
284
295
  ...userFormContext,
285
296
  errors: formErrors,
@@ -6333,8 +6333,18 @@ const UserInfoFormView = (props) => {
6333
6333
  h("sl-button", { type: "primary", disabled: states.disabled, submit: true, exportparts: "base: primarybutton-base" }, text.continueButton))))));
6334
6334
  };
6335
6335
 
6336
+ const GET_INDIRECT_TAX_COUNTRY_CODE = dist.gql `
6337
+ query getIndirectTaxCountryCode {
6338
+ tenant {
6339
+ settings {
6340
+ impactBrandCountryCode
6341
+ impactBrandIndirectTaxCountryCode
6342
+ }
6343
+ }
6344
+ }
6345
+ `;
6336
6346
  function useUserInfoForm(props) {
6337
- var _a, _b, _c, _d, _e, _f;
6347
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
6338
6348
  const currencyRef = useRef(undefined);
6339
6349
  const phoneCountryRef = useRef(undefined);
6340
6350
  const formRef = useRef(null);
@@ -6344,6 +6354,7 @@ function useUserInfoForm(props) {
6344
6354
  const [userFormContext, setUserFormContext] = Pn(USER_FORM_CONTEXT_NAMESPACE);
6345
6355
  const user = J();
6346
6356
  const [connectImpactPartner, { loading: connectLoading, errors: connectErrors },] = $e(CONNECT_PARTNER);
6357
+ const { data: tenantData } = wn(GET_INDIRECT_TAX_COUNTRY_CODE, {});
6347
6358
  const { data, loading, refetch, errors: userError, } = $n(USER_QUERY_NAMESPACE);
6348
6359
  const _currencies = Fn(CURRENCIES_NAMESPACE);
6349
6360
  const currencies = useMemo(() => [...(_currencies || [])].sort((a, b) => a.displayName.localeCompare(b.displayName)), [_currencies]);
@@ -6557,10 +6568,16 @@ function useUserInfoForm(props) {
6557
6568
  const nextStep = context.overrideNextStep || skipNextStep ? "/3" : "/2";
6558
6569
  setStep(nextStep);
6559
6570
  }
6571
+ const brandCountry = (_b = (_a = tenantData === null || tenantData === void 0 ? void 0 : tenantData.tenant) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.impactBrandCountryCode;
6572
+ const hasIndirectTax = !!((_d = (_c = tenantData === null || tenantData === void 0 ? void 0 : tenantData.tenant) === null || _c === void 0 ? void 0 : _c.settings) === null || _d === void 0 ? void 0 : _d.impactBrandIndirectTaxCountryCode);
6560
6573
  function getSkipNextStep(userData) {
6561
6574
  if (userData.countryCode === "US")
6562
6575
  return true;
6563
- return true;
6576
+ if (!hasIndirectTax)
6577
+ return true;
6578
+ if (hasIndirectTax && userData.countryCode !== brandCountry)
6579
+ return true;
6580
+ return false;
6564
6581
  }
6565
6582
  const hasStates = ["ES", "AU", "US", "CA"].includes(userFormContext.countryCode);
6566
6583
  const regionObj = hasStates
@@ -6589,7 +6606,7 @@ function useUserInfoForm(props) {
6589
6606
  allCountries: countries,
6590
6607
  regionLabelEnum: regionObj === null || regionObj === void 0 ? void 0 : regionObj.labelEnum,
6591
6608
  regions: (regionObj === null || regionObj === void 0 ? void 0 : regionObj.regions) || [],
6592
- partnerData: (_b = (_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.impactConnection) === null || _b === void 0 ? void 0 : _b.publisher,
6609
+ partnerData: (_f = (_e = data === null || data === void 0 ? void 0 : data.user) === null || _e === void 0 ? void 0 : _e.impactConnection) === null || _f === void 0 ? void 0 : _f.publisher,
6593
6610
  },
6594
6611
  states: {
6595
6612
  step: step === null || step === void 0 ? void 0 : step.replace("/", ""),
@@ -6598,8 +6615,8 @@ function useUserInfoForm(props) {
6598
6615
  disabled: loading || connectLoading,
6599
6616
  loadingError: !!(userError === null || userError === void 0 ? void 0 : userError.message),
6600
6617
  loading: loading || connectLoading,
6601
- isPartner: !!((_d = (_c = data === null || data === void 0 ? void 0 : data.user) === null || _c === void 0 ? void 0 : _c.impactConnection) === null || _d === void 0 ? void 0 : _d.publisher),
6602
- isUser: !!((_f = (_e = data === null || data === void 0 ? void 0 : data.user) === null || _e === void 0 ? void 0 : _e.impactConnection) === null || _f === void 0 ? void 0 : _f.user),
6618
+ isPartner: !!((_h = (_g = data === null || data === void 0 ? void 0 : data.user) === null || _g === void 0 ? void 0 : _g.impactConnection) === null || _h === void 0 ? void 0 : _h.publisher),
6619
+ isUser: !!((_k = (_j = data === null || data === void 0 ? void 0 : data.user) === null || _j === void 0 ? void 0 : _j.impactConnection) === null || _k === void 0 ? void 0 : _k.user),
6603
6620
  formState: {
6604
6621
  ...userFormContext,
6605
6622
  errors: formErrors,