@layerfi/components 0.1.45 → 0.1.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +569 -559
- package/dist/esm/index.js.map +4 -4
- package/dist/index.d.ts +23 -33
- package/dist/index.js +776 -766
- package/dist/index.js.map +4 -4
- package/dist/styles/index.css +7 -0
- package/dist/styles/index.css.map +2 -2
- package/package.json +1 -1
- package/.idea/codeStyles/Project.xml +0 -61
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/layer-react.iml +0 -9
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
package/dist/esm/index.js
CHANGED
|
@@ -551,6 +551,7 @@ var DEPENDENCIES = {
|
|
|
551
551
|
["PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */]: ALL_TOUCHABLE,
|
|
552
552
|
["STATEMENT_OF_CASH_FLOWS" /* STATEMENT_OF_CASH_FLOWS */]: ALL_TOUCHABLE
|
|
553
553
|
};
|
|
554
|
+
var readTimestampsG = {};
|
|
554
555
|
var useDataSync = () => {
|
|
555
556
|
const initialTimestamp = Date.now();
|
|
556
557
|
const [syncTimestamps, setSyncTimestamps] = useState2({
|
|
@@ -562,38 +563,31 @@ var useDataSync = () => {
|
|
|
562
563
|
["PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */]: initialTimestamp,
|
|
563
564
|
["STATEMENT_OF_CASH_FLOWS" /* STATEMENT_OF_CASH_FLOWS */]: initialTimestamp
|
|
564
565
|
});
|
|
565
|
-
const [readTimestamps, setReadTimestamps] = useState2({
|
|
566
|
-
["BALANCE_SHEET" /* BALANCE_SHEET */]: initialTimestamp,
|
|
567
|
-
["CHART_OF_ACCOUNTS" /* CHART_OF_ACCOUNTS */]: initialTimestamp,
|
|
568
|
-
["JOURNAL" /* JOURNAL */]: initialTimestamp,
|
|
569
|
-
["LEDGER_ACCOUNTS" /* LEDGER_ACCOUNTS */]: initialTimestamp,
|
|
570
|
-
["LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */]: initialTimestamp,
|
|
571
|
-
["PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */]: initialTimestamp,
|
|
572
|
-
["STATEMENT_OF_CASH_FLOWS" /* STATEMENT_OF_CASH_FLOWS */]: initialTimestamp
|
|
573
|
-
});
|
|
566
|
+
const [readTimestamps, setReadTimestamps] = useState2({});
|
|
574
567
|
const touch = (model) => {
|
|
575
568
|
setSyncTimestamps({
|
|
576
569
|
...syncTimestamps,
|
|
577
570
|
[model]: Date.now()
|
|
578
571
|
});
|
|
579
572
|
};
|
|
580
|
-
const read = (model) => {
|
|
581
|
-
|
|
582
|
-
...
|
|
583
|
-
[
|
|
584
|
-
|
|
573
|
+
const read = (model, cacheKey) => {
|
|
574
|
+
readTimestampsG = {
|
|
575
|
+
...readTimestampsG,
|
|
576
|
+
[cacheKey]: {
|
|
577
|
+
t: Date.now(),
|
|
578
|
+
m: model
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
setReadTimestamps({ ...readTimestampsG });
|
|
585
582
|
};
|
|
586
|
-
const hasBeenTouched = (
|
|
587
|
-
|
|
583
|
+
const hasBeenTouched = (cacheKey) => {
|
|
584
|
+
const lastRead = cacheKey in readTimestamps ? readTimestamps[cacheKey] : void 0;
|
|
585
|
+
if (!lastRead || !lastRead?.m || !lastRead?.t) {
|
|
588
586
|
return false;
|
|
589
587
|
}
|
|
590
|
-
const lastRead = model in readTimestamps ? readTimestamps[model] : void 0;
|
|
591
|
-
if (!lastRead) {
|
|
592
|
-
false;
|
|
593
|
-
}
|
|
594
588
|
return Boolean(
|
|
595
|
-
DEPENDENCIES[
|
|
596
|
-
return dep in syncTimestamps && Boolean(syncTimestamps[dep]) && syncTimestamps[dep] > lastRead;
|
|
589
|
+
DEPENDENCIES[lastRead.m]?.find((dep) => {
|
|
590
|
+
return dep in syncTimestamps && Boolean(syncTimestamps[dep]) && syncTimestamps[dep] > lastRead.t;
|
|
597
591
|
})
|
|
598
592
|
);
|
|
599
593
|
};
|
|
@@ -1011,11 +1005,11 @@ var useBankTransactions = (params) => {
|
|
|
1011
1005
|
};
|
|
1012
1006
|
useEffect2(() => {
|
|
1013
1007
|
if (isLoading || isValidating) {
|
|
1014
|
-
read("BANK_TRANSACTIONS" /* BANK_TRANSACTIONS
|
|
1008
|
+
read("BANK_TRANSACTIONS" /* BANK_TRANSACTIONS */, "bank-transactions");
|
|
1015
1009
|
}
|
|
1016
1010
|
}, [isLoading, isValidating]);
|
|
1017
1011
|
useEffect2(() => {
|
|
1018
|
-
if (hasBeenTouched("
|
|
1012
|
+
if (hasBeenTouched("bank-transactions")) {
|
|
1019
1013
|
refetch();
|
|
1020
1014
|
}
|
|
1021
1015
|
}, [syncTimestamps]);
|
|
@@ -1422,7 +1416,7 @@ var LayerProvider = ({
|
|
|
1422
1416
|
});
|
|
1423
1417
|
}
|
|
1424
1418
|
}, [businessAccessToken, auth?.access_token]);
|
|
1425
|
-
useSWR(
|
|
1419
|
+
const { data: categoriesData } = useSWR(
|
|
1426
1420
|
businessId && state.auth?.access_token && `categories-${businessId}`,
|
|
1427
1421
|
Layer.getCategories(apiUrl, state.auth?.access_token, {
|
|
1428
1422
|
params: { businessId }
|
|
@@ -1439,7 +1433,15 @@ var LayerProvider = ({
|
|
|
1439
1433
|
}
|
|
1440
1434
|
}
|
|
1441
1435
|
);
|
|
1442
|
-
|
|
1436
|
+
useEffect3(() => {
|
|
1437
|
+
if (categoriesData?.data?.categories?.length) {
|
|
1438
|
+
dispatch({
|
|
1439
|
+
type: "LayerContext.setCategories" /* setCategories */,
|
|
1440
|
+
payload: { categories: categoriesData.data.categories || [] }
|
|
1441
|
+
});
|
|
1442
|
+
}
|
|
1443
|
+
}, [categoriesData]);
|
|
1444
|
+
const { data: businessData } = useSWR(
|
|
1443
1445
|
businessId && state?.auth?.access_token && `business-${businessId}`,
|
|
1444
1446
|
Layer.getBusiness(apiUrl, state?.auth?.access_token, {
|
|
1445
1447
|
params: { businessId }
|
|
@@ -1456,6 +1458,14 @@ var LayerProvider = ({
|
|
|
1456
1458
|
}
|
|
1457
1459
|
}
|
|
1458
1460
|
);
|
|
1461
|
+
useEffect3(() => {
|
|
1462
|
+
if (businessData?.data) {
|
|
1463
|
+
dispatch({
|
|
1464
|
+
type: "LayerContext.setBusiness" /* setBusiness */,
|
|
1465
|
+
payload: { business: businessData.data || [] }
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
}, [businessData]);
|
|
1459
1469
|
const setTheme = (theme2) => {
|
|
1460
1470
|
dispatch({
|
|
1461
1471
|
type: "LayerContext.setTheme" /* setTheme */,
|
|
@@ -1714,6 +1724,7 @@ var useLinkedAccounts = () => {
|
|
|
1714
1724
|
const [loadingStatus, setLoadingStatus] = useState5("initial");
|
|
1715
1725
|
const USE_PLAID_SANDBOX = usePlaidSandbox ?? true;
|
|
1716
1726
|
const [linkMode, setLinkMode] = useState5("add");
|
|
1727
|
+
const queryKey = businessId && auth?.access_token && `linked-accounts-${businessId}`;
|
|
1717
1728
|
const {
|
|
1718
1729
|
data: responseData,
|
|
1719
1730
|
isLoading,
|
|
@@ -1721,7 +1732,7 @@ var useLinkedAccounts = () => {
|
|
|
1721
1732
|
error: responseError,
|
|
1722
1733
|
mutate
|
|
1723
1734
|
} = useSWR2(
|
|
1724
|
-
|
|
1735
|
+
queryKey,
|
|
1725
1736
|
Layer.getLinkedAccounts(apiUrl, auth?.access_token, {
|
|
1726
1737
|
params: { businessId }
|
|
1727
1738
|
})
|
|
@@ -1910,12 +1921,12 @@ var useLinkedAccounts = () => {
|
|
|
1910
1921
|
touch("LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */);
|
|
1911
1922
|
};
|
|
1912
1923
|
useEffect4(() => {
|
|
1913
|
-
if (isLoading || isValidating) {
|
|
1914
|
-
read("LINKED_ACCOUNTS" /* LINKED_ACCOUNTS
|
|
1924
|
+
if (queryKey && (isLoading || isValidating)) {
|
|
1925
|
+
read("LINKED_ACCOUNTS" /* LINKED_ACCOUNTS */, queryKey);
|
|
1915
1926
|
}
|
|
1916
1927
|
}, [isLoading, isValidating]);
|
|
1917
1928
|
useEffect4(() => {
|
|
1918
|
-
if (hasBeenTouched(
|
|
1929
|
+
if (queryKey && hasBeenTouched(queryKey)) {
|
|
1919
1930
|
refetchAccounts();
|
|
1920
1931
|
}
|
|
1921
1932
|
}, [syncTimestamps]);
|
|
@@ -4198,7 +4209,7 @@ var LinkedAccountsComponent = ({
|
|
|
4198
4209
|
};
|
|
4199
4210
|
|
|
4200
4211
|
// src/components/BankTransactions/BankTransactions.tsx
|
|
4201
|
-
import React111, { useState as
|
|
4212
|
+
import React111, { useState as useState26, useMemo as useMemo6, useEffect as useEffect20 } from "react";
|
|
4202
4213
|
|
|
4203
4214
|
// src/hooks/useElementSize/useElementSize.ts
|
|
4204
4215
|
import { useLayoutEffect as useLayoutEffect2, useRef as useRef7 } from "react";
|
|
@@ -4244,148 +4255,7 @@ var debounce = (fnc, timeout = 300) => {
|
|
|
4244
4255
|
import React85 from "react";
|
|
4245
4256
|
|
|
4246
4257
|
// src/components/BankTransactionList/BankTransactionListItem.tsx
|
|
4247
|
-
import React84, { useEffect as
|
|
4248
|
-
|
|
4249
|
-
// src/hooks/useProfitAndLoss/useProfitAndLossLTM.tsx
|
|
4250
|
-
import { useEffect as useEffect8, useMemo as useMemo4, useState as useState10 } from "react";
|
|
4251
|
-
import { startOfMonth, sub } from "date-fns";
|
|
4252
|
-
import useSWR3 from "swr";
|
|
4253
|
-
var buildDates = ({ currentDate }) => {
|
|
4254
|
-
return {
|
|
4255
|
-
startYear: startOfMonth(currentDate).getFullYear() - 1,
|
|
4256
|
-
startMonth: startOfMonth(currentDate).getMonth() + 1,
|
|
4257
|
-
endYear: startOfMonth(currentDate).getFullYear(),
|
|
4258
|
-
endMonth: startOfMonth(currentDate).getMonth() + 1
|
|
4259
|
-
};
|
|
4260
|
-
};
|
|
4261
|
-
var buildMonthsArray = (startDate, endDate) => {
|
|
4262
|
-
if (startDate >= endDate) {
|
|
4263
|
-
return [];
|
|
4264
|
-
}
|
|
4265
|
-
var dates = [];
|
|
4266
|
-
for (var d = startDate; d <= endDate; d.setMonth(d.getMonth() + 1)) {
|
|
4267
|
-
dates.push(new Date(d));
|
|
4268
|
-
}
|
|
4269
|
-
return dates;
|
|
4270
|
-
};
|
|
4271
|
-
var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
4272
|
-
currentDate: /* @__PURE__ */ new Date()
|
|
4273
|
-
}) => {
|
|
4274
|
-
const { businessId, auth, apiUrl, syncTimestamps, read, hasBeenTouched } = useLayerContext();
|
|
4275
|
-
const [date, setDate] = useState10(currentDate);
|
|
4276
|
-
const [loaded, setLoaded] = useState10("initial");
|
|
4277
|
-
const [data, setData] = useState10([]);
|
|
4278
|
-
const { startYear, startMonth, endYear, endMonth } = useMemo4(() => {
|
|
4279
|
-
return buildDates({ currentDate: date });
|
|
4280
|
-
}, [date, businessId, tagFilter, reportingBasis]);
|
|
4281
|
-
const {
|
|
4282
|
-
data: rawData,
|
|
4283
|
-
isLoading,
|
|
4284
|
-
isValidating,
|
|
4285
|
-
error,
|
|
4286
|
-
mutate
|
|
4287
|
-
} = useSWR3(
|
|
4288
|
-
businessId && Boolean(startYear) && Boolean(startMonth) && Boolean(endYear) && Boolean(endMonth) && auth?.access_token && `profit-and-loss-summaries-${businessId}-${startYear.toString()}-${startMonth.toString()}-${tagFilter?.key}-${tagFilter?.values?.join(
|
|
4289
|
-
","
|
|
4290
|
-
)}-${reportingBasis}`,
|
|
4291
|
-
Layer.getProfitAndLossSummaries(apiUrl, auth?.access_token, {
|
|
4292
|
-
params: {
|
|
4293
|
-
businessId,
|
|
4294
|
-
startYear: startYear.toString(),
|
|
4295
|
-
startMonth: startMonth.toString(),
|
|
4296
|
-
endYear: endYear.toString(),
|
|
4297
|
-
endMonth: endMonth.toString(),
|
|
4298
|
-
tagKey: tagFilter?.key,
|
|
4299
|
-
tagValues: tagFilter?.values?.join(","),
|
|
4300
|
-
reportingBasis
|
|
4301
|
-
}
|
|
4302
|
-
})
|
|
4303
|
-
);
|
|
4304
|
-
useEffect8(() => {
|
|
4305
|
-
const newData = data.slice();
|
|
4306
|
-
const newPeriod = buildMonthsArray(sub(date, { years: 1 }), date);
|
|
4307
|
-
if (newData && newPeriod) {
|
|
4308
|
-
newPeriod.forEach((x) => {
|
|
4309
|
-
if (!newData?.find(
|
|
4310
|
-
(n) => x.getMonth() + 1 === n.month && x.getFullYear() === n.year
|
|
4311
|
-
)) {
|
|
4312
|
-
newData.push({
|
|
4313
|
-
year: x.getFullYear(),
|
|
4314
|
-
month: x.getMonth() + 1,
|
|
4315
|
-
income: 0,
|
|
4316
|
-
costOfGoodsSold: 0,
|
|
4317
|
-
grossProfit: 0,
|
|
4318
|
-
operatingExpenses: 0,
|
|
4319
|
-
profitBeforeTaxes: 0,
|
|
4320
|
-
taxes: 0,
|
|
4321
|
-
netProfit: 0,
|
|
4322
|
-
fullyCategorized: false,
|
|
4323
|
-
totalExpenses: 0,
|
|
4324
|
-
uncategorizedInflows: 0,
|
|
4325
|
-
uncategorizedOutflows: 0,
|
|
4326
|
-
uncategorized_transactions: 0,
|
|
4327
|
-
isLoading: true
|
|
4328
|
-
});
|
|
4329
|
-
}
|
|
4330
|
-
});
|
|
4331
|
-
}
|
|
4332
|
-
if (newData) {
|
|
4333
|
-
setData(
|
|
4334
|
-
newData.sort(
|
|
4335
|
-
(a, b) => Number(new Date(a.year, a.month, 1)) - Number(new Date(b.year, b.month, 1))
|
|
4336
|
-
)
|
|
4337
|
-
);
|
|
4338
|
-
}
|
|
4339
|
-
}, [startYear, startMonth]);
|
|
4340
|
-
useEffect8(() => {
|
|
4341
|
-
const newData = rawData?.data?.months?.slice();
|
|
4342
|
-
if (data && newData) {
|
|
4343
|
-
data.forEach((x) => {
|
|
4344
|
-
if (!newData?.find((n) => x.month === n.month && x.year === n.year)) {
|
|
4345
|
-
newData.push({ ...x });
|
|
4346
|
-
}
|
|
4347
|
-
});
|
|
4348
|
-
}
|
|
4349
|
-
if (newData) {
|
|
4350
|
-
setData(
|
|
4351
|
-
newData.sort(
|
|
4352
|
-
(a, b) => Number(new Date(a.year, a.month, 1)) - Number(new Date(b.year, b.month, 1))
|
|
4353
|
-
)
|
|
4354
|
-
);
|
|
4355
|
-
}
|
|
4356
|
-
}, [rawData]);
|
|
4357
|
-
useEffect8(() => {
|
|
4358
|
-
if (isLoading && loaded === "initial") {
|
|
4359
|
-
setLoaded("loading");
|
|
4360
|
-
return;
|
|
4361
|
-
}
|
|
4362
|
-
if (!isLoading && rawData) {
|
|
4363
|
-
setLoaded("complete");
|
|
4364
|
-
}
|
|
4365
|
-
}, [data, isLoading]);
|
|
4366
|
-
const pullData = (date2) => setDate(date2);
|
|
4367
|
-
useEffect8(() => {
|
|
4368
|
-
if (isLoading || isValidating) {
|
|
4369
|
-
read("PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */);
|
|
4370
|
-
}
|
|
4371
|
-
}, [isLoading, isValidating]);
|
|
4372
|
-
useEffect8(() => {
|
|
4373
|
-
if (hasBeenTouched("PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */)) {
|
|
4374
|
-
mutate();
|
|
4375
|
-
}
|
|
4376
|
-
}, [syncTimestamps]);
|
|
4377
|
-
const refetch = () => {
|
|
4378
|
-
mutate();
|
|
4379
|
-
};
|
|
4380
|
-
return {
|
|
4381
|
-
data,
|
|
4382
|
-
isLoading,
|
|
4383
|
-
loaded,
|
|
4384
|
-
error,
|
|
4385
|
-
pullData,
|
|
4386
|
-
refetch
|
|
4387
|
-
};
|
|
4388
|
-
};
|
|
4258
|
+
import React84, { useEffect as useEffect12, useRef as useRef11, useState as useState15 } from "react";
|
|
4389
4259
|
|
|
4390
4260
|
// src/icons/ChevronDownFill.tsx
|
|
4391
4261
|
import * as React57 from "react";
|
|
@@ -4413,7 +4283,7 @@ var ChevronDownFill = ({ size = 18, ...props }) => /* @__PURE__ */ React57.creat
|
|
|
4413
4283
|
var ChevronDownFill_default = ChevronDownFill;
|
|
4414
4284
|
|
|
4415
4285
|
// src/components/BankTransactionRow/BankTransactionRow.tsx
|
|
4416
|
-
import React82, { useEffect as
|
|
4286
|
+
import React82, { useEffect as useEffect11, useRef as useRef10, useState as useState14 } from "react";
|
|
4417
4287
|
|
|
4418
4288
|
// src/icons/Scissors.tsx
|
|
4419
4289
|
import * as React58 from "react";
|
|
@@ -4654,7 +4524,7 @@ var MinimizeTwo_default = MinimizeTwo;
|
|
|
4654
4524
|
import React64, { useContext as useContext9 } from "react";
|
|
4655
4525
|
|
|
4656
4526
|
// src/components/BankTransactionMobileList/BusinessCategories.tsx
|
|
4657
|
-
import React63, { useState as
|
|
4527
|
+
import React63, { useState as useState10 } from "react";
|
|
4658
4528
|
|
|
4659
4529
|
// src/components/ActionableList/ActionableList.tsx
|
|
4660
4530
|
import React62 from "react";
|
|
@@ -4750,8 +4620,8 @@ var getAssignedValue = (bankTransaction) => {
|
|
|
4750
4620
|
var BusinessCategories = ({ select }) => {
|
|
4751
4621
|
const { categories } = useLayerContext();
|
|
4752
4622
|
const categoryOptions = flattenCategories(categories);
|
|
4753
|
-
const [optionsToShow, setOptionsToShow] =
|
|
4754
|
-
const [selectedGroup, setSelectedGroup] =
|
|
4623
|
+
const [optionsToShow, setOptionsToShow] = useState10(categoryOptions);
|
|
4624
|
+
const [selectedGroup, setSelectedGroup] = useState10();
|
|
4755
4625
|
const onCategorySelect = (v) => {
|
|
4756
4626
|
if (v.value.type === "GROUP" && v.value.items) {
|
|
4757
4627
|
setOptionsToShow(v.value.items);
|
|
@@ -5011,9 +4881,9 @@ var CategorySelect = ({
|
|
|
5011
4881
|
import React80, {
|
|
5012
4882
|
forwardRef as forwardRef5,
|
|
5013
4883
|
useImperativeHandle,
|
|
5014
|
-
useState as
|
|
4884
|
+
useState as useState13,
|
|
5015
4885
|
useCallback,
|
|
5016
|
-
useEffect as
|
|
4886
|
+
useEffect as useEffect10,
|
|
5017
4887
|
useRef as useRef9
|
|
5018
4888
|
} from "react";
|
|
5019
4889
|
|
|
@@ -5516,8 +5386,8 @@ var Textarea = ({
|
|
|
5516
5386
|
|
|
5517
5387
|
// src/components/Toggle/Toggle.tsx
|
|
5518
5388
|
import React78, {
|
|
5519
|
-
useEffect as
|
|
5520
|
-
useState as
|
|
5389
|
+
useEffect as useEffect8,
|
|
5390
|
+
useState as useState11
|
|
5521
5391
|
} from "react";
|
|
5522
5392
|
import classNames31 from "classnames";
|
|
5523
5393
|
var Toggle = ({
|
|
@@ -5527,9 +5397,9 @@ var Toggle = ({
|
|
|
5527
5397
|
onChange,
|
|
5528
5398
|
size = "medium" /* medium */
|
|
5529
5399
|
}) => {
|
|
5530
|
-
const [currentWidth, setCurrentWidth] =
|
|
5531
|
-
const [thumbPos, setThumbPos] =
|
|
5532
|
-
const [initialized, setInitialized] =
|
|
5400
|
+
const [currentWidth, setCurrentWidth] = useState11(0);
|
|
5401
|
+
const [thumbPos, setThumbPos] = useState11({ left: 0, width: 0 });
|
|
5402
|
+
const [initialized, setInitialized] = useState11(false);
|
|
5533
5403
|
const toggleRef = useElementSize((a, b, c) => {
|
|
5534
5404
|
if (c.width && c?.width !== currentWidth) {
|
|
5535
5405
|
setCurrentWidth(c.width);
|
|
@@ -5549,9 +5419,12 @@ var Toggle = ({
|
|
|
5549
5419
|
if (!toggleRef?.current) {
|
|
5550
5420
|
return;
|
|
5551
5421
|
}
|
|
5552
|
-
const optionsNodes = [...toggleRef.current.children].
|
|
5553
|
-
(
|
|
5554
|
-
|
|
5422
|
+
const optionsNodes = [...toggleRef.current.children].map((x) => {
|
|
5423
|
+
if (x.className.includes("Layer__tooltip-trigger") && x.children && x.children.length > 0) {
|
|
5424
|
+
return x.children[0];
|
|
5425
|
+
}
|
|
5426
|
+
return x;
|
|
5427
|
+
}).filter((c) => c.className.includes("Layer__toggle-option"));
|
|
5555
5428
|
let shift2 = 0;
|
|
5556
5429
|
let width = thumbPos.width;
|
|
5557
5430
|
optionsNodes.forEach((c, i) => {
|
|
@@ -5564,14 +5437,14 @@ var Toggle = ({
|
|
|
5564
5437
|
shift2 = shift2 + (size === "medium" /* medium */ ? 2 : 1.5);
|
|
5565
5438
|
setThumbPos({ left: shift2, width });
|
|
5566
5439
|
};
|
|
5567
|
-
|
|
5440
|
+
useEffect8(() => {
|
|
5568
5441
|
const selectedIndex = getSelectedIndex();
|
|
5569
5442
|
updateThumbPosition(selectedIndex);
|
|
5570
5443
|
setTimeout(() => {
|
|
5571
5444
|
setInitialized(true);
|
|
5572
5445
|
}, 400);
|
|
5573
5446
|
}, []);
|
|
5574
|
-
|
|
5447
|
+
useEffect8(() => {
|
|
5575
5448
|
const selectedIndex = getSelectedIndex();
|
|
5576
5449
|
updateThumbPosition(selectedIndex);
|
|
5577
5450
|
}, [currentWidth]);
|
|
@@ -5659,7 +5532,7 @@ var ToggleOption = ({
|
|
|
5659
5532
|
};
|
|
5660
5533
|
|
|
5661
5534
|
// src/components/ExpandedBankTransactionRow/APIErrorNotifications.tsx
|
|
5662
|
-
import React79, { useEffect as
|
|
5535
|
+
import React79, { useEffect as useEffect9, useState as useState12 } from "react";
|
|
5663
5536
|
var ERROR_TITLE = "Approval Failed";
|
|
5664
5537
|
var ERROR_MESSAGE = "Something went wrong, try again later";
|
|
5665
5538
|
var NOTIFICATION_TIME = 4e3;
|
|
@@ -5669,7 +5542,7 @@ var APIErrorNotifications = ({
|
|
|
5669
5542
|
bankTransaction,
|
|
5670
5543
|
containerWidth
|
|
5671
5544
|
}) => {
|
|
5672
|
-
const [notifications, setNotifications] =
|
|
5545
|
+
const [notifications, setNotifications] = useState12([]);
|
|
5673
5546
|
const pushNotification = (title, message) => {
|
|
5674
5547
|
const timestamp = (/* @__PURE__ */ new Date()).valueOf();
|
|
5675
5548
|
if (notificationsCache.find(
|
|
@@ -5698,7 +5571,7 @@ var APIErrorNotifications = ({
|
|
|
5698
5571
|
);
|
|
5699
5572
|
setNotifications(notificationsCache.concat());
|
|
5700
5573
|
};
|
|
5701
|
-
|
|
5574
|
+
useEffect9(() => {
|
|
5702
5575
|
if (bankTransaction.error) {
|
|
5703
5576
|
pushNotification(ERROR_TITLE, ERROR_MESSAGE);
|
|
5704
5577
|
}
|
|
@@ -5723,8 +5596,8 @@ var Notification = ({
|
|
|
5723
5596
|
notification,
|
|
5724
5597
|
deleteNotification
|
|
5725
5598
|
}) => {
|
|
5726
|
-
const [visible, setVisible] =
|
|
5727
|
-
|
|
5599
|
+
const [visible, setVisible] = useState12(false);
|
|
5600
|
+
useEffect9(() => {
|
|
5728
5601
|
setVisible(true);
|
|
5729
5602
|
const timer = setTimeout(() => {
|
|
5730
5603
|
hideNotification();
|
|
@@ -5794,31 +5667,29 @@ var ExpandedBankTransactionRow = forwardRef5(
|
|
|
5794
5667
|
containerWidth,
|
|
5795
5668
|
showDescriptions,
|
|
5796
5669
|
mode,
|
|
5797
|
-
showReceiptUploads
|
|
5798
|
-
hardRefreshPnlOnCategorize
|
|
5670
|
+
showReceiptUploads
|
|
5799
5671
|
}, ref) => {
|
|
5800
5672
|
const {
|
|
5801
5673
|
categorize: categorizeBankTransaction2,
|
|
5802
5674
|
match: matchBankTransaction2
|
|
5803
5675
|
} = useBankTransactionsContext();
|
|
5804
|
-
const
|
|
5805
|
-
const [purpose, setPurpose] = useState14(
|
|
5676
|
+
const [purpose, setPurpose] = useState13(
|
|
5806
5677
|
bankTransaction.category ? "categorize" /* categorize */ : hasMatch(bankTransaction) ? "match" /* match */ : "categorize" /* categorize */
|
|
5807
5678
|
);
|
|
5808
|
-
const [selectedMatchId, setSelectedMatchId] =
|
|
5679
|
+
const [selectedMatchId, setSelectedMatchId] = useState13(
|
|
5809
5680
|
isAlreadyMatched2(bankTransaction)
|
|
5810
5681
|
);
|
|
5811
|
-
const [matchFormError, setMatchFormError] =
|
|
5812
|
-
const [splitFormError, setSplitFormError] =
|
|
5813
|
-
const [height, setHeight] =
|
|
5814
|
-
const [isOver, setOver] =
|
|
5682
|
+
const [matchFormError, setMatchFormError] = useState13();
|
|
5683
|
+
const [splitFormError, setSplitFormError] = useState13();
|
|
5684
|
+
const [height, setHeight] = useState13(0);
|
|
5685
|
+
const [isOver, setOver] = useState13(false);
|
|
5815
5686
|
const bodyRef = useRef9(null);
|
|
5816
|
-
const [memoText, setMemoText] =
|
|
5817
|
-
const [receiptUrls, setReceiptUrls] =
|
|
5818
|
-
const [isLoaded, setIsLoaded] =
|
|
5687
|
+
const [memoText, setMemoText] = useState13();
|
|
5688
|
+
const [receiptUrls, setReceiptUrls] = useState13([]);
|
|
5689
|
+
const [isLoaded, setIsLoaded] = useState13(false);
|
|
5819
5690
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
5820
5691
|
const defaultCategory = bankTransaction.category || hasSuggestions(bankTransaction.categorization_flow) && bankTransaction.categorization_flow?.suggestions?.[0];
|
|
5821
|
-
const [rowState, updateRowState] =
|
|
5692
|
+
const [rowState, updateRowState] = useState13({
|
|
5822
5693
|
splits: bankTransaction.category?.entries ? bankTransaction.category?.entries.map((c) => {
|
|
5823
5694
|
return {
|
|
5824
5695
|
amount: c.amount || 0,
|
|
@@ -5933,8 +5804,6 @@ var ExpandedBankTransactionRow = forwardRef5(
|
|
|
5933
5804
|
} else if (selectedMatchId && selectedMatchId !== isAlreadyMatched2(bankTransaction)) {
|
|
5934
5805
|
onMatchSubmit(selectedMatchId);
|
|
5935
5806
|
}
|
|
5936
|
-
if (hardRefreshPnlOnCategorize)
|
|
5937
|
-
refetch();
|
|
5938
5807
|
return;
|
|
5939
5808
|
}
|
|
5940
5809
|
if (!validateSplit(rowState)) {
|
|
@@ -5960,8 +5829,6 @@ var ExpandedBankTransactionRow = forwardRef5(
|
|
|
5960
5829
|
}))
|
|
5961
5830
|
}
|
|
5962
5831
|
);
|
|
5963
|
-
if (hardRefreshPnlOnCategorize)
|
|
5964
|
-
refetch();
|
|
5965
5832
|
close();
|
|
5966
5833
|
};
|
|
5967
5834
|
const fetchMetadata = async () => {
|
|
@@ -6024,7 +5891,7 @@ var ExpandedBankTransactionRow = forwardRef5(
|
|
|
6024
5891
|
},
|
|
6025
5892
|
[isOpen]
|
|
6026
5893
|
);
|
|
6027
|
-
|
|
5894
|
+
useEffect10(() => {
|
|
6028
5895
|
if (!isLoaded) {
|
|
6029
5896
|
return;
|
|
6030
5897
|
}
|
|
@@ -6036,7 +5903,7 @@ var ExpandedBankTransactionRow = forwardRef5(
|
|
|
6036
5903
|
});
|
|
6037
5904
|
}
|
|
6038
5905
|
}, [getDivHeight, isOpen]);
|
|
6039
|
-
|
|
5906
|
+
useEffect10(() => {
|
|
6040
5907
|
const loadDocumentsAndMetadata = async () => {
|
|
6041
5908
|
if (showDescriptions)
|
|
6042
5909
|
await fetchMetadata();
|
|
@@ -6238,7 +6105,7 @@ var ExpandedBankTransactionRow = forwardRef5(
|
|
|
6238
6105
|
"Receipt ",
|
|
6239
6106
|
index + 1
|
|
6240
6107
|
)))),
|
|
6241
|
-
asListItem ? /* @__PURE__ */ React80.createElement("div", { className: `${className}__submit-btn` }, bankTransaction.error ? /* @__PURE__ */ React80.createElement(
|
|
6108
|
+
asListItem && categorizationEnabled(mode) ? /* @__PURE__ */ React80.createElement("div", { className: `${className}__submit-btn` }, bankTransaction.error ? /* @__PURE__ */ React80.createElement(
|
|
6242
6109
|
Text,
|
|
6243
6110
|
{
|
|
6244
6111
|
as: "span",
|
|
@@ -6317,21 +6184,19 @@ var BankTransactionRow = ({
|
|
|
6317
6184
|
initialLoad,
|
|
6318
6185
|
showDescriptions,
|
|
6319
6186
|
showReceiptUploads,
|
|
6320
|
-
hardRefreshPnlOnCategorize,
|
|
6321
6187
|
stringOverrides
|
|
6322
6188
|
}) => {
|
|
6323
6189
|
const expandedRowRef = useRef10(null);
|
|
6324
|
-
const [showRetry, setShowRetry] =
|
|
6190
|
+
const [showRetry, setShowRetry] = useState14(false);
|
|
6325
6191
|
const {
|
|
6326
6192
|
filters,
|
|
6327
6193
|
categorize: categorizeBankTransaction2,
|
|
6328
6194
|
match: matchBankTransaction2
|
|
6329
6195
|
} = useBankTransactionsContext();
|
|
6330
|
-
const
|
|
6331
|
-
const [selectedCategory, setSelectedCategory] = useState15(
|
|
6196
|
+
const [selectedCategory, setSelectedCategory] = useState14(
|
|
6332
6197
|
getDefaultSelectedCategory(bankTransaction)
|
|
6333
6198
|
);
|
|
6334
|
-
const [open, setOpen] =
|
|
6199
|
+
const [open, setOpen] = useState14(false);
|
|
6335
6200
|
const toggleOpen = () => {
|
|
6336
6201
|
setShowRetry(false);
|
|
6337
6202
|
setOpen(!open);
|
|
@@ -6347,8 +6212,8 @@ var BankTransactionRow = ({
|
|
|
6347
6212
|
}
|
|
6348
6213
|
}
|
|
6349
6214
|
};
|
|
6350
|
-
const [showComponent, setShowComponent] =
|
|
6351
|
-
|
|
6215
|
+
const [showComponent, setShowComponent] = useState14(false);
|
|
6216
|
+
useEffect11(() => {
|
|
6352
6217
|
if (initialLoad) {
|
|
6353
6218
|
const timeoutId = setTimeout(() => {
|
|
6354
6219
|
setShowComponent(true);
|
|
@@ -6358,12 +6223,12 @@ var BankTransactionRow = ({
|
|
|
6358
6223
|
setShowComponent(true);
|
|
6359
6224
|
}
|
|
6360
6225
|
}, []);
|
|
6361
|
-
|
|
6226
|
+
useEffect11(() => {
|
|
6362
6227
|
if (bankTransaction.error) {
|
|
6363
6228
|
setShowRetry(true);
|
|
6364
6229
|
}
|
|
6365
6230
|
}, [bankTransaction.error]);
|
|
6366
|
-
|
|
6231
|
+
useEffect11(() => {
|
|
6367
6232
|
if (editable && bankTransaction.recently_categorized) {
|
|
6368
6233
|
setTimeout(() => {
|
|
6369
6234
|
removeTransaction(bankTransaction);
|
|
@@ -6373,8 +6238,6 @@ var BankTransactionRow = ({
|
|
|
6373
6238
|
const save = async () => {
|
|
6374
6239
|
if (open && expandedRowRef?.current) {
|
|
6375
6240
|
expandedRowRef?.current?.save();
|
|
6376
|
-
if (hardRefreshPnlOnCategorize)
|
|
6377
|
-
refetch();
|
|
6378
6241
|
return;
|
|
6379
6242
|
}
|
|
6380
6243
|
if (!selectedCategory) {
|
|
@@ -6386,16 +6249,12 @@ var BankTransactionRow = ({
|
|
|
6386
6249
|
selectedCategory.payload.id
|
|
6387
6250
|
);
|
|
6388
6251
|
setOpen(false);
|
|
6389
|
-
if (hardRefreshPnlOnCategorize)
|
|
6390
|
-
refetch();
|
|
6391
6252
|
return;
|
|
6392
6253
|
}
|
|
6393
6254
|
await categorizeBankTransaction2(bankTransaction.id, {
|
|
6394
6255
|
type: "Category",
|
|
6395
6256
|
category: getCategorizePayload(selectedCategory)
|
|
6396
6257
|
});
|
|
6397
|
-
if (hardRefreshPnlOnCategorize)
|
|
6398
|
-
refetch();
|
|
6399
6258
|
setOpen(false);
|
|
6400
6259
|
};
|
|
6401
6260
|
const categorized = isCategorized(bankTransaction);
|
|
@@ -6572,8 +6431,7 @@ var BankTransactionRow = ({
|
|
|
6572
6431
|
close: () => setOpen(false),
|
|
6573
6432
|
containerWidth,
|
|
6574
6433
|
showDescriptions,
|
|
6575
|
-
showReceiptUploads
|
|
6576
|
-
hardRefreshPnlOnCategorize
|
|
6434
|
+
showReceiptUploads
|
|
6577
6435
|
}
|
|
6578
6436
|
))));
|
|
6579
6437
|
};
|
|
@@ -6626,36 +6484,34 @@ var BankTransactionListItem = ({
|
|
|
6626
6484
|
mode,
|
|
6627
6485
|
showDescriptions,
|
|
6628
6486
|
showReceiptUploads,
|
|
6629
|
-
hardRefreshPnlOnCategorize,
|
|
6630
6487
|
containerWidth,
|
|
6631
6488
|
removeTransaction,
|
|
6632
6489
|
stringOverrides
|
|
6633
6490
|
}) => {
|
|
6634
6491
|
const expandedRowRef = useRef11(null);
|
|
6635
|
-
const [showRetry, setShowRetry] =
|
|
6492
|
+
const [showRetry, setShowRetry] = useState15(false);
|
|
6636
6493
|
const { categorize: categorizeBankTransaction2, match: matchBankTransaction2 } = useBankTransactionsContext();
|
|
6637
|
-
const
|
|
6638
|
-
const [selectedCategory, setSelectedCategory] = useState16(
|
|
6494
|
+
const [selectedCategory, setSelectedCategory] = useState15(
|
|
6639
6495
|
getDefaultSelectedCategory(bankTransaction)
|
|
6640
6496
|
);
|
|
6641
|
-
const [open, setOpen] =
|
|
6497
|
+
const [open, setOpen] = useState15(false);
|
|
6642
6498
|
const toggleOpen = () => {
|
|
6643
6499
|
setShowRetry(false);
|
|
6644
6500
|
setOpen(!open);
|
|
6645
6501
|
};
|
|
6646
|
-
const [showComponent, setShowComponent] =
|
|
6647
|
-
|
|
6502
|
+
const [showComponent, setShowComponent] = useState15(false);
|
|
6503
|
+
useEffect12(() => {
|
|
6648
6504
|
const timeoutId = setTimeout(() => {
|
|
6649
6505
|
setShowComponent(true);
|
|
6650
6506
|
}, index * 80);
|
|
6651
6507
|
return () => clearTimeout(timeoutId);
|
|
6652
6508
|
}, []);
|
|
6653
|
-
|
|
6509
|
+
useEffect12(() => {
|
|
6654
6510
|
if (bankTransaction.error) {
|
|
6655
6511
|
setShowRetry(true);
|
|
6656
6512
|
}
|
|
6657
6513
|
}, [bankTransaction.error]);
|
|
6658
|
-
|
|
6514
|
+
useEffect12(() => {
|
|
6659
6515
|
if (editable && bankTransaction.recently_categorized) {
|
|
6660
6516
|
setTimeout(() => {
|
|
6661
6517
|
removeTransaction(bankTransaction);
|
|
@@ -6665,8 +6521,6 @@ var BankTransactionListItem = ({
|
|
|
6665
6521
|
const save = () => {
|
|
6666
6522
|
if (open && expandedRowRef?.current) {
|
|
6667
6523
|
expandedRowRef?.current?.save();
|
|
6668
|
-
if (hardRefreshPnlOnCategorize)
|
|
6669
|
-
refetch();
|
|
6670
6524
|
return;
|
|
6671
6525
|
}
|
|
6672
6526
|
if (!selectedCategory) {
|
|
@@ -6674,16 +6528,12 @@ var BankTransactionListItem = ({
|
|
|
6674
6528
|
}
|
|
6675
6529
|
if (selectedCategory.type === "match") {
|
|
6676
6530
|
matchBankTransaction2(bankTransaction.id, selectedCategory.payload.id);
|
|
6677
|
-
if (hardRefreshPnlOnCategorize)
|
|
6678
|
-
refetch();
|
|
6679
6531
|
return;
|
|
6680
6532
|
}
|
|
6681
6533
|
categorizeBankTransaction2(bankTransaction.id, {
|
|
6682
6534
|
type: "Category",
|
|
6683
6535
|
category: getCategorizePayload(selectedCategory)
|
|
6684
6536
|
});
|
|
6685
|
-
if (hardRefreshPnlOnCategorize)
|
|
6686
|
-
refetch();
|
|
6687
6537
|
};
|
|
6688
6538
|
const categorized = isCategorized(bankTransaction);
|
|
6689
6539
|
const className = "Layer__bank-transaction-list-item";
|
|
@@ -6726,8 +6576,7 @@ var BankTransactionListItem = ({
|
|
|
6726
6576
|
submitBtnText: categorized ? stringOverrides?.updateButtonText || "Update" : stringOverrides?.approveButtonText || "Approve",
|
|
6727
6577
|
containerWidth,
|
|
6728
6578
|
showDescriptions,
|
|
6729
|
-
showReceiptUploads
|
|
6730
|
-
hardRefreshPnlOnCategorize
|
|
6579
|
+
showReceiptUploads
|
|
6731
6580
|
}
|
|
6732
6581
|
)), /* @__PURE__ */ React84.createElement("span", { className: `${className}__base-row` }, !categorized ? /* @__PURE__ */ React84.createElement(
|
|
6733
6582
|
CategorySelect,
|
|
@@ -6779,7 +6628,6 @@ var BankTransactionList = ({
|
|
|
6779
6628
|
containerWidth,
|
|
6780
6629
|
showDescriptions = false,
|
|
6781
6630
|
showReceiptUploads = false,
|
|
6782
|
-
hardRefreshPnlOnCategorize = false,
|
|
6783
6631
|
stringOverrides
|
|
6784
6632
|
}) => {
|
|
6785
6633
|
return /* @__PURE__ */ React85.createElement("ul", { className: "Layer__bank-transactions__list" }, bankTransactions?.map(
|
|
@@ -6796,7 +6644,6 @@ var BankTransactionList = ({
|
|
|
6796
6644
|
containerWidth,
|
|
6797
6645
|
showDescriptions,
|
|
6798
6646
|
showReceiptUploads,
|
|
6799
|
-
hardRefreshPnlOnCategorize,
|
|
6800
6647
|
stringOverrides
|
|
6801
6648
|
}
|
|
6802
6649
|
)
|
|
@@ -6807,30 +6654,26 @@ var BankTransactionList = ({
|
|
|
6807
6654
|
import React93 from "react";
|
|
6808
6655
|
|
|
6809
6656
|
// src/components/BankTransactionMobileList/BankTransactionMobileListItem.tsx
|
|
6810
|
-
import React92, { useContext as useContext11, useEffect as
|
|
6657
|
+
import React92, { useContext as useContext11, useEffect as useEffect17, useRef as useRef12, useState as useState22 } from "react";
|
|
6811
6658
|
|
|
6812
6659
|
// src/components/BankTransactionMobileList/BankTransactionMobileForms.tsx
|
|
6813
6660
|
import React91 from "react";
|
|
6814
6661
|
|
|
6815
6662
|
// src/components/BankTransactionMobileList/BusinessForm.tsx
|
|
6816
|
-
import React86, { useContext as useContext10, useEffect as
|
|
6817
|
-
var BusinessForm = ({
|
|
6818
|
-
bankTransaction,
|
|
6819
|
-
hardRefreshPnlOnCategorize = false
|
|
6820
|
-
}) => {
|
|
6663
|
+
import React86, { useContext as useContext10, useEffect as useEffect13, useMemo as useMemo4, useState as useState16 } from "react";
|
|
6664
|
+
var BusinessForm = ({ bankTransaction }) => {
|
|
6821
6665
|
const { setContent, close } = useContext10(DrawerContext);
|
|
6822
6666
|
const { categorize: categorizeBankTransaction2, isLoading } = useBankTransactionsContext();
|
|
6823
|
-
const
|
|
6824
|
-
const [selectedCategory, setSelectedCategory] = useState17(
|
|
6667
|
+
const [selectedCategory, setSelectedCategory] = useState16(
|
|
6825
6668
|
getAssignedValue(bankTransaction)
|
|
6826
6669
|
);
|
|
6827
|
-
const [showRetry, setShowRetry] =
|
|
6828
|
-
|
|
6670
|
+
const [showRetry, setShowRetry] = useState16(false);
|
|
6671
|
+
useEffect13(() => {
|
|
6829
6672
|
if (bankTransaction.error) {
|
|
6830
6673
|
setShowRetry(true);
|
|
6831
6674
|
}
|
|
6832
6675
|
}, [bankTransaction.error]);
|
|
6833
|
-
const options =
|
|
6676
|
+
const options = useMemo4(() => {
|
|
6834
6677
|
const options2 = bankTransaction?.categorization_flow?.type === "ASK_FROM_SUGGESTIONS" /* ASK_FROM_SUGGESTIONS */ ? bankTransaction.categorization_flow.suggestions.map(
|
|
6835
6678
|
(x) => mapCategoryToOption(x)
|
|
6836
6679
|
) : [];
|
|
@@ -6887,8 +6730,6 @@ var BusinessForm = ({
|
|
|
6887
6730
|
},
|
|
6888
6731
|
true
|
|
6889
6732
|
);
|
|
6890
|
-
if (hardRefreshPnlOnCategorize)
|
|
6891
|
-
refetch();
|
|
6892
6733
|
};
|
|
6893
6734
|
return /* @__PURE__ */ React86.createElement("div", { className: "Layer__bank-transaction-mobile-list-item__business-form" }, /* @__PURE__ */ React86.createElement(
|
|
6894
6735
|
ActionableList,
|
|
@@ -6917,7 +6758,7 @@ var BusinessForm = ({
|
|
|
6917
6758
|
};
|
|
6918
6759
|
|
|
6919
6760
|
// src/components/BankTransactionMobileList/PersonalForm.tsx
|
|
6920
|
-
import React87, { useEffect as
|
|
6761
|
+
import React87, { useEffect as useEffect14, useState as useState17 } from "react";
|
|
6921
6762
|
var isAlreadyAssigned = (bankTransaction) => {
|
|
6922
6763
|
if (bankTransaction.categorization_status === "MATCHED" /* MATCHED */ || bankTransaction?.categorization_status === "SPLIT" /* SPLIT */) {
|
|
6923
6764
|
return false;
|
|
@@ -6926,11 +6767,10 @@ var isAlreadyAssigned = (bankTransaction) => {
|
|
|
6926
6767
|
bankTransaction.category && PersonalCategories.includes(bankTransaction.category.display_name)
|
|
6927
6768
|
);
|
|
6928
6769
|
};
|
|
6929
|
-
var PersonalForm = ({ bankTransaction
|
|
6770
|
+
var PersonalForm = ({ bankTransaction }) => {
|
|
6930
6771
|
const { categorize: categorizeBankTransaction2, isLoading } = useBankTransactionsContext();
|
|
6931
|
-
const
|
|
6932
|
-
|
|
6933
|
-
useEffect15(() => {
|
|
6772
|
+
const [showRetry, setShowRetry] = useState17(false);
|
|
6773
|
+
useEffect14(() => {
|
|
6934
6774
|
if (bankTransaction.error) {
|
|
6935
6775
|
setShowRetry(true);
|
|
6936
6776
|
}
|
|
@@ -6947,8 +6787,6 @@ var PersonalForm = ({ bankTransaction, hardRefreshPnlOnCategorize }) => {
|
|
|
6947
6787
|
},
|
|
6948
6788
|
true
|
|
6949
6789
|
);
|
|
6950
|
-
if (hardRefreshPnlOnCategorize)
|
|
6951
|
-
refetch();
|
|
6952
6790
|
};
|
|
6953
6791
|
const alreadyAssigned = isAlreadyAssigned(bankTransaction);
|
|
6954
6792
|
return /* @__PURE__ */ React87.createElement("div", { className: "Layer__bank-transaction-mobile-list-item__personal-form" }, /* @__PURE__ */ React87.createElement(
|
|
@@ -6963,22 +6801,20 @@ var PersonalForm = ({ bankTransaction, hardRefreshPnlOnCategorize }) => {
|
|
|
6963
6801
|
};
|
|
6964
6802
|
|
|
6965
6803
|
// src/components/BankTransactionMobileList/SplitAndMatchForm.tsx
|
|
6966
|
-
import React90, { useState as
|
|
6804
|
+
import React90, { useState as useState20 } from "react";
|
|
6967
6805
|
|
|
6968
6806
|
// src/components/BankTransactionMobileList/MatchForm.tsx
|
|
6969
|
-
import React88, { useEffect as
|
|
6807
|
+
import React88, { useEffect as useEffect15, useState as useState18 } from "react";
|
|
6970
6808
|
var MatchForm2 = ({
|
|
6971
|
-
bankTransaction
|
|
6972
|
-
hardRefreshPnlOnCategorize
|
|
6809
|
+
bankTransaction
|
|
6973
6810
|
}) => {
|
|
6974
6811
|
const { match: matchBankTransaction2, isLoading } = useBankTransactionsContext();
|
|
6975
|
-
const
|
|
6976
|
-
const [selectedMatchId, setSelectedMatchId] = useState19(
|
|
6812
|
+
const [selectedMatchId, setSelectedMatchId] = useState18(
|
|
6977
6813
|
isAlreadyMatched(bankTransaction)
|
|
6978
6814
|
);
|
|
6979
|
-
const [formError, setFormError] =
|
|
6980
|
-
const [showRetry, setShowRetry] =
|
|
6981
|
-
|
|
6815
|
+
const [formError, setFormError] = useState18();
|
|
6816
|
+
const [showRetry, setShowRetry] = useState18(false);
|
|
6817
|
+
useEffect15(() => {
|
|
6982
6818
|
if (bankTransaction.error) {
|
|
6983
6819
|
setShowRetry(true);
|
|
6984
6820
|
} else if (showRetry) {
|
|
@@ -6999,8 +6835,6 @@ var MatchForm2 = ({
|
|
|
6999
6835
|
setFormError("Select an option to match the transaction");
|
|
7000
6836
|
} else if (selectedMatchId && selectedMatchId !== isAlreadyMatched(bankTransaction)) {
|
|
7001
6837
|
onMatchSubmit(selectedMatchId);
|
|
7002
|
-
if (hardRefreshPnlOnCategorize)
|
|
7003
|
-
refetch();
|
|
7004
6838
|
}
|
|
7005
6839
|
return;
|
|
7006
6840
|
};
|
|
@@ -7027,20 +6861,18 @@ var MatchForm2 = ({
|
|
|
7027
6861
|
};
|
|
7028
6862
|
|
|
7029
6863
|
// src/components/BankTransactionMobileList/SplitForm.tsx
|
|
7030
|
-
import React89, { useEffect as
|
|
6864
|
+
import React89, { useEffect as useEffect16, useState as useState19 } from "react";
|
|
7031
6865
|
import classNames35 from "classnames";
|
|
7032
6866
|
var SplitForm = ({
|
|
7033
|
-
bankTransaction
|
|
7034
|
-
hardRefreshPnlOnCategorize
|
|
6867
|
+
bankTransaction
|
|
7035
6868
|
}) => {
|
|
7036
6869
|
const {
|
|
7037
6870
|
categorize: categorizeBankTransaction2,
|
|
7038
6871
|
isLoading,
|
|
7039
6872
|
error
|
|
7040
6873
|
} = useBankTransactionsContext();
|
|
7041
|
-
const { refetch } = useProfitAndLossLTM();
|
|
7042
6874
|
const defaultCategory = bankTransaction.category || hasSuggestions(bankTransaction.categorization_flow) && bankTransaction.categorization_flow?.suggestions?.[0];
|
|
7043
|
-
const [rowState, updateRowState] =
|
|
6875
|
+
const [rowState, updateRowState] = useState19({
|
|
7044
6876
|
splits: bankTransaction.category?.entries ? bankTransaction.category?.entries.map((c) => {
|
|
7045
6877
|
return {
|
|
7046
6878
|
amount: c.amount || 0,
|
|
@@ -7062,9 +6894,9 @@ var SplitForm = ({
|
|
|
7062
6894
|
description: "",
|
|
7063
6895
|
file: void 0
|
|
7064
6896
|
});
|
|
7065
|
-
const [formError, setFormError] =
|
|
7066
|
-
const [showRetry, setShowRetry] =
|
|
7067
|
-
|
|
6897
|
+
const [formError, setFormError] = useState19();
|
|
6898
|
+
const [showRetry, setShowRetry] = useState19(false);
|
|
6899
|
+
useEffect16(() => {
|
|
7068
6900
|
if (bankTransaction.error) {
|
|
7069
6901
|
setShowRetry(true);
|
|
7070
6902
|
}
|
|
@@ -7162,8 +6994,6 @@ var SplitForm = ({
|
|
|
7162
6994
|
},
|
|
7163
6995
|
true
|
|
7164
6996
|
);
|
|
7165
|
-
if (hardRefreshPnlOnCategorize)
|
|
7166
|
-
refetch();
|
|
7167
6997
|
};
|
|
7168
6998
|
return /* @__PURE__ */ React89.createElement("div", null, /* @__PURE__ */ React89.createElement(Text, { weight: "bold" /* bold */, size: "sm" /* sm */ }, "Split transaction"), /* @__PURE__ */ React89.createElement("div", { className: "Layer__bank-transactions__table-cell__header" }, /* @__PURE__ */ React89.createElement(Text, { size: "sm" /* sm */ }, "Category"), /* @__PURE__ */ React89.createElement(Text, { size: "sm" /* sm */ }, "Amount")), /* @__PURE__ */ React89.createElement("div", { className: "Layer__bank-transactions__splits-inputs" }, rowState.splits.map((split, index) => /* @__PURE__ */ React89.createElement(
|
|
7169
6999
|
"div",
|
|
@@ -7233,30 +7063,28 @@ var SplitForm = ({
|
|
|
7233
7063
|
|
|
7234
7064
|
// src/components/BankTransactionMobileList/SplitAndMatchForm.tsx
|
|
7235
7065
|
var SplitAndMatchForm = ({
|
|
7236
|
-
bankTransaction
|
|
7237
|
-
hardRefreshPnlOnCategorize
|
|
7066
|
+
bankTransaction
|
|
7238
7067
|
}) => {
|
|
7239
7068
|
const anyMatch = hasMatch(bankTransaction);
|
|
7240
|
-
const [formType, setFormType] =
|
|
7069
|
+
const [formType, setFormType] = useState20(
|
|
7241
7070
|
bankTransaction.category ? "categorize" /* categorize */ : anyMatch ? "match" /* match */ : "categorize" /* categorize */
|
|
7242
7071
|
);
|
|
7243
|
-
return /* @__PURE__ */ React90.createElement("div", { className: "Layer__bank-transaction-mobile-list-item__split-and-match-form" }, formType === "categorize" /* categorize */ && /* @__PURE__ */ React90.createElement(SplitForm, { bankTransaction
|
|
7072
|
+
return /* @__PURE__ */ React90.createElement("div", { className: "Layer__bank-transaction-mobile-list-item__split-and-match-form" }, formType === "categorize" /* categorize */ && /* @__PURE__ */ React90.createElement(SplitForm, { bankTransaction }), formType === "match" /* match */ && /* @__PURE__ */ React90.createElement(MatchForm2, { bankTransaction }), anyMatch && formType === "match" /* match */ ? /* @__PURE__ */ React90.createElement("div", { className: "Layer__bank-transaction-mobile-list-item__switch-form-btns" }, /* @__PURE__ */ React90.createElement(TextButton, { onClick: () => setFormType("categorize" /* categorize */) }, "or split transaction")) : null, anyMatch && formType === "categorize" /* categorize */ ? /* @__PURE__ */ React90.createElement("div", { className: "Layer__bank-transaction-mobile-list-item__switch-form-btns" }, /* @__PURE__ */ React90.createElement(TextButton, { onClick: () => setFormType("match" /* match */) }, "or find match")) : null);
|
|
7244
7073
|
};
|
|
7245
7074
|
|
|
7246
7075
|
// src/components/BankTransactionMobileList/BankTransactionMobileForms.tsx
|
|
7247
7076
|
var BankTransactionMobileForms = ({
|
|
7248
7077
|
purpose,
|
|
7249
|
-
bankTransaction
|
|
7250
|
-
hardRefreshPnlOnCategorize
|
|
7078
|
+
bankTransaction
|
|
7251
7079
|
}) => {
|
|
7252
7080
|
const getContent = () => {
|
|
7253
7081
|
switch (purpose) {
|
|
7254
7082
|
case "business":
|
|
7255
|
-
return /* @__PURE__ */ React91.createElement(BusinessForm, { bankTransaction
|
|
7083
|
+
return /* @__PURE__ */ React91.createElement(BusinessForm, { bankTransaction });
|
|
7256
7084
|
case "personal":
|
|
7257
|
-
return /* @__PURE__ */ React91.createElement(PersonalForm, { bankTransaction
|
|
7085
|
+
return /* @__PURE__ */ React91.createElement(PersonalForm, { bankTransaction });
|
|
7258
7086
|
case "more":
|
|
7259
|
-
return /* @__PURE__ */ React91.createElement(SplitAndMatchForm, { bankTransaction
|
|
7087
|
+
return /* @__PURE__ */ React91.createElement(SplitAndMatchForm, { bankTransaction });
|
|
7260
7088
|
default:
|
|
7261
7089
|
return null;
|
|
7262
7090
|
}
|
|
@@ -7265,9 +7093,9 @@ var BankTransactionMobileForms = ({
|
|
|
7265
7093
|
};
|
|
7266
7094
|
|
|
7267
7095
|
// src/components/BankTransactionMobileList/TransactionToOpenContext.ts
|
|
7268
|
-
import { createContext as createContext5, useState as
|
|
7096
|
+
import { createContext as createContext5, useState as useState21 } from "react";
|
|
7269
7097
|
var useTransactionToOpen = () => {
|
|
7270
|
-
const [transactionIdToOpen, setTransactionIdToOpen] =
|
|
7098
|
+
const [transactionIdToOpen, setTransactionIdToOpen] = useState21(void 0);
|
|
7271
7099
|
const clearTransactionIdToOpen = () => setTransactionIdToOpen(void 0);
|
|
7272
7100
|
return {
|
|
7273
7101
|
transactionIdToOpen,
|
|
@@ -7300,8 +7128,7 @@ var BankTransactionMobileListItem = ({
|
|
|
7300
7128
|
removeTransaction,
|
|
7301
7129
|
editable,
|
|
7302
7130
|
mode,
|
|
7303
|
-
initialLoad
|
|
7304
|
-
hardRefreshPnlOnCategorize = false
|
|
7131
|
+
initialLoad
|
|
7305
7132
|
}) => {
|
|
7306
7133
|
const {
|
|
7307
7134
|
transactionIdToOpen,
|
|
@@ -7315,14 +7142,14 @@ var BankTransactionMobileListItem = ({
|
|
|
7315
7142
|
setHeadingHeight(height2);
|
|
7316
7143
|
});
|
|
7317
7144
|
const itemRef = useRef12(null);
|
|
7318
|
-
const [removeAnim, setRemoveAnim] =
|
|
7319
|
-
const [purpose, setPurpose] =
|
|
7145
|
+
const [removeAnim, setRemoveAnim] = useState22(false);
|
|
7146
|
+
const [purpose, setPurpose] = useState22(
|
|
7320
7147
|
bankTransaction.category ? bankTransaction.categorization_status === "SPLIT" /* SPLIT */ ? "more" /* more */ : "business" /* business */ : hasMatch(bankTransaction) ? "more" /* more */ : "business" /* business */
|
|
7321
7148
|
);
|
|
7322
|
-
const [open, setOpen] =
|
|
7323
|
-
const [showComponent, setShowComponent] =
|
|
7324
|
-
const [height, setHeight] =
|
|
7325
|
-
const [headingHeight, setHeadingHeight] =
|
|
7149
|
+
const [open, setOpen] = useState22(false);
|
|
7150
|
+
const [showComponent, setShowComponent] = useState22(!initialLoad);
|
|
7151
|
+
const [height, setHeight] = useState22(0);
|
|
7152
|
+
const [headingHeight, setHeadingHeight] = useState22(63);
|
|
7326
7153
|
const openNext = () => {
|
|
7327
7154
|
if (editable && itemRef.current && itemRef.current.nextSibling) {
|
|
7328
7155
|
const txId = itemRef.current.nextSibling.getAttribute(
|
|
@@ -7333,13 +7160,13 @@ var BankTransactionMobileListItem = ({
|
|
|
7333
7160
|
}
|
|
7334
7161
|
}
|
|
7335
7162
|
};
|
|
7336
|
-
|
|
7163
|
+
useEffect17(() => {
|
|
7337
7164
|
if (transactionIdToOpen && transactionIdToOpen === bankTransaction.id) {
|
|
7338
7165
|
setOpen(true);
|
|
7339
7166
|
clearTransactionIdToOpen();
|
|
7340
7167
|
}
|
|
7341
7168
|
}, [transactionIdToOpen]);
|
|
7342
|
-
|
|
7169
|
+
useEffect17(() => {
|
|
7343
7170
|
if (!removeAnim && bankTransaction.recently_categorized) {
|
|
7344
7171
|
if (editable) {
|
|
7345
7172
|
setRemoveAnim(true);
|
|
@@ -7363,7 +7190,7 @@ var BankTransactionMobileListItem = ({
|
|
|
7363
7190
|
setOpen(false);
|
|
7364
7191
|
setHeight(0);
|
|
7365
7192
|
};
|
|
7366
|
-
|
|
7193
|
+
useEffect17(() => {
|
|
7367
7194
|
if (initialLoad) {
|
|
7368
7195
|
const timeoutId = setTimeout(() => {
|
|
7369
7196
|
setShowComponent(true);
|
|
@@ -7373,7 +7200,7 @@ var BankTransactionMobileListItem = ({
|
|
|
7373
7200
|
setShowComponent(true);
|
|
7374
7201
|
}
|
|
7375
7202
|
}, []);
|
|
7376
|
-
|
|
7203
|
+
useEffect17(() => {
|
|
7377
7204
|
if (editable && bankTransaction.recently_categorized) {
|
|
7378
7205
|
setTimeout(() => {
|
|
7379
7206
|
removeTransaction(bankTransaction);
|
|
@@ -7451,8 +7278,7 @@ var BankTransactionMobileListItem = ({
|
|
|
7451
7278
|
BankTransactionMobileForms,
|
|
7452
7279
|
{
|
|
7453
7280
|
purpose,
|
|
7454
|
-
bankTransaction
|
|
7455
|
-
hardRefreshPnlOnCategorize
|
|
7281
|
+
bankTransaction
|
|
7456
7282
|
}
|
|
7457
7283
|
)
|
|
7458
7284
|
)
|
|
@@ -7465,8 +7291,7 @@ var BankTransactionMobileList = ({
|
|
|
7465
7291
|
removeTransaction,
|
|
7466
7292
|
editable,
|
|
7467
7293
|
initialLoad,
|
|
7468
|
-
mode
|
|
7469
|
-
hardRefreshPnlOnCategorize
|
|
7294
|
+
mode
|
|
7470
7295
|
}) => {
|
|
7471
7296
|
const transactionToOpenContextData = useTransactionToOpen();
|
|
7472
7297
|
return /* @__PURE__ */ React93.createElement(TransactionToOpenContext.Provider, { value: transactionToOpenContextData }, /* @__PURE__ */ React93.createElement("ul", { className: "Layer__bank-transactions__mobile-list" }, bankTransactions?.map(
|
|
@@ -7479,8 +7304,7 @@ var BankTransactionMobileList = ({
|
|
|
7479
7304
|
bankTransaction,
|
|
7480
7305
|
editable,
|
|
7481
7306
|
removeTransaction,
|
|
7482
|
-
initialLoad
|
|
7483
|
-
hardRefreshPnlOnCategorize
|
|
7307
|
+
initialLoad
|
|
7484
7308
|
}
|
|
7485
7309
|
)
|
|
7486
7310
|
)));
|
|
@@ -7517,15 +7341,31 @@ var SkeletonTableLoader = ({
|
|
|
7517
7341
|
height = 20,
|
|
7518
7342
|
width = 100
|
|
7519
7343
|
}) => {
|
|
7520
|
-
return /* @__PURE__ */ React95.createElement("tbody", { className: "Layer__skeleton-table-body__loader" }, Array.from({ length: rows }).map((_, rowIndex) => /* @__PURE__ */ React95.createElement("tr", { key: rowIndex }, cols.map((col, colIndex) =>
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7344
|
+
return /* @__PURE__ */ React95.createElement("tbody", { className: "Layer__skeleton-table-body__loader" }, Array.from({ length: rows }).map((_, rowIndex) => /* @__PURE__ */ React95.createElement("tr", { key: rowIndex }, cols.map((col, colIndex) => {
|
|
7345
|
+
const trim = col.trimLastXRows && rowIndex >= col.trimLastXRows - 1 ? (rowIndex - col.trimLastXRows + 1) * 10 : 0;
|
|
7346
|
+
return /* @__PURE__ */ React95.createElement(
|
|
7347
|
+
"td",
|
|
7348
|
+
{
|
|
7349
|
+
key: colIndex,
|
|
7350
|
+
colSpan: col.colSpan,
|
|
7351
|
+
className: "Layer__skeleton-loader__row"
|
|
7352
|
+
},
|
|
7353
|
+
col.colComponent ? col.colComponent : col.parts && col.parts > 1 ? /* @__PURE__ */ React95.createElement("span", { className: "Layer__skeleton-loader__row__group" }, [...Array(col.parts)].map((_part, partIndex) => /* @__PURE__ */ React95.createElement(
|
|
7354
|
+
SkeletonLoader,
|
|
7355
|
+
{
|
|
7356
|
+
key: `part-${partIndex}`,
|
|
7357
|
+
width: "100%",
|
|
7358
|
+
height: `${height}px`
|
|
7359
|
+
}
|
|
7360
|
+
))) : /* @__PURE__ */ React95.createElement(
|
|
7361
|
+
SkeletonLoader,
|
|
7362
|
+
{
|
|
7363
|
+
width: `${width - trim}%`,
|
|
7364
|
+
height: `${height}px`
|
|
7365
|
+
}
|
|
7366
|
+
)
|
|
7367
|
+
);
|
|
7368
|
+
}))));
|
|
7529
7369
|
};
|
|
7530
7370
|
|
|
7531
7371
|
// src/components/BankTransactionsLoader/BankTransactionsLoader.tsx
|
|
@@ -7565,8 +7405,11 @@ var BankTransactionsLoader = ({
|
|
|
7565
7405
|
return /* @__PURE__ */ React96.createElement(
|
|
7566
7406
|
SkeletonTableLoader,
|
|
7567
7407
|
{
|
|
7568
|
-
rows:
|
|
7569
|
-
cols: isLoading ? [
|
|
7408
|
+
rows: 6,
|
|
7409
|
+
cols: isLoading ? [
|
|
7410
|
+
{ colSpan: 4, trimLastXRows: 3 },
|
|
7411
|
+
{ colSpan: 1, parts: 2 }
|
|
7412
|
+
] : [
|
|
7570
7413
|
{ colSpan: 4 },
|
|
7571
7414
|
{ colSpan: 1, colComponent: inactiveBankTransactionsActions }
|
|
7572
7415
|
],
|
|
@@ -7620,7 +7463,6 @@ var BankTransactionsTable = ({
|
|
|
7620
7463
|
removeTransaction,
|
|
7621
7464
|
showDescriptions = false,
|
|
7622
7465
|
showReceiptUploads = false,
|
|
7623
|
-
hardRefreshPnlOnCategorize = false,
|
|
7624
7466
|
stringOverrides,
|
|
7625
7467
|
isSyncing = false,
|
|
7626
7468
|
page,
|
|
@@ -7635,7 +7477,6 @@ var BankTransactionsTable = ({
|
|
|
7635
7477
|
},
|
|
7636
7478
|
/* @__PURE__ */ React98.createElement("thead", null, /* @__PURE__ */ React98.createElement("tr", null, /* @__PURE__ */ React98.createElement("th", { className: "Layer__table-header Layer__bank-transactions__date-col" }, stringOverrides?.transactionsTable?.dateColumnHeaderText || "Date"), /* @__PURE__ */ React98.createElement("th", { className: "Layer__table-header Layer__bank-transactions__tx-col" }, stringOverrides?.transactionsTable?.transactionColumnHeaderText || "Transaction"), /* @__PURE__ */ React98.createElement("th", { className: "Layer__table-header Layer__bank-transactions__account-col" }, stringOverrides?.transactionsTable?.accountColumnHeaderText || "Account"), /* @__PURE__ */ React98.createElement("th", { className: "Layer__table-header Layer__table-cell--amount Layer__table-cell__amount-col" }, stringOverrides?.transactionsTable?.amountColumnHeaderText || "Amount"), categorizeView && editable ? /* @__PURE__ */ React98.createElement("th", { className: "Layer__table-header Layer__table-header--primary Layer__table-cell__category-col" }, stringOverrides?.transactionsTable?.categorizeColumnHeaderText || "Categorize") : /* @__PURE__ */ React98.createElement("th", { className: "Layer__table-header Layer__table-cell__category-col" }, stringOverrides?.transactionsTable?.categoryColumnHeaderText || "Category"))),
|
|
7637
7479
|
isLoading && page && page === 1 ? /* @__PURE__ */ React98.createElement(BankTransactionsLoader, { isLoading: true }) : null,
|
|
7638
|
-
!isLoading && isSyncing && page && page === 1 ? /* @__PURE__ */ React98.createElement(BankTransactionsLoader, { isLoading: false }) : null,
|
|
7639
7480
|
/* @__PURE__ */ React98.createElement("tbody", null, !isLoading && bankTransactions?.map(
|
|
7640
7481
|
(bankTransaction, index) => /* @__PURE__ */ React98.createElement(
|
|
7641
7482
|
BankTransactionRow,
|
|
@@ -7651,7 +7492,6 @@ var BankTransactionsTable = ({
|
|
|
7651
7492
|
containerWidth,
|
|
7652
7493
|
showDescriptions,
|
|
7653
7494
|
showReceiptUploads,
|
|
7654
|
-
hardRefreshPnlOnCategorize,
|
|
7655
7495
|
stringOverrides: stringOverrides?.bankTransactionCTAs
|
|
7656
7496
|
}
|
|
7657
7497
|
)
|
|
@@ -7710,7 +7550,7 @@ var ErrorBoundary = class extends Component {
|
|
|
7710
7550
|
import React102 from "react";
|
|
7711
7551
|
|
|
7712
7552
|
// src/hooks/usePagination/usePagination.ts
|
|
7713
|
-
import { useMemo as
|
|
7553
|
+
import { useMemo as useMemo5 } from "react";
|
|
7714
7554
|
var DOTS = "...";
|
|
7715
7555
|
var usePagination = ({
|
|
7716
7556
|
totalCount,
|
|
@@ -7718,7 +7558,7 @@ var usePagination = ({
|
|
|
7718
7558
|
siblingCount = 1,
|
|
7719
7559
|
currentPage
|
|
7720
7560
|
}) => {
|
|
7721
|
-
const paginationRange =
|
|
7561
|
+
const paginationRange = useMemo5(() => {
|
|
7722
7562
|
const totalPageCount = Math.ceil(totalCount / pageSize);
|
|
7723
7563
|
const totalPageNumbers = siblingCount + 5;
|
|
7724
7564
|
if (totalPageNumbers >= totalPageCount) {
|
|
@@ -7869,7 +7709,7 @@ var Pagination = ({
|
|
|
7869
7709
|
};
|
|
7870
7710
|
|
|
7871
7711
|
// src/components/BankTransactions/BankTransactionsHeader.tsx
|
|
7872
|
-
import React108, { useState as
|
|
7712
|
+
import React108, { useState as useState25 } from "react";
|
|
7873
7713
|
|
|
7874
7714
|
// src/icons/DownloadCloud.tsx
|
|
7875
7715
|
import * as React103 from "react";
|
|
@@ -7914,7 +7754,7 @@ var DownloadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React103.create
|
|
|
7914
7754
|
var DownloadCloud_default = DownloadCloud;
|
|
7915
7755
|
|
|
7916
7756
|
// src/utils/business.ts
|
|
7917
|
-
import { differenceInCalendarMonths, parseISO as parseISO11, startOfMonth
|
|
7757
|
+
import { differenceInCalendarMonths, parseISO as parseISO11, startOfMonth } from "date-fns";
|
|
7918
7758
|
var getActivationDate = (business) => {
|
|
7919
7759
|
try {
|
|
7920
7760
|
if (business && business.activation_at) {
|
|
@@ -7928,7 +7768,7 @@ var getActivationDate = (business) => {
|
|
|
7928
7768
|
var getEarliestDateToBrowse = (business) => {
|
|
7929
7769
|
const activationDate = getActivationDate(business);
|
|
7930
7770
|
if (activationDate) {
|
|
7931
|
-
return
|
|
7771
|
+
return startOfMonth(activationDate);
|
|
7932
7772
|
}
|
|
7933
7773
|
return;
|
|
7934
7774
|
};
|
|
@@ -7940,11 +7780,11 @@ var isDateAllowedToBrowse = (date, business) => {
|
|
|
7940
7780
|
if (!activationDate) {
|
|
7941
7781
|
return true;
|
|
7942
7782
|
}
|
|
7943
|
-
return differenceInCalendarMonths(
|
|
7783
|
+
return differenceInCalendarMonths(startOfMonth(date), activationDate) >= 0;
|
|
7944
7784
|
};
|
|
7945
7785
|
|
|
7946
7786
|
// src/components/DatePicker/DatePicker.tsx
|
|
7947
|
-
import React105, { useEffect as
|
|
7787
|
+
import React105, { useEffect as useEffect18, useRef as useRef13, useState as useState23 } from "react";
|
|
7948
7788
|
import ReactDatePicker from "react-datepicker";
|
|
7949
7789
|
|
|
7950
7790
|
// src/components/DatePicker/DatePickerOptions.tsx
|
|
@@ -7953,7 +7793,7 @@ import {
|
|
|
7953
7793
|
endOfMonth,
|
|
7954
7794
|
endOfQuarter,
|
|
7955
7795
|
endOfYear,
|
|
7956
|
-
startOfMonth as
|
|
7796
|
+
startOfMonth as startOfMonth2,
|
|
7957
7797
|
startOfQuarter,
|
|
7958
7798
|
startOfYear,
|
|
7959
7799
|
subMonths,
|
|
@@ -7974,7 +7814,7 @@ var DatePickerOptions = ({
|
|
|
7974
7814
|
key: option,
|
|
7975
7815
|
onClick: () => {
|
|
7976
7816
|
setSelectedDate([
|
|
7977
|
-
|
|
7817
|
+
startOfMonth2(/* @__PURE__ */ new Date()),
|
|
7978
7818
|
endOfMonth(/* @__PURE__ */ new Date())
|
|
7979
7819
|
]);
|
|
7980
7820
|
}
|
|
@@ -7988,7 +7828,7 @@ var DatePickerOptions = ({
|
|
|
7988
7828
|
key: option,
|
|
7989
7829
|
onClick: () => {
|
|
7990
7830
|
setSelectedDate([
|
|
7991
|
-
|
|
7831
|
+
startOfMonth2(subMonths(/* @__PURE__ */ new Date(), 1)),
|
|
7992
7832
|
endOfMonth(subMonths(/* @__PURE__ */ new Date(), 1))
|
|
7993
7833
|
]);
|
|
7994
7834
|
}
|
|
@@ -8108,27 +7948,27 @@ var DatePicker = ({
|
|
|
8108
7948
|
...props
|
|
8109
7949
|
}) => {
|
|
8110
7950
|
const pickerRef = useRef13(null);
|
|
8111
|
-
const [updatePickerDate, setPickerDate] =
|
|
8112
|
-
const [selectedDates, setSelectedDates] =
|
|
7951
|
+
const [updatePickerDate, setPickerDate] = useState23(false);
|
|
7952
|
+
const [selectedDates, setSelectedDates] = useState23(selected);
|
|
8113
7953
|
const { isDesktop } = useSizeClass();
|
|
8114
|
-
const [startDate, setStartDate] =
|
|
7954
|
+
const [startDate, setStartDate] = useState23(
|
|
8115
7955
|
getDefaultRangeDate("start", mode, selected) ?? /* @__PURE__ */ new Date()
|
|
8116
7956
|
);
|
|
8117
|
-
const [endDate, setEndDate] =
|
|
7957
|
+
const [endDate, setEndDate] = useState23(
|
|
8118
7958
|
getDefaultRangeDate("end", mode, selected)
|
|
8119
7959
|
);
|
|
8120
|
-
|
|
7960
|
+
useEffect18(() => {
|
|
8121
7961
|
try {
|
|
8122
7962
|
setPickerDate(true);
|
|
8123
|
-
if (!isRangeMode(mode) && selected !== selectedDates) {
|
|
7963
|
+
if (!isRangeMode(mode) && selected?.getTime() !== selectedDates?.getTime()) {
|
|
8124
7964
|
setSelectedDates(selected);
|
|
8125
7965
|
return;
|
|
8126
7966
|
}
|
|
8127
7967
|
if (isRangeMode(mode) && Array.isArray(selected)) {
|
|
8128
|
-
if (startDate !== selected[0]) {
|
|
7968
|
+
if (startDate?.getTime() !== selected[0]?.getTime()) {
|
|
8129
7969
|
setStartDate(selected[0]);
|
|
8130
7970
|
}
|
|
8131
|
-
if (endDate !== selected[1]) {
|
|
7971
|
+
if (endDate?.getTime() !== selected[1]?.getTime()) {
|
|
8132
7972
|
setEndDate(selected[1]);
|
|
8133
7973
|
}
|
|
8134
7974
|
}
|
|
@@ -8136,14 +7976,14 @@ var DatePicker = ({
|
|
|
8136
7976
|
return;
|
|
8137
7977
|
}
|
|
8138
7978
|
}, [selected]);
|
|
8139
|
-
|
|
8140
|
-
if (onChange && !updatePickerDate) {
|
|
7979
|
+
useEffect18(() => {
|
|
7980
|
+
if (onChange && (!isRangeMode(mode) || isRangeMode(mode) && !updatePickerDate)) {
|
|
8141
7981
|
onChange(selectedDates);
|
|
8142
7982
|
} else {
|
|
8143
7983
|
setPickerDate(false);
|
|
8144
7984
|
}
|
|
8145
7985
|
}, [selectedDates]);
|
|
8146
|
-
|
|
7986
|
+
useEffect18(() => {
|
|
8147
7987
|
if (isRangeMode(mode)) {
|
|
8148
7988
|
setSelectedDates([startDate, endDate]);
|
|
8149
7989
|
}
|
|
@@ -8320,7 +8160,7 @@ var DatePicker = ({
|
|
|
8320
8160
|
};
|
|
8321
8161
|
|
|
8322
8162
|
// src/components/Tabs/Tabs.tsx
|
|
8323
|
-
import React107, { useEffect as
|
|
8163
|
+
import React107, { useEffect as useEffect19, useState as useState24 } from "react";
|
|
8324
8164
|
|
|
8325
8165
|
// src/components/Tabs/Tab.tsx
|
|
8326
8166
|
import React106 from "react";
|
|
@@ -8366,9 +8206,9 @@ var Tab = ({
|
|
|
8366
8206
|
// src/components/Tabs/Tabs.tsx
|
|
8367
8207
|
import classNames40 from "classnames";
|
|
8368
8208
|
var Tabs = ({ name, options, selected, onChange }) => {
|
|
8369
|
-
const [initialized, setInitialized] =
|
|
8370
|
-
const [thumbPos, setThumbPos] =
|
|
8371
|
-
const [currentWidth, setCurrentWidth] =
|
|
8209
|
+
const [initialized, setInitialized] = useState24(false);
|
|
8210
|
+
const [thumbPos, setThumbPos] = useState24({ left: 0, width: 0 });
|
|
8211
|
+
const [currentWidth, setCurrentWidth] = useState24(0);
|
|
8372
8212
|
const selectedValue = selected || options[0].value;
|
|
8373
8213
|
const baseClassName = classNames40(
|
|
8374
8214
|
"Layer__tabs",
|
|
@@ -8402,7 +8242,7 @@ var Tabs = ({ name, options, selected, onChange }) => {
|
|
|
8402
8242
|
shift2 = shift2 + 1.5;
|
|
8403
8243
|
setThumbPos({ left: shift2, width });
|
|
8404
8244
|
};
|
|
8405
|
-
|
|
8245
|
+
useEffect19(() => {
|
|
8406
8246
|
const selectedIndex = getSelectedIndex();
|
|
8407
8247
|
updateSelectPosition(selectedIndex);
|
|
8408
8248
|
setTimeout(() => {
|
|
@@ -8435,12 +8275,12 @@ var Tabs = ({ name, options, selected, onChange }) => {
|
|
|
8435
8275
|
|
|
8436
8276
|
// src/components/BankTransactions/BankTransactionsHeader.tsx
|
|
8437
8277
|
import classNames41 from "classnames";
|
|
8438
|
-
import { endOfMonth as endOfMonth2, startOfMonth as
|
|
8278
|
+
import { endOfMonth as endOfMonth2, startOfMonth as startOfMonth3 } from "date-fns";
|
|
8439
8279
|
var DownloadButton = ({
|
|
8440
8280
|
downloadButtonTextOverride
|
|
8441
8281
|
}) => {
|
|
8442
8282
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
8443
|
-
const [requestFailed, setRequestFailed] =
|
|
8283
|
+
const [requestFailed, setRequestFailed] = useState25(false);
|
|
8444
8284
|
const handleClick = async () => {
|
|
8445
8285
|
const currentYear = (/* @__PURE__ */ new Date()).getFullYear().toString();
|
|
8446
8286
|
const getBankTransactionsCsv2 = Layer.getBankTransactionsCsv(
|
|
@@ -8531,7 +8371,7 @@ var BankTransactionsHeader = ({
|
|
|
8531
8371
|
onChange: (date) => {
|
|
8532
8372
|
if (!Array.isArray(date)) {
|
|
8533
8373
|
setDateRange({
|
|
8534
|
-
startDate:
|
|
8374
|
+
startDate: startOfMonth3(date),
|
|
8535
8375
|
endDate: endOfMonth2(date)
|
|
8536
8376
|
});
|
|
8537
8377
|
}
|
|
@@ -8641,7 +8481,7 @@ var DataStates = ({
|
|
|
8641
8481
|
};
|
|
8642
8482
|
|
|
8643
8483
|
// src/components/BankTransactions/BankTransactions.tsx
|
|
8644
|
-
import { endOfMonth as endOfMonth3, parseISO as parseISO12, startOfMonth as
|
|
8484
|
+
import { endOfMonth as endOfMonth3, parseISO as parseISO12, startOfMonth as startOfMonth4 } from "date-fns";
|
|
8645
8485
|
var COMPONENT_NAME2 = "bank-transactions";
|
|
8646
8486
|
var TEST_EMPTY_STATE = false;
|
|
8647
8487
|
var POLL_INTERVAL = 1e4;
|
|
@@ -8663,17 +8503,16 @@ var BankTransactionsContent = ({
|
|
|
8663
8503
|
mode = "self-serve",
|
|
8664
8504
|
showDescriptions = false,
|
|
8665
8505
|
showReceiptUploads = false,
|
|
8666
|
-
hardRefreshPnlOnCategorize = false,
|
|
8667
8506
|
monthlyView = false,
|
|
8668
8507
|
mobileComponent,
|
|
8669
8508
|
filters: inputFilters,
|
|
8670
8509
|
hideHeader = false,
|
|
8671
8510
|
stringOverrides
|
|
8672
8511
|
}) => {
|
|
8673
|
-
const [currentPage, setCurrentPage] =
|
|
8674
|
-
const [initialLoad, setInitialLoad] =
|
|
8675
|
-
const [dateRange, setDateRange] =
|
|
8676
|
-
startDate:
|
|
8512
|
+
const [currentPage, setCurrentPage] = useState26(1);
|
|
8513
|
+
const [initialLoad, setInitialLoad] = useState26(true);
|
|
8514
|
+
const [dateRange, setDateRange] = useState26({
|
|
8515
|
+
startDate: startOfMonth4(/* @__PURE__ */ new Date()),
|
|
8677
8516
|
endDate: endOfMonth3(/* @__PURE__ */ new Date())
|
|
8678
8517
|
});
|
|
8679
8518
|
const categorizeView = categorizationEnabled(mode);
|
|
@@ -8693,23 +8532,23 @@ var BankTransactionsContent = ({
|
|
|
8693
8532
|
removeAfterCategorize
|
|
8694
8533
|
} = useBankTransactionsContext();
|
|
8695
8534
|
const { data: linkedAccounts, refetchAccounts } = useLinkedAccounts();
|
|
8696
|
-
const isSyncing =
|
|
8535
|
+
const isSyncing = useMemo6(
|
|
8697
8536
|
() => Boolean(linkedAccounts?.some((item) => item.is_syncing)),
|
|
8698
8537
|
[linkedAccounts]
|
|
8699
8538
|
);
|
|
8700
|
-
const transactionsNotSynced =
|
|
8539
|
+
const transactionsNotSynced = useMemo6(
|
|
8701
8540
|
() => loadingStatus === "complete" && isSyncing && (!data || data?.length === 0),
|
|
8702
8541
|
[data, isSyncing, loadingStatus]
|
|
8703
8542
|
);
|
|
8704
8543
|
let intervalId = void 0;
|
|
8705
|
-
const [refreshTrigger, setRefreshTrigger] =
|
|
8706
|
-
|
|
8544
|
+
const [refreshTrigger, setRefreshTrigger] = useState26(-1);
|
|
8545
|
+
useEffect20(() => {
|
|
8707
8546
|
if (refreshTrigger !== -1) {
|
|
8708
8547
|
refetch();
|
|
8709
8548
|
refetchAccounts();
|
|
8710
8549
|
}
|
|
8711
8550
|
}, [refreshTrigger]);
|
|
8712
|
-
|
|
8551
|
+
useEffect20(() => {
|
|
8713
8552
|
if (isSyncing) {
|
|
8714
8553
|
intervalId = setInterval(() => {
|
|
8715
8554
|
setRefreshTrigger(Math.random());
|
|
@@ -8725,10 +8564,10 @@ var BankTransactionsContent = ({
|
|
|
8725
8564
|
}
|
|
8726
8565
|
};
|
|
8727
8566
|
}, [isSyncing, transactionsNotSynced]);
|
|
8728
|
-
|
|
8567
|
+
useEffect20(() => {
|
|
8729
8568
|
activate();
|
|
8730
8569
|
}, []);
|
|
8731
|
-
|
|
8570
|
+
useEffect20(() => {
|
|
8732
8571
|
if (JSON.stringify(inputFilters) !== JSON.stringify(filters)) {
|
|
8733
8572
|
if (!filters?.categorizationStatus && categorizeView) {
|
|
8734
8573
|
setFilters({
|
|
@@ -8755,7 +8594,7 @@ var BankTransactionsContent = ({
|
|
|
8755
8594
|
});
|
|
8756
8595
|
}
|
|
8757
8596
|
}, [inputFilters, categorizeView, mode]);
|
|
8758
|
-
|
|
8597
|
+
useEffect20(() => {
|
|
8759
8598
|
if (loadingStatus === "complete") {
|
|
8760
8599
|
const timeoutLoad = setTimeout(() => {
|
|
8761
8600
|
setInitialLoad(false);
|
|
@@ -8763,7 +8602,7 @@ var BankTransactionsContent = ({
|
|
|
8763
8602
|
return () => clearTimeout(timeoutLoad);
|
|
8764
8603
|
}
|
|
8765
8604
|
}, [loadingStatus]);
|
|
8766
|
-
const bankTransactions = TEST_EMPTY_STATE ? [] :
|
|
8605
|
+
const bankTransactions = TEST_EMPTY_STATE ? [] : useMemo6(() => {
|
|
8767
8606
|
if (monthlyView) {
|
|
8768
8607
|
return data?.filter(
|
|
8769
8608
|
(x) => parseISO12(x.date) >= dateRange.startDate && parseISO12(x.date) <= dateRange.endDate
|
|
@@ -8779,10 +8618,10 @@ var BankTransactionsContent = ({
|
|
|
8779
8618
|
});
|
|
8780
8619
|
setCurrentPage(1);
|
|
8781
8620
|
};
|
|
8782
|
-
const [shiftStickyHeader, setShiftStickyHeader] =
|
|
8621
|
+
const [shiftStickyHeader, setShiftStickyHeader] = useState26(0);
|
|
8783
8622
|
const debounceShiftStickyHeader = debounce(setShiftStickyHeader, 500);
|
|
8784
|
-
const [listView, setListView] =
|
|
8785
|
-
const [containerWidth, setContainerWidth] =
|
|
8623
|
+
const [listView, setListView] = useState26(false);
|
|
8624
|
+
const [containerWidth, setContainerWidth] = useState26(0);
|
|
8786
8625
|
const debounceContainerWidth = debounce(setContainerWidth, 500);
|
|
8787
8626
|
const removeTransaction = (bankTransaction) => removeAfterCategorize(bankTransaction);
|
|
8788
8627
|
const containerRef = useElementSize((_el, _en, size) => {
|
|
@@ -8846,7 +8685,6 @@ var BankTransactionsContent = ({
|
|
|
8846
8685
|
showDescriptions,
|
|
8847
8686
|
showReceiptUploads,
|
|
8848
8687
|
page: currentPage,
|
|
8849
|
-
hardRefreshPnlOnCategorize,
|
|
8850
8688
|
stringOverrides,
|
|
8851
8689
|
lastPage: isLastPage,
|
|
8852
8690
|
onRefresh: refetch
|
|
@@ -8860,7 +8698,6 @@ var BankTransactionsContent = ({
|
|
|
8860
8698
|
editable,
|
|
8861
8699
|
removeTransaction,
|
|
8862
8700
|
containerWidth,
|
|
8863
|
-
hardRefreshPnlOnCategorize,
|
|
8864
8701
|
stringOverrides: stringOverrides?.bankTransactionCTAs
|
|
8865
8702
|
}
|
|
8866
8703
|
) : null,
|
|
@@ -8871,8 +8708,7 @@ var BankTransactionsContent = ({
|
|
|
8871
8708
|
editable,
|
|
8872
8709
|
mode,
|
|
8873
8710
|
removeTransaction,
|
|
8874
|
-
initialLoad
|
|
8875
|
-
hardRefreshPnlOnCategorize
|
|
8711
|
+
initialLoad
|
|
8876
8712
|
}
|
|
8877
8713
|
) : null,
|
|
8878
8714
|
listView && isLoading ? /* @__PURE__ */ React111.createElement("div", { className: "Layer__bank-transactions__list-loader" }, /* @__PURE__ */ React111.createElement(Loader2, null)) : null,
|
|
@@ -8905,16 +8741,16 @@ var BankTransactionsContent = ({
|
|
|
8905
8741
|
import React112 from "react";
|
|
8906
8742
|
|
|
8907
8743
|
// src/hooks/useQuickbooks/useQuickbooks.ts
|
|
8908
|
-
import { useEffect as
|
|
8744
|
+
import { useEffect as useEffect21, useRef as useRef14, useState as useState27 } from "react";
|
|
8909
8745
|
var DEBUG2 = true;
|
|
8910
8746
|
var useQuickbooks = () => {
|
|
8911
8747
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
8912
|
-
const [isSyncingFromQuickbooks, setIsSyncingFromQuickbooks] =
|
|
8913
|
-
const [quickbooksIsLinked, setQuickbooksIsLinked] =
|
|
8748
|
+
const [isSyncingFromQuickbooks, setIsSyncingFromQuickbooks] = useState27(false);
|
|
8749
|
+
const [quickbooksIsLinked, setQuickbooksIsLinked] = useState27(
|
|
8914
8750
|
null
|
|
8915
8751
|
);
|
|
8916
8752
|
const syncStatusIntervalRef = useRef14(null);
|
|
8917
|
-
|
|
8753
|
+
useEffect21(() => {
|
|
8918
8754
|
if (isSyncingFromQuickbooks && syncStatusIntervalRef.current === null) {
|
|
8919
8755
|
const interval = setInterval(() => fetchIsSyncingFromQuickbooks(), 2e3);
|
|
8920
8756
|
syncStatusIntervalRef.current = interval;
|
|
@@ -8924,7 +8760,7 @@ var useQuickbooks = () => {
|
|
|
8924
8760
|
syncStatusIntervalRef.current = null;
|
|
8925
8761
|
}
|
|
8926
8762
|
}, [isSyncingFromQuickbooks]);
|
|
8927
|
-
|
|
8763
|
+
useEffect21(() => {
|
|
8928
8764
|
fetchQuickbooksConnectionStatus();
|
|
8929
8765
|
}, []);
|
|
8930
8766
|
const fetchQuickbooksConnectionStatus = async () => {
|
|
@@ -8997,7 +8833,7 @@ var Quickbooks = () => {
|
|
|
8997
8833
|
import React127, { createContext as createContext6 } from "react";
|
|
8998
8834
|
|
|
8999
8835
|
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
9000
|
-
import { useMemo as
|
|
8836
|
+
import { useMemo as useMemo7, useState as useState28 } from "react";
|
|
9001
8837
|
|
|
9002
8838
|
// src/utils/profitAndLossUtils.ts
|
|
9003
8839
|
var doesLineItemQualifies = (item) => {
|
|
@@ -9053,29 +8889,30 @@ var applyShare = (items, total) => {
|
|
|
9053
8889
|
};
|
|
9054
8890
|
|
|
9055
8891
|
// src/hooks/useProfitAndLoss/useProfitAndLossQuery.tsx
|
|
9056
|
-
import { useEffect as
|
|
9057
|
-
import { startOfMonth as
|
|
9058
|
-
import
|
|
8892
|
+
import { useEffect as useEffect22 } from "react";
|
|
8893
|
+
import { startOfMonth as startOfMonth5, endOfMonth as endOfMonth4, formatISO } from "date-fns";
|
|
8894
|
+
import useSWR3 from "swr";
|
|
9059
8895
|
var useProfitAndLossQuery = ({
|
|
9060
8896
|
startDate,
|
|
9061
8897
|
endDate,
|
|
9062
8898
|
tagFilter,
|
|
9063
8899
|
reportingBasis
|
|
9064
8900
|
} = {
|
|
9065
|
-
startDate:
|
|
8901
|
+
startDate: startOfMonth5(/* @__PURE__ */ new Date()),
|
|
9066
8902
|
endDate: endOfMonth4(/* @__PURE__ */ new Date())
|
|
9067
8903
|
}) => {
|
|
9068
8904
|
const { auth, businessId, apiUrl, syncTimestamps, read, hasBeenTouched } = useLayerContext();
|
|
8905
|
+
const queryKey = businessId && startDate && endDate && auth?.access_token && `profit-and-loss-${businessId}-${startDate.valueOf()}-${endDate.valueOf()}-${tagFilter?.key}-${tagFilter?.values?.join(
|
|
8906
|
+
","
|
|
8907
|
+
)}-${reportingBasis}`;
|
|
9069
8908
|
const {
|
|
9070
8909
|
data: rawData,
|
|
9071
8910
|
isLoading,
|
|
9072
8911
|
isValidating,
|
|
9073
8912
|
error: rawError,
|
|
9074
8913
|
mutate
|
|
9075
|
-
} =
|
|
9076
|
-
|
|
9077
|
-
","
|
|
9078
|
-
)}-${reportingBasis}`,
|
|
8914
|
+
} = useSWR3(
|
|
8915
|
+
queryKey,
|
|
9079
8916
|
Layer.getProfitAndLoss(apiUrl, auth?.access_token, {
|
|
9080
8917
|
params: {
|
|
9081
8918
|
businessId,
|
|
@@ -9090,16 +8927,16 @@ var useProfitAndLossQuery = ({
|
|
|
9090
8927
|
const refetch = () => {
|
|
9091
8928
|
mutate();
|
|
9092
8929
|
};
|
|
9093
|
-
|
|
9094
|
-
if (isLoading || isValidating) {
|
|
9095
|
-
read("PROFIT_AND_LOSS" /* PROFIT_AND_LOSS
|
|
8930
|
+
useEffect22(() => {
|
|
8931
|
+
if (queryKey && (isLoading || isValidating)) {
|
|
8932
|
+
read("PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */, queryKey);
|
|
9096
8933
|
}
|
|
9097
8934
|
}, [isLoading, isValidating]);
|
|
9098
|
-
|
|
9099
|
-
if (hasBeenTouched(
|
|
8935
|
+
useEffect22(() => {
|
|
8936
|
+
if (queryKey && hasBeenTouched(queryKey)) {
|
|
9100
8937
|
refetch();
|
|
9101
8938
|
}
|
|
9102
|
-
}, [syncTimestamps]);
|
|
8939
|
+
}, [syncTimestamps, startDate, endDate, tagFilter, reportingBasis]);
|
|
9103
8940
|
return {
|
|
9104
8941
|
startDate,
|
|
9105
8942
|
endDate,
|
|
@@ -9112,27 +8949,27 @@ var useProfitAndLossQuery = ({
|
|
|
9112
8949
|
};
|
|
9113
8950
|
|
|
9114
8951
|
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
9115
|
-
import { startOfMonth as
|
|
8952
|
+
import { startOfMonth as startOfMonth6, endOfMonth as endOfMonth5 } from "date-fns";
|
|
9116
8953
|
var useProfitAndLoss = ({
|
|
9117
8954
|
startDate: initialStartDate,
|
|
9118
8955
|
endDate: initialEndDate,
|
|
9119
8956
|
tagFilter,
|
|
9120
8957
|
reportingBasis
|
|
9121
8958
|
} = {
|
|
9122
|
-
startDate:
|
|
8959
|
+
startDate: startOfMonth6(/* @__PURE__ */ new Date()),
|
|
9123
8960
|
endDate: endOfMonth5(/* @__PURE__ */ new Date())
|
|
9124
8961
|
}) => {
|
|
9125
|
-
const [startDate, setStartDate] =
|
|
9126
|
-
initialStartDate ||
|
|
8962
|
+
const [startDate, setStartDate] = useState28(
|
|
8963
|
+
initialStartDate || startOfMonth6(Date.now())
|
|
9127
8964
|
);
|
|
9128
|
-
const [endDate, setEndDate] =
|
|
8965
|
+
const [endDate, setEndDate] = useState28(
|
|
9129
8966
|
initialEndDate || endOfMonth5(Date.now())
|
|
9130
8967
|
);
|
|
9131
|
-
const [filters, setFilters] =
|
|
8968
|
+
const [filters, setFilters] = useState28({
|
|
9132
8969
|
expenses: void 0,
|
|
9133
8970
|
revenue: void 0
|
|
9134
8971
|
});
|
|
9135
|
-
const [sidebarScope, setSidebarScope] =
|
|
8972
|
+
const [sidebarScope, setSidebarScope] = useState28(void 0);
|
|
9136
8973
|
const { data, isLoading, isValidating, error, refetch } = useProfitAndLossQuery({
|
|
9137
8974
|
startDate,
|
|
9138
8975
|
endDate,
|
|
@@ -9165,7 +9002,7 @@ var useProfitAndLoss = ({
|
|
|
9165
9002
|
}
|
|
9166
9003
|
});
|
|
9167
9004
|
};
|
|
9168
|
-
const { filteredDataRevenue, filteredTotalRevenue } =
|
|
9005
|
+
const { filteredDataRevenue, filteredTotalRevenue } = useMemo7(() => {
|
|
9169
9006
|
if (!data) {
|
|
9170
9007
|
return { filteredDataRevenue: [], filteredTotalRevenue: void 0 };
|
|
9171
9008
|
}
|
|
@@ -9202,7 +9039,7 @@ var useProfitAndLoss = ({
|
|
|
9202
9039
|
const withShare = applyShare(sorted, total);
|
|
9203
9040
|
return { filteredDataRevenue: withShare, filteredTotalRevenue: total };
|
|
9204
9041
|
}, [data, startDate, filters, sidebarScope]);
|
|
9205
|
-
const { filteredDataExpenses, filteredTotalExpenses } =
|
|
9042
|
+
const { filteredDataExpenses, filteredTotalExpenses } = useMemo7(() => {
|
|
9206
9043
|
if (!data) {
|
|
9207
9044
|
return { filteredDataExpenses: [], filteredTotalExpenses: void 0 };
|
|
9208
9045
|
}
|
|
@@ -9262,6 +9099,164 @@ var useProfitAndLoss = ({
|
|
|
9262
9099
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
9263
9100
|
import React114, { useContext as useContext12, useEffect as useEffect25, useMemo as useMemo9, useState as useState31 } from "react";
|
|
9264
9101
|
|
|
9102
|
+
// src/hooks/useProfitAndLoss/useProfitAndLossLTM.tsx
|
|
9103
|
+
import { useEffect as useEffect23, useMemo as useMemo8, useState as useState29 } from "react";
|
|
9104
|
+
import { startOfMonth as startOfMonth7, sub } from "date-fns";
|
|
9105
|
+
import useSWR4 from "swr";
|
|
9106
|
+
var buildDates = ({ currentDate }) => {
|
|
9107
|
+
return {
|
|
9108
|
+
startYear: startOfMonth7(currentDate).getFullYear() - 1,
|
|
9109
|
+
startMonth: startOfMonth7(currentDate).getMonth() + 1,
|
|
9110
|
+
endYear: startOfMonth7(currentDate).getFullYear(),
|
|
9111
|
+
endMonth: startOfMonth7(currentDate).getMonth() + 1
|
|
9112
|
+
};
|
|
9113
|
+
};
|
|
9114
|
+
var buildMonthsArray = (startDate, endDate) => {
|
|
9115
|
+
if (startDate >= endDate) {
|
|
9116
|
+
return [];
|
|
9117
|
+
}
|
|
9118
|
+
var dates = [];
|
|
9119
|
+
for (var d = startDate; d <= endDate; d.setMonth(d.getMonth() + 1)) {
|
|
9120
|
+
dates.push(new Date(d));
|
|
9121
|
+
}
|
|
9122
|
+
return dates;
|
|
9123
|
+
};
|
|
9124
|
+
var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
9125
|
+
currentDate: startOfMonth7(Date.now())
|
|
9126
|
+
}) => {
|
|
9127
|
+
const {
|
|
9128
|
+
businessId,
|
|
9129
|
+
auth,
|
|
9130
|
+
apiUrl,
|
|
9131
|
+
syncTimestamps,
|
|
9132
|
+
read,
|
|
9133
|
+
readTimestamps,
|
|
9134
|
+
hasBeenTouched
|
|
9135
|
+
} = useLayerContext();
|
|
9136
|
+
const [date, setDate] = useState29(currentDate);
|
|
9137
|
+
const [loaded, setLoaded] = useState29("initial");
|
|
9138
|
+
const [data, setData] = useState29([]);
|
|
9139
|
+
const { startYear, startMonth, endYear, endMonth } = useMemo8(() => {
|
|
9140
|
+
return buildDates({ currentDate: date });
|
|
9141
|
+
}, [date, businessId, tagFilter, reportingBasis]);
|
|
9142
|
+
const queryKey = businessId && Boolean(startYear) && Boolean(startMonth) && Boolean(endYear) && Boolean(endMonth) && auth?.access_token && `profit-and-loss-summaries-${businessId}-${startYear.toString()}-${startMonth.toString()}-${tagFilter?.key}-${tagFilter?.values?.join(
|
|
9143
|
+
","
|
|
9144
|
+
)}-${reportingBasis}`;
|
|
9145
|
+
const {
|
|
9146
|
+
data: rawData,
|
|
9147
|
+
isLoading,
|
|
9148
|
+
isValidating,
|
|
9149
|
+
error,
|
|
9150
|
+
mutate
|
|
9151
|
+
} = useSWR4(
|
|
9152
|
+
queryKey,
|
|
9153
|
+
Layer.getProfitAndLossSummaries(apiUrl, auth?.access_token, {
|
|
9154
|
+
params: {
|
|
9155
|
+
businessId,
|
|
9156
|
+
startYear: startYear.toString(),
|
|
9157
|
+
startMonth: startMonth.toString(),
|
|
9158
|
+
endYear: endYear.toString(),
|
|
9159
|
+
endMonth: endMonth.toString(),
|
|
9160
|
+
tagKey: tagFilter?.key,
|
|
9161
|
+
tagValues: tagFilter?.values?.join(","),
|
|
9162
|
+
reportingBasis
|
|
9163
|
+
}
|
|
9164
|
+
})
|
|
9165
|
+
);
|
|
9166
|
+
useEffect23(() => {
|
|
9167
|
+
const newData = data.slice();
|
|
9168
|
+
const newPeriod = buildMonthsArray(sub(date, { years: 1 }), date);
|
|
9169
|
+
if (newData && newPeriod) {
|
|
9170
|
+
newPeriod.forEach((x) => {
|
|
9171
|
+
if (!newData?.find(
|
|
9172
|
+
(n) => x.getMonth() + 1 === n.month && x.getFullYear() === n.year
|
|
9173
|
+
)) {
|
|
9174
|
+
newData.push({
|
|
9175
|
+
year: x.getFullYear(),
|
|
9176
|
+
month: x.getMonth() + 1,
|
|
9177
|
+
income: 0,
|
|
9178
|
+
costOfGoodsSold: 0,
|
|
9179
|
+
grossProfit: 0,
|
|
9180
|
+
operatingExpenses: 0,
|
|
9181
|
+
profitBeforeTaxes: 0,
|
|
9182
|
+
taxes: 0,
|
|
9183
|
+
netProfit: 0,
|
|
9184
|
+
fullyCategorized: false,
|
|
9185
|
+
totalExpenses: 0,
|
|
9186
|
+
uncategorizedInflows: 0,
|
|
9187
|
+
uncategorizedOutflows: 0,
|
|
9188
|
+
uncategorized_transactions: 0,
|
|
9189
|
+
isLoading: true
|
|
9190
|
+
});
|
|
9191
|
+
}
|
|
9192
|
+
});
|
|
9193
|
+
}
|
|
9194
|
+
if (newData) {
|
|
9195
|
+
setData(
|
|
9196
|
+
newData.sort(
|
|
9197
|
+
(a, b) => Number(new Date(a.year, a.month, 1)) - Number(new Date(b.year, b.month, 1))
|
|
9198
|
+
)
|
|
9199
|
+
);
|
|
9200
|
+
}
|
|
9201
|
+
}, [startYear, startMonth]);
|
|
9202
|
+
useEffect23(() => {
|
|
9203
|
+
const newData = rawData?.data?.months?.slice();
|
|
9204
|
+
if (data && newData) {
|
|
9205
|
+
data.forEach((x) => {
|
|
9206
|
+
if (!newData?.find((n) => x.month === n.month && x.year === n.year)) {
|
|
9207
|
+
newData.push({ ...x });
|
|
9208
|
+
}
|
|
9209
|
+
});
|
|
9210
|
+
}
|
|
9211
|
+
if (newData) {
|
|
9212
|
+
setData(
|
|
9213
|
+
newData.sort(
|
|
9214
|
+
(a, b) => Number(new Date(a.year, a.month, 1)) - Number(new Date(b.year, b.month, 1))
|
|
9215
|
+
)
|
|
9216
|
+
);
|
|
9217
|
+
}
|
|
9218
|
+
}, [rawData]);
|
|
9219
|
+
useEffect23(() => {
|
|
9220
|
+
if (isLoading && loaded === "initial") {
|
|
9221
|
+
setLoaded("loading");
|
|
9222
|
+
return;
|
|
9223
|
+
}
|
|
9224
|
+
if (!isLoading && rawData) {
|
|
9225
|
+
setLoaded("complete");
|
|
9226
|
+
}
|
|
9227
|
+
}, [data, isLoading]);
|
|
9228
|
+
const pullData = (date2) => setDate(date2);
|
|
9229
|
+
useEffect23(() => {
|
|
9230
|
+
if (queryKey && (isLoading || isValidating)) {
|
|
9231
|
+
read("PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */, queryKey);
|
|
9232
|
+
}
|
|
9233
|
+
}, [isLoading, isValidating]);
|
|
9234
|
+
useEffect23(() => {
|
|
9235
|
+
if (queryKey && hasBeenTouched(queryKey)) {
|
|
9236
|
+
mutate();
|
|
9237
|
+
}
|
|
9238
|
+
}, [
|
|
9239
|
+
syncTimestamps,
|
|
9240
|
+
startYear,
|
|
9241
|
+
startMonth,
|
|
9242
|
+
endYear,
|
|
9243
|
+
endMonth,
|
|
9244
|
+
tagFilter,
|
|
9245
|
+
reportingBasis
|
|
9246
|
+
]);
|
|
9247
|
+
const refetch = () => {
|
|
9248
|
+
mutate();
|
|
9249
|
+
};
|
|
9250
|
+
return {
|
|
9251
|
+
data,
|
|
9252
|
+
isLoading,
|
|
9253
|
+
loaded,
|
|
9254
|
+
error,
|
|
9255
|
+
pullData,
|
|
9256
|
+
refetch
|
|
9257
|
+
};
|
|
9258
|
+
};
|
|
9259
|
+
|
|
9265
9260
|
// src/components/ProfitAndLossChart/Indicator.tsx
|
|
9266
9261
|
import React113, { useEffect as useEffect24, useState as useState30 } from "react";
|
|
9267
9262
|
var emptyViewBox = { x: 0, y: 0, width: 0, height: 0 };
|
|
@@ -10733,7 +10728,7 @@ var ProfitAndLossDetailedCharts = ({
|
|
|
10733
10728
|
};
|
|
10734
10729
|
|
|
10735
10730
|
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
10736
|
-
import React123, { useContext as useContext15,
|
|
10731
|
+
import React123, { useContext as useContext15, useMemo as useMemo11 } from "react";
|
|
10737
10732
|
|
|
10738
10733
|
// src/components/ProfitAndLossSummaries/MiniChart.tsx
|
|
10739
10734
|
import React122 from "react";
|
|
@@ -10810,17 +10805,8 @@ var ProfitAndLossSummaries = ({
|
|
|
10810
10805
|
data: storedData,
|
|
10811
10806
|
isLoading,
|
|
10812
10807
|
setSidebarScope,
|
|
10813
|
-
sidebarScope
|
|
10814
|
-
refetch,
|
|
10815
|
-
dateRange
|
|
10808
|
+
sidebarScope
|
|
10816
10809
|
} = useContext15(ProfitAndLoss.Context);
|
|
10817
|
-
const [trigger, setTrigger] = useState33(-1);
|
|
10818
|
-
useEffect27(() => {
|
|
10819
|
-
setTrigger(Math.random());
|
|
10820
|
-
}, [dateRange?.startDate]);
|
|
10821
|
-
useEffect27(() => {
|
|
10822
|
-
refetch();
|
|
10823
|
-
}, [trigger]);
|
|
10824
10810
|
const dataItem = Array.isArray(storedData) ? storedData[storedData.length - 1] : storedData;
|
|
10825
10811
|
const expensesChartData = useMemo11(() => {
|
|
10826
10812
|
return buildMiniChartData("expenses", dataItem);
|
|
@@ -10906,7 +10892,7 @@ var ProfitAndLossSummaries = ({
|
|
|
10906
10892
|
import React126, { useContext as useContext16 } from "react";
|
|
10907
10893
|
|
|
10908
10894
|
// src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
|
|
10909
|
-
import React125, { useState as
|
|
10895
|
+
import React125, { useState as useState33 } from "react";
|
|
10910
10896
|
|
|
10911
10897
|
// src/icons/PieChart.tsx
|
|
10912
10898
|
import * as React124 from "react";
|
|
@@ -10956,7 +10942,7 @@ var ProfitAndLossRow = ({
|
|
|
10956
10942
|
return null;
|
|
10957
10943
|
}
|
|
10958
10944
|
const { value, display_name, line_items } = lineItem;
|
|
10959
|
-
const [expanded, setExpanded] =
|
|
10945
|
+
const [expanded, setExpanded] = useState33(lockExpanded || defaultExpanded);
|
|
10960
10946
|
const amount = value ?? 0;
|
|
10961
10947
|
const amountString = centsToDollars(Math.abs(amount));
|
|
10962
10948
|
const labelClasses = [
|
|
@@ -11265,7 +11251,7 @@ ProfitAndLoss.Table = ProfitAndLossTable;
|
|
|
11265
11251
|
ProfitAndLoss.DetailedCharts = ProfitAndLossDetailedCharts;
|
|
11266
11252
|
|
|
11267
11253
|
// src/components/BalanceSheet/BalanceSheet.tsx
|
|
11268
|
-
import React140, { useEffect as
|
|
11254
|
+
import React140, { useEffect as useEffect31, useState as useState36 } from "react";
|
|
11269
11255
|
|
|
11270
11256
|
// src/contexts/BalanceSheetContext/BalanceSheetContext.tsx
|
|
11271
11257
|
import { createContext as createContext7 } from "react";
|
|
@@ -11278,7 +11264,7 @@ var BalanceSheetContext = createContext7({
|
|
|
11278
11264
|
});
|
|
11279
11265
|
|
|
11280
11266
|
// src/contexts/TableContext/TableContext.tsx
|
|
11281
|
-
import React128, { createContext as createContext8, useState as
|
|
11267
|
+
import React128, { createContext as createContext8, useState as useState34 } from "react";
|
|
11282
11268
|
var defaultValue = {
|
|
11283
11269
|
expandedRows: [],
|
|
11284
11270
|
setExpandedRows: () => {
|
|
@@ -11291,8 +11277,8 @@ var defaultValue = {
|
|
|
11291
11277
|
};
|
|
11292
11278
|
var TableContext = createContext8(defaultValue);
|
|
11293
11279
|
var TableProvider = ({ children }) => {
|
|
11294
|
-
const [expandedRows, setExpandedRowsState] =
|
|
11295
|
-
const [expandedAllRows, setExpandedAllRows] =
|
|
11280
|
+
const [expandedRows, setExpandedRowsState] = useState34([]);
|
|
11281
|
+
const [expandedAllRows, setExpandedAllRows] = useState34(false);
|
|
11296
11282
|
const toggleRow = (rowKey) => {
|
|
11297
11283
|
setExpandedRowsState((prevRows) => {
|
|
11298
11284
|
const rows = [...prevRows];
|
|
@@ -11318,14 +11304,15 @@ var TableProvider = ({ children }) => {
|
|
|
11318
11304
|
};
|
|
11319
11305
|
|
|
11320
11306
|
// src/hooks/useBalanceSheet/useBalanceSheet.tsx
|
|
11321
|
-
import { useEffect as
|
|
11307
|
+
import { useEffect as useEffect27 } from "react";
|
|
11322
11308
|
import { format as format3, startOfDay } from "date-fns";
|
|
11323
11309
|
import useSWR5 from "swr";
|
|
11324
11310
|
var useBalanceSheet = (date = /* @__PURE__ */ new Date()) => {
|
|
11325
11311
|
const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
|
|
11326
11312
|
const dateString = format3(startOfDay(date), "yyyy-MM-dd'T'HH:mm:ssXXX");
|
|
11313
|
+
const queryKey = businessId && dateString && auth?.access_token && `balance-sheet-${businessId}-${dateString}`;
|
|
11327
11314
|
const { data, isLoading, isValidating, error, mutate } = useSWR5(
|
|
11328
|
-
|
|
11315
|
+
queryKey,
|
|
11329
11316
|
Layer.getBalanceSheet(apiUrl, auth?.access_token, {
|
|
11330
11317
|
params: {
|
|
11331
11318
|
businessId,
|
|
@@ -11336,16 +11323,16 @@ var useBalanceSheet = (date = /* @__PURE__ */ new Date()) => {
|
|
|
11336
11323
|
const refetch = () => {
|
|
11337
11324
|
mutate();
|
|
11338
11325
|
};
|
|
11339
|
-
|
|
11340
|
-
if (isLoading || isValidating) {
|
|
11341
|
-
read("BALANCE_SHEET" /* BALANCE_SHEET
|
|
11326
|
+
useEffect27(() => {
|
|
11327
|
+
if (queryKey && (isLoading || isValidating)) {
|
|
11328
|
+
read("BALANCE_SHEET" /* BALANCE_SHEET */, queryKey);
|
|
11342
11329
|
}
|
|
11343
11330
|
}, [isLoading, isValidating]);
|
|
11344
|
-
|
|
11345
|
-
if (hasBeenTouched(
|
|
11331
|
+
useEffect27(() => {
|
|
11332
|
+
if (queryKey && hasBeenTouched(queryKey)) {
|
|
11346
11333
|
refetch();
|
|
11347
11334
|
}
|
|
11348
|
-
}, [syncTimestamps]);
|
|
11335
|
+
}, [syncTimestamps, dateString]);
|
|
11349
11336
|
return { data: data?.data, isLoading, error, refetch };
|
|
11350
11337
|
};
|
|
11351
11338
|
|
|
@@ -11411,7 +11398,7 @@ var BalanceSheetExpandAllButton = () => {
|
|
|
11411
11398
|
};
|
|
11412
11399
|
|
|
11413
11400
|
// src/components/BalanceSheetTable/BalanceSheetTable.tsx
|
|
11414
|
-
import React136, { useEffect as
|
|
11401
|
+
import React136, { useEffect as useEffect29 } from "react";
|
|
11415
11402
|
|
|
11416
11403
|
// src/components/TableBody/TableBody.tsx
|
|
11417
11404
|
import React131 from "react";
|
|
@@ -11487,7 +11474,7 @@ var TableRow = ({
|
|
|
11487
11474
|
};
|
|
11488
11475
|
|
|
11489
11476
|
// src/components/Table/Table.tsx
|
|
11490
|
-
import React135, { useEffect as
|
|
11477
|
+
import React135, { useEffect as useEffect28, useRef as useRef15 } from "react";
|
|
11491
11478
|
import classNames48 from "classnames";
|
|
11492
11479
|
var Table = ({
|
|
11493
11480
|
componentName,
|
|
@@ -11497,7 +11484,7 @@ var Table = ({
|
|
|
11497
11484
|
}) => {
|
|
11498
11485
|
const tableRef = useRef15(null);
|
|
11499
11486
|
const prevChildrenRef = useRef15([]);
|
|
11500
|
-
|
|
11487
|
+
useEffect28(() => {
|
|
11501
11488
|
if (tableRef.current) {
|
|
11502
11489
|
const tbody = tableRef.current.querySelector("tbody");
|
|
11503
11490
|
const rows = tbody ? Array.from(tbody.querySelectorAll("tr")) : [];
|
|
@@ -11548,12 +11535,12 @@ var BalanceSheetTable = ({
|
|
|
11548
11535
|
}) => {
|
|
11549
11536
|
const { isOpen, setIsOpen, expandedAllRows } = useTableExpandRow();
|
|
11550
11537
|
const allRowKeys = [];
|
|
11551
|
-
|
|
11538
|
+
useEffect29(() => {
|
|
11552
11539
|
if (expandedAllRows) {
|
|
11553
11540
|
setIsOpen(allRowKeys, true);
|
|
11554
11541
|
}
|
|
11555
11542
|
}, [expandedAllRows]);
|
|
11556
|
-
|
|
11543
|
+
useEffect29(() => {
|
|
11557
11544
|
setIsOpen(["assets"]);
|
|
11558
11545
|
}, []);
|
|
11559
11546
|
const renderLineItem = (lineItem, depth = 0, rowKey, rowIndex) => {
|
|
@@ -11618,7 +11605,7 @@ var ViewHeader = ({ title, controls }) => {
|
|
|
11618
11605
|
};
|
|
11619
11606
|
|
|
11620
11607
|
// src/components/Panel/Panel.tsx
|
|
11621
|
-
import React138, { useEffect as
|
|
11608
|
+
import React138, { useEffect as useEffect30, useState as useState35 } from "react";
|
|
11622
11609
|
import classNames49 from "classnames";
|
|
11623
11610
|
var Panel = ({
|
|
11624
11611
|
children,
|
|
@@ -11629,8 +11616,8 @@ var Panel = ({
|
|
|
11629
11616
|
parentRef,
|
|
11630
11617
|
defaultSidebarHeight = false
|
|
11631
11618
|
}) => {
|
|
11632
|
-
const [sidebarHeight, setSidebarHeight] =
|
|
11633
|
-
|
|
11619
|
+
const [sidebarHeight, setSidebarHeight] = useState35(0);
|
|
11620
|
+
useEffect30(() => {
|
|
11634
11621
|
if (parentRef?.current?.offsetHeight) {
|
|
11635
11622
|
setSidebarHeight(parentRef?.current?.offsetHeight - 1);
|
|
11636
11623
|
}
|
|
@@ -11702,16 +11689,23 @@ import { format as format4, parse, startOfDay as startOfDay2 } from "date-fns";
|
|
|
11702
11689
|
var COMPONENT_NAME3 = "balance-sheet";
|
|
11703
11690
|
var BalanceSheet = (props) => {
|
|
11704
11691
|
const balanceSheetContextData = useBalanceSheet(props.effectiveDate);
|
|
11705
|
-
return /* @__PURE__ */ React140.createElement(BalanceSheetContext.Provider, { value: balanceSheetContextData }, /* @__PURE__ */ React140.createElement(
|
|
11692
|
+
return /* @__PURE__ */ React140.createElement(BalanceSheetContext.Provider, { value: balanceSheetContextData }, /* @__PURE__ */ React140.createElement(
|
|
11693
|
+
BalanceSheetView,
|
|
11694
|
+
{
|
|
11695
|
+
asWidget: props.asWidget,
|
|
11696
|
+
stringOverrides: props.stringOverrides,
|
|
11697
|
+
...props
|
|
11698
|
+
}
|
|
11699
|
+
));
|
|
11706
11700
|
};
|
|
11707
11701
|
var BalanceSheetView = ({
|
|
11708
11702
|
withExpandAllButton = true,
|
|
11709
11703
|
asWidget = false,
|
|
11710
11704
|
stringOverrides
|
|
11711
11705
|
}) => {
|
|
11712
|
-
const [effectiveDate, setEffectiveDate] =
|
|
11706
|
+
const [effectiveDate, setEffectiveDate] = useState36(startOfDay2(/* @__PURE__ */ new Date()));
|
|
11713
11707
|
const { data, isLoading, refetch } = useBalanceSheet(effectiveDate);
|
|
11714
|
-
|
|
11708
|
+
useEffect31(() => {
|
|
11715
11709
|
const d1 = effectiveDate && format4(startOfDay2(effectiveDate), "yyyy-MM-dd'T'HH:mm:ssXXX");
|
|
11716
11710
|
const d2 = data?.effective_date && format4(
|
|
11717
11711
|
startOfDay2(
|
|
@@ -11736,7 +11730,14 @@ var BalanceSheetView = ({
|
|
|
11736
11730
|
}
|
|
11737
11731
|
), withExpandAllButton && /* @__PURE__ */ React140.createElement(BalanceSheetExpandAllButton, null))
|
|
11738
11732
|
},
|
|
11739
|
-
!data || isLoading ? /* @__PURE__ */ React140.createElement("div", { className: `Layer__${COMPONENT_NAME3}__loader-container` }, /* @__PURE__ */ React140.createElement(Loader2, null)) : /* @__PURE__ */ React140.createElement(
|
|
11733
|
+
!data || isLoading ? /* @__PURE__ */ React140.createElement("div", { className: `Layer__${COMPONENT_NAME3}__loader-container` }, /* @__PURE__ */ React140.createElement(Loader2, null)) : /* @__PURE__ */ React140.createElement(
|
|
11734
|
+
BalanceSheetTable,
|
|
11735
|
+
{
|
|
11736
|
+
data,
|
|
11737
|
+
config: BALANCE_SHEET_ROWS,
|
|
11738
|
+
stringOverrides: stringOverrides?.balanceSheetTable
|
|
11739
|
+
}
|
|
11740
|
+
)
|
|
11740
11741
|
)));
|
|
11741
11742
|
}
|
|
11742
11743
|
return /* @__PURE__ */ React140.createElement(TableProvider, null, /* @__PURE__ */ React140.createElement(
|
|
@@ -11751,12 +11752,19 @@ var BalanceSheetView = ({
|
|
|
11751
11752
|
}
|
|
11752
11753
|
), withExpandAllButton && /* @__PURE__ */ React140.createElement(BalanceSheetExpandAllButton, null))
|
|
11753
11754
|
},
|
|
11754
|
-
!data || isLoading ? /* @__PURE__ */ React140.createElement("div", { className: `Layer__${COMPONENT_NAME3}__loader-container` }, /* @__PURE__ */ React140.createElement(Loader2, null)) : /* @__PURE__ */ React140.createElement(
|
|
11755
|
+
!data || isLoading ? /* @__PURE__ */ React140.createElement("div", { className: `Layer__${COMPONENT_NAME3}__loader-container` }, /* @__PURE__ */ React140.createElement(Loader2, null)) : /* @__PURE__ */ React140.createElement(
|
|
11756
|
+
BalanceSheetTable,
|
|
11757
|
+
{
|
|
11758
|
+
data,
|
|
11759
|
+
config: BALANCE_SHEET_ROWS,
|
|
11760
|
+
stringOverrides: stringOverrides?.balanceSheetTable
|
|
11761
|
+
}
|
|
11762
|
+
)
|
|
11755
11763
|
));
|
|
11756
11764
|
};
|
|
11757
11765
|
|
|
11758
11766
|
// src/components/StatementOfCashFlow/StatementOfCashFlow.tsx
|
|
11759
|
-
import React142, { useState as
|
|
11767
|
+
import React142, { useState as useState37 } from "react";
|
|
11760
11768
|
|
|
11761
11769
|
// src/contexts/StatementOfCashContext/StatementOfCashFlowContext.tsx
|
|
11762
11770
|
import { createContext as createContext9 } from "react";
|
|
@@ -11769,7 +11777,7 @@ var StatementOfCashFlowContext = createContext9({
|
|
|
11769
11777
|
});
|
|
11770
11778
|
|
|
11771
11779
|
// src/hooks/useStatementOfCashFlow/useStatementOfCashFlow.tsx
|
|
11772
|
-
import { useEffect as
|
|
11780
|
+
import { useEffect as useEffect32 } from "react";
|
|
11773
11781
|
import { format as format5, startOfDay as startOfDay3 } from "date-fns";
|
|
11774
11782
|
import useSWR6 from "swr";
|
|
11775
11783
|
var useStatementOfCashFlow = (startDate = /* @__PURE__ */ new Date(), endDate = /* @__PURE__ */ new Date()) => {
|
|
@@ -11779,8 +11787,9 @@ var useStatementOfCashFlow = (startDate = /* @__PURE__ */ new Date(), endDate =
|
|
|
11779
11787
|
"yyyy-MM-dd'T'HH:mm:ssXXX"
|
|
11780
11788
|
);
|
|
11781
11789
|
const endDateString = format5(startOfDay3(endDate), "yyyy-MM-dd'T'HH:mm:ssXXX");
|
|
11790
|
+
const queryKey = businessId && startDateString && endDateString && auth?.access_token && `statement-of-cash-${businessId}-${startDateString}-${endDateString}`;
|
|
11782
11791
|
const { data, isLoading, isValidating, error, mutate } = useSWR6(
|
|
11783
|
-
|
|
11792
|
+
queryKey,
|
|
11784
11793
|
Layer.getStatementOfCashFlow(apiUrl, auth?.access_token, {
|
|
11785
11794
|
params: {
|
|
11786
11795
|
businessId,
|
|
@@ -11792,16 +11801,16 @@ var useStatementOfCashFlow = (startDate = /* @__PURE__ */ new Date(), endDate =
|
|
|
11792
11801
|
const refetch = () => {
|
|
11793
11802
|
mutate();
|
|
11794
11803
|
};
|
|
11795
|
-
|
|
11796
|
-
if (isLoading || isValidating) {
|
|
11797
|
-
read("STATEMENT_OF_CASH_FLOWS" /* STATEMENT_OF_CASH_FLOWS
|
|
11804
|
+
useEffect32(() => {
|
|
11805
|
+
if (queryKey && (isLoading || isValidating)) {
|
|
11806
|
+
read("STATEMENT_OF_CASH_FLOWS" /* STATEMENT_OF_CASH_FLOWS */, queryKey);
|
|
11798
11807
|
}
|
|
11799
11808
|
}, [isLoading, isValidating]);
|
|
11800
|
-
|
|
11801
|
-
if (hasBeenTouched(
|
|
11809
|
+
useEffect32(() => {
|
|
11810
|
+
if (queryKey && hasBeenTouched(queryKey)) {
|
|
11802
11811
|
refetch();
|
|
11803
11812
|
}
|
|
11804
|
-
}, [syncTimestamps]);
|
|
11813
|
+
}, [syncTimestamps, startDateString, endDateString]);
|
|
11805
11814
|
return { data: data?.data, isLoading, error, refetch };
|
|
11806
11815
|
};
|
|
11807
11816
|
|
|
@@ -11913,10 +11922,10 @@ var StatementOfCashFlow = ({ stringOverrides }) => {
|
|
|
11913
11922
|
return /* @__PURE__ */ React142.createElement(StatementOfCashFlowContext.Provider, { value: cashContextData }, /* @__PURE__ */ React142.createElement(StatementOfCashFlowView, { stringOverrides }));
|
|
11914
11923
|
};
|
|
11915
11924
|
var StatementOfCashFlowView = ({ stringOverrides }) => {
|
|
11916
|
-
const [startDate, setStartDate] =
|
|
11925
|
+
const [startDate, setStartDate] = useState37(
|
|
11917
11926
|
startOfDay4(subWeeks(/* @__PURE__ */ new Date(), 4))
|
|
11918
11927
|
);
|
|
11919
|
-
const [endDate, setEndDate] =
|
|
11928
|
+
const [endDate, setEndDate] = useState37(startOfDay4(/* @__PURE__ */ new Date()));
|
|
11920
11929
|
const { data, isLoading, refetch } = useStatementOfCashFlow(
|
|
11921
11930
|
startDate,
|
|
11922
11931
|
endDate
|
|
@@ -11958,7 +11967,7 @@ var StatementOfCashFlowView = ({ stringOverrides }) => {
|
|
|
11958
11967
|
};
|
|
11959
11968
|
|
|
11960
11969
|
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
11961
|
-
import React157, { useContext as useContext25, useState as
|
|
11970
|
+
import React157, { useContext as useContext25, useState as useState44 } from "react";
|
|
11962
11971
|
|
|
11963
11972
|
// src/contexts/ChartOfAccountsContext/ChartOfAccountsContext.tsx
|
|
11964
11973
|
import { createContext as createContext10 } from "react";
|
|
@@ -12017,7 +12026,7 @@ var LedgerAccountsContext = createContext11({
|
|
|
12017
12026
|
});
|
|
12018
12027
|
|
|
12019
12028
|
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
12020
|
-
import { useEffect as
|
|
12029
|
+
import { useEffect as useEffect33, useState as useState38 } from "react";
|
|
12021
12030
|
|
|
12022
12031
|
// src/components/ChartOfAccountsForm/constants.ts
|
|
12023
12032
|
var LEDGER_ACCOUNT_TYPES = [
|
|
@@ -12314,17 +12323,18 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
12314
12323
|
syncTimestamps,
|
|
12315
12324
|
hasBeenTouched
|
|
12316
12325
|
} = useLayerContext();
|
|
12317
|
-
const [form, setForm] =
|
|
12318
|
-
const [sendingForm, setSendingForm] =
|
|
12319
|
-
const [apiError, setApiError] =
|
|
12320
|
-
const [startDate, setStartDate] =
|
|
12326
|
+
const [form, setForm] = useState38();
|
|
12327
|
+
const [sendingForm, setSendingForm] = useState38(false);
|
|
12328
|
+
const [apiError, setApiError] = useState38(void 0);
|
|
12329
|
+
const [startDate, setStartDate] = useState38(
|
|
12321
12330
|
initialStartDate ?? startOfMonth12(Date.now())
|
|
12322
12331
|
);
|
|
12323
|
-
const [endDate, setEndDate] =
|
|
12332
|
+
const [endDate, setEndDate] = useState38(
|
|
12324
12333
|
initialEndDate ?? endOfMonth10(Date.now())
|
|
12325
12334
|
);
|
|
12335
|
+
const queryKey = businessId && auth?.access_token && `chart-of-accounts-${businessId}-${startDate?.valueOf()}-${endDate?.valueOf()}`;
|
|
12326
12336
|
const { data, isLoading, isValidating, error, mutate } = useSWR7(
|
|
12327
|
-
|
|
12337
|
+
queryKey,
|
|
12328
12338
|
Layer.getLedgerAccountBalances(apiUrl, auth?.access_token, {
|
|
12329
12339
|
params: {
|
|
12330
12340
|
businessId,
|
|
@@ -12500,16 +12510,16 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
12500
12510
|
newEndDate && setEndDate(newEndDate);
|
|
12501
12511
|
};
|
|
12502
12512
|
const refetch = () => mutate();
|
|
12503
|
-
|
|
12504
|
-
if (isLoading || isValidating) {
|
|
12505
|
-
read("CHART_OF_ACCOUNTS" /* CHART_OF_ACCOUNTS
|
|
12513
|
+
useEffect33(() => {
|
|
12514
|
+
if (queryKey && (isLoading || isValidating)) {
|
|
12515
|
+
read("CHART_OF_ACCOUNTS" /* CHART_OF_ACCOUNTS */, queryKey);
|
|
12506
12516
|
}
|
|
12507
12517
|
}, [isLoading, isValidating]);
|
|
12508
|
-
|
|
12509
|
-
if (hasBeenTouched(
|
|
12518
|
+
useEffect33(() => {
|
|
12519
|
+
if (queryKey && hasBeenTouched(queryKey)) {
|
|
12510
12520
|
refetch();
|
|
12511
12521
|
}
|
|
12512
|
-
}, [syncTimestamps]);
|
|
12522
|
+
}, [syncTimestamps, startDate, endDate]);
|
|
12513
12523
|
return {
|
|
12514
12524
|
data: data?.data,
|
|
12515
12525
|
isLoading,
|
|
@@ -12531,14 +12541,15 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
12531
12541
|
};
|
|
12532
12542
|
|
|
12533
12543
|
// src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
|
|
12534
|
-
import { useEffect as
|
|
12544
|
+
import { useEffect as useEffect34, useState as useState39 } from "react";
|
|
12535
12545
|
import useSWR8 from "swr";
|
|
12536
12546
|
var useLedgerAccounts = () => {
|
|
12537
12547
|
const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
|
|
12538
|
-
const [accountId, setAccountId] =
|
|
12539
|
-
const [selectedEntryId, setSelectedEntryId] =
|
|
12548
|
+
const [accountId, setAccountId] = useState39();
|
|
12549
|
+
const [selectedEntryId, setSelectedEntryId] = useState39();
|
|
12550
|
+
const queryKey = businessId && accountId && auth?.access_token && `ledger-accounts-lines-${businessId}-${accountId}`;
|
|
12540
12551
|
const { data, isLoading, isValidating, error, mutate } = useSWR8(
|
|
12541
|
-
|
|
12552
|
+
queryKey,
|
|
12542
12553
|
Layer.getLedgerAccountsLines(apiUrl, auth?.access_token, {
|
|
12543
12554
|
params: { businessId, accountId }
|
|
12544
12555
|
})
|
|
@@ -12560,16 +12571,16 @@ var useLedgerAccounts = () => {
|
|
|
12560
12571
|
setSelectedEntryId(void 0);
|
|
12561
12572
|
mutateEntryData();
|
|
12562
12573
|
};
|
|
12563
|
-
|
|
12564
|
-
if (isLoading || isValidating) {
|
|
12565
|
-
read("LEDGER_ACCOUNTS" /* LEDGER_ACCOUNTS
|
|
12574
|
+
useEffect34(() => {
|
|
12575
|
+
if (queryKey && (isLoading || isValidating)) {
|
|
12576
|
+
read("LEDGER_ACCOUNTS" /* LEDGER_ACCOUNTS */, queryKey);
|
|
12566
12577
|
}
|
|
12567
12578
|
}, [isLoading, isValidating]);
|
|
12568
|
-
|
|
12569
|
-
if (hasBeenTouched(
|
|
12579
|
+
useEffect34(() => {
|
|
12580
|
+
if (queryKey && hasBeenTouched(queryKey)) {
|
|
12570
12581
|
refetch();
|
|
12571
12582
|
}
|
|
12572
|
-
}, [syncTimestamps]);
|
|
12583
|
+
}, [syncTimestamps, accountId]);
|
|
12573
12584
|
return {
|
|
12574
12585
|
data: data?.data,
|
|
12575
12586
|
entryData: entryData?.data,
|
|
@@ -12589,7 +12600,7 @@ var useLedgerAccounts = () => {
|
|
|
12589
12600
|
};
|
|
12590
12601
|
|
|
12591
12602
|
// src/components/ChartOfAccountsTable/ChartOfAccountsTable.tsx
|
|
12592
|
-
import React149, { useContext as useContext21, useState as
|
|
12603
|
+
import React149, { useContext as useContext21, useState as useState41 } from "react";
|
|
12593
12604
|
|
|
12594
12605
|
// src/components/ChartOfAccountsDatePicker/ChartOfAccountsDatePicker.tsx
|
|
12595
12606
|
import React143, { useContext as useContext18 } from "react";
|
|
@@ -12614,7 +12625,7 @@ var ChartOfAccountsDatePicker = () => {
|
|
|
12614
12625
|
};
|
|
12615
12626
|
|
|
12616
12627
|
// src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
|
|
12617
|
-
import React145, { useContext as useContext19, useEffect as
|
|
12628
|
+
import React145, { useContext as useContext19, useEffect as useEffect35, useState as useState40 } from "react";
|
|
12618
12629
|
|
|
12619
12630
|
// src/icons/Edit2.tsx
|
|
12620
12631
|
import * as React144 from "react";
|
|
@@ -12675,7 +12686,7 @@ var ChartOfAccountsRow = ({
|
|
|
12675
12686
|
const { form, editAccount } = useContext19(ChartOfAccountsContext);
|
|
12676
12687
|
const { setAccountId } = useContext19(LedgerAccountsContext);
|
|
12677
12688
|
const baseStyle = view === "desktop" ? EXPANDED_STYLE2 : EXPANDED_MOBILE_STYLE;
|
|
12678
|
-
const [isOpen, setIsOpen] =
|
|
12689
|
+
const [isOpen, setIsOpen] = useState40(defaultOpen);
|
|
12679
12690
|
const style = expanded ? {
|
|
12680
12691
|
...baseStyle,
|
|
12681
12692
|
transitionDelay: `${15 * index}ms`
|
|
@@ -12683,15 +12694,15 @@ var ChartOfAccountsRow = ({
|
|
|
12683
12694
|
...COLLAPSED_STYLE2,
|
|
12684
12695
|
transitionDelay: `${acountsLength - 15 * index}ms`
|
|
12685
12696
|
};
|
|
12686
|
-
const [showComponent, setShowComponent] =
|
|
12687
|
-
const [prevExpandedAll, setPrevExpandedAll] =
|
|
12688
|
-
|
|
12697
|
+
const [showComponent, setShowComponent] = useState40(false);
|
|
12698
|
+
const [prevExpandedAll, setPrevExpandedAll] = useState40(expandAll);
|
|
12699
|
+
useEffect35(() => {
|
|
12689
12700
|
const timeoutId = setTimeout(() => {
|
|
12690
12701
|
setShowComponent(true);
|
|
12691
12702
|
}, cumulativeIndex * 50);
|
|
12692
12703
|
return () => clearTimeout(timeoutId);
|
|
12693
12704
|
}, []);
|
|
12694
|
-
|
|
12705
|
+
useEffect35(() => {
|
|
12695
12706
|
if (prevExpandedAll !== expandAll && expandAll) {
|
|
12696
12707
|
setIsOpen(expandAll === "collapsed" ? false : true);
|
|
12697
12708
|
}
|
|
@@ -13049,7 +13060,7 @@ var ChartOfAccountsTable = ({
|
|
|
13049
13060
|
stringOverrides
|
|
13050
13061
|
}) => {
|
|
13051
13062
|
const { data, isLoading, addAccount, error, isValidating, refetch, form } = useContext21(ChartOfAccountsContext);
|
|
13052
|
-
const [expandAll, setExpandAll] =
|
|
13063
|
+
const [expandAll, setExpandAll] = useState41();
|
|
13053
13064
|
let cumulativeIndex = 0;
|
|
13054
13065
|
const accountsLength = data?.accounts.length ?? 0;
|
|
13055
13066
|
return /* @__PURE__ */ React149.createElement(
|
|
@@ -13143,9 +13154,9 @@ var ChartOfAccountsTable = ({
|
|
|
13143
13154
|
// src/components/LedgerAccount/LedgerAccountIndex.tsx
|
|
13144
13155
|
import React156, {
|
|
13145
13156
|
useContext as useContext24,
|
|
13146
|
-
useEffect as
|
|
13157
|
+
useEffect as useEffect37,
|
|
13147
13158
|
useMemo as useMemo15,
|
|
13148
|
-
useState as
|
|
13159
|
+
useState as useState43
|
|
13149
13160
|
} from "react";
|
|
13150
13161
|
|
|
13151
13162
|
// src/components/LedgerAccountEntryDetails/LedgerAccountEntryDetails.tsx
|
|
@@ -13336,7 +13347,7 @@ var LedgerAccountEntryDetails = ({ stringOverrides }) => {
|
|
|
13336
13347
|
};
|
|
13337
13348
|
|
|
13338
13349
|
// src/components/LedgerAccount/LedgerAccountRow.tsx
|
|
13339
|
-
import React155, { useContext as useContext23, useEffect as
|
|
13350
|
+
import React155, { useContext as useContext23, useEffect as useEffect36, useState as useState42 } from "react";
|
|
13340
13351
|
import classNames54 from "classnames";
|
|
13341
13352
|
import { parseISO as parseISO14, format as formatTime10 } from "date-fns";
|
|
13342
13353
|
var LedgerAccountRow = ({
|
|
@@ -13346,8 +13357,8 @@ var LedgerAccountRow = ({
|
|
|
13346
13357
|
view
|
|
13347
13358
|
}) => {
|
|
13348
13359
|
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = useContext23(LedgerAccountsContext);
|
|
13349
|
-
const [showComponent, setShowComponent] =
|
|
13350
|
-
|
|
13360
|
+
const [showComponent, setShowComponent] = useState42(false);
|
|
13361
|
+
useEffect36(() => {
|
|
13351
13362
|
if (initialLoad) {
|
|
13352
13363
|
const timeoutId = setTimeout(() => {
|
|
13353
13364
|
setShowComponent(true);
|
|
@@ -13456,8 +13467,8 @@ var LedgerAccount = ({
|
|
|
13456
13467
|
view,
|
|
13457
13468
|
stringOverrides
|
|
13458
13469
|
}) => {
|
|
13459
|
-
const [currentPage, setCurrentPage] =
|
|
13460
|
-
const [initialLoad, setInitialLoad] =
|
|
13470
|
+
const [currentPage, setCurrentPage] = useState43(1);
|
|
13471
|
+
const [initialLoad, setInitialLoad] = useState43(true);
|
|
13461
13472
|
const { data: accountData } = useContext24(ChartOfAccountsContext);
|
|
13462
13473
|
const {
|
|
13463
13474
|
data: rawData,
|
|
@@ -13470,7 +13481,7 @@ var LedgerAccount = ({
|
|
|
13470
13481
|
closeSelectedEntry,
|
|
13471
13482
|
refetch
|
|
13472
13483
|
} = useContext24(LedgerAccountsContext);
|
|
13473
|
-
|
|
13484
|
+
useEffect37(() => {
|
|
13474
13485
|
if (!isLoading) {
|
|
13475
13486
|
const timeoutLoad = setTimeout(() => {
|
|
13476
13487
|
setInitialLoad(false);
|
|
@@ -13584,7 +13595,7 @@ var ChartOfAccountsContent = ({
|
|
|
13584
13595
|
stringOverrides
|
|
13585
13596
|
}) => {
|
|
13586
13597
|
const { accountId } = useContext25(LedgerAccountsContext);
|
|
13587
|
-
const [view, setView] =
|
|
13598
|
+
const [view, setView] = useState44("desktop");
|
|
13588
13599
|
const containerRef = useElementSize((_a, _b, { width }) => {
|
|
13589
13600
|
if (width) {
|
|
13590
13601
|
if (width >= BREAKPOINTS.TABLET && view !== "desktop") {
|
|
@@ -13610,7 +13621,7 @@ var ChartOfAccountsContent = ({
|
|
|
13610
13621
|
};
|
|
13611
13622
|
|
|
13612
13623
|
// src/components/Journal/Journal.tsx
|
|
13613
|
-
import React164, { useState as
|
|
13624
|
+
import React164, { useState as useState48 } from "react";
|
|
13614
13625
|
|
|
13615
13626
|
// src/contexts/JournalContext/JournalContext.tsx
|
|
13616
13627
|
import { createContext as createContext12 } from "react";
|
|
@@ -13647,7 +13658,7 @@ var JournalContext = createContext12({
|
|
|
13647
13658
|
});
|
|
13648
13659
|
|
|
13649
13660
|
// src/hooks/useJournal/useJournal.tsx
|
|
13650
|
-
import { useEffect as
|
|
13661
|
+
import { useEffect as useEffect38, useState as useState45 } from "react";
|
|
13651
13662
|
|
|
13652
13663
|
// src/utils/journal.ts
|
|
13653
13664
|
var getAccountIdentifierPayload = (journalLineItem) => {
|
|
@@ -13678,13 +13689,14 @@ var useJournal = () => {
|
|
|
13678
13689
|
syncTimestamps,
|
|
13679
13690
|
hasBeenTouched
|
|
13680
13691
|
} = useLayerContext();
|
|
13681
|
-
const [selectedEntryId, setSelectedEntryId] =
|
|
13682
|
-
const [form, setForm] =
|
|
13683
|
-
const [addingEntry, setAddingEntry] =
|
|
13684
|
-
const [sendingForm, setSendingForm] =
|
|
13685
|
-
const [apiError, setApiError] =
|
|
13692
|
+
const [selectedEntryId, setSelectedEntryId] = useState45();
|
|
13693
|
+
const [form, setForm] = useState45();
|
|
13694
|
+
const [addingEntry, setAddingEntry] = useState45(false);
|
|
13695
|
+
const [sendingForm, setSendingForm] = useState45(false);
|
|
13696
|
+
const [apiError, setApiError] = useState45(void 0);
|
|
13697
|
+
const queryKey = businessId && auth?.access_token && `journal-lines-${businessId}`;
|
|
13686
13698
|
const { data, isLoading, isValidating, error, mutate } = useSWR9(
|
|
13687
|
-
|
|
13699
|
+
queryKey,
|
|
13688
13700
|
Layer.getJournal(apiUrl, auth?.access_token, {
|
|
13689
13701
|
params: { businessId }
|
|
13690
13702
|
})
|
|
@@ -13907,13 +13919,13 @@ var useJournal = () => {
|
|
|
13907
13919
|
}
|
|
13908
13920
|
});
|
|
13909
13921
|
};
|
|
13910
|
-
|
|
13911
|
-
if (isLoading || isValidating) {
|
|
13912
|
-
read("JOURNAL" /* JOURNAL
|
|
13922
|
+
useEffect38(() => {
|
|
13923
|
+
if (queryKey && (isLoading || isValidating)) {
|
|
13924
|
+
read("JOURNAL" /* JOURNAL */, queryKey);
|
|
13913
13925
|
}
|
|
13914
13926
|
}, [isLoading, isValidating]);
|
|
13915
|
-
|
|
13916
|
-
if (hasBeenTouched(
|
|
13927
|
+
useEffect38(() => {
|
|
13928
|
+
if (queryKey && hasBeenTouched(queryKey)) {
|
|
13917
13929
|
refetch();
|
|
13918
13930
|
}
|
|
13919
13931
|
}, [syncTimestamps]);
|
|
@@ -13943,10 +13955,10 @@ var useJournal = () => {
|
|
|
13943
13955
|
};
|
|
13944
13956
|
|
|
13945
13957
|
// src/components/JournalTable/JournalTable.tsx
|
|
13946
|
-
import React163, { useContext as useContext31, useMemo as useMemo17, useState as
|
|
13958
|
+
import React163, { useContext as useContext31, useMemo as useMemo17, useState as useState47 } from "react";
|
|
13947
13959
|
|
|
13948
13960
|
// src/components/JournalRow/JournalRow.tsx
|
|
13949
|
-
import React158, { useContext as useContext26, useEffect as
|
|
13961
|
+
import React158, { useContext as useContext26, useEffect as useEffect39, useState as useState46 } from "react";
|
|
13950
13962
|
import classNames56 from "classnames";
|
|
13951
13963
|
import { parseISO as parseISO15, format as formatTime11 } from "date-fns";
|
|
13952
13964
|
var INDENTATION2 = 24;
|
|
@@ -13985,7 +13997,7 @@ var JournalRow = ({
|
|
|
13985
13997
|
selectedEntries = false
|
|
13986
13998
|
}) => {
|
|
13987
13999
|
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = useContext26(JournalContext);
|
|
13988
|
-
const [isOpen, setIsOpen] =
|
|
14000
|
+
const [isOpen, setIsOpen] = useState46(index === 0 ? true : defaultOpen);
|
|
13989
14001
|
const style = expanded ? {
|
|
13990
14002
|
...EXPANDED_STYLE3,
|
|
13991
14003
|
transitionDelay: `${15 * index}ms`
|
|
@@ -13993,7 +14005,7 @@ var JournalRow = ({
|
|
|
13993
14005
|
...COLLAPSED_STYLE3,
|
|
13994
14006
|
transitionDelay: `${lineItemsLength - 15 * index}ms`
|
|
13995
14007
|
};
|
|
13996
|
-
const [showComponent, setShowComponent] =
|
|
14008
|
+
const [showComponent, setShowComponent] = useState46(false);
|
|
13997
14009
|
const baseClass = classNames56(
|
|
13998
14010
|
"Layer__journal-table-row",
|
|
13999
14011
|
rowId(row) === selectedEntryId && "Layer__table-row--active",
|
|
@@ -14011,7 +14023,7 @@ var JournalRow = ({
|
|
|
14011
14023
|
"Layer__journal-line__table-row",
|
|
14012
14024
|
!expanded && "Layer__table-row--hidden"
|
|
14013
14025
|
);
|
|
14014
|
-
|
|
14026
|
+
useEffect39(() => {
|
|
14015
14027
|
if (initialLoad) {
|
|
14016
14028
|
const timeoutId = setTimeout(() => {
|
|
14017
14029
|
setShowComponent(true);
|
|
@@ -14479,7 +14491,7 @@ var JournalTable = ({
|
|
|
14479
14491
|
config,
|
|
14480
14492
|
stringOverrides
|
|
14481
14493
|
}) => {
|
|
14482
|
-
const [currentPage, setCurrentPage] =
|
|
14494
|
+
const [currentPage, setCurrentPage] = useState47(1);
|
|
14483
14495
|
const {
|
|
14484
14496
|
data: rawData,
|
|
14485
14497
|
isLoading,
|
|
@@ -14552,7 +14564,7 @@ var JournalContent = ({
|
|
|
14552
14564
|
config = JOURNAL_CONFIG,
|
|
14553
14565
|
stringOverrides
|
|
14554
14566
|
}) => {
|
|
14555
|
-
const [view, setView] =
|
|
14567
|
+
const [view, setView] = useState48("desktop");
|
|
14556
14568
|
const containerRef = useElementSize((_a, _b, { width }) => {
|
|
14557
14569
|
if (width) {
|
|
14558
14570
|
if (width >= BREAKPOINTS.TABLET && view !== "desktop") {
|
|
@@ -14579,9 +14591,9 @@ var JournalContent = ({
|
|
|
14579
14591
|
import React171, {
|
|
14580
14592
|
createContext as createContext14,
|
|
14581
14593
|
useContext as useContext36,
|
|
14582
|
-
useEffect as
|
|
14594
|
+
useEffect as useEffect43,
|
|
14583
14595
|
useMemo as useMemo19,
|
|
14584
|
-
useState as
|
|
14596
|
+
useState as useState52
|
|
14585
14597
|
} from "react";
|
|
14586
14598
|
|
|
14587
14599
|
// src/contexts/TasksContext/TasksContext.tsx
|
|
@@ -14598,18 +14610,19 @@ var TasksContext = createContext13({
|
|
|
14598
14610
|
});
|
|
14599
14611
|
|
|
14600
14612
|
// src/hooks/useTasks/useTasks.tsx
|
|
14601
|
-
import { useEffect as
|
|
14613
|
+
import { useEffect as useEffect40, useState as useState49 } from "react";
|
|
14602
14614
|
import useSWR10 from "swr";
|
|
14603
14615
|
var useTasks = () => {
|
|
14604
|
-
const [loadedStatus, setLoadedStatus] =
|
|
14616
|
+
const [loadedStatus, setLoadedStatus] = useState49("initial");
|
|
14605
14617
|
const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
|
|
14618
|
+
const queryKey = businessId && auth?.access_token && `tasks-${businessId}`;
|
|
14606
14619
|
const { data, isLoading, isValidating, error, mutate } = useSWR10(
|
|
14607
|
-
|
|
14620
|
+
queryKey,
|
|
14608
14621
|
Layer.getTasks(apiUrl, auth?.access_token, {
|
|
14609
14622
|
params: { businessId }
|
|
14610
14623
|
})
|
|
14611
14624
|
);
|
|
14612
|
-
|
|
14625
|
+
useEffect40(() => {
|
|
14613
14626
|
if (isLoading && loadedStatus === "initial") {
|
|
14614
14627
|
setLoadedStatus("loading");
|
|
14615
14628
|
} else if (!isLoading && loadedStatus === "loading") {
|
|
@@ -14629,13 +14642,13 @@ var useTasks = () => {
|
|
|
14629
14642
|
body: data2
|
|
14630
14643
|
}).then(() => refetch());
|
|
14631
14644
|
};
|
|
14632
|
-
|
|
14633
|
-
if (isLoading || isValidating) {
|
|
14634
|
-
read("TASKS" /* TASKS
|
|
14645
|
+
useEffect40(() => {
|
|
14646
|
+
if (queryKey && (isLoading || isValidating)) {
|
|
14647
|
+
read("TASKS" /* TASKS */, queryKey);
|
|
14635
14648
|
}
|
|
14636
14649
|
}, [isLoading, isValidating]);
|
|
14637
|
-
|
|
14638
|
-
if (hasBeenTouched(
|
|
14650
|
+
useEffect40(() => {
|
|
14651
|
+
if (queryKey && hasBeenTouched(queryKey)) {
|
|
14639
14652
|
refetch();
|
|
14640
14653
|
}
|
|
14641
14654
|
}, [syncTimestamps]);
|
|
@@ -14790,7 +14803,7 @@ var TasksHeader = ({
|
|
|
14790
14803
|
};
|
|
14791
14804
|
|
|
14792
14805
|
// src/components/TasksList/TasksList.tsx
|
|
14793
|
-
import React169, { useContext as useContext34, useMemo as useMemo18, useState as
|
|
14806
|
+
import React169, { useContext as useContext34, useMemo as useMemo18, useState as useState51 } from "react";
|
|
14794
14807
|
|
|
14795
14808
|
// src/icons/SmileIcon.tsx
|
|
14796
14809
|
import * as React167 from "react";
|
|
@@ -14844,15 +14857,15 @@ var SmileIcon = ({ size = 12, ...props }) => /* @__PURE__ */ React167.createElem
|
|
|
14844
14857
|
var SmileIcon_default = SmileIcon;
|
|
14845
14858
|
|
|
14846
14859
|
// src/components/TasksListItem/TasksListItem.tsx
|
|
14847
|
-
import React168, { useContext as useContext33, useEffect as
|
|
14860
|
+
import React168, { useContext as useContext33, useEffect as useEffect41, useState as useState50 } from "react";
|
|
14848
14861
|
import classNames57 from "classnames";
|
|
14849
14862
|
var TasksListItem = ({
|
|
14850
14863
|
task,
|
|
14851
14864
|
goToNextPageIfAllComplete,
|
|
14852
14865
|
defaultOpen
|
|
14853
14866
|
}) => {
|
|
14854
|
-
const [isOpen, setIsOpen] =
|
|
14855
|
-
const [userResponse, setUserResponse] =
|
|
14867
|
+
const [isOpen, setIsOpen] = useState50(defaultOpen);
|
|
14868
|
+
const [userResponse, setUserResponse] = useState50(task.user_response || "");
|
|
14856
14869
|
const { submitResponseToTask: submitResponseToTask2 } = useContext33(TasksContext);
|
|
14857
14870
|
const taskBodyClassName = classNames57(
|
|
14858
14871
|
"Layer__tasks-list-item__body",
|
|
@@ -14867,7 +14880,7 @@ var TasksListItem = ({
|
|
|
14867
14880
|
"Layer__tasks-list-item",
|
|
14868
14881
|
isOpen && "Layer__tasks-list-item__expanded"
|
|
14869
14882
|
);
|
|
14870
|
-
|
|
14883
|
+
useEffect41(() => {
|
|
14871
14884
|
setIsOpen(defaultOpen);
|
|
14872
14885
|
}, [defaultOpen]);
|
|
14873
14886
|
return /* @__PURE__ */ React168.createElement("div", { className: "Layer__tasks-list-item-wrapper" }, /* @__PURE__ */ React168.createElement("div", { className: taskItemClassName }, /* @__PURE__ */ React168.createElement(
|
|
@@ -14924,7 +14937,7 @@ var TasksList = ({ pageSize = 10 }) => {
|
|
|
14924
14937
|
tasks || [],
|
|
14925
14938
|
pageSize
|
|
14926
14939
|
).findIndex((page) => page.some((task) => !isComplete(task.status)));
|
|
14927
|
-
const [currentPage, setCurrentPage] =
|
|
14940
|
+
const [currentPage, setCurrentPage] = useState51(
|
|
14928
14941
|
firstPageWithIincompleteTasks === -1 ? 1 : firstPageWithIincompleteTasks + 1
|
|
14929
14942
|
);
|
|
14930
14943
|
const sortedTasks = useMemo18(() => {
|
|
@@ -14941,7 +14954,6 @@ var TasksList = ({ pageSize = 10 }) => {
|
|
|
14941
14954
|
setCurrentPage(currentPage + 1);
|
|
14942
14955
|
}
|
|
14943
14956
|
};
|
|
14944
|
-
console.log("TasksList", { tasks, sortedTasks, currentPage });
|
|
14945
14957
|
return /* @__PURE__ */ React169.createElement("div", { className: "Layer__tasks-list" }, sortedTasks && sortedTasks.length > 0 ? /* @__PURE__ */ React169.createElement(React169.Fragment, null, sortedTasks.map((task, index) => /* @__PURE__ */ React169.createElement(
|
|
14946
14958
|
TasksListItem,
|
|
14947
14959
|
{
|
|
@@ -15066,10 +15078,10 @@ var TasksComponent = ({
|
|
|
15066
15078
|
}
|
|
15067
15079
|
return false;
|
|
15068
15080
|
}, [data, isLoading]);
|
|
15069
|
-
const [open, setOpen] =
|
|
15081
|
+
const [open, setOpen] = useState52(
|
|
15070
15082
|
defaultCollapsed || collapsedWhenComplete ? false : true
|
|
15071
15083
|
);
|
|
15072
|
-
|
|
15084
|
+
useEffect43(() => {
|
|
15073
15085
|
if (allComplete && open && collapsedWhenComplete && loadedStatus === "complete") {
|
|
15074
15086
|
setOpen(false);
|
|
15075
15087
|
}
|
|
@@ -15184,14 +15196,14 @@ var BookkeepingUpsellBar = ({
|
|
|
15184
15196
|
};
|
|
15185
15197
|
|
|
15186
15198
|
// src/views/BookkeepingOverview/BookkeepingOverview.tsx
|
|
15187
|
-
import React175, { useState as
|
|
15199
|
+
import React175, { useState as useState53 } from "react";
|
|
15188
15200
|
import classNames60 from "classnames";
|
|
15189
15201
|
var BookkeepingOverview = ({
|
|
15190
15202
|
title,
|
|
15191
15203
|
// deprecated
|
|
15192
15204
|
stringOverrides
|
|
15193
15205
|
}) => {
|
|
15194
|
-
const [pnlToggle, setPnlToggle] =
|
|
15206
|
+
const [pnlToggle, setPnlToggle] = useState53("revenue");
|
|
15195
15207
|
const [width] = useWindowSize();
|
|
15196
15208
|
return /* @__PURE__ */ React175.createElement(ProfitAndLoss, { asContainer: false }, /* @__PURE__ */ React175.createElement(TasksProvider, null, /* @__PURE__ */ React175.createElement(
|
|
15197
15209
|
View,
|
|
@@ -15279,10 +15291,10 @@ var BookkeepingOverview = ({
|
|
|
15279
15291
|
};
|
|
15280
15292
|
|
|
15281
15293
|
// src/views/AccountingOverview/AccountingOverview.tsx
|
|
15282
|
-
import React179, { useState as
|
|
15294
|
+
import React179, { useState as useState55 } from "react";
|
|
15283
15295
|
|
|
15284
15296
|
// src/components/TransactionToReviewCard/TransactionToReviewCard.tsx
|
|
15285
|
-
import React178, { useContext as useContext37, useEffect as
|
|
15297
|
+
import React178, { useContext as useContext37, useEffect as useEffect44, useState as useState54 } from "react";
|
|
15286
15298
|
|
|
15287
15299
|
// src/components/BadgeLoader/BadgeLoader.tsx
|
|
15288
15300
|
import React176 from "react";
|
|
@@ -15316,14 +15328,14 @@ var TransactionToReviewCard = ({
|
|
|
15316
15328
|
}) => {
|
|
15317
15329
|
const { dateRange: contextDateRange } = useContext37(ProfitAndLoss.Context);
|
|
15318
15330
|
const dateRange = usePnlDateRange ? contextDateRange : void 0;
|
|
15319
|
-
const [toReview, setToReview] =
|
|
15331
|
+
const [toReview, setToReview] = useState54(0);
|
|
15320
15332
|
const { data, loaded, error, refetch } = useProfitAndLossLTM({
|
|
15321
15333
|
currentDate: dateRange ? dateRange.startDate : startOfMonth14(/* @__PURE__ */ new Date())
|
|
15322
15334
|
});
|
|
15323
|
-
|
|
15335
|
+
useEffect44(() => {
|
|
15324
15336
|
checkTransactionsToReview();
|
|
15325
15337
|
}, []);
|
|
15326
|
-
|
|
15338
|
+
useEffect44(() => {
|
|
15327
15339
|
checkTransactionsToReview();
|
|
15328
15340
|
}, [dateRange, loaded]);
|
|
15329
15341
|
const checkTransactionsToReview = () => {
|
|
@@ -15386,7 +15398,7 @@ var AccountingOverview = ({
|
|
|
15386
15398
|
chartColorsList,
|
|
15387
15399
|
stringOverrides
|
|
15388
15400
|
}) => {
|
|
15389
|
-
const [pnlToggle, setPnlToggle] =
|
|
15401
|
+
const [pnlToggle, setPnlToggle] = useState55("revenue");
|
|
15390
15402
|
return /* @__PURE__ */ React179.createElement(ProfitAndLoss, { asContainer: false }, /* @__PURE__ */ React179.createElement(View, { title, headerControls: /* @__PURE__ */ React179.createElement(ProfitAndLoss.DatePicker, null) }, enableOnboarding && /* @__PURE__ */ React179.createElement(
|
|
15391
15403
|
Onboarding,
|
|
15392
15404
|
{
|
|
@@ -15476,7 +15488,6 @@ var BankTransactionsWithLinkedAccounts = ({
|
|
|
15476
15488
|
showUnlinkItem = false,
|
|
15477
15489
|
showBreakConnection = false,
|
|
15478
15490
|
mode = "self-serve",
|
|
15479
|
-
hardRefreshPnlOnCategorize = false,
|
|
15480
15491
|
showDescriptions,
|
|
15481
15492
|
showReceiptUploads,
|
|
15482
15493
|
mobileComponent,
|
|
@@ -15499,20 +15510,19 @@ var BankTransactionsWithLinkedAccounts = ({
|
|
|
15499
15510
|
showReceiptUploads,
|
|
15500
15511
|
mobileComponent,
|
|
15501
15512
|
mode,
|
|
15502
|
-
hardRefreshPnlOnCategorize,
|
|
15503
15513
|
stringOverrides: stringOverrides?.bankTransactions
|
|
15504
15514
|
}
|
|
15505
15515
|
));
|
|
15506
15516
|
};
|
|
15507
15517
|
|
|
15508
15518
|
// src/views/GeneralLedger/GeneralLedger.tsx
|
|
15509
|
-
import React181, { useState as
|
|
15519
|
+
import React181, { useState as useState56 } from "react";
|
|
15510
15520
|
var GeneralLedgerView = ({
|
|
15511
15521
|
title,
|
|
15512
15522
|
// deprecated
|
|
15513
15523
|
stringOverrides
|
|
15514
15524
|
}) => {
|
|
15515
|
-
const [activeTab, setActiveTab] =
|
|
15525
|
+
const [activeTab, setActiveTab] = useState56("chartOfAccounts");
|
|
15516
15526
|
return /* @__PURE__ */ React181.createElement(ProfitAndLoss, { asContainer: false }, /* @__PURE__ */ React181.createElement(View, { title: stringOverrides?.title || title || "General Ledger" }, /* @__PURE__ */ React181.createElement(
|
|
15517
15527
|
Toggle,
|
|
15518
15528
|
{
|
|
@@ -15541,13 +15551,13 @@ var GeneralLedgerView = ({
|
|
|
15541
15551
|
};
|
|
15542
15552
|
|
|
15543
15553
|
// src/views/Reports/Reports.tsx
|
|
15544
|
-
import React182, { useContext as useContext38, useRef as useRef16, useState as
|
|
15554
|
+
import React182, { useContext as useContext38, useRef as useRef16, useState as useState57 } from "react";
|
|
15545
15555
|
var DownloadButton2 = ({
|
|
15546
15556
|
stringOverrides
|
|
15547
15557
|
}) => {
|
|
15548
15558
|
const { dateRange } = useContext38(ProfitAndLoss.Context);
|
|
15549
15559
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
15550
|
-
const [requestFailed, setRequestFailed] =
|
|
15560
|
+
const [requestFailed, setRequestFailed] = useState57(false);
|
|
15551
15561
|
const handleClick = async () => {
|
|
15552
15562
|
const month = (dateRange.startDate.getMonth() + 1).toString();
|
|
15553
15563
|
const year = dateRange.startDate.getFullYear().toString();
|
|
@@ -15614,7 +15624,7 @@ var Reports = ({
|
|
|
15614
15624
|
enabledReports = ["profitAndLoss", "balanceSheet", "statementOfCashFlow"]
|
|
15615
15625
|
}) => {
|
|
15616
15626
|
const containerRef = useRef16(null);
|
|
15617
|
-
const [activeTab, setActiveTab] =
|
|
15627
|
+
const [activeTab, setActiveTab] = useState57(enabledReports[0]);
|
|
15618
15628
|
const options = getOptions(enabledReports);
|
|
15619
15629
|
const defaultTitle = enabledReports.length > 1 ? "Reports" : options.find((option) => option.value = enabledReports[0])?.label;
|
|
15620
15630
|
return /* @__PURE__ */ React182.createElement(View, { title: stringOverrides?.title || title || defaultTitle }, enabledReports.length > 1 && /* @__PURE__ */ React182.createElement("div", { className: "Layer__component Layer__header__actions" }, /* @__PURE__ */ React182.createElement(
|