@tesouro/embedded-components-react 0.3.12 → 0.3.13

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 (17) hide show
  1. package/dist/index.d.ts +12 -0
  2. package/dist/lib/CardsWidget.d.ts +12 -0
  3. package/dist/lib/CreateCardWidget.d.ts +12 -0
  4. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index5.js +1 -2
  5. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index.js +3 -2
  6. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index5.js +19 -12
  7. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index6.js +22 -0
  8. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index4.js +4 -1
  9. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index5.js +0 -1
  10. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index6.js +22 -37
  11. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index7.js +167 -110
  12. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +18 -18
  13. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +111 -104
  14. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +144 -128
  15. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js +20 -18
  16. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  17. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -2310,6 +2310,18 @@ interface CreateCardFeatureLabels {
2310
2310
  creating: string;
2311
2311
  success: string;
2312
2312
  error: string;
2313
+ /**
2314
+ * Card issued but granting company admins access to it failed. The card
2315
+ * already exists; this must not read as a create failure.
2316
+ */
2317
+ companyAdminAccessWarning: string;
2318
+ /**
2319
+ * The roster of users to grant access to a new card failed to load.
2320
+ * Shown with a retry action; Create stays disabled until it resolves so
2321
+ * a card is never issued without its required admin grants.
2322
+ */
2323
+ debitCardIssuersError: string;
2324
+ retry: string;
2313
2325
  };
2314
2326
  untitledFundingAccount: string;
2315
2327
  /**
@@ -968,6 +968,18 @@ interface CreateCardFeatureLabels {
968
968
  creating: string;
969
969
  success: string;
970
970
  error: string;
971
+ /**
972
+ * Card issued but granting company admins access to it failed. The card
973
+ * already exists; this must not read as a create failure.
974
+ */
975
+ companyAdminAccessWarning: string;
976
+ /**
977
+ * The roster of users to grant access to a new card failed to load.
978
+ * Shown with a retry action; Create stays disabled until it resolves so
979
+ * a card is never issued without its required admin grants.
980
+ */
981
+ debitCardIssuersError: string;
982
+ retry: string;
971
983
  };
972
984
  untitledFundingAccount: string;
973
985
  /**
@@ -691,6 +691,18 @@ interface CreateCardFeatureLabels {
691
691
  creating: string;
692
692
  success: string;
693
693
  error: string;
694
+ /**
695
+ * Card issued but granting company admins access to it failed. The card
696
+ * already exists; this must not read as a create failure.
697
+ */
698
+ companyAdminAccessWarning: string;
699
+ /**
700
+ * The roster of users to grant access to a new card failed to load.
701
+ * Shown with a retry action; Create stays disabled until it resolves so
702
+ * a card is never issued without its required admin grants.
703
+ */
704
+ debitCardIssuersError: string;
705
+ retry: string;
694
706
  };
695
707
  untitledFundingAccount: string;
