@layerfi/components 0.1.104-alpha → 0.1.105
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +551 -256
- package/dist/esm/index.mjs +434 -139
- package/dist/index.css +23 -23
- package/dist/index.d.ts +56 -0
- package/package.json +1 -1
package/dist/esm/index.mjs
CHANGED
|
@@ -3893,7 +3893,7 @@ var require_lodash = __commonJS({
|
|
|
3893
3893
|
result2.placeholder = curryRight.placeholder;
|
|
3894
3894
|
return result2;
|
|
3895
3895
|
}
|
|
3896
|
-
function
|
|
3896
|
+
function debounce6(func, wait, options) {
|
|
3897
3897
|
var lastArgs, lastThis, maxWait, result2, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
3898
3898
|
if (typeof func != "function") {
|
|
3899
3899
|
throw new TypeError2(FUNC_ERROR_TEXT);
|
|
@@ -4073,7 +4073,7 @@ var require_lodash = __commonJS({
|
|
|
4073
4073
|
leading = "leading" in options ? !!options.leading : leading;
|
|
4074
4074
|
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
4075
4075
|
}
|
|
4076
|
-
return
|
|
4076
|
+
return debounce6(func, wait, {
|
|
4077
4077
|
"leading": leading,
|
|
4078
4078
|
"maxWait": wait,
|
|
4079
4079
|
"trailing": trailing
|
|
@@ -5087,7 +5087,7 @@ var require_lodash = __commonJS({
|
|
|
5087
5087
|
lodash.create = create;
|
|
5088
5088
|
lodash.curry = curry;
|
|
5089
5089
|
lodash.curryRight = curryRight;
|
|
5090
|
-
lodash.debounce =
|
|
5090
|
+
lodash.debounce = debounce6;
|
|
5091
5091
|
lodash.defaults = defaults;
|
|
5092
5092
|
lodash.defaultsDeep = defaultsDeep;
|
|
5093
5093
|
lodash.defer = defer;
|
|
@@ -5570,7 +5570,7 @@ import { useState as useState5 } from "react";
|
|
|
5570
5570
|
import { useReducer, useEffect as useEffect2 } from "react";
|
|
5571
5571
|
|
|
5572
5572
|
// package.json
|
|
5573
|
-
var version = "0.1.
|
|
5573
|
+
var version = "0.1.105";
|
|
5574
5574
|
|
|
5575
5575
|
// src/models/APIError.ts
|
|
5576
5576
|
var APIError = class _APIError extends Error {
|
|
@@ -27594,6 +27594,9 @@ var LedgerAccountsContext = createContext21({
|
|
|
27594
27594
|
setSelectedEntryId: () => {
|
|
27595
27595
|
},
|
|
27596
27596
|
closeSelectedEntry: () => {
|
|
27597
|
+
},
|
|
27598
|
+
hasMore: false,
|
|
27599
|
+
fetchMore: () => {
|
|
27597
27600
|
}
|
|
27598
27601
|
});
|
|
27599
27602
|
|
|
@@ -27661,6 +27664,10 @@ var ASSET_LEDGER_ACCOUNT_SUBTYPES = [
|
|
|
27661
27664
|
value: "FIXED_ASSET",
|
|
27662
27665
|
label: "Fixed Assets"
|
|
27663
27666
|
},
|
|
27667
|
+
{
|
|
27668
|
+
value: "ACCUMULATED_DEPRECIATION",
|
|
27669
|
+
label: "Accumulated Depreciation"
|
|
27670
|
+
},
|
|
27664
27671
|
{
|
|
27665
27672
|
value: "CASH",
|
|
27666
27673
|
label: "Cash"
|
|
@@ -27668,13 +27675,33 @@ var ASSET_LEDGER_ACCOUNT_SUBTYPES = [
|
|
|
27668
27675
|
{
|
|
27669
27676
|
value: "UNDEPOSITED_FUNDS",
|
|
27670
27677
|
label: "Undeposited Funds"
|
|
27678
|
+
},
|
|
27679
|
+
{
|
|
27680
|
+
value: "CURRENT_ASSET",
|
|
27681
|
+
label: "Current Assets"
|
|
27682
|
+
},
|
|
27683
|
+
{
|
|
27684
|
+
value: "NON_CURRENT_ASSET",
|
|
27685
|
+
label: "Non-Current Assets"
|
|
27686
|
+
},
|
|
27687
|
+
{
|
|
27688
|
+
value: "PREPAID_EXPENSES",
|
|
27689
|
+
label: "Prepaid Expenses"
|
|
27690
|
+
},
|
|
27691
|
+
{
|
|
27692
|
+
value: "DEVELOPMENT_COSTS",
|
|
27693
|
+
label: "Development Costs"
|
|
27694
|
+
},
|
|
27695
|
+
{
|
|
27696
|
+
value: "LOANS_RECEIVABLE",
|
|
27697
|
+
label: "Loans Receivable"
|
|
27698
|
+
},
|
|
27699
|
+
{
|
|
27700
|
+
value: "INTANGIBLE_ASSET",
|
|
27701
|
+
label: "Intangible Assets"
|
|
27671
27702
|
}
|
|
27672
27703
|
];
|
|
27673
27704
|
var LIABILITY_LEDGER_ACCOUNT_SUBTYPES = [
|
|
27674
|
-
{
|
|
27675
|
-
value: "LIABILITY",
|
|
27676
|
-
label: "Liabilities"
|
|
27677
|
-
},
|
|
27678
27705
|
{
|
|
27679
27706
|
value: "ACCOUNTS_PAYABLE",
|
|
27680
27707
|
label: "Accounts Payable"
|
|
@@ -27684,36 +27711,72 @@ var LIABILITY_LEDGER_ACCOUNT_SUBTYPES = [
|
|
|
27684
27711
|
label: "Credit Cards"
|
|
27685
27712
|
},
|
|
27686
27713
|
{
|
|
27687
|
-
value: "
|
|
27688
|
-
label: "
|
|
27714
|
+
value: "INCOME_TAXES_PAYABLE",
|
|
27715
|
+
label: "Income Taxes Payable"
|
|
27716
|
+
},
|
|
27717
|
+
{
|
|
27718
|
+
value: "SALES_TAXES_PAYABLE",
|
|
27719
|
+
label: "Sales Taxes Payable"
|
|
27720
|
+
},
|
|
27721
|
+
{
|
|
27722
|
+
value: "OTHER_TAXES_PAYABLE",
|
|
27723
|
+
label: "Other Taxes Payable"
|
|
27724
|
+
},
|
|
27725
|
+
{
|
|
27726
|
+
value: "PAYROLL_TAXES_PAYABLE",
|
|
27727
|
+
label: "Payroll Taxes Payable"
|
|
27728
|
+
},
|
|
27729
|
+
{
|
|
27730
|
+
value: "UNEARNED_REVENUE",
|
|
27731
|
+
label: "Unearned Revenue"
|
|
27689
27732
|
},
|
|
27690
27733
|
{
|
|
27691
27734
|
value: "PAYROLL_LIABILITY",
|
|
27692
27735
|
label: "Payroll Liabilities"
|
|
27693
27736
|
},
|
|
27694
27737
|
{
|
|
27695
|
-
value: "
|
|
27696
|
-
label: "
|
|
27738
|
+
value: "PAYROLL_CLEARING",
|
|
27739
|
+
label: "Payroll Clearing"
|
|
27697
27740
|
},
|
|
27698
27741
|
{
|
|
27699
27742
|
value: "LINE_OF_CREDIT",
|
|
27700
27743
|
label: "Lines of Credit"
|
|
27701
27744
|
},
|
|
27702
|
-
{
|
|
27703
|
-
value: "NOTES_PAYABLE",
|
|
27704
|
-
label: "Notes Payable"
|
|
27705
|
-
},
|
|
27706
27745
|
{
|
|
27707
27746
|
value: "TIPS",
|
|
27708
27747
|
label: "Tips"
|
|
27709
27748
|
},
|
|
27710
27749
|
{
|
|
27711
|
-
value: "
|
|
27712
|
-
label: "
|
|
27750
|
+
value: "REFUND_LIABILITIES",
|
|
27751
|
+
label: "Refund Liabilities"
|
|
27713
27752
|
},
|
|
27714
27753
|
{
|
|
27715
27754
|
value: "UNDEPOSITED_OUTFLOWS",
|
|
27716
27755
|
label: "Undeposited Outflows"
|
|
27756
|
+
},
|
|
27757
|
+
{
|
|
27758
|
+
value: "OUTGOING_PAYMENT_CLEARING_ACCOUNT",
|
|
27759
|
+
label: "Outgoing Payment Clearing Accounts"
|
|
27760
|
+
},
|
|
27761
|
+
{
|
|
27762
|
+
value: "OTHER_CURRENT_LIABILITY",
|
|
27763
|
+
label: "Current Liabilities"
|
|
27764
|
+
},
|
|
27765
|
+
{
|
|
27766
|
+
value: "LOANS_PAYABLE",
|
|
27767
|
+
label: "Loans Payable"
|
|
27768
|
+
},
|
|
27769
|
+
{
|
|
27770
|
+
value: "NOTES_PAYABLE",
|
|
27771
|
+
label: "Notes Payable"
|
|
27772
|
+
},
|
|
27773
|
+
{
|
|
27774
|
+
value: "SHAREHOLDER_LOAN",
|
|
27775
|
+
label: "Shareholder Loans"
|
|
27776
|
+
},
|
|
27777
|
+
{
|
|
27778
|
+
value: "NON_CURRENT_LIABILITY",
|
|
27779
|
+
label: "Long Term Liabilities"
|
|
27717
27780
|
}
|
|
27718
27781
|
];
|
|
27719
27782
|
var EQUITY_LEDGER_ACCOUNT_SUBTYPES = [
|
|
@@ -27729,6 +27792,10 @@ var EQUITY_LEDGER_ACCOUNT_SUBTYPES = [
|
|
|
27729
27792
|
value: "COMMON_STOCK",
|
|
27730
27793
|
label: "Common Stock"
|
|
27731
27794
|
},
|
|
27795
|
+
{
|
|
27796
|
+
value: "PREFERRED_STOCK",
|
|
27797
|
+
label: "Preferred Stock"
|
|
27798
|
+
},
|
|
27732
27799
|
{
|
|
27733
27800
|
value: "ADDITIONAL_PAID_IN_CAPITAL",
|
|
27734
27801
|
label: "Additional Paid In Capital"
|
|
@@ -27744,6 +27811,10 @@ var EQUITY_LEDGER_ACCOUNT_SUBTYPES = [
|
|
|
27744
27811
|
{
|
|
27745
27812
|
value: "OPENING_BALANCE_EQUITY",
|
|
27746
27813
|
label: "Opening Balance Equity"
|
|
27814
|
+
},
|
|
27815
|
+
{
|
|
27816
|
+
value: "OTHER_EQUITY",
|
|
27817
|
+
label: "Other Equity"
|
|
27747
27818
|
}
|
|
27748
27819
|
];
|
|
27749
27820
|
var REVENUE_LEDGER_ACCOUNT_SUBTYPES = [
|
|
@@ -27758,6 +27829,18 @@ var REVENUE_LEDGER_ACCOUNT_SUBTYPES = [
|
|
|
27758
27829
|
{
|
|
27759
27830
|
value: "RETURNS_ALLOWANCES",
|
|
27760
27831
|
label: "Returns & Allowances"
|
|
27832
|
+
},
|
|
27833
|
+
{
|
|
27834
|
+
value: "DIVIDEND_INCOME",
|
|
27835
|
+
label: "Dividend Income"
|
|
27836
|
+
},
|
|
27837
|
+
{
|
|
27838
|
+
value: "INTEREST_INCOME",
|
|
27839
|
+
label: "Interest Income"
|
|
27840
|
+
},
|
|
27841
|
+
{
|
|
27842
|
+
value: "OTHER_INCOME",
|
|
27843
|
+
label: "Other Income"
|
|
27761
27844
|
}
|
|
27762
27845
|
];
|
|
27763
27846
|
var EXPENSE_LEDGER_ACCOUNT_SUBTYPES = [
|
|
@@ -27778,12 +27861,40 @@ var EXPENSE_LEDGER_ACCOUNT_SUBTYPES = [
|
|
|
27778
27861
|
label: "Taxes & Licenses"
|
|
27779
27862
|
},
|
|
27780
27863
|
{
|
|
27781
|
-
value: "
|
|
27782
|
-
label: "
|
|
27864
|
+
value: "UNCATEGORIZED_EXPENSE",
|
|
27865
|
+
label: "Uncategorized Expense"
|
|
27783
27866
|
},
|
|
27784
27867
|
{
|
|
27785
27868
|
value: "CHARITABLE_CONTRIBUTIONS",
|
|
27786
27869
|
label: "Charitable Contributions"
|
|
27870
|
+
},
|
|
27871
|
+
{
|
|
27872
|
+
value: "LOAN_EXPENSES",
|
|
27873
|
+
label: "Loan Expenses"
|
|
27874
|
+
},
|
|
27875
|
+
{
|
|
27876
|
+
value: "FINANCE_COSTS",
|
|
27877
|
+
label: "Finance Costs"
|
|
27878
|
+
},
|
|
27879
|
+
{
|
|
27880
|
+
value: "INTEREST_EXPENSES",
|
|
27881
|
+
label: "Interest Expenses"
|
|
27882
|
+
},
|
|
27883
|
+
{
|
|
27884
|
+
value: "DEPRECIATION",
|
|
27885
|
+
label: "Depreciation"
|
|
27886
|
+
},
|
|
27887
|
+
{
|
|
27888
|
+
value: "AMORTIZATION",
|
|
27889
|
+
label: "Amortization"
|
|
27890
|
+
},
|
|
27891
|
+
{
|
|
27892
|
+
value: "BAD_DEBT",
|
|
27893
|
+
label: "Bad Debt"
|
|
27894
|
+
},
|
|
27895
|
+
{
|
|
27896
|
+
value: "OTHER_EXPENSES",
|
|
27897
|
+
label: "Other Expenses"
|
|
27787
27898
|
}
|
|
27788
27899
|
];
|
|
27789
27900
|
var LEDGER_ACCOUNT_SUBTYPES = [
|
|
@@ -28126,25 +28237,187 @@ import { useSWRConfig as useSWRConfig6 } from "swr";
|
|
|
28126
28237
|
import { useCallback as useCallback32 } from "react";
|
|
28127
28238
|
|
|
28128
28239
|
// src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
|
|
28129
|
-
import { useEffect as useEffect33, useState as useState59 } from "react";
|
|
28240
|
+
import { useEffect as useEffect33, useState as useState59, useMemo as useMemo45, useCallback as useCallback34 } from "react";
|
|
28130
28241
|
import useSWR17 from "swr";
|
|
28131
|
-
|
|
28132
|
-
|
|
28242
|
+
|
|
28243
|
+
// src/features/ledger/accounts/[ledgerAccountId]/api/useListLedgerAccountLines.ts
|
|
28244
|
+
import useSWRInfinite4 from "swr/infinite";
|
|
28245
|
+
var import_lodash4 = __toESM(require_lodash2());
|
|
28246
|
+
import { useCallback as useCallback33, useMemo as useMemo44 } from "react";
|
|
28247
|
+
var LIST_LEDGER_ACCOUNT_LINES_TAG_KEY = "#list-ledger-account-lines";
|
|
28248
|
+
var listLedgerAccountLines = get(({
|
|
28249
|
+
businessId,
|
|
28250
|
+
accountId,
|
|
28251
|
+
include_entries_before_activation,
|
|
28252
|
+
include_child_account_lines,
|
|
28253
|
+
start_date,
|
|
28254
|
+
end_date,
|
|
28255
|
+
sort_by,
|
|
28256
|
+
sort_order,
|
|
28257
|
+
cursor,
|
|
28258
|
+
limit,
|
|
28259
|
+
show_total_count
|
|
28260
|
+
}) => {
|
|
28261
|
+
const parameters = toDefinedSearchParameters({
|
|
28262
|
+
include_entries_before_activation,
|
|
28263
|
+
include_child_account_lines,
|
|
28264
|
+
start_date,
|
|
28265
|
+
end_date,
|
|
28266
|
+
sort_by,
|
|
28267
|
+
sort_order,
|
|
28268
|
+
cursor,
|
|
28269
|
+
limit,
|
|
28270
|
+
show_total_count
|
|
28271
|
+
});
|
|
28272
|
+
return `/v1/businesses/${businessId}/ledger/accounts/${accountId}/lines?${parameters}`;
|
|
28273
|
+
});
|
|
28274
|
+
function keyLoader4(previousPageData, {
|
|
28275
|
+
access_token: accessToken,
|
|
28276
|
+
apiUrl,
|
|
28277
|
+
businessId,
|
|
28278
|
+
accountId,
|
|
28279
|
+
include_entries_before_activation,
|
|
28280
|
+
include_child_account_lines,
|
|
28281
|
+
start_date,
|
|
28282
|
+
end_date,
|
|
28283
|
+
sort_by,
|
|
28284
|
+
sort_order,
|
|
28285
|
+
limit,
|
|
28286
|
+
show_total_count
|
|
28287
|
+
}) {
|
|
28288
|
+
var _a;
|
|
28289
|
+
if (accessToken && apiUrl && accountId) {
|
|
28290
|
+
return {
|
|
28291
|
+
accessToken,
|
|
28292
|
+
apiUrl,
|
|
28293
|
+
businessId,
|
|
28294
|
+
accountId,
|
|
28295
|
+
cursor: (_a = previousPageData == null ? void 0 : previousPageData.meta) == null ? void 0 : _a.pagination.cursor,
|
|
28296
|
+
include_entries_before_activation,
|
|
28297
|
+
include_child_account_lines,
|
|
28298
|
+
start_date,
|
|
28299
|
+
end_date,
|
|
28300
|
+
sort_by,
|
|
28301
|
+
sort_order,
|
|
28302
|
+
limit,
|
|
28303
|
+
show_total_count,
|
|
28304
|
+
tags: [LIST_LEDGER_ACCOUNT_LINES_TAG_KEY]
|
|
28305
|
+
};
|
|
28306
|
+
}
|
|
28307
|
+
}
|
|
28308
|
+
function useListLedgerAccountLines({
|
|
28309
|
+
accountId,
|
|
28310
|
+
include_entries_before_activation,
|
|
28311
|
+
include_child_account_lines,
|
|
28312
|
+
start_date,
|
|
28313
|
+
end_date,
|
|
28314
|
+
sort_by,
|
|
28315
|
+
sort_order,
|
|
28316
|
+
limit,
|
|
28317
|
+
show_total_count
|
|
28318
|
+
}) {
|
|
28319
|
+
const { businessId } = useLayerContext();
|
|
28133
28320
|
const { apiUrl } = useEnvironment();
|
|
28134
28321
|
const { data: auth } = useAuth();
|
|
28135
|
-
|
|
28136
|
-
|
|
28137
|
-
|
|
28138
|
-
|
|
28139
|
-
|
|
28140
|
-
Layer.getLedgerAccountsLines(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
28141
|
-
params: {
|
|
28322
|
+
return useSWRInfinite4(
|
|
28323
|
+
(index, previousPageData) => keyLoader4(
|
|
28324
|
+
previousPageData,
|
|
28325
|
+
__spreadProps(__spreadValues({}, auth), {
|
|
28326
|
+
apiUrl,
|
|
28142
28327
|
businessId,
|
|
28143
28328
|
accountId,
|
|
28144
|
-
|
|
28329
|
+
include_entries_before_activation,
|
|
28330
|
+
include_child_account_lines,
|
|
28331
|
+
start_date,
|
|
28332
|
+
end_date,
|
|
28333
|
+
sort_by,
|
|
28334
|
+
sort_order,
|
|
28335
|
+
limit,
|
|
28336
|
+
show_total_count
|
|
28337
|
+
})
|
|
28338
|
+
),
|
|
28339
|
+
({
|
|
28340
|
+
accessToken,
|
|
28341
|
+
apiUrl: apiUrl2,
|
|
28342
|
+
businessId: businessId2,
|
|
28343
|
+
accountId: accountId2,
|
|
28344
|
+
cursor,
|
|
28345
|
+
include_entries_before_activation: include_entries_before_activation2,
|
|
28346
|
+
include_child_account_lines: include_child_account_lines2,
|
|
28347
|
+
start_date: start_date2,
|
|
28348
|
+
end_date: end_date2,
|
|
28349
|
+
sort_by: sort_by2,
|
|
28350
|
+
sort_order: sort_order2,
|
|
28351
|
+
limit: limit2,
|
|
28352
|
+
show_total_count: show_total_count2
|
|
28353
|
+
}) => listLedgerAccountLines(
|
|
28354
|
+
apiUrl2,
|
|
28355
|
+
accessToken,
|
|
28356
|
+
{
|
|
28357
|
+
params: {
|
|
28358
|
+
businessId: businessId2,
|
|
28359
|
+
accountId: accountId2,
|
|
28360
|
+
cursor,
|
|
28361
|
+
include_entries_before_activation: include_entries_before_activation2,
|
|
28362
|
+
include_child_account_lines: include_child_account_lines2,
|
|
28363
|
+
start_date: start_date2,
|
|
28364
|
+
end_date: end_date2,
|
|
28365
|
+
sort_by: sort_by2,
|
|
28366
|
+
sort_order: sort_order2,
|
|
28367
|
+
limit: limit2,
|
|
28368
|
+
show_total_count: show_total_count2
|
|
28369
|
+
}
|
|
28145
28370
|
}
|
|
28146
|
-
|
|
28371
|
+
)(),
|
|
28372
|
+
{
|
|
28373
|
+
keepPreviousData: true,
|
|
28374
|
+
revalidateAll: false,
|
|
28375
|
+
revalidateFirstPage: false,
|
|
28376
|
+
initialSize: 1
|
|
28377
|
+
}
|
|
28147
28378
|
);
|
|
28379
|
+
}
|
|
28380
|
+
|
|
28381
|
+
// src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
|
|
28382
|
+
var useLedgerAccounts = (showReversalEntries = false) => {
|
|
28383
|
+
const { businessId, read, syncTimestamps, hasBeenTouched } = useLayerContext();
|
|
28384
|
+
const { apiUrl } = useEnvironment();
|
|
28385
|
+
const { data: auth } = useAuth();
|
|
28386
|
+
const [accountId, setAccountId] = useState59();
|
|
28387
|
+
const [selectedEntryId, setSelectedEntryId] = useState59();
|
|
28388
|
+
const {
|
|
28389
|
+
data: paginatedData,
|
|
28390
|
+
isLoading: paginationIsLoading,
|
|
28391
|
+
isValidating: paginationIsValidating,
|
|
28392
|
+
error: paginationError,
|
|
28393
|
+
mutate,
|
|
28394
|
+
size,
|
|
28395
|
+
setSize
|
|
28396
|
+
} = useListLedgerAccountLines({
|
|
28397
|
+
accountId: accountId || "",
|
|
28398
|
+
include_child_account_lines: true,
|
|
28399
|
+
sort_by: "entry_at",
|
|
28400
|
+
sort_order: "DESC",
|
|
28401
|
+
limit: 150
|
|
28402
|
+
});
|
|
28403
|
+
const shouldFetch = Boolean(accountId);
|
|
28404
|
+
const data = useMemo45(() => {
|
|
28405
|
+
if (!paginatedData || !shouldFetch) return void 0;
|
|
28406
|
+
return paginatedData.flatMap((page) => page.data);
|
|
28407
|
+
}, [paginatedData, shouldFetch, showReversalEntries]);
|
|
28408
|
+
const hasMore = useMemo45(() => {
|
|
28409
|
+
var _a, _b;
|
|
28410
|
+
if (!shouldFetch || !paginatedData || paginatedData.length === 0) return false;
|
|
28411
|
+
const lastPage = paginatedData[paginatedData.length - 1];
|
|
28412
|
+
return Boolean(
|
|
28413
|
+
((_a = lastPage.meta) == null ? void 0 : _a.pagination.cursor) && ((_b = lastPage.meta) == null ? void 0 : _b.pagination.has_more)
|
|
28414
|
+
);
|
|
28415
|
+
}, [paginatedData, shouldFetch]);
|
|
28416
|
+
const fetchMore = useCallback34(() => {
|
|
28417
|
+
if (hasMore && shouldFetch) {
|
|
28418
|
+
setSize(size + 1);
|
|
28419
|
+
}
|
|
28420
|
+
}, [hasMore, setSize, size, shouldFetch]);
|
|
28148
28421
|
const {
|
|
28149
28422
|
data: entryData,
|
|
28150
28423
|
mutate: mutateEntryData,
|
|
@@ -28162,31 +28435,36 @@ var useLedgerAccounts = (showReversalEntries = false) => {
|
|
|
28162
28435
|
setSelectedEntryId(void 0);
|
|
28163
28436
|
void mutateEntryData();
|
|
28164
28437
|
};
|
|
28438
|
+
const queryKey = useMemo45(() => {
|
|
28439
|
+
return businessId && accountId && (auth == null ? void 0 : auth.access_token) && `ledger-accounts-lines-${businessId}-${accountId}`;
|
|
28440
|
+
}, [businessId, accountId, auth == null ? void 0 : auth.access_token]);
|
|
28165
28441
|
useEffect33(() => {
|
|
28166
|
-
if (queryKey && (
|
|
28442
|
+
if (queryKey && shouldFetch && (paginationIsLoading || paginationIsValidating)) {
|
|
28167
28443
|
read("LEDGER_ACCOUNTS" /* LEDGER_ACCOUNTS */, queryKey);
|
|
28168
28444
|
}
|
|
28169
|
-
}, [
|
|
28445
|
+
}, [paginationIsLoading, paginationIsValidating, shouldFetch]);
|
|
28170
28446
|
useEffect33(() => {
|
|
28171
|
-
if (queryKey && hasBeenTouched(queryKey)) {
|
|
28447
|
+
if (queryKey && shouldFetch && hasBeenTouched(queryKey)) {
|
|
28172
28448
|
void refetch();
|
|
28173
28449
|
}
|
|
28174
|
-
}, [syncTimestamps, accountId]);
|
|
28450
|
+
}, [syncTimestamps, accountId, shouldFetch]);
|
|
28175
28451
|
return {
|
|
28176
|
-
data
|
|
28452
|
+
data,
|
|
28177
28453
|
entryData: entryData == null ? void 0 : entryData.data,
|
|
28178
|
-
isLoading,
|
|
28454
|
+
isLoading: shouldFetch ? paginationIsLoading : false,
|
|
28179
28455
|
isLoadingEntry,
|
|
28180
|
-
isValidating,
|
|
28181
|
-
isValdiatingEntry,
|
|
28182
|
-
error,
|
|
28456
|
+
isValidating: shouldFetch ? paginationIsValidating : false,
|
|
28457
|
+
isValidatingEntry: isValdiatingEntry,
|
|
28458
|
+
error: shouldFetch ? paginationError : void 0,
|
|
28183
28459
|
errorEntry,
|
|
28184
28460
|
refetch,
|
|
28185
28461
|
accountId,
|
|
28186
28462
|
setAccountId,
|
|
28187
28463
|
selectedEntryId,
|
|
28188
28464
|
setSelectedEntryId,
|
|
28189
|
-
closeSelectedEntry
|
|
28465
|
+
closeSelectedEntry,
|
|
28466
|
+
hasMore,
|
|
28467
|
+
fetchMore
|
|
28190
28468
|
};
|
|
28191
28469
|
};
|
|
28192
28470
|
|
|
@@ -28255,13 +28533,13 @@ var ChartOfAccountsDatePicker = () => {
|
|
|
28255
28533
|
};
|
|
28256
28534
|
|
|
28257
28535
|
// src/components/ChartOfAccountsForm/ChartOfAccountsForm.tsx
|
|
28258
|
-
import { useContext as useContext42, useMemo as
|
|
28536
|
+
import { useContext as useContext42, useMemo as useMemo47 } from "react";
|
|
28259
28537
|
|
|
28260
28538
|
// src/components/ChartOfAccountsForm/useParentOptions.ts
|
|
28261
|
-
import { useMemo as
|
|
28539
|
+
import { useMemo as useMemo46 } from "react";
|
|
28262
28540
|
var useParentOptions = (data) => {
|
|
28263
28541
|
var _a;
|
|
28264
|
-
return
|
|
28542
|
+
return useMemo46(
|
|
28265
28543
|
() => flattenAccounts((data == null ? void 0 : data.accounts) || []).sort((a, b) => (a == null ? void 0 : a.name) && (b == null ? void 0 : b.name) ? a.name.localeCompare(b.name) : 0).map((x) => {
|
|
28266
28544
|
return {
|
|
28267
28545
|
label: x.name,
|
|
@@ -28288,7 +28566,7 @@ var ChartOfAccountsForm = ({
|
|
|
28288
28566
|
apiError
|
|
28289
28567
|
} = useContext42(ChartOfAccountsContext);
|
|
28290
28568
|
const parentOptions = useParentOptions(data);
|
|
28291
|
-
const entry =
|
|
28569
|
+
const entry = useMemo47(() => {
|
|
28292
28570
|
if ((form == null ? void 0 : form.action) === "edit" && form.accountId) {
|
|
28293
28571
|
return flattenAccounts((data == null ? void 0 : data.accounts) || []).find(
|
|
28294
28572
|
(x) => x.id === form.accountId
|
|
@@ -28501,7 +28779,7 @@ var ChartOfAccountsSidebar = ({
|
|
|
28501
28779
|
};
|
|
28502
28780
|
|
|
28503
28781
|
// src/components/ChartOfAccountsTable/ChartOfAccountsTable.tsx
|
|
28504
|
-
import { Fragment as Fragment34, useContext as useContext43, useEffect as useEffect34, useMemo as
|
|
28782
|
+
import { Fragment as Fragment34, useContext as useContext43, useEffect as useEffect34, useMemo as useMemo48, useState as useState60 } from "react";
|
|
28505
28783
|
|
|
28506
28784
|
// src/icons/Edit2.tsx
|
|
28507
28785
|
import { jsx as jsx245 } from "react/jsx-runtime";
|
|
@@ -28724,8 +29002,8 @@ var ChartOfAccountsTableContent = ({
|
|
|
28724
29002
|
const { setAccountId } = useContext43(LedgerAccountsContext);
|
|
28725
29003
|
const { editAccount } = useContext43(ChartOfAccountsContext);
|
|
28726
29004
|
const [toggledKeys, setToggledKeys] = useState60({});
|
|
28727
|
-
const sortedAccounts =
|
|
28728
|
-
const allRowKeys =
|
|
29005
|
+
const sortedAccounts = useMemo48(() => sortAccountsRecursive(data.accounts), [data.accounts]);
|
|
29006
|
+
const allRowKeys = useMemo48(() => {
|
|
28729
29007
|
const keys = [];
|
|
28730
29008
|
const collect = (accounts) => {
|
|
28731
29009
|
for (const account of accounts) {
|
|
@@ -28750,7 +29028,7 @@ var ChartOfAccountsTableContent = ({
|
|
|
28750
29028
|
useEffect34(() => {
|
|
28751
29029
|
setToggledKeys({});
|
|
28752
29030
|
}, [searchQuery]);
|
|
28753
|
-
const filteredAccounts =
|
|
29031
|
+
const filteredAccounts = useMemo48(() => {
|
|
28754
29032
|
if (!searchQuery) return sortedAccounts;
|
|
28755
29033
|
return filterAccounts(sortedAccounts, searchQuery.toLowerCase());
|
|
28756
29034
|
}, [searchQuery, sortedAccounts]);
|
|
@@ -29087,12 +29365,12 @@ var ChartOfAccountsTableWithPanel = ({
|
|
|
29087
29365
|
// src/components/LedgerAccount/LedgerAccountIndex.tsx
|
|
29088
29366
|
import {
|
|
29089
29367
|
useContext as useContext47,
|
|
29090
|
-
useMemo as
|
|
29368
|
+
useMemo as useMemo50,
|
|
29091
29369
|
useState as useState62
|
|
29092
29370
|
} from "react";
|
|
29093
29371
|
|
|
29094
29372
|
// src/components/LedgerAccountEntryDetails/LedgerAccountEntryDetails.tsx
|
|
29095
|
-
import { useContext as useContext45, useMemo as
|
|
29373
|
+
import { useContext as useContext45, useMemo as useMemo49 } from "react";
|
|
29096
29374
|
|
|
29097
29375
|
// src/utils/journal.ts
|
|
29098
29376
|
var getAccountIdentifierPayload = (journalLineItem) => {
|
|
@@ -29337,7 +29615,7 @@ var LedgerAccountEntryDetails = ({
|
|
|
29337
29615
|
}) => {
|
|
29338
29616
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
29339
29617
|
const { entryData, isLoadingEntry, closeSelectedEntry, errorEntry } = useContext45(LedgerAccountsContext);
|
|
29340
|
-
const { totalDebit, totalCredit } =
|
|
29618
|
+
const { totalDebit, totalCredit } = useMemo49(() => {
|
|
29341
29619
|
var _a2;
|
|
29342
29620
|
let totalDebit2 = 0;
|
|
29343
29621
|
let totalCredit2 = 0;
|
|
@@ -29492,7 +29770,7 @@ var LedgerAccountRow = ({
|
|
|
29492
29770
|
index,
|
|
29493
29771
|
view
|
|
29494
29772
|
}) => {
|
|
29495
|
-
var _a, _b, _c, _d, _e, _f;
|
|
29773
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
29496
29774
|
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = useContext46(LedgerAccountsContext);
|
|
29497
29775
|
if (view === "tablet") {
|
|
29498
29776
|
return /* @__PURE__ */ jsxs158(
|
|
@@ -29523,7 +29801,8 @@ var LedgerAccountRow = ({
|
|
|
29523
29801
|
}
|
|
29524
29802
|
)
|
|
29525
29803
|
] }),
|
|
29526
|
-
/* @__PURE__ */ jsx253(Text, { children: (_b = (_a = row.source) == null ? void 0 : _a.display_description) != null ? _b : "" })
|
|
29804
|
+
/* @__PURE__ */ jsx253(Text, { children: (_b = (_a = row.source) == null ? void 0 : _a.display_description) != null ? _b : "" }),
|
|
29805
|
+
/* @__PURE__ */ jsx253(Text, { weight: "normal" /* normal */, children: (_d = (_c = row.account) == null ? void 0 : _c.name) != null ? _d : "" })
|
|
29527
29806
|
] }) }),
|
|
29528
29807
|
/* @__PURE__ */ jsx253("td", { className: "Layer__table-cell Layer__table-cell--primary", children: /* @__PURE__ */ jsx253("span", { className: "Layer__table-cell-content Layer__table-cell--amount", children: row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars((row == null ? void 0 : row.amount) || 0)}` }) }),
|
|
29529
29808
|
/* @__PURE__ */ jsx253("td", { className: "Layer__table-cell Layer__table-cell--primary", children: /* @__PURE__ */ jsx253("span", { className: "Layer__table-cell-content Layer__table-cell--amount", children: row.direction === "CREDIT" /* CREDIT */ && `$${centsToDollars((row == null ? void 0 : row.amount) || 0)}` }) }),
|
|
@@ -29560,7 +29839,8 @@ var LedgerAccountRow = ({
|
|
|
29560
29839
|
}
|
|
29561
29840
|
)
|
|
29562
29841
|
] }),
|
|
29563
|
-
/* @__PURE__ */ jsx253(Text, { children: (
|
|
29842
|
+
/* @__PURE__ */ jsx253(Text, { children: (_f = (_e = row.source) == null ? void 0 : _e.display_description) != null ? _f : "" }),
|
|
29843
|
+
/* @__PURE__ */ jsx253(Text, { weight: "normal" /* normal */, children: (_h = (_g = row.account) == null ? void 0 : _g.name) != null ? _h : "" }),
|
|
29564
29844
|
/* @__PURE__ */ jsxs158("div", { className: "Layer__ledger_account-table__balances-mobile", children: [
|
|
29565
29845
|
/* @__PURE__ */ jsxs158("div", { className: "Layer__ledger_account-table__balance-item", children: [
|
|
29566
29846
|
/* @__PURE__ */ jsx253("span", { className: "Layer__ledger_account-table__balances-mobile__label", children: "Debit" }),
|
|
@@ -29600,7 +29880,8 @@ var LedgerAccountRow = ({
|
|
|
29600
29880
|
children: [
|
|
29601
29881
|
/* @__PURE__ */ jsx253("td", { className: "Layer__table-cell", children: /* @__PURE__ */ jsx253("span", { className: "Layer__table-cell-content", children: row.date && formatTime11(parseISO14(row.date), DATE_FORMAT) }) }),
|
|
29602
29882
|
/* @__PURE__ */ jsx253("td", { className: "Layer__table-cell", children: /* @__PURE__ */ jsx253("span", { className: "Layer__table-cell-content", children: lineEntryNumber(row) }) }),
|
|
29603
|
-
/* @__PURE__ */ jsx253("td", { className: "Layer__table-cell", children: /* @__PURE__ */ jsx253("span", { className: "Layer__table-cell-content", children: (
|
|
29883
|
+
/* @__PURE__ */ jsx253("td", { className: "Layer__table-cell", children: /* @__PURE__ */ jsx253("span", { className: "Layer__table-cell-content", children: (_j = (_i = row.source) == null ? void 0 : _i.display_description) != null ? _j : "" }) }),
|
|
29884
|
+
/* @__PURE__ */ jsx253("td", { className: "Layer__table-cell", children: /* @__PURE__ */ jsx253("span", { className: "Layer__table-cell-content", children: (_l = (_k = row.account) == null ? void 0 : _k.name) != null ? _l : "" }) }),
|
|
29604
29885
|
/* @__PURE__ */ jsx253("td", { className: "Layer__table-cell Layer__table-cell--primary", children: /* @__PURE__ */ jsx253("span", { className: "Layer__table-cell-content Layer__table-cell--amount", children: row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars((row == null ? void 0 : row.amount) || 0)}` }) }),
|
|
29605
29886
|
/* @__PURE__ */ jsx253("td", { className: "Layer__table-cell Layer__table-cell--primary", children: /* @__PURE__ */ jsx253("span", { className: "Layer__table-cell-content Layer__table-cell--amount", children: row.direction === "CREDIT" /* CREDIT */ && `$${centsToDollars((row == null ? void 0 : row.amount) || 0)}` }) }),
|
|
29606
29887
|
/* @__PURE__ */ jsx253("td", { className: "Layer__table-cell Layer__table-cell--primary", children: /* @__PURE__ */ jsx253("span", { className: "Layer__table-cell-content Layer__table-cell--amount", children: `$${centsToDollars(row.running_balance)}` }) })
|
|
@@ -29630,23 +29911,36 @@ var LedgerAccount = ({
|
|
|
29630
29911
|
setAccountId,
|
|
29631
29912
|
selectedEntryId,
|
|
29632
29913
|
closeSelectedEntry,
|
|
29633
|
-
refetch
|
|
29914
|
+
refetch,
|
|
29915
|
+
hasMore,
|
|
29916
|
+
fetchMore
|
|
29634
29917
|
} = useContext47(LedgerAccountsContext);
|
|
29635
29918
|
const baseClassName = classNames75(
|
|
29636
29919
|
"Layer__ledger-account__index",
|
|
29637
29920
|
accountId && "open"
|
|
29638
29921
|
);
|
|
29639
|
-
const account =
|
|
29922
|
+
const account = useMemo50(() => {
|
|
29640
29923
|
return flattenAccounts((accountData == null ? void 0 : accountData.accounts) || []).find(
|
|
29641
29924
|
(x) => x.id === accountId
|
|
29642
29925
|
);
|
|
29643
29926
|
}, [accountId]);
|
|
29644
|
-
const data =
|
|
29927
|
+
const data = useMemo50(() => {
|
|
29645
29928
|
var _a2;
|
|
29929
|
+
if (!rawData) return void 0;
|
|
29646
29930
|
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
29647
29931
|
const lastPageIndex = firstPageIndex + pageSize;
|
|
29648
29932
|
return (_a2 = rawData == null ? void 0 : rawData.sort((a, b) => Date.parse(b.date) - Date.parse(a.date))) == null ? void 0 : _a2.slice(firstPageIndex, lastPageIndex);
|
|
29649
|
-
}, [rawData, currentPage]);
|
|
29933
|
+
}, [rawData, currentPage, pageSize]);
|
|
29934
|
+
const handlePageChange = (page) => {
|
|
29935
|
+
setCurrentPage(page);
|
|
29936
|
+
if (rawData) {
|
|
29937
|
+
const requestedItemIndex = (page - 1) * pageSize + pageSize - 1;
|
|
29938
|
+
const lastAvailableIndex = rawData.length - 1;
|
|
29939
|
+
if (requestedItemIndex > lastAvailableIndex && hasMore) {
|
|
29940
|
+
fetchMore();
|
|
29941
|
+
}
|
|
29942
|
+
}
|
|
29943
|
+
};
|
|
29650
29944
|
const close2 = () => {
|
|
29651
29945
|
setAccountId(void 0);
|
|
29652
29946
|
closeSelectedEntry();
|
|
@@ -29704,17 +29998,16 @@ var LedgerAccount = ({
|
|
|
29704
29998
|
view === "desktop" && /* @__PURE__ */ jsxs159(Fragment37, { children: [
|
|
29705
29999
|
/* @__PURE__ */ jsx254("th", { className: "Layer__table-header", children: ((_b = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _b.dateColumnHeader) || "Date" }),
|
|
29706
30000
|
/* @__PURE__ */ jsx254("th", { className: "Layer__table-header", children: ((_c = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _c.journalIdColumnHeader) || "Journal id #" }),
|
|
29707
|
-
/* @__PURE__ */ jsx254("th", { className: "Layer__table-header", children: ((_d = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _d.sourceColumnHeader) || "Source" })
|
|
30001
|
+
/* @__PURE__ */ jsx254("th", { className: "Layer__table-header", children: ((_d = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _d.sourceColumnHeader) || "Source" }),
|
|
30002
|
+
/* @__PURE__ */ jsx254("th", { className: "Layer__table-header", children: ((_e = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _e.accountColumnHeader) || "Account" })
|
|
29708
30003
|
] }),
|
|
29709
30004
|
view !== "mobile" && /* @__PURE__ */ jsxs159(Fragment37, { children: [
|
|
29710
|
-
/* @__PURE__ */ jsx254("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((
|
|
29711
|
-
/* @__PURE__ */ jsx254("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((
|
|
29712
|
-
/* @__PURE__ */ jsx254("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((
|
|
30005
|
+
/* @__PURE__ */ jsx254("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((_f = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _f.debitColumnHeader) || "Debit" }),
|
|
30006
|
+
/* @__PURE__ */ jsx254("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((_g = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _g.creditColumnHeader) || "Credit" }),
|
|
30007
|
+
/* @__PURE__ */ jsx254("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((_h = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _h.runningBalanceColumnHeader) || "Running balance" })
|
|
29713
30008
|
] })
|
|
29714
30009
|
] }) }),
|
|
29715
|
-
/* @__PURE__ */ jsx254("tbody", { children:
|
|
29716
|
-
(entry) => !entry.entry_reversal_of && !entry.entry_reversed_by
|
|
29717
|
-
)) == null ? void 0 : _h.map((x, index) => /* @__PURE__ */ jsx254(
|
|
30010
|
+
/* @__PURE__ */ jsx254("tbody", { children: data == null ? void 0 : data.map((x, index) => /* @__PURE__ */ jsx254(
|
|
29718
30011
|
LedgerAccountRow,
|
|
29719
30012
|
{
|
|
29720
30013
|
row: x,
|
|
@@ -29730,7 +30023,9 @@ var LedgerAccount = ({
|
|
|
29730
30023
|
currentPage,
|
|
29731
30024
|
totalCount: (rawData == null ? void 0 : rawData.length) || 0,
|
|
29732
30025
|
pageSize,
|
|
29733
|
-
onPageChange:
|
|
30026
|
+
onPageChange: handlePageChange,
|
|
30027
|
+
hasMore,
|
|
30028
|
+
fetchMore
|
|
29734
30029
|
}
|
|
29735
30030
|
),
|
|
29736
30031
|
error ? /* @__PURE__ */ jsx254("div", { className: "Layer__table-state-container", children: /* @__PURE__ */ jsx254(
|
|
@@ -29835,12 +30130,12 @@ var JournalContext = createContext22({
|
|
|
29835
30130
|
});
|
|
29836
30131
|
|
|
29837
30132
|
// src/hooks/useJournal/useJournal.tsx
|
|
29838
|
-
import { useState as useState63, useMemo as
|
|
30133
|
+
import { useState as useState63, useMemo as useMemo52, useCallback as useCallback36 } from "react";
|
|
29839
30134
|
|
|
29840
30135
|
// src/features/ledger/entries/api/useListLedgerEntries.ts
|
|
29841
|
-
import
|
|
29842
|
-
var
|
|
29843
|
-
import { useCallback as
|
|
30136
|
+
import useSWRInfinite5 from "swr/infinite";
|
|
30137
|
+
var import_lodash5 = __toESM(require_lodash2());
|
|
30138
|
+
import { useCallback as useCallback35, useMemo as useMemo51 } from "react";
|
|
29844
30139
|
var LIST_LEDGER_ENTRIES_TAG_KEY = "#list-ledger-entries";
|
|
29845
30140
|
var listLedgerEntries = get(({ businessId, sort_by, sort_order, cursor, limit, show_total_count }) => {
|
|
29846
30141
|
const parameters = toDefinedSearchParameters({
|
|
@@ -29852,7 +30147,7 @@ var listLedgerEntries = get(({ businessId, sort_by, sort_order, cursor, limit, s
|
|
|
29852
30147
|
});
|
|
29853
30148
|
return `/v1/businesses/${businessId}/ledger/entries?${parameters}`;
|
|
29854
30149
|
});
|
|
29855
|
-
function
|
|
30150
|
+
function keyLoader5(previousPageData, {
|
|
29856
30151
|
access_token: accessToken,
|
|
29857
30152
|
apiUrl,
|
|
29858
30153
|
businessId,
|
|
@@ -29885,8 +30180,8 @@ function useListLedgerEntries({
|
|
|
29885
30180
|
const { businessId } = useLayerContext();
|
|
29886
30181
|
const { apiUrl } = useEnvironment();
|
|
29887
30182
|
const { data: auth } = useAuth();
|
|
29888
|
-
return
|
|
29889
|
-
(index, previousPageData) =>
|
|
30183
|
+
return useSWRInfinite5(
|
|
30184
|
+
(index, previousPageData) => keyLoader5(
|
|
29890
30185
|
previousPageData,
|
|
29891
30186
|
__spreadProps(__spreadValues({}, auth), {
|
|
29892
30187
|
apiUrl,
|
|
@@ -29955,11 +30250,11 @@ var useJournal = () => {
|
|
|
29955
30250
|
sort_order: "DESC",
|
|
29956
30251
|
limit: 150
|
|
29957
30252
|
});
|
|
29958
|
-
const data =
|
|
30253
|
+
const data = useMemo52(() => {
|
|
29959
30254
|
if (!paginatedData) return void 0;
|
|
29960
30255
|
return paginatedData.flatMap((page) => page.data);
|
|
29961
30256
|
}, [paginatedData]);
|
|
29962
|
-
const hasMore =
|
|
30257
|
+
const hasMore = useMemo52(() => {
|
|
29963
30258
|
var _a, _b;
|
|
29964
30259
|
if (paginatedData && paginatedData.length > 0) {
|
|
29965
30260
|
const lastPage = paginatedData[paginatedData.length - 1];
|
|
@@ -29969,7 +30264,7 @@ var useJournal = () => {
|
|
|
29969
30264
|
}
|
|
29970
30265
|
return false;
|
|
29971
30266
|
}, [paginatedData]);
|
|
29972
|
-
const fetchMore =
|
|
30267
|
+
const fetchMore = useCallback36(() => {
|
|
29973
30268
|
if (hasMore) {
|
|
29974
30269
|
setSize(size + 1);
|
|
29975
30270
|
}
|
|
@@ -30214,13 +30509,13 @@ var useJournal = () => {
|
|
|
30214
30509
|
};
|
|
30215
30510
|
|
|
30216
30511
|
// src/components/JournalTable/JournalTableWithPanel.tsx
|
|
30217
|
-
import { useContext as useContext54, useMemo as
|
|
30512
|
+
import { useContext as useContext54, useMemo as useMemo55, useState as useState65 } from "react";
|
|
30218
30513
|
|
|
30219
30514
|
// src/components/JournalSidebar/JournalSidebar.tsx
|
|
30220
30515
|
import { useContext as useContext52 } from "react";
|
|
30221
30516
|
|
|
30222
30517
|
// src/components/JournalEntryDetails/JournalEntryDetails.tsx
|
|
30223
|
-
import { useContext as useContext49, useMemo as
|
|
30518
|
+
import { useContext as useContext49, useMemo as useMemo53, useState as useState64 } from "react";
|
|
30224
30519
|
import { jsx as jsx256, jsxs as jsxs160 } from "react/jsx-runtime";
|
|
30225
30520
|
var JournalEntryDetails = () => {
|
|
30226
30521
|
var _a, _b, _c, _d;
|
|
@@ -30235,13 +30530,13 @@ var JournalEntryDetails = () => {
|
|
|
30235
30530
|
} = useContext49(JournalContext);
|
|
30236
30531
|
const [reverseEntryProcessing, setReverseEntryProcessing] = useState64(false);
|
|
30237
30532
|
const [reverseEntryError, setReverseEntryError] = useState64();
|
|
30238
|
-
const entry =
|
|
30533
|
+
const entry = useMemo53(() => {
|
|
30239
30534
|
if (selectedEntryId && data) {
|
|
30240
30535
|
return data.find((x) => x.id === selectedEntryId);
|
|
30241
30536
|
}
|
|
30242
30537
|
return;
|
|
30243
30538
|
}, [data, selectedEntryId]);
|
|
30244
|
-
const sortedLineItems =
|
|
30539
|
+
const sortedLineItems = useMemo53(
|
|
30245
30540
|
() => {
|
|
30246
30541
|
var _a2;
|
|
30247
30542
|
return (_a2 = entry == null ? void 0 : entry.line_items) == null ? void 0 : _a2.sort(
|
|
@@ -30422,7 +30717,7 @@ var JournalEntryDetails = () => {
|
|
|
30422
30717
|
import { useContext as useContext51 } from "react";
|
|
30423
30718
|
|
|
30424
30719
|
// src/components/JournalForm/JournalFormEntryLines.tsx
|
|
30425
|
-
import { useContext as useContext50, useMemo as
|
|
30720
|
+
import { useContext as useContext50, useMemo as useMemo54 } from "react";
|
|
30426
30721
|
import { Fragment as Fragment38, jsx as jsx257, jsxs as jsxs161 } from "react/jsx-runtime";
|
|
30427
30722
|
function recursiveFlattenCategories(accounts) {
|
|
30428
30723
|
const flattenedResult = accounts.flatMap((a) => {
|
|
@@ -30444,7 +30739,7 @@ var JournalFormEntryLines = ({
|
|
|
30444
30739
|
}) => {
|
|
30445
30740
|
const { data: categories } = useCategories({ mode: "ALL" });
|
|
30446
30741
|
const { form } = useContext50(JournalContext);
|
|
30447
|
-
const { flattenedCategories, parentOptions } =
|
|
30742
|
+
const { flattenedCategories, parentOptions } = useMemo54(() => {
|
|
30448
30743
|
const flattenedCategories2 = recursiveFlattenCategories(categories != null ? categories : []);
|
|
30449
30744
|
const parentOptions2 = [...flattenedCategories2].sort((a, b) => a.display_name.localeCompare(b.display_name)).map((account) => {
|
|
30450
30745
|
switch (account.type) {
|
|
@@ -31037,7 +31332,7 @@ var JournalTableWithPanel = ({
|
|
|
31037
31332
|
hasMore,
|
|
31038
31333
|
fetchMore
|
|
31039
31334
|
} = useContext54(JournalContext);
|
|
31040
|
-
const data =
|
|
31335
|
+
const data = useMemo55(
|
|
31041
31336
|
() => {
|
|
31042
31337
|
if (!rawData) return void 0;
|
|
31043
31338
|
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
@@ -31183,7 +31478,7 @@ var TasksHeader = ({
|
|
|
31183
31478
|
};
|
|
31184
31479
|
|
|
31185
31480
|
// src/components/Tasks/TasksList.tsx
|
|
31186
|
-
import { useMemo as
|
|
31481
|
+
import { useMemo as useMemo58 } from "react";
|
|
31187
31482
|
|
|
31188
31483
|
// src/icons/SmileIcon.tsx
|
|
31189
31484
|
import { jsx as jsx265, jsxs as jsxs166 } from "react/jsx-runtime";
|
|
@@ -31242,7 +31537,7 @@ var SmileIcon = (_a) => {
|
|
|
31242
31537
|
var SmileIcon_default = SmileIcon;
|
|
31243
31538
|
|
|
31244
31539
|
// src/components/Tasks/TasksListItem.tsx
|
|
31245
|
-
import { useEffect as useEffect36, useMemo as
|
|
31540
|
+
import { useEffect as useEffect36, useMemo as useMemo56, useState as useState66 } from "react";
|
|
31246
31541
|
import classNames76 from "classnames";
|
|
31247
31542
|
|
|
31248
31543
|
// src/utils/bookkeeping/tasks/getBookkeepingTaskStatusIcon.tsx
|
|
@@ -31300,7 +31595,7 @@ function completeTaskWithUpload(baseUrl, accessToken, {
|
|
|
31300
31595
|
}
|
|
31301
31596
|
|
|
31302
31597
|
// src/hooks/bookkeeping/periods/tasks/useSubmitResponseForTask.ts
|
|
31303
|
-
import { useCallback as
|
|
31598
|
+
import { useCallback as useCallback37 } from "react";
|
|
31304
31599
|
function buildKey29({
|
|
31305
31600
|
access_token: accessToken,
|
|
31306
31601
|
apiUrl,
|
|
@@ -31343,7 +31638,7 @@ function useSubmitUserResponseForTask() {
|
|
|
31343
31638
|
}
|
|
31344
31639
|
);
|
|
31345
31640
|
const { trigger: originalTrigger } = mutationResponse;
|
|
31346
|
-
const stableProxiedTrigger =
|
|
31641
|
+
const stableProxiedTrigger = useCallback37(
|
|
31347
31642
|
(...triggerParameters) => __async(null, null, function* () {
|
|
31348
31643
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
31349
31644
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -31370,7 +31665,7 @@ function useSubmitUserResponseForTask() {
|
|
|
31370
31665
|
// src/hooks/bookkeeping/periods/tasks/useUploadDocumentsForTask.ts
|
|
31371
31666
|
import { useSWRConfig as useSWRConfig8 } from "swr";
|
|
31372
31667
|
import useSWRMutation19 from "swr/mutation";
|
|
31373
|
-
import { useCallback as
|
|
31668
|
+
import { useCallback as useCallback38 } from "react";
|
|
31374
31669
|
function buildKey30({
|
|
31375
31670
|
access_token: accessToken,
|
|
31376
31671
|
apiUrl,
|
|
@@ -31409,7 +31704,7 @@ function useUploadDocumentsForTask() {
|
|
|
31409
31704
|
}
|
|
31410
31705
|
);
|
|
31411
31706
|
const { trigger: originalTrigger } = mutationResponse;
|
|
31412
|
-
const stableProxiedTrigger =
|
|
31707
|
+
const stableProxiedTrigger = useCallback38(
|
|
31413
31708
|
(...triggerParameters) => __async(null, null, function* () {
|
|
31414
31709
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
31415
31710
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -31436,7 +31731,7 @@ function useUploadDocumentsForTask() {
|
|
|
31436
31731
|
// src/hooks/bookkeeping/periods/tasks/useDeleteUploadsOnTask.ts
|
|
31437
31732
|
import { useSWRConfig as useSWRConfig9 } from "swr";
|
|
31438
31733
|
import useSWRMutation20 from "swr/mutation";
|
|
31439
|
-
import { useCallback as
|
|
31734
|
+
import { useCallback as useCallback39 } from "react";
|
|
31440
31735
|
function buildKey31({
|
|
31441
31736
|
access_token: accessToken,
|
|
31442
31737
|
apiUrl,
|
|
@@ -31472,7 +31767,7 @@ function useDeleteUploadsOnTask() {
|
|
|
31472
31767
|
}
|
|
31473
31768
|
);
|
|
31474
31769
|
const { trigger: originalTrigger } = mutationResponse;
|
|
31475
|
-
const stableProxiedTrigger =
|
|
31770
|
+
const stableProxiedTrigger = useCallback39(
|
|
31476
31771
|
(...triggerParameters) => __async(null, null, function* () {
|
|
31477
31772
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
31478
31773
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -31499,7 +31794,7 @@ function useDeleteUploadsOnTask() {
|
|
|
31499
31794
|
// src/hooks/bookkeeping/periods/tasks/useUpdateTaskUploadDescription.ts
|
|
31500
31795
|
import { useSWRConfig as useSWRConfig10 } from "swr";
|
|
31501
31796
|
import useSWRMutation21 from "swr/mutation";
|
|
31502
|
-
import { useCallback as
|
|
31797
|
+
import { useCallback as useCallback40 } from "react";
|
|
31503
31798
|
function buildKey32({
|
|
31504
31799
|
access_token: accessToken,
|
|
31505
31800
|
apiUrl,
|
|
@@ -31539,7 +31834,7 @@ function useUpdateTaskUploadDescription() {
|
|
|
31539
31834
|
}
|
|
31540
31835
|
);
|
|
31541
31836
|
const { trigger: originalTrigger } = mutationResponse;
|
|
31542
|
-
const stableProxiedTrigger =
|
|
31837
|
+
const stableProxiedTrigger = useCallback40(
|
|
31543
31838
|
(...triggerParameters) => __async(null, null, function* () {
|
|
31544
31839
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
31545
31840
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -31605,7 +31900,7 @@ var TasksListItem = ({
|
|
|
31605
31900
|
setIsOpen(false);
|
|
31606
31901
|
setSelectedFiles(void 0);
|
|
31607
31902
|
});
|
|
31608
|
-
const uploadDocumentAction =
|
|
31903
|
+
const uploadDocumentAction = useMemo56(() => {
|
|
31609
31904
|
if (task.user_response_type === "UPLOAD_DOCUMENT") {
|
|
31610
31905
|
if (task.status === "TODO") {
|
|
31611
31906
|
if (!selectedFiles) {
|
|
@@ -31809,27 +32104,27 @@ var TasksListMobile = ({
|
|
|
31809
32104
|
};
|
|
31810
32105
|
|
|
31811
32106
|
// src/hooks/array/usePaginatedList.ts
|
|
31812
|
-
import { useCallback as
|
|
32107
|
+
import { useCallback as useCallback41, useMemo as useMemo57, useState as useState68 } from "react";
|
|
31813
32108
|
function usePaginatedList(list, pageSize) {
|
|
31814
32109
|
const [internalPageIndex, setInternalPageIndex] = useState68(0);
|
|
31815
32110
|
const pageCount = Math.max(0, Math.ceil(list.length / pageSize));
|
|
31816
32111
|
const effectivePageIndex = Math.max(0, Math.min(internalPageIndex, pageCount - 1));
|
|
31817
|
-
const pageItems =
|
|
32112
|
+
const pageItems = useMemo57(() => {
|
|
31818
32113
|
return list.slice(
|
|
31819
32114
|
effectivePageIndex * pageSize,
|
|
31820
32115
|
(effectivePageIndex + 1) * pageSize
|
|
31821
32116
|
);
|
|
31822
32117
|
}, [list, effectivePageIndex, pageSize]);
|
|
31823
|
-
const next =
|
|
32118
|
+
const next = useCallback41(() => {
|
|
31824
32119
|
setInternalPageIndex(Math.min(effectivePageIndex + 1, pageCount - 1));
|
|
31825
32120
|
}, [effectivePageIndex, pageCount]);
|
|
31826
|
-
const set2 =
|
|
32121
|
+
const set2 = useCallback41((pageIndex) => {
|
|
31827
32122
|
setInternalPageIndex(Math.max(0, Math.min(pageIndex, pageCount - 1)));
|
|
31828
32123
|
}, [pageCount]);
|
|
31829
|
-
const previous =
|
|
32124
|
+
const previous = useCallback41(() => {
|
|
31830
32125
|
setInternalPageIndex(Math.max(effectivePageIndex - 1, 0));
|
|
31831
32126
|
}, [effectivePageIndex]);
|
|
31832
|
-
const reset =
|
|
32127
|
+
const reset = useCallback41(() => {
|
|
31833
32128
|
setInternalPageIndex(0);
|
|
31834
32129
|
}, []);
|
|
31835
32130
|
return {
|
|
@@ -31857,7 +32152,7 @@ var TasksEmptyState = () => /* @__PURE__ */ jsxs170("div", { className: "Layer__
|
|
|
31857
32152
|
] });
|
|
31858
32153
|
function TasksList({ pageSize = 8, mobile }) {
|
|
31859
32154
|
const { activePeriod } = useActiveBookkeepingPeriod();
|
|
31860
|
-
const sortedTasks =
|
|
32155
|
+
const sortedTasks = useMemo58(() => {
|
|
31861
32156
|
var _a;
|
|
31862
32157
|
const tasksInPeriod = (_a = activePeriod == null ? void 0 : activePeriod.tasks) != null ? _a : [];
|
|
31863
32158
|
return tasksInPeriod.sort((taskA, taskB) => {
|
|
@@ -31999,7 +32294,7 @@ var TasksPending = () => {
|
|
|
31999
32294
|
};
|
|
32000
32295
|
|
|
32001
32296
|
// src/components/Tasks/TasksMonthSelector.tsx
|
|
32002
|
-
import { useMemo as
|
|
32297
|
+
import { useMemo as useMemo59 } from "react";
|
|
32003
32298
|
import { format as format7, getMonth as getMonth3, getYear as getYear4, set } from "date-fns";
|
|
32004
32299
|
|
|
32005
32300
|
// src/components/Tasks/TaskStatusBadge.tsx
|
|
@@ -32101,7 +32396,7 @@ function useActiveYearBookkeepingPeriods() {
|
|
|
32101
32396
|
const { date } = useGlobalDate();
|
|
32102
32397
|
const { data } = useBookkeepingPeriods();
|
|
32103
32398
|
const activeYear = getYear4(date);
|
|
32104
|
-
const periodsInActiveYear =
|
|
32399
|
+
const periodsInActiveYear = useMemo59(() => {
|
|
32105
32400
|
return data == null ? void 0 : data.filter((period) => period.year === activeYear);
|
|
32106
32401
|
}, [data, activeYear]);
|
|
32107
32402
|
return { periodsInActiveYear };
|
|
@@ -32112,7 +32407,7 @@ function TasksMonthSelector() {
|
|
|
32112
32407
|
const { periodsInActiveYear } = useActiveYearBookkeepingPeriods();
|
|
32113
32408
|
const activeMonthNumber = getMonth3(date) + 1;
|
|
32114
32409
|
const activeYear = getYear4(date);
|
|
32115
|
-
const monthsData =
|
|
32410
|
+
const monthsData = useMemo59(() => {
|
|
32116
32411
|
return Array.from({ length: 12 }, (_, index) => {
|
|
32117
32412
|
var _a, _b;
|
|
32118
32413
|
const date2 = set(
|
|
@@ -32162,13 +32457,13 @@ import classNames80 from "classnames";
|
|
|
32162
32457
|
import pluralize4 from "pluralize";
|
|
32163
32458
|
|
|
32164
32459
|
// src/hooks/bookkeeping/periods/useBookkeepingYearsStatus.ts
|
|
32165
|
-
import { useMemo as
|
|
32460
|
+
import { useMemo as useMemo60 } from "react";
|
|
32166
32461
|
import { getYear as getYear5 } from "date-fns";
|
|
32167
32462
|
var useBookkeepingYearsStatus = () => {
|
|
32168
32463
|
const { business } = useLayerContext();
|
|
32169
32464
|
const activationDate = getActivationDate(business);
|
|
32170
32465
|
const { data, isLoading } = useBookkeepingPeriods();
|
|
32171
|
-
const yearStatuses =
|
|
32466
|
+
const yearStatuses = useMemo60(() => {
|
|
32172
32467
|
const startYear = getYear5(activationDate != null ? activationDate : /* @__PURE__ */ new Date());
|
|
32173
32468
|
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
32174
32469
|
const count = currentYear - startYear + 1;
|
|
@@ -32183,7 +32478,7 @@ var useBookkeepingYearsStatus = () => {
|
|
|
32183
32478
|
};
|
|
32184
32479
|
}).filter(({ year }) => data == null ? void 0 : data.some((period) => period.year === year)).sort((a, b) => b.year - a.year);
|
|
32185
32480
|
}, [activationDate, data]);
|
|
32186
|
-
const earliestIncompletePeriod =
|
|
32481
|
+
const earliestIncompletePeriod = useMemo60(
|
|
32187
32482
|
() => [...data != null ? data : []].sort((a, b) => {
|
|
32188
32483
|
if (a.year === b.year) {
|
|
32189
32484
|
return b.month - a.month;
|
|
@@ -32326,7 +32621,7 @@ var TasksPanelNotification = ({
|
|
|
32326
32621
|
};
|
|
32327
32622
|
|
|
32328
32623
|
// src/components/Tasks/TasksYearsTabs.tsx
|
|
32329
|
-
import { useMemo as
|
|
32624
|
+
import { useMemo as useMemo61 } from "react";
|
|
32330
32625
|
|
|
32331
32626
|
// src/components/Tabs/Tabs.tsx
|
|
32332
32627
|
import { useEffect as useEffect37, useState as useState69 } from "react";
|
|
@@ -32488,7 +32783,7 @@ var TasksYearsTabs = () => {
|
|
|
32488
32783
|
yearNumber: Number(year)
|
|
32489
32784
|
});
|
|
32490
32785
|
};
|
|
32491
|
-
const yearsList =
|
|
32786
|
+
const yearsList = useMemo61(() => {
|
|
32492
32787
|
return yearStatuses == null ? void 0 : yearStatuses.sort((a, b) => a.year - b.year).map((y) => {
|
|
32493
32788
|
return {
|
|
32494
32789
|
value: `${y.year}`,
|
|
@@ -33194,7 +33489,7 @@ function useBusinessPersonnel() {
|
|
|
33194
33489
|
// src/hooks/businessPersonnel/useCreateBusinessPersonnel.ts
|
|
33195
33490
|
import useSWRMutation22 from "swr/mutation";
|
|
33196
33491
|
import { useSWRConfig as useSWRConfig11 } from "swr";
|
|
33197
|
-
import { useCallback as
|
|
33492
|
+
import { useCallback as useCallback42 } from "react";
|
|
33198
33493
|
var createBusinessPersonnel = post(({ businessId }) => `/v1/businesses/${businessId}/personnel`);
|
|
33199
33494
|
function buildKey34({
|
|
33200
33495
|
access_token: accessToken,
|
|
@@ -33232,7 +33527,7 @@ function useCreateBusinessPersonnel() {
|
|
|
33232
33527
|
}
|
|
33233
33528
|
);
|
|
33234
33529
|
const { trigger: originalTrigger } = mutationResponse;
|
|
33235
|
-
const stableProxiedTrigger =
|
|
33530
|
+
const stableProxiedTrigger = useCallback42(
|
|
33236
33531
|
(...triggerParameters) => __async(null, null, function* () {
|
|
33237
33532
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
33238
33533
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -33266,7 +33561,7 @@ var updateBusinessPersonnel = post(({ businessId, businessPersonnelId }) => {
|
|
|
33266
33561
|
});
|
|
33267
33562
|
|
|
33268
33563
|
// src/hooks/businessPersonnel/useUpdateBusinessPersonnel.ts
|
|
33269
|
-
import { useCallback as
|
|
33564
|
+
import { useCallback as useCallback43 } from "react";
|
|
33270
33565
|
function buildKey35({
|
|
33271
33566
|
access_token: accessToken,
|
|
33272
33567
|
apiUrl,
|
|
@@ -33309,7 +33604,7 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
|
|
|
33309
33604
|
}
|
|
33310
33605
|
);
|
|
33311
33606
|
const { trigger: originalTrigger } = mutationResponse;
|
|
33312
|
-
const stableProxiedTrigger =
|
|
33607
|
+
const stableProxiedTrigger = useCallback43(
|
|
33313
33608
|
(...triggerParameters) => __async(null, null, function* () {
|
|
33314
33609
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
33315
33610
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -33336,7 +33631,7 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
|
|
|
33336
33631
|
// src/hooks/business/useUpdateBusiness.ts
|
|
33337
33632
|
import useSWRMutation24 from "swr/mutation";
|
|
33338
33633
|
import { useSWRConfig as useSWRConfig13 } from "swr";
|
|
33339
|
-
import { useCallback as
|
|
33634
|
+
import { useCallback as useCallback44 } from "react";
|
|
33340
33635
|
var BUSINESS_TAG_KEY = "business";
|
|
33341
33636
|
function buildKey36({
|
|
33342
33637
|
access_token: accessToken,
|
|
@@ -33374,7 +33669,7 @@ function useUpdateBusiness() {
|
|
|
33374
33669
|
}
|
|
33375
33670
|
);
|
|
33376
33671
|
const { trigger: originalTrigger } = mutationResponse;
|
|
33377
|
-
const stableProxiedTrigger =
|
|
33672
|
+
const stableProxiedTrigger = useCallback44(
|
|
33378
33673
|
(...triggerParameters) => __async(null, null, function* () {
|
|
33379
33674
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
33380
33675
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -34551,9 +34846,9 @@ var ProjectProfitabilityView = ({
|
|
|
34551
34846
|
import { createContext as createContext23, useContext as useContext58 } from "react";
|
|
34552
34847
|
|
|
34553
34848
|
// src/hooks/useBills.tsx
|
|
34554
|
-
import { useMemo as
|
|
34849
|
+
import { useMemo as useMemo62, useState as useState76 } from "react";
|
|
34555
34850
|
import { endOfMonth as endOfMonth14, startOfMonth as startOfMonth17, sub as sub3 } from "date-fns";
|
|
34556
|
-
import
|
|
34851
|
+
import useSWRInfinite6 from "swr/infinite";
|
|
34557
34852
|
var PAGE_SIZE = 20;
|
|
34558
34853
|
var useBills = () => {
|
|
34559
34854
|
const { businessId } = useLayerContext();
|
|
@@ -34600,7 +34895,7 @@ var useBills = () => {
|
|
|
34600
34895
|
size,
|
|
34601
34896
|
setSize,
|
|
34602
34897
|
mutate
|
|
34603
|
-
} =
|
|
34898
|
+
} = useSWRInfinite6(
|
|
34604
34899
|
getKey,
|
|
34605
34900
|
(_0) => __async(null, [_0], function* ([_query, nextCursor]) {
|
|
34606
34901
|
if (auth == null ? void 0 : auth.access_token) {
|
|
@@ -34622,24 +34917,24 @@ var useBills = () => {
|
|
|
34622
34917
|
revalidateFirstPage: false
|
|
34623
34918
|
}
|
|
34624
34919
|
);
|
|
34625
|
-
const data =
|
|
34920
|
+
const data = useMemo62(() => {
|
|
34626
34921
|
if (rawResponseData && rawResponseData.length > 0) {
|
|
34627
34922
|
return rawResponseData == null ? void 0 : rawResponseData.map((x) => x == null ? void 0 : x.data).flat().filter((x) => !!x);
|
|
34628
34923
|
}
|
|
34629
34924
|
return void 0;
|
|
34630
34925
|
}, [rawResponseData]);
|
|
34631
|
-
const paginatedData =
|
|
34926
|
+
const paginatedData = useMemo62(() => {
|
|
34632
34927
|
const firstPageIndex = (currentPage - 1) * PAGE_SIZE;
|
|
34633
34928
|
const lastPageIndex = firstPageIndex + PAGE_SIZE;
|
|
34634
34929
|
return data == null ? void 0 : data.slice(firstPageIndex, lastPageIndex);
|
|
34635
34930
|
}, [currentPage, data]);
|
|
34636
|
-
const lastMetadata =
|
|
34931
|
+
const lastMetadata = useMemo62(() => {
|
|
34637
34932
|
if (rawResponseData && rawResponseData.length > 0) {
|
|
34638
34933
|
return rawResponseData[rawResponseData.length - 1].meta;
|
|
34639
34934
|
}
|
|
34640
34935
|
return void 0;
|
|
34641
34936
|
}, [rawResponseData]);
|
|
34642
|
-
const hasMore =
|
|
34937
|
+
const hasMore = useMemo62(() => {
|
|
34643
34938
|
var _a, _b, _c, _d;
|
|
34644
34939
|
if (rawResponseData && rawResponseData.length > 0) {
|
|
34645
34940
|
const lastElement = rawResponseData[rawResponseData.length - 1];
|
|
@@ -34684,7 +34979,7 @@ var useBills = () => {
|
|
|
34684
34979
|
};
|
|
34685
34980
|
|
|
34686
34981
|
// src/components/Bills/useBillsRecordPayment.ts
|
|
34687
|
-
import { useEffect as useEffect39, useMemo as
|
|
34982
|
+
import { useEffect as useEffect39, useMemo as useMemo63, useState as useState77 } from "react";
|
|
34688
34983
|
import useSWRMutation25 from "swr/mutation";
|
|
34689
34984
|
function buildKey37({
|
|
34690
34985
|
access_token: accessToken,
|
|
@@ -34796,7 +35091,7 @@ var useBillsRecordPayment = ({ refetchAllBills }) => {
|
|
|
34796
35091
|
setBillsToPay([{ bill, amount: (_b = convertFromCents((_a = bill.outstanding_balance) != null ? _a : 0)) == null ? void 0 : _b.toString() }]);
|
|
34797
35092
|
setShowRecordPaymentForm(true);
|
|
34798
35093
|
};
|
|
34799
|
-
const payload =
|
|
35094
|
+
const payload = useMemo63(() => {
|
|
34800
35095
|
const filteredBillsToPay = billsToPay.filter((item) => {
|
|
34801
35096
|
var _a;
|
|
34802
35097
|
return item.amount && ((_a = item.bill) == null ? void 0 : _a.id);
|
|
@@ -35128,7 +35423,7 @@ var useBillForm = (bill) => {
|
|
|
35128
35423
|
import { formatISO as formatISO4, parseISO as parseISO18 } from "date-fns";
|
|
35129
35424
|
|
|
35130
35425
|
// src/components/Bills/BillsPaymentRecorded.tsx
|
|
35131
|
-
import { useMemo as
|
|
35426
|
+
import { useMemo as useMemo64 } from "react";
|
|
35132
35427
|
|
|
35133
35428
|
// src/components/Input/StaticValue.tsx
|
|
35134
35429
|
import classNames83 from "classnames";
|
|
@@ -35174,11 +35469,11 @@ var BillsPaymentRecorded = ({
|
|
|
35174
35469
|
vendor,
|
|
35175
35470
|
payRemainingBalance
|
|
35176
35471
|
} = useBillsRecordPaymentContext();
|
|
35177
|
-
const totalPaid =
|
|
35472
|
+
const totalPaid = useMemo64(
|
|
35178
35473
|
() => billsToPay.reduce((acc, record) => acc + (record.amount !== void 0 ? Number(record.amount) : 0), 0),
|
|
35179
35474
|
[billsToPay]
|
|
35180
35475
|
);
|
|
35181
|
-
const anyUnpaid =
|
|
35476
|
+
const anyUnpaid = useMemo64(
|
|
35182
35477
|
() => billsToPay.some((record) => {
|
|
35183
35478
|
var _a2;
|
|
35184
35479
|
return ((_a2 = record.bill) == null ? void 0 : _a2.status) !== "PAID";
|
|
@@ -35235,7 +35530,7 @@ var BillsPaymentRecorded = ({
|
|
|
35235
35530
|
};
|
|
35236
35531
|
|
|
35237
35532
|
// src/components/Bills/BillsRecordPayment.tsx
|
|
35238
|
-
import { useMemo as
|
|
35533
|
+
import { useMemo as useMemo65 } from "react";
|
|
35239
35534
|
import { parseISO as parseISO16, format as formatTime13 } from "date-fns";
|
|
35240
35535
|
|
|
35241
35536
|
// src/components/Bills/useUnpaidBillsByVendor.ts
|
|
@@ -35318,7 +35613,7 @@ var BillsRecordPayment = ({
|
|
|
35318
35613
|
apiError
|
|
35319
35614
|
} = useBillsRecordPaymentContext();
|
|
35320
35615
|
const { data: rawAvailableBills } = useUnpaidBillsByVendor({ vendorId: vendor == null ? void 0 : vendor.id });
|
|
35321
|
-
const availableBills =
|
|
35616
|
+
const availableBills = useMemo65(
|
|
35322
35617
|
() => rawAvailableBills == null ? void 0 : rawAvailableBills.filter((b) => !billsToPay.find((x) => {
|
|
35323
35618
|
var _a2;
|
|
35324
35619
|
return ((_a2 = x.bill) == null ? void 0 : _a2.id) === b.id;
|
|
@@ -35644,7 +35939,7 @@ var BillSummaryPaid = ({ bill }) => {
|
|
|
35644
35939
|
};
|
|
35645
35940
|
|
|
35646
35941
|
// src/components/Bills/BillSummaryUnpaid.tsx
|
|
35647
|
-
import { useMemo as
|
|
35942
|
+
import { useMemo as useMemo66 } from "react";
|
|
35648
35943
|
import { differenceInDays as differenceInDays2, parseISO as parseISO17 } from "date-fns";
|
|
35649
35944
|
import { jsx as jsx315, jsxs as jsxs201 } from "react/jsx-runtime";
|
|
35650
35945
|
function buildDifference(due_at) {
|
|
@@ -35672,7 +35967,7 @@ function buildDifference(due_at) {
|
|
|
35672
35967
|
};
|
|
35673
35968
|
}
|
|
35674
35969
|
var BillSummaryUnpaid = ({ bill }) => {
|
|
35675
|
-
const difference =
|
|
35970
|
+
const difference = useMemo66(() => buildDifference(bill.due_at), [bill.due_at]);
|
|
35676
35971
|
return /* @__PURE__ */ jsxs201("div", { className: "Layer__bill-details__summary", children: [
|
|
35677
35972
|
/* @__PURE__ */ jsxs201("div", { children: [
|
|
35678
35973
|
/* @__PURE__ */ jsx315(
|
|
@@ -36065,13 +36360,13 @@ var BillsDetails = ({
|
|
|
36065
36360
|
};
|
|
36066
36361
|
|
|
36067
36362
|
// src/components/Bills/BillsTableWithPanel.tsx
|
|
36068
|
-
import { useMemo as
|
|
36363
|
+
import { useMemo as useMemo68 } from "react";
|
|
36069
36364
|
|
|
36070
36365
|
// src/components/Bills/BillsTable.tsx
|
|
36071
36366
|
import { Fragment as Fragment53 } from "react";
|
|
36072
36367
|
|
|
36073
36368
|
// src/components/DueStatus/DueStatus.tsx
|
|
36074
|
-
import { useMemo as
|
|
36369
|
+
import { useMemo as useMemo67 } from "react";
|
|
36075
36370
|
import { parseISO as parseISO19, differenceInDays as differenceInDays3 } from "date-fns";
|
|
36076
36371
|
import { jsx as jsx318, jsxs as jsxs203 } from "react/jsx-runtime";
|
|
36077
36372
|
var dueStatusTitle = (daysDiff, paid) => {
|
|
@@ -36136,7 +36431,7 @@ var getDiff = (refDate) => {
|
|
|
36136
36431
|
return differenceInDays3(today, d);
|
|
36137
36432
|
};
|
|
36138
36433
|
var DueStatus = ({ dueDate, paidAt, size = "md" }) => {
|
|
36139
|
-
const date =
|
|
36434
|
+
const date = useMemo67(() => {
|
|
36140
36435
|
try {
|
|
36141
36436
|
const diff = getDiff(paidAt ? paidAt : dueDate);
|
|
36142
36437
|
if (diff === null) {
|
|
@@ -36464,11 +36759,11 @@ var BillsTableWithPanel = ({
|
|
|
36464
36759
|
setVendor: setRecordPaymentVendor
|
|
36465
36760
|
} = useBillsRecordPaymentContext();
|
|
36466
36761
|
const { isDesktop, isMobile } = useSizeClass();
|
|
36467
|
-
const totalCount =
|
|
36762
|
+
const totalCount = useMemo68(() => {
|
|
36468
36763
|
var _a;
|
|
36469
36764
|
return (_a = rawData == null ? void 0 : rawData.length) != null ? _a : 0;
|
|
36470
36765
|
}, [rawData]);
|
|
36471
|
-
const anyBillToPaySelected =
|
|
36766
|
+
const anyBillToPaySelected = useMemo68(() => {
|
|
36472
36767
|
return billsToPay.length > 0;
|
|
36473
36768
|
}, [billsToPay]);
|
|
36474
36769
|
return /* @__PURE__ */ jsxs206(
|