@justifi/webcomponents 4.7.6 → 4.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Business-3c0aa22c.js +82 -0
- package/dist/cjs/BusinessFormEventTypes-863f48e9.js +42 -0
- package/dist/cjs/{Payout-7821eb61.js → Payout-44b49b2d.js} +2 -1
- package/dist/cjs/additional-questions-details_5.cjs.entry.js +4 -4
- package/dist/cjs/{business-form-schema-a2b87e77.js → business-form-schema-37e5381d.js} +17 -17
- package/dist/cjs/{form-control-datepart_2.cjs.entry.js → form-control-datepart_3.cjs.entry.js} +45 -2
- package/dist/cjs/{form-control-number_3.cjs.entry.js → form-control-select_2.cjs.entry.js} +0 -43
- package/dist/cjs/form-input-masks-e3bf2614.js +9 -0
- package/dist/cjs/{index.esm-c08c2adc.js → index.esm-d25bd7bf.js} +0 -259
- package/dist/cjs/{justifi-additional-questions_6.cjs.entry.js → justifi-additional-questions_5.cjs.entry.js} +10 -280
- package/dist/cjs/justifi-billing-form_2.cjs.entry.js +1 -1
- package/dist/cjs/justifi-business-details.cjs.entry.js +5 -5
- package/dist/cjs/justifi-business-form-stepped.cjs.entry.js +46 -52
- package/dist/cjs/justifi-business-form.cjs.entry.js +31 -35
- package/dist/cjs/justifi-business-list.cjs.entry.js +3 -50
- package/dist/cjs/justifi-business-owners.cjs.entry.js +78 -0
- package/dist/cjs/justifi-details.cjs.entry.js +1 -1
- package/dist/cjs/justifi-gross-payment-chart.cjs.entry.js +2 -2
- package/dist/cjs/justifi-payment-balance-transactions.cjs.entry.js +1 -1
- package/dist/cjs/justifi-payment-details.cjs.entry.js +43 -42
- package/dist/cjs/justifi-payment-form.cjs.entry.js +1 -1
- package/dist/cjs/justifi-payment-method-form.cjs.entry.js +6 -4
- package/dist/cjs/justifi-payments-list.cjs.entry.js +46 -90
- package/dist/cjs/justifi-payout-details.cjs.entry.js +47 -45
- package/dist/cjs/justifi-payouts-list.cjs.entry.js +46 -112
- package/dist/cjs/justifi-proceeds-list.cjs.entry.js +1 -1
- package/dist/cjs/justifi-refund-form.cjs.entry.js +2 -2
- package/dist/cjs/justifi-subaccount-details.cjs.entry.js +2 -2
- package/dist/cjs/justifi-subaccounts-list.cjs.entry.js +1 -1
- package/dist/cjs/justifi-table_2.cjs.entry.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/payment-details-core.cjs.entry.js +52 -0
- package/dist/cjs/payment.service-605896dc.js +20 -0
- package/dist/cjs/payments-list-core.cjs.entry.js +98 -0
- package/dist/cjs/payout-details-core.cjs.entry.js +52 -0
- package/dist/cjs/payout.service-b39f2739.js +21 -0
- package/dist/cjs/payouts-list-core.cjs.entry.js +121 -0
- package/dist/cjs/subaccount-account-details_4.cjs.entry.js +1 -1
- package/dist/cjs/subaccount-bank-details.cjs.entry.js +1 -1
- package/dist/cjs/subaccount-terms-details.cjs.entry.js +1 -1
- package/dist/cjs/{utils-99c086ee.js → utils-d126d17c.js} +4 -4
- package/dist/cjs/utils-f5d82f21.js +10 -0
- package/dist/cjs/webcomponents.cjs.js +1 -1
- package/dist/collection/api/Business.js +32 -3
- package/dist/collection/api/Payment.js +2 -1
- package/dist/collection/api/mockData/MockPayments.js +25 -0
- package/dist/collection/api/services/payment.service.js +13 -0
- package/dist/collection/api/services/payout.service.js +14 -0
- package/dist/collection/api/services/utils.js +6 -0
- package/dist/collection/collection-manifest.json +4 -0
- package/dist/collection/components/business-details/additional-questions-details/additional-questions-details.js +8 -8
- package/dist/collection/components/business-details/business-details.js +3 -3
- package/dist/collection/components/business-details/legal-address-details/legal-address-details.js +4 -4
- package/dist/collection/components/business-form/BusinessFormEventTypes.js +6 -0
- package/dist/collection/components/business-form/business-address/business-address-form-schema.js +1 -1
- package/dist/collection/components/business-form/business-form-schema.js +16 -16
- package/dist/collection/components/business-form/business-form-stepped.js +77 -50
- package/dist/collection/components/business-form/business-form.js +62 -33
- package/dist/collection/components/business-form/business-generic-info/business-generic-info.js +7 -3
- package/dist/collection/components/business-form/business-owners/business-owners.js +6 -21
- package/dist/collection/components/business-form/business-representative/business-representative.js +1 -1
- package/dist/collection/components/business-form/helpers.js +21 -20
- package/dist/collection/components/business-form/legal-address-form/legal-address-form-schema.js +1 -1
- package/dist/collection/components/business-form/legal-address-form/legal-address-form.js +3 -3
- package/dist/collection/components/business-form/test/business-form.spec.js +5 -14
- package/dist/collection/components/details/utils.js +2 -2
- package/dist/collection/components/pagination-menu/test/pagination-menu.spec.js +87 -0
- package/dist/collection/components/payment-details/get-payment-details.js +17 -0
- package/dist/collection/components/payment-details/payment-details-core.js +86 -0
- package/dist/collection/components/payment-details/payment-details.js +27 -52
- package/dist/collection/components/payment-details/test/get-payment-details.spec.js +64 -0
- package/dist/collection/components/payment-details/test/payment-details-core.spec.js +47 -0
- package/dist/collection/components/payment-details/test/payment-details.spec.js +31 -0
- package/dist/collection/components/payment-method-form/test/payment-method-form.e2e.js +1 -1
- package/dist/collection/components/payments-list/get-payments.js +20 -0
- package/dist/collection/components/payments-list/payments-list-core.js +158 -0
- package/dist/collection/components/payments-list/payments-list.js +27 -127
- package/dist/collection/components/payments-list/test/get-payments.spec.js +70 -0
- package/dist/collection/components/payments-list/test/payments-list-core.spec.js +100 -0
- package/dist/collection/components/payments-list/test/payments-list.spec.js +17 -21
- package/dist/collection/components/payout-details/get-payout-details.js +20 -0
- package/dist/collection/components/payout-details/payout-details-core.js +86 -0
- package/dist/collection/components/payout-details/payout-details.js +27 -78
- package/dist/collection/components/payout-details/test/get-payout-details.spec.js +55 -0
- package/dist/collection/components/payout-details/test/payout-details-core.spec.js +72 -0
- package/dist/collection/components/payout-details/test/payout-details.spec.js +13 -0
- package/dist/collection/components/payouts-list/get-payouts.js +20 -0
- package/dist/collection/components/payouts-list/payouts-list-core.js +181 -0
- package/dist/collection/components/payouts-list/payouts-list.js +26 -148
- package/dist/collection/components/payouts-list/test/get-payouts.spec.js +64 -0
- package/dist/collection/components/payouts-list/test/payouts-list-core.spec.js +105 -0
- package/dist/collection/components/payouts-list/test/payouts-list.spec.js +29 -0
- package/dist/collection/components/table/table.js +1 -1
- package/dist/collection/components/table/test/table.spec.js +18 -0
- package/dist/collection/components/table/utils.js +1 -1
- package/dist/collection/utils/{phone-masks.js → form-input-masks.js} +1 -0
- package/dist/docs.json +397 -233
- package/dist/esm/Business-954e1c1b.js +78 -0
- package/dist/esm/BusinessFormEventTypes-989960ba.js +39 -0
- package/dist/esm/{Payout-c42e3877.js → Payout-dc5f009c.js} +2 -1
- package/dist/esm/{SubAccount-b3ce8720.js → SubAccount-bd59f646.js} +1 -1
- package/dist/esm/additional-questions-details_5.entry.js +5 -5
- package/dist/esm/{business-form-schema-997c585c.js → business-form-schema-f8f554d1.js} +17 -17
- package/dist/esm/{form-control-datepart_2.entry.js → form-control-datepart_3.entry.js} +46 -4
- package/dist/esm/{form-control-number_3.entry.js → form-control-select_2.entry.js} +1 -43
- package/dist/esm/form-input-masks-a8187c77.js +6 -0
- package/dist/esm/{index.esm-8ae36d07.js → index.esm-22b47398.js} +1 -258
- package/dist/esm/{justifi-additional-questions_6.entry.js → justifi-additional-questions_5.entry.js} +10 -279
- package/dist/esm/justifi-billing-form_2.entry.js +1 -1
- package/dist/esm/justifi-business-details.entry.js +5 -5
- package/dist/esm/justifi-business-form-stepped.entry.js +47 -53
- package/dist/esm/justifi-business-form.entry.js +32 -36
- package/dist/esm/justifi-business-list.entry.js +3 -50
- package/dist/{module/business-owners.js → esm/justifi-business-owners.entry.js} +13 -55
- package/dist/esm/justifi-details.entry.js +1 -1
- package/dist/esm/justifi-gross-payment-chart.entry.js +3 -3
- package/dist/esm/justifi-payment-balance-transactions.entry.js +2 -2
- package/dist/esm/justifi-payment-details.entry.js +44 -43
- package/dist/esm/justifi-payment-form.entry.js +2 -2
- package/dist/esm/justifi-payment-method-form.entry.js +6 -4
- package/dist/esm/justifi-payments-list.entry.js +47 -91
- package/dist/esm/justifi-payout-details.entry.js +48 -46
- package/dist/esm/justifi-payouts-list.entry.js +47 -113
- package/dist/esm/justifi-proceeds-list.entry.js +2 -2
- package/dist/esm/justifi-refund-form.entry.js +2 -2
- package/dist/esm/justifi-subaccount-details.entry.js +4 -4
- package/dist/esm/justifi-subaccounts-list.entry.js +3 -3
- package/dist/esm/justifi-table_2.entry.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/payment-details-core.entry.js +48 -0
- package/dist/esm/payment.service-bea02ccf.js +18 -0
- package/dist/esm/payments-list-core.entry.js +94 -0
- package/dist/{webcomponents/p-34c30022.entry.js → esm/payout-details-core.entry.js} +48 -1
- package/dist/esm/payout.service-92e56814.js +19 -0
- package/dist/esm/payouts-list-core.entry.js +117 -0
- package/dist/esm/subaccount-account-details_4.entry.js +2 -2
- package/dist/esm/subaccount-bank-details.entry.js +1 -1
- package/dist/esm/subaccount-terms-details.entry.js +1 -1
- package/dist/esm/utils-546ca6aa.js +8 -0
- package/dist/esm/{utils-f33f7e3c.js → utils-576874df.js} +4 -4
- package/dist/esm/{utils-26c7dd12.js → utils-dd428dba.js} +1 -1
- package/dist/esm/webcomponents.js +1 -1
- package/dist/module/Business.js +78 -0
- package/dist/module/BusinessFormEventTypes.js +39 -0
- package/dist/module/Payout.js +2 -1
- package/dist/module/additional-questions-details2.js +4 -4
- package/dist/module/business-generic-info.js +25 -27
- package/dist/module/business-representative.js +1 -1
- package/dist/module/form-input-masks.js +6 -0
- package/dist/module/index.esm.js +1 -258
- package/dist/module/justifi-business-details.js +3 -3
- package/dist/module/justifi-business-form-stepped.js +62 -74
- package/dist/module/justifi-business-form.js +47 -57
- package/dist/module/justifi-business-list.js +1 -48
- package/dist/module/justifi-business-owners.js +115 -1
- package/dist/module/justifi-payment-details.js +52 -48
- package/dist/module/justifi-payments-list.js +58 -102
- package/dist/module/justifi-payout-details.js +57 -52
- package/dist/module/justifi-payouts-list.js +59 -125
- package/dist/module/justifi-refund-form.js +1 -1
- package/dist/module/legal-address-form.js +3 -203
- package/dist/module/payment-details-core.d.ts +11 -0
- package/dist/module/payment-details-core.js +6 -0
- package/dist/module/payment-details-core2.js +76 -0
- package/dist/module/payment-method-form.js +6 -4
- package/dist/module/payment.service.js +18 -0
- package/dist/module/payments-list-core.d.ts +11 -0
- package/dist/module/payments-list-core.js +6 -0
- package/dist/module/payments-list-core2.js +131 -0
- package/dist/module/payout-details-core.d.ts +11 -0
- package/dist/module/payout-details-core.js +6 -0
- package/dist/module/payout-details-core2.js +76 -0
- package/dist/module/payout.service.js +19 -0
- package/dist/module/payouts-list-core.d.ts +11 -0
- package/dist/module/payouts-list-core.js +6 -0
- package/dist/module/payouts-list-core2.js +153 -0
- package/dist/module/table.js +2 -2
- package/dist/module/utils.js +4 -4
- package/dist/module/utils3.js +6 -29
- package/dist/types/api/Business.d.ts +64 -28
- package/dist/types/api/Payment.d.ts +33 -1
- package/dist/types/api/services/payment.service.d.ts +9 -0
- package/dist/types/api/services/payout.service.d.ts +9 -0
- package/dist/types/api/services/utils.d.ts +1 -0
- package/dist/types/components/business-details/additional-questions-details/additional-questions-details.d.ts +2 -2
- package/dist/types/components/business-details/business-details.d.ts +2 -2
- package/dist/types/components/business-details/legal-address-details/legal-address-details.d.ts +2 -2
- package/dist/types/components/business-form/BusinessFormEventTypes.d.ts +5 -0
- package/dist/types/components/business-form/business-form-schema.d.ts +1 -19
- package/dist/types/components/business-form/business-form-stepped.d.ts +19 -5
- package/dist/types/components/business-form/business-form.d.ts +11 -2
- package/dist/types/components/business-form/business-generic-info/business-generic-info.d.ts +2 -0
- package/dist/types/components/business-form/business-owners/business-owners.d.ts +1 -1
- package/dist/types/components/business-form/helpers.d.ts +1 -1
- package/dist/types/components/details/utils.d.ts +4 -3
- package/dist/types/components/payment-details/get-payment-details.d.ts +8 -0
- package/dist/types/components/payment-details/payment-details-core.d.ts +11 -0
- package/dist/types/components/payment-details/payment-details.d.ts +6 -6
- package/dist/types/components/payment-method-form/payment-method-responses.d.ts +10 -2
- package/dist/types/components/payments-list/get-payments.d.ts +9 -0
- package/dist/types/components/payments-list/payments-list-core.d.ts +17 -0
- package/dist/types/components/payments-list/payments-list.d.ts +4 -12
- package/dist/types/components/payout-details/get-payout-details.d.ts +8 -0
- package/dist/types/components/payout-details/payout-details-core.d.ts +11 -0
- package/dist/types/components/payout-details/payout-details.d.ts +5 -31
- package/dist/types/components/payouts-list/get-payouts.d.ts +9 -0
- package/dist/types/components/payouts-list/payouts-list-core.d.ts +18 -0
- package/dist/types/components/payouts-list/payouts-list.d.ts +4 -13
- package/dist/types/components.d.ts +136 -138
- package/dist/types/utils/form-input-masks.d.ts +6 -0
- package/dist/webcomponents/p-081cf5f6.entry.js +1 -0
- package/dist/webcomponents/p-0b9146cd.entry.js +1 -0
- package/dist/webcomponents/p-0e53f470.entry.js +1 -0
- package/dist/webcomponents/p-112acd3c.entry.js +1 -0
- package/dist/webcomponents/p-1555e6b1.js +1 -0
- package/dist/webcomponents/{p-ac8be2a8.entry.js → p-16f41fd0.entry.js} +1 -1
- package/dist/webcomponents/p-17715325.js +1 -0
- package/dist/webcomponents/p-19c5ddf1.entry.js +1 -0
- package/dist/webcomponents/{p-2b2f8162.entry.js → p-2e318b6a.entry.js} +1 -1
- package/dist/webcomponents/p-34de1c5d.entry.js +1 -0
- package/dist/webcomponents/p-3a4d4869.entry.js +1 -0
- package/dist/webcomponents/p-3cb0b96d.js +1 -0
- package/dist/webcomponents/p-4ba2c711.entry.js +1 -0
- package/dist/webcomponents/p-4c01df65.entry.js +1 -0
- package/dist/webcomponents/p-4fa27a28.entry.js +1 -0
- package/dist/webcomponents/{p-3bef762a.js → p-50730e69.js} +1 -1
- package/dist/webcomponents/p-5e142186.entry.js +1 -0
- package/dist/webcomponents/{p-85ddbe82.entry.js → p-5f8b9f64.entry.js} +1 -1
- package/dist/webcomponents/p-663bfe87.js +1 -0
- package/dist/webcomponents/p-6ab67031.entry.js +1 -0
- package/dist/webcomponents/p-6ed680e9.js +1 -0
- package/dist/webcomponents/{p-d8835e7a.entry.js → p-731cb109.entry.js} +1 -1
- package/dist/webcomponents/{p-525adabf.entry.js → p-7c0f91fa.entry.js} +1 -1
- package/dist/webcomponents/p-80140d5b.js +1 -0
- package/dist/webcomponents/p-810b72b5.js +1 -0
- package/dist/webcomponents/p-870c2e4d.entry.js +1 -0
- package/dist/webcomponents/{p-64a5126c.entry.js → p-896a9ddb.entry.js} +1 -1
- package/dist/webcomponents/{p-9ba0be02.entry.js → p-8a90b976.entry.js} +1 -1
- package/dist/webcomponents/p-9b99370e.js +1 -0
- package/dist/webcomponents/p-9cb3ff78.entry.js +1 -0
- package/dist/webcomponents/p-a5d662ac.entry.js +1 -0
- package/dist/webcomponents/p-ad9a6c20.entry.js +1 -0
- package/dist/webcomponents/p-ade12f56.js +1 -0
- package/dist/webcomponents/{p-45d2761d.entry.js → p-b5aba473.entry.js} +1 -1
- package/dist/webcomponents/p-b8a8b551.js +1 -0
- package/dist/webcomponents/{p-c950901c.entry.js → p-c0f882ce.entry.js} +1 -1
- package/dist/webcomponents/p-d66a6057.entry.js +1 -0
- package/dist/webcomponents/{p-9cec4a27.entry.js → p-d71ce1cd.entry.js} +1 -1
- package/dist/webcomponents/p-ea05d7c2.entry.js +1 -0
- package/dist/webcomponents/{p-c43e29ac.entry.js → p-ec4f27e7.entry.js} +1 -1
- package/dist/webcomponents/{p-40fb25c6.entry.js → p-eef5b15b.entry.js} +1 -1
- package/dist/webcomponents/{p-9a6e4749.js → p-f0c535ed.js} +1 -1
- package/dist/webcomponents/{p-c63a98f6.entry.js → p-f7a3fd12.entry.js} +1 -1
- package/dist/webcomponents/webcomponents.esm.js +1 -1
- package/package.json +6 -4
- package/dist/cjs/utils-931f4879.js +0 -34
- package/dist/esm/utils-8cc130a9.js +0 -31
- package/dist/module/phone-masks.js +0 -5
- package/dist/types/utils/phone-masks.d.ts +0 -3
- package/dist/webcomponents/p-0a1347cf.entry.js +0 -1
- package/dist/webcomponents/p-0f3e9483.js +0 -1
- package/dist/webcomponents/p-0fa49c38.entry.js +0 -1
- package/dist/webcomponents/p-1e2a98bf.js +0 -1
- package/dist/webcomponents/p-5a502ceb.entry.js +0 -1
- package/dist/webcomponents/p-5bf0ac1a.entry.js +0 -1
- package/dist/webcomponents/p-6e80f063.entry.js +0 -1
- package/dist/webcomponents/p-71679a41.js +0 -1
- package/dist/webcomponents/p-78baff54.js +0 -1
- package/dist/webcomponents/p-8bbb1b10.entry.js +0 -1
- package/dist/webcomponents/p-90926321.js +0 -1
- package/dist/webcomponents/p-9e0d2179.entry.js +0 -1
- package/dist/webcomponents/p-c4826a33.entry.js +0 -1
- package/dist/webcomponents/p-d4755024.entry.js +0 -1
- package/dist/webcomponents/p-e8e109bd.entry.js +0 -1
- package/dist/webcomponents/p-ead8cfc2.entry.js +0 -1
- package/dist/webcomponents/p-f74899b9.entry.js +0 -1
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
import { pagingDefaults } from "../../api";
|
|
3
|
+
import { MapPaymentStatusToBadge, formatCurrency, formatDate, formatTime } from "../../utils/utils";
|
|
4
|
+
export class PaymentsListCore {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.handleClickPrevious = (beforeCursor) => {
|
|
7
|
+
const newParams = Object.assign({}, this.params);
|
|
8
|
+
delete newParams.after_cursor;
|
|
9
|
+
this.params = (Object.assign(Object.assign({}, newParams), { before_cursor: beforeCursor }));
|
|
10
|
+
};
|
|
11
|
+
this.handleClickNext = (afterCursor) => {
|
|
12
|
+
const newParams = Object.assign({}, this.params);
|
|
13
|
+
delete newParams.before_cursor;
|
|
14
|
+
this.params = (Object.assign(Object.assign({}, newParams), { after_cursor: afterCursor }));
|
|
15
|
+
};
|
|
16
|
+
this.getPayments = undefined;
|
|
17
|
+
this.payments = [];
|
|
18
|
+
this.loading = true;
|
|
19
|
+
this.errorMessage = undefined;
|
|
20
|
+
this.paging = pagingDefaults;
|
|
21
|
+
this.params = undefined;
|
|
22
|
+
}
|
|
23
|
+
componentWillLoad() {
|
|
24
|
+
if (this.getPayments) {
|
|
25
|
+
this.fetchData();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
updateOnPropChange() {
|
|
29
|
+
this.fetchData();
|
|
30
|
+
}
|
|
31
|
+
fetchData() {
|
|
32
|
+
this.loading = true;
|
|
33
|
+
this.getPayments({
|
|
34
|
+
params: this.params,
|
|
35
|
+
onSuccess: ({ payments, pagingInfo }) => {
|
|
36
|
+
this.payments = payments;
|
|
37
|
+
this.paging = pagingInfo;
|
|
38
|
+
this.loading = false;
|
|
39
|
+
},
|
|
40
|
+
onError: (errorMessage) => {
|
|
41
|
+
this.errorMessage = errorMessage;
|
|
42
|
+
this.loading = false;
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
;
|
|
47
|
+
render() {
|
|
48
|
+
return (h(Host, null, h("justifi-table", { rowClickHandler: e => {
|
|
49
|
+
const clickedPaymentID = e.target.closest('tr').dataset.rowEntityId;
|
|
50
|
+
if (!clickedPaymentID) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this.rowClicked.emit(this.payments.find((payment) => payment.id === clickedPaymentID));
|
|
54
|
+
}, entityId: this.payments.map((payment) => payment.id), columnData: [
|
|
55
|
+
['Made On', 'The date and time each payment was made'],
|
|
56
|
+
['Amount', 'The dollar amount of each payment'],
|
|
57
|
+
['Description', 'The payment description, if you provided one'],
|
|
58
|
+
['Cardholder', 'The name associated with the payment method'],
|
|
59
|
+
['Payment Method', 'The brand and last 4 digits of the payment method'],
|
|
60
|
+
['Status', 'The current status of each payment'],
|
|
61
|
+
['Payment ID', 'The unique identifier of each payment']
|
|
62
|
+
], rowData: this.payments.map((payment) => ([
|
|
63
|
+
{
|
|
64
|
+
type: 'head',
|
|
65
|
+
value: `
|
|
66
|
+
<div class='fw-bold'>${formatDate(payment.created_at)}</div>
|
|
67
|
+
<div class='fw-bold'>${formatTime(payment.created_at)}</div>
|
|
68
|
+
`,
|
|
69
|
+
},
|
|
70
|
+
formatCurrency(payment.amount),
|
|
71
|
+
payment.description,
|
|
72
|
+
payment.payment_method.payersName,
|
|
73
|
+
payment.payment_method.lastFourDigits,
|
|
74
|
+
{
|
|
75
|
+
type: 'inner',
|
|
76
|
+
value: MapPaymentStatusToBadge(payment.status)
|
|
77
|
+
},
|
|
78
|
+
payment.id
|
|
79
|
+
])), loading: this.loading, "error-message": this.errorMessage, params: this.params, paging: Object.assign(Object.assign({}, this.paging), { handleClickNext: this.handleClickNext, handleClickPrevious: this.handleClickPrevious }) })));
|
|
80
|
+
}
|
|
81
|
+
static get is() { return "payments-list-core"; }
|
|
82
|
+
static get originalStyleUrls() {
|
|
83
|
+
return {
|
|
84
|
+
"$": ["payments-list.scss"]
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
static get styleUrls() {
|
|
88
|
+
return {
|
|
89
|
+
"$": ["payments-list.css"]
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
static get properties() {
|
|
93
|
+
return {
|
|
94
|
+
"getPayments": {
|
|
95
|
+
"type": "unknown",
|
|
96
|
+
"mutable": false,
|
|
97
|
+
"complexType": {
|
|
98
|
+
"original": "Function",
|
|
99
|
+
"resolved": "Function",
|
|
100
|
+
"references": {
|
|
101
|
+
"Function": {
|
|
102
|
+
"location": "global",
|
|
103
|
+
"id": "global::Function"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"required": false,
|
|
108
|
+
"optional": false,
|
|
109
|
+
"docs": {
|
|
110
|
+
"tags": [],
|
|
111
|
+
"text": ""
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
static get states() {
|
|
117
|
+
return {
|
|
118
|
+
"payments": {},
|
|
119
|
+
"loading": {},
|
|
120
|
+
"errorMessage": {},
|
|
121
|
+
"paging": {},
|
|
122
|
+
"params": {}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
static get events() {
|
|
126
|
+
return [{
|
|
127
|
+
"method": "rowClicked",
|
|
128
|
+
"name": "payment-row-clicked",
|
|
129
|
+
"bubbles": true,
|
|
130
|
+
"cancelable": true,
|
|
131
|
+
"composed": true,
|
|
132
|
+
"docs": {
|
|
133
|
+
"tags": [],
|
|
134
|
+
"text": ""
|
|
135
|
+
},
|
|
136
|
+
"complexType": {
|
|
137
|
+
"original": "Payment",
|
|
138
|
+
"resolved": "Payment",
|
|
139
|
+
"references": {
|
|
140
|
+
"Payment": {
|
|
141
|
+
"location": "import",
|
|
142
|
+
"path": "../../api",
|
|
143
|
+
"id": "src/api/index.ts::Payment"
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}];
|
|
148
|
+
}
|
|
149
|
+
static get watchers() {
|
|
150
|
+
return [{
|
|
151
|
+
"propName": "params",
|
|
152
|
+
"methodName": "updateOnPropChange"
|
|
153
|
+
}, {
|
|
154
|
+
"propName": "getPayments",
|
|
155
|
+
"methodName": "updateOnPropChange"
|
|
156
|
+
}];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { PaymentService } from "../../api/services/payment.service";
|
|
3
|
+
import { makeGetPayments } from "./get-payments";
|
|
4
|
+
import { ErrorState } from "../details/utils";
|
|
5
5
|
/**
|
|
6
6
|
* @exportedPart table-head: Table head
|
|
7
7
|
* @exportedPart table-head-row: Head row
|
|
@@ -23,107 +23,37 @@ import { config } from "../../../config";
|
|
|
23
23
|
*/
|
|
24
24
|
export class PaymentsList {
|
|
25
25
|
constructor() {
|
|
26
|
-
this.handleClickPrevious = (beforeCursor) => {
|
|
27
|
-
const newParams = Object.assign({}, this.params);
|
|
28
|
-
delete newParams.after_cursor;
|
|
29
|
-
this.params = (Object.assign(Object.assign({}, newParams), { before_cursor: beforeCursor }));
|
|
30
|
-
};
|
|
31
|
-
this.handleClickNext = (afterCursor) => {
|
|
32
|
-
const newParams = Object.assign({}, this.params);
|
|
33
|
-
delete newParams.before_cursor;
|
|
34
|
-
this.params = (Object.assign(Object.assign({}, newParams), { after_cursor: afterCursor }));
|
|
35
|
-
};
|
|
36
26
|
this.accountId = undefined;
|
|
37
27
|
this.authToken = undefined;
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
40
|
-
this.errorMessage = undefined;
|
|
41
|
-
this.paging = pagingDefaults;
|
|
42
|
-
this.params = undefined;
|
|
28
|
+
this.getPayments = undefined;
|
|
29
|
+
this.errorMessage = null;
|
|
43
30
|
}
|
|
44
|
-
|
|
45
|
-
this.
|
|
31
|
+
componentWillLoad() {
|
|
32
|
+
this.initializeGetPayments();
|
|
46
33
|
}
|
|
47
|
-
|
|
48
|
-
this.
|
|
34
|
+
propChanged() {
|
|
35
|
+
this.initializeGetPayments();
|
|
49
36
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.loading = true;
|
|
58
|
-
try {
|
|
59
|
-
const api = Api(this.authToken, config.proxyApiOrigin);
|
|
60
|
-
const endpoint = `account/${this.accountId}/payments`;
|
|
61
|
-
const response = await api.get(endpoint, this.params);
|
|
62
|
-
if (!response.error) {
|
|
63
|
-
this.paging = Object.assign(Object.assign({}, this.paging), response.page_info);
|
|
64
|
-
const data = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.map(dataItem => new Payment(dataItem));
|
|
65
|
-
this.payments = data;
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
const responseError = typeof response.error === 'string' ? response.error : response.error.message;
|
|
69
|
-
console.error(`Error fetching payments: ${responseError}`);
|
|
70
|
-
this.errorMessage = 'No results';
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
console.error(`Error fetching payments: ${error.message}`);
|
|
75
|
-
this.errorMessage = 'No results';
|
|
37
|
+
initializeGetPayments() {
|
|
38
|
+
if (this.accountId && this.authToken) {
|
|
39
|
+
this.getPayments = makeGetPayments({
|
|
40
|
+
id: this.accountId,
|
|
41
|
+
authToken: this.authToken,
|
|
42
|
+
service: new PaymentService(),
|
|
43
|
+
});
|
|
76
44
|
}
|
|
77
|
-
|
|
78
|
-
this.
|
|
45
|
+
else {
|
|
46
|
+
this.errorMessage = 'Account ID and Auth Token are required';
|
|
79
47
|
}
|
|
80
48
|
}
|
|
81
49
|
render() {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
this.rowClicked.emit(this.payments.find((payment) => payment.id === clickedPaymentID));
|
|
88
|
-
}, entityId: this.payments.map((payment) => payment.id), columnData: [
|
|
89
|
-
['Made On', 'The date and time each payment was made'],
|
|
90
|
-
['Amount', 'The dollar amount of each payment'],
|
|
91
|
-
['Description', 'The payment description, if you provided one'],
|
|
92
|
-
['Cardholder', 'The name associated with the payment method'],
|
|
93
|
-
['Payment Method', 'The brand and last 4 digits of the payment method'],
|
|
94
|
-
['Status', 'The current status of each payment'],
|
|
95
|
-
['Payment ID', 'The unique identifier of each payment']
|
|
96
|
-
], rowData: this.payments.map((payment) => ([
|
|
97
|
-
{
|
|
98
|
-
type: 'head',
|
|
99
|
-
value: `
|
|
100
|
-
<div class='fw-bold'>${formatDate(payment.created_at)}</div>
|
|
101
|
-
<div class='fw-bold'>${formatTime(payment.created_at)}</div>
|
|
102
|
-
`,
|
|
103
|
-
},
|
|
104
|
-
formatCurrency(payment.amount),
|
|
105
|
-
payment.description,
|
|
106
|
-
payment.payment_method.payersName,
|
|
107
|
-
payment.payment_method.lastFourDigits,
|
|
108
|
-
{
|
|
109
|
-
type: 'inner',
|
|
110
|
-
value: MapPaymentStatusToBadge(payment.status)
|
|
111
|
-
},
|
|
112
|
-
payment.id
|
|
113
|
-
])), loading: this.loading, "error-message": this.errorMessage, params: this.params, paging: Object.assign(Object.assign({}, this.paging), { handleClickNext: this.handleClickNext, handleClickPrevious: this.handleClickPrevious }) })));
|
|
50
|
+
if (this.errorMessage) {
|
|
51
|
+
return ErrorState(this.errorMessage);
|
|
52
|
+
}
|
|
53
|
+
return (h("payments-list-core", { getPayments: this.getPayments }));
|
|
114
54
|
}
|
|
115
55
|
static get is() { return "justifi-payments-list"; }
|
|
116
56
|
static get encapsulation() { return "shadow"; }
|
|
117
|
-
static get originalStyleUrls() {
|
|
118
|
-
return {
|
|
119
|
-
"$": ["payments-list.scss"]
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
static get styleUrls() {
|
|
123
|
-
return {
|
|
124
|
-
"$": ["payments-list.css"]
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
57
|
static get properties() {
|
|
128
58
|
return {
|
|
129
59
|
"accountId": {
|
|
@@ -164,47 +94,17 @@ export class PaymentsList {
|
|
|
164
94
|
}
|
|
165
95
|
static get states() {
|
|
166
96
|
return {
|
|
167
|
-
"
|
|
168
|
-
"
|
|
169
|
-
"errorMessage": {},
|
|
170
|
-
"paging": {},
|
|
171
|
-
"params": {}
|
|
97
|
+
"getPayments": {},
|
|
98
|
+
"errorMessage": {}
|
|
172
99
|
};
|
|
173
100
|
}
|
|
174
|
-
static get events() {
|
|
175
|
-
return [{
|
|
176
|
-
"method": "rowClicked",
|
|
177
|
-
"name": "payment-row-clicked",
|
|
178
|
-
"bubbles": true,
|
|
179
|
-
"cancelable": true,
|
|
180
|
-
"composed": true,
|
|
181
|
-
"docs": {
|
|
182
|
-
"tags": [],
|
|
183
|
-
"text": ""
|
|
184
|
-
},
|
|
185
|
-
"complexType": {
|
|
186
|
-
"original": "Payment",
|
|
187
|
-
"resolved": "Payment",
|
|
188
|
-
"references": {
|
|
189
|
-
"Payment": {
|
|
190
|
-
"location": "import",
|
|
191
|
-
"path": "../../api",
|
|
192
|
-
"id": "src/api/index.ts::Payment"
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}];
|
|
197
|
-
}
|
|
198
101
|
static get watchers() {
|
|
199
102
|
return [{
|
|
200
103
|
"propName": "accountId",
|
|
201
|
-
"methodName": "
|
|
104
|
+
"methodName": "propChanged"
|
|
202
105
|
}, {
|
|
203
106
|
"propName": "authToken",
|
|
204
|
-
"methodName": "
|
|
205
|
-
}, {
|
|
206
|
-
"propName": "params",
|
|
207
|
-
"methodName": "updateOnPropChange"
|
|
107
|
+
"methodName": "propChanged"
|
|
208
108
|
}];
|
|
209
109
|
}
|
|
210
110
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { PaymentService } from "../../../api/services/payment.service";
|
|
2
|
+
import { makeGetPayments } from "../get-payments";
|
|
3
|
+
import mockResponse from "../../../api/mockData/mockPaymentsSuccess.json";
|
|
4
|
+
import { Payment } from "../../../api";
|
|
5
|
+
// Mock the PaymentService class
|
|
6
|
+
jest.mock('../../../api/services/payment.service');
|
|
7
|
+
describe('makeGetPayments', () => {
|
|
8
|
+
const mockId = '123';
|
|
9
|
+
const mockAuthToken = 'token';
|
|
10
|
+
const mockParams = { limit: 10, page: 1 };
|
|
11
|
+
let mockServiceInstance;
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
jest.clearAllMocks();
|
|
14
|
+
// Create a new instance of the mocked PaymentService
|
|
15
|
+
mockServiceInstance = new PaymentService();
|
|
16
|
+
// Explicitly mock fetchPayments as a jest mock function
|
|
17
|
+
mockServiceInstance.fetchPayments = jest.fn();
|
|
18
|
+
});
|
|
19
|
+
it('should call onSuccess with payments and pagingInfo on successful fetch', async () => {
|
|
20
|
+
const onSuccess = jest.fn();
|
|
21
|
+
const onError = jest.fn();
|
|
22
|
+
// Mock fetchPayments to resolve with mockResponse
|
|
23
|
+
mockServiceInstance.fetchPayments.mockResolvedValue(mockResponse);
|
|
24
|
+
const getPayments = makeGetPayments({
|
|
25
|
+
id: mockId,
|
|
26
|
+
authToken: mockAuthToken,
|
|
27
|
+
service: mockServiceInstance,
|
|
28
|
+
});
|
|
29
|
+
await getPayments({ params: mockParams, onSuccess, onError });
|
|
30
|
+
expect(onSuccess).toHaveBeenCalledWith({
|
|
31
|
+
payments: expect.arrayContaining([
|
|
32
|
+
expect.any(Payment),
|
|
33
|
+
expect.any(Payment),
|
|
34
|
+
]),
|
|
35
|
+
pagingInfo: mockResponse.page_info,
|
|
36
|
+
});
|
|
37
|
+
expect(onError).not.toHaveBeenCalled();
|
|
38
|
+
});
|
|
39
|
+
it('should call onError with an error message on API failure', async () => {
|
|
40
|
+
const mockError = new Error('Error fetching payments');
|
|
41
|
+
const onSuccess = jest.fn();
|
|
42
|
+
const onError = jest.fn();
|
|
43
|
+
// Mock fetchPayments to reject with mockError
|
|
44
|
+
mockServiceInstance.fetchPayments.mockRejectedValue(mockError);
|
|
45
|
+
const getPayments = makeGetPayments({
|
|
46
|
+
id: mockId,
|
|
47
|
+
authToken: mockAuthToken,
|
|
48
|
+
service: mockServiceInstance,
|
|
49
|
+
});
|
|
50
|
+
await getPayments({ params: mockParams, onSuccess, onError });
|
|
51
|
+
expect(onError).toHaveBeenCalledWith('Error fetching payments');
|
|
52
|
+
expect(onSuccess).not.toHaveBeenCalled();
|
|
53
|
+
});
|
|
54
|
+
it('should call onError with an exception message on fetch exception', async () => {
|
|
55
|
+
const mockError = new Error('Network error');
|
|
56
|
+
const onSuccess = jest.fn();
|
|
57
|
+
const onError = jest.fn();
|
|
58
|
+
// Mock fetchPayments to reject with mockError
|
|
59
|
+
mockServiceInstance.fetchPayments.mockRejectedValue(mockError);
|
|
60
|
+
const getPayments = makeGetPayments({
|
|
61
|
+
id: mockId,
|
|
62
|
+
authToken: mockAuthToken,
|
|
63
|
+
service: mockServiceInstance,
|
|
64
|
+
});
|
|
65
|
+
await getPayments({ params: mockParams, onSuccess, onError });
|
|
66
|
+
expect(onError).toHaveBeenCalledWith('Network error');
|
|
67
|
+
expect(onSuccess).not.toHaveBeenCalled();
|
|
68
|
+
});
|
|
69
|
+
// Add more tests as needed for edge cases and different scenarios
|
|
70
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { newSpecPage } from "@stencil/core/testing";
|
|
2
|
+
import { PaymentsListCore } from "../payments-list-core";
|
|
3
|
+
import { Table } from "../../table/table";
|
|
4
|
+
import { PaginationMenu } from "../../pagination-menu/pagination-menu";
|
|
5
|
+
import mockSuccessResponse from "../../../api/mockData/mockPaymentsSuccess.json";
|
|
6
|
+
import { makeGetPayments } from "../get-payments";
|
|
7
|
+
const mockPaymentsResponse = mockSuccessResponse;
|
|
8
|
+
describe('payments-list-core', () => {
|
|
9
|
+
it('renders properly with fetched data', async () => {
|
|
10
|
+
const mockPaymentsService = {
|
|
11
|
+
fetchPayments: jest.fn().mockResolvedValue(mockPaymentsResponse),
|
|
12
|
+
};
|
|
13
|
+
const page = await newSpecPage({
|
|
14
|
+
components: [PaymentsListCore, Table, PaginationMenu],
|
|
15
|
+
html: `<payments-list-core></payments-list-core>`,
|
|
16
|
+
});
|
|
17
|
+
page.rootInstance.componentWillLoad = () => { };
|
|
18
|
+
page.rootInstance.getPayments = makeGetPayments({
|
|
19
|
+
id: '123',
|
|
20
|
+
authToken: '123',
|
|
21
|
+
service: mockPaymentsService
|
|
22
|
+
});
|
|
23
|
+
page.rootInstance.fetchData();
|
|
24
|
+
await page.waitForChanges();
|
|
25
|
+
const justifiTable = page.root.querySelector('justifi-table');
|
|
26
|
+
expect(page.rootInstance.payments[0]).toEqual(expect.objectContaining({ account_id: mockPaymentsResponse.data[0].account_id }));
|
|
27
|
+
const rows = justifiTable.shadowRoot.querySelectorAll('[data-test-id="table-row"]');
|
|
28
|
+
expect(rows.length).toBe(mockPaymentsResponse.data.length);
|
|
29
|
+
expect(mockPaymentsService.fetchPayments).toHaveBeenCalled();
|
|
30
|
+
// expect(page.root).toMatchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
it('displays an error state on failed data fetch', async () => {
|
|
33
|
+
const mockService = {
|
|
34
|
+
fetchPayments: jest.fn().mockRejectedValue(new Error('Fetch error'))
|
|
35
|
+
};
|
|
36
|
+
const getPayments = makeGetPayments({
|
|
37
|
+
id: 'some-id',
|
|
38
|
+
authToken: 'some-auth-token',
|
|
39
|
+
service: mockService
|
|
40
|
+
});
|
|
41
|
+
const page = await newSpecPage({
|
|
42
|
+
components: [PaymentsListCore, Table, PaginationMenu],
|
|
43
|
+
html: '<payments-list-core></payments-list-core>',
|
|
44
|
+
});
|
|
45
|
+
page.rootInstance.componentWillLoad = () => { };
|
|
46
|
+
page.rootInstance.getPayments = getPayments;
|
|
47
|
+
await page.rootInstance.fetchData();
|
|
48
|
+
await page.waitForChanges();
|
|
49
|
+
expect(page.rootInstance.errorMessage).toBe('Fetch error');
|
|
50
|
+
// expect(page.root).toMatchSnapshot();
|
|
51
|
+
});
|
|
52
|
+
it('emits payment-row-clicked event on row click', async () => {
|
|
53
|
+
const mockPaymentsService = {
|
|
54
|
+
fetchPayments: jest.fn().mockResolvedValue(mockPaymentsResponse),
|
|
55
|
+
};
|
|
56
|
+
const page = await newSpecPage({
|
|
57
|
+
components: [PaymentsListCore, Table, PaginationMenu],
|
|
58
|
+
html: `<payments-list-core></payments-list-core>`,
|
|
59
|
+
});
|
|
60
|
+
page.rootInstance.componentWillLoad = () => { };
|
|
61
|
+
page.rootInstance.getPayments = makeGetPayments({
|
|
62
|
+
id: '123',
|
|
63
|
+
authToken: '123',
|
|
64
|
+
service: mockPaymentsService
|
|
65
|
+
});
|
|
66
|
+
page.rootInstance.fetchData();
|
|
67
|
+
await page.waitForChanges();
|
|
68
|
+
const justifiTable = page.root.querySelector('justifi-table');
|
|
69
|
+
const firstRow = justifiTable.shadowRoot.querySelector('[data-test-id="table-row"]');
|
|
70
|
+
expect(firstRow).not.toBeNull();
|
|
71
|
+
const spyEvent = jest.fn();
|
|
72
|
+
page.win.addEventListener('payment-row-clicked', spyEvent);
|
|
73
|
+
firstRow.click();
|
|
74
|
+
expect(spyEvent).toHaveBeenCalled();
|
|
75
|
+
});
|
|
76
|
+
it('updates params and refetches data on pagination interaction', async () => {
|
|
77
|
+
const mockPaymentsService = {
|
|
78
|
+
fetchPayments: jest.fn().mockResolvedValue(mockPaymentsResponse),
|
|
79
|
+
};
|
|
80
|
+
const page = await newSpecPage({
|
|
81
|
+
components: [PaymentsListCore, Table, PaginationMenu],
|
|
82
|
+
html: `<payments-list-core></payments-list-core>`,
|
|
83
|
+
});
|
|
84
|
+
page.rootInstance.componentWillLoad = () => { };
|
|
85
|
+
page.rootInstance.getPayments = makeGetPayments({
|
|
86
|
+
id: '123',
|
|
87
|
+
authToken: '123',
|
|
88
|
+
service: mockPaymentsService
|
|
89
|
+
});
|
|
90
|
+
page.rootInstance.fetchData();
|
|
91
|
+
await page.waitForChanges();
|
|
92
|
+
// Assuming handleClickNext is accessible and modifies `params` which triggers a re-fetch
|
|
93
|
+
page.rootInstance.handleClickNext('nextCursor');
|
|
94
|
+
await page.waitForChanges();
|
|
95
|
+
// The mock function should be called 3 times: once for the initial load, twice for when mockGetPayments is set and later after the pagination interaction
|
|
96
|
+
expect(mockPaymentsService.fetchPayments).toHaveBeenCalledTimes(3);
|
|
97
|
+
const updatedParams = page.rootInstance.params;
|
|
98
|
+
expect(updatedParams.after_cursor).toBe('nextCursor');
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -1,33 +1,29 @@
|
|
|
1
1
|
import { newSpecPage } from "@stencil/core/testing";
|
|
2
2
|
import { PaymentsList } from "../payments-list";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { PaymentsListCore } from "../payments-list-core";
|
|
4
|
+
describe('payments-list', () => {
|
|
5
|
+
it('renders an error message when accountId and authToken are not provided', async () => {
|
|
5
6
|
const page = await newSpecPage({
|
|
6
|
-
components: [PaymentsList],
|
|
7
|
-
html:
|
|
7
|
+
components: [PaymentsList, PaymentsListCore],
|
|
8
|
+
html: '<justifi-payments-list></justifi-payments-list>',
|
|
8
9
|
});
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<mock:shadow-root>
|
|
12
|
-
<justifi-table error-message="Can not fetch any data without an AccountID and an AuthToken">
|
|
13
|
-
</mock:shadow-root>
|
|
14
|
-
</justifi-table>
|
|
15
|
-
`);
|
|
10
|
+
await page.waitForChanges();
|
|
11
|
+
// expect(page.root).toMatchSnapshot();
|
|
16
12
|
});
|
|
17
|
-
it('
|
|
13
|
+
it('renders an error message when accountId is not provided', async () => {
|
|
18
14
|
const page = await newSpecPage({
|
|
19
|
-
components: [PaymentsList],
|
|
20
|
-
html:
|
|
15
|
+
components: [PaymentsList, PaymentsListCore],
|
|
16
|
+
html: '<justifi-payments-list auth-token="abc"></justifi-payments-list>',
|
|
21
17
|
});
|
|
22
|
-
|
|
23
|
-
expect(
|
|
18
|
+
await page.waitForChanges();
|
|
19
|
+
// expect(page.root).toMatchSnapshot();
|
|
24
20
|
});
|
|
25
|
-
it('renders an error when
|
|
21
|
+
it('renders an error message when authToken is not provided', async () => {
|
|
26
22
|
const page = await newSpecPage({
|
|
27
|
-
components: [PaymentsList],
|
|
28
|
-
html:
|
|
23
|
+
components: [PaymentsList, PaymentsListCore],
|
|
24
|
+
html: '<justifi-payments-list account-id="abc"></justifi-payments-list>',
|
|
29
25
|
});
|
|
30
|
-
|
|
31
|
-
expect(
|
|
26
|
+
await page.waitForChanges();
|
|
27
|
+
// expect(page.root).toMatchSnapshot();
|
|
32
28
|
});
|
|
33
29
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Payout } from "../../api";
|
|
2
|
+
import { getErrorMessage } from "../../api/services/utils";
|
|
3
|
+
export const makeGetPayoutDetails = ({ id, authToken, service }) => async ({ onSuccess, onError }) => {
|
|
4
|
+
try {
|
|
5
|
+
const response = await service.fetchPayout(id, authToken);
|
|
6
|
+
if (!response.error) {
|
|
7
|
+
const payout = new Payout(response.data);
|
|
8
|
+
onSuccess(payout);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
const responseError = getErrorMessage(response.error);
|
|
12
|
+
const errorMessage = `Error fetching payout details: ${responseError}`;
|
|
13
|
+
onError(errorMessage);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
const errorMessage = `Error fetching payout details: ${error}`;
|
|
18
|
+
onError(errorMessage);
|
|
19
|
+
}
|
|
20
|
+
};
|