@layerfi/components 0.1.51 → 0.1.53
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/esm/index.js +1299 -1253
- package/dist/esm/index.js.map +4 -4
- package/dist/index.d.ts +14 -7
- package/dist/index.js +1395 -1347
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ __export(src_exports, {
|
|
|
38
38
|
BookkeepingOverview: () => BookkeepingOverview,
|
|
39
39
|
BookkeepingUpsellBar: () => BookkeepingUpsellBar,
|
|
40
40
|
ChartOfAccounts: () => ChartOfAccounts,
|
|
41
|
+
Direction: () => Direction,
|
|
41
42
|
DisplayState: () => DisplayState,
|
|
42
43
|
GeneralLedgerView: () => GeneralLedgerView,
|
|
43
44
|
Journal: () => Journal,
|
|
@@ -51,12 +52,13 @@ __export(src_exports, {
|
|
|
51
52
|
StatementOfCashFlow: () => StatementOfCashFlow,
|
|
52
53
|
Tasks: () => Tasks,
|
|
53
54
|
useBankTransactionsContext: () => useBankTransactionsContext,
|
|
55
|
+
useDataSync: () => useDataSync,
|
|
54
56
|
useLayerContext: () => useLayerContext
|
|
55
57
|
});
|
|
56
58
|
module.exports = __toCommonJS(src_exports);
|
|
57
59
|
|
|
58
60
|
// src/providers/LayerProvider/LayerProvider.tsx
|
|
59
|
-
var
|
|
61
|
+
var import_react13 = __toESM(require("react"));
|
|
60
62
|
|
|
61
63
|
// src/api/util.ts
|
|
62
64
|
var formStringFromObject = (object) => Object.entries(object).map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`).join("&");
|
|
@@ -205,9 +207,12 @@ var getBankTransactions = get(
|
|
|
205
207
|
businessId,
|
|
206
208
|
cursor,
|
|
207
209
|
categorized,
|
|
210
|
+
direction,
|
|
211
|
+
startDate,
|
|
212
|
+
endDate,
|
|
208
213
|
sortBy = "date",
|
|
209
214
|
sortOrder = "DESC"
|
|
210
|
-
}) => `/v1/businesses/${businessId}/bank-transactions?${cursor ? `cursor=${cursor}&` : ""}${categorized !== void 0 && categorized !== "" ? `categorized=${categorized}&` : ""}sort_by=${sortBy}&sort_order=${sortOrder}&limit=200`
|
|
215
|
+
}) => `/v1/businesses/${businessId}/bank-transactions?${cursor !== void 0 && cursor !== "" ? `cursor=${cursor}&` : ""}${categorized !== void 0 && categorized !== "" ? `categorized=${categorized}&` : ""}${direction !== void 0 ? `direction=${direction}&` : ""}${startDate !== void 0 && startDate !== "" ? `start_date=${startDate}&` : ""}${endDate !== void 0 && endDate !== "" ? `end_date=${endDate}&` : ""}sort_by=${sortBy}&sort_order=${sortOrder}&limit=200`
|
|
211
216
|
);
|
|
212
217
|
var categorizeBankTransaction = put(
|
|
213
218
|
({ businessId, bankTransactionId }) => `/v1/businesses/${businessId}/bank-transactions/${bankTransactionId}/categorize`
|
|
@@ -548,6 +553,7 @@ var LayerContext = (0, import_react4.createContext)({
|
|
|
548
553
|
syncTimestamps: {},
|
|
549
554
|
readTimestamps: {},
|
|
550
555
|
hasBeenTouched: () => false,
|
|
556
|
+
expireDataCaches: () => void 0,
|
|
551
557
|
eventCallbacks: {}
|
|
552
558
|
});
|
|
553
559
|
var useLayerContext = () => (0, import_react4.useContext)(LayerContext);
|
|
@@ -604,9 +610,19 @@ var DEPENDENCIES = {
|
|
|
604
610
|
["CHART_OF_ACCOUNTS" /* CHART_OF_ACCOUNTS */]: ALL_TOUCHABLE,
|
|
605
611
|
["JOURNAL" /* JOURNAL */]: ALL_TOUCHABLE,
|
|
606
612
|
["LEDGER_ACCOUNTS" /* LEDGER_ACCOUNTS */]: ALL_TOUCHABLE,
|
|
607
|
-
["LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */]:
|
|
613
|
+
["LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */]: [
|
|
614
|
+
"BUSINESS" /* BUSINESS */,
|
|
615
|
+
"LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */,
|
|
616
|
+
"CHART_OF_ACCOUNTS" /* CHART_OF_ACCOUNTS */
|
|
617
|
+
],
|
|
608
618
|
["PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */]: ALL_TOUCHABLE,
|
|
609
|
-
["STATEMENT_OF_CASH_FLOWS" /* STATEMENT_OF_CASH_FLOWS */]: ALL_TOUCHABLE
|
|
619
|
+
["STATEMENT_OF_CASH_FLOWS" /* STATEMENT_OF_CASH_FLOWS */]: ALL_TOUCHABLE,
|
|
620
|
+
["BANK_TRANSACTIONS" /* BANK_TRANSACTIONS */]: [
|
|
621
|
+
"LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */,
|
|
622
|
+
"BANK_TRANSACTIONS" /* BANK_TRANSACTIONS */,
|
|
623
|
+
"BUSINESS" /* BUSINESS */,
|
|
624
|
+
"CHART_OF_ACCOUNTS" /* CHART_OF_ACCOUNTS */
|
|
625
|
+
]
|
|
610
626
|
};
|
|
611
627
|
var readTimestampsG = {};
|
|
612
628
|
var useDataSync = () => {
|
|
@@ -618,7 +634,8 @@ var useDataSync = () => {
|
|
|
618
634
|
["LEDGER_ACCOUNTS" /* LEDGER_ACCOUNTS */]: initialTimestamp,
|
|
619
635
|
["LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */]: initialTimestamp,
|
|
620
636
|
["PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */]: initialTimestamp,
|
|
621
|
-
["STATEMENT_OF_CASH_FLOWS" /* STATEMENT_OF_CASH_FLOWS */]: initialTimestamp
|
|
637
|
+
["STATEMENT_OF_CASH_FLOWS" /* STATEMENT_OF_CASH_FLOWS */]: initialTimestamp,
|
|
638
|
+
["BANK_TRANSACTIONS" /* BANK_TRANSACTIONS */]: initialTimestamp
|
|
622
639
|
});
|
|
623
640
|
const [readTimestamps, setReadTimestamps] = (0, import_react7.useState)({});
|
|
624
641
|
const touch = (model) => {
|
|
@@ -648,12 +665,26 @@ var useDataSync = () => {
|
|
|
648
665
|
})
|
|
649
666
|
);
|
|
650
667
|
};
|
|
668
|
+
const resetCaches = () => {
|
|
669
|
+
const now = Date.now();
|
|
670
|
+
setSyncTimestamps({
|
|
671
|
+
["BALANCE_SHEET" /* BALANCE_SHEET */]: now,
|
|
672
|
+
["CHART_OF_ACCOUNTS" /* CHART_OF_ACCOUNTS */]: now,
|
|
673
|
+
["JOURNAL" /* JOURNAL */]: now,
|
|
674
|
+
["LEDGER_ACCOUNTS" /* LEDGER_ACCOUNTS */]: now,
|
|
675
|
+
["LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */]: now,
|
|
676
|
+
["PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */]: now,
|
|
677
|
+
["STATEMENT_OF_CASH_FLOWS" /* STATEMENT_OF_CASH_FLOWS */]: now,
|
|
678
|
+
["BANK_TRANSACTIONS" /* BANK_TRANSACTIONS */]: now
|
|
679
|
+
});
|
|
680
|
+
};
|
|
651
681
|
return {
|
|
652
682
|
touch,
|
|
653
683
|
read,
|
|
654
684
|
syncTimestamps,
|
|
655
685
|
readTimestamps,
|
|
656
|
-
hasBeenTouched
|
|
686
|
+
hasBeenTouched,
|
|
687
|
+
resetCaches
|
|
657
688
|
};
|
|
658
689
|
};
|
|
659
690
|
|
|
@@ -679,18 +710,19 @@ var useDrawer = () => {
|
|
|
679
710
|
};
|
|
680
711
|
|
|
681
712
|
// src/providers/BankTransactionsProvider/BankTransactionsProvider.tsx
|
|
682
|
-
var
|
|
713
|
+
var import_react12 = __toESM(require("react"));
|
|
683
714
|
|
|
684
715
|
// src/contexts/BankTransactionsContext/BankTransactionsContext.tsx
|
|
685
716
|
var import_react9 = require("react");
|
|
686
717
|
|
|
687
718
|
// src/types/bank_transactions.ts
|
|
688
|
-
var Direction = /* @__PURE__ */ ((
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
return
|
|
719
|
+
var Direction = /* @__PURE__ */ ((Direction2) => {
|
|
720
|
+
Direction2["CREDIT"] = "CREDIT";
|
|
721
|
+
Direction2["DEBIT"] = "DEBIT";
|
|
722
|
+
return Direction2;
|
|
692
723
|
})(Direction || {});
|
|
693
724
|
var DisplayState = /* @__PURE__ */ ((DisplayState2) => {
|
|
725
|
+
DisplayState2["all"] = "all";
|
|
694
726
|
DisplayState2["review"] = "review";
|
|
695
727
|
DisplayState2["categorized"] = "categorized";
|
|
696
728
|
return DisplayState2;
|
|
@@ -719,6 +751,7 @@ var BankTransactionsContext = (0, import_react9.createContext)({
|
|
|
719
751
|
pagination: void 0
|
|
720
752
|
},
|
|
721
753
|
updateOneLocal: () => void 0,
|
|
754
|
+
shouldHideAfterCategorize: () => false,
|
|
722
755
|
removeAfterCategorize: () => void 0,
|
|
723
756
|
activate: () => void 0,
|
|
724
757
|
display: "review" /* review */,
|
|
@@ -729,7 +762,7 @@ var BankTransactionsContext = (0, import_react9.createContext)({
|
|
|
729
762
|
var useBankTransactionsContext = () => (0, import_react9.useContext)(BankTransactionsContext);
|
|
730
763
|
|
|
731
764
|
// src/hooks/useBankTransactions/useBankTransactions.tsx
|
|
732
|
-
var
|
|
765
|
+
var import_react11 = require("react");
|
|
733
766
|
|
|
734
767
|
// src/components/BankTransactions/constants.ts
|
|
735
768
|
var CategorizedCategories = [
|
|
@@ -743,1262 +776,1287 @@ var ReviewCategories = [
|
|
|
743
776
|
"LAYER_REVIEW" /* LAYER_REVIEW */
|
|
744
777
|
];
|
|
745
778
|
|
|
746
|
-
// src/
|
|
747
|
-
var
|
|
748
|
-
|
|
749
|
-
bankTransaction.categorization_status
|
|
750
|
-
);
|
|
751
|
-
const inReview = ReviewCategories.includes(
|
|
752
|
-
bankTransaction.categorization_status
|
|
753
|
-
);
|
|
754
|
-
return scope === "review" /* review */ && inReview || scope === "categorized" /* categorized */ && categorized;
|
|
755
|
-
};
|
|
756
|
-
var isCategorized = (bankTransaction) => CategorizedCategories.includes(bankTransaction.categorization_status);
|
|
779
|
+
// src/hooks/useLinkedAccounts/useLinkedAccounts.ts
|
|
780
|
+
var import_react10 = require("react");
|
|
781
|
+
var import_react_plaid_link = require("react-plaid-link");
|
|
757
782
|
|
|
758
|
-
// src/hooks/
|
|
759
|
-
var
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
783
|
+
// src/hooks/useLinkedAccounts/mockData.ts
|
|
784
|
+
var LINKED_ACCOUNTS_MOCK_DATA = [
|
|
785
|
+
{
|
|
786
|
+
id: "d800ada8-8075-4436-a712-08efabcbd51a",
|
|
787
|
+
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
788
|
+
external_account_source: "PLAID",
|
|
789
|
+
external_account_name: "Citi Double Cash\xAE Card",
|
|
790
|
+
mask: "1234",
|
|
791
|
+
latest_balance_timestamp: {
|
|
792
|
+
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
793
|
+
external_account_source: "PLAID",
|
|
794
|
+
balance: 435121,
|
|
795
|
+
at: "2024-04-03T13:00:00Z",
|
|
796
|
+
created_at: "2024-04-06T22:47:59.715458Z"
|
|
797
|
+
},
|
|
798
|
+
current_ledger_balance: 373717,
|
|
799
|
+
institution: {
|
|
800
|
+
name: "Chase",
|
|
801
|
+
logo: ""
|
|
802
|
+
},
|
|
803
|
+
connection_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
804
|
+
connection_external_id: "11111",
|
|
805
|
+
connection_needs_repair_as_of: null,
|
|
806
|
+
requires_user_confirmation_as_of: null,
|
|
807
|
+
is_syncing: true
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
id: "f98ec50a-c370-484d-a35b-d00207436075",
|
|
811
|
+
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
812
|
+
external_account_source: "PLAID",
|
|
813
|
+
external_account_name: "Citi Double Cash\xAE Card",
|
|
814
|
+
mask: "1234",
|
|
815
|
+
latest_balance_timestamp: {
|
|
816
|
+
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
817
|
+
external_account_source: "PLAID",
|
|
818
|
+
balance: 435121,
|
|
819
|
+
at: "2024-04-03T13:00:00Z",
|
|
820
|
+
created_at: "2024-04-06T16:44:35.715458Z"
|
|
821
|
+
},
|
|
822
|
+
current_ledger_balance: 373717,
|
|
823
|
+
institution: {
|
|
824
|
+
name: "Chase",
|
|
825
|
+
logo: ""
|
|
826
|
+
},
|
|
827
|
+
connection_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
828
|
+
connection_external_id: "11111",
|
|
829
|
+
connection_needs_repair_as_of: null,
|
|
830
|
+
requires_user_confirmation_as_of: null,
|
|
831
|
+
is_syncing: false
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
id: "843f1748-fdaa-422d-a73d-2489a40c8dc7",
|
|
835
|
+
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
836
|
+
external_account_source: "PLAID",
|
|
837
|
+
external_account_name: "Citi Double Cash\xAE Card",
|
|
838
|
+
mask: "1234",
|
|
839
|
+
latest_balance_timestamp: {
|
|
840
|
+
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
841
|
+
external_account_source: "PLAID",
|
|
842
|
+
balance: 435121,
|
|
843
|
+
at: "2024-04-03T13:00:00Z",
|
|
844
|
+
created_at: "2024-04-06T16:44:35.715458Z"
|
|
845
|
+
},
|
|
846
|
+
current_ledger_balance: 373717,
|
|
847
|
+
institution: {
|
|
848
|
+
name: "Chase",
|
|
849
|
+
logo: ""
|
|
850
|
+
},
|
|
851
|
+
connection_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
852
|
+
connection_external_id: "11111",
|
|
853
|
+
connection_needs_repair_as_of: "2024-03-06T16:44:35.715458Z",
|
|
854
|
+
requires_user_confirmation_as_of: null,
|
|
855
|
+
is_syncing: false
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
id: "8f430e29-e339-4d71-a08a-fce469c7a7c1",
|
|
859
|
+
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
860
|
+
external_account_source: "PLAID",
|
|
861
|
+
external_account_name: "Citi Double Cash\xAE Card",
|
|
862
|
+
mask: "1234",
|
|
863
|
+
latest_balance_timestamp: {
|
|
864
|
+
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
865
|
+
external_account_source: "PLAID",
|
|
866
|
+
balance: 435121,
|
|
867
|
+
at: "2024-04-03T13:00:00Z",
|
|
868
|
+
created_at: "2024-04-06T16:44:35.715458Z"
|
|
869
|
+
},
|
|
870
|
+
current_ledger_balance: 373717,
|
|
871
|
+
institution: {
|
|
872
|
+
name: "Chase",
|
|
873
|
+
logo: ""
|
|
874
|
+
},
|
|
875
|
+
connection_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
876
|
+
connection_external_id: "11111",
|
|
877
|
+
connection_needs_repair_as_of: null,
|
|
878
|
+
requires_user_confirmation_as_of: "2024-03-06T16:44:35.715458Z",
|
|
879
|
+
is_syncing: false
|
|
801
880
|
}
|
|
802
|
-
|
|
803
|
-
(tx) => filterVisibility(filter, tx) || filter === "review" /* review */ && tx.recently_categorized || filter === "categorized" /* categorized */ && tx.recently_categorized
|
|
804
|
-
);
|
|
805
|
-
};
|
|
806
|
-
var appplyDateRangeFilter = (data, filter) => {
|
|
807
|
-
return data?.filter((x) => {
|
|
808
|
-
const txDate = (0, import_date_fns.parseISO)(x.date);
|
|
809
|
-
if (filter?.startDate && filter?.endDate) {
|
|
810
|
-
return txDate >= filter.startDate && txDate <= filter.endDate;
|
|
811
|
-
}
|
|
812
|
-
if (filter?.startDate) {
|
|
813
|
-
return txDate >= filter.startDate;
|
|
814
|
-
}
|
|
815
|
-
if (filter?.endDate) {
|
|
816
|
-
return txDate <= filter.endDate;
|
|
817
|
-
}
|
|
818
|
-
});
|
|
819
|
-
};
|
|
881
|
+
];
|
|
820
882
|
|
|
821
|
-
// src/hooks/
|
|
822
|
-
var
|
|
823
|
-
var
|
|
883
|
+
// src/hooks/useLinkedAccounts/useLinkedAccounts.ts
|
|
884
|
+
var import_swr = __toESM(require("swr"));
|
|
885
|
+
var DEBUG = true;
|
|
886
|
+
var USE_MOCK_RESPONSE_DATA = false;
|
|
887
|
+
var useLinkedAccounts = () => {
|
|
824
888
|
const {
|
|
825
889
|
auth,
|
|
826
890
|
businessId,
|
|
827
891
|
apiUrl,
|
|
828
|
-
|
|
892
|
+
usePlaidSandbox,
|
|
829
893
|
touch,
|
|
830
894
|
read,
|
|
831
895
|
syncTimestamps,
|
|
832
|
-
hasBeenTouched
|
|
833
|
-
eventCallbacks
|
|
896
|
+
hasBeenTouched
|
|
834
897
|
} = useLayerContext();
|
|
835
|
-
const
|
|
836
|
-
const [filters, setTheFilters] = (0, import_react10.useState)(
|
|
837
|
-
scope ? { categorizationStatus: scope } : void 0
|
|
838
|
-
);
|
|
839
|
-
const display = (0, import_react10.useMemo)(() => {
|
|
840
|
-
if (filters?.categorizationStatus === "review" /* review */) {
|
|
841
|
-
return "review" /* review */;
|
|
842
|
-
}
|
|
843
|
-
return "categorized" /* categorized */;
|
|
844
|
-
}, [filters?.categorizationStatus]);
|
|
845
|
-
const [active, setActive] = (0, import_react10.useState)(false);
|
|
898
|
+
const [linkToken, setLinkToken] = (0, import_react10.useState)(null);
|
|
846
899
|
const [loadingStatus, setLoadingStatus] = (0, import_react10.useState)("initial");
|
|
847
|
-
const
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
}
|
|
851
|
-
if (!prevData?.meta?.pagination?.cursor) {
|
|
852
|
-
return [
|
|
853
|
-
businessId && auth?.access_token && `bank-transactions-${businessId}`,
|
|
854
|
-
void 0
|
|
855
|
-
];
|
|
856
|
-
}
|
|
857
|
-
return [
|
|
858
|
-
businessId && auth?.access_token && `bank-transactions-${businessId}-${prevData.meta.pagination.cursor}`,
|
|
859
|
-
prevData.meta.pagination.cursor
|
|
860
|
-
];
|
|
861
|
-
};
|
|
900
|
+
const USE_PLAID_SANDBOX = usePlaidSandbox ?? true;
|
|
901
|
+
const [linkMode, setLinkMode] = (0, import_react10.useState)("add");
|
|
902
|
+
const queryKey = businessId && auth?.access_token && `linked-accounts-${businessId}`;
|
|
862
903
|
const {
|
|
863
|
-
data:
|
|
904
|
+
data: responseData,
|
|
864
905
|
isLoading,
|
|
865
906
|
isValidating,
|
|
866
907
|
error: responseError,
|
|
867
|
-
mutate
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
if (auth?.access_token) {
|
|
874
|
-
return Layer.getBankTransactions(apiUrl, auth?.access_token, {
|
|
875
|
-
params: {
|
|
876
|
-
businessId,
|
|
877
|
-
cursor: nextCursor
|
|
878
|
-
}
|
|
879
|
-
}).call(false);
|
|
880
|
-
}
|
|
881
|
-
return {};
|
|
882
|
-
},
|
|
883
|
-
{
|
|
884
|
-
initialSize: 1,
|
|
885
|
-
revalidateFirstPage: false
|
|
886
|
-
}
|
|
887
|
-
);
|
|
888
|
-
const data = (0, import_react10.useMemo)(() => {
|
|
889
|
-
if (rawResponseData && rawResponseData.length > 0) {
|
|
890
|
-
return rawResponseData?.map((x) => x?.data).flat().filter((x) => !!x);
|
|
891
|
-
}
|
|
892
|
-
return void 0;
|
|
893
|
-
}, [rawResponseData]);
|
|
894
|
-
const lastMetadata = (0, import_react10.useMemo)(() => {
|
|
895
|
-
if (rawResponseData && rawResponseData.length > 0) {
|
|
896
|
-
return rawResponseData[rawResponseData.length - 1].meta;
|
|
897
|
-
}
|
|
898
|
-
return void 0;
|
|
899
|
-
}, [rawResponseData]);
|
|
900
|
-
const hasMore = (0, import_react10.useMemo)(() => {
|
|
901
|
-
if (rawResponseData && rawResponseData.length > 0) {
|
|
902
|
-
const lastElement = rawResponseData[rawResponseData.length - 1];
|
|
903
|
-
return Boolean(
|
|
904
|
-
lastElement.meta?.pagination?.cursor && lastElement.meta?.pagination?.has_more
|
|
905
|
-
);
|
|
906
|
-
}
|
|
907
|
-
return false;
|
|
908
|
-
}, [rawResponseData]);
|
|
909
|
-
const accountsList = (0, import_react10.useMemo)(
|
|
910
|
-
() => data ? collectAccounts(data) : [],
|
|
911
|
-
[data]
|
|
908
|
+
mutate
|
|
909
|
+
} = (0, import_swr.default)(
|
|
910
|
+
queryKey,
|
|
911
|
+
Layer.getLinkedAccounts(apiUrl, auth?.access_token, {
|
|
912
|
+
params: { businessId }
|
|
913
|
+
})
|
|
912
914
|
);
|
|
913
915
|
(0, import_react10.useEffect)(() => {
|
|
916
|
+
if (!isLoading && responseData?.data.external_accounts) {
|
|
917
|
+
setLoadingStatus("complete");
|
|
918
|
+
return;
|
|
919
|
+
}
|
|
914
920
|
if (isLoading && loadingStatus === "initial") {
|
|
915
921
|
setLoadingStatus("loading");
|
|
916
922
|
return;
|
|
917
923
|
}
|
|
918
924
|
if (!isLoading && loadingStatus === "loading") {
|
|
919
925
|
setLoadingStatus("complete");
|
|
920
|
-
return;
|
|
921
926
|
}
|
|
922
927
|
}, [isLoading]);
|
|
923
|
-
const
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
});
|
|
931
|
-
};
|
|
932
|
-
const filteredData = (0, import_react10.useMemo)(() => {
|
|
933
|
-
let filtered = data;
|
|
934
|
-
if (!filtered) {
|
|
935
|
-
return;
|
|
936
|
-
}
|
|
937
|
-
if (filters?.amount?.min || filters?.amount?.max) {
|
|
938
|
-
filtered = applyAmountFilter(filtered, filters.amount);
|
|
928
|
+
const fetchPlaidLinkToken = async () => {
|
|
929
|
+
if (auth?.access_token) {
|
|
930
|
+
const linkToken2 = (await Layer.getPlaidLinkToken(apiUrl, auth.access_token, {
|
|
931
|
+
params: { businessId }
|
|
932
|
+
})).data.link_token;
|
|
933
|
+
setLinkMode("add");
|
|
934
|
+
setLinkToken(linkToken2);
|
|
939
935
|
}
|
|
940
|
-
|
|
941
|
-
|
|
936
|
+
};
|
|
937
|
+
const fetchPlaidUpdateModeLinkToken = async (plaidItemPlaidId) => {
|
|
938
|
+
if (auth?.access_token) {
|
|
939
|
+
const linkToken2 = (await Layer.getPlaidUpdateModeLinkToken(apiUrl, auth.access_token, {
|
|
940
|
+
params: { businessId },
|
|
941
|
+
body: { plaid_item_id: plaidItemPlaidId }
|
|
942
|
+
})).data.link_token;
|
|
943
|
+
setLinkMode("update");
|
|
944
|
+
setLinkToken(linkToken2);
|
|
942
945
|
}
|
|
943
|
-
|
|
944
|
-
|
|
946
|
+
};
|
|
947
|
+
const exchangePlaidPublicToken2 = async (publicToken, metadata) => {
|
|
948
|
+
await Layer.exchangePlaidPublicToken(apiUrl, auth?.access_token, {
|
|
949
|
+
params: { businessId },
|
|
950
|
+
body: { public_token: publicToken, institution: metadata.institution }
|
|
951
|
+
});
|
|
952
|
+
refetchAccounts();
|
|
953
|
+
};
|
|
954
|
+
const { open: plaidLinkStart, ready: plaidLinkReady } = (0, import_react_plaid_link.usePlaidLink)({
|
|
955
|
+
token: linkToken,
|
|
956
|
+
// If in update mode, we don't need to exchange the public token for an access token.
|
|
957
|
+
// The existing access token will automatically become valid again
|
|
958
|
+
onSuccess: async (publicToken, metadata) => {
|
|
959
|
+
if (linkMode == "add") {
|
|
960
|
+
exchangePlaidPublicToken2(publicToken, metadata);
|
|
961
|
+
} else {
|
|
962
|
+
await updateConnectionStatus2();
|
|
963
|
+
refetchAccounts();
|
|
964
|
+
setLinkMode("add");
|
|
965
|
+
touch("LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */);
|
|
966
|
+
}
|
|
967
|
+
},
|
|
968
|
+
onExit: () => setLinkMode("add"),
|
|
969
|
+
env: USE_PLAID_SANDBOX ? "sandbox" : void 0
|
|
970
|
+
});
|
|
971
|
+
(0, import_react10.useEffect)(() => {
|
|
972
|
+
if (plaidLinkReady) {
|
|
973
|
+
plaidLinkStart();
|
|
945
974
|
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
975
|
+
}, [plaidLinkStart, plaidLinkReady]);
|
|
976
|
+
const mockResponseData = {
|
|
977
|
+
data: LINKED_ACCOUNTS_MOCK_DATA,
|
|
978
|
+
meta: {},
|
|
979
|
+
error: void 0
|
|
980
|
+
};
|
|
981
|
+
const addConnection = (source) => {
|
|
982
|
+
if (source === "PLAID") {
|
|
983
|
+
fetchPlaidLinkToken();
|
|
984
|
+
} else {
|
|
985
|
+
console.error(
|
|
986
|
+
`Adding a connection with source ${source} not yet supported`
|
|
950
987
|
);
|
|
951
988
|
}
|
|
952
|
-
|
|
953
|
-
|
|
989
|
+
};
|
|
990
|
+
const repairConnection = async (source, connectionExternalId) => {
|
|
991
|
+
if (source === "PLAID") {
|
|
992
|
+
await fetchPlaidUpdateModeLinkToken(connectionExternalId);
|
|
993
|
+
} else {
|
|
994
|
+
console.error(
|
|
995
|
+
`Repairing a connection with source ${source} not yet supported`
|
|
996
|
+
);
|
|
954
997
|
}
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
998
|
+
};
|
|
999
|
+
const removeConnection = async (source, connectionExternalId) => {
|
|
1000
|
+
if (source === "PLAID") {
|
|
1001
|
+
await unlinkPlaidItem2(connectionExternalId);
|
|
1002
|
+
await refetchAccounts();
|
|
1003
|
+
} else {
|
|
1004
|
+
console.error(
|
|
1005
|
+
`Removing a connection with source ${source} not yet supported`
|
|
1006
|
+
);
|
|
961
1007
|
}
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
if (newBT?.recently_categorized === true && notify) {
|
|
975
|
-
addToast({ content: "Transaction saved" });
|
|
976
|
-
}
|
|
977
|
-
}).catch((err) => {
|
|
978
|
-
const newBT = data?.find(
|
|
979
|
-
(x) => x.business_id === businessId && x.id === id
|
|
1008
|
+
};
|
|
1009
|
+
const unlinkAccount2 = async (source, accountId) => {
|
|
1010
|
+
DEBUG && console.log("unlinking account");
|
|
1011
|
+
if (source === "PLAID") {
|
|
1012
|
+
await Layer.unlinkAccount(apiUrl, auth?.access_token, {
|
|
1013
|
+
params: { businessId, accountId }
|
|
1014
|
+
});
|
|
1015
|
+
await refetchAccounts();
|
|
1016
|
+
touch("LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */);
|
|
1017
|
+
} else {
|
|
1018
|
+
console.error(
|
|
1019
|
+
`Unlinking an account with source ${source} not yet supported`
|
|
980
1020
|
);
|
|
981
|
-
|
|
982
|
-
updateOneLocal({
|
|
983
|
-
...newBT,
|
|
984
|
-
error: err.message,
|
|
985
|
-
processing: false
|
|
986
|
-
});
|
|
987
|
-
}
|
|
988
|
-
}).finally(() => {
|
|
989
|
-
touch("BANK_TRANSACTIONS" /* BANK_TRANSACTIONS */);
|
|
990
|
-
eventCallbacks?.onTransactionCategorized?.(id);
|
|
991
|
-
});
|
|
1021
|
+
}
|
|
992
1022
|
};
|
|
993
|
-
const
|
|
994
|
-
|
|
995
|
-
if (
|
|
996
|
-
|
|
1023
|
+
const confirmAccount = async (source, accountId) => {
|
|
1024
|
+
DEBUG && console.log("confirming account");
|
|
1025
|
+
if (source === "PLAID") {
|
|
1026
|
+
await Layer.confirmConnection(apiUrl, auth?.access_token, {
|
|
1027
|
+
params: {
|
|
1028
|
+
businessId,
|
|
1029
|
+
accountId
|
|
1030
|
+
}
|
|
1031
|
+
});
|
|
1032
|
+
await refetchAccounts();
|
|
1033
|
+
touch("LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */);
|
|
1034
|
+
} else {
|
|
1035
|
+
console.error(
|
|
1036
|
+
`Confirming an account with source ${source} not yet supported`
|
|
1037
|
+
);
|
|
997
1038
|
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1039
|
+
};
|
|
1040
|
+
const denyAccount = async (source, accountId) => {
|
|
1041
|
+
DEBUG && console.log("confirming account");
|
|
1042
|
+
if (source === "PLAID") {
|
|
1043
|
+
await Layer.denyConnection(apiUrl, auth?.access_token, {
|
|
1044
|
+
params: {
|
|
1045
|
+
businessId,
|
|
1046
|
+
accountId
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
await refetchAccounts();
|
|
1050
|
+
touch("LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */);
|
|
1051
|
+
} else {
|
|
1052
|
+
console.error(
|
|
1053
|
+
`Denying an account with source ${source} not yet supported`
|
|
1004
1054
|
);
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1055
|
+
}
|
|
1056
|
+
};
|
|
1057
|
+
const breakConnection = async (source, connectionExternalId) => {
|
|
1058
|
+
DEBUG && console.log("Breaking sandbox plaid item connection");
|
|
1059
|
+
if (source === "PLAID") {
|
|
1060
|
+
await Layer.breakPlaidItemConnection(apiUrl, auth?.access_token, {
|
|
1061
|
+
params: {
|
|
1062
|
+
businessId,
|
|
1063
|
+
plaidItemPlaidId: connectionExternalId
|
|
1064
|
+
}
|
|
1065
|
+
});
|
|
1066
|
+
await refetchAccounts();
|
|
1067
|
+
touch("LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */);
|
|
1068
|
+
} else {
|
|
1069
|
+
console.error(
|
|
1070
|
+
`Breaking a sandbox connection with source ${source} not yet supported`
|
|
1021
1071
|
);
|
|
1022
|
-
|
|
1023
|
-
updateOneLocal({
|
|
1024
|
-
...newBT,
|
|
1025
|
-
error: err.message,
|
|
1026
|
-
processing: false
|
|
1027
|
-
});
|
|
1028
|
-
}
|
|
1029
|
-
}).finally(() => {
|
|
1030
|
-
touch("BANK_TRANSACTIONS" /* BANK_TRANSACTIONS */);
|
|
1031
|
-
eventCallbacks?.onTransactionCategorized?.(id);
|
|
1032
|
-
});
|
|
1072
|
+
}
|
|
1033
1073
|
};
|
|
1034
|
-
const
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
...page,
|
|
1038
|
-
data: page.data?.map(
|
|
1039
|
-
(bt) => bt.id === newBankTransaction.id ? newBankTransaction : bt
|
|
1040
|
-
)
|
|
1041
|
-
};
|
|
1042
|
-
});
|
|
1043
|
-
mutate(updatedData, { revalidate: false });
|
|
1074
|
+
const refetchAccounts = async () => {
|
|
1075
|
+
DEBUG && console.log("refetching accounts...");
|
|
1076
|
+
await mutate();
|
|
1044
1077
|
};
|
|
1045
|
-
const
|
|
1078
|
+
const syncAccounts = async () => {
|
|
1079
|
+
DEBUG && console.log("resyncing accounts...");
|
|
1080
|
+
await Layer.syncConnection(apiUrl, auth?.access_token, {
|
|
1081
|
+
params: { businessId }
|
|
1082
|
+
});
|
|
1046
1083
|
};
|
|
1047
|
-
const
|
|
1048
|
-
|
|
1084
|
+
const updateConnectionStatus2 = async () => {
|
|
1085
|
+
DEBUG && console.log("updating connection status...");
|
|
1086
|
+
await Layer.updateConnectionStatus(apiUrl, auth?.access_token, {
|
|
1087
|
+
params: { businessId }
|
|
1088
|
+
});
|
|
1049
1089
|
};
|
|
1050
|
-
const
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1090
|
+
const unlinkPlaidItem2 = async (plaidItemPlaidId) => {
|
|
1091
|
+
DEBUG && console.log("unlinking plaid item");
|
|
1092
|
+
await Layer.unlinkPlaidItem(apiUrl, auth?.access_token, {
|
|
1093
|
+
params: { businessId, plaidItemPlaidId }
|
|
1094
|
+
});
|
|
1095
|
+
await refetchAccounts();
|
|
1096
|
+
touch("LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */);
|
|
1054
1097
|
};
|
|
1055
1098
|
(0, import_react10.useEffect)(() => {
|
|
1056
|
-
if (isLoading || isValidating) {
|
|
1057
|
-
read("
|
|
1099
|
+
if (queryKey && (isLoading || isValidating)) {
|
|
1100
|
+
read("LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */, queryKey);
|
|
1058
1101
|
}
|
|
1059
1102
|
}, [isLoading, isValidating]);
|
|
1060
1103
|
(0, import_react10.useEffect)(() => {
|
|
1061
|
-
if (hasBeenTouched(
|
|
1062
|
-
|
|
1104
|
+
if (queryKey && hasBeenTouched(queryKey)) {
|
|
1105
|
+
refetchAccounts();
|
|
1063
1106
|
}
|
|
1064
1107
|
}, [syncTimestamps]);
|
|
1065
1108
|
return {
|
|
1066
|
-
data:
|
|
1067
|
-
metadata: lastMetadata,
|
|
1068
|
-
loadingStatus,
|
|
1109
|
+
data: USE_MOCK_RESPONSE_DATA ? mockResponseData.data : responseData?.data.external_accounts,
|
|
1069
1110
|
isLoading,
|
|
1111
|
+
loadingStatus,
|
|
1070
1112
|
isValidating,
|
|
1071
|
-
refetch,
|
|
1072
1113
|
error: responseError,
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
hasMore
|
|
1114
|
+
addConnection,
|
|
1115
|
+
removeConnection,
|
|
1116
|
+
repairConnection,
|
|
1117
|
+
refetchAccounts,
|
|
1118
|
+
unlinkAccount: unlinkAccount2,
|
|
1119
|
+
confirmAccount,
|
|
1120
|
+
denyAccount,
|
|
1121
|
+
breakConnection,
|
|
1122
|
+
syncAccounts,
|
|
1123
|
+
updateConnectionStatus: updateConnectionStatus2
|
|
1084
1124
|
};
|
|
1085
1125
|
};
|
|
1086
1126
|
|
|
1087
|
-
// src/
|
|
1088
|
-
var
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
return /* @__PURE__ */ import_react11.default.createElement(BankTransactionsContext.Provider, { value: bankTransactionsContextData }, children);
|
|
1093
|
-
};
|
|
1094
|
-
|
|
1095
|
-
// src/config/theme.ts
|
|
1096
|
-
var SHADES = {
|
|
1097
|
-
50: { s: 1, l: 98 },
|
|
1098
|
-
100: { s: 1, l: 96 },
|
|
1099
|
-
200: { s: 1, l: 94 },
|
|
1100
|
-
300: { s: 2, l: 92 },
|
|
1101
|
-
500: { s: 5, l: 53 },
|
|
1102
|
-
600: { s: 7, l: 40 },
|
|
1103
|
-
700: { s: 9, l: 27 },
|
|
1104
|
-
800: { s: 12, l: 20 },
|
|
1105
|
-
1e3: { s: 20, l: 7 }
|
|
1106
|
-
};
|
|
1107
|
-
var COLORS = {
|
|
1108
|
-
dark: {
|
|
1109
|
-
h: 0,
|
|
1110
|
-
s: 0,
|
|
1111
|
-
l: 7
|
|
1112
|
-
},
|
|
1113
|
-
light: {
|
|
1114
|
-
h: 0,
|
|
1115
|
-
s: 0,
|
|
1116
|
-
l: 100
|
|
1127
|
+
// src/hooks/useBankTransactions/utils.ts
|
|
1128
|
+
var collectAccounts = (transactions) => {
|
|
1129
|
+
const accounts = [];
|
|
1130
|
+
if (!transactions) {
|
|
1131
|
+
return accounts;
|
|
1117
1132
|
}
|
|
1133
|
+
transactions.forEach((x) => {
|
|
1134
|
+
if (!accounts.find((y) => y.id === x.source_account_id)) {
|
|
1135
|
+
accounts.push({
|
|
1136
|
+
id: x.source_account_id,
|
|
1137
|
+
name: x.account_name || ""
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
});
|
|
1141
|
+
return accounts.sort((a, b) => a.name.localeCompare(b.name));
|
|
1142
|
+
};
|
|
1143
|
+
var applyAmountFilter = (data, filter) => {
|
|
1144
|
+
return data?.filter((x) => {
|
|
1145
|
+
if ((filter?.min || filter?.min === 0) && (filter?.max || filter?.max === 0)) {
|
|
1146
|
+
return x.amount >= filter.min * 100 && x.amount <= filter.max * 100;
|
|
1147
|
+
}
|
|
1148
|
+
if (filter?.min || filter?.min === 0) {
|
|
1149
|
+
return x.amount >= filter.min * 100;
|
|
1150
|
+
}
|
|
1151
|
+
if (filter?.max || filter?.max === 0) {
|
|
1152
|
+
return x.amount <= filter.max * 100;
|
|
1153
|
+
}
|
|
1154
|
+
});
|
|
1118
1155
|
};
|
|
1156
|
+
var applyAccountFilter = (data, filter) => data?.filter((x) => filter && filter.includes(x.source_account_id));
|
|
1119
1157
|
|
|
1120
|
-
// src/
|
|
1121
|
-
var
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1158
|
+
// src/hooks/useBankTransactions/useBankTransactions.tsx
|
|
1159
|
+
var import_infinite = __toESM(require("swr/infinite"));
|
|
1160
|
+
var INITIAL_POLL_INTERVAL_MS = 1e3;
|
|
1161
|
+
var POLL_INTERVAL_AFTER_TXNS_RECEIVED_MS = 5e3;
|
|
1162
|
+
function useTriggerOnChange(data, anyAccountSyncing, callback) {
|
|
1163
|
+
const prevDataRef = (0, import_react11.useRef)();
|
|
1164
|
+
(0, import_react11.useEffect)(() => {
|
|
1165
|
+
if (anyAccountSyncing && prevDataRef.current !== void 0 && prevDataRef.current !== data) {
|
|
1166
|
+
callback(data);
|
|
1167
|
+
}
|
|
1168
|
+
prevDataRef.current = data;
|
|
1169
|
+
}, [data, anyAccountSyncing, callback]);
|
|
1170
|
+
}
|
|
1171
|
+
var filtersSettingString = (filters) => {
|
|
1172
|
+
return `bank-transactions${filters?.categorizationStatus ? `-categorizationStatus-${filters.categorizationStatus}` : `-categorizationStatus-${"all" /* all */}`}${filters?.direction?.length === 1 ? `-direction-${filters.direction.join("-")}` : ""}${filters?.dateRange?.startDate ? `-startDate-${filters.dateRange.startDate.toISOString()}` : ""}${filters?.dateRange?.endDate ? `-endDate-${filters.dateRange.endDate.toISOString()}` : ""}`;
|
|
1133
1173
|
};
|
|
1134
|
-
var
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1174
|
+
var useBankTransactions = (params) => {
|
|
1175
|
+
const {
|
|
1176
|
+
auth,
|
|
1177
|
+
businessId,
|
|
1178
|
+
apiUrl,
|
|
1179
|
+
addToast,
|
|
1180
|
+
touch,
|
|
1181
|
+
read,
|
|
1182
|
+
syncTimestamps,
|
|
1183
|
+
hasBeenTouched,
|
|
1184
|
+
eventCallbacks
|
|
1185
|
+
} = useLayerContext();
|
|
1186
|
+
const { scope = void 0 } = params ?? {};
|
|
1187
|
+
const [filters, setTheFilters] = (0, import_react11.useState)(
|
|
1188
|
+
scope ? { categorizationStatus: scope } : void 0
|
|
1189
|
+
);
|
|
1190
|
+
const display = (0, import_react11.useMemo)(() => {
|
|
1191
|
+
if (filters?.categorizationStatus === "review" /* review */) {
|
|
1192
|
+
return "review" /* review */;
|
|
1193
|
+
} else if (filters?.categorizationStatus === "all" /* all */) {
|
|
1194
|
+
return "all" /* all */;
|
|
1141
1195
|
}
|
|
1142
|
-
return
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
return {};
|
|
1150
|
-
}
|
|
1151
|
-
try {
|
|
1152
|
-
if ("h" in color && "s" in color && "l" in color) {
|
|
1153
|
-
return {
|
|
1154
|
-
[`--color-${colorName}-h`]: color.h,
|
|
1155
|
-
[`--color-${colorName}-s`]: color.s,
|
|
1156
|
-
[`--color-${colorName}-l`]: color.l
|
|
1157
|
-
};
|
|
1196
|
+
return "categorized" /* categorized */;
|
|
1197
|
+
}, [filters?.categorizationStatus]);
|
|
1198
|
+
const [active, setActive] = (0, import_react11.useState)(false);
|
|
1199
|
+
const [loadingStatus, setLoadingStatus] = (0, import_react11.useState)("initial");
|
|
1200
|
+
const getKey = (index, prevData) => {
|
|
1201
|
+
if (!auth?.access_token || !active) {
|
|
1202
|
+
return [false, void 0];
|
|
1158
1203
|
}
|
|
1159
|
-
if (
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
[`--color-${colorName}-l`]: `${l}%`
|
|
1165
|
-
};
|
|
1204
|
+
if (index === 0) {
|
|
1205
|
+
return [
|
|
1206
|
+
businessId && auth?.access_token && `${filtersSettingString(filters)}-${businessId}`,
|
|
1207
|
+
void 0
|
|
1208
|
+
];
|
|
1166
1209
|
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1210
|
+
return [
|
|
1211
|
+
businessId && auth?.access_token && `${filtersSettingString(filters)}-${businessId}-${prevData?.meta?.pagination?.cursor}`,
|
|
1212
|
+
prevData?.meta?.pagination?.cursor.toString()
|
|
1213
|
+
];
|
|
1214
|
+
};
|
|
1215
|
+
const {
|
|
1216
|
+
data: rawResponseData,
|
|
1217
|
+
isLoading,
|
|
1218
|
+
isValidating,
|
|
1219
|
+
error: responseError,
|
|
1220
|
+
mutate,
|
|
1221
|
+
size,
|
|
1222
|
+
setSize
|
|
1223
|
+
} = (0, import_infinite.default)(
|
|
1224
|
+
getKey,
|
|
1225
|
+
async ([_query, nextCursor]) => {
|
|
1226
|
+
if (auth?.access_token) {
|
|
1227
|
+
return Layer.getBankTransactions(apiUrl, auth?.access_token, {
|
|
1228
|
+
params: {
|
|
1229
|
+
businessId,
|
|
1230
|
+
cursor: nextCursor ?? "",
|
|
1231
|
+
categorized: filters?.categorizationStatus ? filters?.categorizationStatus === "categorized" /* categorized */ ? "true" : filters?.categorizationStatus === "review" /* review */ ? "false" : "" : "",
|
|
1232
|
+
direction: filters?.direction?.length === 1 ? filters.direction[0] === "CREDIT" /* CREDIT */ ? "INFLOW" : "OUTFLOW" : void 0,
|
|
1233
|
+
startDate: filters?.dateRange?.startDate?.toISOString() ?? void 0,
|
|
1234
|
+
endDate: filters?.dateRange?.endDate?.toISOString() ?? void 0
|
|
1235
|
+
}
|
|
1236
|
+
}).call(false);
|
|
1171
1237
|
}
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
return {
|
|
1178
|
-
[`--color-${colorName}-h`]: h,
|
|
1179
|
-
[`--color-${colorName}-s`]: `${s}%`,
|
|
1180
|
-
[`--color-${colorName}-l`]: `${l}%`
|
|
1181
|
-
};
|
|
1238
|
+
return {};
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
initialSize: 1,
|
|
1242
|
+
revalidateFirstPage: false
|
|
1182
1243
|
}
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
};
|
|
1188
|
-
var parseColorFromThemeToHsl = (color) => {
|
|
1189
|
-
if (!color) {
|
|
1190
|
-
return;
|
|
1191
|
-
}
|
|
1192
|
-
try {
|
|
1193
|
-
if ("h" in color && "s" in color && "l" in color) {
|
|
1194
|
-
return {
|
|
1195
|
-
h: Number(color.h),
|
|
1196
|
-
s: Number(color.s),
|
|
1197
|
-
l: Number(color.l)
|
|
1198
|
-
};
|
|
1244
|
+
);
|
|
1245
|
+
const data = (0, import_react11.useMemo)(() => {
|
|
1246
|
+
if (rawResponseData && rawResponseData.length > 0) {
|
|
1247
|
+
return rawResponseData?.map((x) => x?.data).flat().filter((x) => !!x);
|
|
1199
1248
|
}
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
l
|
|
1206
|
-
};
|
|
1249
|
+
return void 0;
|
|
1250
|
+
}, [rawResponseData]);
|
|
1251
|
+
const lastMetadata = (0, import_react11.useMemo)(() => {
|
|
1252
|
+
if (rawResponseData && rawResponseData.length > 0) {
|
|
1253
|
+
return rawResponseData[rawResponseData.length - 1].meta;
|
|
1207
1254
|
}
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
b: rgb.b.toString()
|
|
1217
|
-
});
|
|
1218
|
-
return {
|
|
1219
|
-
h,
|
|
1220
|
-
s,
|
|
1221
|
-
l
|
|
1222
|
-
};
|
|
1255
|
+
return void 0;
|
|
1256
|
+
}, [rawResponseData]);
|
|
1257
|
+
const hasMore = (0, import_react11.useMemo)(() => {
|
|
1258
|
+
if (rawResponseData && rawResponseData.length > 0) {
|
|
1259
|
+
const lastElement = rawResponseData[rawResponseData.length - 1];
|
|
1260
|
+
return Boolean(
|
|
1261
|
+
lastElement.meta?.pagination?.cursor && lastElement.meta?.pagination?.has_more
|
|
1262
|
+
);
|
|
1223
1263
|
}
|
|
1224
|
-
return;
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
l: 100 * (2 * l - s) / 2
|
|
1264
|
+
return false;
|
|
1265
|
+
}, [rawResponseData]);
|
|
1266
|
+
const accountsList = (0, import_react11.useMemo)(
|
|
1267
|
+
() => data ? collectAccounts(data) : [],
|
|
1268
|
+
[data]
|
|
1269
|
+
);
|
|
1270
|
+
(0, import_react11.useEffect)(() => {
|
|
1271
|
+
if (isLoading && loadingStatus === "initial") {
|
|
1272
|
+
setLoadingStatus("loading");
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1275
|
+
if (!isLoading && loadingStatus === "loading") {
|
|
1276
|
+
setLoadingStatus("complete");
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
}, [isLoading]);
|
|
1280
|
+
const activate = () => {
|
|
1281
|
+
setActive(true);
|
|
1243
1282
|
};
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
).substring(1).match(/.{2}/g)?.map((x) => parseInt(x, 16));
|
|
1250
|
-
if (!values) {
|
|
1251
|
-
return;
|
|
1252
|
-
}
|
|
1253
|
-
return {
|
|
1254
|
-
r: values[0],
|
|
1255
|
-
g: values[1],
|
|
1256
|
-
b: values[2]
|
|
1283
|
+
const setFilters = (value) => {
|
|
1284
|
+
setTheFilters({
|
|
1285
|
+
...filters,
|
|
1286
|
+
...value ?? {}
|
|
1287
|
+
});
|
|
1257
1288
|
};
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1289
|
+
const filteredData = (0, import_react11.useMemo)(() => {
|
|
1290
|
+
let filtered = data;
|
|
1291
|
+
if (!filtered) {
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1294
|
+
if (filters?.amount?.min || filters?.amount?.max) {
|
|
1295
|
+
filtered = applyAmountFilter(filtered, filters.amount);
|
|
1296
|
+
}
|
|
1297
|
+
if (filters?.account) {
|
|
1298
|
+
filtered = applyAccountFilter(filtered, filters.account);
|
|
1299
|
+
}
|
|
1300
|
+
return filtered;
|
|
1301
|
+
}, [filters, data]);
|
|
1302
|
+
const categorize = (id, newCategory, notify) => {
|
|
1303
|
+
const foundBT = data?.find((x) => x.business_id === businessId && x.id === id);
|
|
1304
|
+
if (foundBT) {
|
|
1305
|
+
updateOneLocal({ ...foundBT, processing: true, error: void 0 });
|
|
1306
|
+
}
|
|
1307
|
+
return Layer.categorizeBankTransaction(apiUrl, auth.access_token, {
|
|
1308
|
+
params: { businessId, bankTransactionId: id },
|
|
1309
|
+
body: newCategory
|
|
1310
|
+
}).then(({ data: newBT, errors }) => {
|
|
1311
|
+
if (newBT) {
|
|
1312
|
+
newBT.recently_categorized = true;
|
|
1313
|
+
updateOneLocal(newBT);
|
|
1314
|
+
}
|
|
1315
|
+
if (errors) {
|
|
1316
|
+
console.error(errors);
|
|
1317
|
+
throw errors;
|
|
1318
|
+
}
|
|
1319
|
+
if (newBT?.recently_categorized === true && notify) {
|
|
1320
|
+
addToast({ content: "Transaction saved" });
|
|
1321
|
+
}
|
|
1322
|
+
}).catch((err) => {
|
|
1323
|
+
const newBT = data?.find(
|
|
1324
|
+
(x) => x.business_id === businessId && x.id === id
|
|
1325
|
+
);
|
|
1326
|
+
if (newBT) {
|
|
1327
|
+
updateOneLocal({
|
|
1328
|
+
...newBT,
|
|
1329
|
+
error: err.message,
|
|
1330
|
+
processing: false
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
}).finally(() => {
|
|
1334
|
+
touch("BANK_TRANSACTIONS" /* BANK_TRANSACTIONS */);
|
|
1335
|
+
eventCallbacks?.onTransactionCategorized?.(id);
|
|
1336
|
+
});
|
|
1337
|
+
};
|
|
1338
|
+
const match = (id, matchId, notify) => {
|
|
1339
|
+
const foundBT = data?.find((x) => x.business_id === businessId && x.id === id);
|
|
1340
|
+
if (foundBT) {
|
|
1341
|
+
updateOneLocal({ ...foundBT, processing: true, error: void 0 });
|
|
1342
|
+
}
|
|
1343
|
+
return Layer.matchBankTransaction(apiUrl, auth.access_token, {
|
|
1344
|
+
params: { businessId, bankTransactionId: id },
|
|
1345
|
+
body: { match_id: matchId, type: "Confirm_Match" /* CONFIRM_MATCH */ }
|
|
1346
|
+
}).then(({ data: bt, errors }) => {
|
|
1347
|
+
const newBT = data?.find(
|
|
1348
|
+
(x) => x.business_id === businessId && x.id === id
|
|
1349
|
+
);
|
|
1350
|
+
if (newBT) {
|
|
1351
|
+
newBT.recently_categorized = true;
|
|
1352
|
+
newBT.match = bt;
|
|
1353
|
+
newBT.categorization_status = "MATCHED" /* MATCHED */;
|
|
1354
|
+
updateOneLocal(newBT);
|
|
1355
|
+
}
|
|
1356
|
+
if (errors) {
|
|
1357
|
+
console.error(errors);
|
|
1358
|
+
throw errors;
|
|
1359
|
+
}
|
|
1360
|
+
if (newBT?.recently_categorized === true && notify) {
|
|
1361
|
+
addToast({ content: "Transaction saved" });
|
|
1362
|
+
}
|
|
1363
|
+
}).catch((err) => {
|
|
1364
|
+
const newBT = data?.find(
|
|
1365
|
+
(x) => x.business_id === businessId && x.id === id
|
|
1366
|
+
);
|
|
1367
|
+
if (newBT) {
|
|
1368
|
+
updateOneLocal({
|
|
1369
|
+
...newBT,
|
|
1370
|
+
error: err.message,
|
|
1371
|
+
processing: false
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
}).finally(() => {
|
|
1375
|
+
touch("BANK_TRANSACTIONS" /* BANK_TRANSACTIONS */);
|
|
1376
|
+
eventCallbacks?.onTransactionCategorized?.(id);
|
|
1377
|
+
});
|
|
1378
|
+
};
|
|
1379
|
+
const updateOneLocal = (newBankTransaction) => {
|
|
1380
|
+
const updatedData = rawResponseData?.map((page) => {
|
|
1381
|
+
return {
|
|
1382
|
+
...page,
|
|
1383
|
+
data: page.data?.map(
|
|
1384
|
+
(bt) => bt.id === newBankTransaction.id ? newBankTransaction : bt
|
|
1385
|
+
)
|
|
1386
|
+
};
|
|
1387
|
+
});
|
|
1388
|
+
mutate(updatedData, { revalidate: false });
|
|
1389
|
+
};
|
|
1390
|
+
const shouldHideAfterCategorize = (bankTransaction) => {
|
|
1391
|
+
return filters?.categorizationStatus === "review" /* review */ && ReviewCategories.includes(bankTransaction.categorization_status);
|
|
1392
|
+
};
|
|
1393
|
+
const removeAfterCategorize = (bankTransaction) => {
|
|
1394
|
+
if (shouldHideAfterCategorize(bankTransaction)) {
|
|
1395
|
+
const updatedData = rawResponseData?.map((page) => {
|
|
1396
|
+
return {
|
|
1397
|
+
...page,
|
|
1398
|
+
data: page.data?.filter((bt) => bt.id !== bankTransaction.id)
|
|
1399
|
+
};
|
|
1400
|
+
});
|
|
1401
|
+
mutate(updatedData, { revalidate: false });
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1404
|
+
const refetch = () => {
|
|
1405
|
+
mutate();
|
|
1406
|
+
};
|
|
1407
|
+
const fetchMore = () => {
|
|
1408
|
+
if (hasMore) {
|
|
1409
|
+
setSize(size + 1);
|
|
1410
|
+
}
|
|
1411
|
+
};
|
|
1412
|
+
const getCacheKey = (txnFilters) => {
|
|
1413
|
+
return filtersSettingString(txnFilters);
|
|
1414
|
+
};
|
|
1415
|
+
(0, import_react11.useEffect)(() => {
|
|
1416
|
+
if (isLoading || isValidating) {
|
|
1417
|
+
read("BANK_TRANSACTIONS" /* BANK_TRANSACTIONS */, getCacheKey(filters));
|
|
1418
|
+
}
|
|
1419
|
+
}, [isLoading, isValidating]);
|
|
1420
|
+
(0, import_react11.useEffect)(() => {
|
|
1421
|
+
if (hasBeenTouched(getCacheKey(filters))) {
|
|
1422
|
+
refetch();
|
|
1423
|
+
}
|
|
1424
|
+
}, [syncTimestamps, filters]);
|
|
1425
|
+
const { data: linkedAccounts, refetchAccounts } = useLinkedAccounts();
|
|
1426
|
+
const anyAccountSyncing = (0, import_react11.useMemo)(
|
|
1427
|
+
() => Boolean(linkedAccounts?.some((item) => item.is_syncing)),
|
|
1428
|
+
[linkedAccounts]
|
|
1429
|
+
);
|
|
1430
|
+
const [pollIntervalMs, setPollIntervalMs] = (0, import_react11.useState)(INITIAL_POLL_INTERVAL_MS);
|
|
1431
|
+
const transactionsNotSynced = (0, import_react11.useMemo)(
|
|
1432
|
+
() => loadingStatus === "complete" && anyAccountSyncing && (!data || data?.length === 0),
|
|
1433
|
+
[data, anyAccountSyncing, loadingStatus]
|
|
1434
|
+
);
|
|
1435
|
+
let intervalId = void 0;
|
|
1436
|
+
const [refreshTrigger, setRefreshTrigger] = (0, import_react11.useState)(-1);
|
|
1437
|
+
(0, import_react11.useEffect)(() => {
|
|
1438
|
+
if (refreshTrigger !== -1) {
|
|
1439
|
+
refetch();
|
|
1440
|
+
refetchAccounts();
|
|
1441
|
+
}
|
|
1442
|
+
}, [refreshTrigger]);
|
|
1443
|
+
(0, import_react11.useEffect)(() => {
|
|
1444
|
+
if (anyAccountSyncing) {
|
|
1445
|
+
intervalId = setInterval(() => {
|
|
1446
|
+
setRefreshTrigger(Math.random());
|
|
1447
|
+
}, pollIntervalMs);
|
|
1448
|
+
} else {
|
|
1449
|
+
if (intervalId) {
|
|
1450
|
+
clearInterval(intervalId);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
return () => {
|
|
1454
|
+
if (intervalId) {
|
|
1455
|
+
clearInterval(intervalId);
|
|
1456
|
+
}
|
|
1457
|
+
};
|
|
1458
|
+
}, [anyAccountSyncing, transactionsNotSynced, pollIntervalMs]);
|
|
1459
|
+
useTriggerOnChange(data, anyAccountSyncing, (newTransactionList) => {
|
|
1460
|
+
clearInterval(intervalId);
|
|
1461
|
+
setPollIntervalMs(POLL_INTERVAL_AFTER_TXNS_RECEIVED_MS);
|
|
1462
|
+
touch("BANK_TRANSACTIONS" /* BANK_TRANSACTIONS */);
|
|
1463
|
+
});
|
|
1262
1464
|
return {
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1465
|
+
data: filteredData,
|
|
1466
|
+
metadata: lastMetadata,
|
|
1467
|
+
loadingStatus,
|
|
1468
|
+
isLoading,
|
|
1469
|
+
isValidating,
|
|
1470
|
+
refetch,
|
|
1471
|
+
error: responseError,
|
|
1472
|
+
categorize,
|
|
1473
|
+
match,
|
|
1474
|
+
updateOneLocal,
|
|
1475
|
+
shouldHideAfterCategorize,
|
|
1476
|
+
removeAfterCategorize,
|
|
1477
|
+
filters,
|
|
1478
|
+
setFilters,
|
|
1479
|
+
accountsList,
|
|
1480
|
+
activate,
|
|
1481
|
+
display,
|
|
1482
|
+
fetchMore,
|
|
1483
|
+
hasMore
|
|
1282
1484
|
};
|
|
1283
1485
|
};
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1486
|
+
|
|
1487
|
+
// src/providers/BankTransactionsProvider/BankTransactionsProvider.tsx
|
|
1488
|
+
var BankTransactionsProvider = ({
|
|
1489
|
+
children
|
|
1490
|
+
}) => {
|
|
1491
|
+
const bankTransactionsContextData = useBankTransactions();
|
|
1492
|
+
return /* @__PURE__ */ import_react12.default.createElement(BankTransactionsContext.Provider, { value: bankTransactionsContextData }, children);
|
|
1289
1493
|
};
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1494
|
+
|
|
1495
|
+
// src/config/theme.ts
|
|
1496
|
+
var SHADES = {
|
|
1497
|
+
50: { s: 1, l: 98 },
|
|
1498
|
+
100: { s: 1, l: 96 },
|
|
1499
|
+
200: { s: 1, l: 94 },
|
|
1500
|
+
300: { s: 2, l: 92 },
|
|
1501
|
+
500: { s: 5, l: 53 },
|
|
1502
|
+
600: { s: 7, l: 40 },
|
|
1503
|
+
700: { s: 9, l: 27 },
|
|
1504
|
+
800: { s: 12, l: 20 },
|
|
1505
|
+
1e3: { s: 20, l: 7 }
|
|
1302
1506
|
};
|
|
1303
|
-
var
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
g = hueToRgb(p, q, hsl.h);
|
|
1314
|
-
b = hueToRgb(p, q, hsl.h - 1 / 3);
|
|
1507
|
+
var COLORS = {
|
|
1508
|
+
dark: {
|
|
1509
|
+
h: 0,
|
|
1510
|
+
s: 0,
|
|
1511
|
+
l: 7
|
|
1512
|
+
},
|
|
1513
|
+
light: {
|
|
1514
|
+
h: 0,
|
|
1515
|
+
s: 0,
|
|
1516
|
+
l: 100
|
|
1315
1517
|
}
|
|
1316
|
-
return {
|
|
1317
|
-
r: Math.round(r * 255),
|
|
1318
|
-
g: Math.round(g * 255),
|
|
1319
|
-
b: Math.round(b * 255)
|
|
1320
|
-
};
|
|
1321
|
-
};
|
|
1322
|
-
var hslToHex = (hsl) => {
|
|
1323
|
-
const l = hsl.l / 100;
|
|
1324
|
-
const s = hsl.s;
|
|
1325
|
-
const a = s * Math.min(l, 1 - l) / 100;
|
|
1326
|
-
const f = (n) => {
|
|
1327
|
-
const k = (n + hsl.h / 30) % 12;
|
|
1328
|
-
const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
1329
|
-
return Math.round(255 * color).toString(16).padStart(2, "0");
|
|
1330
|
-
};
|
|
1331
|
-
return `#${f(0)}${f(8)}${f(4)}`;
|
|
1332
1518
|
};
|
|
1333
1519
|
|
|
1334
|
-
// src/
|
|
1335
|
-
var
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
case "LayerContext.setAuth" /* setAuth */:
|
|
1340
|
-
case "LayerContext.setBusiness" /* setBusiness */:
|
|
1341
|
-
case "LayerContext.setCategories" /* setCategories */:
|
|
1342
|
-
case "LayerContext.setTheme" /* setTheme */:
|
|
1343
|
-
case "LayerContext.setOnboardingStep" /* setOnboardingStep */:
|
|
1344
|
-
case "LayerContext.setColors" /* setColors */:
|
|
1345
|
-
return { ...state, ...action.payload };
|
|
1346
|
-
case "LayerContext.setToast" /* setToast */:
|
|
1347
|
-
return {
|
|
1348
|
-
...state,
|
|
1349
|
-
toasts: [
|
|
1350
|
-
...state.toasts,
|
|
1351
|
-
{ ...action.payload.toast, isExiting: false }
|
|
1352
|
-
]
|
|
1353
|
-
};
|
|
1354
|
-
case "LayerContext.setToastExit" /* setToastExit */:
|
|
1355
|
-
return {
|
|
1356
|
-
...state,
|
|
1357
|
-
toasts: state.toasts.map(
|
|
1358
|
-
(toast) => toast.id === action.payload.toast.id ? { ...toast, isExiting: false } : toast
|
|
1359
|
-
)
|
|
1360
|
-
};
|
|
1361
|
-
case "LayerContext.removeToast" /* removeToast */:
|
|
1362
|
-
return {
|
|
1363
|
-
...state,
|
|
1364
|
-
toasts: state.toasts.filter((t) => t.id !== action.payload.toast.id)
|
|
1365
|
-
};
|
|
1366
|
-
default:
|
|
1367
|
-
return state;
|
|
1520
|
+
// src/utils/colors.ts
|
|
1521
|
+
var parseStylesFromThemeConfig = (theme) => {
|
|
1522
|
+
let styles = {};
|
|
1523
|
+
if (!theme) {
|
|
1524
|
+
return styles;
|
|
1368
1525
|
}
|
|
1526
|
+
if (theme.colors) {
|
|
1527
|
+
const darkColor = parseColorFromTheme("dark", theme.colors.dark);
|
|
1528
|
+
const lightColor = parseColorFromTheme("light", theme.colors.light);
|
|
1529
|
+
const textColor = parseTextColorFromTheme(theme.colors.text);
|
|
1530
|
+
styles = { ...styles, ...darkColor, ...lightColor, ...textColor };
|
|
1531
|
+
}
|
|
1532
|
+
return styles;
|
|
1369
1533
|
};
|
|
1370
|
-
var
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
staging: {
|
|
1382
|
-
url: "https://auth.layerfi.com/oauth2/token",
|
|
1383
|
-
scope: "https://sandbox.layerfi.com/sandbox",
|
|
1384
|
-
apiUrl: "https://sandbox.layerfi.com"
|
|
1385
|
-
},
|
|
1386
|
-
internalStaging: {
|
|
1387
|
-
url: "https://auth.layerfi.com/oauth2/token",
|
|
1388
|
-
scope: "https://sandbox.layerfi.com/sandbox",
|
|
1389
|
-
apiUrl: "https://staging.layerfi.com"
|
|
1534
|
+
var parseTextColorFromTheme = (color) => {
|
|
1535
|
+
if (!color) {
|
|
1536
|
+
return {};
|
|
1537
|
+
}
|
|
1538
|
+
try {
|
|
1539
|
+
if ("hex" in color) {
|
|
1540
|
+
return { "--text-color-primary": color.hex };
|
|
1541
|
+
}
|
|
1542
|
+
return {};
|
|
1543
|
+
} catch (_err) {
|
|
1544
|
+
return {};
|
|
1390
1545
|
}
|
|
1391
1546
|
};
|
|
1392
|
-
var
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
}) => {
|
|
1404
|
-
const defaultSWRConfig = {
|
|
1405
|
-
revalidateInterval: 0,
|
|
1406
|
-
revalidateOnFocus: false,
|
|
1407
|
-
revalidateOnReconnect: false,
|
|
1408
|
-
revalidateIfStale: false
|
|
1409
|
-
};
|
|
1410
|
-
errorHandler.setOnError(onError);
|
|
1411
|
-
const colors = buildColorsPalette(theme);
|
|
1412
|
-
const { url, scope, apiUrl } = LayerEnvironment[environment];
|
|
1413
|
-
const [state, dispatch] = (0, import_react12.useReducer)(reducer, {
|
|
1414
|
-
auth: {
|
|
1415
|
-
access_token: "",
|
|
1416
|
-
token_type: "",
|
|
1417
|
-
expires_in: 0,
|
|
1418
|
-
expires_at: new Date(2e3, 1, 1)
|
|
1419
|
-
},
|
|
1420
|
-
businessId,
|
|
1421
|
-
business: void 0,
|
|
1422
|
-
categories: [],
|
|
1423
|
-
apiUrl,
|
|
1424
|
-
theme,
|
|
1425
|
-
colors,
|
|
1426
|
-
usePlaidSandbox,
|
|
1427
|
-
onboardingStep: void 0,
|
|
1428
|
-
environment,
|
|
1429
|
-
toasts: [],
|
|
1430
|
-
eventCallbacks: {}
|
|
1431
|
-
});
|
|
1432
|
-
const { touch, syncTimestamps, read, readTimestamps, hasBeenTouched } = useDataSync();
|
|
1433
|
-
const { data: auth } = appId !== void 0 && appSecret !== void 0 ? (0, import_swr.default)(
|
|
1434
|
-
businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && (0, import_date_fns2.isBefore)(state.auth.expires_at, /* @__PURE__ */ new Date()) && "authenticate",
|
|
1435
|
-
Layer.authenticate({
|
|
1436
|
-
appId,
|
|
1437
|
-
appSecret,
|
|
1438
|
-
authenticationUrl: url,
|
|
1439
|
-
scope
|
|
1440
|
-
}),
|
|
1441
|
-
defaultSWRConfig
|
|
1442
|
-
) : { data: void 0 };
|
|
1443
|
-
(0, import_react12.useEffect)(() => {
|
|
1444
|
-
if (businessAccessToken) {
|
|
1445
|
-
dispatch({
|
|
1446
|
-
type: "LayerContext.setAuth" /* setAuth */,
|
|
1447
|
-
payload: {
|
|
1448
|
-
auth: {
|
|
1449
|
-
access_token: businessAccessToken,
|
|
1450
|
-
token_type: "Bearer",
|
|
1451
|
-
expires_in: 3600,
|
|
1452
|
-
expires_at: (0, import_date_fns2.add)(/* @__PURE__ */ new Date(), { seconds: 3600 })
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
});
|
|
1456
|
-
} else if (auth?.access_token) {
|
|
1457
|
-
dispatch({
|
|
1458
|
-
type: "LayerContext.setAuth" /* setAuth */,
|
|
1459
|
-
payload: {
|
|
1460
|
-
auth: {
|
|
1461
|
-
...auth,
|
|
1462
|
-
expires_at: (0, import_date_fns2.add)(/* @__PURE__ */ new Date(), { seconds: auth.expires_in })
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
});
|
|
1547
|
+
var parseColorFromTheme = (colorName, color) => {
|
|
1548
|
+
if (!color) {
|
|
1549
|
+
return {};
|
|
1550
|
+
}
|
|
1551
|
+
try {
|
|
1552
|
+
if ("h" in color && "s" in color && "l" in color) {
|
|
1553
|
+
return {
|
|
1554
|
+
[`--color-${colorName}-h`]: color.h,
|
|
1555
|
+
[`--color-${colorName}-s`]: color.s,
|
|
1556
|
+
[`--color-${colorName}-l`]: color.l
|
|
1557
|
+
};
|
|
1466
1558
|
}
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
...defaultSWRConfig,
|
|
1475
|
-
onSuccess: (response) => {
|
|
1476
|
-
if (response?.data?.categories?.length) {
|
|
1477
|
-
dispatch({
|
|
1478
|
-
type: "LayerContext.setCategories" /* setCategories */,
|
|
1479
|
-
payload: { categories: response.data.categories || [] }
|
|
1480
|
-
});
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1559
|
+
if ("r" in color && "g" in color && "b" in color) {
|
|
1560
|
+
const { h, s, l } = rgbToHsl(color);
|
|
1561
|
+
return {
|
|
1562
|
+
[`--color-${colorName}-h`]: h,
|
|
1563
|
+
[`--color-${colorName}-s`]: `${s}%`,
|
|
1564
|
+
[`--color-${colorName}-l`]: `${l}%`
|
|
1565
|
+
};
|
|
1483
1566
|
}
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1567
|
+
if ("hex" in color) {
|
|
1568
|
+
const rgb = hexToRgb(color.hex);
|
|
1569
|
+
if (!rgb) {
|
|
1570
|
+
return {};
|
|
1571
|
+
}
|
|
1572
|
+
const { h, s, l } = rgbToHsl({
|
|
1573
|
+
r: rgb.r.toString(),
|
|
1574
|
+
g: rgb.g.toString(),
|
|
1575
|
+
b: rgb.b.toString()
|
|
1490
1576
|
});
|
|
1577
|
+
return {
|
|
1578
|
+
[`--color-${colorName}-h`]: h,
|
|
1579
|
+
[`--color-${colorName}-s`]: `${s}%`,
|
|
1580
|
+
[`--color-${colorName}-l`]: `${l}%`
|
|
1581
|
+
};
|
|
1491
1582
|
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
}
|
|
1583
|
+
return {};
|
|
1584
|
+
} catch (_err) {
|
|
1585
|
+
return {};
|
|
1586
|
+
}
|
|
1587
|
+
};
|
|
1588
|
+
var parseColorFromThemeToHsl = (color) => {
|
|
1589
|
+
if (!color) {
|
|
1590
|
+
return;
|
|
1591
|
+
}
|
|
1592
|
+
try {
|
|
1593
|
+
if ("h" in color && "s" in color && "l" in color) {
|
|
1594
|
+
return {
|
|
1595
|
+
h: Number(color.h),
|
|
1596
|
+
s: Number(color.s),
|
|
1597
|
+
l: Number(color.l)
|
|
1598
|
+
};
|
|
1508
1599
|
}
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
}
|
|
1600
|
+
if ("r" in color && "g" in color && "b" in color) {
|
|
1601
|
+
const { h, s, l } = rgbToHsl(color);
|
|
1602
|
+
return {
|
|
1603
|
+
h,
|
|
1604
|
+
s,
|
|
1605
|
+
l
|
|
1606
|
+
};
|
|
1516
1607
|
}
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
payload: { theme: theme2 }
|
|
1522
|
-
});
|
|
1523
|
-
dispatch({
|
|
1524
|
-
type: "LayerContext.setColors" /* setColors */,
|
|
1525
|
-
payload: { colors: buildColorsPalette(theme2) }
|
|
1526
|
-
});
|
|
1527
|
-
};
|
|
1528
|
-
const setLightColor = (color) => {
|
|
1529
|
-
setTheme({
|
|
1530
|
-
...state.theme ?? {},
|
|
1531
|
-
colors: {
|
|
1532
|
-
...state.theme?.colors ?? {},
|
|
1533
|
-
light: color
|
|
1534
|
-
}
|
|
1535
|
-
});
|
|
1536
|
-
};
|
|
1537
|
-
const setDarkColor = (color) => {
|
|
1538
|
-
setTheme({
|
|
1539
|
-
...state.theme ?? {},
|
|
1540
|
-
colors: {
|
|
1541
|
-
...state.theme?.colors ?? {},
|
|
1542
|
-
dark: color
|
|
1543
|
-
}
|
|
1544
|
-
});
|
|
1545
|
-
};
|
|
1546
|
-
const setTextColor = (color) => {
|
|
1547
|
-
setTheme({
|
|
1548
|
-
...state.theme ?? {},
|
|
1549
|
-
colors: {
|
|
1550
|
-
...state.theme?.colors ?? {},
|
|
1551
|
-
text: color
|
|
1608
|
+
if ("hex" in color) {
|
|
1609
|
+
const rgb = hexToRgb(color.hex);
|
|
1610
|
+
if (!rgb) {
|
|
1611
|
+
return void 0;
|
|
1552
1612
|
}
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1613
|
+
const { h, s, l } = rgbToHsl({
|
|
1614
|
+
r: rgb.r.toString(),
|
|
1615
|
+
g: rgb.g.toString(),
|
|
1616
|
+
b: rgb.b.toString()
|
|
1617
|
+
});
|
|
1618
|
+
return {
|
|
1619
|
+
h,
|
|
1620
|
+
s,
|
|
1621
|
+
l
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
return;
|
|
1625
|
+
} catch (_err) {
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
};
|
|
1629
|
+
var rgbToHsl = (color) => {
|
|
1630
|
+
let r = Number(color.r);
|
|
1631
|
+
let g = Number(color.g);
|
|
1632
|
+
let b = Number(color.b);
|
|
1633
|
+
r /= 255;
|
|
1634
|
+
g /= 255;
|
|
1635
|
+
b /= 255;
|
|
1636
|
+
const l = Math.max(r, g, b);
|
|
1637
|
+
const s = l - Math.min(r, g, b);
|
|
1638
|
+
const h = s ? l === r ? (g - b) / s : l === g ? 2 + (b - r) / s : 4 + (r - g) / s : 0;
|
|
1639
|
+
return {
|
|
1640
|
+
h: 60 * h < 0 ? 60 * h + 360 : 60 * h,
|
|
1641
|
+
s: 100 * (s ? l <= 0.5 ? s / (2 * l - s) : s / (2 - (2 * l - s)) : 0),
|
|
1642
|
+
l: 100 * (2 * l - s) / 2
|
|
1560
1643
|
};
|
|
1561
|
-
|
|
1562
|
-
|
|
1644
|
+
};
|
|
1645
|
+
var hexToRgb = (hex) => {
|
|
1646
|
+
const values = hex.replace(
|
|
1647
|
+
/^#?([a-f\d])([a-f\d])([a-f\d])$/i,
|
|
1648
|
+
(m, r, g, b) => "#" + r + r + g + g + b + b
|
|
1649
|
+
).substring(1).match(/.{2}/g)?.map((x) => parseInt(x, 16));
|
|
1650
|
+
if (!values) {
|
|
1651
|
+
return;
|
|
1652
|
+
}
|
|
1653
|
+
return {
|
|
1654
|
+
r: values[0],
|
|
1655
|
+
g: values[1],
|
|
1656
|
+
b: values[2]
|
|
1563
1657
|
};
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1658
|
+
};
|
|
1659
|
+
var buildColorsPalette = (theme) => {
|
|
1660
|
+
const darkColor = parseColorFromThemeToHsl(theme?.colors?.dark) ?? COLORS.dark;
|
|
1661
|
+
const lightColor = parseColorFromThemeToHsl(theme?.colors?.light) ?? COLORS.light;
|
|
1662
|
+
return {
|
|
1663
|
+
50: buildColorShade(50, darkColor),
|
|
1664
|
+
100: buildColorShade(100, darkColor),
|
|
1665
|
+
200: buildColorShade(200, darkColor),
|
|
1666
|
+
300: buildColorShade(300, darkColor),
|
|
1667
|
+
400: {
|
|
1668
|
+
hsl: lightColor,
|
|
1669
|
+
rgb: hslToRgb(lightColor),
|
|
1670
|
+
hex: hslToHex(lightColor)
|
|
1671
|
+
},
|
|
1672
|
+
500: buildColorShade(500, darkColor),
|
|
1673
|
+
600: buildColorShade(600, darkColor),
|
|
1674
|
+
700: buildColorShade(700, darkColor),
|
|
1675
|
+
800: buildColorShade(800, darkColor),
|
|
1676
|
+
900: {
|
|
1677
|
+
hsl: darkColor,
|
|
1678
|
+
rgb: hslToRgb(darkColor),
|
|
1679
|
+
hex: hslToHex(darkColor)
|
|
1680
|
+
},
|
|
1681
|
+
1e3: buildColorShade(1e3, darkColor)
|
|
1574
1682
|
};
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
const
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1683
|
+
};
|
|
1684
|
+
var buildColorShade = (shade, darkColorHsl) => {
|
|
1685
|
+
const hsl = { h: darkColorHsl.h, ...SHADES[shade] };
|
|
1686
|
+
const rgb = hslToRgb(hsl);
|
|
1687
|
+
const hex = hslToHex(hsl);
|
|
1688
|
+
return { hsl, rgb, hex };
|
|
1689
|
+
};
|
|
1690
|
+
var hueToRgb = (p, q, t) => {
|
|
1691
|
+
if (t < 0)
|
|
1692
|
+
t += 1;
|
|
1693
|
+
if (t > 1)
|
|
1694
|
+
t -= 1;
|
|
1695
|
+
if (t < 1 / 6)
|
|
1696
|
+
return p + (q - p) * 6 * t;
|
|
1697
|
+
if (t < 1 / 2)
|
|
1698
|
+
return q;
|
|
1699
|
+
if (t < 2 / 3)
|
|
1700
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
1701
|
+
return p;
|
|
1702
|
+
};
|
|
1703
|
+
var hslToRgb = (hsl) => {
|
|
1704
|
+
let r, g, b;
|
|
1705
|
+
let l = hsl.l / 100;
|
|
1706
|
+
let s = hsl.s / 100;
|
|
1707
|
+
if (hsl.s === 0) {
|
|
1708
|
+
r = g = b = l;
|
|
1709
|
+
} else {
|
|
1710
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
1711
|
+
const p = 2 * l - q;
|
|
1712
|
+
r = hueToRgb(p, q, hsl.h + 1 / 3);
|
|
1713
|
+
g = hueToRgb(p, q, hsl.h);
|
|
1714
|
+
b = hueToRgb(p, q, hsl.h - 1 / 3);
|
|
1715
|
+
}
|
|
1716
|
+
return {
|
|
1717
|
+
r: Math.round(r * 255),
|
|
1718
|
+
g: Math.round(g * 255),
|
|
1719
|
+
b: Math.round(b * 255)
|
|
1584
1720
|
};
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
const
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
getColor,
|
|
1597
|
-
setLightColor,
|
|
1598
|
-
setDarkColor,
|
|
1599
|
-
setTextColor,
|
|
1600
|
-
setColors,
|
|
1601
|
-
setOnboardingStep,
|
|
1602
|
-
addToast,
|
|
1603
|
-
removeToast,
|
|
1604
|
-
onError: errorHandler.onError,
|
|
1605
|
-
touch,
|
|
1606
|
-
read,
|
|
1607
|
-
syncTimestamps,
|
|
1608
|
-
readTimestamps,
|
|
1609
|
-
hasBeenTouched,
|
|
1610
|
-
eventCallbacks
|
|
1611
|
-
}
|
|
1612
|
-
},
|
|
1613
|
-
/* @__PURE__ */ import_react12.default.createElement(BankTransactionsProvider, null, /* @__PURE__ */ import_react12.default.createElement(DrawerContext.Provider, { value: drawerContextData }, children, /* @__PURE__ */ import_react12.default.createElement(GlobalWidgets, null)))
|
|
1614
|
-
));
|
|
1721
|
+
};
|
|
1722
|
+
var hslToHex = (hsl) => {
|
|
1723
|
+
const l = hsl.l / 100;
|
|
1724
|
+
const s = hsl.s;
|
|
1725
|
+
const a = s * Math.min(l, 1 - l) / 100;
|
|
1726
|
+
const f = (n) => {
|
|
1727
|
+
const k = (n + hsl.h / 30) % 12;
|
|
1728
|
+
const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
1729
|
+
return Math.round(255 * color).toString(16).padStart(2, "0");
|
|
1730
|
+
};
|
|
1731
|
+
return `#${f(0)}${f(8)}${f(4)}`;
|
|
1615
1732
|
};
|
|
1616
1733
|
|
|
1617
|
-
// src/
|
|
1618
|
-
var
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1734
|
+
// src/providers/LayerProvider/LayerProvider.tsx
|
|
1735
|
+
var import_date_fns = require("date-fns");
|
|
1736
|
+
var import_swr2 = __toESM(require("swr"));
|
|
1737
|
+
var reducer = (state, action) => {
|
|
1738
|
+
switch (action.type) {
|
|
1739
|
+
case "LayerContext.setAuth" /* setAuth */:
|
|
1740
|
+
case "LayerContext.setBusiness" /* setBusiness */:
|
|
1741
|
+
case "LayerContext.setCategories" /* setCategories */:
|
|
1742
|
+
case "LayerContext.setTheme" /* setTheme */:
|
|
1743
|
+
case "LayerContext.setOnboardingStep" /* setOnboardingStep */:
|
|
1744
|
+
case "LayerContext.setColors" /* setColors */:
|
|
1745
|
+
return { ...state, ...action.payload };
|
|
1746
|
+
case "LayerContext.setToast" /* setToast */:
|
|
1747
|
+
return {
|
|
1748
|
+
...state,
|
|
1749
|
+
toasts: [
|
|
1750
|
+
...state.toasts,
|
|
1751
|
+
{ ...action.payload.toast, isExiting: false }
|
|
1752
|
+
]
|
|
1753
|
+
};
|
|
1754
|
+
case "LayerContext.setToastExit" /* setToastExit */:
|
|
1755
|
+
return {
|
|
1756
|
+
...state,
|
|
1757
|
+
toasts: state.toasts.map(
|
|
1758
|
+
(toast) => toast.id === action.payload.toast.id ? { ...toast, isExiting: false } : toast
|
|
1759
|
+
)
|
|
1760
|
+
};
|
|
1761
|
+
case "LayerContext.removeToast" /* removeToast */:
|
|
1762
|
+
return {
|
|
1763
|
+
...state,
|
|
1764
|
+
toasts: state.toasts.filter((t) => t.id !== action.payload.toast.id)
|
|
1765
|
+
};
|
|
1766
|
+
default:
|
|
1767
|
+
return state;
|
|
1647
1768
|
}
|
|
1648
|
-
}
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
var import_react14 = require("react");
|
|
1655
|
-
var import_react_plaid_link = require("react-plaid-link");
|
|
1656
|
-
|
|
1657
|
-
// src/hooks/useLinkedAccounts/mockData.ts
|
|
1658
|
-
var LINKED_ACCOUNTS_MOCK_DATA = [
|
|
1659
|
-
{
|
|
1660
|
-
id: "d800ada8-8075-4436-a712-08efabcbd51a",
|
|
1661
|
-
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
1662
|
-
external_account_source: "PLAID",
|
|
1663
|
-
external_account_name: "Citi Double Cash\xAE Card",
|
|
1664
|
-
mask: "1234",
|
|
1665
|
-
latest_balance_timestamp: {
|
|
1666
|
-
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
1667
|
-
external_account_source: "PLAID",
|
|
1668
|
-
balance: 435121,
|
|
1669
|
-
at: "2024-04-03T13:00:00Z",
|
|
1670
|
-
created_at: "2024-04-06T22:47:59.715458Z"
|
|
1671
|
-
},
|
|
1672
|
-
current_ledger_balance: 373717,
|
|
1673
|
-
institution: {
|
|
1674
|
-
name: "Chase",
|
|
1675
|
-
logo: ""
|
|
1676
|
-
},
|
|
1677
|
-
connection_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
1678
|
-
connection_external_id: "11111",
|
|
1679
|
-
connection_needs_repair_as_of: null,
|
|
1680
|
-
requires_user_confirmation_as_of: null,
|
|
1681
|
-
is_syncing: true
|
|
1769
|
+
};
|
|
1770
|
+
var LayerEnvironment = {
|
|
1771
|
+
production: {
|
|
1772
|
+
url: "https://auth.layerfi.com/oauth2/token",
|
|
1773
|
+
scope: "https://api.layerfi.com/production",
|
|
1774
|
+
apiUrl: "https://api.layerfi.com"
|
|
1682
1775
|
},
|
|
1683
|
-
{
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
external_account_name: "Citi Double Cash\xAE Card",
|
|
1688
|
-
mask: "1234",
|
|
1689
|
-
latest_balance_timestamp: {
|
|
1690
|
-
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
1691
|
-
external_account_source: "PLAID",
|
|
1692
|
-
balance: 435121,
|
|
1693
|
-
at: "2024-04-03T13:00:00Z",
|
|
1694
|
-
created_at: "2024-04-06T16:44:35.715458Z"
|
|
1695
|
-
},
|
|
1696
|
-
current_ledger_balance: 373717,
|
|
1697
|
-
institution: {
|
|
1698
|
-
name: "Chase",
|
|
1699
|
-
logo: ""
|
|
1700
|
-
},
|
|
1701
|
-
connection_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
1702
|
-
connection_external_id: "11111",
|
|
1703
|
-
connection_needs_repair_as_of: null,
|
|
1704
|
-
requires_user_confirmation_as_of: null,
|
|
1705
|
-
is_syncing: false
|
|
1776
|
+
sandbox: {
|
|
1777
|
+
url: "https://auth.layerfi.com/oauth2/token",
|
|
1778
|
+
scope: "https://sandbox.layerfi.com/sandbox",
|
|
1779
|
+
apiUrl: "https://sandbox.layerfi.com"
|
|
1706
1780
|
},
|
|
1707
|
-
{
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
external_account_name: "Citi Double Cash\xAE Card",
|
|
1712
|
-
mask: "1234",
|
|
1713
|
-
latest_balance_timestamp: {
|
|
1714
|
-
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
1715
|
-
external_account_source: "PLAID",
|
|
1716
|
-
balance: 435121,
|
|
1717
|
-
at: "2024-04-03T13:00:00Z",
|
|
1718
|
-
created_at: "2024-04-06T16:44:35.715458Z"
|
|
1719
|
-
},
|
|
1720
|
-
current_ledger_balance: 373717,
|
|
1721
|
-
institution: {
|
|
1722
|
-
name: "Chase",
|
|
1723
|
-
logo: ""
|
|
1724
|
-
},
|
|
1725
|
-
connection_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
1726
|
-
connection_external_id: "11111",
|
|
1727
|
-
connection_needs_repair_as_of: "2024-03-06T16:44:35.715458Z",
|
|
1728
|
-
requires_user_confirmation_as_of: null,
|
|
1729
|
-
is_syncing: false
|
|
1781
|
+
staging: {
|
|
1782
|
+
url: "https://auth.layerfi.com/oauth2/token",
|
|
1783
|
+
scope: "https://sandbox.layerfi.com/sandbox",
|
|
1784
|
+
apiUrl: "https://sandbox.layerfi.com"
|
|
1730
1785
|
},
|
|
1731
|
-
{
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
external_account_name: "Citi Double Cash\xAE Card",
|
|
1736
|
-
mask: "1234",
|
|
1737
|
-
latest_balance_timestamp: {
|
|
1738
|
-
external_account_external_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
1739
|
-
external_account_source: "PLAID",
|
|
1740
|
-
balance: 435121,
|
|
1741
|
-
at: "2024-04-03T13:00:00Z",
|
|
1742
|
-
created_at: "2024-04-06T16:44:35.715458Z"
|
|
1743
|
-
},
|
|
1744
|
-
current_ledger_balance: 373717,
|
|
1745
|
-
institution: {
|
|
1746
|
-
name: "Chase",
|
|
1747
|
-
logo: ""
|
|
1748
|
-
},
|
|
1749
|
-
connection_id: "0Br385JmgbTryJn8nEBnUb4A5ydv06U9Vbqqq",
|
|
1750
|
-
connection_external_id: "11111",
|
|
1751
|
-
connection_needs_repair_as_of: null,
|
|
1752
|
-
requires_user_confirmation_as_of: "2024-03-06T16:44:35.715458Z",
|
|
1753
|
-
is_syncing: false
|
|
1786
|
+
internalStaging: {
|
|
1787
|
+
url: "https://auth.layerfi.com/oauth2/token",
|
|
1788
|
+
scope: "https://sandbox.layerfi.com/sandbox",
|
|
1789
|
+
apiUrl: "https://staging.layerfi.com"
|
|
1754
1790
|
}
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1791
|
+
};
|
|
1792
|
+
var LayerProvider = ({
|
|
1793
|
+
appId,
|
|
1794
|
+
appSecret,
|
|
1795
|
+
businessId,
|
|
1796
|
+
children,
|
|
1797
|
+
businessAccessToken,
|
|
1798
|
+
environment = "production",
|
|
1799
|
+
theme,
|
|
1800
|
+
usePlaidSandbox,
|
|
1801
|
+
onError,
|
|
1802
|
+
eventCallbacks
|
|
1803
|
+
}) => {
|
|
1804
|
+
const defaultSWRConfig = {
|
|
1805
|
+
revalidateInterval: 0,
|
|
1806
|
+
revalidateOnFocus: false,
|
|
1807
|
+
revalidateOnReconnect: false,
|
|
1808
|
+
revalidateIfStale: false
|
|
1809
|
+
};
|
|
1810
|
+
errorHandler.setOnError(onError);
|
|
1811
|
+
const colors = buildColorsPalette(theme);
|
|
1812
|
+
const { url, scope, apiUrl } = LayerEnvironment[environment];
|
|
1813
|
+
const [state, dispatch] = (0, import_react13.useReducer)(reducer, {
|
|
1814
|
+
auth: {
|
|
1815
|
+
access_token: "",
|
|
1816
|
+
token_type: "",
|
|
1817
|
+
expires_in: 0,
|
|
1818
|
+
expires_at: new Date(2e3, 1, 1)
|
|
1819
|
+
},
|
|
1764
1820
|
businessId,
|
|
1821
|
+
business: void 0,
|
|
1822
|
+
categories: [],
|
|
1765
1823
|
apiUrl,
|
|
1824
|
+
theme,
|
|
1825
|
+
colors,
|
|
1766
1826
|
usePlaidSandbox,
|
|
1827
|
+
onboardingStep: void 0,
|
|
1828
|
+
environment,
|
|
1829
|
+
toasts: [],
|
|
1830
|
+
eventCallbacks: {}
|
|
1831
|
+
});
|
|
1832
|
+
const {
|
|
1767
1833
|
touch,
|
|
1768
|
-
read,
|
|
1769
1834
|
syncTimestamps,
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
const
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
}
|
|
1798
|
-
if (!isLoading && loadingStatus === "loading") {
|
|
1799
|
-
setLoadingStatus("complete");
|
|
1800
|
-
}
|
|
1801
|
-
}, [isLoading]);
|
|
1802
|
-
const fetchPlaidLinkToken = async () => {
|
|
1803
|
-
if (auth?.access_token) {
|
|
1804
|
-
const linkToken2 = (await Layer.getPlaidLinkToken(apiUrl, auth.access_token, {
|
|
1805
|
-
params: { businessId }
|
|
1806
|
-
})).data.link_token;
|
|
1807
|
-
setLinkMode("add");
|
|
1808
|
-
setLinkToken(linkToken2);
|
|
1809
|
-
}
|
|
1810
|
-
};
|
|
1811
|
-
const fetchPlaidUpdateModeLinkToken = async (plaidItemPlaidId) => {
|
|
1812
|
-
if (auth?.access_token) {
|
|
1813
|
-
const linkToken2 = (await Layer.getPlaidUpdateModeLinkToken(apiUrl, auth.access_token, {
|
|
1814
|
-
params: { businessId },
|
|
1815
|
-
body: { plaid_item_id: plaidItemPlaidId }
|
|
1816
|
-
})).data.link_token;
|
|
1817
|
-
setLinkMode("update");
|
|
1818
|
-
setLinkToken(linkToken2);
|
|
1819
|
-
}
|
|
1820
|
-
};
|
|
1821
|
-
const exchangePlaidPublicToken2 = async (publicToken, metadata) => {
|
|
1822
|
-
await Layer.exchangePlaidPublicToken(apiUrl, auth?.access_token, {
|
|
1823
|
-
params: { businessId },
|
|
1824
|
-
body: { public_token: publicToken, institution: metadata.institution }
|
|
1825
|
-
});
|
|
1826
|
-
refetchAccounts();
|
|
1827
|
-
};
|
|
1828
|
-
const { open: plaidLinkStart, ready: plaidLinkReady } = (0, import_react_plaid_link.usePlaidLink)({
|
|
1829
|
-
token: linkToken,
|
|
1830
|
-
// If in update mode, we don't need to exchange the public token for an access token.
|
|
1831
|
-
// The existing access token will automatically become valid again
|
|
1832
|
-
onSuccess: async (publicToken, metadata) => {
|
|
1833
|
-
if (linkMode == "add") {
|
|
1834
|
-
exchangePlaidPublicToken2(publicToken, metadata);
|
|
1835
|
-
} else {
|
|
1836
|
-
await updateConnectionStatus2();
|
|
1837
|
-
refetchAccounts();
|
|
1838
|
-
setLinkMode("add");
|
|
1839
|
-
touch("LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */);
|
|
1840
|
-
}
|
|
1841
|
-
},
|
|
1842
|
-
onExit: () => setLinkMode("add"),
|
|
1843
|
-
env: USE_PLAID_SANDBOX ? "sandbox" : void 0
|
|
1844
|
-
});
|
|
1845
|
-
(0, import_react14.useEffect)(() => {
|
|
1846
|
-
if (plaidLinkReady) {
|
|
1847
|
-
plaidLinkStart();
|
|
1848
|
-
}
|
|
1849
|
-
}, [plaidLinkStart, plaidLinkReady]);
|
|
1850
|
-
const mockResponseData = {
|
|
1851
|
-
data: LINKED_ACCOUNTS_MOCK_DATA,
|
|
1852
|
-
meta: {},
|
|
1853
|
-
error: void 0
|
|
1854
|
-
};
|
|
1855
|
-
const addConnection = (source) => {
|
|
1856
|
-
if (source === "PLAID") {
|
|
1857
|
-
fetchPlaidLinkToken();
|
|
1858
|
-
} else {
|
|
1859
|
-
console.error(
|
|
1860
|
-
`Adding a connection with source ${source} not yet supported`
|
|
1861
|
-
);
|
|
1862
|
-
}
|
|
1863
|
-
};
|
|
1864
|
-
const repairConnection = async (source, connectionExternalId) => {
|
|
1865
|
-
if (source === "PLAID") {
|
|
1866
|
-
await fetchPlaidUpdateModeLinkToken(connectionExternalId);
|
|
1867
|
-
} else {
|
|
1868
|
-
console.error(
|
|
1869
|
-
`Repairing a connection with source ${source} not yet supported`
|
|
1870
|
-
);
|
|
1871
|
-
}
|
|
1872
|
-
};
|
|
1873
|
-
const removeConnection = async (source, connectionExternalId) => {
|
|
1874
|
-
if (source === "PLAID") {
|
|
1875
|
-
await unlinkPlaidItem2(connectionExternalId);
|
|
1876
|
-
await refetchAccounts();
|
|
1877
|
-
} else {
|
|
1878
|
-
console.error(
|
|
1879
|
-
`Removing a connection with source ${source} not yet supported`
|
|
1880
|
-
);
|
|
1881
|
-
}
|
|
1882
|
-
};
|
|
1883
|
-
const unlinkAccount2 = async (source, accountId) => {
|
|
1884
|
-
DEBUG && console.log("unlinking account");
|
|
1885
|
-
if (source === "PLAID") {
|
|
1886
|
-
await Layer.unlinkAccount(apiUrl, auth?.access_token, {
|
|
1887
|
-
params: { businessId, accountId }
|
|
1835
|
+
read,
|
|
1836
|
+
readTimestamps,
|
|
1837
|
+
hasBeenTouched,
|
|
1838
|
+
resetCaches
|
|
1839
|
+
} = useDataSync();
|
|
1840
|
+
const { data: auth } = appId !== void 0 && appSecret !== void 0 ? (0, import_swr2.default)(
|
|
1841
|
+
businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && (0, import_date_fns.isBefore)(state.auth.expires_at, /* @__PURE__ */ new Date()) && "authenticate",
|
|
1842
|
+
Layer.authenticate({
|
|
1843
|
+
appId,
|
|
1844
|
+
appSecret,
|
|
1845
|
+
authenticationUrl: url,
|
|
1846
|
+
scope
|
|
1847
|
+
}),
|
|
1848
|
+
defaultSWRConfig
|
|
1849
|
+
) : { data: void 0 };
|
|
1850
|
+
(0, import_react13.useEffect)(() => {
|
|
1851
|
+
if (businessAccessToken) {
|
|
1852
|
+
dispatch({
|
|
1853
|
+
type: "LayerContext.setAuth" /* setAuth */,
|
|
1854
|
+
payload: {
|
|
1855
|
+
auth: {
|
|
1856
|
+
access_token: businessAccessToken,
|
|
1857
|
+
token_type: "Bearer",
|
|
1858
|
+
expires_in: 3600,
|
|
1859
|
+
expires_at: (0, import_date_fns.add)(/* @__PURE__ */ new Date(), { seconds: 3600 })
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1888
1862
|
});
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
const confirmAccount = async (source, accountId) => {
|
|
1898
|
-
DEBUG && console.log("confirming account");
|
|
1899
|
-
if (source === "PLAID") {
|
|
1900
|
-
await Layer.confirmConnection(apiUrl, auth?.access_token, {
|
|
1901
|
-
params: {
|
|
1902
|
-
businessId,
|
|
1903
|
-
accountId
|
|
1863
|
+
} else if (auth?.access_token) {
|
|
1864
|
+
dispatch({
|
|
1865
|
+
type: "LayerContext.setAuth" /* setAuth */,
|
|
1866
|
+
payload: {
|
|
1867
|
+
auth: {
|
|
1868
|
+
...auth,
|
|
1869
|
+
expires_at: (0, import_date_fns.add)(/* @__PURE__ */ new Date(), { seconds: auth.expires_in })
|
|
1870
|
+
}
|
|
1904
1871
|
}
|
|
1905
1872
|
});
|
|
1906
|
-
await refetchAccounts();
|
|
1907
|
-
touch("LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */);
|
|
1908
|
-
} else {
|
|
1909
|
-
console.error(
|
|
1910
|
-
`Confirming an account with source ${source} not yet supported`
|
|
1911
|
-
);
|
|
1912
1873
|
}
|
|
1913
|
-
};
|
|
1914
|
-
const
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1874
|
+
}, [businessAccessToken, auth?.access_token]);
|
|
1875
|
+
const { data: categoriesData } = (0, import_swr2.default)(
|
|
1876
|
+
businessId && state.auth?.access_token && `categories-${businessId}`,
|
|
1877
|
+
Layer.getCategories(apiUrl, state.auth?.access_token, {
|
|
1878
|
+
params: { businessId }
|
|
1879
|
+
}),
|
|
1880
|
+
{
|
|
1881
|
+
...defaultSWRConfig,
|
|
1882
|
+
onSuccess: (response) => {
|
|
1883
|
+
if (response?.data?.categories?.length) {
|
|
1884
|
+
dispatch({
|
|
1885
|
+
type: "LayerContext.setCategories" /* setCategories */,
|
|
1886
|
+
payload: { categories: response.data.categories || [] }
|
|
1887
|
+
});
|
|
1921
1888
|
}
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
);
|
|
1892
|
+
(0, import_react13.useEffect)(() => {
|
|
1893
|
+
if (categoriesData?.data?.categories?.length) {
|
|
1894
|
+
dispatch({
|
|
1895
|
+
type: "LayerContext.setCategories" /* setCategories */,
|
|
1896
|
+
payload: { categories: categoriesData.data.categories || [] }
|
|
1922
1897
|
});
|
|
1923
|
-
await refetchAccounts();
|
|
1924
|
-
touch("LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */);
|
|
1925
|
-
} else {
|
|
1926
|
-
console.error(
|
|
1927
|
-
`Denying an account with source ${source} not yet supported`
|
|
1928
|
-
);
|
|
1929
1898
|
}
|
|
1930
|
-
};
|
|
1931
|
-
const
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1899
|
+
}, [categoriesData]);
|
|
1900
|
+
const { data: businessData } = (0, import_swr2.default)(
|
|
1901
|
+
businessId && state?.auth?.access_token && `business-${businessId}`,
|
|
1902
|
+
Layer.getBusiness(apiUrl, state?.auth?.access_token, {
|
|
1903
|
+
params: { businessId }
|
|
1904
|
+
}),
|
|
1905
|
+
{
|
|
1906
|
+
...defaultSWRConfig,
|
|
1907
|
+
onSuccess: (response) => {
|
|
1908
|
+
if (response?.data) {
|
|
1909
|
+
dispatch({
|
|
1910
|
+
type: "LayerContext.setBusiness" /* setBusiness */,
|
|
1911
|
+
payload: { business: response.data || [] }
|
|
1912
|
+
});
|
|
1938
1913
|
}
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
);
|
|
1917
|
+
(0, import_react13.useEffect)(() => {
|
|
1918
|
+
if (businessData?.data) {
|
|
1919
|
+
dispatch({
|
|
1920
|
+
type: "LayerContext.setBusiness" /* setBusiness */,
|
|
1921
|
+
payload: { business: businessData.data || [] }
|
|
1939
1922
|
});
|
|
1940
|
-
await refetchAccounts();
|
|
1941
|
-
touch("LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */);
|
|
1942
|
-
} else {
|
|
1943
|
-
console.error(
|
|
1944
|
-
`Breaking a sandbox connection with source ${source} not yet supported`
|
|
1945
|
-
);
|
|
1946
1923
|
}
|
|
1924
|
+
}, [businessData]);
|
|
1925
|
+
const setTheme = (theme2) => {
|
|
1926
|
+
dispatch({
|
|
1927
|
+
type: "LayerContext.setTheme" /* setTheme */,
|
|
1928
|
+
payload: { theme: theme2 }
|
|
1929
|
+
});
|
|
1930
|
+
dispatch({
|
|
1931
|
+
type: "LayerContext.setColors" /* setColors */,
|
|
1932
|
+
payload: { colors: buildColorsPalette(theme2) }
|
|
1933
|
+
});
|
|
1947
1934
|
};
|
|
1948
|
-
const
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
params: { businessId }
|
|
1935
|
+
const setLightColor = (color) => {
|
|
1936
|
+
setTheme({
|
|
1937
|
+
...state.theme ?? {},
|
|
1938
|
+
colors: {
|
|
1939
|
+
...state.theme?.colors ?? {},
|
|
1940
|
+
light: color
|
|
1941
|
+
}
|
|
1956
1942
|
});
|
|
1957
1943
|
};
|
|
1958
|
-
const
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1944
|
+
const setDarkColor = (color) => {
|
|
1945
|
+
setTheme({
|
|
1946
|
+
...state.theme ?? {},
|
|
1947
|
+
colors: {
|
|
1948
|
+
...state.theme?.colors ?? {},
|
|
1949
|
+
dark: color
|
|
1950
|
+
}
|
|
1962
1951
|
});
|
|
1963
1952
|
};
|
|
1964
|
-
const
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1953
|
+
const setTextColor = (color) => {
|
|
1954
|
+
setTheme({
|
|
1955
|
+
...state.theme ?? {},
|
|
1956
|
+
colors: {
|
|
1957
|
+
...state.theme?.colors ?? {},
|
|
1958
|
+
text: color
|
|
1959
|
+
}
|
|
1968
1960
|
});
|
|
1969
|
-
await refetchAccounts();
|
|
1970
|
-
touch("LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */);
|
|
1971
1961
|
};
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1962
|
+
const setToast = (toast) => {
|
|
1963
|
+
dispatch({ type: "LayerContext.setToast" /* setToast */, payload: { toast } });
|
|
1964
|
+
};
|
|
1965
|
+
const removeToast = (toast) => {
|
|
1966
|
+
dispatch({ type: "LayerContext.removeToast" /* removeToast */, payload: { toast } });
|
|
1967
|
+
};
|
|
1968
|
+
const setToastExit = (toast) => {
|
|
1969
|
+
dispatch({ type: "LayerContext.setToastExit" /* setToastExit */, payload: { toast } });
|
|
1970
|
+
};
|
|
1971
|
+
const addToast = (toast) => {
|
|
1972
|
+
const id = `${Date.now()}-${Math.random()}`;
|
|
1973
|
+
const newToast = { id, isExiting: false, ...toast };
|
|
1974
|
+
setToast(newToast);
|
|
1975
|
+
setTimeout(() => {
|
|
1976
|
+
removeToast(newToast);
|
|
1977
|
+
setTimeout(() => {
|
|
1978
|
+
setToastExit(newToast);
|
|
1979
|
+
}, 1e3);
|
|
1980
|
+
}, toast.duration || 2e3);
|
|
1981
|
+
};
|
|
1982
|
+
const setColors = (colors2) => setTheme({
|
|
1983
|
+
...state.theme ?? {},
|
|
1984
|
+
colors: colors2
|
|
1985
|
+
});
|
|
1986
|
+
const getColor = (shade) => {
|
|
1987
|
+
if (state.colors && shade in state.colors) {
|
|
1988
|
+
return state.colors[shade];
|
|
1980
1989
|
}
|
|
1981
|
-
|
|
1982
|
-
return {
|
|
1983
|
-
data: USE_MOCK_RESPONSE_DATA ? mockResponseData.data : responseData?.data.external_accounts,
|
|
1984
|
-
isLoading,
|
|
1985
|
-
loadingStatus,
|
|
1986
|
-
isValidating,
|
|
1987
|
-
error: responseError,
|
|
1988
|
-
addConnection,
|
|
1989
|
-
removeConnection,
|
|
1990
|
-
repairConnection,
|
|
1991
|
-
refetchAccounts,
|
|
1992
|
-
unlinkAccount: unlinkAccount2,
|
|
1993
|
-
confirmAccount,
|
|
1994
|
-
denyAccount,
|
|
1995
|
-
breakConnection,
|
|
1996
|
-
syncAccounts,
|
|
1997
|
-
updateConnectionStatus: updateConnectionStatus2
|
|
1990
|
+
return;
|
|
1998
1991
|
};
|
|
1992
|
+
const setOnboardingStep = (value) => dispatch({
|
|
1993
|
+
type: "LayerContext.setOnboardingStep" /* setOnboardingStep */,
|
|
1994
|
+
payload: { onboardingStep: value }
|
|
1995
|
+
});
|
|
1996
|
+
const drawerContextData = useDrawer();
|
|
1997
|
+
return /* @__PURE__ */ import_react13.default.createElement(import_swr2.SWRConfig, { value: defaultSWRConfig }, /* @__PURE__ */ import_react13.default.createElement(
|
|
1998
|
+
LayerContext.Provider,
|
|
1999
|
+
{
|
|
2000
|
+
value: {
|
|
2001
|
+
...state,
|
|
2002
|
+
setTheme,
|
|
2003
|
+
getColor,
|
|
2004
|
+
setLightColor,
|
|
2005
|
+
setDarkColor,
|
|
2006
|
+
setTextColor,
|
|
2007
|
+
setColors,
|
|
2008
|
+
setOnboardingStep,
|
|
2009
|
+
addToast,
|
|
2010
|
+
removeToast,
|
|
2011
|
+
onError: errorHandler.onError,
|
|
2012
|
+
touch,
|
|
2013
|
+
read,
|
|
2014
|
+
syncTimestamps,
|
|
2015
|
+
readTimestamps,
|
|
2016
|
+
expireDataCaches: resetCaches,
|
|
2017
|
+
hasBeenTouched,
|
|
2018
|
+
eventCallbacks
|
|
2019
|
+
}
|
|
2020
|
+
},
|
|
2021
|
+
/* @__PURE__ */ import_react13.default.createElement(BankTransactionsProvider, null, /* @__PURE__ */ import_react13.default.createElement(DrawerContext.Provider, { value: drawerContextData }, children, /* @__PURE__ */ import_react13.default.createElement(GlobalWidgets, null)))
|
|
2022
|
+
));
|
|
1999
2023
|
};
|
|
2000
2024
|
|
|
2025
|
+
// src/components/Onboarding/Onboarding.tsx
|
|
2026
|
+
var import_react39 = __toESM(require("react"));
|
|
2027
|
+
|
|
2028
|
+
// src/contexts/LinkedAccountsContext/LinkedAccountsContext.ts
|
|
2029
|
+
var import_react14 = require("react");
|
|
2030
|
+
var LinkedAccountsContext = (0, import_react14.createContext)({
|
|
2031
|
+
data: void 0,
|
|
2032
|
+
isLoading: false,
|
|
2033
|
+
loadingStatus: "initial",
|
|
2034
|
+
isValidating: false,
|
|
2035
|
+
error: void 0,
|
|
2036
|
+
updateConnectionStatus: () => {
|
|
2037
|
+
},
|
|
2038
|
+
addConnection: () => {
|
|
2039
|
+
},
|
|
2040
|
+
removeConnection: () => {
|
|
2041
|
+
},
|
|
2042
|
+
repairConnection: () => {
|
|
2043
|
+
},
|
|
2044
|
+
refetchAccounts: () => {
|
|
2045
|
+
},
|
|
2046
|
+
unlinkAccount: () => {
|
|
2047
|
+
},
|
|
2048
|
+
denyAccount: () => {
|
|
2049
|
+
},
|
|
2050
|
+
confirmAccount: () => {
|
|
2051
|
+
},
|
|
2052
|
+
breakConnection: () => {
|
|
2053
|
+
},
|
|
2054
|
+
syncAccounts: () => {
|
|
2055
|
+
}
|
|
2056
|
+
});
|
|
2057
|
+
|
|
2001
2058
|
// src/providers/LinkedAccountsProvider/LinkedAccountsProvider.tsx
|
|
2059
|
+
var import_react15 = __toESM(require("react"));
|
|
2002
2060
|
var LinkedAccountsProvider = ({
|
|
2003
2061
|
children
|
|
2004
2062
|
}) => {
|
|
@@ -2272,8 +2330,20 @@ var Sunrise = ({ size = 12, ...props }) => /* @__PURE__ */ React16.createElement
|
|
|
2272
2330
|
);
|
|
2273
2331
|
var Sunrise_default = Sunrise;
|
|
2274
2332
|
|
|
2333
|
+
// src/components/BankTransactions/utils.ts
|
|
2334
|
+
var filterVisibility = (scope, bankTransaction) => {
|
|
2335
|
+
const categorized = CategorizedCategories.includes(
|
|
2336
|
+
bankTransaction.categorization_status
|
|
2337
|
+
);
|
|
2338
|
+
const inReview = ReviewCategories.includes(
|
|
2339
|
+
bankTransaction.categorization_status
|
|
2340
|
+
);
|
|
2341
|
+
return scope === "all" /* all */ || scope === "review" /* review */ && inReview || scope === "categorized" /* categorized */ && categorized;
|
|
2342
|
+
};
|
|
2343
|
+
var isCategorized = (bankTransaction) => CategorizedCategories.includes(bankTransaction.categorization_status);
|
|
2344
|
+
|
|
2275
2345
|
// src/utils/bankTransactions.ts
|
|
2276
|
-
var
|
|
2346
|
+
var import_date_fns2 = require("date-fns");
|
|
2277
2347
|
var hasMatch = (bankTransaction) => {
|
|
2278
2348
|
return Boolean(
|
|
2279
2349
|
bankTransaction?.suggested_matches && bankTransaction?.suggested_matches?.length > 0 || bankTransaction?.match
|
|
@@ -2301,7 +2371,7 @@ var countTransactionsToReview = ({
|
|
|
2301
2371
|
};
|
|
2302
2372
|
return transactions.filter((tx) => {
|
|
2303
2373
|
try {
|
|
2304
|
-
return filterVisibility("review" /* review */, tx) && (0,
|
|
2374
|
+
return filterVisibility("review" /* review */, tx) && (0, import_date_fns2.isWithinInterval)((0, import_date_fns2.parseISO)(tx.date), dateRangeInterval);
|
|
2305
2375
|
} catch (_err) {
|
|
2306
2376
|
return false;
|
|
2307
2377
|
}
|
|
@@ -4730,7 +4800,7 @@ var CategorySelectDrawerContent = ({
|
|
|
4730
4800
|
|
|
4731
4801
|
// src/components/CategorySelect/CategorySelect.tsx
|
|
4732
4802
|
var import_classnames23 = __toESM(require("classnames"));
|
|
4733
|
-
var
|
|
4803
|
+
var import_date_fns3 = require("date-fns");
|
|
4734
4804
|
var mapCategoryToOption2 = (category) => {
|
|
4735
4805
|
return {
|
|
4736
4806
|
type: "category" /* CATEGORY */,
|
|
@@ -4782,7 +4852,7 @@ var Option2 = (props) => {
|
|
|
4782
4852
|
...props,
|
|
4783
4853
|
className: `${props.className} Layer__select__option-content__match`
|
|
4784
4854
|
},
|
|
4785
|
-
/* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__select__option-content__match__main-row" }, /* @__PURE__ */ import_react54.default.createElement("span", { className: "Layer__select__option-content__match__date" }, props.data.payload.date && (0,
|
|
4855
|
+
/* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__select__option-content__match__main-row" }, /* @__PURE__ */ import_react54.default.createElement("span", { className: "Layer__select__option-content__match__date" }, props.data.payload.date && (0, import_date_fns3.format)((0, import_date_fns3.parseISO)(props.data.payload.date), DATE_FORMAT)), /* @__PURE__ */ import_react54.default.createElement("span", { className: "Layer__select__option-content__match__description" }, props.data.payload.display_name)),
|
|
4786
4856
|
/* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__select__option-content__match__amount-row" }, /* @__PURE__ */ import_react54.default.createElement("span", { className: "Layer__select__option-content__match__amount" }, "$", centsToDollars(props.data.payload.amount)))
|
|
4787
4857
|
);
|
|
4788
4858
|
}
|
|
@@ -5221,7 +5291,7 @@ var import_react61 = __toESM(require("react"));
|
|
|
5221
5291
|
|
|
5222
5292
|
// src/components/BankTransactionRow/MatchBadge.tsx
|
|
5223
5293
|
var import_react60 = __toESM(require("react"));
|
|
5224
|
-
var
|
|
5294
|
+
var import_date_fns4 = require("date-fns");
|
|
5225
5295
|
var MatchBadge = ({
|
|
5226
5296
|
bankTransaction,
|
|
5227
5297
|
classNamePrefix,
|
|
@@ -5234,7 +5304,7 @@ var MatchBadge = ({
|
|
|
5234
5304
|
Badge,
|
|
5235
5305
|
{
|
|
5236
5306
|
icon: /* @__PURE__ */ import_react60.default.createElement(MinimizeTwo_default, { size: 11 }),
|
|
5237
|
-
tooltip: /* @__PURE__ */ import_react60.default.createElement("span", { className: `${classNamePrefix}__match-tooltip` }, /* @__PURE__ */ import_react60.default.createElement("div", { className: `${classNamePrefix}__match-tooltip__date` }, (0,
|
|
5307
|
+
tooltip: /* @__PURE__ */ import_react60.default.createElement("span", { className: `${classNamePrefix}__match-tooltip` }, /* @__PURE__ */ import_react60.default.createElement("div", { className: `${classNamePrefix}__match-tooltip__date` }, (0, import_date_fns4.format)((0, import_date_fns4.parseISO)(date), dateFormat)), /* @__PURE__ */ import_react60.default.createElement("div", { className: `${classNamePrefix}__match-tooltip__description` }, bankTransaction.match?.details?.description ?? ""), /* @__PURE__ */ import_react60.default.createElement("div", { className: `${classNamePrefix}__match-tooltip__amount` }, "$", centsToDollars(amount)))
|
|
5238
5308
|
},
|
|
5239
5309
|
text
|
|
5240
5310
|
);
|
|
@@ -5244,7 +5314,7 @@ var MatchBadge = ({
|
|
|
5244
5314
|
|
|
5245
5315
|
// src/components/MatchForm/MatchForm.tsx
|
|
5246
5316
|
var import_classnames28 = __toESM(require("classnames"));
|
|
5247
|
-
var
|
|
5317
|
+
var import_date_fns5 = require("date-fns");
|
|
5248
5318
|
var MatchForm = ({
|
|
5249
5319
|
classNamePrefix,
|
|
5250
5320
|
bankTransaction,
|
|
@@ -5283,7 +5353,7 @@ var MatchForm = ({
|
|
|
5283
5353
|
{
|
|
5284
5354
|
className: `Layer__nowrap ${classNamePrefix}__match-table__date`
|
|
5285
5355
|
},
|
|
5286
|
-
/* @__PURE__ */ import_react61.default.createElement("span", null, (0,
|
|
5356
|
+
/* @__PURE__ */ import_react61.default.createElement("span", null, (0, import_date_fns5.format)((0, import_date_fns5.parseISO)(match.details.date), DATE_FORMAT)),
|
|
5287
5357
|
/* @__PURE__ */ import_react61.default.createElement("span", { className: "amount-next-to-date" }, "$", centsToDollars(match.details.amount))
|
|
5288
5358
|
),
|
|
5289
5359
|
/* @__PURE__ */ import_react61.default.createElement("div", { className: `${classNamePrefix}__match-table__desc` }, /* @__PURE__ */ import_react61.default.createElement(
|
|
@@ -5326,7 +5396,7 @@ var MatchForm = ({
|
|
|
5326
5396
|
// src/components/MatchForm/MatchFormMobile.tsx
|
|
5327
5397
|
var import_react62 = __toESM(require("react"));
|
|
5328
5398
|
var import_classnames29 = __toESM(require("classnames"));
|
|
5329
|
-
var
|
|
5399
|
+
var import_date_fns6 = require("date-fns");
|
|
5330
5400
|
var MatchFormMobile = ({
|
|
5331
5401
|
classNamePrefix,
|
|
5332
5402
|
bankTransaction,
|
|
@@ -5373,7 +5443,7 @@ var MatchFormMobile = ({
|
|
|
5373
5443
|
size: "sm" /* sm */,
|
|
5374
5444
|
as: "span"
|
|
5375
5445
|
},
|
|
5376
|
-
(0,
|
|
5446
|
+
(0, import_date_fns6.format)((0, import_date_fns6.parseISO)(match.details.date), MONTH_DAY_FORMAT)
|
|
5377
5447
|
))),
|
|
5378
5448
|
/* @__PURE__ */ import_react62.default.createElement("div", { className: `${classNamePrefix}__match-item__col-status` }, selectedMatchId && selectedMatchId === match.id ? /* @__PURE__ */ import_react62.default.createElement(
|
|
5379
5449
|
Check_default,
|
|
@@ -5798,7 +5868,6 @@ var ExpandedBankTransactionRow = (0, import_react66.forwardRef)(
|
|
|
5798
5868
|
setSplitFormError(void 0);
|
|
5799
5869
|
};
|
|
5800
5870
|
const save = async () => {
|
|
5801
|
-
const endpoint = `/v1/businesses/${businessId}/bank-transactions/${bankTransaction.id}/metadata`;
|
|
5802
5871
|
if (showDescriptions && memoText != void 0) {
|
|
5803
5872
|
const result = await Layer.updateBankTransactionMetadata(
|
|
5804
5873
|
apiUrl,
|
|
@@ -6170,7 +6239,7 @@ var SplitTooltipDetails = ({
|
|
|
6170
6239
|
|
|
6171
6240
|
// src/components/BankTransactionRow/BankTransactionRow.tsx
|
|
6172
6241
|
var import_classnames33 = __toESM(require("classnames"));
|
|
6173
|
-
var
|
|
6242
|
+
var import_date_fns7 = require("date-fns");
|
|
6174
6243
|
var extractDescriptionForSplit = (category) => {
|
|
6175
6244
|
if (!category.entries) {
|
|
6176
6245
|
return "";
|
|
@@ -6205,9 +6274,9 @@ var BankTransactionRow = ({
|
|
|
6205
6274
|
const expandedRowRef = (0, import_react68.useRef)(null);
|
|
6206
6275
|
const [showRetry, setShowRetry] = (0, import_react68.useState)(false);
|
|
6207
6276
|
const {
|
|
6208
|
-
filters,
|
|
6209
6277
|
categorize: categorizeBankTransaction2,
|
|
6210
|
-
match: matchBankTransaction2
|
|
6278
|
+
match: matchBankTransaction2,
|
|
6279
|
+
shouldHideAfterCategorize
|
|
6211
6280
|
} = useBankTransactionsContext();
|
|
6212
6281
|
const [selectedCategory, setSelectedCategory] = (0, import_react68.useState)(
|
|
6213
6282
|
getDefaultSelectedCategory(bankTransaction)
|
|
@@ -6245,7 +6314,7 @@ var BankTransactionRow = ({
|
|
|
6245
6314
|
}
|
|
6246
6315
|
}, [bankTransaction.error]);
|
|
6247
6316
|
(0, import_react68.useEffect)(() => {
|
|
6248
|
-
if (editable && bankTransaction.recently_categorized) {
|
|
6317
|
+
if (editable && bankTransaction.recently_categorized && shouldHideAfterCategorize(bankTransaction)) {
|
|
6249
6318
|
setTimeout(() => {
|
|
6250
6319
|
removeTransaction(bankTransaction);
|
|
6251
6320
|
}, 300);
|
|
@@ -6278,7 +6347,7 @@ var BankTransactionRow = ({
|
|
|
6278
6347
|
const openClassName = open ? `${className}--expanded` : "";
|
|
6279
6348
|
const rowClassName = (0, import_classnames33.default)(
|
|
6280
6349
|
className,
|
|
6281
|
-
bankTransaction.recently_categorized && editable ? "Layer__bank-transaction-row--removing" : "",
|
|
6350
|
+
bankTransaction.recently_categorized && editable && shouldHideAfterCategorize(bankTransaction) ? "Layer__bank-transaction-row--removing" : "",
|
|
6282
6351
|
open ? openClassName : "",
|
|
6283
6352
|
initialLoad ? "initial-load" : "",
|
|
6284
6353
|
showComponent ? "show" : ""
|
|
@@ -6289,7 +6358,7 @@ var BankTransactionRow = ({
|
|
|
6289
6358
|
className: "Layer__table-cell Layer__bank-transaction-table__date-col",
|
|
6290
6359
|
...openRow
|
|
6291
6360
|
},
|
|
6292
|
-
/* @__PURE__ */ import_react68.default.createElement("span", { className: "Layer__table-cell-content" }, (0,
|
|
6361
|
+
/* @__PURE__ */ import_react68.default.createElement("span", { className: "Layer__table-cell-content" }, (0, import_date_fns7.format)((0, import_date_fns7.parseISO)(bankTransaction.date), dateFormat))
|
|
6293
6362
|
), /* @__PURE__ */ import_react68.default.createElement(
|
|
6294
6363
|
"td",
|
|
6295
6364
|
{
|
|
@@ -6378,8 +6447,8 @@ var BankTransactionRow = ({
|
|
|
6378
6447
|
bankTransaction,
|
|
6379
6448
|
dateFormat
|
|
6380
6449
|
}
|
|
6381
|
-
), /* @__PURE__ */ import_react68.default.createElement("span", { className: `${className}__category-text__text` }, `${(0,
|
|
6382
|
-
(0,
|
|
6450
|
+
), /* @__PURE__ */ import_react68.default.createElement("span", { className: `${className}__category-text__text` }, `${(0, import_date_fns7.format)(
|
|
6451
|
+
(0, import_date_fns7.parseISO)(bankTransaction.match.bank_transaction.date),
|
|
6383
6452
|
dateFormat
|
|
6384
6453
|
)}, ${bankTransaction.match?.details?.description}`)), bankTransaction?.categorization_status !== "MATCHED" /* MATCHED */ && bankTransaction?.categorization_status !== "SPLIT" /* SPLIT */ && /* @__PURE__ */ import_react68.default.createElement("span", { className: `${className}__category-text__text` }, bankTransaction?.category?.display_name)) : null,
|
|
6385
6454
|
!categorized && !open && showRetry ? /* @__PURE__ */ import_react68.default.createElement(
|
|
@@ -6454,7 +6523,7 @@ var BankTransactionRow = ({
|
|
|
6454
6523
|
|
|
6455
6524
|
// src/components/BankTransactionList/Assignment.tsx
|
|
6456
6525
|
var import_react69 = __toESM(require("react"));
|
|
6457
|
-
var
|
|
6526
|
+
var import_date_fns8 = require("date-fns");
|
|
6458
6527
|
var Assignment = ({ bankTransaction }) => {
|
|
6459
6528
|
if (bankTransaction.match && bankTransaction.categorization_status === "MATCHED" /* MATCHED */) {
|
|
6460
6529
|
return /* @__PURE__ */ import_react69.default.createElement(import_react69.default.Fragment, null, /* @__PURE__ */ import_react69.default.createElement(
|
|
@@ -6465,8 +6534,8 @@ var Assignment = ({ bankTransaction }) => {
|
|
|
6465
6534
|
dateFormat: DATE_FORMAT,
|
|
6466
6535
|
text: "Matched"
|
|
6467
6536
|
}
|
|
6468
|
-
), /* @__PURE__ */ import_react69.default.createElement(Text, { className: "Layer__bank-transaction-list-item__category-text__text" }, `${(0,
|
|
6469
|
-
(0,
|
|
6537
|
+
), /* @__PURE__ */ import_react69.default.createElement(Text, { className: "Layer__bank-transaction-list-item__category-text__text" }, `${(0, import_date_fns8.format)(
|
|
6538
|
+
(0, import_date_fns8.parseISO)(bankTransaction.match.bank_transaction.date),
|
|
6470
6539
|
DATE_FORMAT
|
|
6471
6540
|
)}, ${bankTransaction.match.bank_transaction.description ?? bankTransaction.match?.details?.description}`));
|
|
6472
6541
|
}
|
|
@@ -6491,7 +6560,7 @@ var Assignment = ({ bankTransaction }) => {
|
|
|
6491
6560
|
|
|
6492
6561
|
// src/components/BankTransactionList/BankTransactionListItem.tsx
|
|
6493
6562
|
var import_classnames34 = __toESM(require("classnames"));
|
|
6494
|
-
var
|
|
6563
|
+
var import_date_fns9 = require("date-fns");
|
|
6495
6564
|
var BankTransactionListItem = ({
|
|
6496
6565
|
index = 0,
|
|
6497
6566
|
dateFormat,
|
|
@@ -6506,7 +6575,11 @@ var BankTransactionListItem = ({
|
|
|
6506
6575
|
}) => {
|
|
6507
6576
|
const expandedRowRef = (0, import_react70.useRef)(null);
|
|
6508
6577
|
const [showRetry, setShowRetry] = (0, import_react70.useState)(false);
|
|
6509
|
-
const {
|
|
6578
|
+
const {
|
|
6579
|
+
categorize: categorizeBankTransaction2,
|
|
6580
|
+
match: matchBankTransaction2,
|
|
6581
|
+
shouldHideAfterCategorize
|
|
6582
|
+
} = useBankTransactionsContext();
|
|
6510
6583
|
const [selectedCategory, setSelectedCategory] = (0, import_react70.useState)(
|
|
6511
6584
|
getDefaultSelectedCategory(bankTransaction)
|
|
6512
6585
|
);
|
|
@@ -6528,7 +6601,7 @@ var BankTransactionListItem = ({
|
|
|
6528
6601
|
}
|
|
6529
6602
|
}, [bankTransaction.error]);
|
|
6530
6603
|
(0, import_react70.useEffect)(() => {
|
|
6531
|
-
if (editable && bankTransaction.recently_categorized) {
|
|
6604
|
+
if (editable && bankTransaction.recently_categorized && shouldHideAfterCategorize(bankTransaction)) {
|
|
6532
6605
|
setTimeout(() => {
|
|
6533
6606
|
removeTransaction(bankTransaction);
|
|
6534
6607
|
}, 300);
|
|
@@ -6556,11 +6629,11 @@ var BankTransactionListItem = ({
|
|
|
6556
6629
|
const openClassName = open ? `${className}--expanded` : "";
|
|
6557
6630
|
const rowClassName = (0, import_classnames34.default)(
|
|
6558
6631
|
className,
|
|
6559
|
-
bankTransaction.recently_categorized && editable ? "Layer__bank-transaction-row--removing" : "",
|
|
6632
|
+
bankTransaction.recently_categorized && editable && shouldHideAfterCategorize(bankTransaction) ? "Layer__bank-transaction-row--removing" : "",
|
|
6560
6633
|
open ? openClassName : "",
|
|
6561
6634
|
showComponent ? "show" : ""
|
|
6562
6635
|
);
|
|
6563
|
-
return /* @__PURE__ */ import_react70.default.createElement("li", { className: rowClassName }, /* @__PURE__ */ import_react70.default.createElement("span", { className: `${className}__heading` }, /* @__PURE__ */ import_react70.default.createElement("div", { className: `${className}__heading__main` }, /* @__PURE__ */ import_react70.default.createElement("span", { className: `${className}__heading-date` }, (0,
|
|
6636
|
+
return /* @__PURE__ */ import_react70.default.createElement("li", { className: rowClassName }, /* @__PURE__ */ import_react70.default.createElement("span", { className: `${className}__heading` }, /* @__PURE__ */ import_react70.default.createElement("div", { className: `${className}__heading__main` }, /* @__PURE__ */ import_react70.default.createElement("span", { className: `${className}__heading-date` }, (0, import_date_fns9.format)((0, import_date_fns9.parseISO)(bankTransaction.date), dateFormat)), /* @__PURE__ */ import_react70.default.createElement("span", { className: `${className}__heading-separator` }), /* @__PURE__ */ import_react70.default.createElement("span", { className: `${className}__heading-account-name` }, bankTransaction.account_name ?? "")), /* @__PURE__ */ import_react70.default.createElement(
|
|
6564
6637
|
"div",
|
|
6565
6638
|
{
|
|
6566
6639
|
onClick: toggleOpen,
|
|
@@ -7127,7 +7200,7 @@ var TransactionToOpenContext = (0, import_react78.createContext)({
|
|
|
7127
7200
|
|
|
7128
7201
|
// src/components/BankTransactionMobileList/BankTransactionMobileListItem.tsx
|
|
7129
7202
|
var import_classnames36 = __toESM(require("classnames"));
|
|
7130
|
-
var
|
|
7203
|
+
var import_date_fns10 = require("date-fns");
|
|
7131
7204
|
var DATE_FORMAT2 = "LLL d";
|
|
7132
7205
|
var getAssignedValue2 = (bankTransaction) => {
|
|
7133
7206
|
if (bankTransaction.categorization_status === "SPLIT" /* SPLIT */) {
|
|
@@ -7152,6 +7225,7 @@ var BankTransactionMobileListItem = ({
|
|
|
7152
7225
|
setTransactionIdToOpen,
|
|
7153
7226
|
clearTransactionIdToOpen
|
|
7154
7227
|
} = (0, import_react79.useContext)(TransactionToOpenContext);
|
|
7228
|
+
const { shouldHideAfterCategorize } = useBankTransactionsContext();
|
|
7155
7229
|
const formRowRef = useElementSize(
|
|
7156
7230
|
(_a, _b, { height: height2 }) => setHeight(height2)
|
|
7157
7231
|
);
|
|
@@ -7185,7 +7259,7 @@ var BankTransactionMobileListItem = ({
|
|
|
7185
7259
|
}, [transactionIdToOpen]);
|
|
7186
7260
|
(0, import_react79.useEffect)(() => {
|
|
7187
7261
|
if (!removeAnim && bankTransaction.recently_categorized) {
|
|
7188
|
-
if (editable) {
|
|
7262
|
+
if (editable && shouldHideAfterCategorize(bankTransaction)) {
|
|
7189
7263
|
setRemoveAnim(true);
|
|
7190
7264
|
openNext();
|
|
7191
7265
|
} else {
|
|
@@ -7218,7 +7292,7 @@ var BankTransactionMobileListItem = ({
|
|
|
7218
7292
|
}
|
|
7219
7293
|
}, []);
|
|
7220
7294
|
(0, import_react79.useEffect)(() => {
|
|
7221
|
-
if (editable && bankTransaction.recently_categorized) {
|
|
7295
|
+
if (editable && bankTransaction.recently_categorized && shouldHideAfterCategorize(bankTransaction)) {
|
|
7222
7296
|
setTimeout(() => {
|
|
7223
7297
|
removeTransaction(bankTransaction);
|
|
7224
7298
|
}, 300);
|
|
@@ -7249,7 +7323,7 @@ var BankTransactionMobileListItem = ({
|
|
|
7249
7323
|
},
|
|
7250
7324
|
isCredit(bankTransaction) ? "+$" : " $",
|
|
7251
7325
|
centsToDollars(bankTransaction.amount)
|
|
7252
|
-
), /* @__PURE__ */ import_react79.default.createElement("span", { className: `${className}__heading__date` }, (0,
|
|
7326
|
+
), /* @__PURE__ */ import_react79.default.createElement("span", { className: `${className}__heading__date` }, (0, import_date_fns10.format)((0, import_date_fns10.parseISO)(bankTransaction.date), DATE_FORMAT2))))
|
|
7253
7327
|
), categorizationEnabled(mode) ? /* @__PURE__ */ import_react79.default.createElement(
|
|
7254
7328
|
"div",
|
|
7255
7329
|
{
|
|
@@ -7772,11 +7846,11 @@ var DownloadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React103.create
|
|
|
7772
7846
|
var DownloadCloud_default = DownloadCloud;
|
|
7773
7847
|
|
|
7774
7848
|
// src/utils/business.ts
|
|
7775
|
-
var
|
|
7849
|
+
var import_date_fns11 = require("date-fns");
|
|
7776
7850
|
var getActivationDate = (business) => {
|
|
7777
7851
|
try {
|
|
7778
7852
|
if (business && business.activation_at) {
|
|
7779
|
-
return (0,
|
|
7853
|
+
return (0, import_date_fns11.parseISO)(business.activation_at);
|
|
7780
7854
|
}
|
|
7781
7855
|
return;
|
|
7782
7856
|
} catch (_err) {
|
|
@@ -7786,7 +7860,7 @@ var getActivationDate = (business) => {
|
|
|
7786
7860
|
var getEarliestDateToBrowse = (business) => {
|
|
7787
7861
|
const activationDate = getActivationDate(business);
|
|
7788
7862
|
if (activationDate) {
|
|
7789
|
-
return (0,
|
|
7863
|
+
return (0, import_date_fns11.startOfMonth)(activationDate);
|
|
7790
7864
|
}
|
|
7791
7865
|
return;
|
|
7792
7866
|
};
|
|
@@ -7798,7 +7872,7 @@ var isDateAllowedToBrowse = (date, business) => {
|
|
|
7798
7872
|
if (!activationDate) {
|
|
7799
7873
|
return true;
|
|
7800
7874
|
}
|
|
7801
|
-
return (0,
|
|
7875
|
+
return (0, import_date_fns11.differenceInCalendarMonths)((0, import_date_fns11.startOfMonth)(date), activationDate) >= 0;
|
|
7802
7876
|
};
|
|
7803
7877
|
|
|
7804
7878
|
// src/components/DatePicker/DatePicker.tsx
|
|
@@ -7807,7 +7881,7 @@ var import_react_datepicker = __toESM(require("react-datepicker"));
|
|
|
7807
7881
|
|
|
7808
7882
|
// src/components/DatePicker/DatePickerOptions.tsx
|
|
7809
7883
|
var import_react90 = __toESM(require("react"));
|
|
7810
|
-
var
|
|
7884
|
+
var import_date_fns12 = require("date-fns");
|
|
7811
7885
|
var DatePickerOptions = ({
|
|
7812
7886
|
options,
|
|
7813
7887
|
setSelectedDate
|
|
@@ -7822,8 +7896,8 @@ var DatePickerOptions = ({
|
|
|
7822
7896
|
key: option,
|
|
7823
7897
|
onClick: () => {
|
|
7824
7898
|
setSelectedDate([
|
|
7825
|
-
(0,
|
|
7826
|
-
(0,
|
|
7899
|
+
(0, import_date_fns12.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
7900
|
+
(0, import_date_fns12.endOfMonth)(/* @__PURE__ */ new Date())
|
|
7827
7901
|
]);
|
|
7828
7902
|
}
|
|
7829
7903
|
},
|
|
@@ -7836,8 +7910,8 @@ var DatePickerOptions = ({
|
|
|
7836
7910
|
key: option,
|
|
7837
7911
|
onClick: () => {
|
|
7838
7912
|
setSelectedDate([
|
|
7839
|
-
(0,
|
|
7840
|
-
(0,
|
|
7913
|
+
(0, import_date_fns12.startOfMonth)((0, import_date_fns12.subMonths)(/* @__PURE__ */ new Date(), 1)),
|
|
7914
|
+
(0, import_date_fns12.endOfMonth)((0, import_date_fns12.subMonths)(/* @__PURE__ */ new Date(), 1))
|
|
7841
7915
|
]);
|
|
7842
7916
|
}
|
|
7843
7917
|
},
|
|
@@ -7850,8 +7924,8 @@ var DatePickerOptions = ({
|
|
|
7850
7924
|
key: option,
|
|
7851
7925
|
onClick: () => {
|
|
7852
7926
|
setSelectedDate([
|
|
7853
|
-
(0,
|
|
7854
|
-
(0,
|
|
7927
|
+
(0, import_date_fns12.startOfQuarter)(/* @__PURE__ */ new Date()),
|
|
7928
|
+
(0, import_date_fns12.endOfQuarter)(/* @__PURE__ */ new Date())
|
|
7855
7929
|
]);
|
|
7856
7930
|
}
|
|
7857
7931
|
},
|
|
@@ -7863,10 +7937,10 @@ var DatePickerOptions = ({
|
|
|
7863
7937
|
{
|
|
7864
7938
|
key: option,
|
|
7865
7939
|
onClick: () => {
|
|
7866
|
-
const lastQuarter = (0,
|
|
7940
|
+
const lastQuarter = (0, import_date_fns12.subQuarters)(/* @__PURE__ */ new Date(), 1);
|
|
7867
7941
|
setSelectedDate([
|
|
7868
|
-
(0,
|
|
7869
|
-
(0,
|
|
7942
|
+
(0, import_date_fns12.startOfQuarter)(lastQuarter),
|
|
7943
|
+
(0, import_date_fns12.endOfQuarter)(lastQuarter)
|
|
7870
7944
|
]);
|
|
7871
7945
|
}
|
|
7872
7946
|
},
|
|
@@ -7878,7 +7952,7 @@ var DatePickerOptions = ({
|
|
|
7878
7952
|
{
|
|
7879
7953
|
key: option,
|
|
7880
7954
|
onClick: () => {
|
|
7881
|
-
setSelectedDate([(0,
|
|
7955
|
+
setSelectedDate([(0, import_date_fns12.startOfYear)(/* @__PURE__ */ new Date()), (0, import_date_fns12.endOfYear)(/* @__PURE__ */ new Date())]);
|
|
7882
7956
|
}
|
|
7883
7957
|
},
|
|
7884
7958
|
"This year"
|
|
@@ -7889,8 +7963,8 @@ var DatePickerOptions = ({
|
|
|
7889
7963
|
{
|
|
7890
7964
|
key: option,
|
|
7891
7965
|
onClick: () => {
|
|
7892
|
-
const lastYear = (0,
|
|
7893
|
-
setSelectedDate([(0,
|
|
7966
|
+
const lastYear = (0, import_date_fns12.subYears)(/* @__PURE__ */ new Date(), 1);
|
|
7967
|
+
setSelectedDate([(0, import_date_fns12.startOfYear)(lastYear), (0, import_date_fns12.endOfYear)(lastYear)]);
|
|
7894
7968
|
}
|
|
7895
7969
|
},
|
|
7896
7970
|
"Last year"
|
|
@@ -8169,7 +8243,7 @@ var DatePicker = ({
|
|
|
8169
8243
|
|
|
8170
8244
|
// src/components/BankTransactions/BankTransactionsHeader.tsx
|
|
8171
8245
|
var import_classnames41 = __toESM(require("classnames"));
|
|
8172
|
-
var
|
|
8246
|
+
var import_date_fns13 = require("date-fns");
|
|
8173
8247
|
var DownloadButton = ({
|
|
8174
8248
|
downloadButtonTextOverride,
|
|
8175
8249
|
iconOnly
|
|
@@ -8275,8 +8349,8 @@ var BankTransactionsHeader = ({
|
|
|
8275
8349
|
onChange: (date) => {
|
|
8276
8350
|
if (!Array.isArray(date)) {
|
|
8277
8351
|
setDateRange({
|
|
8278
|
-
startDate: (0,
|
|
8279
|
-
endDate: (0,
|
|
8352
|
+
startDate: (0, import_date_fns13.startOfMonth)(date),
|
|
8353
|
+
endDate: (0, import_date_fns13.endOfMonth)(date)
|
|
8280
8354
|
});
|
|
8281
8355
|
}
|
|
8282
8356
|
},
|
|
@@ -8351,7 +8425,7 @@ var DataStates = ({
|
|
|
8351
8425
|
editable
|
|
8352
8426
|
}) => {
|
|
8353
8427
|
let title = editable ? "You are up to date with transactions!" : "You have no categorized transactions";
|
|
8354
|
-
let description = editable ? "All uncategorized
|
|
8428
|
+
let description = editable ? "All uncategorized transactions will be displayed here" : "All transactions will be displayed here once reviewed";
|
|
8355
8429
|
const showRefreshButton = bankTransactions?.length;
|
|
8356
8430
|
return /* @__PURE__ */ import_react93.default.createElement(import_react93.default.Fragment, null, !isLoading && !error && (bankTransactions === void 0 || bankTransactions !== void 0 && bankTransactions.length === 0) ? /* @__PURE__ */ import_react93.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react93.default.createElement(
|
|
8357
8431
|
DataState,
|
|
@@ -8376,10 +8450,9 @@ var DataStates = ({
|
|
|
8376
8450
|
};
|
|
8377
8451
|
|
|
8378
8452
|
// src/components/BankTransactions/BankTransactions.tsx
|
|
8379
|
-
var
|
|
8453
|
+
var import_date_fns14 = require("date-fns");
|
|
8380
8454
|
var COMPONENT_NAME2 = "bank-transactions";
|
|
8381
8455
|
var TEST_EMPTY_STATE = false;
|
|
8382
|
-
var POLL_INTERVAL = 1e3;
|
|
8383
8456
|
var categorizationEnabled = (mode) => {
|
|
8384
8457
|
if (mode === "bookkeeping-client") {
|
|
8385
8458
|
return false;
|
|
@@ -8399,6 +8472,7 @@ var BankTransactionsContent = ({
|
|
|
8399
8472
|
showDescriptions = false,
|
|
8400
8473
|
showReceiptUploads = false,
|
|
8401
8474
|
monthlyView = false,
|
|
8475
|
+
categorizeView: categorizeViewProp,
|
|
8402
8476
|
mobileComponent,
|
|
8403
8477
|
filters: inputFilters,
|
|
8404
8478
|
hideHeader = false,
|
|
@@ -8407,10 +8481,10 @@ var BankTransactionsContent = ({
|
|
|
8407
8481
|
const [currentPage, setCurrentPage] = (0, import_react94.useState)(1);
|
|
8408
8482
|
const [initialLoad, setInitialLoad] = (0, import_react94.useState)(true);
|
|
8409
8483
|
const [dateRange, setDateRange] = (0, import_react94.useState)({
|
|
8410
|
-
startDate: (0,
|
|
8411
|
-
endDate: (0,
|
|
8484
|
+
startDate: (0, import_date_fns14.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
8485
|
+
endDate: (0, import_date_fns14.endOfMonth)(/* @__PURE__ */ new Date())
|
|
8412
8486
|
});
|
|
8413
|
-
const categorizeView = categorizationEnabled(mode);
|
|
8487
|
+
const categorizeView = categorizeViewProp ?? categorizationEnabled(mode);
|
|
8414
8488
|
const {
|
|
8415
8489
|
activate,
|
|
8416
8490
|
data,
|
|
@@ -8426,51 +8500,23 @@ var BankTransactionsContent = ({
|
|
|
8426
8500
|
fetchMore,
|
|
8427
8501
|
removeAfterCategorize
|
|
8428
8502
|
} = useBankTransactionsContext();
|
|
8429
|
-
const { data: linkedAccounts
|
|
8503
|
+
const { data: linkedAccounts } = useLinkedAccounts();
|
|
8430
8504
|
const isSyncing = (0, import_react94.useMemo)(
|
|
8431
8505
|
() => Boolean(linkedAccounts?.some((item) => item.is_syncing)),
|
|
8432
8506
|
[linkedAccounts]
|
|
8433
8507
|
);
|
|
8434
|
-
const transactionsNotSynced = (0, import_react94.useMemo)(
|
|
8435
|
-
() => loadingStatus === "complete" && isSyncing && (!data || data?.length === 0),
|
|
8436
|
-
[data, isSyncing, loadingStatus]
|
|
8437
|
-
);
|
|
8438
|
-
let intervalId = void 0;
|
|
8439
|
-
const [refreshTrigger, setRefreshTrigger] = (0, import_react94.useState)(-1);
|
|
8440
|
-
(0, import_react94.useEffect)(() => {
|
|
8441
|
-
if (refreshTrigger !== -1) {
|
|
8442
|
-
refetch();
|
|
8443
|
-
refetchAccounts();
|
|
8444
|
-
}
|
|
8445
|
-
}, [refreshTrigger]);
|
|
8446
|
-
(0, import_react94.useEffect)(() => {
|
|
8447
|
-
if (isSyncing) {
|
|
8448
|
-
intervalId = setInterval(() => {
|
|
8449
|
-
setRefreshTrigger(Math.random());
|
|
8450
|
-
}, POLL_INTERVAL);
|
|
8451
|
-
} else {
|
|
8452
|
-
if (intervalId) {
|
|
8453
|
-
clearInterval(intervalId);
|
|
8454
|
-
}
|
|
8455
|
-
}
|
|
8456
|
-
return () => {
|
|
8457
|
-
if (intervalId) {
|
|
8458
|
-
clearInterval(intervalId);
|
|
8459
|
-
}
|
|
8460
|
-
};
|
|
8461
|
-
}, [isSyncing, transactionsNotSynced]);
|
|
8462
8508
|
(0, import_react94.useEffect)(() => {
|
|
8463
8509
|
activate();
|
|
8464
8510
|
}, []);
|
|
8465
8511
|
(0, import_react94.useEffect)(() => {
|
|
8466
8512
|
if (JSON.stringify(inputFilters) !== JSON.stringify(filters)) {
|
|
8467
|
-
if (!
|
|
8513
|
+
if (!inputFilters?.categorizationStatus && categorizeView) {
|
|
8468
8514
|
setFilters({
|
|
8469
8515
|
...filters,
|
|
8470
8516
|
...inputFilters,
|
|
8471
8517
|
categorizationStatus: "review" /* review */
|
|
8472
8518
|
});
|
|
8473
|
-
} else if (!
|
|
8519
|
+
} else if (!inputFilters?.categorizationStatus && !categorizationEnabled(mode)) {
|
|
8474
8520
|
setFilters({
|
|
8475
8521
|
...filters,
|
|
8476
8522
|
...inputFilters,
|
|
@@ -8479,11 +8525,11 @@ var BankTransactionsContent = ({
|
|
|
8479
8525
|
} else {
|
|
8480
8526
|
setFilters({ ...filters, ...inputFilters });
|
|
8481
8527
|
}
|
|
8482
|
-
} else if (!
|
|
8528
|
+
} else if (!inputFilters?.categorizationStatus && categorizeView) {
|
|
8483
8529
|
setFilters({
|
|
8484
8530
|
categorizationStatus: "review" /* review */
|
|
8485
8531
|
});
|
|
8486
|
-
} else if (!
|
|
8532
|
+
} else if (!inputFilters?.categorizationStatus && !categorizationEnabled(mode)) {
|
|
8487
8533
|
setFilters({
|
|
8488
8534
|
categorizationStatus: "categorized" /* categorized */
|
|
8489
8535
|
});
|
|
@@ -8500,7 +8546,7 @@ var BankTransactionsContent = ({
|
|
|
8500
8546
|
const bankTransactions = TEST_EMPTY_STATE ? [] : (0, import_react94.useMemo)(() => {
|
|
8501
8547
|
if (monthlyView) {
|
|
8502
8548
|
return data?.filter(
|
|
8503
|
-
(x) => (0,
|
|
8549
|
+
(x) => (0, import_date_fns14.parseISO)(x.date) >= dateRange.startDate && (0, import_date_fns14.parseISO)(x.date) <= dateRange.endDate
|
|
8504
8550
|
);
|
|
8505
8551
|
}
|
|
8506
8552
|
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
@@ -8509,7 +8555,7 @@ var BankTransactionsContent = ({
|
|
|
8509
8555
|
}, [currentPage, data, dateRange]);
|
|
8510
8556
|
const onCategorizationDisplayChange = (event) => {
|
|
8511
8557
|
setFilters({
|
|
8512
|
-
categorizationStatus: event.target.value === "categorized" /* categorized */ ? "categorized" /* categorized */ : "review" /* review */
|
|
8558
|
+
categorizationStatus: event.target.value === "categorized" /* categorized */ ? "categorized" /* categorized */ : event.target.value === "all" /* all */ ? "all" /* all */ : "review" /* review */
|
|
8513
8559
|
});
|
|
8514
8560
|
setCurrentPage(1);
|
|
8515
8561
|
};
|
|
@@ -8535,7 +8581,7 @@ var BankTransactionsContent = ({
|
|
|
8535
8581
|
}
|
|
8536
8582
|
debounceContainerWidth(size?.width);
|
|
8537
8583
|
});
|
|
8538
|
-
const editable = display === "review" /* review */;
|
|
8584
|
+
const editable = display === "review" /* review */ || display === "all" /* all */;
|
|
8539
8585
|
const isLastPage = data && !hasMore && Math.ceil((data?.length || 0) / pageSize) === currentPage;
|
|
8540
8586
|
return /* @__PURE__ */ import_react94.default.createElement(
|
|
8541
8587
|
Container,
|
|
@@ -8785,14 +8831,14 @@ var applyShare = (items, total) => {
|
|
|
8785
8831
|
|
|
8786
8832
|
// src/hooks/useProfitAndLoss/useProfitAndLossLTM.tsx
|
|
8787
8833
|
var import_react97 = require("react");
|
|
8788
|
-
var
|
|
8834
|
+
var import_date_fns15 = require("date-fns");
|
|
8789
8835
|
var import_swr3 = __toESM(require("swr"));
|
|
8790
8836
|
var buildDates = ({ currentDate }) => {
|
|
8791
8837
|
return {
|
|
8792
|
-
startYear: (0,
|
|
8793
|
-
startMonth: (0,
|
|
8794
|
-
endYear: (0,
|
|
8795
|
-
endMonth: (0,
|
|
8838
|
+
startYear: (0, import_date_fns15.startOfMonth)(currentDate).getFullYear() - 1,
|
|
8839
|
+
startMonth: (0, import_date_fns15.startOfMonth)(currentDate).getMonth() + 1,
|
|
8840
|
+
endYear: (0, import_date_fns15.startOfMonth)(currentDate).getFullYear(),
|
|
8841
|
+
endMonth: (0, import_date_fns15.startOfMonth)(currentDate).getMonth() + 1
|
|
8796
8842
|
};
|
|
8797
8843
|
};
|
|
8798
8844
|
var buildMonthsArray = (startDate, endDate) => {
|
|
@@ -8806,7 +8852,7 @@ var buildMonthsArray = (startDate, endDate) => {
|
|
|
8806
8852
|
return dates;
|
|
8807
8853
|
};
|
|
8808
8854
|
var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
8809
|
-
currentDate: (0,
|
|
8855
|
+
currentDate: (0, import_date_fns15.startOfMonth)(Date.now())
|
|
8810
8856
|
}) => {
|
|
8811
8857
|
const {
|
|
8812
8858
|
businessId,
|
|
@@ -8849,7 +8895,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
8849
8895
|
);
|
|
8850
8896
|
(0, import_react97.useEffect)(() => {
|
|
8851
8897
|
const newData = data.slice();
|
|
8852
|
-
const newPeriod = buildMonthsArray((0,
|
|
8898
|
+
const newPeriod = buildMonthsArray((0, import_date_fns15.sub)(date, { years: 1 }), date);
|
|
8853
8899
|
if (newData && newPeriod) {
|
|
8854
8900
|
newPeriod.forEach((x) => {
|
|
8855
8901
|
if (!newData?.find(
|
|
@@ -8943,7 +8989,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
8943
8989
|
|
|
8944
8990
|
// src/hooks/useProfitAndLoss/useProfitAndLossQuery.tsx
|
|
8945
8991
|
var import_react98 = require("react");
|
|
8946
|
-
var
|
|
8992
|
+
var import_date_fns16 = require("date-fns");
|
|
8947
8993
|
var import_swr4 = __toESM(require("swr"));
|
|
8948
8994
|
var useProfitAndLossQuery = ({
|
|
8949
8995
|
startDate,
|
|
@@ -8951,8 +8997,8 @@ var useProfitAndLossQuery = ({
|
|
|
8951
8997
|
tagFilter,
|
|
8952
8998
|
reportingBasis
|
|
8953
8999
|
} = {
|
|
8954
|
-
startDate: (0,
|
|
8955
|
-
endDate: (0,
|
|
9000
|
+
startDate: (0, import_date_fns16.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
9001
|
+
endDate: (0, import_date_fns16.endOfMonth)(/* @__PURE__ */ new Date())
|
|
8956
9002
|
}) => {
|
|
8957
9003
|
const { auth, businessId, apiUrl, syncTimestamps, read, hasBeenTouched } = useLayerContext();
|
|
8958
9004
|
const queryKey = businessId && startDate && endDate && auth?.access_token && `profit-and-loss-${businessId}-${startDate.valueOf()}-${endDate.valueOf()}-${tagFilter?.key}-${tagFilter?.values?.join(
|
|
@@ -8969,8 +9015,8 @@ var useProfitAndLossQuery = ({
|
|
|
8969
9015
|
Layer.getProfitAndLoss(apiUrl, auth?.access_token, {
|
|
8970
9016
|
params: {
|
|
8971
9017
|
businessId,
|
|
8972
|
-
startDate: (0,
|
|
8973
|
-
endDate: (0,
|
|
9018
|
+
startDate: (0, import_date_fns16.formatISO)(startDate.valueOf()),
|
|
9019
|
+
endDate: (0, import_date_fns16.formatISO)(endDate.valueOf()),
|
|
8974
9020
|
tagKey: tagFilter?.key,
|
|
8975
9021
|
tagValues: tagFilter?.values?.join(","),
|
|
8976
9022
|
reportingBasis
|
|
@@ -9002,21 +9048,21 @@ var useProfitAndLossQuery = ({
|
|
|
9002
9048
|
};
|
|
9003
9049
|
|
|
9004
9050
|
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
9005
|
-
var
|
|
9051
|
+
var import_date_fns17 = require("date-fns");
|
|
9006
9052
|
var useProfitAndLoss = ({
|
|
9007
9053
|
startDate: initialStartDate,
|
|
9008
9054
|
endDate: initialEndDate,
|
|
9009
9055
|
tagFilter,
|
|
9010
9056
|
reportingBasis
|
|
9011
9057
|
} = {
|
|
9012
|
-
startDate: (0,
|
|
9013
|
-
endDate: (0,
|
|
9058
|
+
startDate: (0, import_date_fns17.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
9059
|
+
endDate: (0, import_date_fns17.endOfMonth)(/* @__PURE__ */ new Date())
|
|
9014
9060
|
}) => {
|
|
9015
9061
|
const [startDate, setStartDate] = (0, import_react99.useState)(
|
|
9016
|
-
initialStartDate || (0,
|
|
9062
|
+
initialStartDate || (0, import_date_fns17.startOfMonth)(Date.now())
|
|
9017
9063
|
);
|
|
9018
9064
|
const [endDate, setEndDate] = (0, import_react99.useState)(
|
|
9019
|
-
initialEndDate || (0,
|
|
9065
|
+
initialEndDate || (0, import_date_fns17.endOfMonth)(Date.now())
|
|
9020
9066
|
);
|
|
9021
9067
|
const [filters, setFilters] = (0, import_react99.useState)({
|
|
9022
9068
|
expenses: void 0,
|
|
@@ -9030,7 +9076,7 @@ var useProfitAndLoss = ({
|
|
|
9030
9076
|
reportingBasis
|
|
9031
9077
|
});
|
|
9032
9078
|
const { data: summaryData } = useProfitAndLossLTM({
|
|
9033
|
-
currentDate: startDate ? startDate : (0,
|
|
9079
|
+
currentDate: startDate ? startDate : (0, import_date_fns17.startOfMonth)(/* @__PURE__ */ new Date())
|
|
9034
9080
|
});
|
|
9035
9081
|
const changeDateRange = ({
|
|
9036
9082
|
startDate: newStartDate,
|
|
@@ -9243,53 +9289,53 @@ var Indicator = ({
|
|
|
9243
9289
|
|
|
9244
9290
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
9245
9291
|
var import_classnames42 = __toESM(require("classnames"));
|
|
9246
|
-
var
|
|
9292
|
+
var import_date_fns18 = require("date-fns");
|
|
9247
9293
|
var import_recharts = require("recharts");
|
|
9248
9294
|
var getChartWindow = ({
|
|
9249
9295
|
chartWindow,
|
|
9250
9296
|
currentYear,
|
|
9251
9297
|
currentMonth
|
|
9252
9298
|
}) => {
|
|
9253
|
-
const today = (0,
|
|
9254
|
-
const yearAgo = (0,
|
|
9255
|
-
const current = (0,
|
|
9256
|
-
if ((0,
|
|
9299
|
+
const today = (0, import_date_fns18.startOfMonth)(Date.now());
|
|
9300
|
+
const yearAgo = (0, import_date_fns18.sub)(today, { months: 11 });
|
|
9301
|
+
const current = (0, import_date_fns18.startOfMonth)(new Date(currentYear, currentMonth - 1, 1));
|
|
9302
|
+
if ((0, import_date_fns18.differenceInMonths)((0, import_date_fns18.startOfMonth)(chartWindow.start), current) < 0 && (0, import_date_fns18.differenceInMonths)((0, import_date_fns18.startOfMonth)(chartWindow.end), current) > 1) {
|
|
9257
9303
|
return chartWindow;
|
|
9258
9304
|
}
|
|
9259
|
-
if ((0,
|
|
9305
|
+
if ((0, import_date_fns18.differenceInMonths)((0, import_date_fns18.startOfMonth)(chartWindow.start), current) === 0) {
|
|
9260
9306
|
return {
|
|
9261
|
-
start: (0,
|
|
9262
|
-
end: (0,
|
|
9307
|
+
start: (0, import_date_fns18.startOfMonth)((0, import_date_fns18.sub)(current, { months: 1 })),
|
|
9308
|
+
end: (0, import_date_fns18.endOfMonth)((0, import_date_fns18.add)(current, { months: 11 }))
|
|
9263
9309
|
};
|
|
9264
9310
|
}
|
|
9265
|
-
if ((0,
|
|
9311
|
+
if ((0, import_date_fns18.differenceInMonths)((0, import_date_fns18.endOfMonth)(chartWindow.end), (0, import_date_fns18.endOfMonth)(current)) === 1 && (0, import_date_fns18.differenceInMonths)(today, current) >= 1) {
|
|
9266
9312
|
return {
|
|
9267
|
-
start: (0,
|
|
9268
|
-
end: (0,
|
|
9313
|
+
start: (0, import_date_fns18.startOfMonth)((0, import_date_fns18.sub)(current, { months: 10 })),
|
|
9314
|
+
end: (0, import_date_fns18.endOfMonth)((0, import_date_fns18.add)(current, { months: 2 }))
|
|
9269
9315
|
};
|
|
9270
9316
|
}
|
|
9271
|
-
if ((0,
|
|
9317
|
+
if ((0, import_date_fns18.differenceInMonths)(current, (0, import_date_fns18.startOfMonth)(chartWindow.end)) === 0 && (0, import_date_fns18.differenceInMonths)(current, (0, import_date_fns18.startOfMonth)(today)) > 0) {
|
|
9272
9318
|
return {
|
|
9273
|
-
start: (0,
|
|
9274
|
-
end: (0,
|
|
9319
|
+
start: (0, import_date_fns18.startOfMonth)((0, import_date_fns18.sub)(current, { months: 11 })),
|
|
9320
|
+
end: (0, import_date_fns18.endOfMonth)((0, import_date_fns18.add)(current, { months: 1 }))
|
|
9275
9321
|
};
|
|
9276
9322
|
}
|
|
9277
9323
|
if (current >= yearAgo) {
|
|
9278
9324
|
return {
|
|
9279
|
-
start: (0,
|
|
9280
|
-
end: (0,
|
|
9325
|
+
start: (0, import_date_fns18.startOfMonth)(yearAgo),
|
|
9326
|
+
end: (0, import_date_fns18.endOfMonth)(today)
|
|
9281
9327
|
};
|
|
9282
9328
|
}
|
|
9283
9329
|
if (Number(current) > Number(chartWindow.end)) {
|
|
9284
9330
|
return {
|
|
9285
|
-
start: (0,
|
|
9286
|
-
end: (0,
|
|
9331
|
+
start: (0, import_date_fns18.startOfMonth)((0, import_date_fns18.sub)(current, { months: 12 })),
|
|
9332
|
+
end: (0, import_date_fns18.endOfMonth)(current)
|
|
9287
9333
|
};
|
|
9288
9334
|
}
|
|
9289
|
-
if ((0,
|
|
9335
|
+
if ((0, import_date_fns18.differenceInMonths)(current, (0, import_date_fns18.startOfMonth)(chartWindow.start)) < 0) {
|
|
9290
9336
|
return {
|
|
9291
|
-
start: (0,
|
|
9292
|
-
end: (0,
|
|
9337
|
+
start: (0, import_date_fns18.startOfMonth)(current),
|
|
9338
|
+
end: (0, import_date_fns18.endOfMonth)((0, import_date_fns18.add)(current, { months: 11 }))
|
|
9293
9339
|
};
|
|
9294
9340
|
}
|
|
9295
9341
|
return chartWindow;
|
|
@@ -9325,8 +9371,8 @@ var ProfitAndLossChart = ({
|
|
|
9325
9371
|
});
|
|
9326
9372
|
const [barAnimActive, setBarAnimActive] = (0, import_react101.useState)(true);
|
|
9327
9373
|
const [chartWindow, setChartWindow] = (0, import_react101.useState)({
|
|
9328
|
-
start: (0,
|
|
9329
|
-
end: (0,
|
|
9374
|
+
start: (0, import_date_fns18.startOfMonth)((0, import_date_fns18.sub)(Date.now(), { months: 11 })),
|
|
9375
|
+
end: (0, import_date_fns18.endOfMonth)(Date.now())
|
|
9330
9376
|
});
|
|
9331
9377
|
const selectionMonth = (0, import_react101.useMemo)(
|
|
9332
9378
|
() => ({
|
|
@@ -9341,25 +9387,25 @@ var ProfitAndLossChart = ({
|
|
|
9341
9387
|
}
|
|
9342
9388
|
}, [dateRange]);
|
|
9343
9389
|
const { data, loaded, pullData } = useProfitAndLossLTM({
|
|
9344
|
-
currentDate: (0,
|
|
9390
|
+
currentDate: (0, import_date_fns18.startOfMonth)(Date.now())
|
|
9345
9391
|
});
|
|
9346
9392
|
const loadingValue = (0, import_react101.useMemo)(() => getLoadingValue(data), [data]);
|
|
9347
9393
|
(0, import_react101.useEffect)(() => {
|
|
9348
9394
|
if (loaded === "complete" && data) {
|
|
9349
9395
|
const foundCurrent = data.find(
|
|
9350
|
-
(x) => Number((0,
|
|
9396
|
+
(x) => Number((0, import_date_fns18.startOfMonth)(new Date(x.year, x.month - 1, 1))) >= Number(localDateRange.startDate) && Number((0, import_date_fns18.startOfMonth)(new Date(x.year, x.month - 1, 1))) < Number(localDateRange.endDate)
|
|
9351
9397
|
);
|
|
9352
9398
|
if (!foundCurrent) {
|
|
9353
|
-
const newDate = (0,
|
|
9399
|
+
const newDate = (0, import_date_fns18.startOfMonth)(localDateRange.startDate);
|
|
9354
9400
|
pullData(newDate);
|
|
9355
9401
|
return;
|
|
9356
9402
|
}
|
|
9357
9403
|
const foundBefore = data.find(
|
|
9358
|
-
(x) => Number((0,
|
|
9404
|
+
(x) => Number((0, import_date_fns18.startOfMonth)(new Date(x.year, x.month - 1, 1))) >= Number((0, import_date_fns18.sub)(localDateRange.startDate, { months: 1 })) && Number((0, import_date_fns18.startOfMonth)(new Date(x.year, x.month - 1, 1))) < Number((0, import_date_fns18.sub)(localDateRange.endDate, { months: 1 }))
|
|
9359
9405
|
);
|
|
9360
9406
|
if (!foundBefore) {
|
|
9361
|
-
const newDate = (0,
|
|
9362
|
-
(0,
|
|
9407
|
+
const newDate = (0, import_date_fns18.startOfMonth)(
|
|
9408
|
+
(0, import_date_fns18.sub)(localDateRange.startDate, { months: 1 })
|
|
9363
9409
|
);
|
|
9364
9410
|
pullData(newDate);
|
|
9365
9411
|
}
|
|
@@ -9382,7 +9428,7 @@ var ProfitAndLossChart = ({
|
|
|
9382
9428
|
}, 2e3);
|
|
9383
9429
|
}
|
|
9384
9430
|
}, [loaded]);
|
|
9385
|
-
const getMonthName = (pnl) => pnl ? (0,
|
|
9431
|
+
const getMonthName = (pnl) => pnl ? (0, import_date_fns18.format)(
|
|
9386
9432
|
new Date(pnl.year, pnl.month - 1, 1),
|
|
9387
9433
|
compactView ? "LLLLL" : "LLL"
|
|
9388
9434
|
) : "";
|
|
@@ -9407,9 +9453,9 @@ var ProfitAndLossChart = ({
|
|
|
9407
9453
|
const loadingData = [];
|
|
9408
9454
|
const today = Date.now();
|
|
9409
9455
|
for (let i = 11; i >= 0; i--) {
|
|
9410
|
-
const currentDate = (0,
|
|
9456
|
+
const currentDate = (0, import_date_fns18.sub)(today, { months: i });
|
|
9411
9457
|
loadingData.push({
|
|
9412
|
-
name: (0,
|
|
9458
|
+
name: (0, import_date_fns18.format)(currentDate, compactView ? "LLLLL" : "LLL"),
|
|
9413
9459
|
revenue: 0,
|
|
9414
9460
|
revenueUncategorized: 0,
|
|
9415
9461
|
totalExpensesInverse: 0,
|
|
@@ -9440,18 +9486,18 @@ var ProfitAndLossChart = ({
|
|
|
9440
9486
|
}
|
|
9441
9487
|
return x;
|
|
9442
9488
|
})?.filter(
|
|
9443
|
-
(x) => (0,
|
|
9444
|
-
(0,
|
|
9489
|
+
(x) => (0, import_date_fns18.differenceInMonths)(
|
|
9490
|
+
(0, import_date_fns18.startOfMonth)(new Date(x.year, x.month - 1, 1)),
|
|
9445
9491
|
chartWindow.start
|
|
9446
|
-
) >= 0 && (0,
|
|
9447
|
-
(0,
|
|
9492
|
+
) >= 0 && (0, import_date_fns18.differenceInMonths)(
|
|
9493
|
+
(0, import_date_fns18.startOfMonth)(new Date(x.year, x.month - 1, 1)),
|
|
9448
9494
|
chartWindow.start
|
|
9449
|
-
) < 12 && (0,
|
|
9495
|
+
) < 12 && (0, import_date_fns18.differenceInMonths)(
|
|
9450
9496
|
chartWindow.end,
|
|
9451
|
-
(0,
|
|
9452
|
-
) >= 0 && (0,
|
|
9497
|
+
(0, import_date_fns18.startOfMonth)(new Date(x.year, x.month - 1, 1))
|
|
9498
|
+
) >= 0 && (0, import_date_fns18.differenceInMonths)(
|
|
9453
9499
|
chartWindow.end,
|
|
9454
|
-
(0,
|
|
9500
|
+
(0, import_date_fns18.startOfMonth)(new Date(x.year, x.month - 1, 1))
|
|
9455
9501
|
) <= 12
|
|
9456
9502
|
).map((x) => summarizePnL(x));
|
|
9457
9503
|
}, [selectionMonth, chartWindow, data, loaded, compactView]);
|
|
@@ -9465,7 +9511,7 @@ var ProfitAndLossChart = ({
|
|
|
9465
9511
|
if (isMonthAllowed) {
|
|
9466
9512
|
changeDateRange({
|
|
9467
9513
|
startDate: new Date(year, month - 1, 1),
|
|
9468
|
-
endDate: (0,
|
|
9514
|
+
endDate: (0, import_date_fns18.endOfMonth)(new Date(year, month - 1, 1))
|
|
9469
9515
|
});
|
|
9470
9516
|
}
|
|
9471
9517
|
}
|
|
@@ -9882,7 +9928,7 @@ var ProfitAndLossChart = ({
|
|
|
9882
9928
|
|
|
9883
9929
|
// src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
|
|
9884
9930
|
var import_react102 = __toESM(require("react"));
|
|
9885
|
-
var
|
|
9931
|
+
var import_date_fns19 = require("date-fns");
|
|
9886
9932
|
var ProfitAndLossDatePicker = () => {
|
|
9887
9933
|
const { business } = useLayerContext();
|
|
9888
9934
|
const { changeDateRange, dateRange } = (0, import_react102.useContext)(ProfitAndLoss.Context);
|
|
@@ -9895,8 +9941,8 @@ var ProfitAndLossDatePicker = () => {
|
|
|
9895
9941
|
onChange: (date) => {
|
|
9896
9942
|
if (!Array.isArray(date)) {
|
|
9897
9943
|
changeDateRange({
|
|
9898
|
-
startDate: (0,
|
|
9899
|
-
endDate: (0,
|
|
9944
|
+
startDate: (0, import_date_fns19.startOfMonth)(date),
|
|
9945
|
+
endDate: (0, import_date_fns19.endOfMonth)(date)
|
|
9900
9946
|
});
|
|
9901
9947
|
}
|
|
9902
9948
|
},
|
|
@@ -10641,7 +10687,7 @@ var Filters = ({
|
|
|
10641
10687
|
};
|
|
10642
10688
|
|
|
10643
10689
|
// src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
|
|
10644
|
-
var
|
|
10690
|
+
var import_date_fns20 = require("date-fns");
|
|
10645
10691
|
var ProfitAndLossDetailedCharts = ({
|
|
10646
10692
|
scope,
|
|
10647
10693
|
hideClose = false,
|
|
@@ -10666,7 +10712,7 @@ var ProfitAndLossDetailedCharts = ({
|
|
|
10666
10712
|
const data = theScope === "revenue" ? filteredDataRevenue : filteredDataExpenses;
|
|
10667
10713
|
const total = theScope === "revenue" ? filteredTotalRevenue : filteredTotalExpenses;
|
|
10668
10714
|
const [hoveredItem, setHoveredItem] = (0, import_react106.useState)();
|
|
10669
|
-
return /* @__PURE__ */ import_react106.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts" }, /* @__PURE__ */ import_react106.default.createElement("header", { className: "Layer__profit-and-loss-detailed-charts__header" }, /* @__PURE__ */ import_react106.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__head" }, /* @__PURE__ */ import_react106.default.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, humanizeTitle(theScope)), /* @__PURE__ */ import_react106.default.createElement(Text, { size: "sm" /* sm */, className: "date" }, (0,
|
|
10715
|
+
return /* @__PURE__ */ import_react106.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts" }, /* @__PURE__ */ import_react106.default.createElement("header", { className: "Layer__profit-and-loss-detailed-charts__header" }, /* @__PURE__ */ import_react106.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__head" }, /* @__PURE__ */ import_react106.default.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, humanizeTitle(theScope)), /* @__PURE__ */ import_react106.default.createElement(Text, { size: "sm" /* sm */, className: "date" }, (0, import_date_fns20.format)(dateRange.startDate, "LLLL, y")), showDatePicker && /* @__PURE__ */ import_react106.default.createElement(ProfitAndLossDatePicker, null)), !hideClose && /* @__PURE__ */ import_react106.default.createElement(
|
|
10670
10716
|
Button,
|
|
10671
10717
|
{
|
|
10672
10718
|
rightIcon: /* @__PURE__ */ import_react106.default.createElement(X_default, null),
|
|
@@ -10674,7 +10720,7 @@ var ProfitAndLossDetailedCharts = ({
|
|
|
10674
10720
|
onClick: () => setSidebarScope(void 0),
|
|
10675
10721
|
variant: "secondary" /* secondary */
|
|
10676
10722
|
}
|
|
10677
|
-
)), /* @__PURE__ */ import_react106.default.createElement("header", { className: "Layer__profit-and-loss-detailed-charts__header--tablet" }, !hideClose && /* @__PURE__ */ import_react106.default.createElement(BackButton, { onClick: () => setSidebarScope(void 0) }), /* @__PURE__ */ import_react106.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__head" }, /* @__PURE__ */ import_react106.default.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, humanizeTitle(theScope)), /* @__PURE__ */ import_react106.default.createElement(Text, { size: "sm" /* sm */, className: "date" }, (0,
|
|
10723
|
+
)), /* @__PURE__ */ import_react106.default.createElement("header", { className: "Layer__profit-and-loss-detailed-charts__header--tablet" }, !hideClose && /* @__PURE__ */ import_react106.default.createElement(BackButton, { onClick: () => setSidebarScope(void 0) }), /* @__PURE__ */ import_react106.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__head" }, /* @__PURE__ */ import_react106.default.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, humanizeTitle(theScope)), /* @__PURE__ */ import_react106.default.createElement(Text, { size: "sm" /* sm */, className: "date" }, (0, import_date_fns20.format)(dateRange.startDate, "LLLL, y")))), /* @__PURE__ */ import_react106.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__content" }, /* @__PURE__ */ import_react106.default.createElement(
|
|
10678
10724
|
DetailedChart,
|
|
10679
10725
|
{
|
|
10680
10726
|
filteredData: data,
|
|
@@ -11304,7 +11350,7 @@ var ProfitAndLossTableWithProvider = (props) => {
|
|
|
11304
11350
|
};
|
|
11305
11351
|
|
|
11306
11352
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
11307
|
-
var
|
|
11353
|
+
var import_date_fns21 = require("date-fns");
|
|
11308
11354
|
var PNLContext = (0, import_react118.createContext)({
|
|
11309
11355
|
data: void 0,
|
|
11310
11356
|
filteredDataRevenue: [],
|
|
@@ -11315,8 +11361,8 @@ var PNLContext = (0, import_react118.createContext)({
|
|
|
11315
11361
|
isValidating: false,
|
|
11316
11362
|
error: void 0,
|
|
11317
11363
|
dateRange: {
|
|
11318
|
-
startDate: (0,
|
|
11319
|
-
endDate: (0,
|
|
11364
|
+
startDate: (0, import_date_fns21.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
11365
|
+
endDate: (0, import_date_fns21.endOfMonth)(/* @__PURE__ */ new Date())
|
|
11320
11366
|
},
|
|
11321
11367
|
changeDateRange: () => {
|
|
11322
11368
|
},
|
|
@@ -11365,11 +11411,11 @@ var BalanceSheetContext = (0, import_react119.createContext)({
|
|
|
11365
11411
|
|
|
11366
11412
|
// src/hooks/useBalanceSheet/useBalanceSheet.tsx
|
|
11367
11413
|
var import_react120 = require("react");
|
|
11368
|
-
var
|
|
11414
|
+
var import_date_fns22 = require("date-fns");
|
|
11369
11415
|
var import_swr5 = __toESM(require("swr"));
|
|
11370
11416
|
var useBalanceSheet = (date = /* @__PURE__ */ new Date()) => {
|
|
11371
11417
|
const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
|
|
11372
|
-
const dateString = (0,
|
|
11418
|
+
const dateString = (0, import_date_fns22.format)((0, import_date_fns22.startOfDay)(date), "yyyy-MM-dd'T'HH:mm:ssXXX");
|
|
11373
11419
|
const queryKey = businessId && dateString && auth?.access_token && `balance-sheet-${businessId}-${dateString}`;
|
|
11374
11420
|
const { data, isLoading, isValidating, error, mutate } = (0, import_swr5.default)(
|
|
11375
11421
|
queryKey,
|
|
@@ -11578,7 +11624,7 @@ var BALANCE_SHEET_ROWS = [
|
|
|
11578
11624
|
];
|
|
11579
11625
|
|
|
11580
11626
|
// src/components/BalanceSheet/BalanceSheet.tsx
|
|
11581
|
-
var
|
|
11627
|
+
var import_date_fns23 = require("date-fns");
|
|
11582
11628
|
var COMPONENT_NAME3 = "balance-sheet";
|
|
11583
11629
|
var BalanceSheet = (props) => {
|
|
11584
11630
|
const balanceSheetContextData = useBalanceSheet(props.effectiveDate);
|
|
@@ -11596,13 +11642,13 @@ var BalanceSheetView = ({
|
|
|
11596
11642
|
asWidget = false,
|
|
11597
11643
|
stringOverrides
|
|
11598
11644
|
}) => {
|
|
11599
|
-
const [effectiveDate, setEffectiveDate] = (0, import_react127.useState)((0,
|
|
11645
|
+
const [effectiveDate, setEffectiveDate] = (0, import_react127.useState)((0, import_date_fns23.startOfDay)(/* @__PURE__ */ new Date()));
|
|
11600
11646
|
const { data, isLoading, refetch } = useBalanceSheet(effectiveDate);
|
|
11601
11647
|
(0, import_react127.useEffect)(() => {
|
|
11602
|
-
const d1 = effectiveDate && (0,
|
|
11603
|
-
const d2 = data?.effective_date && (0,
|
|
11604
|
-
(0,
|
|
11605
|
-
(0,
|
|
11648
|
+
const d1 = effectiveDate && (0, import_date_fns23.format)((0, import_date_fns23.startOfDay)(effectiveDate), "yyyy-MM-dd'T'HH:mm:ssXXX");
|
|
11649
|
+
const d2 = data?.effective_date && (0, import_date_fns23.format)(
|
|
11650
|
+
(0, import_date_fns23.startOfDay)(
|
|
11651
|
+
(0, import_date_fns23.parse)(data.effective_date, "yyyy-MM-dd'T'HH:mm:ssXXX", /* @__PURE__ */ new Date())
|
|
11606
11652
|
),
|
|
11607
11653
|
"yyyy-MM-dd'T'HH:mm:ssXXX"
|
|
11608
11654
|
);
|
|
@@ -11671,15 +11717,15 @@ var StatementOfCashFlowContext = (0, import_react128.createContext)({
|
|
|
11671
11717
|
|
|
11672
11718
|
// src/hooks/useStatementOfCashFlow/useStatementOfCashFlow.tsx
|
|
11673
11719
|
var import_react129 = require("react");
|
|
11674
|
-
var
|
|
11720
|
+
var import_date_fns24 = require("date-fns");
|
|
11675
11721
|
var import_swr6 = __toESM(require("swr"));
|
|
11676
11722
|
var useStatementOfCashFlow = (startDate = /* @__PURE__ */ new Date(), endDate = /* @__PURE__ */ new Date()) => {
|
|
11677
11723
|
const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
|
|
11678
|
-
const startDateString = (0,
|
|
11679
|
-
(0,
|
|
11724
|
+
const startDateString = (0, import_date_fns24.format)(
|
|
11725
|
+
(0, import_date_fns24.startOfDay)(startDate),
|
|
11680
11726
|
"yyyy-MM-dd'T'HH:mm:ssXXX"
|
|
11681
11727
|
);
|
|
11682
|
-
const endDateString = (0,
|
|
11728
|
+
const endDateString = (0, import_date_fns24.format)((0, import_date_fns24.startOfDay)(endDate), "yyyy-MM-dd'T'HH:mm:ssXXX");
|
|
11683
11729
|
const queryKey = businessId && startDateString && endDateString && auth?.access_token && `statement-of-cash-${businessId}-${startDateString}-${endDateString}`;
|
|
11684
11730
|
const { data, isLoading, isValidating, error, mutate } = (0, import_swr6.default)(
|
|
11685
11731
|
queryKey,
|
|
@@ -11808,7 +11854,7 @@ var STATEMENT_OF_CASH_FLOW_ROWS = [
|
|
|
11808
11854
|
];
|
|
11809
11855
|
|
|
11810
11856
|
// src/components/StatementOfCashFlow/StatementOfCashFlow.tsx
|
|
11811
|
-
var
|
|
11857
|
+
var import_date_fns25 = require("date-fns");
|
|
11812
11858
|
var COMPONENT_NAME4 = "statement-of-cash-flow";
|
|
11813
11859
|
var StatementOfCashFlow = ({ stringOverrides }) => {
|
|
11814
11860
|
const cashContextData = useStatementOfCashFlow();
|
|
@@ -11816,19 +11862,19 @@ var StatementOfCashFlow = ({ stringOverrides }) => {
|
|
|
11816
11862
|
};
|
|
11817
11863
|
var StatementOfCashFlowView = ({ stringOverrides }) => {
|
|
11818
11864
|
const [startDate, setStartDate] = (0, import_react131.useState)(
|
|
11819
|
-
(0,
|
|
11865
|
+
(0, import_date_fns25.startOfDay)((0, import_date_fns25.subWeeks)(/* @__PURE__ */ new Date(), 4))
|
|
11820
11866
|
);
|
|
11821
|
-
const [endDate, setEndDate] = (0, import_react131.useState)((0,
|
|
11867
|
+
const [endDate, setEndDate] = (0, import_react131.useState)((0, import_date_fns25.startOfDay)(/* @__PURE__ */ new Date()));
|
|
11822
11868
|
const { data, isLoading, refetch } = useStatementOfCashFlow(
|
|
11823
11869
|
startDate,
|
|
11824
11870
|
endDate
|
|
11825
11871
|
);
|
|
11826
11872
|
const handleDateChange = (dates) => {
|
|
11827
11873
|
if (dates[0]) {
|
|
11828
|
-
setStartDate((0,
|
|
11874
|
+
setStartDate((0, import_date_fns25.startOfDay)(dates[0]));
|
|
11829
11875
|
}
|
|
11830
11876
|
if (dates[1]) {
|
|
11831
|
-
setEndDate((0,
|
|
11877
|
+
setEndDate((0, import_date_fns25.startOfDay)(dates[1]));
|
|
11832
11878
|
}
|
|
11833
11879
|
if (dates[0] && dates[1]) {
|
|
11834
11880
|
refetch();
|
|
@@ -11864,7 +11910,7 @@ var import_react149 = __toESM(require("react"));
|
|
|
11864
11910
|
|
|
11865
11911
|
// src/contexts/ChartOfAccountsContext/ChartOfAccountsContext.tsx
|
|
11866
11912
|
var import_react132 = require("react");
|
|
11867
|
-
var
|
|
11913
|
+
var import_date_fns26 = require("date-fns");
|
|
11868
11914
|
var ChartOfAccountsContext = (0, import_react132.createContext)(
|
|
11869
11915
|
{
|
|
11870
11916
|
data: void 0,
|
|
@@ -11887,8 +11933,8 @@ var ChartOfAccountsContext = (0, import_react132.createContext)(
|
|
|
11887
11933
|
submitForm: () => {
|
|
11888
11934
|
},
|
|
11889
11935
|
dateRange: {
|
|
11890
|
-
startDate: (0,
|
|
11891
|
-
endDate: (0,
|
|
11936
|
+
startDate: (0, import_date_fns26.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
11937
|
+
endDate: (0, import_date_fns26.endOfMonth)(/* @__PURE__ */ new Date())
|
|
11892
11938
|
},
|
|
11893
11939
|
changeDateRange: () => {
|
|
11894
11940
|
}
|
|
@@ -12123,7 +12169,7 @@ var LEDGER_ACCOUNT_SUBTYPES_FOR_TYPE = {
|
|
|
12123
12169
|
};
|
|
12124
12170
|
|
|
12125
12171
|
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
12126
|
-
var
|
|
12172
|
+
var import_date_fns27 = require("date-fns");
|
|
12127
12173
|
var import_swr7 = __toESM(require("swr"));
|
|
12128
12174
|
var validate = (formData) => {
|
|
12129
12175
|
const errors = [];
|
|
@@ -12204,8 +12250,8 @@ var validateName = (formData) => {
|
|
|
12204
12250
|
var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.sub_accounts || [])]).flat().filter((id) => id);
|
|
12205
12251
|
var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: initialEndDate } = {
|
|
12206
12252
|
withDates: false,
|
|
12207
|
-
startDate: (0,
|
|
12208
|
-
endDate: (0,
|
|
12253
|
+
startDate: (0, import_date_fns27.startOfMonth)(/* @__PURE__ */ new Date()),
|
|
12254
|
+
endDate: (0, import_date_fns27.endOfMonth)(/* @__PURE__ */ new Date())
|
|
12209
12255
|
}) => {
|
|
12210
12256
|
const {
|
|
12211
12257
|
auth,
|
|
@@ -12220,10 +12266,10 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
12220
12266
|
const [sendingForm, setSendingForm] = (0, import_react134.useState)(false);
|
|
12221
12267
|
const [apiError, setApiError] = (0, import_react134.useState)(void 0);
|
|
12222
12268
|
const [startDate, setStartDate] = (0, import_react134.useState)(
|
|
12223
|
-
initialStartDate ?? (0,
|
|
12269
|
+
initialStartDate ?? (0, import_date_fns27.startOfMonth)(Date.now())
|
|
12224
12270
|
);
|
|
12225
12271
|
const [endDate, setEndDate] = (0, import_react134.useState)(
|
|
12226
|
-
initialEndDate ?? (0,
|
|
12272
|
+
initialEndDate ?? (0, import_date_fns27.endOfMonth)(Date.now())
|
|
12227
12273
|
);
|
|
12228
12274
|
const queryKey = businessId && auth?.access_token && `chart-of-accounts-${businessId}-${startDate?.valueOf()}-${endDate?.valueOf()}`;
|
|
12229
12275
|
const { data, isLoading, isValidating, error, mutate } = (0, import_swr7.default)(
|
|
@@ -12231,8 +12277,8 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
12231
12277
|
Layer.getLedgerAccountBalances(apiUrl, auth?.access_token, {
|
|
12232
12278
|
params: {
|
|
12233
12279
|
businessId,
|
|
12234
|
-
startDate: withDates && startDate ? (0,
|
|
12235
|
-
endDate: withDates && endDate ? (0,
|
|
12280
|
+
startDate: withDates && startDate ? (0, import_date_fns27.formatISO)(startDate.valueOf()) : void 0,
|
|
12281
|
+
endDate: withDates && endDate ? (0, import_date_fns27.formatISO)(endDate.valueOf()) : void 0
|
|
12236
12282
|
}
|
|
12237
12283
|
})
|
|
12238
12284
|
);
|
|
@@ -12497,7 +12543,7 @@ var import_react141 = __toESM(require("react"));
|
|
|
12497
12543
|
|
|
12498
12544
|
// src/components/ChartOfAccountsDatePicker/ChartOfAccountsDatePicker.tsx
|
|
12499
12545
|
var import_react136 = __toESM(require("react"));
|
|
12500
|
-
var
|
|
12546
|
+
var import_date_fns28 = require("date-fns");
|
|
12501
12547
|
var ChartOfAccountsDatePicker = () => {
|
|
12502
12548
|
const { changeDateRange, dateRange } = (0, import_react136.useContext)(ChartOfAccountsContext);
|
|
12503
12549
|
return /* @__PURE__ */ import_react136.default.createElement(
|
|
@@ -12508,8 +12554,8 @@ var ChartOfAccountsDatePicker = () => {
|
|
|
12508
12554
|
onChange: (date) => {
|
|
12509
12555
|
if (!Array.isArray(date)) {
|
|
12510
12556
|
changeDateRange({
|
|
12511
|
-
startDate: (0,
|
|
12512
|
-
endDate: (0,
|
|
12557
|
+
startDate: (0, import_date_fns28.startOfMonth)(date),
|
|
12558
|
+
endDate: (0, import_date_fns28.endOfMonth)(date)
|
|
12513
12559
|
});
|
|
12514
12560
|
}
|
|
12515
12561
|
}
|
|
@@ -13059,7 +13105,7 @@ var Card = ({ children, className }) => {
|
|
|
13059
13105
|
|
|
13060
13106
|
// src/components/DateTime/DateTime.tsx
|
|
13061
13107
|
var import_react143 = __toESM(require("react"));
|
|
13062
|
-
var
|
|
13108
|
+
var import_date_fns29 = require("date-fns");
|
|
13063
13109
|
var DateTime = ({
|
|
13064
13110
|
value,
|
|
13065
13111
|
format: format7,
|
|
@@ -13069,10 +13115,10 @@ var DateTime = ({
|
|
|
13069
13115
|
onlyTime
|
|
13070
13116
|
}) => {
|
|
13071
13117
|
if (format7) {
|
|
13072
|
-
return /* @__PURE__ */ import_react143.default.createElement(Text, { className: "Layer__datetime" }, (0,
|
|
13118
|
+
return /* @__PURE__ */ import_react143.default.createElement(Text, { className: "Layer__datetime" }, (0, import_date_fns29.format)((0, import_date_fns29.parseISO)(value), format7));
|
|
13073
13119
|
}
|
|
13074
|
-
const date = (0,
|
|
13075
|
-
const time = (0,
|
|
13120
|
+
const date = (0, import_date_fns29.format)((0, import_date_fns29.parseISO)(value), dateFormat ?? DATE_FORMAT);
|
|
13121
|
+
const time = (0, import_date_fns29.format)((0, import_date_fns29.parseISO)(value), timeFormat ?? TIME_FORMAT);
|
|
13076
13122
|
return /* @__PURE__ */ import_react143.default.createElement(Text, { className: "Layer__datetime" }, !onlyTime && /* @__PURE__ */ import_react143.default.createElement(
|
|
13077
13123
|
Text,
|
|
13078
13124
|
{
|
|
@@ -13237,7 +13283,7 @@ var LedgerAccountEntryDetails = ({ stringOverrides }) => {
|
|
|
13237
13283
|
// src/components/LedgerAccount/LedgerAccountRow.tsx
|
|
13238
13284
|
var import_react147 = __toESM(require("react"));
|
|
13239
13285
|
var import_classnames55 = __toESM(require("classnames"));
|
|
13240
|
-
var
|
|
13286
|
+
var import_date_fns30 = require("date-fns");
|
|
13241
13287
|
var LedgerAccountRow = ({
|
|
13242
13288
|
row,
|
|
13243
13289
|
index,
|
|
@@ -13276,7 +13322,7 @@ var LedgerAccountRow = ({
|
|
|
13276
13322
|
}
|
|
13277
13323
|
}
|
|
13278
13324
|
},
|
|
13279
|
-
/* @__PURE__ */ import_react147.default.createElement("td", { className: "Layer__table-cell Layer__ledger-account-table__tablet-main-col" }, /* @__PURE__ */ import_react147.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react147.default.createElement("div", { className: "Layer__ledger-account-table__tablet-main-col__date" }, /* @__PURE__ */ import_react147.default.createElement(Text, null, row.date && (0,
|
|
13325
|
+
/* @__PURE__ */ import_react147.default.createElement("td", { className: "Layer__table-cell Layer__ledger-account-table__tablet-main-col" }, /* @__PURE__ */ import_react147.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react147.default.createElement("div", { className: "Layer__ledger-account-table__tablet-main-col__date" }, /* @__PURE__ */ import_react147.default.createElement(Text, null, row.date && (0, import_date_fns30.format)((0, import_date_fns30.parseISO)(row.date), DATE_FORMAT)), /* @__PURE__ */ import_react147.default.createElement(
|
|
13280
13326
|
Text,
|
|
13281
13327
|
{
|
|
13282
13328
|
weight: "normal" /* normal */,
|
|
@@ -13309,7 +13355,7 @@ var LedgerAccountRow = ({
|
|
|
13309
13355
|
}
|
|
13310
13356
|
}
|
|
13311
13357
|
},
|
|
13312
|
-
/* @__PURE__ */ import_react147.default.createElement("td", { className: "Layer__table-cell Layer__ledger-account-table__tablet-main-col" }, /* @__PURE__ */ import_react147.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react147.default.createElement("div", { className: "Layer__ledger-account-table__tablet-main-col__date" }, /* @__PURE__ */ import_react147.default.createElement(Text, null, row.date && (0,
|
|
13358
|
+
/* @__PURE__ */ import_react147.default.createElement("td", { className: "Layer__table-cell Layer__ledger-account-table__tablet-main-col" }, /* @__PURE__ */ import_react147.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react147.default.createElement("div", { className: "Layer__ledger-account-table__tablet-main-col__date" }, /* @__PURE__ */ import_react147.default.createElement(Text, null, row.date && (0, import_date_fns30.format)((0, import_date_fns30.parseISO)(row.date), DATE_FORMAT)), /* @__PURE__ */ import_react147.default.createElement(
|
|
13313
13359
|
Text,
|
|
13314
13360
|
{
|
|
13315
13361
|
weight: "normal" /* normal */,
|
|
@@ -13338,7 +13384,7 @@ var LedgerAccountRow = ({
|
|
|
13338
13384
|
}
|
|
13339
13385
|
}
|
|
13340
13386
|
},
|
|
13341
|
-
/* @__PURE__ */ import_react147.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react147.default.createElement("span", { className: "Layer__table-cell-content" }, row.date && (0,
|
|
13387
|
+
/* @__PURE__ */ import_react147.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react147.default.createElement("span", { className: "Layer__table-cell-content" }, row.date && (0, import_date_fns30.format)((0, import_date_fns30.parseISO)(row.date), DATE_FORMAT))),
|
|
13342
13388
|
/* @__PURE__ */ import_react147.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react147.default.createElement("span", { className: "Layer__table-cell-content" }, row.entry_id.substring(0, 5))),
|
|
13343
13389
|
/* @__PURE__ */ import_react147.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react147.default.createElement("span", { className: "Layer__table-cell-content" }, row.source?.display_description ?? "")),
|
|
13344
13390
|
/* @__PURE__ */ import_react147.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ import_react147.default.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars(row?.amount || 0)}`)),
|
|
@@ -13848,7 +13894,7 @@ var import_react157 = __toESM(require("react"));
|
|
|
13848
13894
|
// src/components/JournalRow/JournalRow.tsx
|
|
13849
13895
|
var import_react152 = __toESM(require("react"));
|
|
13850
13896
|
var import_classnames57 = __toESM(require("classnames"));
|
|
13851
|
-
var
|
|
13897
|
+
var import_date_fns31 = require("date-fns");
|
|
13852
13898
|
var INDENTATION2 = 24;
|
|
13853
13899
|
var EXPANDED_STYLE3 = {
|
|
13854
13900
|
height: "100%",
|
|
@@ -13961,7 +14007,7 @@ var JournalRow = ({
|
|
|
13961
14007
|
)
|
|
13962
14008
|
))),
|
|
13963
14009
|
/* @__PURE__ */ import_react152.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react152.default.createElement("span", { className: "Layer__table-cell-content" }, row.id.substring(0, 5))),
|
|
13964
|
-
/* @__PURE__ */ import_react152.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react152.default.createElement("span", { className: "Layer__table-cell-content" }, row.date && (0,
|
|
14010
|
+
/* @__PURE__ */ import_react152.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react152.default.createElement("span", { className: "Layer__table-cell-content" }, row.date && (0, import_date_fns31.format)((0, import_date_fns31.parseISO)(row.date), DATE_FORMAT))),
|
|
13965
14011
|
/* @__PURE__ */ import_react152.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react152.default.createElement("span", { className: "Layer__table-cell-content" }, humanizeEnum(row.entry_type))),
|
|
13966
14012
|
/* @__PURE__ */ import_react152.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react152.default.createElement("span", { className: "Layer__table-cell-content" }, `(${row.line_items.length})`)),
|
|
13967
14013
|
/* @__PURE__ */ import_react152.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--primary" }, /* @__PURE__ */ import_react152.default.createElement("span", { className: "Layer__table-cell-content Layer__table-cell--amount" }, "$", centsToDollars(
|
|
@@ -14858,7 +14904,7 @@ var TasksList = ({ pageSize = 10 }) => {
|
|
|
14858
14904
|
// src/components/TasksPending/TasksPending.tsx
|
|
14859
14905
|
var import_react164 = __toESM(require("react"));
|
|
14860
14906
|
var import_classnames59 = __toESM(require("classnames"));
|
|
14861
|
-
var
|
|
14907
|
+
var import_date_fns32 = require("date-fns");
|
|
14862
14908
|
var import_recharts4 = require("recharts");
|
|
14863
14909
|
var TasksPending = () => {
|
|
14864
14910
|
const { data } = (0, import_react164.useContext)(TasksContext);
|
|
@@ -14876,7 +14922,7 @@ var TasksPending = () => {
|
|
|
14876
14922
|
const taskStatusClassName = (0, import_classnames59.default)(
|
|
14877
14923
|
completedTasks && completedTasks > 0 ? "Layer__tasks-pending-bar__status--done" : "Layer__tasks-pending-bar__status--pending"
|
|
14878
14924
|
);
|
|
14879
|
-
return /* @__PURE__ */ import_react164.default.createElement("div", { className: "Layer__tasks-pending" }, /* @__PURE__ */ import_react164.default.createElement(Text, { size: "lg" /* lg */ }, (0,
|
|
14925
|
+
return /* @__PURE__ */ import_react164.default.createElement("div", { className: "Layer__tasks-pending" }, /* @__PURE__ */ import_react164.default.createElement(Text, { size: "lg" /* lg */ }, (0, import_date_fns32.format)(Date.now(), "MMMM")), /* @__PURE__ */ import_react164.default.createElement("div", { className: "Layer__tasks-pending-bar" }, /* @__PURE__ */ import_react164.default.createElement(Text, { size: "sm" /* sm */ }, /* @__PURE__ */ import_react164.default.createElement("span", { className: taskStatusClassName }, completedTasks), "/", data?.length, " done"), /* @__PURE__ */ import_react164.default.createElement(import_recharts4.PieChart, { width: 24, height: 24, className: "mini-chart" }, /* @__PURE__ */ import_react164.default.createElement(
|
|
14880
14926
|
import_recharts4.Pie,
|
|
14881
14927
|
{
|
|
14882
14928
|
data: chartData,
|
|
@@ -15203,7 +15249,7 @@ var NotificationCard = ({
|
|
|
15203
15249
|
};
|
|
15204
15250
|
|
|
15205
15251
|
// src/components/TransactionToReviewCard/TransactionToReviewCard.tsx
|
|
15206
|
-
var
|
|
15252
|
+
var import_date_fns33 = require("date-fns");
|
|
15207
15253
|
var TransactionToReviewCard = ({
|
|
15208
15254
|
onClick,
|
|
15209
15255
|
usePnlDateRange
|
|
@@ -15212,7 +15258,7 @@ var TransactionToReviewCard = ({
|
|
|
15212
15258
|
const dateRange = usePnlDateRange ? contextDateRange : void 0;
|
|
15213
15259
|
const [toReview, setToReview] = (0, import_react171.useState)(0);
|
|
15214
15260
|
const { data, loaded, error, refetch } = useProfitAndLossLTM({
|
|
15215
|
-
currentDate: dateRange ? dateRange.startDate : (0,
|
|
15261
|
+
currentDate: dateRange ? dateRange.startDate : (0, import_date_fns33.startOfMonth)(/* @__PURE__ */ new Date())
|
|
15216
15262
|
});
|
|
15217
15263
|
(0, import_react171.useEffect)(() => {
|
|
15218
15264
|
checkTransactionsToReview();
|
|
@@ -15223,7 +15269,7 @@ var TransactionToReviewCard = ({
|
|
|
15223
15269
|
const checkTransactionsToReview = () => {
|
|
15224
15270
|
if (data && dateRange) {
|
|
15225
15271
|
const monthTx = data.filter(
|
|
15226
|
-
(x) => x.month - 1 === (0,
|
|
15272
|
+
(x) => x.month - 1 === (0, import_date_fns33.getMonth)(dateRange.startDate) && x.year === (0, import_date_fns33.getYear)(dateRange.startDate)
|
|
15227
15273
|
);
|
|
15228
15274
|
if (monthTx.length > 0) {
|
|
15229
15275
|
setToReview(monthTx[0].uncategorized_transactions);
|
|
@@ -15658,6 +15704,7 @@ var Components = ({
|
|
|
15658
15704
|
BookkeepingOverview,
|
|
15659
15705
|
BookkeepingUpsellBar,
|
|
15660
15706
|
ChartOfAccounts,
|
|
15707
|
+
Direction,
|
|
15661
15708
|
DisplayState,
|
|
15662
15709
|
GeneralLedgerView,
|
|
15663
15710
|
Journal,
|
|
@@ -15671,6 +15718,7 @@ var Components = ({
|
|
|
15671
15718
|
StatementOfCashFlow,
|
|
15672
15719
|
Tasks,
|
|
15673
15720
|
useBankTransactionsContext,
|
|
15721
|
+
useDataSync,
|
|
15674
15722
|
useLayerContext
|
|
15675
15723
|
});
|
|
15676
15724
|
//# sourceMappingURL=index.js.map
|