@layerfi/components 0.1.2 → 0.1.3
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 +339 -145
- package/dist/esm/index.js.map +4 -4
- package/dist/index.css +106 -0
- package/dist/index.css.map +7 -0
- package/dist/index.d.ts +41 -7
- package/dist/index.esm.css +106 -0
- package/dist/index.esm.css.map +7 -0
- package/dist/index.esm.js +252 -0
- package/dist/index.esm.js.map +7 -0
- package/dist/index.js +354 -160
- package/dist/index.js.map +4 -4
- package/dist/styles/index.css +64 -1
- package/dist/styles/index.css.map +3 -3
- package/package.json +1 -1
- package/index.d.ts +0 -1309
package/dist/index.js
CHANGED
|
@@ -598,7 +598,7 @@ var BalanceSheet = () => {
|
|
|
598
598
|
};
|
|
599
599
|
|
|
600
600
|
// src/components/BankTransactions/BankTransactions.tsx
|
|
601
|
-
var
|
|
601
|
+
var import_react30 = __toESM(require("react"));
|
|
602
602
|
|
|
603
603
|
// src/hooks/useBankTransactions/useBankTransactions.tsx
|
|
604
604
|
var import_swr2 = __toESM(require("swr"));
|
|
@@ -607,6 +607,7 @@ var useBankTransactions = () => {
|
|
|
607
607
|
const {
|
|
608
608
|
data: responseData,
|
|
609
609
|
isLoading,
|
|
610
|
+
isValidating,
|
|
610
611
|
error: responseError,
|
|
611
612
|
mutate
|
|
612
613
|
} = (0, import_swr2.default)(
|
|
@@ -616,12 +617,12 @@ var useBankTransactions = () => {
|
|
|
616
617
|
})
|
|
617
618
|
);
|
|
618
619
|
const {
|
|
619
|
-
data =
|
|
620
|
+
data = void 0,
|
|
620
621
|
meta: metadata = {},
|
|
621
622
|
error = void 0
|
|
622
623
|
} = responseData || {};
|
|
623
624
|
const categorize = (id, newCategory) => {
|
|
624
|
-
const foundBT = data
|
|
625
|
+
const foundBT = data?.find((x) => x.business_id === businessId && x.id === id);
|
|
625
626
|
if (foundBT) {
|
|
626
627
|
updateOneLocal({ ...foundBT, processing: true, error: void 0 });
|
|
627
628
|
}
|
|
@@ -638,7 +639,7 @@ var useBankTransactions = () => {
|
|
|
638
639
|
throw errors;
|
|
639
640
|
}
|
|
640
641
|
}).catch((err) => {
|
|
641
|
-
const newBT = data
|
|
642
|
+
const newBT = data?.find(
|
|
642
643
|
(x) => x.business_id === businessId && x.id === id
|
|
643
644
|
);
|
|
644
645
|
if (newBT) {
|
|
@@ -651,15 +652,20 @@ var useBankTransactions = () => {
|
|
|
651
652
|
});
|
|
652
653
|
};
|
|
653
654
|
const updateOneLocal = (newBankTransaction) => {
|
|
654
|
-
const updatedData = data
|
|
655
|
+
const updatedData = data?.map(
|
|
655
656
|
(bt) => bt.id === newBankTransaction.id ? newBankTransaction : bt
|
|
656
657
|
);
|
|
657
658
|
mutate({ data: updatedData }, { revalidate: false });
|
|
658
659
|
};
|
|
660
|
+
const refetch = () => {
|
|
661
|
+
mutate();
|
|
662
|
+
};
|
|
659
663
|
return {
|
|
660
664
|
data,
|
|
661
665
|
metadata,
|
|
662
666
|
isLoading,
|
|
667
|
+
isValidating,
|
|
668
|
+
refetch,
|
|
663
669
|
error: responseError || error,
|
|
664
670
|
categorize,
|
|
665
671
|
updateOneLocal
|
|
@@ -704,6 +710,7 @@ var Button = ({
|
|
|
704
710
|
iconOnly,
|
|
705
711
|
...props
|
|
706
712
|
}) => {
|
|
713
|
+
const buttonRef = (0, import_react8.useRef)(null);
|
|
707
714
|
let justify = "center";
|
|
708
715
|
if (leftIcon && rightIcon) {
|
|
709
716
|
justify = "space-between";
|
|
@@ -718,7 +725,23 @@ var Button = ({
|
|
|
718
725
|
iconOnly ? "Layer__btn--icon-only" : "",
|
|
719
726
|
className
|
|
720
727
|
);
|
|
721
|
-
|
|
728
|
+
const startAnimation = () => buttonRef.current && [...buttonRef.current.getElementsByClassName("animateOnHover")].forEach(
|
|
729
|
+
(el) => el.beginElement()
|
|
730
|
+
);
|
|
731
|
+
const stopAnimation = () => buttonRef.current && [...buttonRef.current.getElementsByClassName("animateOnHover")].forEach(
|
|
732
|
+
(el) => el.endElement()
|
|
733
|
+
);
|
|
734
|
+
return /* @__PURE__ */ import_react8.default.createElement(
|
|
735
|
+
"button",
|
|
736
|
+
{
|
|
737
|
+
...props,
|
|
738
|
+
className: baseClassName,
|
|
739
|
+
onMouseEnter: startAnimation,
|
|
740
|
+
onMouseLeave: stopAnimation,
|
|
741
|
+
ref: buttonRef
|
|
742
|
+
},
|
|
743
|
+
/* @__PURE__ */ import_react8.default.createElement("span", { className: `Layer__btn-content Layer__justify--${justify}` }, leftIcon && /* @__PURE__ */ import_react8.default.createElement("span", { className: "Layer__btn-icon Layer__btn-icon--left" }, leftIcon), !iconOnly && /* @__PURE__ */ import_react8.default.createElement("span", { className: "Layer__btn-text" }, children), rightIcon && /* @__PURE__ */ import_react8.default.createElement("span", { className: "Layer__btn-icon Layer__btn-icon--right" }, rightIcon))
|
|
744
|
+
);
|
|
722
745
|
};
|
|
723
746
|
|
|
724
747
|
// src/components/Button/SubmitButton.tsx
|
|
@@ -1258,66 +1281,135 @@ var RefreshCcw = ({ size = 18, ...props }) => /* @__PURE__ */ React19.createElem
|
|
|
1258
1281
|
);
|
|
1259
1282
|
var RefreshCcw_default = RefreshCcw;
|
|
1260
1283
|
|
|
1261
|
-
// src/icons/
|
|
1284
|
+
// src/icons/Scissors.tsx
|
|
1262
1285
|
var React20 = __toESM(require("react"));
|
|
1263
|
-
var
|
|
1286
|
+
var Scissors = ({ size = 11, ...props }) => /* @__PURE__ */ React20.createElement(
|
|
1264
1287
|
"svg",
|
|
1265
1288
|
{
|
|
1266
|
-
viewBox: "0 0
|
|
1289
|
+
viewBox: "0 0 11 11",
|
|
1267
1290
|
fill: "none",
|
|
1268
1291
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1269
1292
|
...props,
|
|
1270
1293
|
width: size,
|
|
1271
1294
|
height: size
|
|
1272
1295
|
},
|
|
1273
|
-
/* @__PURE__ */ React20.createElement(
|
|
1296
|
+
/* @__PURE__ */ React20.createElement(
|
|
1274
1297
|
"path",
|
|
1275
1298
|
{
|
|
1276
|
-
|
|
1277
|
-
d: "M3 4.5C3.82843 4.5 4.5 3.82843 4.5 3C4.5 2.17157 3.82843 1.5 3 1.5C2.17157 1.5 1.5 2.17157 1.5 3C1.5 3.82843 2.17157 4.5 3 4.5Z",
|
|
1299
|
+
d: "M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z",
|
|
1278
1300
|
stroke: "currentColor",
|
|
1279
1301
|
strokeLinecap: "round",
|
|
1280
1302
|
strokeLinejoin: "round"
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1303
|
+
},
|
|
1304
|
+
/* @__PURE__ */ React20.createElement(
|
|
1305
|
+
"animate",
|
|
1306
|
+
{
|
|
1307
|
+
attributeName: "d",
|
|
1308
|
+
className: "animateOnHover",
|
|
1309
|
+
values: "M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z;M2.50519 5.21436C3.20276 4.91424 3.52494 4.10544 3.22481 3.40788C2.92468 2.71031 2.11589 2.38813 1.41833 2.68826C0.720762 2.98839 0.398577 3.79718 0.698706 4.49474C0.998836 5.19231 1.80763 5.51449 2.50519 5.21436Z;M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z",
|
|
1310
|
+
begin: "indefinite",
|
|
1311
|
+
dur: "400ms",
|
|
1312
|
+
repeatCount: "1",
|
|
1313
|
+
fill: "freeze",
|
|
1314
|
+
calcMode: "linear",
|
|
1315
|
+
keyTimes: "0;0.5;1"
|
|
1316
|
+
}
|
|
1317
|
+
)
|
|
1318
|
+
),
|
|
1319
|
+
/* @__PURE__ */ React20.createElement(
|
|
1283
1320
|
"path",
|
|
1284
1321
|
{
|
|
1285
|
-
|
|
1286
|
-
d: "M3 10.5C3.82843 10.5 4.5 9.82843 4.5 9C4.5 8.17157 3.82843 7.5 3 7.5C2.17157 7.5 1.5 8.17157 1.5 9C1.5 9.82843 2.17157 10.5 3 10.5Z",
|
|
1322
|
+
d: "M2.75 9.625C3.50939 9.625 4.125 9.00939 4.125 8.25C4.125 7.49061 3.50939 6.875 2.75 6.875C1.99061 6.875 1.375 7.49061 1.375 8.25C1.375 9.00939 1.99061 9.625 2.75 9.625Z",
|
|
1287
1323
|
stroke: "currentColor",
|
|
1288
1324
|
strokeLinecap: "round",
|
|
1289
1325
|
strokeLinejoin: "round"
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1326
|
+
},
|
|
1327
|
+
/* @__PURE__ */ React20.createElement(
|
|
1328
|
+
"animate",
|
|
1329
|
+
{
|
|
1330
|
+
attributeName: "d",
|
|
1331
|
+
className: "animateOnHover",
|
|
1332
|
+
values: "M2.75 9.625C3.50939 9.625 4.125 9.00939 4.125 8.25C4.125 7.49061 3.50939 6.875 2.75 6.875C1.99061 6.875 1.375 7.49061 1.375 8.25C1.375 9.00939 1.99061 9.625 2.75 9.625Z;M1.43277 8.38576C2.13615 8.67201 2.9384 8.33386 3.22465 7.63049C3.5109 6.92711 3.17275 6.12486 2.46937 5.83861C1.766 5.55236 0.96375 5.89051 0.6775 6.59389C0.391251 7.29726 0.729398 8.09951 1.43277 8.38576Z;M2.75 9.625C3.50939 9.625 4.125 9.00939 4.125 8.25C4.125 7.49061 3.50939 6.875 2.75 6.875C1.99061 6.875 1.375 7.49061 1.375 8.25C1.375 9.00939 1.99061 9.625 2.75 9.625Z",
|
|
1333
|
+
begin: "indefinite",
|
|
1334
|
+
dur: "400ms",
|
|
1335
|
+
repeatCount: "1",
|
|
1336
|
+
fill: "freeze",
|
|
1337
|
+
calcMode: "linear",
|
|
1338
|
+
keyTimes: "0;0.5;1"
|
|
1339
|
+
}
|
|
1340
|
+
)
|
|
1341
|
+
),
|
|
1342
|
+
/* @__PURE__ */ React20.createElement(
|
|
1292
1343
|
"path",
|
|
1293
1344
|
{
|
|
1294
|
-
|
|
1295
|
-
d: "M10 2L4.06 7.94",
|
|
1345
|
+
d: "M9.16668 1.83325L3.72168 7.27825",
|
|
1296
1346
|
stroke: "currentColor",
|
|
1297
1347
|
strokeLinecap: "round",
|
|
1298
1348
|
strokeLinejoin: "round"
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1349
|
+
},
|
|
1350
|
+
/* @__PURE__ */ React20.createElement(
|
|
1351
|
+
"animate",
|
|
1352
|
+
{
|
|
1353
|
+
attributeName: "d",
|
|
1354
|
+
className: "animateOnHover",
|
|
1355
|
+
values: "M9.16668 1.83325L3.72168 7.27825;M10.3129 3.58763L3.21706 6.57851;M9.16668 1.83325L3.72168 7.27825",
|
|
1356
|
+
begin: "indefinite",
|
|
1357
|
+
dur: "400ms",
|
|
1358
|
+
repeatCount: "1",
|
|
1359
|
+
fill: "freeze",
|
|
1360
|
+
calcMode: "linear",
|
|
1361
|
+
keyTimes: "0;0.5;1"
|
|
1362
|
+
}
|
|
1363
|
+
)
|
|
1364
|
+
),
|
|
1365
|
+
/* @__PURE__ */ React20.createElement(
|
|
1301
1366
|
"path",
|
|
1302
1367
|
{
|
|
1303
|
-
|
|
1304
|
-
d: "M7.235 7.23999L10 9.99999",
|
|
1368
|
+
d: "M6.63232 6.63672L9.16691 9.16672",
|
|
1305
1369
|
stroke: "currentColor",
|
|
1306
1370
|
strokeLinecap: "round",
|
|
1307
1371
|
strokeLinejoin: "round"
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1372
|
+
},
|
|
1373
|
+
/* @__PURE__ */ React20.createElement(
|
|
1374
|
+
"animate",
|
|
1375
|
+
{
|
|
1376
|
+
attributeName: "d",
|
|
1377
|
+
className: "animateOnHover",
|
|
1378
|
+
values: "M6.63232 6.63672L9.16691 9.16672;M7.06396 5.9873L10.3921 7.3096;M6.63232 6.63672L9.16691 9.16672",
|
|
1379
|
+
begin: "indefinite",
|
|
1380
|
+
dur: "400ms",
|
|
1381
|
+
repeatCount: "1",
|
|
1382
|
+
fill: "freeze",
|
|
1383
|
+
calcMode: "linear",
|
|
1384
|
+
keyTimes: "0;0.5;1"
|
|
1385
|
+
}
|
|
1386
|
+
)
|
|
1387
|
+
),
|
|
1388
|
+
/* @__PURE__ */ React20.createElement(
|
|
1310
1389
|
"path",
|
|
1311
1390
|
{
|
|
1312
|
-
|
|
1313
|
-
d: "M4.06 4.06006L6 6.00006",
|
|
1391
|
+
d: "M3.72168 3.72168L5.50001 5.50001",
|
|
1314
1392
|
stroke: "currentColor",
|
|
1315
1393
|
strokeLinecap: "round",
|
|
1316
1394
|
strokeLinejoin: "round"
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1395
|
+
},
|
|
1396
|
+
/* @__PURE__ */ React20.createElement(
|
|
1397
|
+
"animate",
|
|
1398
|
+
{
|
|
1399
|
+
attributeName: "d",
|
|
1400
|
+
className: "animateOnHover",
|
|
1401
|
+
values: "M3.72168 3.72168L5.50001 5.50001;M3.23828 4.45996L5.57467 5.39067;M3.72168 3.72168L5.50001 5.50001",
|
|
1402
|
+
begin: "indefinite",
|
|
1403
|
+
dur: "400ms",
|
|
1404
|
+
repeatCount: "1",
|
|
1405
|
+
fill: "freeze",
|
|
1406
|
+
calcMode: "linear",
|
|
1407
|
+
keyTimes: "0;0.5;1"
|
|
1408
|
+
}
|
|
1409
|
+
)
|
|
1410
|
+
)
|
|
1319
1411
|
);
|
|
1320
|
-
var
|
|
1412
|
+
var Scissors_default = Scissors;
|
|
1321
1413
|
|
|
1322
1414
|
// src/components/Input/Input.tsx
|
|
1323
1415
|
var import_react15 = __toESM(require("react"));
|
|
@@ -1653,7 +1745,7 @@ var ExpandedBankTransactionRow = (0, import_react22.forwardRef)(
|
|
|
1653
1745
|
bankTransaction,
|
|
1654
1746
|
isOpen = false,
|
|
1655
1747
|
asListItem = false,
|
|
1656
|
-
|
|
1748
|
+
submitBtnText = "Save"
|
|
1657
1749
|
}, ref) => {
|
|
1658
1750
|
const { categorize: categorizeBankTransaction2 } = useBankTransactions();
|
|
1659
1751
|
const [purpose, setPurpose] = (0, import_react22.useState)("categorize" /* categorize */);
|
|
@@ -1792,7 +1884,7 @@ var ExpandedBankTransactionRow = (0, import_react22.forwardRef)(
|
|
|
1792
1884
|
Button,
|
|
1793
1885
|
{
|
|
1794
1886
|
onClick: addSplit,
|
|
1795
|
-
leftIcon: /* @__PURE__ */ import_react22.default.createElement(
|
|
1887
|
+
leftIcon: /* @__PURE__ */ import_react22.default.createElement(Scissors_default, { size: 14 }),
|
|
1796
1888
|
variant: "secondary" /* secondary */
|
|
1797
1889
|
},
|
|
1798
1890
|
"Split"
|
|
@@ -1815,7 +1907,7 @@ var ExpandedBankTransactionRow = (0, import_react22.forwardRef)(
|
|
|
1815
1907
|
/* @__PURE__ */ import_react22.default.createElement(Textarea, { name: "description", placeholder: "Enter description" })
|
|
1816
1908
|
),
|
|
1817
1909
|
/* @__PURE__ */ import_react22.default.createElement("div", { className: `${className}__file-upload` }, /* @__PURE__ */ import_react22.default.createElement(FileInput, { text: "Upload receipt" })),
|
|
1818
|
-
asListItem
|
|
1910
|
+
asListItem ? /* @__PURE__ */ import_react22.default.createElement("div", { className: `${className}__submit-btn` }, /* @__PURE__ */ import_react22.default.createElement(
|
|
1819
1911
|
SubmitButton,
|
|
1820
1912
|
{
|
|
1821
1913
|
onClick: () => {
|
|
@@ -1828,7 +1920,7 @@ var ExpandedBankTransactionRow = (0, import_react22.forwardRef)(
|
|
|
1828
1920
|
error: bankTransaction.error,
|
|
1829
1921
|
active: true
|
|
1830
1922
|
},
|
|
1831
|
-
|
|
1923
|
+
submitBtnText
|
|
1832
1924
|
)) : null
|
|
1833
1925
|
))
|
|
1834
1926
|
);
|
|
@@ -1906,7 +1998,8 @@ var BankTransactionListItem = ({
|
|
|
1906
1998
|
bankTransaction,
|
|
1907
1999
|
close: () => toggleOpen(bankTransaction.id),
|
|
1908
2000
|
isOpen,
|
|
1909
|
-
asListItem: true
|
|
2001
|
+
asListItem: true,
|
|
2002
|
+
submitBtnText: editable ? "Approve" : "Save"
|
|
1910
2003
|
}
|
|
1911
2004
|
)), /* @__PURE__ */ import_react24.default.createElement("span", { className: `${className}__base-row` }, editable ? /* @__PURE__ */ import_react24.default.createElement(
|
|
1912
2005
|
CategoryMenu,
|
|
@@ -2039,8 +2132,8 @@ var BankTransactionRow = ({
|
|
|
2039
2132
|
disabled: bankTransaction.processing
|
|
2040
2133
|
}
|
|
2041
2134
|
) : null,
|
|
2042
|
-
!editable ? /* @__PURE__ */ import_react25.default.createElement(Text, { as: "span", className: `${className}__category-text` }, bankTransaction?.category?.display_name) : null,
|
|
2043
|
-
editable
|
|
2135
|
+
!editable && !isOpen ? /* @__PURE__ */ import_react25.default.createElement(Text, { as: "span", className: `${className}__category-text` }, bankTransaction?.category?.display_name) : null,
|
|
2136
|
+
editable || isOpen ? /* @__PURE__ */ import_react25.default.createElement(
|
|
2044
2137
|
SubmitButton,
|
|
2045
2138
|
{
|
|
2046
2139
|
onClick: () => {
|
|
@@ -2053,8 +2146,8 @@ var BankTransactionRow = ({
|
|
|
2053
2146
|
error: bankTransaction.error,
|
|
2054
2147
|
active: isOpen
|
|
2055
2148
|
},
|
|
2056
|
-
"Approve"
|
|
2057
|
-
),
|
|
2149
|
+
editable ? "Approve" : "Save"
|
|
2150
|
+
) : null,
|
|
2058
2151
|
/* @__PURE__ */ import_react25.default.createElement(
|
|
2059
2152
|
"div",
|
|
2060
2153
|
{
|
|
@@ -2076,8 +2169,7 @@ var BankTransactionRow = ({
|
|
|
2076
2169
|
ref: expandedRowRef,
|
|
2077
2170
|
bankTransaction,
|
|
2078
2171
|
close: () => toggleOpen(bankTransaction.id),
|
|
2079
|
-
isOpen
|
|
2080
|
-
showSubmitButton: !editable
|
|
2172
|
+
isOpen
|
|
2081
2173
|
}
|
|
2082
2174
|
))));
|
|
2083
2175
|
};
|
|
@@ -2104,7 +2196,6 @@ var parseColorFromTheme = (colorName, color) => {
|
|
|
2104
2196
|
}
|
|
2105
2197
|
try {
|
|
2106
2198
|
if ("h" in color && "s" in color && "l" in color) {
|
|
2107
|
-
console.log("its hsl", color);
|
|
2108
2199
|
return {
|
|
2109
2200
|
[`--color-${colorName}-h`]: color.h,
|
|
2110
2201
|
[`--color-${colorName}-s`]: color.s,
|
|
@@ -2113,7 +2204,6 @@ var parseColorFromTheme = (colorName, color) => {
|
|
|
2113
2204
|
}
|
|
2114
2205
|
if ("r" in color && "g" in color && "b" in color) {
|
|
2115
2206
|
const { h, s, l } = rgbToHsl(color);
|
|
2116
|
-
console.log("its rgb", h, s, l);
|
|
2117
2207
|
return {
|
|
2118
2208
|
[`--color-${colorName}-h`]: h,
|
|
2119
2209
|
[`--color-${colorName}-s`]: `${s}%`,
|
|
@@ -2121,7 +2211,6 @@ var parseColorFromTheme = (colorName, color) => {
|
|
|
2121
2211
|
};
|
|
2122
2212
|
}
|
|
2123
2213
|
if ("hex" in color) {
|
|
2124
|
-
console.log("its hex");
|
|
2125
2214
|
const rgb = hexToRgb(color.hex);
|
|
2126
2215
|
if (!rgb) {
|
|
2127
2216
|
return {};
|
|
@@ -2131,7 +2220,6 @@ var parseColorFromTheme = (colorName, color) => {
|
|
|
2131
2220
|
g: rgb.g.toString(),
|
|
2132
2221
|
b: rgb.b.toString()
|
|
2133
2222
|
});
|
|
2134
|
-
console.log("its hex", h, s, l);
|
|
2135
2223
|
return {
|
|
2136
2224
|
[`--color-${colorName}-h`]: h,
|
|
2137
2225
|
[`--color-${colorName}-s`]: `${s}%`,
|
|
@@ -2175,34 +2263,120 @@ var hexToRgb = (hex) => {
|
|
|
2175
2263
|
};
|
|
2176
2264
|
|
|
2177
2265
|
// src/components/Container/Container.tsx
|
|
2178
|
-
var
|
|
2179
|
-
|
|
2266
|
+
var import_classnames11 = __toESM(require("classnames"));
|
|
2267
|
+
var Container = ({
|
|
2268
|
+
name,
|
|
2269
|
+
className,
|
|
2270
|
+
children,
|
|
2271
|
+
asWidget
|
|
2272
|
+
}) => {
|
|
2273
|
+
const baseClassName = (0, import_classnames11.default)(
|
|
2274
|
+
"Layer__component Layer__component-container",
|
|
2275
|
+
`Layer__${name}`,
|
|
2276
|
+
asWidget ? "Layer__component--as-widget" : "",
|
|
2277
|
+
className
|
|
2278
|
+
);
|
|
2180
2279
|
const { theme } = useLayerContext();
|
|
2181
2280
|
const styles = parseStylesFromThemeConfig(theme);
|
|
2182
|
-
return /* @__PURE__ */ import_react26.default.createElement(
|
|
2183
|
-
"div",
|
|
2184
|
-
{
|
|
2185
|
-
className: `Layer__component Layer__component-container ${baseClassName}`,
|
|
2186
|
-
style: { ...styles }
|
|
2187
|
-
},
|
|
2188
|
-
children
|
|
2189
|
-
);
|
|
2281
|
+
return /* @__PURE__ */ import_react26.default.createElement("div", { className: baseClassName, style: { ...styles } }, children);
|
|
2190
2282
|
};
|
|
2191
2283
|
|
|
2192
2284
|
// src/components/Container/Header.tsx
|
|
2193
2285
|
var import_react27 = __toESM(require("react"));
|
|
2194
|
-
var
|
|
2286
|
+
var import_classnames12 = __toESM(require("classnames"));
|
|
2195
2287
|
var Header = (0, import_react27.forwardRef)(
|
|
2196
2288
|
({ className, children, style }, ref) => {
|
|
2197
|
-
const baseClassName = (0,
|
|
2289
|
+
const baseClassName = (0, import_classnames12.default)("Layer__component-header", className);
|
|
2198
2290
|
return /* @__PURE__ */ import_react27.default.createElement("header", { ref, className: baseClassName, style }, children);
|
|
2199
2291
|
}
|
|
2200
2292
|
);
|
|
2201
2293
|
|
|
2202
|
-
// src/components/
|
|
2294
|
+
// src/components/DataState/DataState.tsx
|
|
2203
2295
|
var import_react28 = __toESM(require("react"));
|
|
2296
|
+
|
|
2297
|
+
// src/icons/AlertOctagon.tsx
|
|
2298
|
+
var React35 = __toESM(require("react"));
|
|
2299
|
+
var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React35.createElement(
|
|
2300
|
+
"svg",
|
|
2301
|
+
{
|
|
2302
|
+
viewBox: "0 0 18 18",
|
|
2303
|
+
fill: "none",
|
|
2304
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2305
|
+
...props,
|
|
2306
|
+
width: size,
|
|
2307
|
+
height: size
|
|
2308
|
+
},
|
|
2309
|
+
/* @__PURE__ */ React35.createElement(
|
|
2310
|
+
"path",
|
|
2311
|
+
{
|
|
2312
|
+
d: "M5.895 1.5H12.105L16.5 5.895V12.105L12.105 16.5H5.895L1.5 12.105V5.895L5.895 1.5Z",
|
|
2313
|
+
stroke: "currentColor",
|
|
2314
|
+
strokeLinecap: "round",
|
|
2315
|
+
strokeLinejoin: "round"
|
|
2316
|
+
}
|
|
2317
|
+
),
|
|
2318
|
+
/* @__PURE__ */ React35.createElement(
|
|
2319
|
+
"path",
|
|
2320
|
+
{
|
|
2321
|
+
d: "M9 6V9",
|
|
2322
|
+
stroke: "currentColor",
|
|
2323
|
+
strokeLinecap: "round",
|
|
2324
|
+
strokeLinejoin: "round"
|
|
2325
|
+
}
|
|
2326
|
+
),
|
|
2327
|
+
/* @__PURE__ */ React35.createElement(
|
|
2328
|
+
"path",
|
|
2329
|
+
{
|
|
2330
|
+
d: "M9 12H9.0075",
|
|
2331
|
+
stroke: "currentColor",
|
|
2332
|
+
strokeLinecap: "round",
|
|
2333
|
+
strokeLinejoin: "round"
|
|
2334
|
+
}
|
|
2335
|
+
)
|
|
2336
|
+
);
|
|
2337
|
+
var AlertOctagon_default = AlertOctagon;
|
|
2338
|
+
|
|
2339
|
+
// src/components/DataState/DataState.tsx
|
|
2340
|
+
var getIcon = (status) => {
|
|
2341
|
+
switch (status) {
|
|
2342
|
+
case "failed" /* failed */:
|
|
2343
|
+
return /* @__PURE__ */ import_react28.default.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--error" }, /* @__PURE__ */ import_react28.default.createElement(AlertOctagon_default, { size: 12 }));
|
|
2344
|
+
default:
|
|
2345
|
+
return /* @__PURE__ */ import_react28.default.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--neutral" }, /* @__PURE__ */ import_react28.default.createElement(CheckCircle_default, { size: 12 }));
|
|
2346
|
+
}
|
|
2347
|
+
};
|
|
2348
|
+
var DataState = ({
|
|
2349
|
+
status,
|
|
2350
|
+
title,
|
|
2351
|
+
description,
|
|
2352
|
+
onRefresh,
|
|
2353
|
+
isLoading
|
|
2354
|
+
}) => {
|
|
2355
|
+
return /* @__PURE__ */ import_react28.default.createElement("div", { className: "Layer__data-state" }, getIcon(status), /* @__PURE__ */ import_react28.default.createElement(
|
|
2356
|
+
Text,
|
|
2357
|
+
{
|
|
2358
|
+
as: "span",
|
|
2359
|
+
size: "lg" /* lg */,
|
|
2360
|
+
weight: "bold" /* bold */,
|
|
2361
|
+
className: "Layer__data-state__title"
|
|
2362
|
+
},
|
|
2363
|
+
title
|
|
2364
|
+
), /* @__PURE__ */ import_react28.default.createElement(Text, { as: "span", className: "Layer__data-state__description" }, description), onRefresh && /* @__PURE__ */ import_react28.default.createElement("span", { className: "Layer__data-state__btn" }, /* @__PURE__ */ import_react28.default.createElement(
|
|
2365
|
+
Button,
|
|
2366
|
+
{
|
|
2367
|
+
variant: "secondary" /* secondary */,
|
|
2368
|
+
rightIcon: isLoading ? /* @__PURE__ */ import_react28.default.createElement(Loader_default, { size: 14, className: "Layer__anim--rotating" }) : /* @__PURE__ */ import_react28.default.createElement(RefreshCcw_default, { size: 12 }),
|
|
2369
|
+
onClick: onRefresh,
|
|
2370
|
+
disabled: isLoading
|
|
2371
|
+
},
|
|
2372
|
+
"Refresh"
|
|
2373
|
+
)));
|
|
2374
|
+
};
|
|
2375
|
+
|
|
2376
|
+
// src/components/Loader/Loader.tsx
|
|
2377
|
+
var import_react29 = __toESM(require("react"));
|
|
2204
2378
|
var Loader2 = ({ children }) => {
|
|
2205
|
-
return /* @__PURE__ */
|
|
2379
|
+
return /* @__PURE__ */ import_react29.default.createElement("span", { className: "Layer__loader" }, /* @__PURE__ */ import_react29.default.createElement(Loader_default, { size: 28, className: "Layer__anim--rotating" }), children);
|
|
2206
2380
|
};
|
|
2207
2381
|
|
|
2208
2382
|
// src/components/BankTransactions/BankTransactions.tsx
|
|
@@ -2224,16 +2398,18 @@ var filterVisibility = (display) => (bankTransaction) => {
|
|
|
2224
2398
|
const inReview = ReviewCategories.includes(bankTransaction.categorization_status) || bankTransaction.recently_categorized;
|
|
2225
2399
|
return display === "review" /* review */ && inReview || display === "categorized" /* categorized */ && categorized;
|
|
2226
2400
|
};
|
|
2227
|
-
var BankTransactions = (
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
const
|
|
2401
|
+
var BankTransactions = ({
|
|
2402
|
+
asWidget = false
|
|
2403
|
+
}) => {
|
|
2404
|
+
const [display, setDisplay] = (0, import_react30.useState)("review" /* review */);
|
|
2405
|
+
const { data, isLoading, error, isValidating, refetch } = useBankTransactions();
|
|
2406
|
+
const bankTransactions = data?.filter(filterVisibility(display));
|
|
2231
2407
|
const onCategorizationDisplayChange = (event) => setDisplay(
|
|
2232
2408
|
event.target.value === "categorized" /* categorized */ ? "categorized" /* categorized */ : "review" /* review */
|
|
2233
2409
|
);
|
|
2234
|
-
const [openRows, setOpenRows] = (0,
|
|
2410
|
+
const [openRows, setOpenRows] = (0, import_react30.useState)({});
|
|
2235
2411
|
const toggleOpen = (id) => setOpenRows({ ...openRows, [id]: !openRows[id] });
|
|
2236
|
-
const [shiftStickyHeader, setShiftStickyHeader] = (0,
|
|
2412
|
+
const [shiftStickyHeader, setShiftStickyHeader] = (0, import_react30.useState)(0);
|
|
2237
2413
|
const headerRef = useElementSize((_el, _en, size) => {
|
|
2238
2414
|
if (size?.height && size?.height >= 90) {
|
|
2239
2415
|
const newShift = -Math.floor(size.height / 2) + 6;
|
|
@@ -2245,15 +2421,15 @@ var BankTransactions = () => {
|
|
|
2245
2421
|
}
|
|
2246
2422
|
});
|
|
2247
2423
|
const editable = display === "review" /* review */;
|
|
2248
|
-
return /* @__PURE__ */
|
|
2424
|
+
return /* @__PURE__ */ import_react30.default.createElement(Container, { name: COMPONENT_NAME, asWidget }, /* @__PURE__ */ import_react30.default.createElement(
|
|
2249
2425
|
Header,
|
|
2250
2426
|
{
|
|
2251
2427
|
ref: headerRef,
|
|
2252
2428
|
className: "Layer__bank-transactions__header",
|
|
2253
2429
|
style: { top: shiftStickyHeader }
|
|
2254
2430
|
},
|
|
2255
|
-
/* @__PURE__ */
|
|
2256
|
-
/* @__PURE__ */
|
|
2431
|
+
/* @__PURE__ */ import_react30.default.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Transactions"),
|
|
2432
|
+
/* @__PURE__ */ import_react30.default.createElement(
|
|
2257
2433
|
Toggle,
|
|
2258
2434
|
{
|
|
2259
2435
|
name: "bank-transaction-display",
|
|
@@ -2265,14 +2441,14 @@ var BankTransactions = () => {
|
|
|
2265
2441
|
onChange: onCategorizationDisplayChange
|
|
2266
2442
|
}
|
|
2267
2443
|
)
|
|
2268
|
-
), /* @__PURE__ */
|
|
2444
|
+
), /* @__PURE__ */ import_react30.default.createElement(
|
|
2269
2445
|
"table",
|
|
2270
2446
|
{
|
|
2271
2447
|
width: "100%",
|
|
2272
2448
|
className: "Layer__table Layer__bank-transactions__table"
|
|
2273
2449
|
},
|
|
2274
|
-
/* @__PURE__ */
|
|
2275
|
-
/* @__PURE__ */
|
|
2450
|
+
/* @__PURE__ */ import_react30.default.createElement("thead", null, /* @__PURE__ */ import_react30.default.createElement("tr", null, /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__date-col" }, "Date"), /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__tx-col" }, "Transaction"), /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__account-col" }, "Account"), /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount Layer__table-cell__amount-col" }, "Amount"), editable ? /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__table-header--primary Layer__table-cell__category-col" }, "Categorize") : /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__table-cell__category-col" }, "Category"))),
|
|
2451
|
+
/* @__PURE__ */ import_react30.default.createElement("tbody", null, !isLoading && bankTransactions?.map((bankTransaction) => /* @__PURE__ */ import_react30.default.createElement(
|
|
2276
2452
|
BankTransactionRow,
|
|
2277
2453
|
{
|
|
2278
2454
|
key: bankTransaction.id,
|
|
@@ -2283,7 +2459,7 @@ var BankTransactions = () => {
|
|
|
2283
2459
|
editable
|
|
2284
2460
|
}
|
|
2285
2461
|
)))
|
|
2286
|
-
), isLoading
|
|
2462
|
+
), isLoading && !bankTransactions ? /* @__PURE__ */ import_react30.default.createElement("div", { className: "Layer__bank-transactions__loader-container" }, /* @__PURE__ */ import_react30.default.createElement(Loader2, null)) : null, !isLoading && /* @__PURE__ */ import_react30.default.createElement("ul", { className: "Layer__bank-transactions__list" }, bankTransactions?.map((bankTransaction) => /* @__PURE__ */ import_react30.default.createElement(
|
|
2287
2463
|
BankTransactionListItem,
|
|
2288
2464
|
{
|
|
2289
2465
|
key: bankTransaction.id,
|
|
@@ -2293,11 +2469,29 @@ var BankTransactions = () => {
|
|
|
2293
2469
|
toggleOpen,
|
|
2294
2470
|
editable
|
|
2295
2471
|
}
|
|
2296
|
-
))))
|
|
2472
|
+
))), !isLoading && !error && (bankTransactions === void 0 || bankTransactions !== void 0 && bankTransactions.length === 0) ? /* @__PURE__ */ import_react30.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react30.default.createElement(
|
|
2473
|
+
DataState,
|
|
2474
|
+
{
|
|
2475
|
+
status: "allDone" /* allDone */,
|
|
2476
|
+
title: "You are up to date with transactions!",
|
|
2477
|
+
description: "All uncategorized transaction will be displayed here",
|
|
2478
|
+
onRefresh: () => refetch(),
|
|
2479
|
+
isLoading: isValidating
|
|
2480
|
+
}
|
|
2481
|
+
)) : null, !isLoading && error ? /* @__PURE__ */ import_react30.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react30.default.createElement(
|
|
2482
|
+
DataState,
|
|
2483
|
+
{
|
|
2484
|
+
status: "failed" /* failed */,
|
|
2485
|
+
title: "Something went wrong",
|
|
2486
|
+
description: "We couldn\u2019t load your data.",
|
|
2487
|
+
onRefresh: () => refetch(),
|
|
2488
|
+
isLoading: isValidating
|
|
2489
|
+
}
|
|
2490
|
+
)) : null);
|
|
2297
2491
|
};
|
|
2298
2492
|
|
|
2299
2493
|
// src/components/Hello/Hello.tsx
|
|
2300
|
-
var
|
|
2494
|
+
var import_react31 = __toESM(require("react"));
|
|
2301
2495
|
var import_swr3 = __toESM(require("swr"));
|
|
2302
2496
|
var fetcher = (url) => fetch(url).then((res) => res.json());
|
|
2303
2497
|
var Hello = ({ user }) => {
|
|
@@ -2306,14 +2500,14 @@ var Hello = ({ user }) => {
|
|
|
2306
2500
|
fetcher
|
|
2307
2501
|
);
|
|
2308
2502
|
const name = (isLoading ? "..." : data?.name) || "User";
|
|
2309
|
-
return /* @__PURE__ */
|
|
2503
|
+
return /* @__PURE__ */ import_react31.default.createElement(import_react31.default.Fragment, null, /* @__PURE__ */ import_react31.default.createElement("div", { className: "hello" }, "Hello, ", name, "!"));
|
|
2310
2504
|
};
|
|
2311
2505
|
|
|
2312
2506
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
2313
|
-
var
|
|
2507
|
+
var import_react39 = __toESM(require("react"));
|
|
2314
2508
|
|
|
2315
2509
|
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
2316
|
-
var
|
|
2510
|
+
var import_react32 = require("react");
|
|
2317
2511
|
var import_date_fns6 = require("date-fns");
|
|
2318
2512
|
var import_swr4 = __toESM(require("swr"));
|
|
2319
2513
|
var useProfitAndLoss = ({ startDate: initialStartDate, endDate: initialEndDate } = {
|
|
@@ -2321,10 +2515,10 @@ var useProfitAndLoss = ({ startDate: initialStartDate, endDate: initialEndDate }
|
|
|
2321
2515
|
endDate: (0, import_date_fns6.endOfMonth)(/* @__PURE__ */ new Date())
|
|
2322
2516
|
}) => {
|
|
2323
2517
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
2324
|
-
const [startDate, setStartDate] = (0,
|
|
2518
|
+
const [startDate, setStartDate] = (0, import_react32.useState)(
|
|
2325
2519
|
initialStartDate || (0, import_date_fns6.startOfMonth)(Date.now())
|
|
2326
2520
|
);
|
|
2327
|
-
const [endDate, setEndDate] = (0,
|
|
2521
|
+
const [endDate, setEndDate] = (0, import_react32.useState)(
|
|
2328
2522
|
initialEndDate || (0, import_date_fns6.endOfMonth)(Date.now())
|
|
2329
2523
|
);
|
|
2330
2524
|
const {
|
|
@@ -2359,10 +2553,10 @@ var useProfitAndLoss = ({ startDate: initialStartDate, endDate: initialEndDate }
|
|
|
2359
2553
|
};
|
|
2360
2554
|
|
|
2361
2555
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
2362
|
-
var
|
|
2556
|
+
var import_react34 = __toESM(require("react"));
|
|
2363
2557
|
|
|
2364
2558
|
// src/components/ProfitAndLossChart/Indicator.tsx
|
|
2365
|
-
var
|
|
2559
|
+
var import_react33 = __toESM(require("react"));
|
|
2366
2560
|
var emptyViewBox = { x: 0, y: 0, width: 0, height: 0 };
|
|
2367
2561
|
var Indicator = ({
|
|
2368
2562
|
viewBox = {},
|
|
@@ -2382,11 +2576,11 @@ var Indicator = ({
|
|
|
2382
2576
|
const boxWidth = width * 2 + 4;
|
|
2383
2577
|
const multiplier = 1.5;
|
|
2384
2578
|
const xOffset = (boxWidth * multiplier - boxWidth) / 2;
|
|
2385
|
-
(0,
|
|
2579
|
+
(0, import_react33.useEffect)(() => {
|
|
2386
2580
|
setAnimateFrom(animateTo);
|
|
2387
2581
|
}, [animateTo]);
|
|
2388
2582
|
const actualX = animateFrom === -1 ? animateTo : animateFrom;
|
|
2389
|
-
return /* @__PURE__ */
|
|
2583
|
+
return /* @__PURE__ */ import_react33.default.createElement(
|
|
2390
2584
|
"rect",
|
|
2391
2585
|
{
|
|
2392
2586
|
className: "Layer__profit-and-loss-chart__selection-indicator",
|
|
@@ -2406,7 +2600,7 @@ var import_recharts = require("recharts");
|
|
|
2406
2600
|
var barGap = 4;
|
|
2407
2601
|
var barSize = 20;
|
|
2408
2602
|
var ProfitAndLossChart = () => {
|
|
2409
|
-
const { changeDateRange, dateRange } = (0,
|
|
2603
|
+
const { changeDateRange, dateRange } = (0, import_react34.useContext)(ProfitAndLoss.Context);
|
|
2410
2604
|
const thisMonth = (0, import_date_fns7.startOfMonth)(Date.now());
|
|
2411
2605
|
const startSelectionMonth = dateRange.startDate.getMonth();
|
|
2412
2606
|
const endSelectionMonth = dateRange.endDate.getMonth();
|
|
@@ -2500,7 +2694,7 @@ var ProfitAndLossChart = () => {
|
|
|
2500
2694
|
});
|
|
2501
2695
|
}
|
|
2502
2696
|
};
|
|
2503
|
-
const data = (0,
|
|
2697
|
+
const data = (0, import_react34.useMemo)(
|
|
2504
2698
|
() => monthData.map(summarizePnL),
|
|
2505
2699
|
[
|
|
2506
2700
|
startSelectionMonth,
|
|
@@ -2508,8 +2702,8 @@ var ProfitAndLossChart = () => {
|
|
|
2508
2702
|
...monthData.map((m) => m?.net_profit)
|
|
2509
2703
|
]
|
|
2510
2704
|
);
|
|
2511
|
-
const [animateFrom, setAnimateFrom] = (0,
|
|
2512
|
-
return /* @__PURE__ */
|
|
2705
|
+
const [animateFrom, setAnimateFrom] = (0, import_react34.useState)(-1);
|
|
2706
|
+
return /* @__PURE__ */ import_react34.default.createElement(import_recharts.ResponsiveContainer, { width: "100%", height: 250 }, /* @__PURE__ */ import_react34.default.createElement(
|
|
2513
2707
|
import_recharts.BarChart,
|
|
2514
2708
|
{
|
|
2515
2709
|
margin: { left: 24, right: 24, bottom: 24 },
|
|
@@ -2518,8 +2712,8 @@ var ProfitAndLossChart = () => {
|
|
|
2518
2712
|
barGap,
|
|
2519
2713
|
className: "Layer__profit-and-loss-chart"
|
|
2520
2714
|
},
|
|
2521
|
-
/* @__PURE__ */
|
|
2522
|
-
/* @__PURE__ */
|
|
2715
|
+
/* @__PURE__ */ import_react34.default.createElement(import_recharts.CartesianGrid, { vertical: false }),
|
|
2716
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
2523
2717
|
import_recharts.Legend,
|
|
2524
2718
|
{
|
|
2525
2719
|
verticalAlign: "top",
|
|
@@ -2530,8 +2724,8 @@ var ProfitAndLossChart = () => {
|
|
|
2530
2724
|
]
|
|
2531
2725
|
}
|
|
2532
2726
|
),
|
|
2533
|
-
/* @__PURE__ */
|
|
2534
|
-
/* @__PURE__ */
|
|
2727
|
+
/* @__PURE__ */ import_react34.default.createElement(import_recharts.XAxis, { dataKey: "name", tickLine: false }),
|
|
2728
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
2535
2729
|
import_recharts.Bar,
|
|
2536
2730
|
{
|
|
2537
2731
|
dataKey: "revenue",
|
|
@@ -2540,10 +2734,10 @@ var ProfitAndLossChart = () => {
|
|
|
2540
2734
|
radius: [barSize / 4, barSize / 4, 0, 0],
|
|
2541
2735
|
className: "Layer__profit-and-loss-chart__bar--income"
|
|
2542
2736
|
},
|
|
2543
|
-
/* @__PURE__ */
|
|
2737
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
2544
2738
|
import_recharts.LabelList,
|
|
2545
2739
|
{
|
|
2546
|
-
content: /* @__PURE__ */
|
|
2740
|
+
content: /* @__PURE__ */ import_react34.default.createElement(
|
|
2547
2741
|
Indicator,
|
|
2548
2742
|
{
|
|
2549
2743
|
animateFrom,
|
|
@@ -2552,7 +2746,7 @@ var ProfitAndLossChart = () => {
|
|
|
2552
2746
|
)
|
|
2553
2747
|
}
|
|
2554
2748
|
),
|
|
2555
|
-
data.map((entry) => /* @__PURE__ */
|
|
2749
|
+
data.map((entry) => /* @__PURE__ */ import_react34.default.createElement(
|
|
2556
2750
|
import_recharts.Cell,
|
|
2557
2751
|
{
|
|
2558
2752
|
key: entry.name,
|
|
@@ -2560,7 +2754,7 @@ var ProfitAndLossChart = () => {
|
|
|
2560
2754
|
}
|
|
2561
2755
|
))
|
|
2562
2756
|
),
|
|
2563
|
-
/* @__PURE__ */
|
|
2757
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
2564
2758
|
import_recharts.Bar,
|
|
2565
2759
|
{
|
|
2566
2760
|
dataKey: "expenses",
|
|
@@ -2569,7 +2763,7 @@ var ProfitAndLossChart = () => {
|
|
|
2569
2763
|
radius: [barSize / 4, barSize / 4, 0, 0],
|
|
2570
2764
|
className: "Layer__profit-and-loss-chart__bar--expenses"
|
|
2571
2765
|
},
|
|
2572
|
-
data.map((entry) => /* @__PURE__ */
|
|
2766
|
+
data.map((entry) => /* @__PURE__ */ import_react34.default.createElement(
|
|
2573
2767
|
import_recharts.Cell,
|
|
2574
2768
|
{
|
|
2575
2769
|
key: entry.name,
|
|
@@ -2581,15 +2775,15 @@ var ProfitAndLossChart = () => {
|
|
|
2581
2775
|
};
|
|
2582
2776
|
|
|
2583
2777
|
// src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
|
|
2584
|
-
var
|
|
2778
|
+
var import_react35 = __toESM(require("react"));
|
|
2585
2779
|
|
|
2586
2780
|
// src/icons/ChevronLeft.tsx
|
|
2587
|
-
var
|
|
2781
|
+
var React42 = __toESM(require("react"));
|
|
2588
2782
|
var ChevronLeft = ({
|
|
2589
2783
|
strokeColor,
|
|
2590
2784
|
size,
|
|
2591
2785
|
...props
|
|
2592
|
-
}) => /* @__PURE__ */
|
|
2786
|
+
}) => /* @__PURE__ */ React42.createElement(
|
|
2593
2787
|
"svg",
|
|
2594
2788
|
{
|
|
2595
2789
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -2599,7 +2793,7 @@ var ChevronLeft = ({
|
|
|
2599
2793
|
viewBox: "0 0 24 24",
|
|
2600
2794
|
...props
|
|
2601
2795
|
},
|
|
2602
|
-
/* @__PURE__ */
|
|
2796
|
+
/* @__PURE__ */ React42.createElement(
|
|
2603
2797
|
"path",
|
|
2604
2798
|
{
|
|
2605
2799
|
stroke: strokeColor ?? "#000",
|
|
@@ -2613,8 +2807,8 @@ var ChevronLeft = ({
|
|
|
2613
2807
|
var ChevronLeft_default = ChevronLeft;
|
|
2614
2808
|
|
|
2615
2809
|
// src/icons/ChevronRight.tsx
|
|
2616
|
-
var
|
|
2617
|
-
var ChavronRight = ({ size, ...props }) => /* @__PURE__ */
|
|
2810
|
+
var React43 = __toESM(require("react"));
|
|
2811
|
+
var ChavronRight = ({ size, ...props }) => /* @__PURE__ */ React43.createElement(
|
|
2618
2812
|
"svg",
|
|
2619
2813
|
{
|
|
2620
2814
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -2624,7 +2818,7 @@ var ChavronRight = ({ size, ...props }) => /* @__PURE__ */ React41.createElement
|
|
|
2624
2818
|
viewBox: "0 0 24 24",
|
|
2625
2819
|
...props
|
|
2626
2820
|
},
|
|
2627
|
-
/* @__PURE__ */
|
|
2821
|
+
/* @__PURE__ */ React43.createElement(
|
|
2628
2822
|
"path",
|
|
2629
2823
|
{
|
|
2630
2824
|
stroke: "#000",
|
|
@@ -2640,7 +2834,7 @@ var ChevronRight_default = ChavronRight;
|
|
|
2640
2834
|
// src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
|
|
2641
2835
|
var import_date_fns8 = require("date-fns");
|
|
2642
2836
|
var ProfitAndLossDatePicker = () => {
|
|
2643
|
-
const { changeDateRange, dateRange } = (0,
|
|
2837
|
+
const { changeDateRange, dateRange } = (0, import_react35.useContext)(ProfitAndLoss.Context);
|
|
2644
2838
|
const date = dateRange.startDate;
|
|
2645
2839
|
const label = (0, import_date_fns8.format)(date, "LLLL y");
|
|
2646
2840
|
const change = (duration) => {
|
|
@@ -2652,28 +2846,28 @@ var ProfitAndLossDatePicker = () => {
|
|
|
2652
2846
|
};
|
|
2653
2847
|
const previousMonth = () => change({ months: -1 });
|
|
2654
2848
|
const nextMonth = () => change({ months: 1 });
|
|
2655
|
-
return /* @__PURE__ */
|
|
2849
|
+
return /* @__PURE__ */ import_react35.default.createElement("div", { className: "Layer__profit-and-loss-date-picker" }, /* @__PURE__ */ import_react35.default.createElement(
|
|
2656
2850
|
"button",
|
|
2657
2851
|
{
|
|
2658
2852
|
"aria-label": "View Previous Month",
|
|
2659
2853
|
className: "Layer__profit-and-loss-date-picker__button",
|
|
2660
2854
|
onClick: previousMonth
|
|
2661
2855
|
},
|
|
2662
|
-
/* @__PURE__ */
|
|
2856
|
+
/* @__PURE__ */ import_react35.default.createElement(
|
|
2663
2857
|
ChevronLeft_default,
|
|
2664
2858
|
{
|
|
2665
2859
|
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
2666
2860
|
size: 18
|
|
2667
2861
|
}
|
|
2668
2862
|
)
|
|
2669
|
-
), /* @__PURE__ */
|
|
2863
|
+
), /* @__PURE__ */ import_react35.default.createElement("span", { className: "Layer__profit-and-loss-date-picker__label" }, label), /* @__PURE__ */ import_react35.default.createElement(
|
|
2670
2864
|
"button",
|
|
2671
2865
|
{
|
|
2672
2866
|
"aria-label": "View Next Month",
|
|
2673
2867
|
className: "Layer__profit-and-loss-date-picker__button",
|
|
2674
2868
|
onClick: nextMonth
|
|
2675
2869
|
},
|
|
2676
|
-
/* @__PURE__ */
|
|
2870
|
+
/* @__PURE__ */ import_react35.default.createElement(
|
|
2677
2871
|
ChevronRight_default,
|
|
2678
2872
|
{
|
|
2679
2873
|
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
@@ -2684,26 +2878,26 @@ var ProfitAndLossDatePicker = () => {
|
|
|
2684
2878
|
};
|
|
2685
2879
|
|
|
2686
2880
|
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
2687
|
-
var
|
|
2881
|
+
var import_react36 = __toESM(require("react"));
|
|
2688
2882
|
var ProfitAndLossSummaries = () => {
|
|
2689
|
-
const { data: storedData } = (0,
|
|
2883
|
+
const { data: storedData } = (0, import_react36.useContext)(ProfitAndLoss.Context);
|
|
2690
2884
|
const data = storedData ? storedData : { income: { value: NaN }, net_profit: NaN };
|
|
2691
2885
|
const incomeDirectionClass = (data.income.value ?? NaN) < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
|
|
2692
2886
|
const expensesDirectionClass = (data?.income?.value ?? NaN) - data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
|
|
2693
2887
|
const netProfitDirectionClass = data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
|
|
2694
|
-
return /* @__PURE__ */
|
|
2888
|
+
return /* @__PURE__ */ import_react36.default.createElement("div", { className: "Layer__profit-and-loss-summaries" }, /* @__PURE__ */ import_react36.default.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--income" }, /* @__PURE__ */ import_react36.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Revenue"), /* @__PURE__ */ import_react36.default.createElement(
|
|
2695
2889
|
"span",
|
|
2696
2890
|
{
|
|
2697
2891
|
className: `Layer__profit-and-loss-summaries__amount ${incomeDirectionClass}`
|
|
2698
2892
|
},
|
|
2699
2893
|
centsToDollars(Math.abs(data?.income?.value ?? NaN))
|
|
2700
|
-
)), /* @__PURE__ */
|
|
2894
|
+
)), /* @__PURE__ */ import_react36.default.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--expenses" }, /* @__PURE__ */ import_react36.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Expenses"), /* @__PURE__ */ import_react36.default.createElement(
|
|
2701
2895
|
"span",
|
|
2702
2896
|
{
|
|
2703
2897
|
className: `Layer__profit-and-loss-summaries__amount ${expensesDirectionClass}`
|
|
2704
2898
|
},
|
|
2705
2899
|
centsToDollars(Math.abs((data.income.value ?? 0) - data.net_profit))
|
|
2706
|
-
)), /* @__PURE__ */
|
|
2900
|
+
)), /* @__PURE__ */ import_react36.default.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--net-profit" }, /* @__PURE__ */ import_react36.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Net Profit"), /* @__PURE__ */ import_react36.default.createElement(
|
|
2707
2901
|
"span",
|
|
2708
2902
|
{
|
|
2709
2903
|
className: `Layer__profit-and-loss-summaries__amount ${netProfitDirectionClass}`
|
|
@@ -2713,10 +2907,10 @@ var ProfitAndLossSummaries = () => {
|
|
|
2713
2907
|
};
|
|
2714
2908
|
|
|
2715
2909
|
// src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
|
|
2716
|
-
var
|
|
2910
|
+
var import_react38 = __toESM(require("react"));
|
|
2717
2911
|
|
|
2718
2912
|
// src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
|
|
2719
|
-
var
|
|
2913
|
+
var import_react37 = __toESM(require("react"));
|
|
2720
2914
|
var ProfitAndLossRow = ({
|
|
2721
2915
|
variant,
|
|
2722
2916
|
lineItem,
|
|
@@ -2729,7 +2923,7 @@ var ProfitAndLossRow = ({
|
|
|
2729
2923
|
return null;
|
|
2730
2924
|
}
|
|
2731
2925
|
const { value, display_name, line_items } = lineItem;
|
|
2732
|
-
const [expanded, setExpanded] = (0,
|
|
2926
|
+
const [expanded, setExpanded] = (0, import_react37.useState)(true);
|
|
2733
2927
|
const amount = value ?? 0;
|
|
2734
2928
|
const amountString = centsToDollars(Math.abs(amount));
|
|
2735
2929
|
const labelClasses = [
|
|
@@ -2760,12 +2954,12 @@ var ProfitAndLossRow = ({
|
|
|
2760
2954
|
);
|
|
2761
2955
|
displayChildren && expanded && labelClasses.push("Layer__profit-and-loss-row__label--expanded");
|
|
2762
2956
|
displayChildren && expanded && valueClasses.push("Layer__profit-and-loss-row__value--expanded");
|
|
2763
|
-
return /* @__PURE__ */
|
|
2957
|
+
return /* @__PURE__ */ import_react37.default.createElement(import_react37.default.Fragment, null, /* @__PURE__ */ import_react37.default.createElement("div", { className: labelClasses.join(" "), onClick: toggleExpanded }, /* @__PURE__ */ import_react37.default.createElement(ChevronDown_default, { size: 16 }), display_name), /* @__PURE__ */ import_react37.default.createElement("div", { className: valueClasses.join(" ") }, amountString), canGoDeeper && hasChildren && /* @__PURE__ */ import_react37.default.createElement(
|
|
2764
2958
|
"div",
|
|
2765
2959
|
{
|
|
2766
2960
|
className: `Layer__profit-and-loss-row__children ${expanded && "Layer__profit-and-loss-row__children--expanded"}`
|
|
2767
2961
|
},
|
|
2768
|
-
/* @__PURE__ */
|
|
2962
|
+
/* @__PURE__ */ import_react37.default.createElement("div", { className: "Layer__balance-sheet-row__children--content" }, (line_items || []).map((line_item) => /* @__PURE__ */ import_react37.default.createElement(
|
|
2769
2963
|
ProfitAndLossRow,
|
|
2770
2964
|
{
|
|
2771
2965
|
key: line_item.display_name,
|
|
@@ -2774,7 +2968,7 @@ var ProfitAndLossRow = ({
|
|
|
2774
2968
|
maxDepth,
|
|
2775
2969
|
direction
|
|
2776
2970
|
}
|
|
2777
|
-
)), summarize && /* @__PURE__ */
|
|
2971
|
+
)), summarize && /* @__PURE__ */ import_react37.default.createElement(
|
|
2778
2972
|
ProfitAndLossRow,
|
|
2779
2973
|
{
|
|
2780
2974
|
key: display_name,
|
|
@@ -2837,15 +3031,15 @@ var empty_profit_and_loss_report_default = {
|
|
|
2837
3031
|
|
|
2838
3032
|
// src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
|
|
2839
3033
|
var ProfitAndLossTable = () => {
|
|
2840
|
-
const { data: actualData, isLoading } = (0,
|
|
3034
|
+
const { data: actualData, isLoading } = (0, import_react38.useContext)(ProfitAndLoss.Context);
|
|
2841
3035
|
const data = !actualData || isLoading ? empty_profit_and_loss_report_default : actualData;
|
|
2842
|
-
return /* @__PURE__ */
|
|
3036
|
+
return /* @__PURE__ */ import_react38.default.createElement(import_react38.default.Fragment, null, /* @__PURE__ */ import_react38.default.createElement("div", { className: "Layer__profit-and-loss-table" }, /* @__PURE__ */ import_react38.default.createElement(ProfitAndLossRow, { lineItem: data.income, direction: "CREDIT" /* CREDIT */ }), /* @__PURE__ */ import_react38.default.createElement(
|
|
2843
3037
|
ProfitAndLossRow,
|
|
2844
3038
|
{
|
|
2845
3039
|
lineItem: data.cost_of_goods_sold,
|
|
2846
3040
|
direction: "DEBIT" /* DEBIT */
|
|
2847
3041
|
}
|
|
2848
|
-
), /* @__PURE__ */
|
|
3042
|
+
), /* @__PURE__ */ import_react38.default.createElement(
|
|
2849
3043
|
ProfitAndLossRow,
|
|
2850
3044
|
{
|
|
2851
3045
|
lineItem: {
|
|
@@ -2855,13 +3049,13 @@ var ProfitAndLossTable = () => {
|
|
|
2855
3049
|
variant: "summation",
|
|
2856
3050
|
direction: "CREDIT" /* CREDIT */
|
|
2857
3051
|
}
|
|
2858
|
-
), /* @__PURE__ */
|
|
3052
|
+
), /* @__PURE__ */ import_react38.default.createElement(
|
|
2859
3053
|
ProfitAndLossRow,
|
|
2860
3054
|
{
|
|
2861
3055
|
lineItem: data.expenses,
|
|
2862
3056
|
direction: "DEBIT" /* DEBIT */
|
|
2863
3057
|
}
|
|
2864
|
-
), /* @__PURE__ */
|
|
3058
|
+
), /* @__PURE__ */ import_react38.default.createElement(
|
|
2865
3059
|
ProfitAndLossRow,
|
|
2866
3060
|
{
|
|
2867
3061
|
lineItem: {
|
|
@@ -2871,7 +3065,7 @@ var ProfitAndLossTable = () => {
|
|
|
2871
3065
|
variant: "summation",
|
|
2872
3066
|
direction: "CREDIT" /* CREDIT */
|
|
2873
3067
|
}
|
|
2874
|
-
), /* @__PURE__ */
|
|
3068
|
+
), /* @__PURE__ */ import_react38.default.createElement(ProfitAndLossRow, { lineItem: data.taxes, direction: "DEBIT" /* DEBIT */ }), /* @__PURE__ */ import_react38.default.createElement(
|
|
2875
3069
|
ProfitAndLossRow,
|
|
2876
3070
|
{
|
|
2877
3071
|
lineItem: {
|
|
@@ -2881,13 +3075,13 @@ var ProfitAndLossTable = () => {
|
|
|
2881
3075
|
variant: "summation",
|
|
2882
3076
|
direction: "CREDIT" /* CREDIT */
|
|
2883
3077
|
}
|
|
2884
|
-
)), /* @__PURE__ */
|
|
3078
|
+
)), /* @__PURE__ */ import_react38.default.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table__outflows" }, /* @__PURE__ */ import_react38.default.createElement(
|
|
2885
3079
|
ProfitAndLossRow,
|
|
2886
3080
|
{
|
|
2887
3081
|
lineItem: data.other_outflows,
|
|
2888
3082
|
direction: "DEBIT" /* DEBIT */
|
|
2889
3083
|
}
|
|
2890
|
-
), /* @__PURE__ */
|
|
3084
|
+
), /* @__PURE__ */ import_react38.default.createElement(
|
|
2891
3085
|
ProfitAndLossRow,
|
|
2892
3086
|
{
|
|
2893
3087
|
lineItem: data.personal_expenses,
|
|
@@ -2898,7 +3092,7 @@ var ProfitAndLossTable = () => {
|
|
|
2898
3092
|
|
|
2899
3093
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
2900
3094
|
var import_date_fns9 = require("date-fns");
|
|
2901
|
-
var PNLContext = (0,
|
|
3095
|
+
var PNLContext = (0, import_react39.createContext)({
|
|
2902
3096
|
data: void 0,
|
|
2903
3097
|
isLoading: true,
|
|
2904
3098
|
error: void 0,
|
|
@@ -2911,7 +3105,7 @@ var PNLContext = (0, import_react38.createContext)({
|
|
|
2911
3105
|
});
|
|
2912
3106
|
var ProfitAndLoss = ({ children }) => {
|
|
2913
3107
|
const contextData = useProfitAndLoss();
|
|
2914
|
-
return /* @__PURE__ */
|
|
3108
|
+
return /* @__PURE__ */ import_react39.default.createElement(PNLContext.Provider, { value: contextData }, /* @__PURE__ */ import_react39.default.createElement("div", { className: "Layer__component Layer__profit-and-loss" }, /* @__PURE__ */ import_react39.default.createElement("h2", { className: "Layer__profit-and-loss__title" }, "Profit & Loss"), children));
|
|
2915
3109
|
};
|
|
2916
3110
|
ProfitAndLoss.Chart = ProfitAndLossChart;
|
|
2917
3111
|
ProfitAndLoss.Context = PNLContext;
|
|
@@ -2920,7 +3114,7 @@ ProfitAndLoss.Summaries = ProfitAndLossSummaries;
|
|
|
2920
3114
|
ProfitAndLoss.Table = ProfitAndLossTable;
|
|
2921
3115
|
|
|
2922
3116
|
// src/providers/LayerProvider/LayerProvider.tsx
|
|
2923
|
-
var
|
|
3117
|
+
var import_react40 = __toESM(require("react"));
|
|
2924
3118
|
var import_date_fns10 = require("date-fns");
|
|
2925
3119
|
var import_swr5 = __toESM(require("swr"));
|
|
2926
3120
|
var reducer = (state, action) => {
|
|
@@ -2961,7 +3155,7 @@ var LayerProvider = ({
|
|
|
2961
3155
|
revalidateIfStale: false
|
|
2962
3156
|
};
|
|
2963
3157
|
const { url, scope, apiUrl } = LayerEnvironment[environment];
|
|
2964
|
-
const [state, dispatch] = (0,
|
|
3158
|
+
const [state, dispatch] = (0, import_react40.useReducer)(reducer, {
|
|
2965
3159
|
auth: {
|
|
2966
3160
|
access_token: "",
|
|
2967
3161
|
token_type: "",
|
|
@@ -2983,7 +3177,7 @@ var LayerProvider = ({
|
|
|
2983
3177
|
}),
|
|
2984
3178
|
defaultSWRConfig
|
|
2985
3179
|
) : { data: void 0 };
|
|
2986
|
-
(0,
|
|
3180
|
+
(0, import_react40.useEffect)(() => {
|
|
2987
3181
|
if (businessAccessToken) {
|
|
2988
3182
|
dispatch({
|
|
2989
3183
|
type: "LayerContext.setAuth" /* setAuth */,
|
|
@@ -3013,7 +3207,7 @@ var LayerProvider = ({
|
|
|
3013
3207
|
Layer.getCategories(apiUrl, auth?.access_token, { params: { businessId } }),
|
|
3014
3208
|
defaultSWRConfig
|
|
3015
3209
|
);
|
|
3016
|
-
(0,
|
|
3210
|
+
(0, import_react40.useEffect)(() => {
|
|
3017
3211
|
if (categories?.data?.categories?.length) {
|
|
3018
3212
|
dispatch({
|
|
3019
3213
|
type: "LayerContext.setCategories" /* setCategories */,
|
|
@@ -3025,11 +3219,11 @@ var LayerProvider = ({
|
|
|
3025
3219
|
type: "LayerContext.setTheme" /* setTheme */,
|
|
3026
3220
|
payload: { theme: theme2 }
|
|
3027
3221
|
});
|
|
3028
|
-
return /* @__PURE__ */
|
|
3222
|
+
return /* @__PURE__ */ import_react40.default.createElement(import_swr5.SWRConfig, { value: defaultSWRConfig }, /* @__PURE__ */ import_react40.default.createElement(LayerContext.Provider, { value: { ...state, setTheme } }, children));
|
|
3029
3223
|
};
|
|
3030
3224
|
|
|
3031
3225
|
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
3032
|
-
var
|
|
3226
|
+
var import_react43 = __toESM(require("react"));
|
|
3033
3227
|
|
|
3034
3228
|
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
3035
3229
|
var import_swr6 = __toESM(require("swr"));
|
|
@@ -3049,21 +3243,21 @@ var useChartOfAccounts = () => {
|
|
|
3049
3243
|
};
|
|
3050
3244
|
|
|
3051
3245
|
// src/components/ChartOfAccountsNewForm/ChartOfAccountsNewForm.tsx
|
|
3052
|
-
var
|
|
3246
|
+
var import_react41 = __toESM(require("react"));
|
|
3053
3247
|
var import_react_select2 = __toESM(require("react-select"));
|
|
3054
3248
|
var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.subAccounts || [])]).flat().filter((id) => id);
|
|
3055
3249
|
var ChartOfAccountsNewForm = () => {
|
|
3056
3250
|
const { data, create: createAccount2 } = useChartOfAccounts();
|
|
3057
|
-
const accountOptions = (0,
|
|
3251
|
+
const accountOptions = (0, import_react41.useMemo)(
|
|
3058
3252
|
() => flattenAccounts(data?.accounts || []).sort(
|
|
3059
3253
|
(a, b) => a?.name && b?.name ? a.name.localeCompare(b.name) : 0
|
|
3060
3254
|
),
|
|
3061
3255
|
[data?.accounts?.length]
|
|
3062
3256
|
);
|
|
3063
|
-
const [name, setName] = (0,
|
|
3064
|
-
const [description, setDescription] = (0,
|
|
3065
|
-
const [normality, setNormality] = (0,
|
|
3066
|
-
const [parentAccount, setParentAccount] = (0,
|
|
3257
|
+
const [name, setName] = (0, import_react41.useState)("");
|
|
3258
|
+
const [description, setDescription] = (0, import_react41.useState)("");
|
|
3259
|
+
const [normality, setNormality] = (0, import_react41.useState)("DEBIT" /* DEBIT */);
|
|
3260
|
+
const [parentAccount, setParentAccount] = (0, import_react41.useState)(
|
|
3067
3261
|
data?.accounts[0]
|
|
3068
3262
|
);
|
|
3069
3263
|
const save = () => {
|
|
@@ -3077,21 +3271,21 @@ var ChartOfAccountsNewForm = () => {
|
|
|
3077
3271
|
description
|
|
3078
3272
|
});
|
|
3079
3273
|
};
|
|
3080
|
-
return /* @__PURE__ */
|
|
3274
|
+
return /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form" }, /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react41.default.createElement("span", null, "Name"), /* @__PURE__ */ import_react41.default.createElement(
|
|
3081
3275
|
"input",
|
|
3082
3276
|
{
|
|
3083
3277
|
name: "name",
|
|
3084
3278
|
value: name,
|
|
3085
3279
|
onChange: (event) => setName(event.target.value)
|
|
3086
3280
|
}
|
|
3087
|
-
)), /* @__PURE__ */
|
|
3281
|
+
)), /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react41.default.createElement("span", null, "Description"), /* @__PURE__ */ import_react41.default.createElement(
|
|
3088
3282
|
"input",
|
|
3089
3283
|
{
|
|
3090
3284
|
name: "description",
|
|
3091
3285
|
value: description,
|
|
3092
3286
|
onChange: (event) => setDescription(event.target.value)
|
|
3093
3287
|
}
|
|
3094
|
-
)), /* @__PURE__ */
|
|
3288
|
+
)), /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react41.default.createElement("span", null, "Normality"), /* @__PURE__ */ import_react41.default.createElement(
|
|
3095
3289
|
import_react_select2.default,
|
|
3096
3290
|
{
|
|
3097
3291
|
isSearchable: false,
|
|
@@ -3101,7 +3295,7 @@ var ChartOfAccountsNewForm = () => {
|
|
|
3101
3295
|
{ label: "Debit", value: "DEBIT" /* DEBIT */ }
|
|
3102
3296
|
]
|
|
3103
3297
|
}
|
|
3104
|
-
)), /* @__PURE__ */
|
|
3298
|
+
)), /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react41.default.createElement("span", null, "Parent Account"), /* @__PURE__ */ import_react41.default.createElement(
|
|
3105
3299
|
import_react_select2.default,
|
|
3106
3300
|
{
|
|
3107
3301
|
isSearchable: true,
|
|
@@ -3111,49 +3305,49 @@ var ChartOfAccountsNewForm = () => {
|
|
|
3111
3305
|
getOptionValue: (a) => a.id,
|
|
3112
3306
|
options: accountOptions
|
|
3113
3307
|
}
|
|
3114
|
-
)), /* @__PURE__ */
|
|
3308
|
+
)), /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field Layer__chart-of-accounts-new-form__field--actions" }, /* @__PURE__ */ import_react41.default.createElement("button", { onClick: save }, "Save")));
|
|
3115
3309
|
};
|
|
3116
3310
|
|
|
3117
3311
|
// src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
|
|
3118
|
-
var
|
|
3312
|
+
var import_react42 = __toESM(require("react"));
|
|
3119
3313
|
var ChartOfAccountsRow = ({ account, depth = 0 }) => {
|
|
3120
|
-
const
|
|
3314
|
+
const classNames13 = [
|
|
3121
3315
|
"Layer__chart-of-accounts-row__table-cell",
|
|
3122
3316
|
depth > 0 && `Layer__chart-of-accounts-row__table-cell--depth-${depth}`
|
|
3123
3317
|
];
|
|
3124
|
-
const className =
|
|
3318
|
+
const className = classNames13.filter((id) => id).join(" ");
|
|
3125
3319
|
const amountClassName = account.balance < 0 ? "Layer__chart-of-accounts-row__table-cell--amount-negative" : "Layer__chart-of-accounts-row__table-cell--amount-positive";
|
|
3126
|
-
return /* @__PURE__ */
|
|
3320
|
+
return /* @__PURE__ */ import_react42.default.createElement(import_react42.default.Fragment, null, /* @__PURE__ */ import_react42.default.createElement(
|
|
3127
3321
|
"div",
|
|
3128
3322
|
{
|
|
3129
3323
|
className: `${className} Layer__chart-of-accounts-row__table-cell--name`
|
|
3130
3324
|
},
|
|
3131
3325
|
account.name
|
|
3132
|
-
), /* @__PURE__ */
|
|
3326
|
+
), /* @__PURE__ */ import_react42.default.createElement(
|
|
3133
3327
|
"div",
|
|
3134
3328
|
{
|
|
3135
3329
|
className: `${className} Layer__chart-of-accounts-row__table-cell--type`
|
|
3136
3330
|
},
|
|
3137
3331
|
"Assets"
|
|
3138
|
-
), /* @__PURE__ */
|
|
3332
|
+
), /* @__PURE__ */ import_react42.default.createElement(
|
|
3139
3333
|
"div",
|
|
3140
3334
|
{
|
|
3141
3335
|
className: `${className} Layer__chart-of-accounts-row__table-cell--subtype`
|
|
3142
3336
|
},
|
|
3143
3337
|
"Cash"
|
|
3144
|
-
), /* @__PURE__ */
|
|
3338
|
+
), /* @__PURE__ */ import_react42.default.createElement(
|
|
3145
3339
|
"div",
|
|
3146
3340
|
{
|
|
3147
3341
|
className: `${className} Layer__chart-of-accounts-row__table-cell--balance ${amountClassName}`
|
|
3148
3342
|
},
|
|
3149
3343
|
centsToDollars(Math.abs(account.balance || 0))
|
|
3150
|
-
), /* @__PURE__ */
|
|
3344
|
+
), /* @__PURE__ */ import_react42.default.createElement(
|
|
3151
3345
|
"div",
|
|
3152
3346
|
{
|
|
3153
3347
|
className: `${className} Layer__chart-of-accounts-row__table-cell--actions`
|
|
3154
3348
|
},
|
|
3155
|
-
/* @__PURE__ */
|
|
3156
|
-
), (account.subAccounts || []).map((subAccount) => /* @__PURE__ */
|
|
3349
|
+
/* @__PURE__ */ import_react42.default.createElement("button", { className: "Layer__chart-of-accounts-row__view-entries-button" }, "View Entries")
|
|
3350
|
+
), (account.subAccounts || []).map((subAccount) => /* @__PURE__ */ import_react42.default.createElement(
|
|
3157
3351
|
ChartOfAccountsRow,
|
|
3158
3352
|
{
|
|
3159
3353
|
key: subAccount.id,
|
|
@@ -3166,15 +3360,15 @@ var ChartOfAccountsRow = ({ account, depth = 0 }) => {
|
|
|
3166
3360
|
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
3167
3361
|
var ChartOfAccounts = () => {
|
|
3168
3362
|
const { data, isLoading } = useChartOfAccounts();
|
|
3169
|
-
const [showingForm, setShowingForm] = (0,
|
|
3170
|
-
return /* @__PURE__ */
|
|
3363
|
+
const [showingForm, setShowingForm] = (0, import_react43.useState)(false);
|
|
3364
|
+
return /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__component Layer__chart-of-accounts" }, !data || isLoading ? "Loading." : /* @__PURE__ */ import_react43.default.createElement(import_react43.default.Fragment, null, /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__header" }, /* @__PURE__ */ import_react43.default.createElement("h2", { className: "Layer__chart-of-accounts__title" }, "Chart of Accounts"), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__actions" }, /* @__PURE__ */ import_react43.default.createElement("button", { className: "Layer__chart-of-accounts__download-button" }, /* @__PURE__ */ import_react43.default.createElement(DownloadCloud_default, null), "Download"), /* @__PURE__ */ import_react43.default.createElement(
|
|
3171
3365
|
"button",
|
|
3172
3366
|
{
|
|
3173
3367
|
className: "Layer__chart-of-accounts__edit-accounts-button",
|
|
3174
3368
|
onClick: () => setShowingForm(!showingForm)
|
|
3175
3369
|
},
|
|
3176
3370
|
"Edit Accounts"
|
|
3177
|
-
))), showingForm && /* @__PURE__ */
|
|
3371
|
+
))), showingForm && /* @__PURE__ */ import_react43.default.createElement(ChartOfAccountsNewForm, null), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table" }, /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Name"), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Type"), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Sub-Type"), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header Layer__chart-of-accounts__table-cell--header-balance" }, "Balance"), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }), data.accounts.map((account) => /* @__PURE__ */ import_react43.default.createElement(
|
|
3178
3372
|
ChartOfAccountsRow,
|
|
3179
3373
|
{
|
|
3180
3374
|
key: account.id,
|