@layerfi/components 0.1.1 → 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 +359 -155
- 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 +47 -15
- 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 +374 -170
- 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/.vim_backups/%Users%danieloneel%repos%components%package.json +0 -0
- package/.vim_backups/%Users%danieloneel%repos%components%src%providers%LayerProvider%LayerProvider.tsx +0 -0
- package/index.d.ts +0 -1088
package/dist/index.js
CHANGED
|
@@ -50,7 +50,6 @@ var authenticate = ({
|
|
|
50
50
|
appId,
|
|
51
51
|
appSecret,
|
|
52
52
|
authenticationUrl = "https://auth.layerfi.com/oauth2/token",
|
|
53
|
-
clientId,
|
|
54
53
|
scope
|
|
55
54
|
}) => () => fetch(authenticationUrl, {
|
|
56
55
|
method: "POST",
|
|
@@ -61,7 +60,7 @@ var authenticate = ({
|
|
|
61
60
|
body: formStringFromObject({
|
|
62
61
|
grant_type: "client_credentials",
|
|
63
62
|
scope,
|
|
64
|
-
client_id:
|
|
63
|
+
client_id: appId
|
|
65
64
|
})
|
|
66
65
|
}).then((res) => res.json());
|
|
67
66
|
|
|
@@ -599,7 +598,7 @@ var BalanceSheet = () => {
|
|
|
599
598
|
};
|
|
600
599
|
|
|
601
600
|
// src/components/BankTransactions/BankTransactions.tsx
|
|
602
|
-
var
|
|
601
|
+
var import_react30 = __toESM(require("react"));
|
|
603
602
|
|
|
604
603
|
// src/hooks/useBankTransactions/useBankTransactions.tsx
|
|
605
604
|
var import_swr2 = __toESM(require("swr"));
|
|
@@ -608,6 +607,7 @@ var useBankTransactions = () => {
|
|
|
608
607
|
const {
|
|
609
608
|
data: responseData,
|
|
610
609
|
isLoading,
|
|
610
|
+
isValidating,
|
|
611
611
|
error: responseError,
|
|
612
612
|
mutate
|
|
613
613
|
} = (0, import_swr2.default)(
|
|
@@ -617,12 +617,12 @@ var useBankTransactions = () => {
|
|
|
617
617
|
})
|
|
618
618
|
);
|
|
619
619
|
const {
|
|
620
|
-
data =
|
|
620
|
+
data = void 0,
|
|
621
621
|
meta: metadata = {},
|
|
622
622
|
error = void 0
|
|
623
623
|
} = responseData || {};
|
|
624
624
|
const categorize = (id, newCategory) => {
|
|
625
|
-
const foundBT = data
|
|
625
|
+
const foundBT = data?.find((x) => x.business_id === businessId && x.id === id);
|
|
626
626
|
if (foundBT) {
|
|
627
627
|
updateOneLocal({ ...foundBT, processing: true, error: void 0 });
|
|
628
628
|
}
|
|
@@ -639,7 +639,7 @@ var useBankTransactions = () => {
|
|
|
639
639
|
throw errors;
|
|
640
640
|
}
|
|
641
641
|
}).catch((err) => {
|
|
642
|
-
const newBT = data
|
|
642
|
+
const newBT = data?.find(
|
|
643
643
|
(x) => x.business_id === businessId && x.id === id
|
|
644
644
|
);
|
|
645
645
|
if (newBT) {
|
|
@@ -652,15 +652,20 @@ var useBankTransactions = () => {
|
|
|
652
652
|
});
|
|
653
653
|
};
|
|
654
654
|
const updateOneLocal = (newBankTransaction) => {
|
|
655
|
-
const updatedData = data
|
|
655
|
+
const updatedData = data?.map(
|
|
656
656
|
(bt) => bt.id === newBankTransaction.id ? newBankTransaction : bt
|
|
657
657
|
);
|
|
658
658
|
mutate({ data: updatedData }, { revalidate: false });
|
|
659
659
|
};
|
|
660
|
+
const refetch = () => {
|
|
661
|
+
mutate();
|
|
662
|
+
};
|
|
660
663
|
return {
|
|
661
664
|
data,
|
|
662
665
|
metadata,
|
|
663
666
|
isLoading,
|
|
667
|
+
isValidating,
|
|
668
|
+
refetch,
|
|
664
669
|
error: responseError || error,
|
|
665
670
|
categorize,
|
|
666
671
|
updateOneLocal
|
|
@@ -705,6 +710,7 @@ var Button = ({
|
|
|
705
710
|
iconOnly,
|
|
706
711
|
...props
|
|
707
712
|
}) => {
|
|
713
|
+
const buttonRef = (0, import_react8.useRef)(null);
|
|
708
714
|
let justify = "center";
|
|
709
715
|
if (leftIcon && rightIcon) {
|
|
710
716
|
justify = "space-between";
|
|
@@ -719,7 +725,23 @@ var Button = ({
|
|
|
719
725
|
iconOnly ? "Layer__btn--icon-only" : "",
|
|
720
726
|
className
|
|
721
727
|
);
|
|
722
|
-
|
|
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
|
+
);
|
|
723
745
|
};
|
|
724
746
|
|
|
725
747
|
// src/components/Button/SubmitButton.tsx
|
|
@@ -1259,66 +1281,135 @@ var RefreshCcw = ({ size = 18, ...props }) => /* @__PURE__ */ React19.createElem
|
|
|
1259
1281
|
);
|
|
1260
1282
|
var RefreshCcw_default = RefreshCcw;
|
|
1261
1283
|
|
|
1262
|
-
// src/icons/
|
|
1284
|
+
// src/icons/Scissors.tsx
|
|
1263
1285
|
var React20 = __toESM(require("react"));
|
|
1264
|
-
var
|
|
1286
|
+
var Scissors = ({ size = 11, ...props }) => /* @__PURE__ */ React20.createElement(
|
|
1265
1287
|
"svg",
|
|
1266
1288
|
{
|
|
1267
|
-
viewBox: "0 0
|
|
1289
|
+
viewBox: "0 0 11 11",
|
|
1268
1290
|
fill: "none",
|
|
1269
1291
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1270
1292
|
...props,
|
|
1271
1293
|
width: size,
|
|
1272
1294
|
height: size
|
|
1273
1295
|
},
|
|
1274
|
-
/* @__PURE__ */ React20.createElement(
|
|
1296
|
+
/* @__PURE__ */ React20.createElement(
|
|
1275
1297
|
"path",
|
|
1276
1298
|
{
|
|
1277
|
-
|
|
1278
|
-
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",
|
|
1279
1300
|
stroke: "currentColor",
|
|
1280
1301
|
strokeLinecap: "round",
|
|
1281
1302
|
strokeLinejoin: "round"
|
|
1282
|
-
}
|
|
1283
|
-
|
|
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(
|
|
1284
1320
|
"path",
|
|
1285
1321
|
{
|
|
1286
|
-
|
|
1287
|
-
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",
|
|
1288
1323
|
stroke: "currentColor",
|
|
1289
1324
|
strokeLinecap: "round",
|
|
1290
1325
|
strokeLinejoin: "round"
|
|
1291
|
-
}
|
|
1292
|
-
|
|
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(
|
|
1293
1343
|
"path",
|
|
1294
1344
|
{
|
|
1295
|
-
|
|
1296
|
-
d: "M10 2L4.06 7.94",
|
|
1345
|
+
d: "M9.16668 1.83325L3.72168 7.27825",
|
|
1297
1346
|
stroke: "currentColor",
|
|
1298
1347
|
strokeLinecap: "round",
|
|
1299
1348
|
strokeLinejoin: "round"
|
|
1300
|
-
}
|
|
1301
|
-
|
|
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(
|
|
1302
1366
|
"path",
|
|
1303
1367
|
{
|
|
1304
|
-
|
|
1305
|
-
d: "M7.235 7.23999L10 9.99999",
|
|
1368
|
+
d: "M6.63232 6.63672L9.16691 9.16672",
|
|
1306
1369
|
stroke: "currentColor",
|
|
1307
1370
|
strokeLinecap: "round",
|
|
1308
1371
|
strokeLinejoin: "round"
|
|
1309
|
-
}
|
|
1310
|
-
|
|
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(
|
|
1311
1389
|
"path",
|
|
1312
1390
|
{
|
|
1313
|
-
|
|
1314
|
-
d: "M4.06 4.06006L6 6.00006",
|
|
1391
|
+
d: "M3.72168 3.72168L5.50001 5.50001",
|
|
1315
1392
|
stroke: "currentColor",
|
|
1316
1393
|
strokeLinecap: "round",
|
|
1317
1394
|
strokeLinejoin: "round"
|
|
1318
|
-
}
|
|
1319
|
-
|
|
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
|
+
)
|
|
1320
1411
|
);
|
|
1321
|
-
var
|
|
1412
|
+
var Scissors_default = Scissors;
|
|
1322
1413
|
|
|
1323
1414
|
// src/components/Input/Input.tsx
|
|
1324
1415
|
var import_react15 = __toESM(require("react"));
|
|
@@ -1654,7 +1745,7 @@ var ExpandedBankTransactionRow = (0, import_react22.forwardRef)(
|
|
|
1654
1745
|
bankTransaction,
|
|
1655
1746
|
isOpen = false,
|
|
1656
1747
|
asListItem = false,
|
|
1657
|
-
|
|
1748
|
+
submitBtnText = "Save"
|
|
1658
1749
|
}, ref) => {
|
|
1659
1750
|
const { categorize: categorizeBankTransaction2 } = useBankTransactions();
|
|
1660
1751
|
const [purpose, setPurpose] = (0, import_react22.useState)("categorize" /* categorize */);
|
|
@@ -1793,7 +1884,7 @@ var ExpandedBankTransactionRow = (0, import_react22.forwardRef)(
|
|
|
1793
1884
|
Button,
|
|
1794
1885
|
{
|
|
1795
1886
|
onClick: addSplit,
|
|
1796
|
-
leftIcon: /* @__PURE__ */ import_react22.default.createElement(
|
|
1887
|
+
leftIcon: /* @__PURE__ */ import_react22.default.createElement(Scissors_default, { size: 14 }),
|
|
1797
1888
|
variant: "secondary" /* secondary */
|
|
1798
1889
|
},
|
|
1799
1890
|
"Split"
|
|
@@ -1816,7 +1907,7 @@ var ExpandedBankTransactionRow = (0, import_react22.forwardRef)(
|
|
|
1816
1907
|
/* @__PURE__ */ import_react22.default.createElement(Textarea, { name: "description", placeholder: "Enter description" })
|
|
1817
1908
|
),
|
|
1818
1909
|
/* @__PURE__ */ import_react22.default.createElement("div", { className: `${className}__file-upload` }, /* @__PURE__ */ import_react22.default.createElement(FileInput, { text: "Upload receipt" })),
|
|
1819
|
-
asListItem
|
|
1910
|
+
asListItem ? /* @__PURE__ */ import_react22.default.createElement("div", { className: `${className}__submit-btn` }, /* @__PURE__ */ import_react22.default.createElement(
|
|
1820
1911
|
SubmitButton,
|
|
1821
1912
|
{
|
|
1822
1913
|
onClick: () => {
|
|
@@ -1829,7 +1920,7 @@ var ExpandedBankTransactionRow = (0, import_react22.forwardRef)(
|
|
|
1829
1920
|
error: bankTransaction.error,
|
|
1830
1921
|
active: true
|
|
1831
1922
|
},
|
|
1832
|
-
|
|
1923
|
+
submitBtnText
|
|
1833
1924
|
)) : null
|
|
1834
1925
|
))
|
|
1835
1926
|
);
|
|
@@ -1907,7 +1998,8 @@ var BankTransactionListItem = ({
|
|
|
1907
1998
|
bankTransaction,
|
|
1908
1999
|
close: () => toggleOpen(bankTransaction.id),
|
|
1909
2000
|
isOpen,
|
|
1910
|
-
asListItem: true
|
|
2001
|
+
asListItem: true,
|
|
2002
|
+
submitBtnText: editable ? "Approve" : "Save"
|
|
1911
2003
|
}
|
|
1912
2004
|
)), /* @__PURE__ */ import_react24.default.createElement("span", { className: `${className}__base-row` }, editable ? /* @__PURE__ */ import_react24.default.createElement(
|
|
1913
2005
|
CategoryMenu,
|
|
@@ -2040,8 +2132,8 @@ var BankTransactionRow = ({
|
|
|
2040
2132
|
disabled: bankTransaction.processing
|
|
2041
2133
|
}
|
|
2042
2134
|
) : null,
|
|
2043
|
-
!editable ? /* @__PURE__ */ import_react25.default.createElement(Text, { as: "span", className: `${className}__category-text` }, bankTransaction?.category?.display_name) : null,
|
|
2044
|
-
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(
|
|
2045
2137
|
SubmitButton,
|
|
2046
2138
|
{
|
|
2047
2139
|
onClick: () => {
|
|
@@ -2054,8 +2146,8 @@ var BankTransactionRow = ({
|
|
|
2054
2146
|
error: bankTransaction.error,
|
|
2055
2147
|
active: isOpen
|
|
2056
2148
|
},
|
|
2057
|
-
"Approve"
|
|
2058
|
-
),
|
|
2149
|
+
editable ? "Approve" : "Save"
|
|
2150
|
+
) : null,
|
|
2059
2151
|
/* @__PURE__ */ import_react25.default.createElement(
|
|
2060
2152
|
"div",
|
|
2061
2153
|
{
|
|
@@ -2077,8 +2169,7 @@ var BankTransactionRow = ({
|
|
|
2077
2169
|
ref: expandedRowRef,
|
|
2078
2170
|
bankTransaction,
|
|
2079
2171
|
close: () => toggleOpen(bankTransaction.id),
|
|
2080
|
-
isOpen
|
|
2081
|
-
showSubmitButton: !editable
|
|
2172
|
+
isOpen
|
|
2082
2173
|
}
|
|
2083
2174
|
))));
|
|
2084
2175
|
};
|
|
@@ -2105,7 +2196,6 @@ var parseColorFromTheme = (colorName, color) => {
|
|
|
2105
2196
|
}
|
|
2106
2197
|
try {
|
|
2107
2198
|
if ("h" in color && "s" in color && "l" in color) {
|
|
2108
|
-
console.log("its hsl", color);
|
|
2109
2199
|
return {
|
|
2110
2200
|
[`--color-${colorName}-h`]: color.h,
|
|
2111
2201
|
[`--color-${colorName}-s`]: color.s,
|
|
@@ -2114,7 +2204,6 @@ var parseColorFromTheme = (colorName, color) => {
|
|
|
2114
2204
|
}
|
|
2115
2205
|
if ("r" in color && "g" in color && "b" in color) {
|
|
2116
2206
|
const { h, s, l } = rgbToHsl(color);
|
|
2117
|
-
console.log("its rgb", h, s, l);
|
|
2118
2207
|
return {
|
|
2119
2208
|
[`--color-${colorName}-h`]: h,
|
|
2120
2209
|
[`--color-${colorName}-s`]: `${s}%`,
|
|
@@ -2122,7 +2211,6 @@ var parseColorFromTheme = (colorName, color) => {
|
|
|
2122
2211
|
};
|
|
2123
2212
|
}
|
|
2124
2213
|
if ("hex" in color) {
|
|
2125
|
-
console.log("its hex");
|
|
2126
2214
|
const rgb = hexToRgb(color.hex);
|
|
2127
2215
|
if (!rgb) {
|
|
2128
2216
|
return {};
|
|
@@ -2132,7 +2220,6 @@ var parseColorFromTheme = (colorName, color) => {
|
|
|
2132
2220
|
g: rgb.g.toString(),
|
|
2133
2221
|
b: rgb.b.toString()
|
|
2134
2222
|
});
|
|
2135
|
-
console.log("its hex", h, s, l);
|
|
2136
2223
|
return {
|
|
2137
2224
|
[`--color-${colorName}-h`]: h,
|
|
2138
2225
|
[`--color-${colorName}-s`]: `${s}%`,
|
|
@@ -2176,34 +2263,120 @@ var hexToRgb = (hex) => {
|
|
|
2176
2263
|
};
|
|
2177
2264
|
|
|
2178
2265
|
// src/components/Container/Container.tsx
|
|
2179
|
-
var
|
|
2180
|
-
|
|
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
|
+
);
|
|
2181
2279
|
const { theme } = useLayerContext();
|
|
2182
2280
|
const styles = parseStylesFromThemeConfig(theme);
|
|
2183
|
-
return /* @__PURE__ */ import_react26.default.createElement(
|
|
2184
|
-
"div",
|
|
2185
|
-
{
|
|
2186
|
-
className: `Layer__component Layer__component-container ${baseClassName}`,
|
|
2187
|
-
style: { ...styles }
|
|
2188
|
-
},
|
|
2189
|
-
children
|
|
2190
|
-
);
|
|
2281
|
+
return /* @__PURE__ */ import_react26.default.createElement("div", { className: baseClassName, style: { ...styles } }, children);
|
|
2191
2282
|
};
|
|
2192
2283
|
|
|
2193
2284
|
// src/components/Container/Header.tsx
|
|
2194
2285
|
var import_react27 = __toESM(require("react"));
|
|
2195
|
-
var
|
|
2286
|
+
var import_classnames12 = __toESM(require("classnames"));
|
|
2196
2287
|
var Header = (0, import_react27.forwardRef)(
|
|
2197
2288
|
({ className, children, style }, ref) => {
|
|
2198
|
-
const baseClassName = (0,
|
|
2289
|
+
const baseClassName = (0, import_classnames12.default)("Layer__component-header", className);
|
|
2199
2290
|
return /* @__PURE__ */ import_react27.default.createElement("header", { ref, className: baseClassName, style }, children);
|
|
2200
2291
|
}
|
|
2201
2292
|
);
|
|
2202
2293
|
|
|
2203
|
-
// src/components/
|
|
2294
|
+
// src/components/DataState/DataState.tsx
|
|
2204
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"));
|
|
2205
2378
|
var Loader2 = ({ children }) => {
|
|
2206
|
-
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);
|
|
2207
2380
|
};
|
|
2208
2381
|
|
|
2209
2382
|
// src/components/BankTransactions/BankTransactions.tsx
|
|
@@ -2225,16 +2398,18 @@ var filterVisibility = (display) => (bankTransaction) => {
|
|
|
2225
2398
|
const inReview = ReviewCategories.includes(bankTransaction.categorization_status) || bankTransaction.recently_categorized;
|
|
2226
2399
|
return display === "review" /* review */ && inReview || display === "categorized" /* categorized */ && categorized;
|
|
2227
2400
|
};
|
|
2228
|
-
var BankTransactions = (
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
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));
|
|
2232
2407
|
const onCategorizationDisplayChange = (event) => setDisplay(
|
|
2233
2408
|
event.target.value === "categorized" /* categorized */ ? "categorized" /* categorized */ : "review" /* review */
|
|
2234
2409
|
);
|
|
2235
|
-
const [openRows, setOpenRows] = (0,
|
|
2410
|
+
const [openRows, setOpenRows] = (0, import_react30.useState)({});
|
|
2236
2411
|
const toggleOpen = (id) => setOpenRows({ ...openRows, [id]: !openRows[id] });
|
|
2237
|
-
const [shiftStickyHeader, setShiftStickyHeader] = (0,
|
|
2412
|
+
const [shiftStickyHeader, setShiftStickyHeader] = (0, import_react30.useState)(0);
|
|
2238
2413
|
const headerRef = useElementSize((_el, _en, size) => {
|
|
2239
2414
|
if (size?.height && size?.height >= 90) {
|
|
2240
2415
|
const newShift = -Math.floor(size.height / 2) + 6;
|
|
@@ -2246,15 +2421,15 @@ var BankTransactions = () => {
|
|
|
2246
2421
|
}
|
|
2247
2422
|
});
|
|
2248
2423
|
const editable = display === "review" /* review */;
|
|
2249
|
-
return /* @__PURE__ */
|
|
2424
|
+
return /* @__PURE__ */ import_react30.default.createElement(Container, { name: COMPONENT_NAME, asWidget }, /* @__PURE__ */ import_react30.default.createElement(
|
|
2250
2425
|
Header,
|
|
2251
2426
|
{
|
|
2252
2427
|
ref: headerRef,
|
|
2253
2428
|
className: "Layer__bank-transactions__header",
|
|
2254
2429
|
style: { top: shiftStickyHeader }
|
|
2255
2430
|
},
|
|
2256
|
-
/* @__PURE__ */
|
|
2257
|
-
/* @__PURE__ */
|
|
2431
|
+
/* @__PURE__ */ import_react30.default.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Transactions"),
|
|
2432
|
+
/* @__PURE__ */ import_react30.default.createElement(
|
|
2258
2433
|
Toggle,
|
|
2259
2434
|
{
|
|
2260
2435
|
name: "bank-transaction-display",
|
|
@@ -2266,14 +2441,14 @@ var BankTransactions = () => {
|
|
|
2266
2441
|
onChange: onCategorizationDisplayChange
|
|
2267
2442
|
}
|
|
2268
2443
|
)
|
|
2269
|
-
), /* @__PURE__ */
|
|
2444
|
+
), /* @__PURE__ */ import_react30.default.createElement(
|
|
2270
2445
|
"table",
|
|
2271
2446
|
{
|
|
2272
2447
|
width: "100%",
|
|
2273
2448
|
className: "Layer__table Layer__bank-transactions__table"
|
|
2274
2449
|
},
|
|
2275
|
-
/* @__PURE__ */
|
|
2276
|
-
/* @__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(
|
|
2277
2452
|
BankTransactionRow,
|
|
2278
2453
|
{
|
|
2279
2454
|
key: bankTransaction.id,
|
|
@@ -2284,7 +2459,7 @@ var BankTransactions = () => {
|
|
|
2284
2459
|
editable
|
|
2285
2460
|
}
|
|
2286
2461
|
)))
|
|
2287
|
-
), 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(
|
|
2288
2463
|
BankTransactionListItem,
|
|
2289
2464
|
{
|
|
2290
2465
|
key: bankTransaction.id,
|
|
@@ -2294,11 +2469,29 @@ var BankTransactions = () => {
|
|
|
2294
2469
|
toggleOpen,
|
|
2295
2470
|
editable
|
|
2296
2471
|
}
|
|
2297
|
-
))))
|
|
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);
|
|
2298
2491
|
};
|
|
2299
2492
|
|
|
2300
2493
|
// src/components/Hello/Hello.tsx
|
|
2301
|
-
var
|
|
2494
|
+
var import_react31 = __toESM(require("react"));
|
|
2302
2495
|
var import_swr3 = __toESM(require("swr"));
|
|
2303
2496
|
var fetcher = (url) => fetch(url).then((res) => res.json());
|
|
2304
2497
|
var Hello = ({ user }) => {
|
|
@@ -2307,14 +2500,14 @@ var Hello = ({ user }) => {
|
|
|
2307
2500
|
fetcher
|
|
2308
2501
|
);
|
|
2309
2502
|
const name = (isLoading ? "..." : data?.name) || "User";
|
|
2310
|
-
return /* @__PURE__ */
|
|
2503
|
+
return /* @__PURE__ */ import_react31.default.createElement(import_react31.default.Fragment, null, /* @__PURE__ */ import_react31.default.createElement("div", { className: "hello" }, "Hello, ", name, "!"));
|
|
2311
2504
|
};
|
|
2312
2505
|
|
|
2313
2506
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
2314
|
-
var
|
|
2507
|
+
var import_react39 = __toESM(require("react"));
|
|
2315
2508
|
|
|
2316
2509
|
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
2317
|
-
var
|
|
2510
|
+
var import_react32 = require("react");
|
|
2318
2511
|
var import_date_fns6 = require("date-fns");
|
|
2319
2512
|
var import_swr4 = __toESM(require("swr"));
|
|
2320
2513
|
var useProfitAndLoss = ({ startDate: initialStartDate, endDate: initialEndDate } = {
|
|
@@ -2322,10 +2515,10 @@ var useProfitAndLoss = ({ startDate: initialStartDate, endDate: initialEndDate }
|
|
|
2322
2515
|
endDate: (0, import_date_fns6.endOfMonth)(/* @__PURE__ */ new Date())
|
|
2323
2516
|
}) => {
|
|
2324
2517
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
2325
|
-
const [startDate, setStartDate] = (0,
|
|
2518
|
+
const [startDate, setStartDate] = (0, import_react32.useState)(
|
|
2326
2519
|
initialStartDate || (0, import_date_fns6.startOfMonth)(Date.now())
|
|
2327
2520
|
);
|
|
2328
|
-
const [endDate, setEndDate] = (0,
|
|
2521
|
+
const [endDate, setEndDate] = (0, import_react32.useState)(
|
|
2329
2522
|
initialEndDate || (0, import_date_fns6.endOfMonth)(Date.now())
|
|
2330
2523
|
);
|
|
2331
2524
|
const {
|
|
@@ -2360,10 +2553,10 @@ var useProfitAndLoss = ({ startDate: initialStartDate, endDate: initialEndDate }
|
|
|
2360
2553
|
};
|
|
2361
2554
|
|
|
2362
2555
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
2363
|
-
var
|
|
2556
|
+
var import_react34 = __toESM(require("react"));
|
|
2364
2557
|
|
|
2365
2558
|
// src/components/ProfitAndLossChart/Indicator.tsx
|
|
2366
|
-
var
|
|
2559
|
+
var import_react33 = __toESM(require("react"));
|
|
2367
2560
|
var emptyViewBox = { x: 0, y: 0, width: 0, height: 0 };
|
|
2368
2561
|
var Indicator = ({
|
|
2369
2562
|
viewBox = {},
|
|
@@ -2383,11 +2576,11 @@ var Indicator = ({
|
|
|
2383
2576
|
const boxWidth = width * 2 + 4;
|
|
2384
2577
|
const multiplier = 1.5;
|
|
2385
2578
|
const xOffset = (boxWidth * multiplier - boxWidth) / 2;
|
|
2386
|
-
(0,
|
|
2579
|
+
(0, import_react33.useEffect)(() => {
|
|
2387
2580
|
setAnimateFrom(animateTo);
|
|
2388
2581
|
}, [animateTo]);
|
|
2389
2582
|
const actualX = animateFrom === -1 ? animateTo : animateFrom;
|
|
2390
|
-
return /* @__PURE__ */
|
|
2583
|
+
return /* @__PURE__ */ import_react33.default.createElement(
|
|
2391
2584
|
"rect",
|
|
2392
2585
|
{
|
|
2393
2586
|
className: "Layer__profit-and-loss-chart__selection-indicator",
|
|
@@ -2407,7 +2600,7 @@ var import_recharts = require("recharts");
|
|
|
2407
2600
|
var barGap = 4;
|
|
2408
2601
|
var barSize = 20;
|
|
2409
2602
|
var ProfitAndLossChart = () => {
|
|
2410
|
-
const { changeDateRange, dateRange } = (0,
|
|
2603
|
+
const { changeDateRange, dateRange } = (0, import_react34.useContext)(ProfitAndLoss.Context);
|
|
2411
2604
|
const thisMonth = (0, import_date_fns7.startOfMonth)(Date.now());
|
|
2412
2605
|
const startSelectionMonth = dateRange.startDate.getMonth();
|
|
2413
2606
|
const endSelectionMonth = dateRange.endDate.getMonth();
|
|
@@ -2501,7 +2694,7 @@ var ProfitAndLossChart = () => {
|
|
|
2501
2694
|
});
|
|
2502
2695
|
}
|
|
2503
2696
|
};
|
|
2504
|
-
const data = (0,
|
|
2697
|
+
const data = (0, import_react34.useMemo)(
|
|
2505
2698
|
() => monthData.map(summarizePnL),
|
|
2506
2699
|
[
|
|
2507
2700
|
startSelectionMonth,
|
|
@@ -2509,8 +2702,8 @@ var ProfitAndLossChart = () => {
|
|
|
2509
2702
|
...monthData.map((m) => m?.net_profit)
|
|
2510
2703
|
]
|
|
2511
2704
|
);
|
|
2512
|
-
const [animateFrom, setAnimateFrom] = (0,
|
|
2513
|
-
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(
|
|
2514
2707
|
import_recharts.BarChart,
|
|
2515
2708
|
{
|
|
2516
2709
|
margin: { left: 24, right: 24, bottom: 24 },
|
|
@@ -2519,8 +2712,8 @@ var ProfitAndLossChart = () => {
|
|
|
2519
2712
|
barGap,
|
|
2520
2713
|
className: "Layer__profit-and-loss-chart"
|
|
2521
2714
|
},
|
|
2522
|
-
/* @__PURE__ */
|
|
2523
|
-
/* @__PURE__ */
|
|
2715
|
+
/* @__PURE__ */ import_react34.default.createElement(import_recharts.CartesianGrid, { vertical: false }),
|
|
2716
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
2524
2717
|
import_recharts.Legend,
|
|
2525
2718
|
{
|
|
2526
2719
|
verticalAlign: "top",
|
|
@@ -2531,8 +2724,8 @@ var ProfitAndLossChart = () => {
|
|
|
2531
2724
|
]
|
|
2532
2725
|
}
|
|
2533
2726
|
),
|
|
2534
|
-
/* @__PURE__ */
|
|
2535
|
-
/* @__PURE__ */
|
|
2727
|
+
/* @__PURE__ */ import_react34.default.createElement(import_recharts.XAxis, { dataKey: "name", tickLine: false }),
|
|
2728
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
2536
2729
|
import_recharts.Bar,
|
|
2537
2730
|
{
|
|
2538
2731
|
dataKey: "revenue",
|
|
@@ -2541,10 +2734,10 @@ var ProfitAndLossChart = () => {
|
|
|
2541
2734
|
radius: [barSize / 4, barSize / 4, 0, 0],
|
|
2542
2735
|
className: "Layer__profit-and-loss-chart__bar--income"
|
|
2543
2736
|
},
|
|
2544
|
-
/* @__PURE__ */
|
|
2737
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
2545
2738
|
import_recharts.LabelList,
|
|
2546
2739
|
{
|
|
2547
|
-
content: /* @__PURE__ */
|
|
2740
|
+
content: /* @__PURE__ */ import_react34.default.createElement(
|
|
2548
2741
|
Indicator,
|
|
2549
2742
|
{
|
|
2550
2743
|
animateFrom,
|
|
@@ -2553,7 +2746,7 @@ var ProfitAndLossChart = () => {
|
|
|
2553
2746
|
)
|
|
2554
2747
|
}
|
|
2555
2748
|
),
|
|
2556
|
-
data.map((entry) => /* @__PURE__ */
|
|
2749
|
+
data.map((entry) => /* @__PURE__ */ import_react34.default.createElement(
|
|
2557
2750
|
import_recharts.Cell,
|
|
2558
2751
|
{
|
|
2559
2752
|
key: entry.name,
|
|
@@ -2561,7 +2754,7 @@ var ProfitAndLossChart = () => {
|
|
|
2561
2754
|
}
|
|
2562
2755
|
))
|
|
2563
2756
|
),
|
|
2564
|
-
/* @__PURE__ */
|
|
2757
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
2565
2758
|
import_recharts.Bar,
|
|
2566
2759
|
{
|
|
2567
2760
|
dataKey: "expenses",
|
|
@@ -2570,7 +2763,7 @@ var ProfitAndLossChart = () => {
|
|
|
2570
2763
|
radius: [barSize / 4, barSize / 4, 0, 0],
|
|
2571
2764
|
className: "Layer__profit-and-loss-chart__bar--expenses"
|
|
2572
2765
|
},
|
|
2573
|
-
data.map((entry) => /* @__PURE__ */
|
|
2766
|
+
data.map((entry) => /* @__PURE__ */ import_react34.default.createElement(
|
|
2574
2767
|
import_recharts.Cell,
|
|
2575
2768
|
{
|
|
2576
2769
|
key: entry.name,
|
|
@@ -2582,15 +2775,15 @@ var ProfitAndLossChart = () => {
|
|
|
2582
2775
|
};
|
|
2583
2776
|
|
|
2584
2777
|
// src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
|
|
2585
|
-
var
|
|
2778
|
+
var import_react35 = __toESM(require("react"));
|
|
2586
2779
|
|
|
2587
2780
|
// src/icons/ChevronLeft.tsx
|
|
2588
|
-
var
|
|
2781
|
+
var React42 = __toESM(require("react"));
|
|
2589
2782
|
var ChevronLeft = ({
|
|
2590
2783
|
strokeColor,
|
|
2591
2784
|
size,
|
|
2592
2785
|
...props
|
|
2593
|
-
}) => /* @__PURE__ */
|
|
2786
|
+
}) => /* @__PURE__ */ React42.createElement(
|
|
2594
2787
|
"svg",
|
|
2595
2788
|
{
|
|
2596
2789
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -2600,7 +2793,7 @@ var ChevronLeft = ({
|
|
|
2600
2793
|
viewBox: "0 0 24 24",
|
|
2601
2794
|
...props
|
|
2602
2795
|
},
|
|
2603
|
-
/* @__PURE__ */
|
|
2796
|
+
/* @__PURE__ */ React42.createElement(
|
|
2604
2797
|
"path",
|
|
2605
2798
|
{
|
|
2606
2799
|
stroke: strokeColor ?? "#000",
|
|
@@ -2614,8 +2807,8 @@ var ChevronLeft = ({
|
|
|
2614
2807
|
var ChevronLeft_default = ChevronLeft;
|
|
2615
2808
|
|
|
2616
2809
|
// src/icons/ChevronRight.tsx
|
|
2617
|
-
var
|
|
2618
|
-
var ChavronRight = ({ size, ...props }) => /* @__PURE__ */
|
|
2810
|
+
var React43 = __toESM(require("react"));
|
|
2811
|
+
var ChavronRight = ({ size, ...props }) => /* @__PURE__ */ React43.createElement(
|
|
2619
2812
|
"svg",
|
|
2620
2813
|
{
|
|
2621
2814
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -2625,7 +2818,7 @@ var ChavronRight = ({ size, ...props }) => /* @__PURE__ */ React41.createElement
|
|
|
2625
2818
|
viewBox: "0 0 24 24",
|
|
2626
2819
|
...props
|
|
2627
2820
|
},
|
|
2628
|
-
/* @__PURE__ */
|
|
2821
|
+
/* @__PURE__ */ React43.createElement(
|
|
2629
2822
|
"path",
|
|
2630
2823
|
{
|
|
2631
2824
|
stroke: "#000",
|
|
@@ -2641,7 +2834,7 @@ var ChevronRight_default = ChavronRight;
|
|
|
2641
2834
|
// src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
|
|
2642
2835
|
var import_date_fns8 = require("date-fns");
|
|
2643
2836
|
var ProfitAndLossDatePicker = () => {
|
|
2644
|
-
const { changeDateRange, dateRange } = (0,
|
|
2837
|
+
const { changeDateRange, dateRange } = (0, import_react35.useContext)(ProfitAndLoss.Context);
|
|
2645
2838
|
const date = dateRange.startDate;
|
|
2646
2839
|
const label = (0, import_date_fns8.format)(date, "LLLL y");
|
|
2647
2840
|
const change = (duration) => {
|
|
@@ -2653,28 +2846,28 @@ var ProfitAndLossDatePicker = () => {
|
|
|
2653
2846
|
};
|
|
2654
2847
|
const previousMonth = () => change({ months: -1 });
|
|
2655
2848
|
const nextMonth = () => change({ months: 1 });
|
|
2656
|
-
return /* @__PURE__ */
|
|
2849
|
+
return /* @__PURE__ */ import_react35.default.createElement("div", { className: "Layer__profit-and-loss-date-picker" }, /* @__PURE__ */ import_react35.default.createElement(
|
|
2657
2850
|
"button",
|
|
2658
2851
|
{
|
|
2659
2852
|
"aria-label": "View Previous Month",
|
|
2660
2853
|
className: "Layer__profit-and-loss-date-picker__button",
|
|
2661
2854
|
onClick: previousMonth
|
|
2662
2855
|
},
|
|
2663
|
-
/* @__PURE__ */
|
|
2856
|
+
/* @__PURE__ */ import_react35.default.createElement(
|
|
2664
2857
|
ChevronLeft_default,
|
|
2665
2858
|
{
|
|
2666
2859
|
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
2667
2860
|
size: 18
|
|
2668
2861
|
}
|
|
2669
2862
|
)
|
|
2670
|
-
), /* @__PURE__ */
|
|
2863
|
+
), /* @__PURE__ */ import_react35.default.createElement("span", { className: "Layer__profit-and-loss-date-picker__label" }, label), /* @__PURE__ */ import_react35.default.createElement(
|
|
2671
2864
|
"button",
|
|
2672
2865
|
{
|
|
2673
2866
|
"aria-label": "View Next Month",
|
|
2674
2867
|
className: "Layer__profit-and-loss-date-picker__button",
|
|
2675
2868
|
onClick: nextMonth
|
|
2676
2869
|
},
|
|
2677
|
-
/* @__PURE__ */
|
|
2870
|
+
/* @__PURE__ */ import_react35.default.createElement(
|
|
2678
2871
|
ChevronRight_default,
|
|
2679
2872
|
{
|
|
2680
2873
|
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
@@ -2685,26 +2878,26 @@ var ProfitAndLossDatePicker = () => {
|
|
|
2685
2878
|
};
|
|
2686
2879
|
|
|
2687
2880
|
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
2688
|
-
var
|
|
2881
|
+
var import_react36 = __toESM(require("react"));
|
|
2689
2882
|
var ProfitAndLossSummaries = () => {
|
|
2690
|
-
const { data: storedData } = (0,
|
|
2883
|
+
const { data: storedData } = (0, import_react36.useContext)(ProfitAndLoss.Context);
|
|
2691
2884
|
const data = storedData ? storedData : { income: { value: NaN }, net_profit: NaN };
|
|
2692
2885
|
const incomeDirectionClass = (data.income.value ?? NaN) < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
|
|
2693
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";
|
|
2694
2887
|
const netProfitDirectionClass = data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
|
|
2695
|
-
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(
|
|
2696
2889
|
"span",
|
|
2697
2890
|
{
|
|
2698
2891
|
className: `Layer__profit-and-loss-summaries__amount ${incomeDirectionClass}`
|
|
2699
2892
|
},
|
|
2700
2893
|
centsToDollars(Math.abs(data?.income?.value ?? NaN))
|
|
2701
|
-
)), /* @__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(
|
|
2702
2895
|
"span",
|
|
2703
2896
|
{
|
|
2704
2897
|
className: `Layer__profit-and-loss-summaries__amount ${expensesDirectionClass}`
|
|
2705
2898
|
},
|
|
2706
2899
|
centsToDollars(Math.abs((data.income.value ?? 0) - data.net_profit))
|
|
2707
|
-
)), /* @__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(
|
|
2708
2901
|
"span",
|
|
2709
2902
|
{
|
|
2710
2903
|
className: `Layer__profit-and-loss-summaries__amount ${netProfitDirectionClass}`
|
|
@@ -2714,10 +2907,10 @@ var ProfitAndLossSummaries = () => {
|
|
|
2714
2907
|
};
|
|
2715
2908
|
|
|
2716
2909
|
// src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
|
|
2717
|
-
var
|
|
2910
|
+
var import_react38 = __toESM(require("react"));
|
|
2718
2911
|
|
|
2719
2912
|
// src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
|
|
2720
|
-
var
|
|
2913
|
+
var import_react37 = __toESM(require("react"));
|
|
2721
2914
|
var ProfitAndLossRow = ({
|
|
2722
2915
|
variant,
|
|
2723
2916
|
lineItem,
|
|
@@ -2730,7 +2923,7 @@ var ProfitAndLossRow = ({
|
|
|
2730
2923
|
return null;
|
|
2731
2924
|
}
|
|
2732
2925
|
const { value, display_name, line_items } = lineItem;
|
|
2733
|
-
const [expanded, setExpanded] = (0,
|
|
2926
|
+
const [expanded, setExpanded] = (0, import_react37.useState)(true);
|
|
2734
2927
|
const amount = value ?? 0;
|
|
2735
2928
|
const amountString = centsToDollars(Math.abs(amount));
|
|
2736
2929
|
const labelClasses = [
|
|
@@ -2761,12 +2954,12 @@ var ProfitAndLossRow = ({
|
|
|
2761
2954
|
);
|
|
2762
2955
|
displayChildren && expanded && labelClasses.push("Layer__profit-and-loss-row__label--expanded");
|
|
2763
2956
|
displayChildren && expanded && valueClasses.push("Layer__profit-and-loss-row__value--expanded");
|
|
2764
|
-
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(
|
|
2765
2958
|
"div",
|
|
2766
2959
|
{
|
|
2767
2960
|
className: `Layer__profit-and-loss-row__children ${expanded && "Layer__profit-and-loss-row__children--expanded"}`
|
|
2768
2961
|
},
|
|
2769
|
-
/* @__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(
|
|
2770
2963
|
ProfitAndLossRow,
|
|
2771
2964
|
{
|
|
2772
2965
|
key: line_item.display_name,
|
|
@@ -2775,7 +2968,7 @@ var ProfitAndLossRow = ({
|
|
|
2775
2968
|
maxDepth,
|
|
2776
2969
|
direction
|
|
2777
2970
|
}
|
|
2778
|
-
)), summarize && /* @__PURE__ */
|
|
2971
|
+
)), summarize && /* @__PURE__ */ import_react37.default.createElement(
|
|
2779
2972
|
ProfitAndLossRow,
|
|
2780
2973
|
{
|
|
2781
2974
|
key: display_name,
|
|
@@ -2838,15 +3031,15 @@ var empty_profit_and_loss_report_default = {
|
|
|
2838
3031
|
|
|
2839
3032
|
// src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
|
|
2840
3033
|
var ProfitAndLossTable = () => {
|
|
2841
|
-
const { data: actualData, isLoading } = (0,
|
|
3034
|
+
const { data: actualData, isLoading } = (0, import_react38.useContext)(ProfitAndLoss.Context);
|
|
2842
3035
|
const data = !actualData || isLoading ? empty_profit_and_loss_report_default : actualData;
|
|
2843
|
-
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(
|
|
2844
3037
|
ProfitAndLossRow,
|
|
2845
3038
|
{
|
|
2846
3039
|
lineItem: data.cost_of_goods_sold,
|
|
2847
3040
|
direction: "DEBIT" /* DEBIT */
|
|
2848
3041
|
}
|
|
2849
|
-
), /* @__PURE__ */
|
|
3042
|
+
), /* @__PURE__ */ import_react38.default.createElement(
|
|
2850
3043
|
ProfitAndLossRow,
|
|
2851
3044
|
{
|
|
2852
3045
|
lineItem: {
|
|
@@ -2856,13 +3049,13 @@ var ProfitAndLossTable = () => {
|
|
|
2856
3049
|
variant: "summation",
|
|
2857
3050
|
direction: "CREDIT" /* CREDIT */
|
|
2858
3051
|
}
|
|
2859
|
-
), /* @__PURE__ */
|
|
3052
|
+
), /* @__PURE__ */ import_react38.default.createElement(
|
|
2860
3053
|
ProfitAndLossRow,
|
|
2861
3054
|
{
|
|
2862
3055
|
lineItem: data.expenses,
|
|
2863
3056
|
direction: "DEBIT" /* DEBIT */
|
|
2864
3057
|
}
|
|
2865
|
-
), /* @__PURE__ */
|
|
3058
|
+
), /* @__PURE__ */ import_react38.default.createElement(
|
|
2866
3059
|
ProfitAndLossRow,
|
|
2867
3060
|
{
|
|
2868
3061
|
lineItem: {
|
|
@@ -2872,7 +3065,7 @@ var ProfitAndLossTable = () => {
|
|
|
2872
3065
|
variant: "summation",
|
|
2873
3066
|
direction: "CREDIT" /* CREDIT */
|
|
2874
3067
|
}
|
|
2875
|
-
), /* @__PURE__ */
|
|
3068
|
+
), /* @__PURE__ */ import_react38.default.createElement(ProfitAndLossRow, { lineItem: data.taxes, direction: "DEBIT" /* DEBIT */ }), /* @__PURE__ */ import_react38.default.createElement(
|
|
2876
3069
|
ProfitAndLossRow,
|
|
2877
3070
|
{
|
|
2878
3071
|
lineItem: {
|
|
@@ -2882,13 +3075,13 @@ var ProfitAndLossTable = () => {
|
|
|
2882
3075
|
variant: "summation",
|
|
2883
3076
|
direction: "CREDIT" /* CREDIT */
|
|
2884
3077
|
}
|
|
2885
|
-
)), /* @__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(
|
|
2886
3079
|
ProfitAndLossRow,
|
|
2887
3080
|
{
|
|
2888
3081
|
lineItem: data.other_outflows,
|
|
2889
3082
|
direction: "DEBIT" /* DEBIT */
|
|
2890
3083
|
}
|
|
2891
|
-
), /* @__PURE__ */
|
|
3084
|
+
), /* @__PURE__ */ import_react38.default.createElement(
|
|
2892
3085
|
ProfitAndLossRow,
|
|
2893
3086
|
{
|
|
2894
3087
|
lineItem: data.personal_expenses,
|
|
@@ -2899,7 +3092,7 @@ var ProfitAndLossTable = () => {
|
|
|
2899
3092
|
|
|
2900
3093
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
2901
3094
|
var import_date_fns9 = require("date-fns");
|
|
2902
|
-
var PNLContext = (0,
|
|
3095
|
+
var PNLContext = (0, import_react39.createContext)({
|
|
2903
3096
|
data: void 0,
|
|
2904
3097
|
isLoading: true,
|
|
2905
3098
|
error: void 0,
|
|
@@ -2912,7 +3105,7 @@ var PNLContext = (0, import_react38.createContext)({
|
|
|
2912
3105
|
});
|
|
2913
3106
|
var ProfitAndLoss = ({ children }) => {
|
|
2914
3107
|
const contextData = useProfitAndLoss();
|
|
2915
|
-
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));
|
|
2916
3109
|
};
|
|
2917
3110
|
ProfitAndLoss.Chart = ProfitAndLossChart;
|
|
2918
3111
|
ProfitAndLoss.Context = PNLContext;
|
|
@@ -2921,7 +3114,7 @@ ProfitAndLoss.Summaries = ProfitAndLossSummaries;
|
|
|
2921
3114
|
ProfitAndLoss.Table = ProfitAndLossTable;
|
|
2922
3115
|
|
|
2923
3116
|
// src/providers/LayerProvider/LayerProvider.tsx
|
|
2924
|
-
var
|
|
3117
|
+
var import_react40 = __toESM(require("react"));
|
|
2925
3118
|
var import_date_fns10 = require("date-fns");
|
|
2926
3119
|
var import_swr5 = __toESM(require("swr"));
|
|
2927
3120
|
var reducer = (state, action) => {
|
|
@@ -2951,7 +3144,7 @@ var LayerProvider = ({
|
|
|
2951
3144
|
appSecret,
|
|
2952
3145
|
businessId,
|
|
2953
3146
|
children,
|
|
2954
|
-
|
|
3147
|
+
businessAccessToken,
|
|
2955
3148
|
environment = "production",
|
|
2956
3149
|
theme
|
|
2957
3150
|
}) => {
|
|
@@ -2962,7 +3155,7 @@ var LayerProvider = ({
|
|
|
2962
3155
|
revalidateIfStale: false
|
|
2963
3156
|
};
|
|
2964
3157
|
const { url, scope, apiUrl } = LayerEnvironment[environment];
|
|
2965
|
-
const [state, dispatch] = (0,
|
|
3158
|
+
const [state, dispatch] = (0, import_react40.useReducer)(reducer, {
|
|
2966
3159
|
auth: {
|
|
2967
3160
|
access_token: "",
|
|
2968
3161
|
token_type: "",
|
|
@@ -2974,19 +3167,30 @@ var LayerProvider = ({
|
|
|
2974
3167
|
apiUrl,
|
|
2975
3168
|
theme
|
|
2976
3169
|
});
|
|
2977
|
-
const { data: auth } = (0, import_swr5.default)(
|
|
2978
|
-
(0, import_date_fns10.isBefore)(state.auth.expires_at, /* @__PURE__ */ new Date()) && "authenticate",
|
|
3170
|
+
const { data: auth } = appId !== void 0 && appSecret !== void 0 ? (0, import_swr5.default)(
|
|
3171
|
+
businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && (0, import_date_fns10.isBefore)(state.auth.expires_at, /* @__PURE__ */ new Date()) && "authenticate",
|
|
2979
3172
|
Layer.authenticate({
|
|
2980
3173
|
appId,
|
|
2981
3174
|
appSecret,
|
|
2982
3175
|
authenticationUrl: url,
|
|
2983
|
-
scope
|
|
2984
|
-
clientId
|
|
3176
|
+
scope
|
|
2985
3177
|
}),
|
|
2986
3178
|
defaultSWRConfig
|
|
2987
|
-
);
|
|
2988
|
-
(0,
|
|
2989
|
-
if (
|
|
3179
|
+
) : { data: void 0 };
|
|
3180
|
+
(0, import_react40.useEffect)(() => {
|
|
3181
|
+
if (businessAccessToken) {
|
|
3182
|
+
dispatch({
|
|
3183
|
+
type: "LayerContext.setAuth" /* setAuth */,
|
|
3184
|
+
payload: {
|
|
3185
|
+
auth: {
|
|
3186
|
+
access_token: businessAccessToken,
|
|
3187
|
+
token_type: "Bearer",
|
|
3188
|
+
expires_in: 3600,
|
|
3189
|
+
expires_at: (0, import_date_fns10.add)(/* @__PURE__ */ new Date(), { seconds: 3600 })
|
|
3190
|
+
}
|
|
3191
|
+
}
|
|
3192
|
+
});
|
|
3193
|
+
} else if (auth?.access_token) {
|
|
2990
3194
|
dispatch({
|
|
2991
3195
|
type: "LayerContext.setAuth" /* setAuth */,
|
|
2992
3196
|
payload: {
|
|
@@ -2997,13 +3201,13 @@ var LayerProvider = ({
|
|
|
2997
3201
|
}
|
|
2998
3202
|
});
|
|
2999
3203
|
}
|
|
3000
|
-
}, [auth?.access_token]);
|
|
3204
|
+
}, [businessAccessToken, auth?.access_token]);
|
|
3001
3205
|
const { data: categories } = (0, import_swr5.default)(
|
|
3002
3206
|
businessId && auth?.access_token && `categories-${businessId}`,
|
|
3003
3207
|
Layer.getCategories(apiUrl, auth?.access_token, { params: { businessId } }),
|
|
3004
3208
|
defaultSWRConfig
|
|
3005
3209
|
);
|
|
3006
|
-
(0,
|
|
3210
|
+
(0, import_react40.useEffect)(() => {
|
|
3007
3211
|
if (categories?.data?.categories?.length) {
|
|
3008
3212
|
dispatch({
|
|
3009
3213
|
type: "LayerContext.setCategories" /* setCategories */,
|
|
@@ -3015,11 +3219,11 @@ var LayerProvider = ({
|
|
|
3015
3219
|
type: "LayerContext.setTheme" /* setTheme */,
|
|
3016
3220
|
payload: { theme: theme2 }
|
|
3017
3221
|
});
|
|
3018
|
-
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));
|
|
3019
3223
|
};
|
|
3020
3224
|
|
|
3021
3225
|
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
3022
|
-
var
|
|
3226
|
+
var import_react43 = __toESM(require("react"));
|
|
3023
3227
|
|
|
3024
3228
|
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
3025
3229
|
var import_swr6 = __toESM(require("swr"));
|
|
@@ -3039,21 +3243,21 @@ var useChartOfAccounts = () => {
|
|
|
3039
3243
|
};
|
|
3040
3244
|
|
|
3041
3245
|
// src/components/ChartOfAccountsNewForm/ChartOfAccountsNewForm.tsx
|
|
3042
|
-
var
|
|
3246
|
+
var import_react41 = __toESM(require("react"));
|
|
3043
3247
|
var import_react_select2 = __toESM(require("react-select"));
|
|
3044
3248
|
var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.subAccounts || [])]).flat().filter((id) => id);
|
|
3045
3249
|
var ChartOfAccountsNewForm = () => {
|
|
3046
3250
|
const { data, create: createAccount2 } = useChartOfAccounts();
|
|
3047
|
-
const accountOptions = (0,
|
|
3251
|
+
const accountOptions = (0, import_react41.useMemo)(
|
|
3048
3252
|
() => flattenAccounts(data?.accounts || []).sort(
|
|
3049
3253
|
(a, b) => a?.name && b?.name ? a.name.localeCompare(b.name) : 0
|
|
3050
3254
|
),
|
|
3051
3255
|
[data?.accounts?.length]
|
|
3052
3256
|
);
|
|
3053
|
-
const [name, setName] = (0,
|
|
3054
|
-
const [description, setDescription] = (0,
|
|
3055
|
-
const [normality, setNormality] = (0,
|
|
3056
|
-
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)(
|
|
3057
3261
|
data?.accounts[0]
|
|
3058
3262
|
);
|
|
3059
3263
|
const save = () => {
|
|
@@ -3067,21 +3271,21 @@ var ChartOfAccountsNewForm = () => {
|
|
|
3067
3271
|
description
|
|
3068
3272
|
});
|
|
3069
3273
|
};
|
|
3070
|
-
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(
|
|
3071
3275
|
"input",
|
|
3072
3276
|
{
|
|
3073
3277
|
name: "name",
|
|
3074
3278
|
value: name,
|
|
3075
3279
|
onChange: (event) => setName(event.target.value)
|
|
3076
3280
|
}
|
|
3077
|
-
)), /* @__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(
|
|
3078
3282
|
"input",
|
|
3079
3283
|
{
|
|
3080
3284
|
name: "description",
|
|
3081
3285
|
value: description,
|
|
3082
3286
|
onChange: (event) => setDescription(event.target.value)
|
|
3083
3287
|
}
|
|
3084
|
-
)), /* @__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(
|
|
3085
3289
|
import_react_select2.default,
|
|
3086
3290
|
{
|
|
3087
3291
|
isSearchable: false,
|
|
@@ -3091,7 +3295,7 @@ var ChartOfAccountsNewForm = () => {
|
|
|
3091
3295
|
{ label: "Debit", value: "DEBIT" /* DEBIT */ }
|
|
3092
3296
|
]
|
|
3093
3297
|
}
|
|
3094
|
-
)), /* @__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(
|
|
3095
3299
|
import_react_select2.default,
|
|
3096
3300
|
{
|
|
3097
3301
|
isSearchable: true,
|
|
@@ -3101,49 +3305,49 @@ var ChartOfAccountsNewForm = () => {
|
|
|
3101
3305
|
getOptionValue: (a) => a.id,
|
|
3102
3306
|
options: accountOptions
|
|
3103
3307
|
}
|
|
3104
|
-
)), /* @__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")));
|
|
3105
3309
|
};
|
|
3106
3310
|
|
|
3107
3311
|
// src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
|
|
3108
|
-
var
|
|
3312
|
+
var import_react42 = __toESM(require("react"));
|
|
3109
3313
|
var ChartOfAccountsRow = ({ account, depth = 0 }) => {
|
|
3110
|
-
const
|
|
3314
|
+
const classNames13 = [
|
|
3111
3315
|
"Layer__chart-of-accounts-row__table-cell",
|
|
3112
3316
|
depth > 0 && `Layer__chart-of-accounts-row__table-cell--depth-${depth}`
|
|
3113
3317
|
];
|
|
3114
|
-
const className =
|
|
3318
|
+
const className = classNames13.filter((id) => id).join(" ");
|
|
3115
3319
|
const amountClassName = account.balance < 0 ? "Layer__chart-of-accounts-row__table-cell--amount-negative" : "Layer__chart-of-accounts-row__table-cell--amount-positive";
|
|
3116
|
-
return /* @__PURE__ */
|
|
3320
|
+
return /* @__PURE__ */ import_react42.default.createElement(import_react42.default.Fragment, null, /* @__PURE__ */ import_react42.default.createElement(
|
|
3117
3321
|
"div",
|
|
3118
3322
|
{
|
|
3119
3323
|
className: `${className} Layer__chart-of-accounts-row__table-cell--name`
|
|
3120
3324
|
},
|
|
3121
3325
|
account.name
|
|
3122
|
-
), /* @__PURE__ */
|
|
3326
|
+
), /* @__PURE__ */ import_react42.default.createElement(
|
|
3123
3327
|
"div",
|
|
3124
3328
|
{
|
|
3125
3329
|
className: `${className} Layer__chart-of-accounts-row__table-cell--type`
|
|
3126
3330
|
},
|
|
3127
3331
|
"Assets"
|
|
3128
|
-
), /* @__PURE__ */
|
|
3332
|
+
), /* @__PURE__ */ import_react42.default.createElement(
|
|
3129
3333
|
"div",
|
|
3130
3334
|
{
|
|
3131
3335
|
className: `${className} Layer__chart-of-accounts-row__table-cell--subtype`
|
|
3132
3336
|
},
|
|
3133
3337
|
"Cash"
|
|
3134
|
-
), /* @__PURE__ */
|
|
3338
|
+
), /* @__PURE__ */ import_react42.default.createElement(
|
|
3135
3339
|
"div",
|
|
3136
3340
|
{
|
|
3137
3341
|
className: `${className} Layer__chart-of-accounts-row__table-cell--balance ${amountClassName}`
|
|
3138
3342
|
},
|
|
3139
3343
|
centsToDollars(Math.abs(account.balance || 0))
|
|
3140
|
-
), /* @__PURE__ */
|
|
3344
|
+
), /* @__PURE__ */ import_react42.default.createElement(
|
|
3141
3345
|
"div",
|
|
3142
3346
|
{
|
|
3143
3347
|
className: `${className} Layer__chart-of-accounts-row__table-cell--actions`
|
|
3144
3348
|
},
|
|
3145
|
-
/* @__PURE__ */
|
|
3146
|
-
), (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(
|
|
3147
3351
|
ChartOfAccountsRow,
|
|
3148
3352
|
{
|
|
3149
3353
|
key: subAccount.id,
|
|
@@ -3156,15 +3360,15 @@ var ChartOfAccountsRow = ({ account, depth = 0 }) => {
|
|
|
3156
3360
|
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
3157
3361
|
var ChartOfAccounts = () => {
|
|
3158
3362
|
const { data, isLoading } = useChartOfAccounts();
|
|
3159
|
-
const [showingForm, setShowingForm] = (0,
|
|
3160
|
-
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(
|
|
3161
3365
|
"button",
|
|
3162
3366
|
{
|
|
3163
3367
|
className: "Layer__chart-of-accounts__edit-accounts-button",
|
|
3164
3368
|
onClick: () => setShowingForm(!showingForm)
|
|
3165
3369
|
},
|
|
3166
3370
|
"Edit Accounts"
|
|
3167
|
-
))), 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(
|
|
3168
3372
|
ChartOfAccountsRow,
|
|
3169
3373
|
{
|
|
3170
3374
|
key: account.id,
|