@tesouro/embedded-components-react 0.11.100 → 0.11.101
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/experimental/QuickViewWidget.d.ts +62 -2
- package/dist/experimental/index.d.ts +62 -2
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/accounts/ui/dist/index2.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/bills/ui/dist/index2.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/data-access/dist/index.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/data-access/dist/index2.js +98 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/index.js +3 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/CardsQuickViewWidgetFeature.js +80 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/labels.js +27 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/summarizeCardSpend.js +17 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/testIds.js +7 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/useCardSpendSummary.js +29 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/analytics/events.js +4 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/ui/dist/index.js +3 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/ui/dist/index2.js +8 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/ui/dist/index3.js +31 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/feature/dist/lib/QuickViewWidget/QuickViewWidget.js +57 -44
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/feature/dist/lib/QuickViewWidget/labels.js +6 -3
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/invoices/ui/dist/index2.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +43 -43
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/debit-card/useAllDebitCardsQuery.js +22 -18
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +97 -97
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +166 -154
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
|
@@ -739,11 +739,61 @@ interface BillsQuickViewWidgetLabels extends BillsQuickViewTileLabels {
|
|
|
739
739
|
}) => string;
|
|
740
740
|
}
|
|
741
741
|
|
|
742
|
+
interface CardsQuickViewTileLabels {
|
|
743
|
+
/**
|
|
744
|
+
* Tile heading above the total, used when the caller passes no `title`,
|
|
745
|
+
* as before the browser's month is known.
|
|
746
|
+
*/
|
|
747
|
+
title: string;
|
|
748
|
+
/** Screen-reader only: names the wait while card spend loads. */
|
|
749
|
+
loadingLabel: string;
|
|
750
|
+
/** Shown when the card spend request failed. */
|
|
751
|
+
loadErrorTitle: string;
|
|
752
|
+
/** Label for retry after a failed load. */
|
|
753
|
+
loadErrorRetry: string;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
interface CardsQuickViewWidgetLabels extends CardsQuickViewTileLabels {
|
|
757
|
+
/**
|
|
758
|
+
* Tile heading for a month, e.g. "Card spend · October". `month` is 0 for
|
|
759
|
+
* January. Before the browser's month is known the tile shows `title`.
|
|
760
|
+
*/
|
|
761
|
+
titleForMonth: (month: number) => string;
|
|
762
|
+
/**
|
|
763
|
+
* The heading as a screen reader hears it, at the start of the accessible
|
|
764
|
+
* name, e.g. "Card spend in October". Override it alongside
|
|
765
|
+
* `titleForMonth`.
|
|
766
|
+
*/
|
|
767
|
+
accessibleTitleForMonth: (month: number) => string;
|
|
768
|
+
/** Call to action that opens the cards list. */
|
|
769
|
+
viewCards: string;
|
|
770
|
+
/** Line under the total when the token can see no card at all. */
|
|
771
|
+
noCardsYet: string;
|
|
772
|
+
/** Line under the total: the cards that are not closed, e.g. "5 cards". */
|
|
773
|
+
cardCount: (count: number) => string;
|
|
774
|
+
/**
|
|
775
|
+
* A negative total as a screen reader hears it, e.g. "negative $312.75".
|
|
776
|
+
* Screen readers skip the accounting parentheses the tile shows.
|
|
777
|
+
*/
|
|
778
|
+
negativeAmount: (magnitude: string) => string;
|
|
779
|
+
/**
|
|
780
|
+
* The tile's one-sentence accessible name, e.g. "Card spend in October,
|
|
781
|
+
* $3,186.52, 5 cards. View cards."
|
|
782
|
+
*/
|
|
783
|
+
accessibleName: (parts: {
|
|
784
|
+
title: string;
|
|
785
|
+
value: string;
|
|
786
|
+
detail: string;
|
|
787
|
+
action: string;
|
|
788
|
+
}) => string;
|
|
789
|
+
}
|
|
790
|
+
|
|
742
791
|
/** Every tile's copy, keyed by `QuickViewWidget` `type`. */
|
|
743
792
|
interface QuickViewWidgetLabels {
|
|
744
793
|
accounts: AccountsQuickViewWidgetLabels;
|
|
745
794
|
invoices: InvoicesQuickViewWidgetLabels;
|
|
746
795
|
bills: BillsQuickViewWidgetLabels;
|
|
796
|
+
cards: CardsQuickViewWidgetLabels;
|
|
747
797
|
}
|
|
748
798
|
/**
|
|
749
799
|
* Overrides for `QuickViewWidget`'s `labels` prop. Each group is merged with
|
|
@@ -753,6 +803,7 @@ interface QuickViewWidgetLabelOverrides {
|
|
|
753
803
|
accounts?: Partial<AccountsQuickViewWidgetLabels>;
|
|
754
804
|
invoices?: Partial<InvoicesQuickViewWidgetLabels>;
|
|
755
805
|
bills?: Partial<BillsQuickViewWidgetLabels>;
|
|
806
|
+
cards?: Partial<CardsQuickViewWidgetLabels>;
|
|
756
807
|
}
|
|
757
808
|
declare const QUICK_VIEW_WIDGET_LABELS_EN: QuickViewWidgetLabels;
|
|
758
809
|
|
|
@@ -760,6 +811,7 @@ declare const QuickViewType: {
|
|
|
760
811
|
readonly Accounts: "accounts";
|
|
761
812
|
readonly Invoices: "invoices";
|
|
762
813
|
readonly Bills: "bills";
|
|
814
|
+
readonly Cards: "cards";
|
|
763
815
|
};
|
|
764
816
|
type QuickViewType = (typeof QuickViewType)[keyof typeof QuickViewType];
|
|
765
817
|
interface QuickViewWidgetClickHandlers {
|
|
@@ -790,6 +842,11 @@ interface QuickViewWidgetClickHandlers {
|
|
|
790
842
|
* bill". Without it that tile is static.
|
|
791
843
|
*/
|
|
792
844
|
onAddBillClick?: () => void;
|
|
845
|
+
/**
|
|
846
|
+
* `type="cards"`: called when the tile is clicked. Wire it to the host's
|
|
847
|
+
* cards list. Without it the tile is static.
|
|
848
|
+
*/
|
|
849
|
+
onViewCardsClick?: () => void;
|
|
793
850
|
}
|
|
794
851
|
/**
|
|
795
852
|
* Which click handlers each tile calls. Every other handler is ignored for that
|
|
@@ -799,6 +856,7 @@ declare const QUICK_VIEW_CLICK_HANDLERS: {
|
|
|
799
856
|
readonly accounts: readonly ["onViewAccountsClick"];
|
|
800
857
|
readonly invoices: readonly ["onViewInvoicesClick", "onCreateInvoiceClick"];
|
|
801
858
|
readonly bills: readonly ["onViewBillsClick", "onAddBillClick"];
|
|
859
|
+
readonly cards: readonly ["onViewCardsClick"];
|
|
802
860
|
};
|
|
803
861
|
interface QuickViewWidgetProps extends WidgetProviderProps, QuickViewWidgetClickHandlers {
|
|
804
862
|
/** Which summary the tile shows. */
|
|
@@ -826,10 +884,12 @@ interface QuickViewWidgetProps extends WidgetProviderProps, QuickViewWidgetClick
|
|
|
826
884
|
* - `bills`: the total due on open bills due in the next 30 days, and how
|
|
827
885
|
* many are overdue or awaiting approval. Renders nothing without
|
|
828
886
|
* `payable:read:org`.
|
|
887
|
+
* - `cards`: this month's spend across every card the token can see, and how
|
|
888
|
+
* many cards are open. Renders nothing without `debit_card:read:org`.
|
|
829
889
|
*
|
|
830
890
|
* Each type calls only its own click handlers; see `QUICK_VIEW_CLICK_HANDLERS`.
|
|
831
891
|
*/
|
|
832
|
-
declare function QuickViewWidget({ type, labels, onViewAccountsClick, onViewInvoicesClick, onCreateInvoiceClick, onViewBillsClick, onAddBillClick, className, style, ...widgetProviderProps }: QuickViewWidgetProps): React.JSX.Element | null;
|
|
892
|
+
declare function QuickViewWidget({ type, labels, onViewAccountsClick, onViewInvoicesClick, onCreateInvoiceClick, onViewBillsClick, onAddBillClick, onViewCardsClick, className, style, ...widgetProviderProps }: QuickViewWidgetProps): React.JSX.Element | null;
|
|
833
893
|
|
|
834
894
|
export { QUICK_VIEW_CLICK_HANDLERS, QUICK_VIEW_WIDGET_LABELS_EN, QuickViewType, QuickViewWidget };
|
|
835
|
-
export type { AccountsQuickViewWidgetLabels, BillsQuickViewWidgetLabels, InvoicesQuickViewWidgetLabels, QuickViewWidgetClickHandlers, QuickViewWidgetLabelOverrides, QuickViewWidgetLabels, QuickViewWidgetProps };
|
|
895
|
+
export type { AccountsQuickViewWidgetLabels, BillsQuickViewWidgetLabels, CardsQuickViewWidgetLabels, InvoicesQuickViewWidgetLabels, QuickViewWidgetClickHandlers, QuickViewWidgetLabelOverrides, QuickViewWidgetLabels, QuickViewWidgetProps };
|
|
@@ -739,11 +739,61 @@ interface BillsQuickViewWidgetLabels extends BillsQuickViewTileLabels {
|
|
|
739
739
|
}) => string;
|
|
740
740
|
}
|
|
741
741
|
|
|
742
|
+
interface CardsQuickViewTileLabels {
|
|
743
|
+
/**
|
|
744
|
+
* Tile heading above the total, used when the caller passes no `title`,
|
|
745
|
+
* as before the browser's month is known.
|
|
746
|
+
*/
|
|
747
|
+
title: string;
|
|
748
|
+
/** Screen-reader only: names the wait while card spend loads. */
|
|
749
|
+
loadingLabel: string;
|
|
750
|
+
/** Shown when the card spend request failed. */
|
|
751
|
+
loadErrorTitle: string;
|
|
752
|
+
/** Label for retry after a failed load. */
|
|
753
|
+
loadErrorRetry: string;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
interface CardsQuickViewWidgetLabels extends CardsQuickViewTileLabels {
|
|
757
|
+
/**
|
|
758
|
+
* Tile heading for a month, e.g. "Card spend · October". `month` is 0 for
|
|
759
|
+
* January. Before the browser's month is known the tile shows `title`.
|
|
760
|
+
*/
|
|
761
|
+
titleForMonth: (month: number) => string;
|
|
762
|
+
/**
|
|
763
|
+
* The heading as a screen reader hears it, at the start of the accessible
|
|
764
|
+
* name, e.g. "Card spend in October". Override it alongside
|
|
765
|
+
* `titleForMonth`.
|
|
766
|
+
*/
|
|
767
|
+
accessibleTitleForMonth: (month: number) => string;
|
|
768
|
+
/** Call to action that opens the cards list. */
|
|
769
|
+
viewCards: string;
|
|
770
|
+
/** Line under the total when the token can see no card at all. */
|
|
771
|
+
noCardsYet: string;
|
|
772
|
+
/** Line under the total: the cards that are not closed, e.g. "5 cards". */
|
|
773
|
+
cardCount: (count: number) => string;
|
|
774
|
+
/**
|
|
775
|
+
* A negative total as a screen reader hears it, e.g. "negative $312.75".
|
|
776
|
+
* Screen readers skip the accounting parentheses the tile shows.
|
|
777
|
+
*/
|
|
778
|
+
negativeAmount: (magnitude: string) => string;
|
|
779
|
+
/**
|
|
780
|
+
* The tile's one-sentence accessible name, e.g. "Card spend in October,
|
|
781
|
+
* $3,186.52, 5 cards. View cards."
|
|
782
|
+
*/
|
|
783
|
+
accessibleName: (parts: {
|
|
784
|
+
title: string;
|
|
785
|
+
value: string;
|
|
786
|
+
detail: string;
|
|
787
|
+
action: string;
|
|
788
|
+
}) => string;
|
|
789
|
+
}
|
|
790
|
+
|
|
742
791
|
/** Every tile's copy, keyed by `QuickViewWidget` `type`. */
|
|
743
792
|
interface QuickViewWidgetLabels {
|
|
744
793
|
accounts: AccountsQuickViewWidgetLabels;
|
|
745
794
|
invoices: InvoicesQuickViewWidgetLabels;
|
|
746
795
|
bills: BillsQuickViewWidgetLabels;
|
|
796
|
+
cards: CardsQuickViewWidgetLabels;
|
|
747
797
|
}
|
|
748
798
|
/**
|
|
749
799
|
* Overrides for `QuickViewWidget`'s `labels` prop. Each group is merged with
|
|
@@ -753,6 +803,7 @@ interface QuickViewWidgetLabelOverrides {
|
|
|
753
803
|
accounts?: Partial<AccountsQuickViewWidgetLabels>;
|
|
754
804
|
invoices?: Partial<InvoicesQuickViewWidgetLabels>;
|
|
755
805
|
bills?: Partial<BillsQuickViewWidgetLabels>;
|
|
806
|
+
cards?: Partial<CardsQuickViewWidgetLabels>;
|
|
756
807
|
}
|
|
757
808
|
declare const QUICK_VIEW_WIDGET_LABELS_EN: QuickViewWidgetLabels;
|
|
758
809
|
|
|
@@ -760,6 +811,7 @@ declare const QuickViewType: {
|
|
|
760
811
|
readonly Accounts: "accounts";
|
|
761
812
|
readonly Invoices: "invoices";
|
|
762
813
|
readonly Bills: "bills";
|
|
814
|
+
readonly Cards: "cards";
|
|
763
815
|
};
|
|
764
816
|
type QuickViewType = (typeof QuickViewType)[keyof typeof QuickViewType];
|
|
765
817
|
interface QuickViewWidgetClickHandlers {
|
|
@@ -790,6 +842,11 @@ interface QuickViewWidgetClickHandlers {
|
|
|
790
842
|
* bill". Without it that tile is static.
|
|
791
843
|
*/
|
|
792
844
|
onAddBillClick?: () => void;
|
|
845
|
+
/**
|
|
846
|
+
* `type="cards"`: called when the tile is clicked. Wire it to the host's
|
|
847
|
+
* cards list. Without it the tile is static.
|
|
848
|
+
*/
|
|
849
|
+
onViewCardsClick?: () => void;
|
|
793
850
|
}
|
|
794
851
|
/**
|
|
795
852
|
* Which click handlers each tile calls. Every other handler is ignored for that
|
|
@@ -799,6 +856,7 @@ declare const QUICK_VIEW_CLICK_HANDLERS: {
|
|
|
799
856
|
readonly accounts: readonly ["onViewAccountsClick"];
|
|
800
857
|
readonly invoices: readonly ["onViewInvoicesClick", "onCreateInvoiceClick"];
|
|
801
858
|
readonly bills: readonly ["onViewBillsClick", "onAddBillClick"];
|
|
859
|
+
readonly cards: readonly ["onViewCardsClick"];
|
|
802
860
|
};
|
|
803
861
|
interface QuickViewWidgetProps extends WidgetProviderProps, QuickViewWidgetClickHandlers {
|
|
804
862
|
/** Which summary the tile shows. */
|
|
@@ -826,10 +884,12 @@ interface QuickViewWidgetProps extends WidgetProviderProps, QuickViewWidgetClick
|
|
|
826
884
|
* - `bills`: the total due on open bills due in the next 30 days, and how
|
|
827
885
|
* many are overdue or awaiting approval. Renders nothing without
|
|
828
886
|
* `payable:read:org`.
|
|
887
|
+
* - `cards`: this month's spend across every card the token can see, and how
|
|
888
|
+
* many cards are open. Renders nothing without `debit_card:read:org`.
|
|
829
889
|
*
|
|
830
890
|
* Each type calls only its own click handlers; see `QUICK_VIEW_CLICK_HANDLERS`.
|
|
831
891
|
*/
|
|
832
|
-
declare function QuickViewWidget({ type, labels, onViewAccountsClick, onViewInvoicesClick, onCreateInvoiceClick, onViewBillsClick, onAddBillClick, className, style, ...widgetProviderProps }: QuickViewWidgetProps): React.JSX.Element | null;
|
|
892
|
+
declare function QuickViewWidget({ type, labels, onViewAccountsClick, onViewInvoicesClick, onCreateInvoiceClick, onViewBillsClick, onAddBillClick, onViewCardsClick, className, style, ...widgetProviderProps }: QuickViewWidgetProps): React.JSX.Element | null;
|
|
833
893
|
|
|
834
894
|
interface CheckAmountAndDetailScreenLabels {
|
|
835
895
|
title: string;
|
|
@@ -942,4 +1002,4 @@ interface RemoteCheckCaptureWidgetProps extends WidgetProviderProps {
|
|
|
942
1002
|
declare function RemoteCheckCaptureWidget({ baseUrl, widgetToken, organizationId, configClient, gatewayRouting, linkComponent, uiFramework, errorFallback, onError, analytics, disclosuresAcceptance, providerLabels, labels, onDepositComplete, }: RemoteCheckCaptureWidgetProps): React.JSX.Element;
|
|
943
1003
|
|
|
944
1004
|
export { QUICK_VIEW_CLICK_HANDLERS, QUICK_VIEW_WIDGET_LABELS_EN, QuickViewType, QuickViewWidget, RemoteCheckCaptureWidget };
|
|
945
|
-
export type { AccountsQuickViewWidgetLabels, BillsQuickViewWidgetLabels, InvoicesQuickViewWidgetLabels, QuickViewWidgetClickHandlers, QuickViewWidgetLabelOverrides, QuickViewWidgetLabels, QuickViewWidgetProps, RemoteCheckCaptureWidgetProps };
|
|
1005
|
+
export type { AccountsQuickViewWidgetLabels, BillsQuickViewWidgetLabels, CardsQuickViewWidgetLabels, InvoicesQuickViewWidgetLabels, QuickViewWidgetClickHandlers, QuickViewWidgetLabelOverrides, QuickViewWidgetLabels, QuickViewWidgetProps, RemoteCheckCaptureWidgetProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useCardSpendReads } from "./index2.js";
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
"use client";
|
|
4
|
+
"use client";
|
|
5
|
+
import { getDebitCardTransactions as e } from "../../../../shared/data-access/dist/lib/rest/sdk.gen.js";
|
|
6
|
+
import { getDebitCardTransactionsQueryKey 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 { useEmbedApi as r } from "../../../../shared/data-access/dist/lib/EmbedApiContext.js";
|
|
9
|
+
import { organizationHeaders as i } from "../../../../shared/data-access/dist/lib/organizationHeaders.js";
|
|
10
|
+
import { useAllDebitCardsQuery as a } from "../../../../shared/data-access/dist/lib/debit-card/useAllDebitCardsQuery.js";
|
|
11
|
+
import "../../../../shared/data-access/dist/index.js";
|
|
12
|
+
import { useQueries as o } from "@tanstack/react-query";
|
|
13
|
+
// ../../libs/tesouro-embedded-components-react/quick-view-widget/cards/data-access/dist/index2.js
|
|
14
|
+
var s = 100, c = {
|
|
15
|
+
staleTime: 6e4,
|
|
16
|
+
refetchOnWindowFocus: !0
|
|
17
|
+
}, l = {
|
|
18
|
+
staleTime: 3e5,
|
|
19
|
+
refetchOnWindowFocus: !1
|
|
20
|
+
}, u = {
|
|
21
|
+
retry: 2,
|
|
22
|
+
retryDelay: 300
|
|
23
|
+
};
|
|
24
|
+
function d(e) {
|
|
25
|
+
return {
|
|
26
|
+
transactions: e.every((e) => e.data !== void 0) ? e.flatMap((e) => e.data ?? []) : void 0,
|
|
27
|
+
isLoading: e.some((e) => e.isLoading),
|
|
28
|
+
isFetching: e.some((e) => e.isFetching),
|
|
29
|
+
isError: e.some((e) => e.isError),
|
|
30
|
+
refetch: () => Promise.all(e.map((e) => e.refetch()))
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
async function f(e) {
|
|
34
|
+
let t = [], n = /* @__PURE__ */ new Set(), r;
|
|
35
|
+
do {
|
|
36
|
+
let i = await e(r);
|
|
37
|
+
t.push(...i.data), r && n.add(r), r = i.nextPaginationToken ?? void 0;
|
|
38
|
+
} while (r && !n.has(r));
|
|
39
|
+
return t;
|
|
40
|
+
}
|
|
41
|
+
function p(e) {
|
|
42
|
+
return e.data !== void 0 && !e.isPlaceholderData && !e.hasNextPage && !e.isFetchingNextPage;
|
|
43
|
+
}
|
|
44
|
+
function m(e) {
|
|
45
|
+
return e.data !== void 0 && !e.isError && !p(e);
|
|
46
|
+
}
|
|
47
|
+
function h({ enabled: h = !0 } = {}) {
|
|
48
|
+
let { client: g, organizationId: _, widgetToken: v, authEpoch: y, organizationStatus: b } = r(), x = a({
|
|
49
|
+
enabled: h,
|
|
50
|
+
...c,
|
|
51
|
+
...u
|
|
52
|
+
}), S = p(x) ? x.data?.data : void 0, C = i(_), w = o({
|
|
53
|
+
queries: (S ?? []).map((r) => ({
|
|
54
|
+
...n({
|
|
55
|
+
queryKey: [...t({
|
|
56
|
+
client: g,
|
|
57
|
+
headers: C,
|
|
58
|
+
path: { id: r.id },
|
|
59
|
+
query: { limit: s }
|
|
60
|
+
}), "all-pages"],
|
|
61
|
+
queryFn: ({ signal: t }) => f(async (n) => {
|
|
62
|
+
let { data: i } = await e({
|
|
63
|
+
client: g,
|
|
64
|
+
headers: C,
|
|
65
|
+
path: { id: r.id },
|
|
66
|
+
query: {
|
|
67
|
+
limit: s,
|
|
68
|
+
...n ? { paginationToken: n } : {}
|
|
69
|
+
},
|
|
70
|
+
signal: t,
|
|
71
|
+
throwOnError: !0
|
|
72
|
+
});
|
|
73
|
+
return i;
|
|
74
|
+
})
|
|
75
|
+
}, {
|
|
76
|
+
authEpoch: y,
|
|
77
|
+
organizationStatus: b
|
|
78
|
+
}),
|
|
79
|
+
...l,
|
|
80
|
+
...u,
|
|
81
|
+
enabled: !!(_ && v) && h
|
|
82
|
+
})),
|
|
83
|
+
combine: d
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
data: S && w.transactions ? {
|
|
87
|
+
cards: S,
|
|
88
|
+
transactions: w.transactions
|
|
89
|
+
} : void 0,
|
|
90
|
+
isLoading: x.isLoading || m(x) || w.isLoading,
|
|
91
|
+
isFetching: x.isFetching || w.isFetching,
|
|
92
|
+
isError: x.isError || w.isError,
|
|
93
|
+
refetch: async () => {
|
|
94
|
+
await x.refetch(), await w.refetch();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export { p as isCardListComplete, m as isCardListPaging, f as readAllPages, h as useCardSpendReads };
|
package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CARDS_QUICK_VIEW_WIDGET_LABELS_EN as e } from "./lib/CardsQuickViewWidget/labels.js";
|
|
2
|
+
import { CardsQuickViewWidget as t } from "./lib/CardsQuickViewWidget/CardsQuickViewWidgetFeature.js";
|
|
3
|
+
export { e as CARDS_QUICK_VIEW_WIDGET_LABELS_EN, t as CardsQuickViewWidget };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
"use client";
|
|
4
|
+
"use client";
|
|
5
|
+
import { amountOutputToMajorUnits as e } from "../../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
6
|
+
import { formatAccountingAmount as t } from "../../../../../../shared/util/dist/lib/formatAccountingAmount.js";
|
|
7
|
+
import "../../../../../../shared/util/dist/index.js";
|
|
8
|
+
import { OrganizationStatus as n, isOrganizationOnItsWay as r } from "../../../../../../shared/data-access/dist/lib/organizationStatus.js";
|
|
9
|
+
import { useEmbedApi as i } from "../../../../../../shared/data-access/dist/lib/EmbedApiContext.js";
|
|
10
|
+
import { Scope as a } from "../../../../../../shared/data-access/dist/lib/scopes.js";
|
|
11
|
+
import "../../../../../../shared/data-access/dist/index.js";
|
|
12
|
+
import { useAnalyticsTrack as o } from "../../../../../../shared/feature/dist/lib/analytics/hooks.js";
|
|
13
|
+
import { WidgetProvider as s } from "../../../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
|
|
14
|
+
import { useRefetchWidget as c, useWidgetConfig as l, useWidgetError as u, useWidgetLoading as d } from "../../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
15
|
+
import "../../../../../../shared/feature/dist/index.js";
|
|
16
|
+
import { CardsQuickViewTile as f } from "../../../../ui/dist/index3.js";
|
|
17
|
+
import "../../../../ui/dist/index.js";
|
|
18
|
+
import { CARDS_QUICK_VIEW_WIDGET_LABELS_EN as p } from "./labels.js";
|
|
19
|
+
import { CardsQuickViewWidgetAnalyticsEvent as m, WIDGET_NAME as h } from "../analytics/events.js";
|
|
20
|
+
import { cardsQuickViewWidgetTestIds as g } from "./testIds.js";
|
|
21
|
+
import { useCardSpendSummary as _ } from "./useCardSpendSummary.js";
|
|
22
|
+
import { useCallback as v, useEffect as y } from "react";
|
|
23
|
+
import { jsx as b } from "react/jsx-runtime";
|
|
24
|
+
// ../../libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/CardsQuickViewWidgetFeature.js
|
|
25
|
+
var x = (n) => t(e({
|
|
26
|
+
value: n,
|
|
27
|
+
currencyCode: "USD"
|
|
28
|
+
}), "USD"), S = (e) => Number(e.slice(5, 7)) - 1;
|
|
29
|
+
function C({ labels: e, onViewCardsClick: t, className: s, style: h }) {
|
|
30
|
+
let C = {
|
|
31
|
+
...p,
|
|
32
|
+
...e
|
|
33
|
+
}, w = o();
|
|
34
|
+
y(() => {
|
|
35
|
+
w(m.Mounted);
|
|
36
|
+
}, [w]);
|
|
37
|
+
let { initResponse: T } = l(), E = d(), D = u(), O = c(), { organizationId: k, organizationStatus: A } = i(), j = r(A), M = T?.scopes?.includes(a.DebitCardReadOrg) ?? !1, { data: N, today: P, isLoading: F, isError: I, refetch: L } = _({ enabled: M }), R = E && !T || j && N === void 0 || F, z = (!!D || I) && N === void 0, B = v(() => {
|
|
38
|
+
O(), M && k && L();
|
|
39
|
+
}, [
|
|
40
|
+
O,
|
|
41
|
+
L,
|
|
42
|
+
M,
|
|
43
|
+
k
|
|
44
|
+
]);
|
|
45
|
+
if (T && (!M || A === n.None)) return null;
|
|
46
|
+
let V = P === void 0 ? void 0 : S(P), H = N ? x(N.spendAmount) : void 0, U = H?.text ?? "", W = N ? N.hasCards ? C.cardCount(N.cardCount) : C.noCardsYet : void 0;
|
|
47
|
+
return /* @__PURE__ */ b(f, {
|
|
48
|
+
title: V === void 0 ? void 0 : C.titleForMonth(V),
|
|
49
|
+
value: U,
|
|
50
|
+
subtext: W,
|
|
51
|
+
linkText: C.viewCards,
|
|
52
|
+
onClick: t,
|
|
53
|
+
ariaLabel: N && W && V !== void 0 ? C.accessibleName({
|
|
54
|
+
title: C.accessibleTitleForMonth(V),
|
|
55
|
+
value: H?.isNegative ? C.negativeAmount(H.magnitude) : U,
|
|
56
|
+
detail: W,
|
|
57
|
+
action: C.viewCards
|
|
58
|
+
}) : void 0,
|
|
59
|
+
isLoading: R,
|
|
60
|
+
isError: z,
|
|
61
|
+
onRetry: z ? B : void 0,
|
|
62
|
+
labels: C,
|
|
63
|
+
testIds: g,
|
|
64
|
+
className: s,
|
|
65
|
+
style: h
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function w({ labels: e, onViewCardsClick: t, className: n, style: r, ...i }) {
|
|
69
|
+
return /* @__PURE__ */ b(s, {
|
|
70
|
+
...i,
|
|
71
|
+
widgetName: h,
|
|
72
|
+
children: /* @__PURE__ */ b(C, {
|
|
73
|
+
labels: e,
|
|
74
|
+
onViewCardsClick: t,
|
|
75
|
+
className: n,
|
|
76
|
+
style: r
|
|
77
|
+
})
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export { w as CardsQuickViewWidget, C as CardsQuickViewWidgetWithContext };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CARDS_QUICK_VIEW_TILE_LABELS_EN as e } from "../../../../ui/dist/index2.js";
|
|
2
|
+
import "../../../../ui/dist/index.js";
|
|
3
|
+
// ../../libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/labels.js
|
|
4
|
+
var t = (e) => e.toLocaleString("en-US"), n = [
|
|
5
|
+
"January",
|
|
6
|
+
"February",
|
|
7
|
+
"March",
|
|
8
|
+
"April",
|
|
9
|
+
"May",
|
|
10
|
+
"June",
|
|
11
|
+
"July",
|
|
12
|
+
"August",
|
|
13
|
+
"September",
|
|
14
|
+
"October",
|
|
15
|
+
"November",
|
|
16
|
+
"December"
|
|
17
|
+
], r = {
|
|
18
|
+
...e,
|
|
19
|
+
titleForMonth: (e) => `Card spend · ${n[e]}`,
|
|
20
|
+
accessibleTitleForMonth: (e) => `Card spend in ${n[e]}`,
|
|
21
|
+
viewCards: "View cards",
|
|
22
|
+
noCardsYet: "No cards yet",
|
|
23
|
+
cardCount: (e) => `${t(e)} ${e === 1 ? "card" : "cards"}`,
|
|
24
|
+
negativeAmount: (e) => `negative ${e}`,
|
|
25
|
+
accessibleName: ({ title: e, value: t, detail: n, action: r }) => `${e}, ${t}, ${n}. ${r}.`
|
|
26
|
+
};
|
|
27
|
+
export { r as CARDS_QUICK_VIEW_WIDGET_LABELS_EN };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// ../../libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/summarizeCardSpend.js
|
|
2
|
+
var e = ["PENDING", "SETTLED"], t = (e) => {
|
|
3
|
+
let t = new Date(e);
|
|
4
|
+
return `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, "0")}`;
|
|
5
|
+
}, n = (e) => e.settledAmount ?? e.authorizedAmount;
|
|
6
|
+
function r({ cards: r, transactions: i }, a) {
|
|
7
|
+
let o = a.slice(0, 7), s = i.filter((r) => e.includes(r.state) && n(r).currencyCode === "USD" && t(r.authorizedAt) === o).reduce((e, t) => {
|
|
8
|
+
let r = Number(n(t).value);
|
|
9
|
+
return t.type === "REFUND" ? e - r : e + r;
|
|
10
|
+
}, 0);
|
|
11
|
+
return {
|
|
12
|
+
hasCards: r.length > 0,
|
|
13
|
+
cardCount: r.filter((e) => e.cardStatus !== "CLOSED").length,
|
|
14
|
+
spendAmount: s
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export { r as summarizeCardSpend };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// ../../libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/testIds.js
|
|
2
|
+
var e = {
|
|
3
|
+
tile: "cards-quick-view-widget-tile",
|
|
4
|
+
skeleton: "cards-quick-view-widget-skeleton",
|
|
5
|
+
error: "cards-quick-view-widget-error"
|
|
6
|
+
};
|
|
7
|
+
export { e as cardsQuickViewWidgetTestIds };
|
|
@@ -0,0 +1,29 @@
|
|
|
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 "../../../../../../shared/data-access/dist/index.js";
|
|
7
|
+
import { useLocalCalendarDay as t } from "../../../../../../shared/feature/dist/lib/calendar/useLocalCalendarDay.js";
|
|
8
|
+
import "../../../../../../shared/feature/dist/index.js";
|
|
9
|
+
import { summarizeCardSpend as n } from "./summarizeCardSpend.js";
|
|
10
|
+
import { useCardSpendReads as r } from "../../../../data-access/dist/index2.js";
|
|
11
|
+
import "../../../../data-access/dist/index.js";
|
|
12
|
+
import { useMemo as i, useState as a } from "react";
|
|
13
|
+
// ../../libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/useCardSpendSummary.js
|
|
14
|
+
var o = (e, t) => Object.keys(e).every((n) => e[n] === t[n]);
|
|
15
|
+
function s({ enabled: s } = {}) {
|
|
16
|
+
let c = t(), l = r({ enabled: s }), { organizationId: u, authEpoch: d } = e(), f = i(() => l.data && c ? n(l.data, c) : void 0, [l.data, c]), [p, m] = a(), h = c?.slice(0, 7), g = p !== void 0 && p.organizationId === u && p.authEpoch === d && p.month === h, _ = f !== void 0 && (!l.isFetching && !l.isError || !g), v = g ? p.summary : f;
|
|
17
|
+
return _ && !(g && o(p.summary, f)) && (m({
|
|
18
|
+
organizationId: u,
|
|
19
|
+
authEpoch: d,
|
|
20
|
+
month: h,
|
|
21
|
+
summary: f
|
|
22
|
+
}), v = f), {
|
|
23
|
+
...l,
|
|
24
|
+
data: v,
|
|
25
|
+
today: c,
|
|
26
|
+
isLoading: (l.isLoading || c === void 0) && !v
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export { s as useCardSpendSummary };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { QUICK_VIEW_WIDGET_NAME as e } from "../../../../../shared/util/dist/lib/widgetName.js";
|
|
2
|
+
// ../../libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/analytics/events.js
|
|
3
|
+
var t = `${e}.cards_quick_view_widget`, n = { Mounted: `${t}.mounted` };
|
|
4
|
+
export { n as CardsQuickViewWidgetAnalyticsEvent, t as WIDGET_NAME };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// ../../libs/tesouro-embedded-components-react/quick-view-widget/cards/ui/dist/index2.js
|
|
2
|
+
var e = {
|
|
3
|
+
title: "Card spend · this month",
|
|
4
|
+
loadingLabel: "Loading card spend",
|
|
5
|
+
loadErrorTitle: "Couldn't load card spend",
|
|
6
|
+
loadErrorRetry: "Try again"
|
|
7
|
+
};
|
|
8
|
+
export { e as CARDS_QUICK_VIEW_TILE_LABELS_EN };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { QuickViewTile as e } from "../../../../shared/quick-view/ui/dist/index3.js";
|
|
2
|
+
import "../../../../shared/quick-view/ui/dist/index.js";
|
|
3
|
+
import { CARDS_QUICK_VIEW_TILE_LABELS_EN as t } from "./index2.js";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
5
|
+
// ../../libs/tesouro-embedded-components-react/quick-view-widget/cards/ui/dist/index3.js
|
|
6
|
+
function r({ title: r, value: i, subtext: a, linkText: o, onClick: s, ariaLabel: c, isLoading: l, isError: u, onRetry: d, labels: f, testIds: p, className: m, style: h }) {
|
|
7
|
+
let g = {
|
|
8
|
+
...t,
|
|
9
|
+
...f
|
|
10
|
+
};
|
|
11
|
+
return /* @__PURE__ */ n(e, {
|
|
12
|
+
title: r ?? g.title,
|
|
13
|
+
value: i,
|
|
14
|
+
subtext: a,
|
|
15
|
+
linkText: o,
|
|
16
|
+
onClick: s,
|
|
17
|
+
ariaLabel: c,
|
|
18
|
+
isLoading: l,
|
|
19
|
+
isError: u,
|
|
20
|
+
onRetry: d,
|
|
21
|
+
labels: {
|
|
22
|
+
loadingLabel: g.loadingLabel,
|
|
23
|
+
loadErrorTitle: g.loadErrorTitle,
|
|
24
|
+
loadErrorRetry: g.loadErrorRetry
|
|
25
|
+
},
|
|
26
|
+
testIds: p,
|
|
27
|
+
className: m,
|
|
28
|
+
style: h
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export { r as CardsQuickViewTile };
|