696
708
  /**
@@ -17,7 +17,6 @@ var r = {
17
17
  }
18
18
  }, i = [t.BankAccountReadOrg], a = {
19
19
  users: [t.UserReadOrg],
20
- roles: [t.RoleReadOrg],
21
20
  funding: i
22
21
  };
23
22
  function o({ cardProgram: t, scopes: o }) {
@@ -27,7 +26,7 @@ function o({ cardProgram: t, scopes: o }) {
27
26
  canActivate: e(s, c.activate),
28
27
  canCreate: e(s, c.create),
29
28
  canReadFundingAccounts: t === n.Debit && e(s, i),
30
- canComposeDebitCreate: t === n.Debit && e(s, a.users) && e(s, a.roles) && e(s, a.funding)
29
+ canComposeDebitCreate: t === n.Debit && e(s, a.users) && e(s, a.funding)
31
30
  };
32
31
  }
33
32
  //#endregion
@@ -1,5 +1,6 @@
1
1
  import { useCreateCard as e } from "./index2.js";
2
2
  import "./index3.js";
3
3
  import { useCreateDebitCardMutation as t } from "./index4.js";
4
- import { useCreateCardOrganizationQuery as n } from "./index5.js";
5
- export { e as useCreateCard, n as useCreateCardOrganizationQuery, t as useCreateDebitCardMutation };
4
+ import { useManageDebitCardAccessMutation as n } from "./index5.js";
5
+ import { useCreateCardOrganizationQuery as r } from "./index6.js";
6
+ export { e as useCreateCard, r as useCreateCardOrganizationQuery, t as useCreateDebitCardMutation, n as useManageDebitCardAccessMutation };
@@ -2,21 +2,28 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { useEmbedApi as e } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
6
- import { getOrganizationOptions as t } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
7
- import { withAuthEpoch as n } from "../../../shared/data-access/dist/lib/withAuthEpoch.js";
5
+ import { invalidateAllClients as e } from "../../../shared/data-access/dist/lib/clientRegistry.js";
6
+ import { useEmbedApi as t } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
7
+ import { organizationHeaders as n } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
8
+ import { manageDebitCardAccessMutation as r } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
8
9
  import "../../../shared/data-access/dist/index.js";
9
- import { useQuery as r } from "@tanstack/react-query";
10
+ import { debitCardsInvalidationKey as i } from "./index3.js";
11
+ import { useMutation as a } from "@tanstack/react-query";
10
12
  //#region ../../libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index5.js
11
- function i({ enabled: i } = {}) {
12
- let { client: a, organizationId: o, widgetToken: s, authEpoch: c } = e(), l = t({
13
- client: a,
14
- path: { organizationId: o ?? "" }
13
+ function o() {
14
+ let { client: o, organizationId: s } = t(), c = n(s), l = r({
15
+ client: o,
16
+ headers: c
15
17
  });
16
- return r({
17
- ...n(l, c),
18
- enabled: !!(o && s) && (i === !0 || i === void 0)
18
+ return a({
19
+ ...l,
20
+ onSuccess: async (...t) => {
21
+ await e(i({
22
+ client: o,
23
+ organizationId: s
24
+ })), await l.onSuccess?.(...t);
25
+ }
19
26
  });
20
27
  }
21
28
  //#endregion
22
- export { i as useCreateCardOrganizationQuery };
29
+ export { o as useManageDebitCardAccessMutation };
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { useEmbedApi as e } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
6
+ import { getOrganizationOptions as t } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
7
+ import { withAuthEpoch as n } from "../../../shared/data-access/dist/lib/withAuthEpoch.js";
8
+ import "../../../shared/data-access/dist/index.js";
9
+ import { useQuery as r } from "@tanstack/react-query";
10
+ //#region ../../libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index6.js
11
+ function i({ enabled: i } = {}) {
12
+ let { client: a, organizationId: o, widgetToken: s, authEpoch: c } = e(), l = t({
13
+ client: a,
14
+ path: { organizationId: o ?? "" }
15
+ });
16
+ return r({
17
+ ...n(l, c),
18
+ enabled: !!(o && s) && (i === !0 || i === void 0)
19
+ });
20
+ }
21
+ //#endregion
22
+ export { i as useCreateCardOrganizationQuery };
@@ -3,7 +3,10 @@ var e = {
3
3
  toast: {
4
4
  creating: "Creating your card…",
5
5
  success: "Card created successfully.",
6
- error: "We could not create this card. Please try again."
6
+ error: "We could not create this card. Please try again.",
7
+ companyAdminAccessWarning: "Card created, but some admins could not be granted access to it.",
8
+ debitCardIssuersError: "We could not load the list of admins to grant access to this card.",
9
+ retry: "Retry"
7
10
  },
8
11
  untitledFundingAccount: "Bank account",
9
12
  success: {
@@ -7,7 +7,6 @@ function n(n) {
7
7
  return {
8
8
  canIssue: e(r, [t.DebitCardIssueOrg]),
9
9
  canReadUsers: e(r, [t.UserReadOrg]),
10
- canReadRoles: e(r, [t.RoleReadOrg]),
11
10
  canReadFundingAccounts: e(r, [t.BankAccountReadOrg]),
12
11
  canReadOrganization: e(r, [t.OrganizationReadOrg])
13
12
  };
@@ -3,50 +3,35 @@
3
3
  "use client";
4
4
  "use client";
5
5
  import { Scope as e } from "../../../shared/data-access/dist/lib/scopes.js";
6
- import { useAllOrganizationRolesQuery as t } from "../../../shared/data-access/dist/lib/role/useAllOrganizationRolesQuery.js";
7
- import { useRolePermissionsQueries as n } from "../../../shared/data-access/dist/lib/role/useRolePermissionsQueries.js";
8
- import { useAllOrganizationUsersQuery as r } from "../../../shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js";
6
+ import { useAllOrganizationUsersQuery as t } from "../../../shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js";
9
7
  import "../../../shared/data-access/dist/index.js";
10
- import { useCallback as i, useMemo as a } from "react";
8
+ import { useCallback as n, useMemo as r } from "react";
11
9
  //#region ../../libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index6.js
12
- var o = e.DebitCardReadOrg;
13
- function s(e) {
10
+ var i = e.DebitCardReadOrg;
11
+ function a(e) {
14
12
  let t = e.name?.trim(), n = e.email?.trim();
15
13
  return t && n ? `${t} (${n})` : t || n || e.id;
16
14
  }
17
- function c({ enabled: e = !0 } = {}) {
18
- let c = r({ enabled: e }), l = t({ enabled: e }), u = c.data?.data, d = l.data?.data, f = a(() => (d ?? []).map((e) => e.id), [d]), p = n({
19
- roleIds: f,
20
- enabled: e && !l.isResolving
21
- }), m = c.refetch, h = l.refetch, g = p.refetch, _ = e && (c.isResolving || l.isResolving || p.isResolving), v = p.byRoleId, y = a(() => {
22
- if (!e || _) return [];
23
- let t = new Map((d ?? []).filter((e) => e.key?.trim()).map((e) => [e.key.trim().toLowerCase(), e])), n = (e) => !!v.get(e)?.has(o);
24
- return [...u ?? []].filter((e) => {
25
- let r = t.get(e.role?.trim().toLowerCase() ?? "");
26
- return !!(r && n(r.id));
27
- }).sort((e, t) => e.name.localeCompare(t.name)).map((e) => ({
28
- value: e.id,
29
- label: s(e)
30
- }));
31
- }, [
15
+ function o({ enabled: e = !0 } = {}) {
16
+ let o = t({
17
+ enabled: e,
18
+ permissions: [i]
19
+ }), s = o.data?.data, c = r(() => !e || o.isResolving ? [] : [...s ?? []].sort((e, t) => e.name.localeCompare(t.name)).map((e) => ({
20
+ value: e.id,
21
+ label: a(e)
22
+ })), [
32
23
  e,
33
- _,
34
- v,
35
- d,
36
- u
37
- ]), b = i(() => {
38
- m(), h(), g();
39
- }, [
40
- g,
41
- h,
42
- m
43
- ]);
24
+ s,
25
+ o.isResolving
26
+ ]), l = o.refetch, u = n(() => {
27
+ l();
28
+ }, [l]);
44
29
  return {
45
- options: y,
46
- isResolving: _,
47
- isError: e && (c.isError || l.isError || p.isError),
48
- refetch: b
30
+ options: c,
31
+ isResolving: e && o.isResolving,
32
+ isError: e && o.isError,
33
+ refetch: u
49
34
  };
50
35
  }
51
36
  //#endregion
52
- export { o as CARDHOLDER_PERMISSION_KEY, s as formatCardholderOptionLabel, c as useCreateCardCardholderOptions };
37
+ export { i as CARDHOLDER_PERMISSION_KEY, a as formatCardholderOptionLabel, o as useCreateCardCardholderOptions };
@@ -3,38 +3,41 @@
3
3
  "use client";
4
4
  "use client";
5
5
  import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
- import { useAllBankAccountsQuery as t } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
6
+ import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
7
+ import { useAllBankAccountsQuery as n } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
8
+ import { useAllOrganizationUsersQuery as r } from "../../../shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js";
7
9
  import "../../../shared/data-access/dist/index.js";
8
- import { EmbeddedToaster as n } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
10
+ import { EmbeddedToaster as i } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
9
11
  import "../../../shared/ui/dist/index.js";
10
- import { useAnalyticsTrack as r } from "../../../shared/feature/dist/lib/analytics/hooks.js";
11
- import { WidgetProvider as ee } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
12
- import { getStateOptions as i } from "../../../shared/util/dist/lib/usStates.js";
13
- import { useWidgetConfig as a } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
12
+ import { useAnalyticsTrack as a } from "../../../shared/feature/dist/lib/analytics/hooks.js";
13
+ import { WidgetProvider as o } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
14
+ import { getStateOptions as s } from "../../../shared/util/dist/lib/usStates.js";
15
+ import { useWidgetConfig as c } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
14
16
  import "../../../shared/feature/dist/index.js";
15
- import { CREATE_CARD_WIDGET_LABELS_EN as o } from "../../ui/dist/lib/CreateCardWidget/labels.js";
16
- import { CreateCardView as s, MailingOptionValue as c } from "../../ui/dist/lib/CreateCardWidget/types.js";
17
- import { CreateCardWidget as te } from "../../ui/dist/lib/CreateCardWidget/CreateCardWidget.js";
17
+ import { CREATE_CARD_WIDGET_LABELS_EN as l } from "../../ui/dist/lib/CreateCardWidget/labels.js";
18
+ import { CreateCardView as u, MailingOptionValue as d } from "../../ui/dist/lib/CreateCardWidget/types.js";
19
+ import { CreateCardWidget as f } from "../../ui/dist/lib/CreateCardWidget/CreateCardWidget.js";
18
20
  import "../../ui/dist/index.js";
19
- import { CardFormatValue as l, buildCreateDebitCardRequest as u, createDebitCardReference as d, formatBusinessAddress as ne, isBusinessAddressComplete as re, isManualAddressComplete as ie } from "./index3.js";
21
+ import { CardFormatValue as p, buildCreateDebitCardRequest as ee, createDebitCardReference as te, formatBusinessAddress as ne, isBusinessAddressComplete as re, isManualAddressComplete as ie } from "./index3.js";
20
22
  import { resolveCreateCardFeatureLabels as ae } from "./index4.js";
21
- import { CreateCardWidgetAnalyticsEvent as oe, WIDGET_NAME as f } from "./index2.js";
22
- import { getCreateCardPermissions as se } from "./index5.js";
23
- import { useCreateCardCardholderOptions as ce } from "./index6.js";
24
- import { useCreateCard as le } from "../../data-access/dist/index2.js";
25
- import { useCreateDebitCardMutation as ue } from "../../data-access/dist/index4.js";
26
- import { useCreateCardOrganizationQuery as de } from "../../data-access/dist/index5.js";
23
+ import { CreateCardWidgetAnalyticsEvent as oe, WIDGET_NAME as se } from "./index2.js";
24
+ import { getCreateCardPermissions as ce } from "./index5.js";
25
+ import { useCreateCardCardholderOptions as le } from "./index6.js";
26
+ import { useCreateCard as ue } from "../../data-access/dist/index2.js";
27
+ import { useCreateDebitCardMutation as de } from "../../data-access/dist/index4.js";
28
+ import { useManageDebitCardAccessMutation as fe } from "../../data-access/dist/index5.js";
29
+ import { useCreateCardOrganizationQuery as pe } from "../../data-access/dist/index6.js";
27
30
  import "../../data-access/dist/index.js";
28
- import { useEffect as p, useMemo as m, useRef as fe, useState as h } from "react";
29
- import { Fragment as pe, jsx as g, jsxs as me } from "react/jsx-runtime";
31
+ import { useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
32
+ import { Fragment as me, jsx as v, jsxs as he } from "react/jsx-runtime";
30
33
  //#region ../../libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index7.js
31
- var _ = {
34
+ var ge = t.DebitCardIssueOrg, _e = {
32
35
  street: "",
33
36
  city: "",
34
37
  state: "",
35
38
  zip: ""
36
- }, he = 3e3, ge = 5e3;
37
- function _e(e, t) {
39
+ }, ve = 3e3, y = 5e3;
40
+ function ye(e, t) {
38
41
  if (e === "PENDING_ACTIVATION") return {
39
42
  title: t.success.pendingActivationTitle,
40
43
  description: t.success.pendingActivationDescription
@@ -44,159 +47,213 @@ function _e(e, t) {
44
47
  description: t.success.createdDescription
45
48
  };
46
49
  }
47
- function v(e) {
50
+ function b(e) {
48
51
  let t = e?.trim().slice(-4);
49
52
  return t ? `••••${t}` : void 0;
50
53
  }
51
- function y(e, t) {
52
- let n = e.nickname?.trim(), r = v(e.accountNumber);
54
+ function x(e, t) {
55
+ let n = e.nickname?.trim(), r = b(e.accountNumber);
53
56
  return n && r ? `${n} (${r})` : n || r || t;
54
57
  }
55
- function b({ cardArtSrc: ee, labels: f, featureLabels: v, className: b, onClose: x, onCancel: ve, onViewCard: S }) {
56
- let C = r(), { isReady: w } = le(), { initResponse: T, organizationId: E } = a(), D = m(() => se(T?.scopes), [T?.scopes]), O = ae(v), k = {
58
+ function S({ cardArtSrc: t, labels: o, featureLabels: se, className: b, onClose: S, onCancel: C, onViewCard: w }) {
59
+ let T = a(), { isReady: E } = ue(), { initResponse: D, organizationId: O } = c(), k = h(() => ce(D?.scopes), [D?.scopes]), A = ae(se), j = {
60
+ ...l,
57
61
  ...o,
58
- ...f,
59
62
  setup: {
60
- ...o.setup,
61
- ...f?.setup
63
+ ...l.setup,
64
+ ...o?.setup
62
65
  }
63
- }, ye = m(() => [{
64
- value: l.Virtual,
65
- label: k.setup.cardFormatVirtual
66
+ }, be = h(() => [{
67
+ value: p.Virtual,
68
+ label: j.setup.cardFormatVirtual
66
69
  }, {
67
- value: l.Physical,
68
- label: k.setup.cardFormatPhysical
69
- }], [k.setup.cardFormatPhysical, k.setup.cardFormatVirtual]), be = m(() => i(), []), [xe, A] = h(s.Setup), [j, M] = h(null), [N, P] = h(null), [Se, F] = h(null), [I, L] = h(null), [R, z] = h(_), [B, V] = h(null), [H, U] = h(null), W = () => {
70
- M(null), P(null), F(null), L(null), z(_), V(null), U(null), A(s.Setup);
71
- }, G = fe(E);
72
- E && E !== G.current && (G.current = E, W());
73
- let K = fe(!0);
74
- p(() => (K.current = !0, () => {
75
- K.current = !1;
76
- }), []), p(() => {
77
- C(oe.Mounted);
78
- }, [C]);
79
- let { options: Ce, isError: q, refetch: we } = ce({ enabled: w && D.canReadUsers && D.canReadRoles }), Te = de({ enabled: w && D.canReadOrganization }), J = t({ enabled: w && D.canReadFundingAccounts }), Ee = ue(), Y = !!J.isError && w && D.canReadFundingAccounts, X = m(() => Y ? [] : (J.data?.data ?? []).map((e) => ({
70
+ value: p.Physical,
71
+ label: j.setup.cardFormatPhysical
72
+ }], [j.setup.cardFormatPhysical, j.setup.cardFormatVirtual]), xe = h(() => s(), []), [Se, M] = _(u.Setup), [N, P] = _(null), [F, I] = _(null), [Ce, L] = _(null), [R, z] = _(null), [B, V] = _(_e), [H, we] = _(null), [Te, Ee] = _(null), De = () => {
73
+ P(null), I(null), L(null), z(null), V(_e), we(null), Ee(null), M(u.Setup);
74
+ }, Oe = g(O);
75
+ O && O !== Oe.current && (Oe.current = O, De());
76
+ let U = g(!0);
77
+ m(() => (U.current = !0, () => {
78
+ U.current = !1;
79
+ }), []), m(() => {
80
+ T(oe.Mounted);
81
+ }, [T]);
82
+ let { options: ke, isError: W, refetch: Ae } = le({ enabled: E && k.canReadUsers }), G = r({
83
+ enabled: E && k.canReadUsers,
84
+ permissions: [ge]
85
+ }), je = h(() => !E || !k.canReadUsers || G.isResolving || G.isError ? [] : (G.data?.data ?? []).filter((e) => e.organizationId === O).map((e) => e.id), [
86
+ G.data?.data,
87
+ G.isError,
88
+ G.isResolving,
89
+ E,
90
+ O,
91
+ k.canReadUsers
92
+ ]), K = !!G.isError && E && k.canReadUsers, Me = E && k.canReadUsers && G.isResolving, q = g(null);
93
+ m(() => {
94
+ if (!K) {
95
+ q.current !== null && (e.dismiss(q.current), q.current = null);
96
+ return;
97
+ }
98
+ return q.current = e.error(A.toast.debitCardIssuersError, {
99
+ duration: Infinity,
100
+ action: {
101
+ label: A.toast.retry,
102
+ onClick: () => {
103
+ G.refetch();
104
+ }
105
+ }
106
+ }), () => {
107
+ q.current !== null && (e.dismiss(q.current), q.current = null);
108
+ };
109
+ }, [
110
+ G.refetch,
111
+ A.toast.debitCardIssuersError,
112
+ A.toast.retry,
113
+ K
114
+ ]);
115
+ let Ne = pe({ enabled: E && k.canReadOrganization }), J = n({ enabled: E && k.canReadFundingAccounts }), Pe = de(), Fe = fe(), Y = !!J.isError && E && k.canReadFundingAccounts, X = h(() => Y ? [] : (J.data?.data ?? []).map((e) => ({
80
116
  value: e.id,
81
- label: y(e, O.untitledFundingAccount)
117
+ label: x(e, A.untitledFundingAccount)
82
118
  })), [
83
119
  J.data?.data,
84
- O.untitledFundingAccount,
120
+ A.untitledFundingAccount,
85
121
  Y
86
- ]), Z = Se ?? (X.length === 1 ? X[0].value : null), Q = Te.data?.address, De = ne(Q), Oe = re(Q), $ = N === l.Physical, ke = $ && I === c.BusinessAddress && !!De, Ae = $ && I === c.DifferentAddress, je = Y || X.length > 0, Me = !w || !D.canIssue || Ee.isPending || q || Y || !j || !N || !Z || N === l.Physical && (!I || I === c.BusinessAddress && !Oe || I === c.DifferentAddress && !ie(R)), Ne = m(() => {
87
- let e = _e(H, O);
122
+ ]), Z = Ce ?? (X.length === 1 ? X[0].value : null), Q = Ne.data?.address, Ie = ne(Q), Le = re(Q), $ = F === p.Physical, Re = $ && R === d.BusinessAddress && !!Ie, ze = $ && R === d.DifferentAddress, Be = Y || X.length > 0, Ve = !E || !k.canIssue || Pe.isPending || W || Y || K || Me || !N || !F || !Z || F === p.Physical && (!R || R === d.BusinessAddress && !Le || R === d.DifferentAddress && !ie(B)), He = h(() => {
123
+ let e = ye(Te, A);
88
124
  return {
89
- ...f,
125
+ ...o,
90
126
  success: {
91
- ...f?.success,
127
+ ...o?.success,
92
128
  ...e
93
129
  }
94
130
  };
95
131
  }, [
96
- H,
97
- O,
98
- f
99
- ]), Pe = async () => {
100
- if (!w) return;
101
- let t = d(), n = u({
102
- cardholderUserId: j,
103
- format: N,
132
+ Te,
133
+ A,
134
+ o
135
+ ]), Ue = async () => {
136
+ if (!E) return;
137
+ let t = te(), n = ee({
138
+ cardholderUserId: N,
139
+ format: F,
104
140
  bankAccountId: Z,
105
141
  reference: t,
106
- mailingOption: I,
142
+ mailingOption: R,
107
143
  orgAddress: Q,
108
- manualAddress: R
144
+ manualAddress: B
109
145
  });
110
146
  if (!n) return;
111
- A(s.Preparing);
112
- let r = e.loading(O.toast.creating);
147
+ M(u.Preparing);
148
+ let r = e.loading(A.toast.creating);
113
149
  try {
114
- let t = await Ee.mutateAsync({ body: n });
115
- if (!K.current) {
150
+ let t = await Pe.mutateAsync({ body: n });
151
+ if (!U.current) {
152
+ e.dismiss(r);
153
+ return;
154
+ }
155
+ if (we(t.id), Ee(t.cardStatus), je.length > 0) try {
156
+ await Fe.mutateAsync({ body: {
157
+ debitCardIds: [t.id],
158
+ type: "GRANT",
159
+ userIds: je
160
+ } });
161
+ } catch {
162
+ if (!U.current) {
163
+ e.dismiss(r);
164
+ return;
165
+ }
166
+ M(u.Success), e.warning(A.toast.companyAdminAccessWarning, {
167
+ id: r,
168
+ duration: y
169
+ });
170
+ return;
171
+ }
172
+ if (!U.current) {
116
173
  e.dismiss(r);
117
174
  return;
118
175
  }
119
- V(t.id), U(t.cardStatus), A(s.Success), e.success(O.toast.success, {
176
+ M(u.Success), e.success(A.toast.success, {
120
177
  id: r,
121
- duration: he
178
+ duration: ve
122
179
  });
123
180
  } catch {
124
- if (!K.current) {
181
+ if (!U.current) {
125
182
  e.dismiss(r);
126
183
  return;
127
184
  }
128
- A(s.Setup), e.error(O.toast.error, {
185
+ M(u.Setup), e.error(A.toast.error, {
129
186
  id: r,
130
- duration: ge
187
+ duration: y
131
188
  });
132
189
  }
133
190
  };
134
- return /* @__PURE__ */ me(pe, { children: [/* @__PURE__ */ g(n, {}), /* @__PURE__ */ g(te, {
135
- view: xe,
136
- cardArtSrc: ee,
137
- labels: Ne,
191
+ return /* @__PURE__ */ he(me, { children: [/* @__PURE__ */ v(i, {}), /* @__PURE__ */ v(f, {
192
+ view: Se,
193
+ cardArtSrc: t,
194
+ labels: He,
138
195
  className: b,
139
- cardholderOptions: Ce,
140
- selectedCardholder: j,
141
- onCardholderSelect: M,
142
- isCardholderError: q,
143
- onCardholderRetry: q ? we : void 0,
144
- cardFormatOptions: ye,
145
- selectedCardFormat: N,
196
+ cardholderOptions: ke,
197
+ selectedCardholder: N,
198
+ onCardholderSelect: P,
199
+ isCardholderError: W,
200
+ onCardholderRetry: W ? Ae : void 0,
201
+ cardFormatOptions: be,
202
+ selectedCardFormat: F,
146
203
  onCardFormatSelect: (e) => {
147
- P(e), L(null);
204
+ I(e), z(null);
148
205
  },
149
- isFundingAccountVisible: je,
206
+ isFundingAccountVisible: Be,
150
207
  fundingAccountOptions: X,
151
208
  selectedFundingAccount: Z,
152
- onFundingAccountSelect: F,
209
+ onFundingAccountSelect: L,
153
210
  isFundingAccountError: Y,
154
211
  onFundingAccountRetry: Y ? () => {
155
212
  J.refetch();
156
213
  } : void 0,
157
214
  isMailingSectionVisible: $,
158
- selectedMailingOption: I,
159
- onMailingOptionSelect: L,
160
- businessAddress: De,
161
- isBusinessAddressVisible: ke,
162
- isManualAddressVisible: Ae,
163
- manualAddress: R,
164
- onManualAddressChange: (e) => z((t) => ({
215
+ selectedMailingOption: R,
216
+ onMailingOptionSelect: z,
217
+ businessAddress: Ie,
218
+ isBusinessAddressVisible: Re,
219
+ isManualAddressVisible: ze,
220
+ manualAddress: B,
221
+ onManualAddressChange: (e) => V((t) => ({
165
222
  ...t,
166
223
  ...e
167
224
  })),
168
- stateOptions: be,
169
- isCreateDisabled: Me,
225
+ stateOptions: xe,
226
+ isCreateDisabled: Ve,
170
227
  onCreateClick: () => {
171
- Pe();
228
+ Ue();
172
229
  },
173
230
  onCancelClick: () => {
174
- ve?.(), x?.();
231
+ C?.(), S?.();
175
232
  },
176
- onClose: x,
177
- onCreateAnotherClick: W,
178
- onViewCardClick: S && B ? () => {
179
- S(B);
233
+ onClose: S,
234
+ onCreateAnotherClick: De,
235
+ onViewCardClick: w && H ? () => {
236
+ w(H);
180
237
  } : void 0
181
238
  })] });
182
239
  }
183
- function x({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, gatewayRouting: i, linkComponent: a, implementation: o, uiFramework: s, errorFallback: c, onError: te, analytics: l, disclosuresAcceptance: u, ...d }) {
184
- return /* @__PURE__ */ g(ee, {
185
- widgetName: f,
240
+ function C({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, gatewayRouting: i, linkComponent: a, implementation: s, uiFramework: c, errorFallback: l, onError: u, analytics: d, disclosuresAcceptance: f, ...p }) {
241
+ return /* @__PURE__ */ v(o, {
242
+ widgetName: se,
186
243
  baseUrl: e,
187
244
  widgetToken: t,
188
245
  organizationId: n,
189
246
  configClient: r,
190
247
  gatewayRouting: i,
191
248
  linkComponent: a,
192
- implementation: o,
193
- uiFramework: s,
194
- errorFallback: c,
195
- onError: te,
196
- analytics: l,
197
- disclosuresAcceptance: u,
198
- children: /* @__PURE__ */ g(b, { ...d })
249
+ implementation: s,
250
+ uiFramework: c,
251
+ errorFallback: l,
252
+ onError: u,
253
+ analytics: d,
254
+ disclosuresAcceptance: f,
255
+ children: /* @__PURE__ */ v(S, { ...p })
199
256
  });
200
257
  }
201
258
  //#endregion
202
- export { x as CreateCardWidget, y as formatFundingAccountLabel };
259
+ export { C as CreateCardWidget, x as formatFundingAccountLabel };