@layerfi/components 0.1.104 → 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 +427 -240
- package/dist/esm/index.mjs +310 -123
- 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
|
|
|
@@ -28234,25 +28237,187 @@ import { useSWRConfig as useSWRConfig6 } from "swr";
|
|
|
28234
28237
|
import { useCallback as useCallback32 } from "react";
|
|
28235
28238
|
|
|
28236
28239
|
// src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
|
|
28237
|
-
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";
|
|
28238
28241
|
import useSWR17 from "swr";
|
|
28239
|
-
|
|
28240
|
-
|
|
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();
|
|
28241
28320
|
const { apiUrl } = useEnvironment();
|
|
28242
28321
|
const { data: auth } = useAuth();
|
|
28243
|
-
|
|
28244
|
-
|
|
28245
|
-
|
|
28246
|
-
|
|
28247
|
-
|
|
28248
|
-
Layer.getLedgerAccountsLines(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
28249
|
-
params: {
|
|
28322
|
+
return useSWRInfinite4(
|
|
28323
|
+
(index, previousPageData) => keyLoader4(
|
|
28324
|
+
previousPageData,
|
|
28325
|
+
__spreadProps(__spreadValues({}, auth), {
|
|
28326
|
+
apiUrl,
|
|
28250
28327
|
businessId,
|
|
28251
28328
|
accountId,
|
|
28252
|
-
|
|
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
|
+
}
|
|
28253
28370
|
}
|
|
28254
|
-
|
|
28371
|
+
)(),
|
|
28372
|
+
{
|
|
28373
|
+
keepPreviousData: true,
|
|
28374
|
+
revalidateAll: false,
|
|
28375
|
+
revalidateFirstPage: false,
|
|
28376
|
+
initialSize: 1
|
|
28377
|
+
}
|
|
28255
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]);
|
|
28256
28421
|
const {
|
|
28257
28422
|
data: entryData,
|
|
28258
28423
|
mutate: mutateEntryData,
|
|
@@ -28270,31 +28435,36 @@ var useLedgerAccounts = (showReversalEntries = false) => {
|
|
|
28270
28435
|
setSelectedEntryId(void 0);
|
|
28271
28436
|
void mutateEntryData();
|
|
28272
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]);
|
|
28273
28441
|
useEffect33(() => {
|
|
28274
|
-
if (queryKey && (
|
|
28442
|
+
if (queryKey && shouldFetch && (paginationIsLoading || paginationIsValidating)) {
|
|
28275
28443
|
read("LEDGER_ACCOUNTS" /* LEDGER_ACCOUNTS */, queryKey);
|
|
28276
28444
|
}
|
|
28277
|
-
}, [
|
|
28445
|
+
}, [paginationIsLoading, paginationIsValidating, shouldFetch]);
|
|
28278
28446
|
useEffect33(() => {
|
|
28279
|
-
if (queryKey && hasBeenTouched(queryKey)) {
|
|
28447
|
+
if (queryKey && shouldFetch && hasBeenTouched(queryKey)) {
|
|
28280
28448
|
void refetch();
|
|
28281
28449
|
}
|
|
28282
|
-
}, [syncTimestamps, accountId]);
|
|
28450
|
+
}, [syncTimestamps, accountId, shouldFetch]);
|
|
28283
28451
|
return {
|
|
28284
|
-
data
|
|
28452
|
+
data,
|
|
28285
28453
|
entryData: entryData == null ? void 0 : entryData.data,
|
|
28286
|
-
isLoading,
|
|
28454
|
+
isLoading: shouldFetch ? paginationIsLoading : false,
|
|
28287
28455
|
isLoadingEntry,
|
|
28288
|
-
isValidating,
|
|
28289
|
-
isValdiatingEntry,
|
|
28290
|
-
error,
|
|
28456
|
+
isValidating: shouldFetch ? paginationIsValidating : false,
|
|
28457
|
+
isValidatingEntry: isValdiatingEntry,
|
|
28458
|
+
error: shouldFetch ? paginationError : void 0,
|
|
28291
28459
|
errorEntry,
|
|
28292
28460
|
refetch,
|
|
28293
28461
|
accountId,
|
|
28294
28462
|
setAccountId,
|
|
28295
28463
|
selectedEntryId,
|
|
28296
28464
|
setSelectedEntryId,
|
|
28297
|
-
closeSelectedEntry
|
|
28465
|
+
closeSelectedEntry,
|
|
28466
|
+
hasMore,
|
|
28467
|
+
fetchMore
|
|
28298
28468
|
};
|
|
28299
28469
|
};
|
|
28300
28470
|
|
|
@@ -28363,13 +28533,13 @@ var ChartOfAccountsDatePicker = () => {
|
|
|
28363
28533
|
};
|
|
28364
28534
|
|
|
28365
28535
|
// src/components/ChartOfAccountsForm/ChartOfAccountsForm.tsx
|
|
28366
|
-
import { useContext as useContext42, useMemo as
|
|
28536
|
+
import { useContext as useContext42, useMemo as useMemo47 } from "react";
|
|
28367
28537
|
|
|
28368
28538
|
// src/components/ChartOfAccountsForm/useParentOptions.ts
|
|
28369
|
-
import { useMemo as
|
|
28539
|
+
import { useMemo as useMemo46 } from "react";
|
|
28370
28540
|
var useParentOptions = (data) => {
|
|
28371
28541
|
var _a;
|
|
28372
|
-
return
|
|
28542
|
+
return useMemo46(
|
|
28373
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) => {
|
|
28374
28544
|
return {
|
|
28375
28545
|
label: x.name,
|
|
@@ -28396,7 +28566,7 @@ var ChartOfAccountsForm = ({
|
|
|
28396
28566
|
apiError
|
|
28397
28567
|
} = useContext42(ChartOfAccountsContext);
|
|
28398
28568
|
const parentOptions = useParentOptions(data);
|
|
28399
|
-
const entry =
|
|
28569
|
+
const entry = useMemo47(() => {
|
|
28400
28570
|
if ((form == null ? void 0 : form.action) === "edit" && form.accountId) {
|
|
28401
28571
|
return flattenAccounts((data == null ? void 0 : data.accounts) || []).find(
|
|
28402
28572
|
(x) => x.id === form.accountId
|
|
@@ -28609,7 +28779,7 @@ var ChartOfAccountsSidebar = ({
|
|
|
28609
28779
|
};
|
|
28610
28780
|
|
|
28611
28781
|
// src/components/ChartOfAccountsTable/ChartOfAccountsTable.tsx
|
|
28612
|
-
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";
|
|
28613
28783
|
|
|
28614
28784
|
// src/icons/Edit2.tsx
|
|
28615
28785
|
import { jsx as jsx245 } from "react/jsx-runtime";
|
|
@@ -28832,8 +29002,8 @@ var ChartOfAccountsTableContent = ({
|
|
|
28832
29002
|
const { setAccountId } = useContext43(LedgerAccountsContext);
|
|
28833
29003
|
const { editAccount } = useContext43(ChartOfAccountsContext);
|
|
28834
29004
|
const [toggledKeys, setToggledKeys] = useState60({});
|
|
28835
|
-
const sortedAccounts =
|
|
28836
|
-
const allRowKeys =
|
|
29005
|
+
const sortedAccounts = useMemo48(() => sortAccountsRecursive(data.accounts), [data.accounts]);
|
|
29006
|
+
const allRowKeys = useMemo48(() => {
|
|
28837
29007
|
const keys = [];
|
|
28838
29008
|
const collect = (accounts) => {
|
|
28839
29009
|
for (const account of accounts) {
|
|
@@ -28858,7 +29028,7 @@ var ChartOfAccountsTableContent = ({
|
|
|
28858
29028
|
useEffect34(() => {
|
|
28859
29029
|
setToggledKeys({});
|
|
28860
29030
|
}, [searchQuery]);
|
|
28861
|
-
const filteredAccounts =
|
|
29031
|
+
const filteredAccounts = useMemo48(() => {
|
|
28862
29032
|
if (!searchQuery) return sortedAccounts;
|
|
28863
29033
|
return filterAccounts(sortedAccounts, searchQuery.toLowerCase());
|
|
28864
29034
|
}, [searchQuery, sortedAccounts]);
|
|
@@ -29195,12 +29365,12 @@ var ChartOfAccountsTableWithPanel = ({
|
|
|
29195
29365
|
// src/components/LedgerAccount/LedgerAccountIndex.tsx
|
|
29196
29366
|
import {
|
|
29197
29367
|
useContext as useContext47,
|
|
29198
|
-
useMemo as
|
|
29368
|
+
useMemo as useMemo50,
|
|
29199
29369
|
useState as useState62
|
|
29200
29370
|
} from "react";
|
|
29201
29371
|
|
|
29202
29372
|
// src/components/LedgerAccountEntryDetails/LedgerAccountEntryDetails.tsx
|
|
29203
|
-
import { useContext as useContext45, useMemo as
|
|
29373
|
+
import { useContext as useContext45, useMemo as useMemo49 } from "react";
|
|
29204
29374
|
|
|
29205
29375
|
// src/utils/journal.ts
|
|
29206
29376
|
var getAccountIdentifierPayload = (journalLineItem) => {
|
|
@@ -29445,7 +29615,7 @@ var LedgerAccountEntryDetails = ({
|
|
|
29445
29615
|
}) => {
|
|
29446
29616
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
29447
29617
|
const { entryData, isLoadingEntry, closeSelectedEntry, errorEntry } = useContext45(LedgerAccountsContext);
|
|
29448
|
-
const { totalDebit, totalCredit } =
|
|
29618
|
+
const { totalDebit, totalCredit } = useMemo49(() => {
|
|
29449
29619
|
var _a2;
|
|
29450
29620
|
let totalDebit2 = 0;
|
|
29451
29621
|
let totalCredit2 = 0;
|
|
@@ -29600,7 +29770,7 @@ var LedgerAccountRow = ({
|
|
|
29600
29770
|
index,
|
|
29601
29771
|
view
|
|
29602
29772
|
}) => {
|
|
29603
|
-
var _a, _b, _c, _d, _e, _f;
|
|
29773
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
29604
29774
|
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = useContext46(LedgerAccountsContext);
|
|
29605
29775
|
if (view === "tablet") {
|
|
29606
29776
|
return /* @__PURE__ */ jsxs158(
|
|
@@ -29631,7 +29801,8 @@ var LedgerAccountRow = ({
|
|
|
29631
29801
|
}
|
|
29632
29802
|
)
|
|
29633
29803
|
] }),
|
|
29634
|
-
/* @__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 : "" })
|
|
29635
29806
|
] }) }),
|
|
29636
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)}` }) }),
|
|
29637
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)}` }) }),
|
|
@@ -29668,7 +29839,8 @@ var LedgerAccountRow = ({
|
|
|
29668
29839
|
}
|
|
29669
29840
|
)
|
|
29670
29841
|
] }),
|
|
29671
|
-
/* @__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 : "" }),
|
|
29672
29844
|
/* @__PURE__ */ jsxs158("div", { className: "Layer__ledger_account-table__balances-mobile", children: [
|
|
29673
29845
|
/* @__PURE__ */ jsxs158("div", { className: "Layer__ledger_account-table__balance-item", children: [
|
|
29674
29846
|
/* @__PURE__ */ jsx253("span", { className: "Layer__ledger_account-table__balances-mobile__label", children: "Debit" }),
|
|
@@ -29708,7 +29880,8 @@ var LedgerAccountRow = ({
|
|
|
29708
29880
|
children: [
|
|
29709
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) }) }),
|
|
29710
29882
|
/* @__PURE__ */ jsx253("td", { className: "Layer__table-cell", children: /* @__PURE__ */ jsx253("span", { className: "Layer__table-cell-content", children: lineEntryNumber(row) }) }),
|
|
29711
|
-
/* @__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 : "" }) }),
|
|
29712
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)}` }) }),
|
|
29713
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)}` }) }),
|
|
29714
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)}` }) })
|
|
@@ -29738,23 +29911,36 @@ var LedgerAccount = ({
|
|
|
29738
29911
|
setAccountId,
|
|
29739
29912
|
selectedEntryId,
|
|
29740
29913
|
closeSelectedEntry,
|
|
29741
|
-
refetch
|
|
29914
|
+
refetch,
|
|
29915
|
+
hasMore,
|
|
29916
|
+
fetchMore
|
|
29742
29917
|
} = useContext47(LedgerAccountsContext);
|
|
29743
29918
|
const baseClassName = classNames75(
|
|
29744
29919
|
"Layer__ledger-account__index",
|
|
29745
29920
|
accountId && "open"
|
|
29746
29921
|
);
|
|
29747
|
-
const account =
|
|
29922
|
+
const account = useMemo50(() => {
|
|
29748
29923
|
return flattenAccounts((accountData == null ? void 0 : accountData.accounts) || []).find(
|
|
29749
29924
|
(x) => x.id === accountId
|
|
29750
29925
|
);
|
|
29751
29926
|
}, [accountId]);
|
|
29752
|
-
const data =
|
|
29927
|
+
const data = useMemo50(() => {
|
|
29753
29928
|
var _a2;
|
|
29929
|
+
if (!rawData) return void 0;
|
|
29754
29930
|
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
29755
29931
|
const lastPageIndex = firstPageIndex + pageSize;
|
|
29756
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);
|
|
29757
|
-
}, [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
|
+
};
|
|
29758
29944
|
const close2 = () => {
|
|
29759
29945
|
setAccountId(void 0);
|
|
29760
29946
|
closeSelectedEntry();
|
|
@@ -29812,17 +29998,16 @@ var LedgerAccount = ({
|
|
|
29812
29998
|
view === "desktop" && /* @__PURE__ */ jsxs159(Fragment37, { children: [
|
|
29813
29999
|
/* @__PURE__ */ jsx254("th", { className: "Layer__table-header", children: ((_b = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _b.dateColumnHeader) || "Date" }),
|
|
29814
30000
|
/* @__PURE__ */ jsx254("th", { className: "Layer__table-header", children: ((_c = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _c.journalIdColumnHeader) || "Journal id #" }),
|
|
29815
|
-
/* @__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" })
|
|
29816
30003
|
] }),
|
|
29817
30004
|
view !== "mobile" && /* @__PURE__ */ jsxs159(Fragment37, { children: [
|
|
29818
|
-
/* @__PURE__ */ jsx254("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((
|
|
29819
|
-
/* @__PURE__ */ jsx254("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((
|
|
29820
|
-
/* @__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" })
|
|
29821
30008
|
] })
|
|
29822
30009
|
] }) }),
|
|
29823
|
-
/* @__PURE__ */ jsx254("tbody", { children:
|
|
29824
|
-
(entry) => !entry.entry_reversal_of && !entry.entry_reversed_by
|
|
29825
|
-
)) == null ? void 0 : _h.map((x, index) => /* @__PURE__ */ jsx254(
|
|
30010
|
+
/* @__PURE__ */ jsx254("tbody", { children: data == null ? void 0 : data.map((x, index) => /* @__PURE__ */ jsx254(
|
|
29826
30011
|
LedgerAccountRow,
|
|
29827
30012
|
{
|
|
29828
30013
|
row: x,
|
|
@@ -29838,7 +30023,9 @@ var LedgerAccount = ({
|
|
|
29838
30023
|
currentPage,
|
|
29839
30024
|
totalCount: (rawData == null ? void 0 : rawData.length) || 0,
|
|
29840
30025
|
pageSize,
|
|
29841
|
-
onPageChange:
|
|
30026
|
+
onPageChange: handlePageChange,
|
|
30027
|
+
hasMore,
|
|
30028
|
+
fetchMore
|
|
29842
30029
|
}
|
|
29843
30030
|
),
|
|
29844
30031
|
error ? /* @__PURE__ */ jsx254("div", { className: "Layer__table-state-container", children: /* @__PURE__ */ jsx254(
|
|
@@ -29943,12 +30130,12 @@ var JournalContext = createContext22({
|
|
|
29943
30130
|
});
|
|
29944
30131
|
|
|
29945
30132
|
// src/hooks/useJournal/useJournal.tsx
|
|
29946
|
-
import { useState as useState63, useMemo as
|
|
30133
|
+
import { useState as useState63, useMemo as useMemo52, useCallback as useCallback36 } from "react";
|
|
29947
30134
|
|
|
29948
30135
|
// src/features/ledger/entries/api/useListLedgerEntries.ts
|
|
29949
|
-
import
|
|
29950
|
-
var
|
|
29951
|
-
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";
|
|
29952
30139
|
var LIST_LEDGER_ENTRIES_TAG_KEY = "#list-ledger-entries";
|
|
29953
30140
|
var listLedgerEntries = get(({ businessId, sort_by, sort_order, cursor, limit, show_total_count }) => {
|
|
29954
30141
|
const parameters = toDefinedSearchParameters({
|
|
@@ -29960,7 +30147,7 @@ var listLedgerEntries = get(({ businessId, sort_by, sort_order, cursor, limit, s
|
|
|
29960
30147
|
});
|
|
29961
30148
|
return `/v1/businesses/${businessId}/ledger/entries?${parameters}`;
|
|
29962
30149
|
});
|
|
29963
|
-
function
|
|
30150
|
+
function keyLoader5(previousPageData, {
|
|
29964
30151
|
access_token: accessToken,
|
|
29965
30152
|
apiUrl,
|
|
29966
30153
|
businessId,
|
|
@@ -29993,8 +30180,8 @@ function useListLedgerEntries({
|
|
|
29993
30180
|
const { businessId } = useLayerContext();
|
|
29994
30181
|
const { apiUrl } = useEnvironment();
|
|
29995
30182
|
const { data: auth } = useAuth();
|
|
29996
|
-
return
|
|
29997
|
-
(index, previousPageData) =>
|
|
30183
|
+
return useSWRInfinite5(
|
|
30184
|
+
(index, previousPageData) => keyLoader5(
|
|
29998
30185
|
previousPageData,
|
|
29999
30186
|
__spreadProps(__spreadValues({}, auth), {
|
|
30000
30187
|
apiUrl,
|
|
@@ -30063,11 +30250,11 @@ var useJournal = () => {
|
|
|
30063
30250
|
sort_order: "DESC",
|
|
30064
30251
|
limit: 150
|
|
30065
30252
|
});
|
|
30066
|
-
const data =
|
|
30253
|
+
const data = useMemo52(() => {
|
|
30067
30254
|
if (!paginatedData) return void 0;
|
|
30068
30255
|
return paginatedData.flatMap((page) => page.data);
|
|
30069
30256
|
}, [paginatedData]);
|
|
30070
|
-
const hasMore =
|
|
30257
|
+
const hasMore = useMemo52(() => {
|
|
30071
30258
|
var _a, _b;
|
|
30072
30259
|
if (paginatedData && paginatedData.length > 0) {
|
|
30073
30260
|
const lastPage = paginatedData[paginatedData.length - 1];
|
|
@@ -30077,7 +30264,7 @@ var useJournal = () => {
|
|
|
30077
30264
|
}
|
|
30078
30265
|
return false;
|
|
30079
30266
|
}, [paginatedData]);
|
|
30080
|
-
const fetchMore =
|
|
30267
|
+
const fetchMore = useCallback36(() => {
|
|
30081
30268
|
if (hasMore) {
|
|
30082
30269
|
setSize(size + 1);
|
|
30083
30270
|
}
|
|
@@ -30322,13 +30509,13 @@ var useJournal = () => {
|
|
|
30322
30509
|
};
|
|
30323
30510
|
|
|
30324
30511
|
// src/components/JournalTable/JournalTableWithPanel.tsx
|
|
30325
|
-
import { useContext as useContext54, useMemo as
|
|
30512
|
+
import { useContext as useContext54, useMemo as useMemo55, useState as useState65 } from "react";
|
|
30326
30513
|
|
|
30327
30514
|
// src/components/JournalSidebar/JournalSidebar.tsx
|
|
30328
30515
|
import { useContext as useContext52 } from "react";
|
|
30329
30516
|
|
|
30330
30517
|
// src/components/JournalEntryDetails/JournalEntryDetails.tsx
|
|
30331
|
-
import { useContext as useContext49, useMemo as
|
|
30518
|
+
import { useContext as useContext49, useMemo as useMemo53, useState as useState64 } from "react";
|
|
30332
30519
|
import { jsx as jsx256, jsxs as jsxs160 } from "react/jsx-runtime";
|
|
30333
30520
|
var JournalEntryDetails = () => {
|
|
30334
30521
|
var _a, _b, _c, _d;
|
|
@@ -30343,13 +30530,13 @@ var JournalEntryDetails = () => {
|
|
|
30343
30530
|
} = useContext49(JournalContext);
|
|
30344
30531
|
const [reverseEntryProcessing, setReverseEntryProcessing] = useState64(false);
|
|
30345
30532
|
const [reverseEntryError, setReverseEntryError] = useState64();
|
|
30346
|
-
const entry =
|
|
30533
|
+
const entry = useMemo53(() => {
|
|
30347
30534
|
if (selectedEntryId && data) {
|
|
30348
30535
|
return data.find((x) => x.id === selectedEntryId);
|
|
30349
30536
|
}
|
|
30350
30537
|
return;
|
|
30351
30538
|
}, [data, selectedEntryId]);
|
|
30352
|
-
const sortedLineItems =
|
|
30539
|
+
const sortedLineItems = useMemo53(
|
|
30353
30540
|
() => {
|
|
30354
30541
|
var _a2;
|
|
30355
30542
|
return (_a2 = entry == null ? void 0 : entry.line_items) == null ? void 0 : _a2.sort(
|
|
@@ -30530,7 +30717,7 @@ var JournalEntryDetails = () => {
|
|
|
30530
30717
|
import { useContext as useContext51 } from "react";
|
|
30531
30718
|
|
|
30532
30719
|
// src/components/JournalForm/JournalFormEntryLines.tsx
|
|
30533
|
-
import { useContext as useContext50, useMemo as
|
|
30720
|
+
import { useContext as useContext50, useMemo as useMemo54 } from "react";
|
|
30534
30721
|
import { Fragment as Fragment38, jsx as jsx257, jsxs as jsxs161 } from "react/jsx-runtime";
|
|
30535
30722
|
function recursiveFlattenCategories(accounts) {
|
|
30536
30723
|
const flattenedResult = accounts.flatMap((a) => {
|
|
@@ -30552,7 +30739,7 @@ var JournalFormEntryLines = ({
|
|
|
30552
30739
|
}) => {
|
|
30553
30740
|
const { data: categories } = useCategories({ mode: "ALL" });
|
|
30554
30741
|
const { form } = useContext50(JournalContext);
|
|
30555
|
-
const { flattenedCategories, parentOptions } =
|
|
30742
|
+
const { flattenedCategories, parentOptions } = useMemo54(() => {
|
|
30556
30743
|
const flattenedCategories2 = recursiveFlattenCategories(categories != null ? categories : []);
|
|
30557
30744
|
const parentOptions2 = [...flattenedCategories2].sort((a, b) => a.display_name.localeCompare(b.display_name)).map((account) => {
|
|
30558
30745
|
switch (account.type) {
|
|
@@ -31145,7 +31332,7 @@ var JournalTableWithPanel = ({
|
|
|
31145
31332
|
hasMore,
|
|
31146
31333
|
fetchMore
|
|
31147
31334
|
} = useContext54(JournalContext);
|
|
31148
|
-
const data =
|
|
31335
|
+
const data = useMemo55(
|
|
31149
31336
|
() => {
|
|
31150
31337
|
if (!rawData) return void 0;
|
|
31151
31338
|
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
@@ -31291,7 +31478,7 @@ var TasksHeader = ({
|
|
|
31291
31478
|
};
|
|
31292
31479
|
|
|
31293
31480
|
// src/components/Tasks/TasksList.tsx
|
|
31294
|
-
import { useMemo as
|
|
31481
|
+
import { useMemo as useMemo58 } from "react";
|
|
31295
31482
|
|
|
31296
31483
|
// src/icons/SmileIcon.tsx
|
|
31297
31484
|
import { jsx as jsx265, jsxs as jsxs166 } from "react/jsx-runtime";
|
|
@@ -31350,7 +31537,7 @@ var SmileIcon = (_a) => {
|
|
|
31350
31537
|
var SmileIcon_default = SmileIcon;
|
|
31351
31538
|
|
|
31352
31539
|
// src/components/Tasks/TasksListItem.tsx
|
|
31353
|
-
import { useEffect as useEffect36, useMemo as
|
|
31540
|
+
import { useEffect as useEffect36, useMemo as useMemo56, useState as useState66 } from "react";
|
|
31354
31541
|
import classNames76 from "classnames";
|
|
31355
31542
|
|
|
31356
31543
|
// src/utils/bookkeeping/tasks/getBookkeepingTaskStatusIcon.tsx
|
|
@@ -31408,7 +31595,7 @@ function completeTaskWithUpload(baseUrl, accessToken, {
|
|
|
31408
31595
|
}
|
|
31409
31596
|
|
|
31410
31597
|
// src/hooks/bookkeeping/periods/tasks/useSubmitResponseForTask.ts
|
|
31411
|
-
import { useCallback as
|
|
31598
|
+
import { useCallback as useCallback37 } from "react";
|
|
31412
31599
|
function buildKey29({
|
|
31413
31600
|
access_token: accessToken,
|
|
31414
31601
|
apiUrl,
|
|
@@ -31451,7 +31638,7 @@ function useSubmitUserResponseForTask() {
|
|
|
31451
31638
|
}
|
|
31452
31639
|
);
|
|
31453
31640
|
const { trigger: originalTrigger } = mutationResponse;
|
|
31454
|
-
const stableProxiedTrigger =
|
|
31641
|
+
const stableProxiedTrigger = useCallback37(
|
|
31455
31642
|
(...triggerParameters) => __async(null, null, function* () {
|
|
31456
31643
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
31457
31644
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -31478,7 +31665,7 @@ function useSubmitUserResponseForTask() {
|
|
|
31478
31665
|
// src/hooks/bookkeeping/periods/tasks/useUploadDocumentsForTask.ts
|
|
31479
31666
|
import { useSWRConfig as useSWRConfig8 } from "swr";
|
|
31480
31667
|
import useSWRMutation19 from "swr/mutation";
|
|
31481
|
-
import { useCallback as
|
|
31668
|
+
import { useCallback as useCallback38 } from "react";
|
|
31482
31669
|
function buildKey30({
|
|
31483
31670
|
access_token: accessToken,
|
|
31484
31671
|
apiUrl,
|
|
@@ -31517,7 +31704,7 @@ function useUploadDocumentsForTask() {
|
|
|
31517
31704
|
}
|
|
31518
31705
|
);
|
|
31519
31706
|
const { trigger: originalTrigger } = mutationResponse;
|
|
31520
|
-
const stableProxiedTrigger =
|
|
31707
|
+
const stableProxiedTrigger = useCallback38(
|
|
31521
31708
|
(...triggerParameters) => __async(null, null, function* () {
|
|
31522
31709
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
31523
31710
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -31544,7 +31731,7 @@ function useUploadDocumentsForTask() {
|
|
|
31544
31731
|
// src/hooks/bookkeeping/periods/tasks/useDeleteUploadsOnTask.ts
|
|
31545
31732
|
import { useSWRConfig as useSWRConfig9 } from "swr";
|
|
31546
31733
|
import useSWRMutation20 from "swr/mutation";
|
|
31547
|
-
import { useCallback as
|
|
31734
|
+
import { useCallback as useCallback39 } from "react";
|
|
31548
31735
|
function buildKey31({
|
|
31549
31736
|
access_token: accessToken,
|
|
31550
31737
|
apiUrl,
|
|
@@ -31580,7 +31767,7 @@ function useDeleteUploadsOnTask() {
|
|
|
31580
31767
|
}
|
|
31581
31768
|
);
|
|
31582
31769
|
const { trigger: originalTrigger } = mutationResponse;
|
|
31583
|
-
const stableProxiedTrigger =
|
|
31770
|
+
const stableProxiedTrigger = useCallback39(
|
|
31584
31771
|
(...triggerParameters) => __async(null, null, function* () {
|
|
31585
31772
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
31586
31773
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -31607,7 +31794,7 @@ function useDeleteUploadsOnTask() {
|
|
|
31607
31794
|
// src/hooks/bookkeeping/periods/tasks/useUpdateTaskUploadDescription.ts
|
|
31608
31795
|
import { useSWRConfig as useSWRConfig10 } from "swr";
|
|
31609
31796
|
import useSWRMutation21 from "swr/mutation";
|
|
31610
|
-
import { useCallback as
|
|
31797
|
+
import { useCallback as useCallback40 } from "react";
|
|
31611
31798
|
function buildKey32({
|
|
31612
31799
|
access_token: accessToken,
|
|
31613
31800
|
apiUrl,
|
|
@@ -31647,7 +31834,7 @@ function useUpdateTaskUploadDescription() {
|
|
|
31647
31834
|
}
|
|
31648
31835
|
);
|
|
31649
31836
|
const { trigger: originalTrigger } = mutationResponse;
|
|
31650
|
-
const stableProxiedTrigger =
|
|
31837
|
+
const stableProxiedTrigger = useCallback40(
|
|
31651
31838
|
(...triggerParameters) => __async(null, null, function* () {
|
|
31652
31839
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
31653
31840
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -31713,7 +31900,7 @@ var TasksListItem = ({
|
|
|
31713
31900
|
setIsOpen(false);
|
|
31714
31901
|
setSelectedFiles(void 0);
|
|
31715
31902
|
});
|
|
31716
|
-
const uploadDocumentAction =
|
|
31903
|
+
const uploadDocumentAction = useMemo56(() => {
|
|
31717
31904
|
if (task.user_response_type === "UPLOAD_DOCUMENT") {
|
|
31718
31905
|
if (task.status === "TODO") {
|
|
31719
31906
|
if (!selectedFiles) {
|
|
@@ -31917,27 +32104,27 @@ var TasksListMobile = ({
|
|
|
31917
32104
|
};
|
|
31918
32105
|
|
|
31919
32106
|
// src/hooks/array/usePaginatedList.ts
|
|
31920
|
-
import { useCallback as
|
|
32107
|
+
import { useCallback as useCallback41, useMemo as useMemo57, useState as useState68 } from "react";
|
|
31921
32108
|
function usePaginatedList(list, pageSize) {
|
|
31922
32109
|
const [internalPageIndex, setInternalPageIndex] = useState68(0);
|
|
31923
32110
|
const pageCount = Math.max(0, Math.ceil(list.length / pageSize));
|
|
31924
32111
|
const effectivePageIndex = Math.max(0, Math.min(internalPageIndex, pageCount - 1));
|
|
31925
|
-
const pageItems =
|
|
32112
|
+
const pageItems = useMemo57(() => {
|
|
31926
32113
|
return list.slice(
|
|
31927
32114
|
effectivePageIndex * pageSize,
|
|
31928
32115
|
(effectivePageIndex + 1) * pageSize
|
|
31929
32116
|
);
|
|
31930
32117
|
}, [list, effectivePageIndex, pageSize]);
|
|
31931
|
-
const next =
|
|
32118
|
+
const next = useCallback41(() => {
|
|
31932
32119
|
setInternalPageIndex(Math.min(effectivePageIndex + 1, pageCount - 1));
|
|
31933
32120
|
}, [effectivePageIndex, pageCount]);
|
|
31934
|
-
const set2 =
|
|
32121
|
+
const set2 = useCallback41((pageIndex) => {
|
|
31935
32122
|
setInternalPageIndex(Math.max(0, Math.min(pageIndex, pageCount - 1)));
|
|
31936
32123
|
}, [pageCount]);
|
|
31937
|
-
const previous =
|
|
32124
|
+
const previous = useCallback41(() => {
|
|
31938
32125
|
setInternalPageIndex(Math.max(effectivePageIndex - 1, 0));
|
|
31939
32126
|
}, [effectivePageIndex]);
|
|
31940
|
-
const reset =
|
|
32127
|
+
const reset = useCallback41(() => {
|
|
31941
32128
|
setInternalPageIndex(0);
|
|
31942
32129
|
}, []);
|
|
31943
32130
|
return {
|
|
@@ -31965,7 +32152,7 @@ var TasksEmptyState = () => /* @__PURE__ */ jsxs170("div", { className: "Layer__
|
|
|
31965
32152
|
] });
|
|
31966
32153
|
function TasksList({ pageSize = 8, mobile }) {
|
|
31967
32154
|
const { activePeriod } = useActiveBookkeepingPeriod();
|
|
31968
|
-
const sortedTasks =
|
|
32155
|
+
const sortedTasks = useMemo58(() => {
|
|
31969
32156
|
var _a;
|
|
31970
32157
|
const tasksInPeriod = (_a = activePeriod == null ? void 0 : activePeriod.tasks) != null ? _a : [];
|
|
31971
32158
|
return tasksInPeriod.sort((taskA, taskB) => {
|
|
@@ -32107,7 +32294,7 @@ var TasksPending = () => {
|
|
|
32107
32294
|
};
|
|
32108
32295
|
|
|
32109
32296
|
// src/components/Tasks/TasksMonthSelector.tsx
|
|
32110
|
-
import { useMemo as
|
|
32297
|
+
import { useMemo as useMemo59 } from "react";
|
|
32111
32298
|
import { format as format7, getMonth as getMonth3, getYear as getYear4, set } from "date-fns";
|
|
32112
32299
|
|
|
32113
32300
|
// src/components/Tasks/TaskStatusBadge.tsx
|
|
@@ -32209,7 +32396,7 @@ function useActiveYearBookkeepingPeriods() {
|
|
|
32209
32396
|
const { date } = useGlobalDate();
|
|
32210
32397
|
const { data } = useBookkeepingPeriods();
|
|
32211
32398
|
const activeYear = getYear4(date);
|
|
32212
|
-
const periodsInActiveYear =
|
|
32399
|
+
const periodsInActiveYear = useMemo59(() => {
|
|
32213
32400
|
return data == null ? void 0 : data.filter((period) => period.year === activeYear);
|
|
32214
32401
|
}, [data, activeYear]);
|
|
32215
32402
|
return { periodsInActiveYear };
|
|
@@ -32220,7 +32407,7 @@ function TasksMonthSelector() {
|
|
|
32220
32407
|
const { periodsInActiveYear } = useActiveYearBookkeepingPeriods();
|
|
32221
32408
|
const activeMonthNumber = getMonth3(date) + 1;
|
|
32222
32409
|
const activeYear = getYear4(date);
|
|
32223
|
-
const monthsData =
|
|
32410
|
+
const monthsData = useMemo59(() => {
|
|
32224
32411
|
return Array.from({ length: 12 }, (_, index) => {
|
|
32225
32412
|
var _a, _b;
|
|
32226
32413
|
const date2 = set(
|
|
@@ -32270,13 +32457,13 @@ import classNames80 from "classnames";
|
|
|
32270
32457
|
import pluralize4 from "pluralize";
|
|
32271
32458
|
|
|
32272
32459
|
// src/hooks/bookkeeping/periods/useBookkeepingYearsStatus.ts
|
|
32273
|
-
import { useMemo as
|
|
32460
|
+
import { useMemo as useMemo60 } from "react";
|
|
32274
32461
|
import { getYear as getYear5 } from "date-fns";
|
|
32275
32462
|
var useBookkeepingYearsStatus = () => {
|
|
32276
32463
|
const { business } = useLayerContext();
|
|
32277
32464
|
const activationDate = getActivationDate(business);
|
|
32278
32465
|
const { data, isLoading } = useBookkeepingPeriods();
|
|
32279
|
-
const yearStatuses =
|
|
32466
|
+
const yearStatuses = useMemo60(() => {
|
|
32280
32467
|
const startYear = getYear5(activationDate != null ? activationDate : /* @__PURE__ */ new Date());
|
|
32281
32468
|
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
32282
32469
|
const count = currentYear - startYear + 1;
|
|
@@ -32291,7 +32478,7 @@ var useBookkeepingYearsStatus = () => {
|
|
|
32291
32478
|
};
|
|
32292
32479
|
}).filter(({ year }) => data == null ? void 0 : data.some((period) => period.year === year)).sort((a, b) => b.year - a.year);
|
|
32293
32480
|
}, [activationDate, data]);
|
|
32294
|
-
const earliestIncompletePeriod =
|
|
32481
|
+
const earliestIncompletePeriod = useMemo60(
|
|
32295
32482
|
() => [...data != null ? data : []].sort((a, b) => {
|
|
32296
32483
|
if (a.year === b.year) {
|
|
32297
32484
|
return b.month - a.month;
|
|
@@ -32434,7 +32621,7 @@ var TasksPanelNotification = ({
|
|
|
32434
32621
|
};
|
|
32435
32622
|
|
|
32436
32623
|
// src/components/Tasks/TasksYearsTabs.tsx
|
|
32437
|
-
import { useMemo as
|
|
32624
|
+
import { useMemo as useMemo61 } from "react";
|
|
32438
32625
|
|
|
32439
32626
|
// src/components/Tabs/Tabs.tsx
|
|
32440
32627
|
import { useEffect as useEffect37, useState as useState69 } from "react";
|
|
@@ -32596,7 +32783,7 @@ var TasksYearsTabs = () => {
|
|
|
32596
32783
|
yearNumber: Number(year)
|
|
32597
32784
|
});
|
|
32598
32785
|
};
|
|
32599
|
-
const yearsList =
|
|
32786
|
+
const yearsList = useMemo61(() => {
|
|
32600
32787
|
return yearStatuses == null ? void 0 : yearStatuses.sort((a, b) => a.year - b.year).map((y) => {
|
|
32601
32788
|
return {
|
|
32602
32789
|
value: `${y.year}`,
|
|
@@ -33302,7 +33489,7 @@ function useBusinessPersonnel() {
|
|
|
33302
33489
|
// src/hooks/businessPersonnel/useCreateBusinessPersonnel.ts
|
|
33303
33490
|
import useSWRMutation22 from "swr/mutation";
|
|
33304
33491
|
import { useSWRConfig as useSWRConfig11 } from "swr";
|
|
33305
|
-
import { useCallback as
|
|
33492
|
+
import { useCallback as useCallback42 } from "react";
|
|
33306
33493
|
var createBusinessPersonnel = post(({ businessId }) => `/v1/businesses/${businessId}/personnel`);
|
|
33307
33494
|
function buildKey34({
|
|
33308
33495
|
access_token: accessToken,
|
|
@@ -33340,7 +33527,7 @@ function useCreateBusinessPersonnel() {
|
|
|
33340
33527
|
}
|
|
33341
33528
|
);
|
|
33342
33529
|
const { trigger: originalTrigger } = mutationResponse;
|
|
33343
|
-
const stableProxiedTrigger =
|
|
33530
|
+
const stableProxiedTrigger = useCallback42(
|
|
33344
33531
|
(...triggerParameters) => __async(null, null, function* () {
|
|
33345
33532
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
33346
33533
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -33374,7 +33561,7 @@ var updateBusinessPersonnel = post(({ businessId, businessPersonnelId }) => {
|
|
|
33374
33561
|
});
|
|
33375
33562
|
|
|
33376
33563
|
// src/hooks/businessPersonnel/useUpdateBusinessPersonnel.ts
|
|
33377
|
-
import { useCallback as
|
|
33564
|
+
import { useCallback as useCallback43 } from "react";
|
|
33378
33565
|
function buildKey35({
|
|
33379
33566
|
access_token: accessToken,
|
|
33380
33567
|
apiUrl,
|
|
@@ -33417,7 +33604,7 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
|
|
|
33417
33604
|
}
|
|
33418
33605
|
);
|
|
33419
33606
|
const { trigger: originalTrigger } = mutationResponse;
|
|
33420
|
-
const stableProxiedTrigger =
|
|
33607
|
+
const stableProxiedTrigger = useCallback43(
|
|
33421
33608
|
(...triggerParameters) => __async(null, null, function* () {
|
|
33422
33609
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
33423
33610
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -33444,7 +33631,7 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
|
|
|
33444
33631
|
// src/hooks/business/useUpdateBusiness.ts
|
|
33445
33632
|
import useSWRMutation24 from "swr/mutation";
|
|
33446
33633
|
import { useSWRConfig as useSWRConfig13 } from "swr";
|
|
33447
|
-
import { useCallback as
|
|
33634
|
+
import { useCallback as useCallback44 } from "react";
|
|
33448
33635
|
var BUSINESS_TAG_KEY = "business";
|
|
33449
33636
|
function buildKey36({
|
|
33450
33637
|
access_token: accessToken,
|
|
@@ -33482,7 +33669,7 @@ function useUpdateBusiness() {
|
|
|
33482
33669
|
}
|
|
33483
33670
|
);
|
|
33484
33671
|
const { trigger: originalTrigger } = mutationResponse;
|
|
33485
|
-
const stableProxiedTrigger =
|
|
33672
|
+
const stableProxiedTrigger = useCallback44(
|
|
33486
33673
|
(...triggerParameters) => __async(null, null, function* () {
|
|
33487
33674
|
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
33488
33675
|
void mutate((key) => withSWRKeyTags(
|
|
@@ -34659,9 +34846,9 @@ var ProjectProfitabilityView = ({
|
|
|
34659
34846
|
import { createContext as createContext23, useContext as useContext58 } from "react";
|
|
34660
34847
|
|
|
34661
34848
|
// src/hooks/useBills.tsx
|
|
34662
|
-
import { useMemo as
|
|
34849
|
+
import { useMemo as useMemo62, useState as useState76 } from "react";
|
|
34663
34850
|
import { endOfMonth as endOfMonth14, startOfMonth as startOfMonth17, sub as sub3 } from "date-fns";
|
|
34664
|
-
import
|
|
34851
|
+
import useSWRInfinite6 from "swr/infinite";
|
|
34665
34852
|
var PAGE_SIZE = 20;
|
|
34666
34853
|
var useBills = () => {
|
|
34667
34854
|
const { businessId } = useLayerContext();
|
|
@@ -34708,7 +34895,7 @@ var useBills = () => {
|
|
|
34708
34895
|
size,
|
|
34709
34896
|
setSize,
|
|
34710
34897
|
mutate
|
|
34711
|
-
} =
|
|
34898
|
+
} = useSWRInfinite6(
|
|
34712
34899
|
getKey,
|
|
34713
34900
|
(_0) => __async(null, [_0], function* ([_query, nextCursor]) {
|
|
34714
34901
|
if (auth == null ? void 0 : auth.access_token) {
|
|
@@ -34730,24 +34917,24 @@ var useBills = () => {
|
|
|
34730
34917
|
revalidateFirstPage: false
|
|
34731
34918
|
}
|
|
34732
34919
|
);
|
|
34733
|
-
const data =
|
|
34920
|
+
const data = useMemo62(() => {
|
|
34734
34921
|
if (rawResponseData && rawResponseData.length > 0) {
|
|
34735
34922
|
return rawResponseData == null ? void 0 : rawResponseData.map((x) => x == null ? void 0 : x.data).flat().filter((x) => !!x);
|
|
34736
34923
|
}
|
|
34737
34924
|
return void 0;
|
|
34738
34925
|
}, [rawResponseData]);
|
|
34739
|
-
const paginatedData =
|
|
34926
|
+
const paginatedData = useMemo62(() => {
|
|
34740
34927
|
const firstPageIndex = (currentPage - 1) * PAGE_SIZE;
|
|
34741
34928
|
const lastPageIndex = firstPageIndex + PAGE_SIZE;
|
|
34742
34929
|
return data == null ? void 0 : data.slice(firstPageIndex, lastPageIndex);
|
|
34743
34930
|
}, [currentPage, data]);
|
|
34744
|
-
const lastMetadata =
|
|
34931
|
+
const lastMetadata = useMemo62(() => {
|
|
34745
34932
|
if (rawResponseData && rawResponseData.length > 0) {
|
|
34746
34933
|
return rawResponseData[rawResponseData.length - 1].meta;
|
|
34747
34934
|
}
|
|
34748
34935
|
return void 0;
|
|
34749
34936
|
}, [rawResponseData]);
|
|
34750
|
-
const hasMore =
|
|
34937
|
+
const hasMore = useMemo62(() => {
|
|
34751
34938
|
var _a, _b, _c, _d;
|
|
34752
34939
|
if (rawResponseData && rawResponseData.length > 0) {
|
|
34753
34940
|
const lastElement = rawResponseData[rawResponseData.length - 1];
|
|
@@ -34792,7 +34979,7 @@ var useBills = () => {
|
|
|
34792
34979
|
};
|
|
34793
34980
|
|
|
34794
34981
|
// src/components/Bills/useBillsRecordPayment.ts
|
|
34795
|
-
import { useEffect as useEffect39, useMemo as
|
|
34982
|
+
import { useEffect as useEffect39, useMemo as useMemo63, useState as useState77 } from "react";
|
|
34796
34983
|
import useSWRMutation25 from "swr/mutation";
|
|
34797
34984
|
function buildKey37({
|
|
34798
34985
|
access_token: accessToken,
|
|
@@ -34904,7 +35091,7 @@ var useBillsRecordPayment = ({ refetchAllBills }) => {
|
|
|
34904
35091
|
setBillsToPay([{ bill, amount: (_b = convertFromCents((_a = bill.outstanding_balance) != null ? _a : 0)) == null ? void 0 : _b.toString() }]);
|
|
34905
35092
|
setShowRecordPaymentForm(true);
|
|
34906
35093
|
};
|
|
34907
|
-
const payload =
|
|
35094
|
+
const payload = useMemo63(() => {
|
|
34908
35095
|
const filteredBillsToPay = billsToPay.filter((item) => {
|
|
34909
35096
|
var _a;
|
|
34910
35097
|
return item.amount && ((_a = item.bill) == null ? void 0 : _a.id);
|
|
@@ -35236,7 +35423,7 @@ var useBillForm = (bill) => {
|
|
|
35236
35423
|
import { formatISO as formatISO4, parseISO as parseISO18 } from "date-fns";
|
|
35237
35424
|
|
|
35238
35425
|
// src/components/Bills/BillsPaymentRecorded.tsx
|
|
35239
|
-
import { useMemo as
|
|
35426
|
+
import { useMemo as useMemo64 } from "react";
|
|
35240
35427
|
|
|
35241
35428
|
// src/components/Input/StaticValue.tsx
|
|
35242
35429
|
import classNames83 from "classnames";
|
|
@@ -35282,11 +35469,11 @@ var BillsPaymentRecorded = ({
|
|
|
35282
35469
|
vendor,
|
|
35283
35470
|
payRemainingBalance
|
|
35284
35471
|
} = useBillsRecordPaymentContext();
|
|
35285
|
-
const totalPaid =
|
|
35472
|
+
const totalPaid = useMemo64(
|
|
35286
35473
|
() => billsToPay.reduce((acc, record) => acc + (record.amount !== void 0 ? Number(record.amount) : 0), 0),
|
|
35287
35474
|
[billsToPay]
|
|
35288
35475
|
);
|
|
35289
|
-
const anyUnpaid =
|
|
35476
|
+
const anyUnpaid = useMemo64(
|
|
35290
35477
|
() => billsToPay.some((record) => {
|
|
35291
35478
|
var _a2;
|
|
35292
35479
|
return ((_a2 = record.bill) == null ? void 0 : _a2.status) !== "PAID";
|
|
@@ -35343,7 +35530,7 @@ var BillsPaymentRecorded = ({
|
|
|
35343
35530
|
};
|
|
35344
35531
|
|
|
35345
35532
|
// src/components/Bills/BillsRecordPayment.tsx
|
|
35346
|
-
import { useMemo as
|
|
35533
|
+
import { useMemo as useMemo65 } from "react";
|
|
35347
35534
|
import { parseISO as parseISO16, format as formatTime13 } from "date-fns";
|
|
35348
35535
|
|
|
35349
35536
|
// src/components/Bills/useUnpaidBillsByVendor.ts
|
|
@@ -35426,7 +35613,7 @@ var BillsRecordPayment = ({
|
|
|
35426
35613
|
apiError
|
|
35427
35614
|
} = useBillsRecordPaymentContext();
|
|
35428
35615
|
const { data: rawAvailableBills } = useUnpaidBillsByVendor({ vendorId: vendor == null ? void 0 : vendor.id });
|
|
35429
|
-
const availableBills =
|
|
35616
|
+
const availableBills = useMemo65(
|
|
35430
35617
|
() => rawAvailableBills == null ? void 0 : rawAvailableBills.filter((b) => !billsToPay.find((x) => {
|
|
35431
35618
|
var _a2;
|
|
35432
35619
|
return ((_a2 = x.bill) == null ? void 0 : _a2.id) === b.id;
|
|
@@ -35752,7 +35939,7 @@ var BillSummaryPaid = ({ bill }) => {
|
|
|
35752
35939
|
};
|
|
35753
35940
|
|
|
35754
35941
|
// src/components/Bills/BillSummaryUnpaid.tsx
|
|
35755
|
-
import { useMemo as
|
|
35942
|
+
import { useMemo as useMemo66 } from "react";
|
|
35756
35943
|
import { differenceInDays as differenceInDays2, parseISO as parseISO17 } from "date-fns";
|
|
35757
35944
|
import { jsx as jsx315, jsxs as jsxs201 } from "react/jsx-runtime";
|
|
35758
35945
|
function buildDifference(due_at) {
|
|
@@ -35780,7 +35967,7 @@ function buildDifference(due_at) {
|
|
|
35780
35967
|
};
|
|
35781
35968
|
}
|
|
35782
35969
|
var BillSummaryUnpaid = ({ bill }) => {
|
|
35783
|
-
const difference =
|
|
35970
|
+
const difference = useMemo66(() => buildDifference(bill.due_at), [bill.due_at]);
|
|
35784
35971
|
return /* @__PURE__ */ jsxs201("div", { className: "Layer__bill-details__summary", children: [
|
|
35785
35972
|
/* @__PURE__ */ jsxs201("div", { children: [
|
|
35786
35973
|
/* @__PURE__ */ jsx315(
|
|
@@ -36173,13 +36360,13 @@ var BillsDetails = ({
|
|
|
36173
36360
|
};
|
|
36174
36361
|
|
|
36175
36362
|
// src/components/Bills/BillsTableWithPanel.tsx
|
|
36176
|
-
import { useMemo as
|
|
36363
|
+
import { useMemo as useMemo68 } from "react";
|
|
36177
36364
|
|
|
36178
36365
|
// src/components/Bills/BillsTable.tsx
|
|
36179
36366
|
import { Fragment as Fragment53 } from "react";
|
|
36180
36367
|
|
|
36181
36368
|
// src/components/DueStatus/DueStatus.tsx
|
|
36182
|
-
import { useMemo as
|
|
36369
|
+
import { useMemo as useMemo67 } from "react";
|
|
36183
36370
|
import { parseISO as parseISO19, differenceInDays as differenceInDays3 } from "date-fns";
|
|
36184
36371
|
import { jsx as jsx318, jsxs as jsxs203 } from "react/jsx-runtime";
|
|
36185
36372
|
var dueStatusTitle = (daysDiff, paid) => {
|
|
@@ -36244,7 +36431,7 @@ var getDiff = (refDate) => {
|
|
|
36244
36431
|
return differenceInDays3(today, d);
|
|
36245
36432
|
};
|
|
36246
36433
|
var DueStatus = ({ dueDate, paidAt, size = "md" }) => {
|
|
36247
|
-
const date =
|
|
36434
|
+
const date = useMemo67(() => {
|
|
36248
36435
|
try {
|
|
36249
36436
|
const diff = getDiff(paidAt ? paidAt : dueDate);
|
|
36250
36437
|
if (diff === null) {
|
|
@@ -36572,11 +36759,11 @@ var BillsTableWithPanel = ({
|
|
|
36572
36759
|
setVendor: setRecordPaymentVendor
|
|
36573
36760
|
} = useBillsRecordPaymentContext();
|
|
36574
36761
|
const { isDesktop, isMobile } = useSizeClass();
|
|
36575
|
-
const totalCount =
|
|
36762
|
+
const totalCount = useMemo68(() => {
|
|
36576
36763
|
var _a;
|
|
36577
36764
|
return (_a = rawData == null ? void 0 : rawData.length) != null ? _a : 0;
|
|
36578
36765
|
}, [rawData]);
|
|
36579
|
-
const anyBillToPaySelected =
|
|
36766
|
+
const anyBillToPaySelected = useMemo68(() => {
|
|
36580
36767
|
return billsToPay.length > 0;
|
|
36581
36768
|
}, [billsToPay]);
|
|
36582
36769
|
return /* @__PURE__ */ jsxs206(
|