@tesouro/embedded-components-react 0.4.24 → 0.4.26

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.
@@ -23,14 +23,15 @@ function c({ roleIds: c, enabled: l }) {
23
23
  for (let e of v.current) e.refetch();
24
24
  }, []);
25
25
  return a(() => {
26
- let e = /* @__PURE__ */ new Map();
27
- return g.forEach((t, n) => {
28
- let r = _[n]?.data?.data;
29
- r && e.set(t, new Set(r.map((e) => e.key)));
26
+ let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
27
+ return g.forEach((n, r) => {
28
+ let i = _[r], a = i?.data?.data;
29
+ a && e.set(n, new Set(a.map((e) => e.key))), i?.isLoading && t.add(n);
30
30
  }), {
31
31
  byRoleId: e,
32
32
  isResolving: h && g.length > 0 && _.some((e) => e.isLoading),
33
33
  isError: _.some((e) => e.isError),
34
+ resolvingRoleIds: t,
34
35
  refetch: y
35
36
  };
36
37
  }, [
@@ -1,5 +1,5 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
2
- var e = "@tesouro/embedded-components-react", t = "0.4.24", n = "1f0ca563b171bebb1fd0cec1979133b1a44e06fb", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.4.26", n = "60ffb54e5a1ba4716173396e50e183cb8d4450e6", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
@@ -13,13 +13,19 @@ function m(e, n) {
13
13
  return r(i.filter(p));
14
14
  }
15
15
  function h(e, t) {
16
+ return t ? e.filter((e) => n({
17
+ ...e,
18
+ status: "ACTIVE"
19
+ }, t)) : [...e];
20
+ }
21
+ function g(e, t) {
16
22
  let i = t ? e.filter((e) => n({
17
23
  ...e,
18
24
  status: "ACTIVE"
19
25
  }, t)) : e;
20
26
  return d(r(i));
21
27
  }
22
- function g(e) {
28
+ function _(e) {
23
29
  return e.map((e) => ({
24
30
  value: e.id,
25
31
  label: e.name,
@@ -27,18 +33,18 @@ function g(e) {
27
33
  icon: f(e.key, e.icon)
28
34
  }));
29
35
  }
30
- function _(e) {
36
+ function v(e) {
31
37
  return e.map((e) => ({
32
38
  value: e.id,
33
39
  label: e.name
34
40
  }));
35
41
  }
36
- function v(e) {
42
+ function y(e) {
37
43
  return (e.status ?? "").trim().toUpperCase() === "ACTIVE";
38
44
  }
39
- function y(e, t, n, r) {
40
- return e.filter(v).map((e) => {
41
- let i = o(l(t, e.organizationId, r), e.role) ?? w(e.role, n);
45
+ function b(e, t, n, r) {
46
+ return e.filter(y).map((e) => {
47
+ let i = o(l(t, e.organizationId, r), e.role) ?? E(e.role, n);
42
48
  return {
43
49
  value: e.id,
44
50
  label: e.name,
@@ -46,7 +52,7 @@ function y(e, t, n, r) {
46
52
  };
47
53
  });
48
54
  }
49
- function b(e, t) {
55
+ function x(e, t) {
50
56
  let n = t?.trim();
51
57
  if (!n) return;
52
58
  let r = n.toLowerCase(), a = i(n);
@@ -55,24 +61,27 @@ function b(e, t) {
55
61
  return t.toLowerCase() === r || n === a || e.name.trim().toLowerCase() === a;
56
62
  })?.id;
57
63
  }
58
- var x = ["INACTIVE", "REVOKED"];
59
- function S(e) {
64
+ var S = ["INACTIVE", "REVOKED"];
65
+ function C(e) {
60
66
  if (!e) return !1;
61
67
  let t = e.status?.trim().toUpperCase() ?? "";
62
- return !x.includes(t);
68
+ return !S.includes(t);
63
69
  }
64
- function C(e) {
70
+ function w(e) {
71
+ return (e?.status ?? "").trim().toUpperCase() === "INVITED";
72
+ }
73
+ function T(e) {
65
74
  return e.split(/[\s_-]+/).filter(Boolean).map((e) => e[0].toUpperCase() + e.slice(1).toLowerCase()).join(" ");
66
75
  }
67
- function w(e, t) {
76
+ function E(e, t) {
68
77
  let n = e?.trim();
69
- return n ? C(u(n).trim() || n) : t.notAvailable;
78
+ return n ? T(u(n).trim() || n) : t.notAvailable;
70
79
  }
71
- function T(e, t) {
80
+ function D(e, t) {
72
81
  let n = e?.trim();
73
82
  return n ? n[0].toUpperCase() + n.slice(1).toLowerCase() : t.notAvailable;
74
83
  }
75
- function E(e) {
84
+ function O(e) {
76
85
  if (!e) return "";
77
86
  let t = new Date(e);
78
87
  return Number.isNaN(t.getTime()) ? "" : t.toLocaleString(void 0, {
@@ -83,66 +92,66 @@ function E(e) {
83
92
  minute: "2-digit"
84
93
  });
85
94
  }
86
- function D(t, n, r = [], i) {
95
+ function k(t, n, r = [], i) {
87
96
  let a = l(r, t.organizationId, i);
88
97
  return {
89
98
  name: t.name,
90
99
  email: t.email,
91
100
  initials: e(t.name),
92
- roleLabel: o(a, t.role) ?? w(t.role, n),
93
- statusLabel: T(t.status, n)
101
+ roleLabel: o(a, t.role) ?? E(t.role, n),
102
+ statusLabel: D(t.status, n)
94
103
  };
95
104
  }
96
- function O(e) {
105
+ function A(e) {
97
106
  switch ((e ?? "").trim().toUpperCase()) {
98
107
  case "ACTIVE": return "success";
99
108
  case "INVITED": return "info";
100
109
  default: return "neutral";
101
110
  }
102
111
  }
103
- function k(e, t, n, r = [], i) {
112
+ function j(e, t, n, r = [], i) {
104
113
  return {
105
114
  key: e.id,
106
- ...D(e, t, r, i),
107
- statusTone: O(e.status),
115
+ ...k(e, t, r, i),
116
+ statusTone: A(e.status),
108
117
  departmentLabel: e.department?.name?.trim() || t.notAvailable,
109
- isInactive: !S(e),
118
+ isInactive: !C(e),
110
119
  onSelect: n
111
120
  };
112
121
  }
113
- function A(e, t, n, r = [], i) {
114
- return e.map((e) => k(e, t, () => n(e.id), r, i));
122
+ function M(e, t, n, r = [], i) {
123
+ return e.map((e) => j(e, t, () => n(e.id), r, i));
115
124
  }
116
- function j(t, n, r = [], i) {
117
- let u = l(r, t.organizationId, i), d = o(u, t.role) ?? w(t.role, n), p = a(u, t.role) ?? "", m = s(u, t.role) ?? null, h = c(u, t.role);
125
+ function N(t, n, r = [], i) {
126
+ let u = l(r, t.organizationId, i), d = o(u, t.role) ?? E(t.role, n), p = a(u, t.role) ?? "", m = s(u, t.role) ?? null, h = c(u, t.role);
118
127
  return {
119
128
  name: t.name,
120
129
  email: t.email,
121
130
  initials: e(t.name),
122
- statusLabel: T(t.status, n),
123
- statusTone: O(t.status),
131
+ statusLabel: D(t.status, n),
132
+ statusTone: A(t.status),
124
133
  accountAccessLabel: n.notAvailable,
125
134
  roleCardTitle: d,
126
135
  roleCardDescription: p,
127
136
  roleCardIcon: f(h, m),
128
- lastSignInLabel: E(t.lastLoggedInDateTime),
137
+ lastSignInLabel: O(t.lastLoggedInDateTime),
129
138
  departmentLabel: t.department?.name?.trim() || n.notAvailable,
130
139
  locationLabel: t.location?.name?.trim() || n.notAvailable
131
140
  };
132
141
  }
133
- function M(t, n, r, i = [], a) {
142
+ function P(t, n, r, i = [], a) {
134
143
  return t.filter((e) => e.reportingManagerUserId === n).map((t) => ({
135
144
  key: t.id,
136
145
  email: t.email,
137
146
  name: t.name,
138
147
  initials: e(t.name),
139
- roleLabel: o(l(i, t.organizationId, a), t.role) ?? w(t.role, r),
148
+ roleLabel: o(l(i, t.organizationId, a), t.role) ?? E(t.role, r),
140
149
  departmentLabel: t.department?.name?.trim() || r.notAvailable,
141
- statusLabel: T(t.status, r),
142
- statusTone: O(t.status)
150
+ statusLabel: D(t.status, r),
151
+ statusTone: A(t.status)
143
152
  }));
144
153
  }
145
- function N(t, n) {
154
+ function F(t, n) {
146
155
  if (!n) return;
147
156
  let r = t.find((e) => e.id === n);
148
157
  if (r) return {
@@ -153,4 +162,4 @@ function N(t, n) {
153
162
  };
154
163
  }
155
164
  //#endregion
156
- export { p as isAssignableRole, v as isEligibleReportingManager, S as isMemberActionable, b as resolveMemberRoleId, N as resolveReportingManager, m as toAssignableRoles, M as toDirectReportRows, _ as toNamedSelectOptions, y as toReportingManagerOptions, g as toRoleCardOptions, h as toRoleDisplayCatalog, j as toTeamMemberDetails, k as toTeamMemberRow, A as toTeamMemberRows };
165
+ export { p as isAssignableRole, y as isEligibleReportingManager, C as isMemberActionable, w as isMemberInvited, x as resolveMemberRoleId, F as resolveReportingManager, m as toAssignableRoles, P as toDirectReportRows, v as toNamedSelectOptions, b as toReportingManagerOptions, _ as toRoleCardOptions, g as toRoleDisplayCatalog, h as toScopedRoles, N as toTeamMemberDetails, j as toTeamMemberRow, M as toTeamMemberRows };
@@ -5,22 +5,23 @@
5
5
  import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
6
  import { useAllBankAccountsQuery as t } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
7
7
  import { useAllExternalBankAccountsQuery as n } from "../../../shared/data-access/dist/lib/external-bank-account/useAllExternalBankAccountsQuery.js";
8
+ import { useRolePermissionsQueries as r } from "../../../shared/data-access/dist/lib/role/useRolePermissionsQueries.js";
8
9
  import "../../../shared/data-access/dist/index.js";
9
10
  import "../../../shared/ui/dist/index.js";
10
- import { useAnalyticsTrack as r } from "../../../shared/feature/dist/lib/analytics/hooks.js";
11
+ import { useAnalyticsTrack as i } from "../../../shared/feature/dist/lib/analytics/hooks.js";
11
12
  import "../../../shared/feature/dist/index.js";
12
- import { TeamWidgetAnalyticsEvent as i } from "./index2.js";
13
+ import { TeamWidgetAnalyticsEvent as ee } from "./index2.js";
13
14
  import { useInviteUserMutation as a } from "../../data-access/dist/index7.js";
14
15
  import { useAllTeamMembersQuery as o } from "../../data-access/dist/index14.js";
15
16
  import { useAllDepartmentsQuery as s } from "../../data-access/dist/index17.js";
16
- import { useAllLocationsQuery as c } from "../../data-access/dist/index21.js";
17
+ import { useAllLocationsQuery as te } from "../../data-access/dist/index21.js";
17
18
  import "../../data-access/dist/index.js";
18
- import { toNamedSelectOptions as l, toReportingManagerOptions as ee, toRoleCardOptions as te } from "./index11.js";
19
- import { isAccountsSectionVisibleForRole as ne, isAdminRoleKey as u, isEmployeeRoleKey as re, resolveRoleKeyById as d, toAccountAccessInputs as f, toAccountAccessOptions as ie } from "./index7.js";
20
- import { resolveAcceptInviteRedirectUri as ae } from "./index8.js";
21
- import { useMemo as p, useState as m } from "react";
19
+ import { toNamedSelectOptions as c, toReportingManagerOptions as ne, toRoleCardOptions as re } from "./index11.js";
20
+ import { isAccountsSectionVisibleForRole as ie, isAdminPermissionSet as ae, isEmployeePermissionSet as l, toAccountAccessInputs as oe, toAccountAccessOptions as se } from "./index7.js";
21
+ import { resolveAcceptInviteRedirectUri as u } from "./index8.js";
22
+ import { useMemo as d, useState as f } from "react";
22
23
  //#region ../../libs/tesouro-embedded-components-react/team-widget/feature/dist/index12.js
23
- var h = {
24
+ var p = {
24
25
  name: "",
25
26
  email: "",
26
27
  department: "",
@@ -28,78 +29,81 @@ var h = {
28
29
  reportingManager: "",
29
30
  role: "",
30
31
  accountAccess: []
31
- }, g = /^\S+@\S+\.\S+$/;
32
- function _({ canInvite: _, canReadDirectory: v, canManageAccountAccess: y, canReadInternalAccounts: b, canReadExternalAccounts: x, roles: S, roleCatalog: C = [], organizationId: w, featureLabels: T, acceptInviteRedirectUri: E }) {
33
- let oe = r(), [D, O] = m(!1), [k, A] = m(h), [se, j] = m({}), M = a(), N = D && _ && v, P = s({ enabled: N }), F = c({ enabled: N }), I = o({
32
+ }, ce = /^\S+@\S+\.\S+$/;
33
+ function m({ canInvite: m, canReadDirectory: h, canManageAccountAccess: g, canReadInternalAccounts: _, canReadExternalAccounts: v, roles: y, roleCatalog: b = [], organizationId: x, featureLabels: S, acceptInviteRedirectUri: le }) {
34
+ let C = i(), [w, T] = f(!1), [E, D] = f(p), [ue, O] = f({}), k = a(), A = w && m && h, j = s({ enabled: A }), M = te({ enabled: A }), N = o({
34
35
  Status: "ACTIVE",
35
- enabled: N
36
- }), L = D && _ && y, R = t({ enabled: L && b }), z = n({ enabled: L && x }), B = p(() => te(S), [S]), V = p(() => P.isComplete ? l(P.data?.data ?? []) : [], [P.isComplete, P.data?.data]), H = p(() => F.isComplete ? l(F.data?.data ?? []) : [], [F.isComplete, F.data?.data]), U = p(() => I.isComplete ? ee(I.data?.data ?? [], C, T, w) : [], [
37
- I.isComplete,
38
- I.data?.data,
39
- C,
40
- T,
41
- w
42
- ]), W = N && !P.isComplete && !P.isError, G = N && !F.isComplete && !F.isError, K = N && !I.isComplete && !I.isError, ce = N && P.isError, le = N && F.isError, ue = N && I.isError, q = !b || !!R.data && !R.hasNextPage && !R.isFetchingNextPage, de = !x || !!z.data && !z.hasNextPage && !z.isFetchingNextPage, J = L && (b && R.isError || x && z.isError), Y = L && !J && (!q || !de), X = p(() => ie(b ? R.data?.data ?? [] : [], x ? z.data?.data ?? [] : [], {
43
- checking: T.accountTypeChecking,
44
- savings: T.accountTypeSavings
45
- }), [
36
+ enabled: A
37
+ }), P = w && m && g, F = t({ enabled: P && _ }), I = n({ enabled: P && v }), L = w && m, R = d(() => y.map((e) => e.id), [y]), z = r({
38
+ roleIds: R,
39
+ enabled: L
40
+ }), B = d(() => re(y), [y]), V = d(() => j.isComplete ? c(j.data?.data ?? []) : [], [j.isComplete, j.data?.data]), H = d(() => M.isComplete ? c(M.data?.data ?? []) : [], [M.isComplete, M.data?.data]), de = d(() => N.isComplete ? ne(N.data?.data ?? [], b, S, x) : [], [
41
+ N.isComplete,
42
+ N.data?.data,
46
43
  b,
47
- x,
48
- R.data?.data,
49
- z.data?.data,
50
- T.accountTypeChecking,
51
- T.accountTypeSavings
52
- ]), fe = X.options, Z = d(S, k.role), Q = u(Z), $ = y && ne(Z), pe = y && re(Z), me = $ ? Q ? "admin" : "picker" : pe ? "employee" : "hidden";
44
+ S,
45
+ x
46
+ ]), U = A && !j.isComplete && !j.isError, W = A && !M.isComplete && !M.isError, G = A && !N.isComplete && !N.isError, fe = A && j.isError, pe = A && M.isError, me = A && N.isError, he = !_ || !!F.data && !F.hasNextPage && !F.isFetchingNextPage, ge = !v || !!I.data && !I.hasNextPage && !I.isFetchingNextPage, K = !!E.role && z.resolvingRoleIds.has(E.role), q = L && !!E.role && (K || !z.byRoleId.has(E.role)) && !K, J = P && (_ && F.isError || v && I.isError || q), Y = P && !J && (!he || !ge || K), X = d(() => se(_ ? F.data?.data ?? [] : [], v ? I.data?.data ?? [] : [], {
47
+ checking: S.accountTypeChecking,
48
+ savings: S.accountTypeSavings
49
+ }), [
50
+ _,
51
+ v,
52
+ F.data?.data,
53
+ I.data?.data,
54
+ S.accountTypeChecking,
55
+ S.accountTypeSavings
56
+ ]), _e = X.options, Z = z.byRoleId.get(E.role), Q = ae(Z), $ = g && ie(!!E.role, l(Z)), ve = g && l(Z), ye = $ ? Q ? "admin" : "picker" : ve ? "employee" : "hidden";
53
57
  return {
54
- isInviteOpen: D,
55
- inviteForm: k,
56
- inviteErrors: se,
57
- isInviting: M.isPending,
58
- inviteErrorMessage: M.isError ? T.inviteFailedError : void 0,
58
+ isInviteOpen: w,
59
+ inviteForm: E,
60
+ inviteErrors: ue,
61
+ isInviting: k.isPending,
62
+ inviteErrorMessage: k.isError ? S.inviteFailedError : void 0,
59
63
  roleOptions: B,
60
64
  departmentOptions: V,
61
65
  locationOptions: H,
62
- reportingManagerOptions: U,
63
- accountAccessOptions: fe,
64
- departmentsLoading: W,
65
- locationsLoading: G,
66
- reportingManagersLoading: K,
67
- departmentsError: ce,
68
- locationsError: le,
69
- reportingManagersError: ue,
66
+ reportingManagerOptions: de,
67
+ accountAccessOptions: _e,
68
+ departmentsLoading: U,
69
+ locationsLoading: W,
70
+ reportingManagersLoading: G,
71
+ departmentsError: fe,
72
+ locationsError: pe,
73
+ reportingManagersError: me,
70
74
  accountAccessLoading: Y,
71
75
  accountAccessError: J,
72
- accountAccessMode: me,
76
+ accountAccessMode: ye,
73
77
  openInviteForm: () => {
74
- _ && (A(h), j({}), M.reset(), O(!0));
78
+ m && (D(p), O({}), k.reset(), T(!0));
75
79
  },
76
80
  closeInviteForm: () => {
77
- O(!1);
81
+ T(!1);
78
82
  },
79
- onInviteFormChange: A,
83
+ onInviteFormChange: D,
80
84
  onInviteSubmit: () => {
81
- if (!_ || W || G || K || $ && (Y || J)) return;
82
- let t = {}, n = k.name.trim(), r = k.email.trim();
83
- n || (t.name = T.nameRequiredError), r ? g.test(r) || (t.email = T.emailInvalidError) : t.email = T.emailRequiredError;
84
- let a = k.role;
85
- if (S.some((e) => e.id === a) ? Q && !y && (t.role = T.roleNeedsAccountAccessError) : t.role = T.roleRequiredError, j(t), t.name || t.email || t.role) return;
86
- let o = $ ? Q ? X.allAccountIds : k.accountAccess : [], s = f(o, X.descriptors);
87
- M.mutate({
85
+ if (!m || U || W || G || $ && (Y || J) || K) return;
86
+ let t = {}, n = E.name.trim(), r = E.email.trim();
87
+ n || (t.name = S.nameRequiredError), r ? ce.test(r) || (t.email = S.emailInvalidError) : t.email = S.emailRequiredError;
88
+ let i = E.role;
89
+ if (y.some((e) => e.id === i) ? q ? t.role = S.rolePermissionsUnavailableError : Q && !g && (t.role = S.roleNeedsAccountAccessError) : t.role = S.roleRequiredError, O(t), t.name || t.email || t.role) return;
90
+ let a = $ ? Q ? X.allAccountIds : E.accountAccess : [], o = oe(a, X.descriptors);
91
+ k.mutate({
88
92
  body: {
89
93
  name: n,
90
94
  email: r,
91
95
  status: "INVITED",
92
- reportingManagerUserId: k.reportingManager || null,
96
+ reportingManagerUserId: E.reportingManager || null,
93
97
  permissionIds: [],
94
- redirectUri: ae(E)
98
+ redirectUri: u(le)
95
99
  },
96
- roleId: a,
97
- departmentId: k.department || void 0,
98
- locationId: k.location || void 0,
99
- bankAccountAccess: s
100
+ roleId: i,
101
+ departmentId: E.department || void 0,
102
+ locationId: E.location || void 0,
103
+ bankAccountAccess: o
100
104
  }, {
101
105
  onSuccess: (t) => {
102
- oe(i.MemberInvited, { memberId: t?.id }), e.success(T.inviteSuccessToast), O(!1);
106
+ C(ee.MemberInvited, { memberId: t?.id }), e.success(S.inviteSuccessToast), T(!1);
103
107
  },
104
108
  onError: (e) => {
105
109
  console.error("Failed to send team invite:", e);
@@ -109,4 +113,4 @@ function _({ canInvite: _, canReadDirectory: v, canManageAccountAccess: y, canRe
109
113
  };
110
114
  }
111
115
  //#endregion
112
- export { _ as useInviteForm };
116
+ export { m as useInviteForm };
@@ -4,69 +4,78 @@
4
4
  "use client";
5
5
  import { useAllBankAccountsQuery as e } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
6
6
  import { useAllExternalBankAccountsQuery as t } from "../../../shared/data-access/dist/lib/external-bank-account/useAllExternalBankAccountsQuery.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";
7
9
  import "../../../shared/data-access/dist/index.js";
8
- import { useUserBankAccountAccessQuery as n } from "../../data-access/dist/index10.js";
10
+ import { useUserBankAccountAccessQuery as i } from "../../data-access/dist/index10.js";
9
11
  import "../../data-access/dist/index.js";
10
- import { formatAccountAccessLabel as r, isAdminRoleKey as i, toAccountAccessOptions as a } from "./index7.js";
11
- import { useMemo as o } from "react";
12
+ import { isMemberInvited as a, resolveMemberRoleId as o } from "./index11.js";
13
+ import { ACCOUNT_ACCESS_ADMIN_PERMISSION_KEY as s, formatAccountAccessLabel as c, isAdminPermissionSet as l, toAccountAccessOptions as u } from "./index7.js";
14
+ import { useMemo as d } from "react";
12
15
  //#region ../../libs/tesouro-embedded-components-react/team-widget/feature/dist/index14.js
13
- function s({ selectedMember: s, canReadInternalAccounts: c, canReadExternalAccounts: l, featureLabels: u }) {
14
- let d = c && l, f = s?.id, p = i(s?.role ?? ""), m = !!s && d, h = e({ enabled: m && c }), g = t({ enabled: m && l }), _ = !c || !!h.data && !h.hasNextPage && !h.isFetchingNextPage, v = !l || !!g.data && !g.hasNextPage && !g.isFetchingNextPage, y = m && _ && v, b = m && (c && h.isError || l && g.isError), x = o(() => a(c ? h.data?.data ?? [] : [], l ? g.data?.data ?? [] : [], {
15
- checking: u.accountTypeChecking,
16
- savings: u.accountTypeSavings
16
+ function f({ selectedMember: f, canReadInternalAccounts: p, canReadExternalAccounts: m, featureLabels: h, allRoles: g }) {
17
+ let _ = p && m, v = f?.id, y = !!f && _, b = e({ enabled: y && p }), x = t({ enabled: y && m }), S = a(f), C = o(g, f?.role) ?? "", w = n({
18
+ roleIds: C ? [C] : [],
19
+ enabled: y && S
20
+ }), T = r({
21
+ enabled: y && !S,
22
+ permissions: [s]
23
+ }), E = y ? S ? w.resolvingRoleIds.has(C) : T.isResolving : !1, D = y && (S ? !E && !w.byRoleId.has(C) : T.isError), O = !!(v && !E && !D && (S ? l(w.byRoleId.get(C)) : (T.data?.data ?? []).some((e) => e.id === v))), k = !p || !!b.data && !b.hasNextPage && !b.isFetchingNextPage, A = !m || !!x.data && !x.hasNextPage && !x.isFetchingNextPage, j = y && k && A && !E, M = y && (p && b.isError || m && x.isError || D), N = d(() => u(p ? b.data?.data ?? [] : [], m ? x.data?.data ?? [] : [], {
24
+ checking: h.accountTypeChecking,
25
+ savings: h.accountTypeSavings
17
26
  }), [
18
- c,
19
- l,
20
- h.data?.data,
21
- g.data?.data,
22
- u.accountTypeChecking,
23
- u.accountTypeSavings
24
- ]), S = o(() => [...x.descriptors.values()].map((e) => ({
27
+ p,
28
+ m,
29
+ b.data?.data,
30
+ x.data?.data,
31
+ h.accountTypeChecking,
32
+ h.accountTypeSavings
33
+ ]), P = d(() => [...N.descriptors.values()].map((e) => ({
25
34
  bankAccountId: e.bankAccountId,
26
35
  source: e.source
27
- })), [x.descriptors]), C = n({
28
- userId: f,
29
- accounts: S,
30
- enabled: !!s && d && !p && y
31
- }), w = S.length === 0 || C.isComplete, T = o(() => !d || !s ? u.notAvailable : p ? u.accountAccessAll : !y || !w ? u.notAvailable : r({
36
+ })), [N.descriptors]), F = i({
37
+ userId: v,
38
+ accounts: P,
39
+ enabled: !!f && _ && !O && j
40
+ }), I = P.length === 0 || F.isComplete, L = d(() => !_ || !f ? h.notAvailable : O ? h.accountAccessAll : !j || !I ? h.notAvailable : c({
32
41
  isAdmin: !1,
33
- accessibleCount: C.accessibleAccountIds.size,
34
- totalCount: x.allAccountIds.length,
35
- labels: u
42
+ accessibleCount: F.accessibleAccountIds.size,
43
+ totalCount: N.allAccountIds.length,
44
+ labels: h
36
45
  }), [
37
- d,
38
- s,
39
- p,
40
- y,
41
- w,
42
- C.accessibleAccountIds,
43
- x.allAccountIds.length,
44
- u
45
- ]), E = o(() => p ? x.allAccountIds : [...C.accessibleAccountIds], [
46
- p,
47
- x.allAccountIds,
48
- C.accessibleAccountIds
49
- ]), D = o(() => {
50
- let e = new Set(E);
51
- return x.options.filter((t) => e.has(t.value)).map((e) => ({
46
+ _,
47
+ f,
48
+ O,
49
+ j,
50
+ I,
51
+ F.accessibleAccountIds,
52
+ N.allAccountIds.length,
53
+ h
54
+ ]), R = d(() => O ? N.allAccountIds : [...F.accessibleAccountIds], [
55
+ O,
56
+ N.allAccountIds,
57
+ F.accessibleAccountIds
58
+ ]), z = d(() => {
59
+ let e = new Set(R);
60
+ return N.options.filter((t) => e.has(t.value)).map((e) => ({
52
61
  value: e.value,
53
62
  name: e.name,
54
63
  typeLabel: e.typeLabel,
55
64
  maskedNumber: e.maskedNumber,
56
65
  source: e.source,
57
- sourceLabel: e.source === "internal" ? u.accountSourceInternal : u.accountSourceExternal
66
+ sourceLabel: e.source === "internal" ? h.accountSourceInternal : h.accountSourceExternal
58
67
  }));
59
68
  }, [
60
- x.options,
61
- E,
62
- u.accountSourceInternal,
63
- u.accountSourceExternal
64
- ]), O = !!s && d && (b || !p && C.isError);
69
+ N.options,
70
+ R,
71
+ h.accountSourceInternal,
72
+ h.accountSourceExternal
73
+ ]), B = !!f && _ && (M || !O && F.isError);
65
74
  return {
66
- detailAccountAccessLabel: T,
67
- detailAccounts: D,
68
- detailAccountsLoading: !!s && d && !O && (!y || !p && !w)
75
+ detailAccountAccessLabel: L,
76
+ detailAccounts: z,
77
+ detailAccountsLoading: !!f && _ && !B && (!j || !O && !I)
69
78
  };
70
79
  }
71
80
  //#endregion
72
- export { s as useMemberAccountAccess };
81
+ export { f as useMemberAccountAccess };