@layerfi/components 0.1.7 → 0.1.9
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 +1440 -821
- package/dist/esm/index.js.map +4 -4
- package/dist/index.d.ts +286 -119
- package/dist/index.js +1468 -851
- package/dist/index.js.map +4 -4
- package/dist/styles/index.css +456 -171
- package/dist/styles/index.css.map +3 -3
- package/package.json +1 -1
- package/index.d.ts +0 -1309
package/dist/index.js
CHANGED
|
@@ -32,9 +32,9 @@ var src_exports = {};
|
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
BalanceSheet: () => BalanceSheet,
|
|
34
34
|
BankTransactions: () => BankTransactions,
|
|
35
|
-
ChartOfAccounts: () => ChartOfAccounts,
|
|
36
35
|
Hello: () => Hello,
|
|
37
36
|
LayerProvider: () => LayerProvider,
|
|
37
|
+
LedgerAccounts: () => LedgerAccounts,
|
|
38
38
|
LinkedAccounts: () => LinkedAccounts,
|
|
39
39
|
ProfitAndLoss: () => ProfitAndLoss,
|
|
40
40
|
ProfitAndLossView: () => ProfitAndLossView
|
|
@@ -304,8 +304,8 @@ var matchBankTransaction = put(
|
|
|
304
304
|
// src/api/layer/categories.ts
|
|
305
305
|
var getCategories = get(({ businessId }) => `/v1/businesses/${businessId}/categories`);
|
|
306
306
|
|
|
307
|
-
// src/api/layer/
|
|
308
|
-
var
|
|
307
|
+
// src/api/layer/ledger_accounts.ts
|
|
308
|
+
var getLedgerAccounts = get(
|
|
309
309
|
({ businessId }) => `/v1/businesses/${businessId}/ledger/accounts`
|
|
310
310
|
);
|
|
311
311
|
var createAccount = post(
|
|
@@ -326,7 +326,7 @@ var Layer = {
|
|
|
326
326
|
getBalanceSheet,
|
|
327
327
|
getBankTransactions,
|
|
328
328
|
getCategories,
|
|
329
|
-
|
|
329
|
+
getLedgerAccounts,
|
|
330
330
|
getProfitAndLoss
|
|
331
331
|
};
|
|
332
332
|
|
|
@@ -371,23 +371,41 @@ var useBalanceSheet = (date = /* @__PURE__ */ new Date()) => {
|
|
|
371
371
|
|
|
372
372
|
// src/icons/DownloadCloud.tsx
|
|
373
373
|
var React = __toESM(require("react"));
|
|
374
|
-
var DownloadCloud = (props) => /* @__PURE__ */ React.createElement(
|
|
374
|
+
var DownloadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React.createElement(
|
|
375
375
|
"svg",
|
|
376
376
|
{
|
|
377
377
|
xmlns: "http://www.w3.org/2000/svg",
|
|
378
|
-
|
|
379
|
-
height: 24,
|
|
378
|
+
viewBox: "0 0 18 18",
|
|
380
379
|
fill: "none",
|
|
381
|
-
...props
|
|
380
|
+
...props,
|
|
381
|
+
width: size,
|
|
382
|
+
height: size
|
|
382
383
|
},
|
|
383
384
|
/* @__PURE__ */ React.createElement(
|
|
384
385
|
"path",
|
|
385
386
|
{
|
|
386
|
-
|
|
387
|
+
d: "M6 12.75L9 15.75L12 12.75",
|
|
388
|
+
stroke: "currentColor",
|
|
387
389
|
strokeLinecap: "round",
|
|
388
|
-
strokeLinejoin: "round"
|
|
389
|
-
|
|
390
|
-
|
|
390
|
+
strokeLinejoin: "round"
|
|
391
|
+
}
|
|
392
|
+
),
|
|
393
|
+
/* @__PURE__ */ React.createElement(
|
|
394
|
+
"path",
|
|
395
|
+
{
|
|
396
|
+
d: "M9 9V15.75",
|
|
397
|
+
stroke: "currentColor",
|
|
398
|
+
strokeLinecap: "round",
|
|
399
|
+
strokeLinejoin: "round"
|
|
400
|
+
}
|
|
401
|
+
),
|
|
402
|
+
/* @__PURE__ */ React.createElement(
|
|
403
|
+
"path",
|
|
404
|
+
{
|
|
405
|
+
d: "M15.66 13.5675C16.3121 13.109 16.801 12.4546 17.056 11.6994C17.3109 10.9441 17.3186 10.1273 17.0778 9.36737C16.837 8.60748 16.3604 7.94407 15.7171 7.47342C15.0737 7.00278 14.2971 6.74938 13.5 6.75H12.555C12.3294 5.87091 11.9074 5.05444 11.3206 4.36206C10.7338 3.66969 9.99762 3.11945 9.16742 2.75277C8.33721 2.38609 7.43464 2.21252 6.52766 2.24514C5.62067 2.27776 4.7329 2.51571 3.93118 2.94107C3.12946 3.36644 2.43468 3.96814 1.89915 4.70087C1.36362 5.43361 1.0013 6.27829 0.839456 7.17132C0.677613 8.06434 0.720468 8.98245 0.964796 9.85652C1.20912 10.7306 1.64856 11.5378 2.25001 12.2175",
|
|
406
|
+
stroke: "currentColor",
|
|
407
|
+
strokeLinecap: "round",
|
|
408
|
+
strokeLinejoin: "round"
|
|
391
409
|
}
|
|
392
410
|
)
|
|
393
411
|
);
|
|
@@ -606,7 +624,7 @@ var BalanceSheet = () => {
|
|
|
606
624
|
};
|
|
607
625
|
|
|
608
626
|
// src/components/BankTransactions/BankTransactions.tsx
|
|
609
|
-
var
|
|
627
|
+
var import_react43 = __toESM(require("react"));
|
|
610
628
|
|
|
611
629
|
// src/config/general.ts
|
|
612
630
|
var DATE_FORMAT = "LLL d, yyyy";
|
|
@@ -762,7 +780,7 @@ var debounce = (fnc, timeout = 300) => {
|
|
|
762
780
|
};
|
|
763
781
|
|
|
764
782
|
// src/components/BankTransactionListItem/BankTransactionListItem.tsx
|
|
765
|
-
var
|
|
783
|
+
var import_react36 = __toESM(require("react"));
|
|
766
784
|
|
|
767
785
|
// src/icons/ChevronDownFill.tsx
|
|
768
786
|
var React8 = __toESM(require("react"));
|
|
@@ -790,7 +808,7 @@ var ChevronDownFill = ({ size = 18, ...props }) => /* @__PURE__ */ React8.create
|
|
|
790
808
|
var ChevronDownFill_default = ChevronDownFill;
|
|
791
809
|
|
|
792
810
|
// src/components/BankTransactionRow/BankTransactionRow.tsx
|
|
793
|
-
var
|
|
811
|
+
var import_react34 = __toESM(require("react"));
|
|
794
812
|
|
|
795
813
|
// src/icons/AlertCircle.tsx
|
|
796
814
|
var React9 = __toESM(require("react"));
|
|
@@ -1426,8 +1444,12 @@ var import_classnames4 = __toESM(require("classnames"));
|
|
|
1426
1444
|
var buildRightIcon = ({
|
|
1427
1445
|
processing,
|
|
1428
1446
|
error,
|
|
1429
|
-
action
|
|
1447
|
+
action,
|
|
1448
|
+
noIcon
|
|
1430
1449
|
}) => {
|
|
1450
|
+
if (noIcon) {
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1431
1453
|
if (processing) {
|
|
1432
1454
|
return /* @__PURE__ */ import_react15.default.createElement(Loader_default, { size: 14, className: "Layer__anim--rotating" });
|
|
1433
1455
|
}
|
|
@@ -1447,6 +1469,7 @@ var SubmitButton = ({
|
|
|
1447
1469
|
error,
|
|
1448
1470
|
children,
|
|
1449
1471
|
action = "save" /* SAVE */,
|
|
1472
|
+
noIcon,
|
|
1450
1473
|
...props
|
|
1451
1474
|
}) => {
|
|
1452
1475
|
const baseClassName = (0, import_classnames4.default)(
|
|
@@ -1460,7 +1483,7 @@ var SubmitButton = ({
|
|
|
1460
1483
|
className: baseClassName,
|
|
1461
1484
|
variant: "primary" /* primary */,
|
|
1462
1485
|
disabled: processing || disabled,
|
|
1463
|
-
rightIcon: buildRightIcon({ processing, error, action }),
|
|
1486
|
+
rightIcon: buildRightIcon({ processing, error, action, noIcon }),
|
|
1464
1487
|
iconAsPrimary: true
|
|
1465
1488
|
},
|
|
1466
1489
|
children
|
|
@@ -1759,7 +1782,7 @@ var CategorySelect = ({
|
|
|
1759
1782
|
};
|
|
1760
1783
|
|
|
1761
1784
|
// src/components/ExpandedBankTransactionRow/ExpandedBankTransactionRow.tsx
|
|
1762
|
-
var
|
|
1785
|
+
var import_react32 = __toESM(require("react"));
|
|
1763
1786
|
|
|
1764
1787
|
// src/icons/ScissorsFullOpen.tsx
|
|
1765
1788
|
var React26 = __toESM(require("react"));
|
|
@@ -2055,9 +2078,14 @@ var InputGroup = ({
|
|
|
2055
2078
|
label,
|
|
2056
2079
|
name,
|
|
2057
2080
|
className,
|
|
2081
|
+
inline,
|
|
2058
2082
|
children
|
|
2059
2083
|
}) => {
|
|
2060
|
-
const baseClassName = (0, import_classnames12.default)(
|
|
2084
|
+
const baseClassName = (0, import_classnames12.default)(
|
|
2085
|
+
"Layer__input-group",
|
|
2086
|
+
className,
|
|
2087
|
+
inline && "Layer__input-group--inline"
|
|
2088
|
+
);
|
|
2061
2089
|
return /* @__PURE__ */ import_react24.default.createElement("div", { className: baseClassName }, label && /* @__PURE__ */ import_react24.default.createElement(
|
|
2062
2090
|
Text,
|
|
2063
2091
|
{
|
|
@@ -2157,11 +2185,43 @@ var FileInput = ({ text = "Upload", onUpload }) => {
|
|
|
2157
2185
|
));
|
|
2158
2186
|
};
|
|
2159
2187
|
|
|
2188
|
+
// src/components/Input/Select.tsx
|
|
2189
|
+
var import_react26 = __toESM(require("react"));
|
|
2190
|
+
var import_react_select3 = __toESM(require("react-select"));
|
|
2191
|
+
var DropdownIndicator3 = (props) => {
|
|
2192
|
+
return /* @__PURE__ */ import_react26.default.createElement(import_react_select3.components.DropdownIndicator, { ...props }, /* @__PURE__ */ import_react26.default.createElement(ChevronDownFill_default, null));
|
|
2193
|
+
};
|
|
2194
|
+
var Select3 = ({
|
|
2195
|
+
name,
|
|
2196
|
+
options,
|
|
2197
|
+
className,
|
|
2198
|
+
classNamePrefix = "Layer__select",
|
|
2199
|
+
value,
|
|
2200
|
+
onChange,
|
|
2201
|
+
disabled
|
|
2202
|
+
}) => {
|
|
2203
|
+
return /* @__PURE__ */ import_react26.default.createElement(
|
|
2204
|
+
import_react_select3.default,
|
|
2205
|
+
{
|
|
2206
|
+
name,
|
|
2207
|
+
className: `Layer__select ${className ?? ""}`,
|
|
2208
|
+
classNamePrefix,
|
|
2209
|
+
options,
|
|
2210
|
+
value,
|
|
2211
|
+
onChange: (newValue) => newValue && onChange(newValue),
|
|
2212
|
+
menuPortalTarget: document.body,
|
|
2213
|
+
styles: { menuPortal: (base) => ({ ...base, zIndex: 9999 }) },
|
|
2214
|
+
components: { DropdownIndicator: DropdownIndicator3 },
|
|
2215
|
+
isDisabled: disabled
|
|
2216
|
+
}
|
|
2217
|
+
);
|
|
2218
|
+
};
|
|
2219
|
+
|
|
2160
2220
|
// src/components/MatchForm/MatchForm.tsx
|
|
2161
|
-
var
|
|
2221
|
+
var import_react28 = __toESM(require("react"));
|
|
2162
2222
|
|
|
2163
2223
|
// src/components/BankTransactionRow/MatchBadge.tsx
|
|
2164
|
-
var
|
|
2224
|
+
var import_react27 = __toESM(require("react"));
|
|
2165
2225
|
var import_date_fns5 = require("date-fns");
|
|
2166
2226
|
var MatchBadge = ({
|
|
2167
2227
|
bankTransaction,
|
|
@@ -2171,11 +2231,11 @@ var MatchBadge = ({
|
|
|
2171
2231
|
}) => {
|
|
2172
2232
|
if (bankTransaction.categorization_status === "MATCHED" /* MATCHED */ && bankTransaction.match) {
|
|
2173
2233
|
const { date, amount, description } = bankTransaction.match.bank_transaction;
|
|
2174
|
-
return /* @__PURE__ */
|
|
2234
|
+
return /* @__PURE__ */ import_react27.default.createElement(
|
|
2175
2235
|
Badge,
|
|
2176
2236
|
{
|
|
2177
|
-
icon: /* @__PURE__ */
|
|
2178
|
-
tooltip: /* @__PURE__ */
|
|
2237
|
+
icon: /* @__PURE__ */ import_react27.default.createElement(MinimizeTwo_default, { size: 11 }),
|
|
2238
|
+
tooltip: /* @__PURE__ */ import_react27.default.createElement("span", { className: `${classNamePrefix}__match-tooltip` }, /* @__PURE__ */ import_react27.default.createElement("div", { className: `${classNamePrefix}__match-tooltip__date` }, (0, import_date_fns5.format)((0, import_date_fns5.parseISO)(date), dateFormat)), /* @__PURE__ */ import_react27.default.createElement("div", { className: `${classNamePrefix}__match-tooltip__description` }, description), /* @__PURE__ */ import_react27.default.createElement("div", { className: `${classNamePrefix}__match-tooltip__amount` }, "$", centsToDollars(amount)))
|
|
2179
2239
|
},
|
|
2180
2240
|
text
|
|
2181
2241
|
);
|
|
@@ -2193,13 +2253,13 @@ var MatchForm = ({
|
|
|
2193
2253
|
setSelectedMatchId,
|
|
2194
2254
|
matchFormError
|
|
2195
2255
|
}) => {
|
|
2196
|
-
return /* @__PURE__ */
|
|
2256
|
+
return /* @__PURE__ */ import_react28.default.createElement("div", { className: `${classNamePrefix}__match-table` }, /* @__PURE__ */ import_react28.default.createElement("div", { className: `${classNamePrefix}__match-table__header` }, /* @__PURE__ */ import_react28.default.createElement("div", { className: `${classNamePrefix}__match-table__date` }, "Date"), /* @__PURE__ */ import_react28.default.createElement("div", { className: `${classNamePrefix}__match-table__desc` }, "Description"), /* @__PURE__ */ import_react28.default.createElement("div", { className: `${classNamePrefix}__match-table__amount` }, "Amount"), /* @__PURE__ */ import_react28.default.createElement(
|
|
2197
2257
|
"div",
|
|
2198
2258
|
{
|
|
2199
2259
|
className: `${classNamePrefix}__match-table__status ${bankTransaction.match ? "" : "no-match"}`
|
|
2200
2260
|
}
|
|
2201
2261
|
)), bankTransaction.suggested_matches?.map((match, idx) => {
|
|
2202
|
-
return /* @__PURE__ */
|
|
2262
|
+
return /* @__PURE__ */ import_react28.default.createElement(
|
|
2203
2263
|
"div",
|
|
2204
2264
|
{
|
|
2205
2265
|
key: idx,
|
|
@@ -2215,15 +2275,15 @@ var MatchForm = ({
|
|
|
2215
2275
|
setSelectedMatchId(match.id);
|
|
2216
2276
|
}
|
|
2217
2277
|
},
|
|
2218
|
-
/* @__PURE__ */
|
|
2278
|
+
/* @__PURE__ */ import_react28.default.createElement(
|
|
2219
2279
|
"div",
|
|
2220
2280
|
{
|
|
2221
2281
|
className: `Layer__nowrap ${classNamePrefix}__match-table__date`
|
|
2222
2282
|
},
|
|
2223
|
-
/* @__PURE__ */
|
|
2224
|
-
/* @__PURE__ */
|
|
2283
|
+
/* @__PURE__ */ import_react28.default.createElement("span", null, (0, import_date_fns6.format)((0, import_date_fns6.parseISO)(match.details.date), DATE_FORMAT)),
|
|
2284
|
+
/* @__PURE__ */ import_react28.default.createElement("span", { className: "amount-next-to-date" }, "$", centsToDollars(match.details.amount))
|
|
2225
2285
|
),
|
|
2226
|
-
/* @__PURE__ */
|
|
2286
|
+
/* @__PURE__ */ import_react28.default.createElement("div", { className: `${classNamePrefix}__match-table__desc` }, /* @__PURE__ */ import_react28.default.createElement(
|
|
2227
2287
|
Text,
|
|
2228
2288
|
{
|
|
2229
2289
|
className: `${classNamePrefix}__match-table__desc-tooltip`,
|
|
@@ -2231,7 +2291,7 @@ var MatchForm = ({
|
|
|
2231
2291
|
as: "span"
|
|
2232
2292
|
},
|
|
2233
2293
|
match.details.description
|
|
2234
|
-
), match.details.id === bankTransaction.match?.details.id && /* @__PURE__ */
|
|
2294
|
+
), match.details.id === bankTransaction.match?.details.id && /* @__PURE__ */ import_react28.default.createElement("span", { className: "match-badge" }, /* @__PURE__ */ import_react28.default.createElement(
|
|
2235
2295
|
MatchBadge,
|
|
2236
2296
|
{
|
|
2237
2297
|
classNamePrefix,
|
|
@@ -2240,13 +2300,13 @@ var MatchForm = ({
|
|
|
2240
2300
|
text: "Matched"
|
|
2241
2301
|
}
|
|
2242
2302
|
))),
|
|
2243
|
-
/* @__PURE__ */
|
|
2244
|
-
/* @__PURE__ */
|
|
2303
|
+
/* @__PURE__ */ import_react28.default.createElement("div", { className: `${classNamePrefix}__match-table__amount` }, "$", centsToDollars(match.details.amount)),
|
|
2304
|
+
/* @__PURE__ */ import_react28.default.createElement(
|
|
2245
2305
|
"div",
|
|
2246
2306
|
{
|
|
2247
2307
|
className: `${classNamePrefix}__match-table__status ${bankTransaction.match ? "" : "no-match"}`
|
|
2248
2308
|
},
|
|
2249
|
-
match.details.id === bankTransaction.match?.details.id && /* @__PURE__ */
|
|
2309
|
+
match.details.id === bankTransaction.match?.details.id && /* @__PURE__ */ import_react28.default.createElement(
|
|
2250
2310
|
MatchBadge,
|
|
2251
2311
|
{
|
|
2252
2312
|
classNamePrefix,
|
|
@@ -2257,22 +2317,22 @@ var MatchForm = ({
|
|
|
2257
2317
|
)
|
|
2258
2318
|
)
|
|
2259
2319
|
);
|
|
2260
|
-
}), matchFormError && /* @__PURE__ */
|
|
2320
|
+
}), matchFormError && /* @__PURE__ */ import_react28.default.createElement(ErrorText, null, matchFormError));
|
|
2261
2321
|
};
|
|
2262
2322
|
|
|
2263
2323
|
// src/components/Textarea/Textarea.tsx
|
|
2264
|
-
var
|
|
2324
|
+
var import_react29 = __toESM(require("react"));
|
|
2265
2325
|
var import_classnames14 = __toESM(require("classnames"));
|
|
2266
2326
|
var Textarea = ({
|
|
2267
2327
|
className,
|
|
2268
2328
|
...props
|
|
2269
2329
|
}) => {
|
|
2270
2330
|
const baseClassName = (0, import_classnames14.default)("Layer__textarea", className);
|
|
2271
|
-
return /* @__PURE__ */
|
|
2331
|
+
return /* @__PURE__ */ import_react29.default.createElement("textarea", { ...props, className: baseClassName });
|
|
2272
2332
|
};
|
|
2273
2333
|
|
|
2274
2334
|
// src/components/Toggle/Toggle.tsx
|
|
2275
|
-
var
|
|
2335
|
+
var import_react30 = __toESM(require("react"));
|
|
2276
2336
|
var import_classnames15 = __toESM(require("classnames"));
|
|
2277
2337
|
var Toggle = ({
|
|
2278
2338
|
name,
|
|
@@ -2281,9 +2341,9 @@ var Toggle = ({
|
|
|
2281
2341
|
onChange,
|
|
2282
2342
|
size = "medium" /* medium */
|
|
2283
2343
|
}) => {
|
|
2284
|
-
const [currentWidth, setCurrentWidth] = (0,
|
|
2285
|
-
const [thumbPos, setThumbPos] = (0,
|
|
2286
|
-
const [initialized, setInitialized] = (0,
|
|
2344
|
+
const [currentWidth, setCurrentWidth] = (0, import_react30.useState)(0);
|
|
2345
|
+
const [thumbPos, setThumbPos] = (0, import_react30.useState)({ left: 0, width: 0 });
|
|
2346
|
+
const [initialized, setInitialized] = (0, import_react30.useState)(false);
|
|
2287
2347
|
const toggleRef = useElementSize((a, b, c) => {
|
|
2288
2348
|
if (c.width && c?.width !== currentWidth) {
|
|
2289
2349
|
setCurrentWidth(c.width);
|
|
@@ -2318,14 +2378,14 @@ var Toggle = ({
|
|
|
2318
2378
|
shift2 = shift2 + (size === "medium" /* medium */ ? 2 : 1.5);
|
|
2319
2379
|
setThumbPos({ left: shift2, width });
|
|
2320
2380
|
};
|
|
2321
|
-
(0,
|
|
2381
|
+
(0, import_react30.useEffect)(() => {
|
|
2322
2382
|
const selectedIndex = getSelectedIndex();
|
|
2323
2383
|
updateThumbPosition(selectedIndex);
|
|
2324
2384
|
setTimeout(() => {
|
|
2325
2385
|
setInitialized(true);
|
|
2326
2386
|
}, 400);
|
|
2327
2387
|
}, []);
|
|
2328
|
-
(0,
|
|
2388
|
+
(0, import_react30.useEffect)(() => {
|
|
2329
2389
|
const selectedIndex = getSelectedIndex();
|
|
2330
2390
|
updateThumbPosition(selectedIndex);
|
|
2331
2391
|
}, [currentWidth]);
|
|
@@ -2338,7 +2398,7 @@ var Toggle = ({
|
|
|
2338
2398
|
}
|
|
2339
2399
|
return selectedIndex;
|
|
2340
2400
|
};
|
|
2341
|
-
return /* @__PURE__ */
|
|
2401
|
+
return /* @__PURE__ */ import_react30.default.createElement("div", { className: baseClassName, ref: toggleRef }, options.map((option, index) => /* @__PURE__ */ import_react30.default.createElement(
|
|
2342
2402
|
ToggleOption,
|
|
2343
2403
|
{
|
|
2344
2404
|
...option,
|
|
@@ -2350,7 +2410,7 @@ var Toggle = ({
|
|
|
2350
2410
|
disabled: option.disabled ?? false,
|
|
2351
2411
|
index
|
|
2352
2412
|
}
|
|
2353
|
-
)), /* @__PURE__ */
|
|
2413
|
+
)), /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__toggle__thumb", style: { ...thumbPos } }));
|
|
2354
2414
|
};
|
|
2355
2415
|
var ToggleOption = ({
|
|
2356
2416
|
checked,
|
|
@@ -2364,7 +2424,7 @@ var ToggleOption = ({
|
|
|
2364
2424
|
index
|
|
2365
2425
|
}) => {
|
|
2366
2426
|
if (disabled) {
|
|
2367
|
-
return /* @__PURE__ */
|
|
2427
|
+
return /* @__PURE__ */ import_react30.default.createElement(Tooltip, null, /* @__PURE__ */ import_react30.default.createElement(TooltipTrigger, null, /* @__PURE__ */ import_react30.default.createElement("label", { className: `Layer__toggle-option`, "data-checked": checked }, /* @__PURE__ */ import_react30.default.createElement(
|
|
2368
2428
|
"input",
|
|
2369
2429
|
{
|
|
2370
2430
|
type: "radio",
|
|
@@ -2375,9 +2435,9 @@ var ToggleOption = ({
|
|
|
2375
2435
|
disabled: disabled ?? false,
|
|
2376
2436
|
"data-idx": index
|
|
2377
2437
|
}
|
|
2378
|
-
), /* @__PURE__ */
|
|
2438
|
+
), /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__toggle-option-content" }, leftIcon && /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__toggle-option__icon" }, leftIcon), /* @__PURE__ */ import_react30.default.createElement("span", null, label)))), /* @__PURE__ */ import_react30.default.createElement(TooltipContent, { className: "Layer__tooltip" }, "We could not find matching transactions"));
|
|
2379
2439
|
}
|
|
2380
|
-
return /* @__PURE__ */
|
|
2440
|
+
return /* @__PURE__ */ import_react30.default.createElement("label", { className: `Layer__toggle-option`, "data-checked": checked }, /* @__PURE__ */ import_react30.default.createElement(
|
|
2381
2441
|
"input",
|
|
2382
2442
|
{
|
|
2383
2443
|
type: "radio",
|
|
@@ -2388,15 +2448,15 @@ var ToggleOption = ({
|
|
|
2388
2448
|
disabled: disabled ?? false,
|
|
2389
2449
|
"data-idx": index
|
|
2390
2450
|
}
|
|
2391
|
-
), /* @__PURE__ */
|
|
2451
|
+
), /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__toggle-option-content" }, leftIcon && /* @__PURE__ */ import_react30.default.createElement("span", { className: "Layer__toggle-option__icon" }, leftIcon), /* @__PURE__ */ import_react30.default.createElement("span", null, label)));
|
|
2392
2452
|
};
|
|
2393
2453
|
|
|
2394
2454
|
// src/components/ExpandedBankTransactionRow/APIErrorNotifications.tsx
|
|
2395
|
-
var
|
|
2455
|
+
var import_react31 = __toESM(require("react"));
|
|
2396
2456
|
|
|
2397
2457
|
// src/icons/AlertOctagon.tsx
|
|
2398
|
-
var
|
|
2399
|
-
var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
2458
|
+
var React41 = __toESM(require("react"));
|
|
2459
|
+
var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React41.createElement(
|
|
2400
2460
|
"svg",
|
|
2401
2461
|
{
|
|
2402
2462
|
viewBox: "0 0 18 18",
|
|
@@ -2406,7 +2466,7 @@ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React40.createEl
|
|
|
2406
2466
|
width: size,
|
|
2407
2467
|
height: size
|
|
2408
2468
|
},
|
|
2409
|
-
/* @__PURE__ */
|
|
2469
|
+
/* @__PURE__ */ React41.createElement(
|
|
2410
2470
|
"path",
|
|
2411
2471
|
{
|
|
2412
2472
|
d: "M5.895 1.5H12.105L16.5 5.895V12.105L12.105 16.5H5.895L1.5 12.105V5.895L5.895 1.5Z",
|
|
@@ -2415,7 +2475,7 @@ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React40.createEl
|
|
|
2415
2475
|
strokeLinejoin: "round"
|
|
2416
2476
|
}
|
|
2417
2477
|
),
|
|
2418
|
-
/* @__PURE__ */
|
|
2478
|
+
/* @__PURE__ */ React41.createElement(
|
|
2419
2479
|
"path",
|
|
2420
2480
|
{
|
|
2421
2481
|
d: "M9 6V9",
|
|
@@ -2424,7 +2484,7 @@ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React40.createEl
|
|
|
2424
2484
|
strokeLinejoin: "round"
|
|
2425
2485
|
}
|
|
2426
2486
|
),
|
|
2427
|
-
/* @__PURE__ */
|
|
2487
|
+
/* @__PURE__ */ React41.createElement(
|
|
2428
2488
|
"path",
|
|
2429
2489
|
{
|
|
2430
2490
|
d: "M9 12H9.0075",
|
|
@@ -2446,7 +2506,7 @@ var APIErrorNotifications = ({
|
|
|
2446
2506
|
bankTransaction,
|
|
2447
2507
|
containerWidth
|
|
2448
2508
|
}) => {
|
|
2449
|
-
const [notifications, setNotifications] = (0,
|
|
2509
|
+
const [notifications, setNotifications] = (0, import_react31.useState)([]);
|
|
2450
2510
|
const pushNotification = (title, message) => {
|
|
2451
2511
|
const timestamp = (/* @__PURE__ */ new Date()).valueOf();
|
|
2452
2512
|
if (notificationsCache.find(
|
|
@@ -2475,18 +2535,18 @@ var APIErrorNotifications = ({
|
|
|
2475
2535
|
);
|
|
2476
2536
|
setNotifications(notificationsCache.concat());
|
|
2477
2537
|
};
|
|
2478
|
-
(0,
|
|
2538
|
+
(0, import_react31.useEffect)(() => {
|
|
2479
2539
|
if (bankTransaction.error) {
|
|
2480
2540
|
pushNotification(ERROR_TITLE, ERROR_MESSAGE);
|
|
2481
2541
|
}
|
|
2482
2542
|
}, [bankTransaction.error]);
|
|
2483
|
-
return /* @__PURE__ */
|
|
2543
|
+
return /* @__PURE__ */ import_react31.default.createElement(
|
|
2484
2544
|
"div",
|
|
2485
2545
|
{
|
|
2486
2546
|
className: "Layer__bank-transactions__notifications",
|
|
2487
2547
|
style: containerWidth ? { left: containerWidth - 324 } : {}
|
|
2488
2548
|
},
|
|
2489
|
-
notifications.filter((n) => n.bankTransactionId === bankTransaction.id).map((notification) => /* @__PURE__ */
|
|
2549
|
+
notifications.filter((n) => n.bankTransactionId === bankTransaction.id).map((notification) => /* @__PURE__ */ import_react31.default.createElement(
|
|
2490
2550
|
Notification,
|
|
2491
2551
|
{
|
|
2492
2552
|
key: notification.timestamp,
|
|
@@ -2500,8 +2560,8 @@ var Notification = ({
|
|
|
2500
2560
|
notification,
|
|
2501
2561
|
deleteNotification
|
|
2502
2562
|
}) => {
|
|
2503
|
-
const [visible, setVisible] = (0,
|
|
2504
|
-
(0,
|
|
2563
|
+
const [visible, setVisible] = (0, import_react31.useState)(false);
|
|
2564
|
+
(0, import_react31.useEffect)(() => {
|
|
2505
2565
|
setVisible(true);
|
|
2506
2566
|
const timer = setTimeout(() => {
|
|
2507
2567
|
hideNotification();
|
|
@@ -2514,20 +2574,20 @@ var Notification = ({
|
|
|
2514
2574
|
deleteNotification(notification.timestamp);
|
|
2515
2575
|
}, FADE_OUT_TIME_WAIT);
|
|
2516
2576
|
};
|
|
2517
|
-
return /* @__PURE__ */
|
|
2577
|
+
return /* @__PURE__ */ import_react31.default.createElement(
|
|
2518
2578
|
"div",
|
|
2519
2579
|
{
|
|
2520
2580
|
className: `Layer__bank-transactions__notification ${visible ? "notification-enter" : "notification-exit"}`,
|
|
2521
2581
|
onClick: hideNotification
|
|
2522
2582
|
},
|
|
2523
|
-
/* @__PURE__ */
|
|
2583
|
+
/* @__PURE__ */ import_react31.default.createElement("div", { className: "Layer__bank-transactions__notification-content" }, /* @__PURE__ */ import_react31.default.createElement("div", { className: "Layer__bank-transactions__notification-icon" }, /* @__PURE__ */ import_react31.default.createElement(AlertOctagon_default, { size: 14 })), /* @__PURE__ */ import_react31.default.createElement("div", { className: "Layer__bank-transactions__notification-text" }, /* @__PURE__ */ import_react31.default.createElement(
|
|
2524
2584
|
Text,
|
|
2525
2585
|
{
|
|
2526
2586
|
as: "span",
|
|
2527
2587
|
className: "Layer__bank-transactions__notification-title"
|
|
2528
2588
|
},
|
|
2529
2589
|
notification.title
|
|
2530
|
-
), /* @__PURE__ */
|
|
2590
|
+
), /* @__PURE__ */ import_react31.default.createElement(
|
|
2531
2591
|
Text,
|
|
2532
2592
|
{
|
|
2533
2593
|
as: "span",
|
|
@@ -2565,7 +2625,7 @@ var validateSplit = (splitData) => {
|
|
|
2565
2625
|
});
|
|
2566
2626
|
return valid;
|
|
2567
2627
|
};
|
|
2568
|
-
var ExpandedBankTransactionRow = (0,
|
|
2628
|
+
var ExpandedBankTransactionRow = (0, import_react32.forwardRef)(
|
|
2569
2629
|
({
|
|
2570
2630
|
bankTransaction,
|
|
2571
2631
|
isOpen = false,
|
|
@@ -2578,20 +2638,20 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2578
2638
|
categorize: categorizeBankTransaction2,
|
|
2579
2639
|
match: matchBankTransaction2
|
|
2580
2640
|
} = useBankTransactions();
|
|
2581
|
-
const [purpose, setPurpose] = (0,
|
|
2641
|
+
const [purpose, setPurpose] = (0, import_react32.useState)(
|
|
2582
2642
|
bankTransaction.category ? "categorize" /* categorize */ : hasMatch(bankTransaction) ? "match" /* match */ : "categorize" /* categorize */
|
|
2583
2643
|
);
|
|
2584
|
-
const [selectedMatchId, setSelectedMatchId] = (0,
|
|
2644
|
+
const [selectedMatchId, setSelectedMatchId] = (0, import_react32.useState)(
|
|
2585
2645
|
isAlreadyMatched(bankTransaction)
|
|
2586
2646
|
);
|
|
2587
|
-
const [matchFormError, setMatchFormError] = (0,
|
|
2588
|
-
const [splitFormError, setSplitFormError] = (0,
|
|
2589
|
-
const [height, setHeight] = (0,
|
|
2590
|
-
const [isOver, setOver] = (0,
|
|
2591
|
-
const bodyRef = (0,
|
|
2592
|
-
const [isLoaded, setIsLoaded] = (0,
|
|
2647
|
+
const [matchFormError, setMatchFormError] = (0, import_react32.useState)();
|
|
2648
|
+
const [splitFormError, setSplitFormError] = (0, import_react32.useState)();
|
|
2649
|
+
const [height, setHeight] = (0, import_react32.useState)(0);
|
|
2650
|
+
const [isOver, setOver] = (0, import_react32.useState)(false);
|
|
2651
|
+
const bodyRef = (0, import_react32.useRef)(null);
|
|
2652
|
+
const [isLoaded, setIsLoaded] = (0, import_react32.useState)(false);
|
|
2593
2653
|
const defaultCategory = bankTransaction.category || hasSuggestions(bankTransaction.categorization_flow) && bankTransaction.categorization_flow?.suggestions?.[0];
|
|
2594
|
-
const [rowState, updateRowState] = (0,
|
|
2654
|
+
const [rowState, updateRowState] = (0, import_react32.useState)({
|
|
2595
2655
|
splits: bankTransaction.category?.entries ? bankTransaction.category?.entries.map((c) => {
|
|
2596
2656
|
return {
|
|
2597
2657
|
amount: c.amount || 0,
|
|
@@ -2704,7 +2764,7 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2704
2764
|
}
|
|
2705
2765
|
);
|
|
2706
2766
|
};
|
|
2707
|
-
(0,
|
|
2767
|
+
(0, import_react32.useImperativeHandle)(ref, () => ({
|
|
2708
2768
|
save
|
|
2709
2769
|
}));
|
|
2710
2770
|
const onMatchSubmit = (matchId) => {
|
|
@@ -2716,11 +2776,11 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2716
2776
|
}
|
|
2717
2777
|
matchBankTransaction2(bankTransaction.id, foundMatch.id);
|
|
2718
2778
|
};
|
|
2719
|
-
const getDivHeight = (0,
|
|
2779
|
+
const getDivHeight = (0, import_react32.useCallback)(() => {
|
|
2720
2780
|
const { height: height2 } = bodyRef.current ? bodyRef.current.getBoundingClientRect() : { height: void 0 };
|
|
2721
2781
|
return height2 || 0;
|
|
2722
2782
|
}, []);
|
|
2723
|
-
const handleTransitionEnd = (0,
|
|
2783
|
+
const handleTransitionEnd = (0, import_react32.useCallback)(
|
|
2724
2784
|
(e) => {
|
|
2725
2785
|
if (e.propertyName === "height") {
|
|
2726
2786
|
setHeight(isOpen ? "auto" : 0);
|
|
@@ -2731,7 +2791,7 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2731
2791
|
},
|
|
2732
2792
|
[isOpen]
|
|
2733
2793
|
);
|
|
2734
|
-
(0,
|
|
2794
|
+
(0, import_react32.useEffect)(() => {
|
|
2735
2795
|
if (!isLoaded) {
|
|
2736
2796
|
return;
|
|
2737
2797
|
}
|
|
@@ -2743,20 +2803,20 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2743
2803
|
});
|
|
2744
2804
|
}
|
|
2745
2805
|
}, [getDivHeight, isOpen]);
|
|
2746
|
-
(0,
|
|
2806
|
+
(0, import_react32.useEffect)(() => {
|
|
2747
2807
|
setIsLoaded(true);
|
|
2748
2808
|
setOver(true);
|
|
2749
2809
|
}, []);
|
|
2750
2810
|
const className = "Layer__expanded-bank-transaction-row";
|
|
2751
2811
|
const shouldHide = !isOpen && isOver;
|
|
2752
|
-
return /* @__PURE__ */
|
|
2812
|
+
return /* @__PURE__ */ import_react32.default.createElement(
|
|
2753
2813
|
"span",
|
|
2754
2814
|
{
|
|
2755
2815
|
className: `${className} ${className}--${isOpen ? "expanded" : "collapsed"}`,
|
|
2756
2816
|
style: { height },
|
|
2757
2817
|
onTransitionEnd: handleTransitionEnd
|
|
2758
2818
|
},
|
|
2759
|
-
shouldHide ? null : /* @__PURE__ */
|
|
2819
|
+
shouldHide ? null : /* @__PURE__ */ import_react32.default.createElement("span", { className: `${className}__wrapper`, ref: bodyRef }, /* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__content-toggle` }, /* @__PURE__ */ import_react32.default.createElement(
|
|
2760
2820
|
Toggle,
|
|
2761
2821
|
{
|
|
2762
2822
|
name: `purpose-${bankTransaction.id}${asListItem ? "-li" : ""}`,
|
|
@@ -2775,13 +2835,13 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2775
2835
|
selected: purpose,
|
|
2776
2836
|
onChange: onChangePurpose
|
|
2777
2837
|
}
|
|
2778
|
-
)), /* @__PURE__ */
|
|
2838
|
+
)), /* @__PURE__ */ import_react32.default.createElement(
|
|
2779
2839
|
"div",
|
|
2780
2840
|
{
|
|
2781
2841
|
className: `${className}__content`,
|
|
2782
2842
|
id: `expanded-${bankTransaction.id}`
|
|
2783
2843
|
},
|
|
2784
|
-
/* @__PURE__ */
|
|
2844
|
+
/* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__content-panels` }, /* @__PURE__ */ import_react32.default.createElement(
|
|
2785
2845
|
"div",
|
|
2786
2846
|
{
|
|
2787
2847
|
className: (0, import_classnames16.default)(
|
|
@@ -2790,7 +2850,7 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2790
2850
|
purpose === "match" /* match */ ? `${className}__content-panel--active` : ""
|
|
2791
2851
|
)
|
|
2792
2852
|
},
|
|
2793
|
-
/* @__PURE__ */
|
|
2853
|
+
/* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__content-panel-container` }, /* @__PURE__ */ import_react32.default.createElement(
|
|
2794
2854
|
MatchForm,
|
|
2795
2855
|
{
|
|
2796
2856
|
classNamePrefix: className,
|
|
@@ -2803,7 +2863,7 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2803
2863
|
matchFormError
|
|
2804
2864
|
}
|
|
2805
2865
|
))
|
|
2806
|
-
), /* @__PURE__ */
|
|
2866
|
+
), /* @__PURE__ */ import_react32.default.createElement(
|
|
2807
2867
|
"div",
|
|
2808
2868
|
{
|
|
2809
2869
|
className: (0, import_classnames16.default)(
|
|
@@ -2812,13 +2872,13 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2812
2872
|
purpose === "categorize" /* categorize */ ? `${className}__content-panel--active` : ""
|
|
2813
2873
|
)
|
|
2814
2874
|
},
|
|
2815
|
-
/* @__PURE__ */
|
|
2875
|
+
/* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__content-panel-container` }, /* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__splits-inputs` }, rowState.splits.map((split, index) => /* @__PURE__ */ import_react32.default.createElement(
|
|
2816
2876
|
"div",
|
|
2817
2877
|
{
|
|
2818
2878
|
className: `${className}__table-cell--split-entry`,
|
|
2819
2879
|
key: `split-${index}`
|
|
2820
2880
|
},
|
|
2821
|
-
/* @__PURE__ */
|
|
2881
|
+
/* @__PURE__ */ import_react32.default.createElement(
|
|
2822
2882
|
Input,
|
|
2823
2883
|
{
|
|
2824
2884
|
type: "text",
|
|
@@ -2831,12 +2891,12 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2831
2891
|
errorMessage: "Negative values are not allowed"
|
|
2832
2892
|
}
|
|
2833
2893
|
),
|
|
2834
|
-
/* @__PURE__ */
|
|
2894
|
+
/* @__PURE__ */ import_react32.default.createElement(
|
|
2835
2895
|
"div",
|
|
2836
2896
|
{
|
|
2837
2897
|
className: `${className}__table-cell--split-entry__right-col`
|
|
2838
2898
|
},
|
|
2839
|
-
/* @__PURE__ */
|
|
2899
|
+
/* @__PURE__ */ import_react32.default.createElement(
|
|
2840
2900
|
CategoryMenu,
|
|
2841
2901
|
{
|
|
2842
2902
|
bankTransaction,
|
|
@@ -2846,18 +2906,18 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2846
2906
|
className: "Layer__category-menu--full"
|
|
2847
2907
|
}
|
|
2848
2908
|
),
|
|
2849
|
-
index > 0 && /* @__PURE__ */
|
|
2909
|
+
index > 0 && /* @__PURE__ */ import_react32.default.createElement(
|
|
2850
2910
|
Button,
|
|
2851
2911
|
{
|
|
2852
2912
|
className: `${className}__table-cell--split-entry__merge-btn`,
|
|
2853
2913
|
onClick: () => removeSplit(index),
|
|
2854
|
-
rightIcon: /* @__PURE__ */
|
|
2914
|
+
rightIcon: /* @__PURE__ */ import_react32.default.createElement(Trash_default, { size: 18 }),
|
|
2855
2915
|
variant: "secondary" /* secondary */,
|
|
2856
2916
|
iconOnly: true
|
|
2857
2917
|
}
|
|
2858
2918
|
)
|
|
2859
2919
|
)
|
|
2860
|
-
))), splitFormError && /* @__PURE__ */
|
|
2920
|
+
))), splitFormError && /* @__PURE__ */ import_react32.default.createElement(ErrorText, null, splitFormError), /* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__total-and-btns` }, rowState.splits.length > 1 && /* @__PURE__ */ import_react32.default.createElement(
|
|
2861
2921
|
Input,
|
|
2862
2922
|
{
|
|
2863
2923
|
disabled: true,
|
|
@@ -2869,43 +2929,43 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2869
2929
|
)
|
|
2870
2930
|
)}`
|
|
2871
2931
|
}
|
|
2872
|
-
), /* @__PURE__ */
|
|
2932
|
+
), /* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__splits-buttons` }, rowState.splits.length > 1 ? /* @__PURE__ */ import_react32.default.createElement(
|
|
2873
2933
|
TextButton,
|
|
2874
2934
|
{
|
|
2875
2935
|
onClick: addSplit,
|
|
2876
2936
|
disabled: rowState.splits.length > 5
|
|
2877
2937
|
},
|
|
2878
2938
|
"Add new split"
|
|
2879
|
-
) : /* @__PURE__ */
|
|
2939
|
+
) : /* @__PURE__ */ import_react32.default.createElement(
|
|
2880
2940
|
Button,
|
|
2881
2941
|
{
|
|
2882
2942
|
onClick: addSplit,
|
|
2883
|
-
rightIcon: /* @__PURE__ */
|
|
2943
|
+
rightIcon: /* @__PURE__ */ import_react32.default.createElement(ScissorsFullOpen_default, { size: 14 }),
|
|
2884
2944
|
variant: "secondary" /* secondary */,
|
|
2885
2945
|
disabled: rowState.splits.length > 5
|
|
2886
2946
|
},
|
|
2887
2947
|
"Split"
|
|
2888
2948
|
))))
|
|
2889
2949
|
)),
|
|
2890
|
-
/* @__PURE__ */
|
|
2950
|
+
/* @__PURE__ */ import_react32.default.createElement(
|
|
2891
2951
|
InputGroup,
|
|
2892
2952
|
{
|
|
2893
2953
|
className: `${className}__description`,
|
|
2894
2954
|
name: "description"
|
|
2895
2955
|
},
|
|
2896
|
-
/* @__PURE__ */
|
|
2956
|
+
/* @__PURE__ */ import_react32.default.createElement(Textarea, { name: "description", placeholder: "Add description" })
|
|
2897
2957
|
),
|
|
2898
|
-
/* @__PURE__ */
|
|
2899
|
-
asListItem ? /* @__PURE__ */
|
|
2958
|
+
/* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__file-upload` }, /* @__PURE__ */ import_react32.default.createElement(FileInput, { text: "Upload receipt" })),
|
|
2959
|
+
asListItem ? /* @__PURE__ */ import_react32.default.createElement("div", { className: `${className}__submit-btn` }, bankTransaction.error ? /* @__PURE__ */ import_react32.default.createElement(
|
|
2900
2960
|
Text,
|
|
2901
2961
|
{
|
|
2902
2962
|
as: "span",
|
|
2903
2963
|
size: "md" /* md */,
|
|
2904
2964
|
className: "Layer__unsaved-info"
|
|
2905
2965
|
},
|
|
2906
|
-
/* @__PURE__ */
|
|
2907
|
-
/* @__PURE__ */
|
|
2908
|
-
) : null, /* @__PURE__ */
|
|
2966
|
+
/* @__PURE__ */ import_react32.default.createElement("span", null, "Unsaved"),
|
|
2967
|
+
/* @__PURE__ */ import_react32.default.createElement(AlertCircle_default, { size: 12 })
|
|
2968
|
+
) : null, /* @__PURE__ */ import_react32.default.createElement(
|
|
2909
2969
|
SubmitButton,
|
|
2910
2970
|
{
|
|
2911
2971
|
onClick: () => {
|
|
@@ -2920,7 +2980,7 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2920
2980
|
},
|
|
2921
2981
|
submitBtnText
|
|
2922
2982
|
)) : null
|
|
2923
|
-
), /* @__PURE__ */
|
|
2983
|
+
), /* @__PURE__ */ import_react32.default.createElement(
|
|
2924
2984
|
APIErrorNotifications,
|
|
2925
2985
|
{
|
|
2926
2986
|
bankTransaction,
|
|
@@ -2932,7 +2992,7 @@ var ExpandedBankTransactionRow = (0, import_react31.forwardRef)(
|
|
|
2932
2992
|
);
|
|
2933
2993
|
|
|
2934
2994
|
// src/components/BankTransactionRow/SplitTooltipDetails.tsx
|
|
2935
|
-
var
|
|
2995
|
+
var import_react33 = __toESM(require("react"));
|
|
2936
2996
|
var SplitTooltipDetails = ({
|
|
2937
2997
|
classNamePrefix,
|
|
2938
2998
|
category
|
|
@@ -2940,7 +3000,7 @@ var SplitTooltipDetails = ({
|
|
|
2940
3000
|
if (!category.entries) {
|
|
2941
3001
|
return;
|
|
2942
3002
|
}
|
|
2943
|
-
return /* @__PURE__ */
|
|
3003
|
+
return /* @__PURE__ */ import_react33.default.createElement("span", { className: `${classNamePrefix}__split-tooltip` }, /* @__PURE__ */ import_react33.default.createElement("ul", null, category.entries.map((entry, idx) => /* @__PURE__ */ import_react33.default.createElement("li", { key: idx }, /* @__PURE__ */ import_react33.default.createElement("span", { className: `${classNamePrefix}__split-tooltip__label` }, entry.category.display_name), /* @__PURE__ */ import_react33.default.createElement("span", { className: `${classNamePrefix}__split-tooltip__value` }, "$", centsToDollars(entry.amount))))));
|
|
2944
3004
|
};
|
|
2945
3005
|
|
|
2946
3006
|
// src/components/BankTransactionRow/BankTransactionRow.tsx
|
|
@@ -2965,14 +3025,14 @@ var BankTransactionRow = ({
|
|
|
2965
3025
|
removeTransaction,
|
|
2966
3026
|
containerWidth
|
|
2967
3027
|
}) => {
|
|
2968
|
-
const expandedRowRef = (0,
|
|
2969
|
-
const [showRetry, setShowRetry] = (0,
|
|
2970
|
-
const [removed, setRemoved] = (0,
|
|
3028
|
+
const expandedRowRef = (0, import_react34.useRef)(null);
|
|
3029
|
+
const [showRetry, setShowRetry] = (0, import_react34.useState)(false);
|
|
3030
|
+
const [removed, setRemoved] = (0, import_react34.useState)(false);
|
|
2971
3031
|
const { categorize: categorizeBankTransaction2, match: matchBankTransaction2 } = useBankTransactions();
|
|
2972
|
-
const [selectedCategory, setSelectedCategory] = (0,
|
|
3032
|
+
const [selectedCategory, setSelectedCategory] = (0, import_react34.useState)(
|
|
2973
3033
|
getDefaultSelectedCategory(bankTransaction)
|
|
2974
3034
|
);
|
|
2975
|
-
const [open, setOpen] = (0,
|
|
3035
|
+
const [open, setOpen] = (0, import_react34.useState)(false);
|
|
2976
3036
|
const toggleOpen = () => {
|
|
2977
3037
|
setShowRetry(false);
|
|
2978
3038
|
setOpen(!open);
|
|
@@ -2988,14 +3048,14 @@ var BankTransactionRow = ({
|
|
|
2988
3048
|
}
|
|
2989
3049
|
}
|
|
2990
3050
|
};
|
|
2991
|
-
const [showComponent, setShowComponent] = (0,
|
|
2992
|
-
(0,
|
|
3051
|
+
const [showComponent, setShowComponent] = (0, import_react34.useState)(false);
|
|
3052
|
+
(0, import_react34.useEffect)(() => {
|
|
2993
3053
|
const timeoutId = setTimeout(() => {
|
|
2994
3054
|
setShowComponent(true);
|
|
2995
3055
|
}, index * 80);
|
|
2996
3056
|
return () => clearTimeout(timeoutId);
|
|
2997
3057
|
}, []);
|
|
2998
|
-
(0,
|
|
3058
|
+
(0, import_react34.useEffect)(() => {
|
|
2999
3059
|
if (bankTransaction.error) {
|
|
3000
3060
|
setShowRetry(true);
|
|
3001
3061
|
}
|
|
@@ -3031,7 +3091,7 @@ var BankTransactionRow = ({
|
|
|
3031
3091
|
open ? openClassName : "",
|
|
3032
3092
|
showComponent ? "show" : ""
|
|
3033
3093
|
);
|
|
3034
|
-
return /* @__PURE__ */
|
|
3094
|
+
return /* @__PURE__ */ import_react34.default.createElement(import_react34.default.Fragment, null, /* @__PURE__ */ import_react34.default.createElement(
|
|
3035
3095
|
"tr",
|
|
3036
3096
|
{
|
|
3037
3097
|
className: rowClassName,
|
|
@@ -3042,21 +3102,21 @@ var BankTransactionRow = ({
|
|
|
3042
3102
|
}
|
|
3043
3103
|
}
|
|
3044
3104
|
},
|
|
3045
|
-
/* @__PURE__ */
|
|
3105
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
3046
3106
|
"td",
|
|
3047
3107
|
{
|
|
3048
3108
|
className: "Layer__table-cell Layer__bank-transaction-table__date-col",
|
|
3049
3109
|
...openRow
|
|
3050
3110
|
},
|
|
3051
|
-
/* @__PURE__ */
|
|
3111
|
+
/* @__PURE__ */ import_react34.default.createElement("span", { className: "Layer__table-cell-content" }, (0, import_date_fns7.format)((0, import_date_fns7.parseISO)(bankTransaction.date), dateFormat))
|
|
3052
3112
|
),
|
|
3053
|
-
/* @__PURE__ */
|
|
3113
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
3054
3114
|
"td",
|
|
3055
3115
|
{
|
|
3056
3116
|
className: "Layer__table-cell Layer__bank-transactions__tx-col",
|
|
3057
3117
|
...openRow
|
|
3058
3118
|
},
|
|
3059
|
-
/* @__PURE__ */
|
|
3119
|
+
/* @__PURE__ */ import_react34.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react34.default.createElement(
|
|
3060
3120
|
Text,
|
|
3061
3121
|
{
|
|
3062
3122
|
as: "span",
|
|
@@ -3069,13 +3129,13 @@ var BankTransactionRow = ({
|
|
|
3069
3129
|
bankTransaction.counterparty_name ?? bankTransaction.description
|
|
3070
3130
|
))
|
|
3071
3131
|
),
|
|
3072
|
-
/* @__PURE__ */
|
|
3132
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
3073
3133
|
"td",
|
|
3074
3134
|
{
|
|
3075
3135
|
className: "Layer__table-cell Layer__bank-transactions__account-col",
|
|
3076
3136
|
...openRow
|
|
3077
3137
|
},
|
|
3078
|
-
/* @__PURE__ */
|
|
3138
|
+
/* @__PURE__ */ import_react34.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react34.default.createElement(
|
|
3079
3139
|
Text,
|
|
3080
3140
|
{
|
|
3081
3141
|
as: "span",
|
|
@@ -3085,15 +3145,15 @@ var BankTransactionRow = ({
|
|
|
3085
3145
|
bankTransaction.account_name ?? ""
|
|
3086
3146
|
))
|
|
3087
3147
|
),
|
|
3088
|
-
/* @__PURE__ */
|
|
3148
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
3089
3149
|
"td",
|
|
3090
3150
|
{
|
|
3091
3151
|
className: `Layer__table-cell Layer__table-cell__amount-col Layer__bank-transactions__amount-col Layer__table-cell--amount ${className}__table-cell--amount-${isCredit(bankTransaction) ? "credit" : "debit"}`,
|
|
3092
3152
|
...openRow
|
|
3093
3153
|
},
|
|
3094
|
-
/* @__PURE__ */
|
|
3154
|
+
/* @__PURE__ */ import_react34.default.createElement("span", { className: "Layer__table-cell-content" }, isCredit(bankTransaction) ? "+$" : " $", centsToDollars(bankTransaction.amount))
|
|
3095
3155
|
),
|
|
3096
|
-
/* @__PURE__ */
|
|
3156
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
3097
3157
|
"td",
|
|
3098
3158
|
{
|
|
3099
3159
|
className: (0, import_classnames17.default)(
|
|
@@ -3103,12 +3163,12 @@ var BankTransactionRow = ({
|
|
|
3103
3163
|
`${className}__actions-cell--${open ? "open" : "close"}`
|
|
3104
3164
|
)
|
|
3105
3165
|
},
|
|
3106
|
-
/* @__PURE__ */
|
|
3166
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
3107
3167
|
"span",
|
|
3108
3168
|
{
|
|
3109
3169
|
className: `${className}__actions-container Layer__table-cell-content`
|
|
3110
3170
|
},
|
|
3111
|
-
editable && !open ? /* @__PURE__ */
|
|
3171
|
+
editable && !open ? /* @__PURE__ */ import_react34.default.createElement(
|
|
3112
3172
|
CategorySelect,
|
|
3113
3173
|
{
|
|
3114
3174
|
bankTransaction,
|
|
@@ -3121,11 +3181,11 @@ var BankTransactionRow = ({
|
|
|
3121
3181
|
disabled: bankTransaction.processing
|
|
3122
3182
|
}
|
|
3123
3183
|
) : null,
|
|
3124
|
-
!editable && !open ? /* @__PURE__ */
|
|
3184
|
+
!editable && !open ? /* @__PURE__ */ import_react34.default.createElement(Text, { as: "span", className: `${className}__category-text` }, bankTransaction.categorization_status === "SPLIT" /* SPLIT */ && /* @__PURE__ */ import_react34.default.createElement(import_react34.default.Fragment, null, /* @__PURE__ */ import_react34.default.createElement(
|
|
3125
3185
|
Badge,
|
|
3126
3186
|
{
|
|
3127
|
-
icon: /* @__PURE__ */
|
|
3128
|
-
tooltip: /* @__PURE__ */
|
|
3187
|
+
icon: /* @__PURE__ */ import_react34.default.createElement(Scissors_default, { size: 11 }),
|
|
3188
|
+
tooltip: /* @__PURE__ */ import_react34.default.createElement(
|
|
3129
3189
|
SplitTooltipDetails,
|
|
3130
3190
|
{
|
|
3131
3191
|
classNamePrefix: className,
|
|
@@ -3134,18 +3194,18 @@ var BankTransactionRow = ({
|
|
|
3134
3194
|
)
|
|
3135
3195
|
},
|
|
3136
3196
|
"Split"
|
|
3137
|
-
), /* @__PURE__ */
|
|
3197
|
+
), /* @__PURE__ */ import_react34.default.createElement("span", { className: `${className}__category-text__text` }, extractDescriptionForSplit(bankTransaction.category))), bankTransaction?.categorization_status === "MATCHED" /* MATCHED */ && bankTransaction?.match && /* @__PURE__ */ import_react34.default.createElement(import_react34.default.Fragment, null, /* @__PURE__ */ import_react34.default.createElement(
|
|
3138
3198
|
MatchBadge,
|
|
3139
3199
|
{
|
|
3140
3200
|
classNamePrefix: className,
|
|
3141
3201
|
bankTransaction,
|
|
3142
3202
|
dateFormat
|
|
3143
3203
|
}
|
|
3144
|
-
), /* @__PURE__ */
|
|
3204
|
+
), /* @__PURE__ */ import_react34.default.createElement("span", { className: `${className}__category-text__text` }, `${(0, import_date_fns7.format)(
|
|
3145
3205
|
(0, import_date_fns7.parseISO)(bankTransaction.match.bank_transaction.date),
|
|
3146
3206
|
dateFormat
|
|
3147
|
-
)}, ${bankTransaction.match.bank_transaction.description}`)), bankTransaction?.categorization_status !== "MATCHED" /* MATCHED */ && bankTransaction?.categorization_status !== "SPLIT" /* SPLIT */ && /* @__PURE__ */
|
|
3148
|
-
editable && !open && showRetry ? /* @__PURE__ */
|
|
3207
|
+
)}, ${bankTransaction.match.bank_transaction.description}`)), bankTransaction?.categorization_status !== "MATCHED" /* MATCHED */ && bankTransaction?.categorization_status !== "SPLIT" /* SPLIT */ && /* @__PURE__ */ import_react34.default.createElement("span", { className: `${className}__category-text__text` }, bankTransaction?.category?.display_name)) : null,
|
|
3208
|
+
editable && !open && showRetry ? /* @__PURE__ */ import_react34.default.createElement(
|
|
3149
3209
|
RetryButton,
|
|
3150
3210
|
{
|
|
3151
3211
|
onClick: () => {
|
|
@@ -3159,17 +3219,17 @@ var BankTransactionRow = ({
|
|
|
3159
3219
|
},
|
|
3160
3220
|
"Retry"
|
|
3161
3221
|
) : null,
|
|
3162
|
-
open && bankTransaction.error ? /* @__PURE__ */
|
|
3222
|
+
open && bankTransaction.error ? /* @__PURE__ */ import_react34.default.createElement(
|
|
3163
3223
|
Text,
|
|
3164
3224
|
{
|
|
3165
3225
|
as: "span",
|
|
3166
3226
|
size: "md" /* md */,
|
|
3167
3227
|
className: "Layer__unsaved-info"
|
|
3168
3228
|
},
|
|
3169
|
-
/* @__PURE__ */
|
|
3170
|
-
/* @__PURE__ */
|
|
3229
|
+
/* @__PURE__ */ import_react34.default.createElement("span", null, "Unsaved"),
|
|
3230
|
+
/* @__PURE__ */ import_react34.default.createElement(AlertCircle_default, { size: 12 })
|
|
3171
3231
|
) : null,
|
|
3172
|
-
editable && (open || !open && !showRetry) || !editable && open ? /* @__PURE__ */
|
|
3232
|
+
editable && (open || !open && !showRetry) || !editable && open ? /* @__PURE__ */ import_react34.default.createElement(
|
|
3173
3233
|
SubmitButton,
|
|
3174
3234
|
{
|
|
3175
3235
|
onClick: () => {
|
|
@@ -3184,13 +3244,13 @@ var BankTransactionRow = ({
|
|
|
3184
3244
|
},
|
|
3185
3245
|
editable ? "Approve" : "Update"
|
|
3186
3246
|
) : null,
|
|
3187
|
-
/* @__PURE__ */
|
|
3247
|
+
/* @__PURE__ */ import_react34.default.createElement(
|
|
3188
3248
|
IconButton,
|
|
3189
3249
|
{
|
|
3190
3250
|
onClick: toggleOpen,
|
|
3191
3251
|
className: "Layer__bank-transaction-row__expand-button",
|
|
3192
3252
|
active: open,
|
|
3193
|
-
icon: /* @__PURE__ */
|
|
3253
|
+
icon: /* @__PURE__ */ import_react34.default.createElement(
|
|
3194
3254
|
ChevronDownFill_default,
|
|
3195
3255
|
{
|
|
3196
3256
|
className: `Layer__chevron ${open ? "Layer__chevron__up" : "Layer__chevron__down"}`
|
|
@@ -3200,7 +3260,7 @@ var BankTransactionRow = ({
|
|
|
3200
3260
|
)
|
|
3201
3261
|
)
|
|
3202
3262
|
)
|
|
3203
|
-
), /* @__PURE__ */
|
|
3263
|
+
), /* @__PURE__ */ import_react34.default.createElement("tr", null, /* @__PURE__ */ import_react34.default.createElement("td", { colSpan: 5, className: "Layer__bank-transaction-row__expanded-td" }, /* @__PURE__ */ import_react34.default.createElement(
|
|
3204
3264
|
ExpandedBankTransactionRow,
|
|
3205
3265
|
{
|
|
3206
3266
|
ref: expandedRowRef,
|
|
@@ -3213,11 +3273,11 @@ var BankTransactionRow = ({
|
|
|
3213
3273
|
};
|
|
3214
3274
|
|
|
3215
3275
|
// src/components/BankTransactionListItem/Assignment.tsx
|
|
3216
|
-
var
|
|
3276
|
+
var import_react35 = __toESM(require("react"));
|
|
3217
3277
|
var import_date_fns8 = require("date-fns");
|
|
3218
3278
|
var Assignment = ({ bankTransaction }) => {
|
|
3219
3279
|
if (bankTransaction.match && bankTransaction.categorization_status === "MATCHED" /* MATCHED */) {
|
|
3220
|
-
return /* @__PURE__ */
|
|
3280
|
+
return /* @__PURE__ */ import_react35.default.createElement(import_react35.default.Fragment, null, /* @__PURE__ */ import_react35.default.createElement(
|
|
3221
3281
|
MatchBadge,
|
|
3222
3282
|
{
|
|
3223
3283
|
classNamePrefix: "Layer__bank-transaction-list-item",
|
|
@@ -3225,17 +3285,17 @@ var Assignment = ({ bankTransaction }) => {
|
|
|
3225
3285
|
dateFormat: DATE_FORMAT,
|
|
3226
3286
|
text: "Matched"
|
|
3227
3287
|
}
|
|
3228
|
-
), /* @__PURE__ */
|
|
3288
|
+
), /* @__PURE__ */ import_react35.default.createElement(Text, { className: "Layer__bank-transaction-list-item__category-text__text" }, `${(0, import_date_fns8.format)(
|
|
3229
3289
|
(0, import_date_fns8.parseISO)(bankTransaction.match.bank_transaction.date),
|
|
3230
3290
|
DATE_FORMAT
|
|
3231
3291
|
)}, ${bankTransaction.match.bank_transaction.description}`));
|
|
3232
3292
|
}
|
|
3233
3293
|
if (bankTransaction.categorization_status === "SPLIT" /* SPLIT */) {
|
|
3234
|
-
return /* @__PURE__ */
|
|
3294
|
+
return /* @__PURE__ */ import_react35.default.createElement(import_react35.default.Fragment, null, /* @__PURE__ */ import_react35.default.createElement(
|
|
3235
3295
|
Badge,
|
|
3236
3296
|
{
|
|
3237
|
-
icon: /* @__PURE__ */
|
|
3238
|
-
tooltip: /* @__PURE__ */
|
|
3297
|
+
icon: /* @__PURE__ */ import_react35.default.createElement(Scissors_default, { size: 11 }),
|
|
3298
|
+
tooltip: /* @__PURE__ */ import_react35.default.createElement(
|
|
3239
3299
|
SplitTooltipDetails,
|
|
3240
3300
|
{
|
|
3241
3301
|
classNamePrefix: "Layer__bank-transaction-list-item",
|
|
@@ -3244,9 +3304,9 @@ var Assignment = ({ bankTransaction }) => {
|
|
|
3244
3304
|
)
|
|
3245
3305
|
},
|
|
3246
3306
|
"Split"
|
|
3247
|
-
), /* @__PURE__ */
|
|
3307
|
+
), /* @__PURE__ */ import_react35.default.createElement(Text, { className: "Layer__bank-transaction-list-item__category-text__text" }, extractDescriptionForSplit(bankTransaction.category)));
|
|
3248
3308
|
}
|
|
3249
|
-
return /* @__PURE__ */
|
|
3309
|
+
return /* @__PURE__ */ import_react35.default.createElement(Text, null, bankTransaction?.category?.display_name);
|
|
3250
3310
|
};
|
|
3251
3311
|
|
|
3252
3312
|
// src/components/BankTransactionListItem/BankTransactionListItem.tsx
|
|
@@ -3260,26 +3320,26 @@ var BankTransactionListItem = ({
|
|
|
3260
3320
|
editable,
|
|
3261
3321
|
containerWidth
|
|
3262
3322
|
}) => {
|
|
3263
|
-
const expandedRowRef = (0,
|
|
3264
|
-
const [showRetry, setShowRetry] = (0,
|
|
3265
|
-
const [removed, setRemoved] = (0,
|
|
3323
|
+
const expandedRowRef = (0, import_react36.useRef)(null);
|
|
3324
|
+
const [showRetry, setShowRetry] = (0, import_react36.useState)(false);
|
|
3325
|
+
const [removed, setRemoved] = (0, import_react36.useState)(false);
|
|
3266
3326
|
const { categorize: categorizeBankTransaction2, match: matchBankTransaction2 } = useBankTransactions();
|
|
3267
|
-
const [selectedCategory, setSelectedCategory] = (0,
|
|
3327
|
+
const [selectedCategory, setSelectedCategory] = (0, import_react36.useState)(
|
|
3268
3328
|
getDefaultSelectedCategory(bankTransaction)
|
|
3269
3329
|
);
|
|
3270
|
-
const [open, setOpen] = (0,
|
|
3330
|
+
const [open, setOpen] = (0, import_react36.useState)(false);
|
|
3271
3331
|
const toggleOpen = () => {
|
|
3272
3332
|
setShowRetry(false);
|
|
3273
3333
|
setOpen(!open);
|
|
3274
3334
|
};
|
|
3275
|
-
const [showComponent, setShowComponent] = (0,
|
|
3276
|
-
(0,
|
|
3335
|
+
const [showComponent, setShowComponent] = (0, import_react36.useState)(false);
|
|
3336
|
+
(0, import_react36.useEffect)(() => {
|
|
3277
3337
|
const timeoutId = setTimeout(() => {
|
|
3278
3338
|
setShowComponent(true);
|
|
3279
3339
|
}, index * 80);
|
|
3280
3340
|
return () => clearTimeout(timeoutId);
|
|
3281
3341
|
}, []);
|
|
3282
|
-
(0,
|
|
3342
|
+
(0, import_react36.useEffect)(() => {
|
|
3283
3343
|
if (bankTransaction.error) {
|
|
3284
3344
|
setShowRetry(true);
|
|
3285
3345
|
}
|
|
@@ -3315,26 +3375,26 @@ var BankTransactionListItem = ({
|
|
|
3315
3375
|
open ? openClassName : "",
|
|
3316
3376
|
showComponent ? "show" : ""
|
|
3317
3377
|
);
|
|
3318
|
-
return /* @__PURE__ */
|
|
3378
|
+
return /* @__PURE__ */ import_react36.default.createElement("li", { className: rowClassName }, /* @__PURE__ */ import_react36.default.createElement("span", { className: `${className}__heading` }, /* @__PURE__ */ import_react36.default.createElement("div", { className: `${className}__heading__main` }, /* @__PURE__ */ import_react36.default.createElement("span", { className: `${className}__heading-date` }, (0, import_date_fns9.format)((0, import_date_fns9.parseISO)(bankTransaction.date), dateFormat)), /* @__PURE__ */ import_react36.default.createElement("span", { className: `${className}__heading-separator` }), /* @__PURE__ */ import_react36.default.createElement("span", { className: `${className}__heading-account-name` }, bankTransaction.account_name ?? "")), /* @__PURE__ */ import_react36.default.createElement(
|
|
3319
3379
|
"div",
|
|
3320
3380
|
{
|
|
3321
3381
|
onClick: toggleOpen,
|
|
3322
3382
|
className: "Layer__bank-transaction-row__expand-button"
|
|
3323
3383
|
},
|
|
3324
|
-
/* @__PURE__ */
|
|
3384
|
+
/* @__PURE__ */ import_react36.default.createElement(
|
|
3325
3385
|
ChevronDownFill_default,
|
|
3326
3386
|
{
|
|
3327
3387
|
className: `Layer__chevron ${open ? "Layer__chevron__up" : "Layer__chevron__down"}`
|
|
3328
3388
|
}
|
|
3329
3389
|
)
|
|
3330
|
-
)), /* @__PURE__ */
|
|
3390
|
+
)), /* @__PURE__ */ import_react36.default.createElement("span", { className: `${className}__body` }, /* @__PURE__ */ import_react36.default.createElement("span", { className: `${className}__body__name` }, /* @__PURE__ */ import_react36.default.createElement(Text, { as: "span", withTooltip: "whenTruncated" /* whenTruncated */ }, bankTransaction.counterparty_name ?? bankTransaction.description)), /* @__PURE__ */ import_react36.default.createElement(
|
|
3331
3391
|
"span",
|
|
3332
3392
|
{
|
|
3333
3393
|
className: `${className}__amount-${isCredit2(bankTransaction) ? "credit" : "debit"}`
|
|
3334
3394
|
},
|
|
3335
3395
|
isCredit2(bankTransaction) ? "+$" : " $",
|
|
3336
3396
|
centsToDollars(bankTransaction.amount)
|
|
3337
|
-
)), /* @__PURE__ */
|
|
3397
|
+
)), /* @__PURE__ */ import_react36.default.createElement("span", { className: `${className}__expanded-row` }, /* @__PURE__ */ import_react36.default.createElement(
|
|
3338
3398
|
ExpandedBankTransactionRow,
|
|
3339
3399
|
{
|
|
3340
3400
|
ref: expandedRowRef,
|
|
@@ -3345,7 +3405,7 @@ var BankTransactionListItem = ({
|
|
|
3345
3405
|
submitBtnText: editable ? "Approve" : "Update",
|
|
3346
3406
|
containerWidth
|
|
3347
3407
|
}
|
|
3348
|
-
)), /* @__PURE__ */
|
|
3408
|
+
)), /* @__PURE__ */ import_react36.default.createElement("span", { className: `${className}__base-row` }, editable ? /* @__PURE__ */ import_react36.default.createElement(
|
|
3349
3409
|
CategorySelect,
|
|
3350
3410
|
{
|
|
3351
3411
|
bankTransaction,
|
|
@@ -3357,7 +3417,7 @@ var BankTransactionListItem = ({
|
|
|
3357
3417
|
},
|
|
3358
3418
|
disabled: bankTransaction.processing
|
|
3359
3419
|
}
|
|
3360
|
-
) : null, !editable ? /* @__PURE__ */
|
|
3420
|
+
) : null, !editable ? /* @__PURE__ */ import_react36.default.createElement(Assignment, { bankTransaction }) : null, editable && !showRetry ? /* @__PURE__ */ import_react36.default.createElement(
|
|
3361
3421
|
SubmitButton,
|
|
3362
3422
|
{
|
|
3363
3423
|
onClick: () => {
|
|
@@ -3370,7 +3430,7 @@ var BankTransactionListItem = ({
|
|
|
3370
3430
|
action: editable ? "save" /* SAVE */ : "update" /* UPDATE */
|
|
3371
3431
|
},
|
|
3372
3432
|
editable ? "Approve" : "Update"
|
|
3373
|
-
) : null, editable && showRetry ? /* @__PURE__ */
|
|
3433
|
+
) : null, editable && showRetry ? /* @__PURE__ */ import_react36.default.createElement(
|
|
3374
3434
|
RetryButton,
|
|
3375
3435
|
{
|
|
3376
3436
|
onClick: () => {
|
|
@@ -3383,11 +3443,11 @@ var BankTransactionListItem = ({
|
|
|
3383
3443
|
error: "Approval failed. Check connection and retry in few seconds."
|
|
3384
3444
|
},
|
|
3385
3445
|
"Retry"
|
|
3386
|
-
) : null), bankTransaction.error && showRetry ? /* @__PURE__ */
|
|
3446
|
+
) : null), bankTransaction.error && showRetry ? /* @__PURE__ */ import_react36.default.createElement(ErrorText, null, "Approval failed. Check connection and retry in few seconds.") : null);
|
|
3387
3447
|
};
|
|
3388
3448
|
|
|
3389
3449
|
// src/components/Container/Container.tsx
|
|
3390
|
-
var
|
|
3450
|
+
var import_react37 = __toESM(require("react"));
|
|
3391
3451
|
|
|
3392
3452
|
// src/config/theme.ts
|
|
3393
3453
|
var SHADES = {
|
|
@@ -3616,7 +3676,7 @@ var hslToHex = (hsl) => {
|
|
|
3616
3676
|
|
|
3617
3677
|
// src/components/Container/Container.tsx
|
|
3618
3678
|
var import_classnames19 = __toESM(require("classnames"));
|
|
3619
|
-
var Container = (0,
|
|
3679
|
+
var Container = (0, import_react37.forwardRef)(
|
|
3620
3680
|
({ name, className, children, asWidget }, ref) => {
|
|
3621
3681
|
const baseClassName = (0, import_classnames19.default)(
|
|
3622
3682
|
"Layer__component Layer__component-container",
|
|
@@ -3626,28 +3686,30 @@ var Container = (0, import_react36.forwardRef)(
|
|
|
3626
3686
|
);
|
|
3627
3687
|
const { theme } = useLayerContext();
|
|
3628
3688
|
const styles = parseStylesFromThemeConfig(theme);
|
|
3629
|
-
return /* @__PURE__ */
|
|
3689
|
+
return /* @__PURE__ */ import_react37.default.createElement("div", { ref, className: baseClassName, style: { ...styles } }, children);
|
|
3630
3690
|
}
|
|
3631
3691
|
);
|
|
3632
3692
|
|
|
3633
3693
|
// src/components/Container/Header.tsx
|
|
3634
|
-
var
|
|
3694
|
+
var import_react38 = __toESM(require("react"));
|
|
3635
3695
|
var import_classnames20 = __toESM(require("classnames"));
|
|
3636
|
-
var Header = (0,
|
|
3696
|
+
var Header = (0, import_react38.forwardRef)(
|
|
3637
3697
|
({ className, children, style }, ref) => {
|
|
3638
3698
|
const baseClassName = (0, import_classnames20.default)("Layer__component-header", className);
|
|
3639
|
-
return /* @__PURE__ */
|
|
3699
|
+
return /* @__PURE__ */ import_react38.default.createElement("header", { ref, className: baseClassName, style }, children);
|
|
3640
3700
|
}
|
|
3641
3701
|
);
|
|
3642
3702
|
|
|
3643
3703
|
// src/components/DataState/DataState.tsx
|
|
3644
|
-
var
|
|
3704
|
+
var import_react39 = __toESM(require("react"));
|
|
3645
3705
|
var getIcon = (status) => {
|
|
3646
3706
|
switch (status) {
|
|
3647
3707
|
case "failed" /* failed */:
|
|
3648
|
-
return /* @__PURE__ */
|
|
3708
|
+
return /* @__PURE__ */ import_react39.default.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--error" }, /* @__PURE__ */ import_react39.default.createElement(AlertOctagon_default, { size: 12 }));
|
|
3709
|
+
case "info" /* info */:
|
|
3710
|
+
return /* @__PURE__ */ import_react39.default.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--neutral" }, /* @__PURE__ */ import_react39.default.createElement(AlertOctagon_default, { size: 12 }));
|
|
3649
3711
|
default:
|
|
3650
|
-
return /* @__PURE__ */
|
|
3712
|
+
return /* @__PURE__ */ import_react39.default.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--neutral" }, /* @__PURE__ */ import_react39.default.createElement(CheckCircle_default, { size: 12 }));
|
|
3651
3713
|
}
|
|
3652
3714
|
};
|
|
3653
3715
|
var DataState = ({
|
|
@@ -3657,7 +3719,7 @@ var DataState = ({
|
|
|
3657
3719
|
onRefresh,
|
|
3658
3720
|
isLoading
|
|
3659
3721
|
}) => {
|
|
3660
|
-
return /* @__PURE__ */
|
|
3722
|
+
return /* @__PURE__ */ import_react39.default.createElement("div", { className: "Layer__data-state" }, getIcon(status), /* @__PURE__ */ import_react39.default.createElement(
|
|
3661
3723
|
Text,
|
|
3662
3724
|
{
|
|
3663
3725
|
as: "span",
|
|
@@ -3666,11 +3728,11 @@ var DataState = ({
|
|
|
3666
3728
|
className: "Layer__data-state__title"
|
|
3667
3729
|
},
|
|
3668
3730
|
title
|
|
3669
|
-
), /* @__PURE__ */
|
|
3731
|
+
), /* @__PURE__ */ import_react39.default.createElement(Text, { as: "span", className: "Layer__data-state__description" }, description), onRefresh && /* @__PURE__ */ import_react39.default.createElement("span", { className: "Layer__data-state__btn" }, /* @__PURE__ */ import_react39.default.createElement(
|
|
3670
3732
|
Button,
|
|
3671
3733
|
{
|
|
3672
3734
|
variant: "secondary" /* secondary */,
|
|
3673
|
-
rightIcon: isLoading ? /* @__PURE__ */
|
|
3735
|
+
rightIcon: isLoading ? /* @__PURE__ */ import_react39.default.createElement(Loader_default, { size: 14, className: "Layer__anim--rotating" }) : /* @__PURE__ */ import_react39.default.createElement(RefreshCcw_default, { size: 12 }),
|
|
3674
3736
|
onClick: onRefresh,
|
|
3675
3737
|
disabled: isLoading
|
|
3676
3738
|
},
|
|
@@ -3679,16 +3741,16 @@ var DataState = ({
|
|
|
3679
3741
|
};
|
|
3680
3742
|
|
|
3681
3743
|
// src/components/Loader/Loader.tsx
|
|
3682
|
-
var
|
|
3744
|
+
var import_react40 = __toESM(require("react"));
|
|
3683
3745
|
var Loader2 = ({ children }) => {
|
|
3684
|
-
return /* @__PURE__ */
|
|
3746
|
+
return /* @__PURE__ */ import_react40.default.createElement("span", { className: "Layer__loader" }, /* @__PURE__ */ import_react40.default.createElement(Loader_default, { size: 28, className: "Layer__anim--rotating" }), children);
|
|
3685
3747
|
};
|
|
3686
3748
|
|
|
3687
3749
|
// src/components/Pagination/Pagination.tsx
|
|
3688
|
-
var
|
|
3750
|
+
var import_react42 = __toESM(require("react"));
|
|
3689
3751
|
|
|
3690
3752
|
// src/hooks/usePagination/usePagination.ts
|
|
3691
|
-
var
|
|
3753
|
+
var import_react41 = require("react");
|
|
3692
3754
|
var DOTS = "...";
|
|
3693
3755
|
var usePagination = ({
|
|
3694
3756
|
totalCount,
|
|
@@ -3696,7 +3758,7 @@ var usePagination = ({
|
|
|
3696
3758
|
siblingCount = 1,
|
|
3697
3759
|
currentPage
|
|
3698
3760
|
}) => {
|
|
3699
|
-
const paginationRange = (0,
|
|
3761
|
+
const paginationRange = (0, import_react41.useMemo)(() => {
|
|
3700
3762
|
const totalPageCount = Math.ceil(totalCount / pageSize);
|
|
3701
3763
|
const totalPageNumbers = siblingCount + 5;
|
|
3702
3764
|
if (totalPageNumbers >= totalPageCount) {
|
|
@@ -3733,8 +3795,8 @@ var usePagination = ({
|
|
|
3733
3795
|
};
|
|
3734
3796
|
|
|
3735
3797
|
// src/icons/ChevronLeft.tsx
|
|
3736
|
-
var
|
|
3737
|
-
var ChevronLeft = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
3798
|
+
var React52 = __toESM(require("react"));
|
|
3799
|
+
var ChevronLeft = ({ size = 18, ...props }) => /* @__PURE__ */ React52.createElement(
|
|
3738
3800
|
"svg",
|
|
3739
3801
|
{
|
|
3740
3802
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -3744,7 +3806,7 @@ var ChevronLeft = ({ size = 18, ...props }) => /* @__PURE__ */ React51.createEle
|
|
|
3744
3806
|
fill: "none",
|
|
3745
3807
|
...props
|
|
3746
3808
|
},
|
|
3747
|
-
/* @__PURE__ */
|
|
3809
|
+
/* @__PURE__ */ React52.createElement(
|
|
3748
3810
|
"path",
|
|
3749
3811
|
{
|
|
3750
3812
|
d: "M11.25 13.5L6.75 9L11.25 4.5",
|
|
@@ -3757,8 +3819,8 @@ var ChevronLeft = ({ size = 18, ...props }) => /* @__PURE__ */ React51.createEle
|
|
|
3757
3819
|
var ChevronLeft_default = ChevronLeft;
|
|
3758
3820
|
|
|
3759
3821
|
// src/icons/ChevronRight.tsx
|
|
3760
|
-
var
|
|
3761
|
-
var ChavronRight = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
3822
|
+
var React53 = __toESM(require("react"));
|
|
3823
|
+
var ChavronRight = ({ size = 18, ...props }) => /* @__PURE__ */ React53.createElement(
|
|
3762
3824
|
"svg",
|
|
3763
3825
|
{
|
|
3764
3826
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -3768,7 +3830,7 @@ var ChavronRight = ({ size = 18, ...props }) => /* @__PURE__ */ React52.createEl
|
|
|
3768
3830
|
fill: "none",
|
|
3769
3831
|
...props
|
|
3770
3832
|
},
|
|
3771
|
-
/* @__PURE__ */
|
|
3833
|
+
/* @__PURE__ */ React53.createElement(
|
|
3772
3834
|
"path",
|
|
3773
3835
|
{
|
|
3774
3836
|
d: "M6.75 13.5L11.25 9L6.75 4.5",
|
|
@@ -3802,7 +3864,7 @@ var Pagination = ({
|
|
|
3802
3864
|
return;
|
|
3803
3865
|
}
|
|
3804
3866
|
let lastPage = paginationRange[paginationRange.length - 1];
|
|
3805
|
-
return /* @__PURE__ */
|
|
3867
|
+
return /* @__PURE__ */ import_react42.default.createElement("ul", { className: "Layer__pagination" }, /* @__PURE__ */ import_react42.default.createElement(
|
|
3806
3868
|
"li",
|
|
3807
3869
|
{
|
|
3808
3870
|
key: `page-prev`,
|
|
@@ -3814,12 +3876,12 @@ var Pagination = ({
|
|
|
3814
3876
|
),
|
|
3815
3877
|
onClick: () => onPageChange(currentPage - 1)
|
|
3816
3878
|
},
|
|
3817
|
-
/* @__PURE__ */
|
|
3879
|
+
/* @__PURE__ */ import_react42.default.createElement(ChevronLeft_default, { size: 12 })
|
|
3818
3880
|
), paginationRange.map((pageNumber) => {
|
|
3819
3881
|
if (pageNumber === DOTS) {
|
|
3820
|
-
return /* @__PURE__ */
|
|
3882
|
+
return /* @__PURE__ */ import_react42.default.createElement("li", { className: "Layer__pagination-item Layer__pagination-dots" }, "\u2026");
|
|
3821
3883
|
}
|
|
3822
|
-
return /* @__PURE__ */
|
|
3884
|
+
return /* @__PURE__ */ import_react42.default.createElement(
|
|
3823
3885
|
"li",
|
|
3824
3886
|
{
|
|
3825
3887
|
key: `page-${pageNumber}`,
|
|
@@ -3834,7 +3896,7 @@ var Pagination = ({
|
|
|
3834
3896
|
},
|
|
3835
3897
|
pageNumber
|
|
3836
3898
|
);
|
|
3837
|
-
}), /* @__PURE__ */
|
|
3899
|
+
}), /* @__PURE__ */ import_react42.default.createElement(
|
|
3838
3900
|
"li",
|
|
3839
3901
|
{
|
|
3840
3902
|
key: `page-last`,
|
|
@@ -3846,7 +3908,7 @@ var Pagination = ({
|
|
|
3846
3908
|
),
|
|
3847
3909
|
onClick: () => onPageChange(currentPage + 1)
|
|
3848
3910
|
},
|
|
3849
|
-
/* @__PURE__ */
|
|
3911
|
+
/* @__PURE__ */ import_react42.default.createElement(ChevronRight_default, { size: 12 })
|
|
3850
3912
|
));
|
|
3851
3913
|
};
|
|
3852
3914
|
|
|
@@ -3873,14 +3935,14 @@ var BankTransactions = ({
|
|
|
3873
3935
|
asWidget = false,
|
|
3874
3936
|
pageSize = 15
|
|
3875
3937
|
}) => {
|
|
3876
|
-
const [display, setDisplay] = (0,
|
|
3877
|
-
const [currentPage, setCurrentPage] = (0,
|
|
3878
|
-
const [removedTxs, setRemovedTxs] = (0,
|
|
3938
|
+
const [display, setDisplay] = (0, import_react43.useState)("review" /* review */);
|
|
3939
|
+
const [currentPage, setCurrentPage] = (0, import_react43.useState)(1);
|
|
3940
|
+
const [removedTxs, setRemovedTxs] = (0, import_react43.useState)([]);
|
|
3879
3941
|
const { data, isLoading, error, isValidating, refetch } = useBankTransactions();
|
|
3880
3942
|
const bankTransactionsByFilter = data?.filter(
|
|
3881
3943
|
(tx) => !removedTxs.includes(tx.id) && filterVisibility(display, tx)
|
|
3882
3944
|
);
|
|
3883
|
-
const bankTransactions = (0,
|
|
3945
|
+
const bankTransactions = (0, import_react43.useMemo)(() => {
|
|
3884
3946
|
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
3885
3947
|
const lastPageIndex = firstPageIndex + pageSize;
|
|
3886
3948
|
return bankTransactionsByFilter?.slice(firstPageIndex, lastPageIndex);
|
|
@@ -3891,10 +3953,10 @@ var BankTransactions = ({
|
|
|
3891
3953
|
);
|
|
3892
3954
|
setCurrentPage(1);
|
|
3893
3955
|
};
|
|
3894
|
-
const [shiftStickyHeader, setShiftStickyHeader] = (0,
|
|
3956
|
+
const [shiftStickyHeader, setShiftStickyHeader] = (0, import_react43.useState)(0);
|
|
3895
3957
|
const debounceShiftStickyHeader = debounce(setShiftStickyHeader, 500);
|
|
3896
|
-
const [listView, setListView] = (0,
|
|
3897
|
-
const [containerWidth, setContainerWidth] = (0,
|
|
3958
|
+
const [listView, setListView] = (0, import_react43.useState)(false);
|
|
3959
|
+
const [containerWidth, setContainerWidth] = (0, import_react43.useState)(0);
|
|
3898
3960
|
const debounceContainerWidth = debounce(setContainerWidth, 500);
|
|
3899
3961
|
const removeTransaction = (id) => {
|
|
3900
3962
|
const newTxs = removedTxs.slice();
|
|
@@ -3918,7 +3980,7 @@ var BankTransactions = ({
|
|
|
3918
3980
|
debounceContainerWidth(size?.width);
|
|
3919
3981
|
});
|
|
3920
3982
|
const editable = display === "review" /* review */;
|
|
3921
|
-
return /* @__PURE__ */
|
|
3983
|
+
return /* @__PURE__ */ import_react43.default.createElement(
|
|
3922
3984
|
Container,
|
|
3923
3985
|
{
|
|
3924
3986
|
className: editable ? "Layer__bank-transactions--to-review" : "Layer__bank-transactions--categorized",
|
|
@@ -3926,14 +3988,14 @@ var BankTransactions = ({
|
|
|
3926
3988
|
asWidget,
|
|
3927
3989
|
ref: containerRef
|
|
3928
3990
|
},
|
|
3929
|
-
/* @__PURE__ */
|
|
3991
|
+
/* @__PURE__ */ import_react43.default.createElement(
|
|
3930
3992
|
Header,
|
|
3931
3993
|
{
|
|
3932
3994
|
className: "Layer__bank-transactions__header",
|
|
3933
3995
|
style: { top: shiftStickyHeader }
|
|
3934
3996
|
},
|
|
3935
|
-
/* @__PURE__ */
|
|
3936
|
-
/* @__PURE__ */
|
|
3997
|
+
/* @__PURE__ */ import_react43.default.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Transactions"),
|
|
3998
|
+
/* @__PURE__ */ import_react43.default.createElement(
|
|
3937
3999
|
Toggle,
|
|
3938
4000
|
{
|
|
3939
4001
|
name: "bank-transaction-display",
|
|
@@ -3946,15 +4008,15 @@ var BankTransactions = ({
|
|
|
3946
4008
|
}
|
|
3947
4009
|
)
|
|
3948
4010
|
),
|
|
3949
|
-
!listView && /* @__PURE__ */
|
|
4011
|
+
!listView && /* @__PURE__ */ import_react43.default.createElement(
|
|
3950
4012
|
"table",
|
|
3951
4013
|
{
|
|
3952
4014
|
width: "100%",
|
|
3953
4015
|
className: "Layer__table Layer__bank-transactions__table with-cell-separators"
|
|
3954
4016
|
},
|
|
3955
|
-
/* @__PURE__ */
|
|
3956
|
-
/* @__PURE__ */
|
|
3957
|
-
(bankTransaction, index) => /* @__PURE__ */
|
|
4017
|
+
/* @__PURE__ */ import_react43.default.createElement("thead", null, /* @__PURE__ */ import_react43.default.createElement("tr", null, /* @__PURE__ */ import_react43.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__date-col" }, "Date"), /* @__PURE__ */ import_react43.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__tx-col" }, "Transaction"), /* @__PURE__ */ import_react43.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__account-col" }, "Account"), /* @__PURE__ */ import_react43.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount Layer__table-cell__amount-col" }, "Amount"), editable ? /* @__PURE__ */ import_react43.default.createElement("th", { className: "Layer__table-header Layer__table-header--primary Layer__table-cell__category-col" }, "Categorize") : /* @__PURE__ */ import_react43.default.createElement("th", { className: "Layer__table-header Layer__table-cell__category-col" }, "Category"))),
|
|
4018
|
+
/* @__PURE__ */ import_react43.default.createElement("tbody", null, !isLoading && bankTransactions?.map(
|
|
4019
|
+
(bankTransaction, index) => /* @__PURE__ */ import_react43.default.createElement(
|
|
3958
4020
|
BankTransactionRow,
|
|
3959
4021
|
{
|
|
3960
4022
|
index,
|
|
@@ -3968,9 +4030,9 @@ var BankTransactions = ({
|
|
|
3968
4030
|
)
|
|
3969
4031
|
))
|
|
3970
4032
|
),
|
|
3971
|
-
isLoading && !bankTransactions ? /* @__PURE__ */
|
|
3972
|
-
!isLoading && listView ? /* @__PURE__ */
|
|
3973
|
-
(bankTransaction, index) => /* @__PURE__ */
|
|
4033
|
+
isLoading && !bankTransactions ? /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__bank-transactions__loader-container" }, /* @__PURE__ */ import_react43.default.createElement(Loader2, null)) : null,
|
|
4034
|
+
!isLoading && listView ? /* @__PURE__ */ import_react43.default.createElement("ul", { className: "Layer__bank-transactions__list" }, bankTransactions?.map(
|
|
4035
|
+
(bankTransaction, index) => /* @__PURE__ */ import_react43.default.createElement(
|
|
3974
4036
|
BankTransactionListItem,
|
|
3975
4037
|
{
|
|
3976
4038
|
index,
|
|
@@ -3983,7 +4045,7 @@ var BankTransactions = ({
|
|
|
3983
4045
|
}
|
|
3984
4046
|
)
|
|
3985
4047
|
)) : null,
|
|
3986
|
-
!isLoading && !error && (bankTransactions === void 0 || bankTransactions !== void 0 && bankTransactions.length === 0) ? /* @__PURE__ */
|
|
4048
|
+
!isLoading && !error && (bankTransactions === void 0 || bankTransactions !== void 0 && bankTransactions.length === 0) ? /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react43.default.createElement(
|
|
3987
4049
|
DataState,
|
|
3988
4050
|
{
|
|
3989
4051
|
status: "allDone" /* allDone */,
|
|
@@ -3993,7 +4055,7 @@ var BankTransactions = ({
|
|
|
3993
4055
|
isLoading: isValidating
|
|
3994
4056
|
}
|
|
3995
4057
|
)) : null,
|
|
3996
|
-
!isLoading && error ? /* @__PURE__ */
|
|
4058
|
+
!isLoading && error ? /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react43.default.createElement(
|
|
3997
4059
|
DataState,
|
|
3998
4060
|
{
|
|
3999
4061
|
status: "failed" /* failed */,
|
|
@@ -4003,7 +4065,7 @@ var BankTransactions = ({
|
|
|
4003
4065
|
isLoading: isValidating
|
|
4004
4066
|
}
|
|
4005
4067
|
)) : null,
|
|
4006
|
-
/* @__PURE__ */
|
|
4068
|
+
/* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__bank-transactions__pagination" }, /* @__PURE__ */ import_react43.default.createElement(
|
|
4007
4069
|
Pagination,
|
|
4008
4070
|
{
|
|
4009
4071
|
currentPage,
|
|
@@ -4016,7 +4078,7 @@ var BankTransactions = ({
|
|
|
4016
4078
|
};
|
|
4017
4079
|
|
|
4018
4080
|
// src/components/Hello/Hello.tsx
|
|
4019
|
-
var
|
|
4081
|
+
var import_react44 = __toESM(require("react"));
|
|
4020
4082
|
var import_swr3 = __toESM(require("swr"));
|
|
4021
4083
|
var fetcher = (url) => fetch(url).then((res) => res.json());
|
|
4022
4084
|
var Hello = ({ user }) => {
|
|
@@ -4025,14 +4087,14 @@ var Hello = ({ user }) => {
|
|
|
4025
4087
|
fetcher
|
|
4026
4088
|
);
|
|
4027
4089
|
const name = (isLoading ? "..." : data?.name) || "User";
|
|
4028
|
-
return /* @__PURE__ */
|
|
4090
|
+
return /* @__PURE__ */ import_react44.default.createElement(import_react44.default.Fragment, null, /* @__PURE__ */ import_react44.default.createElement("div", { className: "hello" }, "Hello, ", name, "!"));
|
|
4029
4091
|
};
|
|
4030
4092
|
|
|
4031
4093
|
// src/components/LinkedAccounts/LinkedAccounts.tsx
|
|
4032
|
-
var
|
|
4094
|
+
var import_react47 = __toESM(require("react"));
|
|
4033
4095
|
|
|
4034
4096
|
// src/hooks/useLinkedAccounts/useLinkedAccounts.ts
|
|
4035
|
-
var
|
|
4097
|
+
var import_react45 = require("react");
|
|
4036
4098
|
var MOCK_DATA = [
|
|
4037
4099
|
{
|
|
4038
4100
|
name: "Business Checking",
|
|
@@ -4047,13 +4109,13 @@ var MOCK_DATA = [
|
|
|
4047
4109
|
{
|
|
4048
4110
|
name: "Account",
|
|
4049
4111
|
account: "4321",
|
|
4050
|
-
amount:
|
|
4112
|
+
amount: 4400020620
|
|
4051
4113
|
}
|
|
4052
4114
|
];
|
|
4053
4115
|
var useLinkedAccounts = () => {
|
|
4054
4116
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
4055
|
-
const [isLoading, setIsLoading] = (0,
|
|
4056
|
-
(0,
|
|
4117
|
+
const [isLoading, setIsLoading] = (0, import_react45.useState)(true);
|
|
4118
|
+
(0, import_react45.useEffect)(() => {
|
|
4057
4119
|
const timer = setTimeout(() => {
|
|
4058
4120
|
setIsLoading(false);
|
|
4059
4121
|
}, 2e3);
|
|
@@ -4079,23 +4141,23 @@ var useLinkedAccounts = () => {
|
|
|
4079
4141
|
};
|
|
4080
4142
|
|
|
4081
4143
|
// src/components/LinkedAccounts/LinkedAccountThumb.tsx
|
|
4082
|
-
var
|
|
4144
|
+
var import_react46 = __toESM(require("react"));
|
|
4083
4145
|
var LinkedAccountThumb = ({ account }) => {
|
|
4084
|
-
return /* @__PURE__ */
|
|
4146
|
+
return /* @__PURE__ */ import_react46.default.createElement("div", { className: "Layer__linked-account-thumb" }, /* @__PURE__ */ import_react46.default.createElement("div", { className: "topbar" }, /* @__PURE__ */ import_react46.default.createElement(Text, { as: "span", className: "account-name" }, account.name), /* @__PURE__ */ import_react46.default.createElement(Text, { as: "span", className: "account-number" }, "\u2022\u2022\u2022", account.account)), /* @__PURE__ */ import_react46.default.createElement("div", { className: "bottombar" }, /* @__PURE__ */ import_react46.default.createElement(Text, { as: "span", className: "account-amount" }, "$", centsToDollars(account.amount))));
|
|
4085
4147
|
};
|
|
4086
4148
|
|
|
4087
4149
|
// src/components/LinkedAccounts/LinkedAccounts.tsx
|
|
4088
4150
|
var COMPONENT_NAME2 = "linked-accounts";
|
|
4089
4151
|
var LinkedAccounts = () => {
|
|
4090
4152
|
const { data, isLoading, error, isValidating, refetch } = useLinkedAccounts();
|
|
4091
|
-
return /* @__PURE__ */
|
|
4153
|
+
return /* @__PURE__ */ import_react47.default.createElement(Container, { name: COMPONENT_NAME2 }, /* @__PURE__ */ import_react47.default.createElement(Header, { className: "Layer__linked-accounts__header" }, /* @__PURE__ */ import_react47.default.createElement(
|
|
4092
4154
|
Heading,
|
|
4093
4155
|
{
|
|
4094
4156
|
className: "Layer__linked-accounts__title",
|
|
4095
4157
|
size: "secondary" /* secondary */
|
|
4096
4158
|
},
|
|
4097
4159
|
"Linked Accounts"
|
|
4098
|
-
)), isLoading && /* @__PURE__ */
|
|
4160
|
+
)), isLoading && /* @__PURE__ */ import_react47.default.createElement("div", { className: "Layer__linked-accounts__loader-container" }, /* @__PURE__ */ import_react47.default.createElement(Loader2, null)), error && !isLoading ? /* @__PURE__ */ import_react47.default.createElement(
|
|
4099
4161
|
DataState,
|
|
4100
4162
|
{
|
|
4101
4163
|
status: "failed" /* failed */,
|
|
@@ -4104,14 +4166,14 @@ var LinkedAccounts = () => {
|
|
|
4104
4166
|
onRefresh: () => refetch(),
|
|
4105
4167
|
isLoading: isValidating
|
|
4106
4168
|
}
|
|
4107
|
-
) : null, !error && !isLoading ? /* @__PURE__ */
|
|
4169
|
+
) : null, !error && !isLoading ? /* @__PURE__ */ import_react47.default.createElement("div", { className: "Layer__linked-accounts__list" }, data?.map((account, index) => /* @__PURE__ */ import_react47.default.createElement(LinkedAccountThumb, { account, key: `linked-acc-${index}` }))) : null);
|
|
4108
4170
|
};
|
|
4109
4171
|
|
|
4110
4172
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
4111
|
-
var
|
|
4173
|
+
var import_react57 = __toESM(require("react"));
|
|
4112
4174
|
|
|
4113
4175
|
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
4114
|
-
var
|
|
4176
|
+
var import_react48 = require("react");
|
|
4115
4177
|
|
|
4116
4178
|
// src/utils/profitAndLossUtils.ts
|
|
4117
4179
|
var doesLineItemQualifies = (item) => {
|
|
@@ -4180,17 +4242,17 @@ var useProfitAndLoss = ({
|
|
|
4180
4242
|
endDate: (0, import_date_fns10.endOfMonth)(/* @__PURE__ */ new Date())
|
|
4181
4243
|
}) => {
|
|
4182
4244
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
4183
|
-
const [startDate, setStartDate] = (0,
|
|
4245
|
+
const [startDate, setStartDate] = (0, import_react48.useState)(
|
|
4184
4246
|
initialStartDate || (0, import_date_fns10.startOfMonth)(Date.now())
|
|
4185
4247
|
);
|
|
4186
|
-
const [endDate, setEndDate] = (0,
|
|
4248
|
+
const [endDate, setEndDate] = (0, import_react48.useState)(
|
|
4187
4249
|
initialEndDate || (0, import_date_fns10.endOfMonth)(Date.now())
|
|
4188
4250
|
);
|
|
4189
|
-
const [filters, setFilters] = (0,
|
|
4251
|
+
const [filters, setFilters] = (0, import_react48.useState)({
|
|
4190
4252
|
expenses: void 0,
|
|
4191
4253
|
revenue: void 0
|
|
4192
4254
|
});
|
|
4193
|
-
const [sidebarScope, setSidebarScope] = (0,
|
|
4255
|
+
const [sidebarScope, setSidebarScope] = (0, import_react48.useState)(void 0);
|
|
4194
4256
|
const {
|
|
4195
4257
|
data: rawData,
|
|
4196
4258
|
isLoading,
|
|
@@ -4213,7 +4275,7 @@ var useProfitAndLoss = ({
|
|
|
4213
4275
|
})
|
|
4214
4276
|
);
|
|
4215
4277
|
const { data, error } = rawData || {};
|
|
4216
|
-
const { filteredData, filteredTotal } = (0,
|
|
4278
|
+
const { filteredData, filteredTotal } = (0, import_react48.useMemo)(() => {
|
|
4217
4279
|
if (!data) {
|
|
4218
4280
|
return { filteredData: [], filteredTotal: void 0 };
|
|
4219
4281
|
}
|
|
@@ -4298,7 +4360,7 @@ var useProfitAndLoss = ({
|
|
|
4298
4360
|
};
|
|
4299
4361
|
|
|
4300
4362
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
4301
|
-
var
|
|
4363
|
+
var import_react50 = __toESM(require("react"));
|
|
4302
4364
|
|
|
4303
4365
|
// src/utils/format.ts
|
|
4304
4366
|
var capitalizeFirstLetter = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
@@ -4336,7 +4398,7 @@ var formatPercent = (value, options) => {
|
|
|
4336
4398
|
};
|
|
4337
4399
|
|
|
4338
4400
|
// src/components/ProfitAndLossChart/Indicator.tsx
|
|
4339
|
-
var
|
|
4401
|
+
var import_react49 = __toESM(require("react"));
|
|
4340
4402
|
var emptyViewBox = { x: 0, y: 0, width: 0, height: 0 };
|
|
4341
4403
|
var Indicator = ({
|
|
4342
4404
|
viewBox = {},
|
|
@@ -4348,25 +4410,26 @@ var Indicator = ({
|
|
|
4348
4410
|
return null;
|
|
4349
4411
|
}
|
|
4350
4412
|
const { x: animateTo = 0, width = 0 } = "x" in viewBox ? viewBox : emptyViewBox;
|
|
4351
|
-
const
|
|
4352
|
-
const
|
|
4413
|
+
const margin = width > 12 ? 4 : 1;
|
|
4414
|
+
const boxWidth = width * 2 + margin;
|
|
4415
|
+
const multiplier = width > 12 ? 1.2 : 1;
|
|
4353
4416
|
const xOffset = (boxWidth * multiplier - boxWidth) / 2;
|
|
4354
|
-
|
|
4417
|
+
const borderRadius = width > 16 ? 8 : width / 2;
|
|
4418
|
+
(0, import_react49.useEffect)(() => {
|
|
4355
4419
|
setAnimateFrom(animateTo);
|
|
4356
4420
|
}, [animateTo]);
|
|
4357
4421
|
const actualX = animateFrom === -1 ? animateTo : animateFrom;
|
|
4358
|
-
return /* @__PURE__ */
|
|
4422
|
+
return /* @__PURE__ */ import_react49.default.createElement(
|
|
4359
4423
|
"rect",
|
|
4360
4424
|
{
|
|
4361
4425
|
className: "Layer__profit-and-loss-chart__selection-indicator",
|
|
4362
|
-
rx:
|
|
4363
|
-
ry:
|
|
4426
|
+
rx: borderRadius,
|
|
4427
|
+
ry: borderRadius,
|
|
4364
4428
|
style: {
|
|
4365
4429
|
width: `${boxWidth * multiplier}px`,
|
|
4366
4430
|
// @ts-expect-error -- y is fine but x apparently isn't!
|
|
4367
4431
|
x: actualX - xOffset,
|
|
4368
4432
|
y: 22,
|
|
4369
|
-
borderRadius: 8,
|
|
4370
4433
|
height: "calc(100% - 38px)"
|
|
4371
4434
|
}
|
|
4372
4435
|
}
|
|
@@ -4380,7 +4443,7 @@ var barGap = 4;
|
|
|
4380
4443
|
var barSize = 20;
|
|
4381
4444
|
var ProfitAndLossChart = () => {
|
|
4382
4445
|
const { getColor } = useLayerContext();
|
|
4383
|
-
const { changeDateRange, dateRange } = (0,
|
|
4446
|
+
const { changeDateRange, dateRange } = (0, import_react50.useContext)(ProfitAndLoss.Context);
|
|
4384
4447
|
const thisMonth = (0, import_date_fns11.startOfMonth)(Date.now());
|
|
4385
4448
|
const startSelectionMonth = dateRange.startDate.getMonth();
|
|
4386
4449
|
const endSelectionMonth = dateRange.endDate.getMonth();
|
|
@@ -4462,6 +4525,7 @@ var ProfitAndLossChart = () => {
|
|
|
4462
4525
|
name: getMonthName(pnl),
|
|
4463
4526
|
revenue: pnl?.income.value || 0,
|
|
4464
4527
|
expenses: Math.abs((pnl?.income.value || 0) - (pnl?.net_profit || 0)),
|
|
4528
|
+
netProfit: pnl?.net_profit || 0,
|
|
4465
4529
|
selected: !!pnl && (0, import_date_fns11.parseISO)(pnl.start_date).getMonth() >= startSelectionMonth && (0, import_date_fns11.parseISO)(pnl.end_date).getMonth() <= endSelectionMonth
|
|
4466
4530
|
});
|
|
4467
4531
|
const onClick = ({ activeTooltipIndex }) => {
|
|
@@ -4480,27 +4544,29 @@ var ProfitAndLossChart = () => {
|
|
|
4480
4544
|
label
|
|
4481
4545
|
}) => {
|
|
4482
4546
|
if (active && payload && payload.length) {
|
|
4483
|
-
|
|
4547
|
+
const netProfit = payload[0].payload.netProfit ?? 0;
|
|
4548
|
+
const netProfitClass = netProfit > 0 ? "positive" : netProfit < 0 ? "negative" : "";
|
|
4549
|
+
return /* @__PURE__ */ import_react50.default.createElement("div", { className: "Layer__chart__tooltip" }, /* @__PURE__ */ import_react50.default.createElement("ul", { className: "Layer__chart__tooltip-list" }, /* @__PURE__ */ import_react50.default.createElement("li", null, /* @__PURE__ */ import_react50.default.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[0].name ?? "")), /* @__PURE__ */ import_react50.default.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[0].value ?? 0)))), /* @__PURE__ */ import_react50.default.createElement("li", null, /* @__PURE__ */ import_react50.default.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[1].name ?? "")), /* @__PURE__ */ import_react50.default.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[1].value ?? 0)))), /* @__PURE__ */ import_react50.default.createElement("li", null, /* @__PURE__ */ import_react50.default.createElement("label", { className: "Layer__chart__tooltip-label" }, "Net Profit"), /* @__PURE__ */ import_react50.default.createElement("span", { className: `Layer__chart__tooltip-value ${netProfitClass}` }, "$", centsToDollars(netProfit)))));
|
|
4484
4550
|
}
|
|
4485
4551
|
return null;
|
|
4486
4552
|
};
|
|
4487
4553
|
const CustomizedCursor = (props) => {
|
|
4488
|
-
const { x,
|
|
4489
|
-
return /* @__PURE__ */
|
|
4554
|
+
const { x, width, height } = props;
|
|
4555
|
+
return /* @__PURE__ */ import_react50.default.createElement(
|
|
4490
4556
|
import_recharts.Rectangle,
|
|
4491
4557
|
{
|
|
4492
|
-
fill: getColor(
|
|
4558
|
+
fill: getColor(900)?.hex ?? "#333",
|
|
4493
4559
|
stroke: "none",
|
|
4494
|
-
x,
|
|
4495
|
-
y,
|
|
4496
|
-
radius:
|
|
4497
|
-
width,
|
|
4498
|
-
height:
|
|
4560
|
+
x: x + width / 2 - 11,
|
|
4561
|
+
y: height + 44,
|
|
4562
|
+
radius: 2,
|
|
4563
|
+
width: 22,
|
|
4564
|
+
height: 2,
|
|
4499
4565
|
className: "Layer__chart__tooltip-cursor"
|
|
4500
4566
|
}
|
|
4501
4567
|
);
|
|
4502
4568
|
};
|
|
4503
|
-
const data = (0,
|
|
4569
|
+
const data = (0, import_react50.useMemo)(
|
|
4504
4570
|
() => monthData.map(summarizePnL),
|
|
4505
4571
|
[
|
|
4506
4572
|
startSelectionMonth,
|
|
@@ -4508,8 +4574,8 @@ var ProfitAndLossChart = () => {
|
|
|
4508
4574
|
...monthData.map((m) => m?.net_profit)
|
|
4509
4575
|
]
|
|
4510
4576
|
);
|
|
4511
|
-
const [animateFrom, setAnimateFrom] = (0,
|
|
4512
|
-
return /* @__PURE__ */
|
|
4577
|
+
const [animateFrom, setAnimateFrom] = (0, import_react50.useState)(-1);
|
|
4578
|
+
return /* @__PURE__ */ import_react50.default.createElement(
|
|
4513
4579
|
import_recharts.ResponsiveContainer,
|
|
4514
4580
|
{
|
|
4515
4581
|
className: "Layer__chart-container",
|
|
@@ -4517,7 +4583,7 @@ var ProfitAndLossChart = () => {
|
|
|
4517
4583
|
height: "100%",
|
|
4518
4584
|
minHeight: 200
|
|
4519
4585
|
},
|
|
4520
|
-
/* @__PURE__ */
|
|
4586
|
+
/* @__PURE__ */ import_react50.default.createElement(
|
|
4521
4587
|
import_recharts.BarChart,
|
|
4522
4588
|
{
|
|
4523
4589
|
margin: { left: 12, right: 12, bottom: 12 },
|
|
@@ -4526,17 +4592,17 @@ var ProfitAndLossChart = () => {
|
|
|
4526
4592
|
barGap,
|
|
4527
4593
|
className: "Layer__profit-and-loss-chart"
|
|
4528
4594
|
},
|
|
4529
|
-
/* @__PURE__ */
|
|
4595
|
+
/* @__PURE__ */ import_react50.default.createElement(
|
|
4530
4596
|
import_recharts.Tooltip,
|
|
4531
4597
|
{
|
|
4532
4598
|
wrapperClassName: "Layer__chart__tooltip-wrapper",
|
|
4533
|
-
content: /* @__PURE__ */
|
|
4534
|
-
cursor: /* @__PURE__ */
|
|
4599
|
+
content: /* @__PURE__ */ import_react50.default.createElement(CustomTooltip, null),
|
|
4600
|
+
cursor: /* @__PURE__ */ import_react50.default.createElement(CustomizedCursor, null),
|
|
4535
4601
|
animationDuration: 100,
|
|
4536
4602
|
animationEasing: "ease-out"
|
|
4537
4603
|
}
|
|
4538
4604
|
),
|
|
4539
|
-
/* @__PURE__ */
|
|
4605
|
+
/* @__PURE__ */ import_react50.default.createElement(
|
|
4540
4606
|
import_recharts.CartesianGrid,
|
|
4541
4607
|
{
|
|
4542
4608
|
vertical: false,
|
|
@@ -4544,7 +4610,7 @@ var ProfitAndLossChart = () => {
|
|
|
4544
4610
|
strokeDasharray: "5 5"
|
|
4545
4611
|
}
|
|
4546
4612
|
),
|
|
4547
|
-
/* @__PURE__ */
|
|
4613
|
+
/* @__PURE__ */ import_react50.default.createElement(
|
|
4548
4614
|
import_recharts.Legend,
|
|
4549
4615
|
{
|
|
4550
4616
|
verticalAlign: "top",
|
|
@@ -4552,7 +4618,7 @@ var ProfitAndLossChart = () => {
|
|
|
4552
4618
|
wrapperStyle: { top: -24 },
|
|
4553
4619
|
payload: [
|
|
4554
4620
|
{
|
|
4555
|
-
value: "
|
|
4621
|
+
value: "Revenue",
|
|
4556
4622
|
type: "circle",
|
|
4557
4623
|
id: "IncomeLegend"
|
|
4558
4624
|
},
|
|
@@ -4564,20 +4630,20 @@ var ProfitAndLossChart = () => {
|
|
|
4564
4630
|
]
|
|
4565
4631
|
}
|
|
4566
4632
|
),
|
|
4567
|
-
/* @__PURE__ */
|
|
4568
|
-
/* @__PURE__ */
|
|
4633
|
+
/* @__PURE__ */ import_react50.default.createElement(import_recharts.XAxis, { dataKey: "name", tickLine: false }),
|
|
4634
|
+
/* @__PURE__ */ import_react50.default.createElement(
|
|
4569
4635
|
import_recharts.Bar,
|
|
4570
4636
|
{
|
|
4571
4637
|
dataKey: "revenue",
|
|
4572
4638
|
barSize,
|
|
4573
4639
|
isAnimationActive: false,
|
|
4574
|
-
radius: [
|
|
4640
|
+
radius: [2, 2, 0, 0],
|
|
4575
4641
|
className: "Layer__profit-and-loss-chart__bar--income"
|
|
4576
4642
|
},
|
|
4577
|
-
/* @__PURE__ */
|
|
4643
|
+
/* @__PURE__ */ import_react50.default.createElement(
|
|
4578
4644
|
import_recharts.LabelList,
|
|
4579
4645
|
{
|
|
4580
|
-
content: /* @__PURE__ */
|
|
4646
|
+
content: /* @__PURE__ */ import_react50.default.createElement(
|
|
4581
4647
|
Indicator,
|
|
4582
4648
|
{
|
|
4583
4649
|
animateFrom,
|
|
@@ -4586,7 +4652,7 @@ var ProfitAndLossChart = () => {
|
|
|
4586
4652
|
)
|
|
4587
4653
|
}
|
|
4588
4654
|
),
|
|
4589
|
-
data.map((entry) => /* @__PURE__ */
|
|
4655
|
+
data.map((entry) => /* @__PURE__ */ import_react50.default.createElement(
|
|
4590
4656
|
import_recharts.Cell,
|
|
4591
4657
|
{
|
|
4592
4658
|
key: entry.name,
|
|
@@ -4594,16 +4660,16 @@ var ProfitAndLossChart = () => {
|
|
|
4594
4660
|
}
|
|
4595
4661
|
))
|
|
4596
4662
|
),
|
|
4597
|
-
/* @__PURE__ */
|
|
4663
|
+
/* @__PURE__ */ import_react50.default.createElement(
|
|
4598
4664
|
import_recharts.Bar,
|
|
4599
4665
|
{
|
|
4600
4666
|
dataKey: "expenses",
|
|
4601
4667
|
barSize,
|
|
4602
4668
|
isAnimationActive: false,
|
|
4603
|
-
radius: [
|
|
4669
|
+
radius: [2, 2, 0, 0],
|
|
4604
4670
|
className: "Layer__profit-and-loss-chart__bar--expenses"
|
|
4605
4671
|
},
|
|
4606
|
-
data.map((entry) => /* @__PURE__ */
|
|
4672
|
+
data.map((entry) => /* @__PURE__ */ import_react50.default.createElement(
|
|
4607
4673
|
import_recharts.Cell,
|
|
4608
4674
|
{
|
|
4609
4675
|
key: entry.name,
|
|
@@ -4616,10 +4682,10 @@ var ProfitAndLossChart = () => {
|
|
|
4616
4682
|
};
|
|
4617
4683
|
|
|
4618
4684
|
// src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
|
|
4619
|
-
var
|
|
4685
|
+
var import_react51 = __toESM(require("react"));
|
|
4620
4686
|
var import_date_fns12 = require("date-fns");
|
|
4621
4687
|
var ProfitAndLossDatePicker = () => {
|
|
4622
|
-
const { changeDateRange, dateRange } = (0,
|
|
4688
|
+
const { changeDateRange, dateRange } = (0, import_react51.useContext)(ProfitAndLoss.Context);
|
|
4623
4689
|
const date = dateRange.startDate;
|
|
4624
4690
|
const label = (0, import_date_fns12.format)(date, "LLLL y");
|
|
4625
4691
|
const change = (duration) => {
|
|
@@ -4631,42 +4697,42 @@ var ProfitAndLossDatePicker = () => {
|
|
|
4631
4697
|
};
|
|
4632
4698
|
const previousMonth = () => change({ months: -1 });
|
|
4633
4699
|
const nextMonth = () => change({ months: 1 });
|
|
4634
|
-
return /* @__PURE__ */
|
|
4700
|
+
return /* @__PURE__ */ import_react51.default.createElement("div", { className: "Layer__profit-and-loss-date-picker" }, /* @__PURE__ */ import_react51.default.createElement("span", { className: "Layer__profit-and-loss-date-picker__label" }, label), /* @__PURE__ */ import_react51.default.createElement(
|
|
4635
4701
|
"button",
|
|
4636
4702
|
{
|
|
4637
4703
|
"aria-label": "View Previous Month",
|
|
4638
4704
|
className: "Layer__profit-and-loss-date-picker__button",
|
|
4639
4705
|
onClick: previousMonth
|
|
4640
4706
|
},
|
|
4641
|
-
/* @__PURE__ */
|
|
4707
|
+
/* @__PURE__ */ import_react51.default.createElement(
|
|
4642
4708
|
ChevronLeft_default,
|
|
4643
4709
|
{
|
|
4644
4710
|
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
4645
|
-
size:
|
|
4711
|
+
size: 16
|
|
4646
4712
|
}
|
|
4647
4713
|
)
|
|
4648
|
-
), /* @__PURE__ */
|
|
4714
|
+
), /* @__PURE__ */ import_react51.default.createElement(
|
|
4649
4715
|
"button",
|
|
4650
4716
|
{
|
|
4651
4717
|
"aria-label": "View Next Month",
|
|
4652
4718
|
className: "Layer__profit-and-loss-date-picker__button",
|
|
4653
4719
|
onClick: nextMonth
|
|
4654
4720
|
},
|
|
4655
|
-
/* @__PURE__ */
|
|
4721
|
+
/* @__PURE__ */ import_react51.default.createElement(
|
|
4656
4722
|
ChevronRight_default,
|
|
4657
4723
|
{
|
|
4658
4724
|
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
4659
|
-
size:
|
|
4725
|
+
size: 16
|
|
4660
4726
|
}
|
|
4661
4727
|
)
|
|
4662
4728
|
));
|
|
4663
4729
|
};
|
|
4664
4730
|
|
|
4665
4731
|
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
4666
|
-
var
|
|
4732
|
+
var import_react54 = __toESM(require("react"));
|
|
4667
4733
|
|
|
4668
4734
|
// src/components/SkeletonLoader/SkeletonLoader.tsx
|
|
4669
|
-
var
|
|
4735
|
+
var import_react52 = __toESM(require("react"));
|
|
4670
4736
|
var import_classnames22 = __toESM(require("classnames"));
|
|
4671
4737
|
var SkeletonLoader = ({
|
|
4672
4738
|
height,
|
|
@@ -4677,11 +4743,161 @@ var SkeletonLoader = ({
|
|
|
4677
4743
|
"Layer__skeleton-loader Layer__anim--skeleton-loading",
|
|
4678
4744
|
className
|
|
4679
4745
|
);
|
|
4680
|
-
return /* @__PURE__ */
|
|
4746
|
+
return /* @__PURE__ */ import_react52.default.createElement("div", { className: baseClassName, style: { width, height } });
|
|
4747
|
+
};
|
|
4748
|
+
|
|
4749
|
+
// src/components/ProfitAndLossSummaries/MiniChart.tsx
|
|
4750
|
+
var import_react53 = __toESM(require("react"));
|
|
4751
|
+
|
|
4752
|
+
// src/config/charts.ts
|
|
4753
|
+
var INACTIVE_OPACITY_LEVELS = [
|
|
4754
|
+
0.85,
|
|
4755
|
+
0.7,
|
|
4756
|
+
0.66,
|
|
4757
|
+
0.55,
|
|
4758
|
+
0.4,
|
|
4759
|
+
0.33,
|
|
4760
|
+
0.25,
|
|
4761
|
+
0.15
|
|
4762
|
+
];
|
|
4763
|
+
var DEFAULT_CHART_COLORS = [
|
|
4764
|
+
{
|
|
4765
|
+
color: "#7417B3",
|
|
4766
|
+
opacity: 1
|
|
4767
|
+
},
|
|
4768
|
+
{
|
|
4769
|
+
color: "#7417B3",
|
|
4770
|
+
opacity: 0.8
|
|
4771
|
+
},
|
|
4772
|
+
{
|
|
4773
|
+
color: "#7417B3",
|
|
4774
|
+
opacity: 0.6
|
|
4775
|
+
},
|
|
4776
|
+
{
|
|
4777
|
+
color: "#7417B3",
|
|
4778
|
+
opacity: 0.4
|
|
4779
|
+
},
|
|
4780
|
+
{
|
|
4781
|
+
color: "#7417B3",
|
|
4782
|
+
opacity: 0.2
|
|
4783
|
+
},
|
|
4784
|
+
{
|
|
4785
|
+
color: "#7417B3",
|
|
4786
|
+
opacity: 0.1
|
|
4787
|
+
},
|
|
4788
|
+
{
|
|
4789
|
+
color: "#006A80",
|
|
4790
|
+
opacity: 1
|
|
4791
|
+
},
|
|
4792
|
+
{
|
|
4793
|
+
color: "#006A80",
|
|
4794
|
+
opacity: 0.8
|
|
4795
|
+
},
|
|
4796
|
+
{
|
|
4797
|
+
color: "#006A80",
|
|
4798
|
+
opacity: 0.6
|
|
4799
|
+
},
|
|
4800
|
+
{
|
|
4801
|
+
color: "#006A80",
|
|
4802
|
+
opacity: 0.4
|
|
4803
|
+
},
|
|
4804
|
+
{
|
|
4805
|
+
color: "#006A80",
|
|
4806
|
+
opacity: 0.2
|
|
4807
|
+
},
|
|
4808
|
+
{
|
|
4809
|
+
color: "#006A80",
|
|
4810
|
+
opacity: 0.1
|
|
4811
|
+
},
|
|
4812
|
+
{
|
|
4813
|
+
color: "#009930",
|
|
4814
|
+
opacity: 1
|
|
4815
|
+
},
|
|
4816
|
+
{
|
|
4817
|
+
color: "#009930",
|
|
4818
|
+
opacity: 0.8
|
|
4819
|
+
},
|
|
4820
|
+
{
|
|
4821
|
+
color: "#009930",
|
|
4822
|
+
opacity: 0.6
|
|
4823
|
+
},
|
|
4824
|
+
{
|
|
4825
|
+
color: "#009930",
|
|
4826
|
+
opacity: 0.4
|
|
4827
|
+
},
|
|
4828
|
+
{
|
|
4829
|
+
color: "#009930",
|
|
4830
|
+
opacity: 0.2
|
|
4831
|
+
},
|
|
4832
|
+
{
|
|
4833
|
+
color: "#009930",
|
|
4834
|
+
opacity: 0.1
|
|
4835
|
+
}
|
|
4836
|
+
];
|
|
4837
|
+
|
|
4838
|
+
// src/components/ProfitAndLossSummaries/MiniChart.tsx
|
|
4839
|
+
var import_recharts2 = require("recharts");
|
|
4840
|
+
var MiniChart = ({ data }) => {
|
|
4841
|
+
return /* @__PURE__ */ import_react53.default.createElement(import_recharts2.PieChart, { width: 48, height: 48, className: "mini-chart" }, /* @__PURE__ */ import_react53.default.createElement(
|
|
4842
|
+
import_recharts2.Pie,
|
|
4843
|
+
{
|
|
4844
|
+
data,
|
|
4845
|
+
dataKey: "value",
|
|
4846
|
+
nameKey: "name",
|
|
4847
|
+
cx: "50%",
|
|
4848
|
+
cy: "50%",
|
|
4849
|
+
innerRadius: 10,
|
|
4850
|
+
outerRadius: 16,
|
|
4851
|
+
paddingAngle: 0.2,
|
|
4852
|
+
fill: "#8884d8",
|
|
4853
|
+
width: 24,
|
|
4854
|
+
height: 24,
|
|
4855
|
+
animationDuration: 250,
|
|
4856
|
+
animationEasing: "ease-in-out"
|
|
4857
|
+
},
|
|
4858
|
+
data.map((entry, index) => {
|
|
4859
|
+
const colorConfig = DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length];
|
|
4860
|
+
return /* @__PURE__ */ import_react53.default.createElement(
|
|
4861
|
+
import_recharts2.Cell,
|
|
4862
|
+
{
|
|
4863
|
+
key: `cell-${index}`,
|
|
4864
|
+
className: `Layer__profit-and-loss-detailed-charts__pie`,
|
|
4865
|
+
fill: entry.name === "placeholder" ? "#e6e6e6" : colorConfig.color,
|
|
4866
|
+
opacity: colorConfig.opacity
|
|
4867
|
+
}
|
|
4868
|
+
);
|
|
4869
|
+
})
|
|
4870
|
+
));
|
|
4681
4871
|
};
|
|
4682
4872
|
|
|
4683
4873
|
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
4684
4874
|
var import_classnames23 = __toESM(require("classnames"));
|
|
4875
|
+
var CHART_PLACEHOLDER = [
|
|
4876
|
+
{
|
|
4877
|
+
name: "placeholder",
|
|
4878
|
+
display_name: "placeholder",
|
|
4879
|
+
value: 1,
|
|
4880
|
+
type: "placeholder",
|
|
4881
|
+
share: 1
|
|
4882
|
+
}
|
|
4883
|
+
];
|
|
4884
|
+
var buildMiniChartData = (scope, data) => {
|
|
4885
|
+
if (!data) {
|
|
4886
|
+
return CHART_PLACEHOLDER;
|
|
4887
|
+
}
|
|
4888
|
+
let items = [];
|
|
4889
|
+
switch (scope) {
|
|
4890
|
+
case "revenue":
|
|
4891
|
+
items = collectRevenueItems(data);
|
|
4892
|
+
break;
|
|
4893
|
+
default:
|
|
4894
|
+
items = collectExpensesItems(data);
|
|
4895
|
+
}
|
|
4896
|
+
if (!items || items.length === 0 || !items.find((x) => Math.abs(x.value) !== 0)) {
|
|
4897
|
+
return CHART_PLACEHOLDER;
|
|
4898
|
+
}
|
|
4899
|
+
return items.slice();
|
|
4900
|
+
};
|
|
4685
4901
|
var ProfitAndLossSummaries = ({
|
|
4686
4902
|
vertical,
|
|
4687
4903
|
revenueLabel = "Revenue"
|
|
@@ -4691,17 +4907,23 @@ var ProfitAndLossSummaries = ({
|
|
|
4691
4907
|
isLoading,
|
|
4692
4908
|
setSidebarScope,
|
|
4693
4909
|
sidebarScope
|
|
4694
|
-
} = (0,
|
|
4910
|
+
} = (0, import_react54.useContext)(ProfitAndLoss.Context);
|
|
4911
|
+
const expensesChartData = (0, import_react54.useMemo)(() => {
|
|
4912
|
+
return buildMiniChartData("expenses", storedData);
|
|
4913
|
+
}, [storedData]);
|
|
4914
|
+
const revenueChartData = (0, import_react54.useMemo)(() => {
|
|
4915
|
+
return buildMiniChartData("revenue", storedData);
|
|
4916
|
+
}, [storedData]);
|
|
4695
4917
|
const data = storedData ? storedData : { income: { value: NaN }, net_profit: NaN };
|
|
4696
4918
|
const incomeDirectionClass = (data.income.value ?? NaN) < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
4697
4919
|
const expensesDirectionClass = (data?.income?.value ?? NaN) - data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
4698
4920
|
const netProfitDirectionClass = data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
4699
|
-
return /* @__PURE__ */
|
|
4921
|
+
return /* @__PURE__ */ import_react54.default.createElement(
|
|
4700
4922
|
"div",
|
|
4701
4923
|
{
|
|
4702
4924
|
className: `Layer__profit-and-loss-summaries ${vertical ? "flex-col" : ""}`
|
|
4703
4925
|
},
|
|
4704
|
-
/* @__PURE__ */
|
|
4926
|
+
/* @__PURE__ */ import_react54.default.createElement(
|
|
4705
4927
|
"div",
|
|
4706
4928
|
{
|
|
4707
4929
|
className: (0, import_classnames23.default)(
|
|
@@ -4711,16 +4933,16 @@ var ProfitAndLossSummaries = ({
|
|
|
4711
4933
|
),
|
|
4712
4934
|
onClick: () => setSidebarScope("revenue")
|
|
4713
4935
|
},
|
|
4714
|
-
/* @__PURE__ */
|
|
4715
|
-
isLoading || storedData === void 0 ? /* @__PURE__ */
|
|
4936
|
+
/* @__PURE__ */ import_react54.default.createElement(MiniChart, { data: revenueChartData }),
|
|
4937
|
+
/* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__profit-and-loss-summaries__text" }, /* @__PURE__ */ import_react54.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, revenueLabel), isLoading || storedData === void 0 ? /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ import_react54.default.createElement(SkeletonLoader, null)) : /* @__PURE__ */ import_react54.default.createElement(
|
|
4716
4938
|
"span",
|
|
4717
4939
|
{
|
|
4718
4940
|
className: `Layer__profit-and-loss-summaries__amount ${incomeDirectionClass}`
|
|
4719
4941
|
},
|
|
4720
4942
|
centsToDollars(Math.abs(data?.income?.value ?? NaN))
|
|
4721
|
-
)
|
|
4943
|
+
))
|
|
4722
4944
|
),
|
|
4723
|
-
/* @__PURE__ */
|
|
4945
|
+
/* @__PURE__ */ import_react54.default.createElement(
|
|
4724
4946
|
"div",
|
|
4725
4947
|
{
|
|
4726
4948
|
className: (0, import_classnames23.default)(
|
|
@@ -4730,43 +4952,81 @@ var ProfitAndLossSummaries = ({
|
|
|
4730
4952
|
),
|
|
4731
4953
|
onClick: () => setSidebarScope("expenses")
|
|
4732
4954
|
},
|
|
4733
|
-
/* @__PURE__ */
|
|
4734
|
-
isLoading || storedData === void 0 ? /* @__PURE__ */
|
|
4955
|
+
/* @__PURE__ */ import_react54.default.createElement(MiniChart, { data: expensesChartData }),
|
|
4956
|
+
/* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__profit-and-loss-summaries__text" }, /* @__PURE__ */ import_react54.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Expenses"), isLoading || storedData === void 0 ? /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ import_react54.default.createElement(SkeletonLoader, { className: "Layer__profit-and-loss-summaries__loader" })) : /* @__PURE__ */ import_react54.default.createElement(
|
|
4735
4957
|
"span",
|
|
4736
4958
|
{
|
|
4737
4959
|
className: `Layer__profit-and-loss-summaries__amount ${expensesDirectionClass}`
|
|
4738
4960
|
},
|
|
4739
|
-
centsToDollars(
|
|
4740
|
-
|
|
4961
|
+
centsToDollars(
|
|
4962
|
+
Math.abs((data.income.value ?? 0) - data.net_profit)
|
|
4963
|
+
)
|
|
4964
|
+
))
|
|
4741
4965
|
),
|
|
4742
|
-
/* @__PURE__ */
|
|
4966
|
+
/* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__profit-and-loss-summaries__summary net-profit Layer__profit-and-loss-summaries__summary--net-profit" }, /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__profit-and-loss-summaries__text" }, /* @__PURE__ */ import_react54.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Net Profit"), isLoading || storedData === void 0 ? /* @__PURE__ */ import_react54.default.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ import_react54.default.createElement(SkeletonLoader, { className: "Layer__profit-and-loss-summaries__loader" })) : /* @__PURE__ */ import_react54.default.createElement(
|
|
4743
4967
|
"span",
|
|
4744
4968
|
{
|
|
4745
4969
|
className: `Layer__profit-and-loss-summaries__amount ${netProfitDirectionClass}`
|
|
4746
4970
|
},
|
|
4747
4971
|
centsToDollars(Math.abs(data.net_profit))
|
|
4748
|
-
))
|
|
4972
|
+
)))
|
|
4749
4973
|
);
|
|
4750
4974
|
};
|
|
4751
4975
|
|
|
4752
4976
|
// src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
|
|
4753
|
-
var
|
|
4977
|
+
var import_react56 = __toESM(require("react"));
|
|
4978
|
+
|
|
4979
|
+
// src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
|
|
4980
|
+
var import_react55 = __toESM(require("react"));
|
|
4981
|
+
|
|
4982
|
+
// src/icons/PieChart.tsx
|
|
4983
|
+
var React65 = __toESM(require("react"));
|
|
4984
|
+
var PieChart2 = ({ size = 12, ...props }) => /* @__PURE__ */ React65.createElement(
|
|
4985
|
+
"svg",
|
|
4986
|
+
{
|
|
4987
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
4988
|
+
viewBox: "0 0 12 12",
|
|
4989
|
+
fill: "none",
|
|
4990
|
+
...props,
|
|
4991
|
+
width: size,
|
|
4992
|
+
height: size
|
|
4993
|
+
},
|
|
4994
|
+
/* @__PURE__ */ React65.createElement("g", null, /* @__PURE__ */ React65.createElement(
|
|
4995
|
+
"path",
|
|
4996
|
+
{
|
|
4997
|
+
d: "M10.2213 7.78271C9.92969 8.47226 9.47363 9.07989 8.89297 9.55247C8.3123 10.0251 7.62471 10.3482 6.89031 10.4936C6.1559 10.6391 5.39705 10.6024 4.68009 10.3869C3.96313 10.1713 3.30989 9.78337 2.77749 9.25701C2.24509 8.73065 1.84973 8.08189 1.62598 7.36744C1.40223 6.65298 1.3569 5.8946 1.49396 5.15858C1.63102 4.42257 1.94629 3.73133 2.41221 3.14531C2.87813 2.55928 3.48051 2.09631 4.16669 1.79688",
|
|
4998
|
+
stroke: "currentColor",
|
|
4999
|
+
"stroke-linecap": "round",
|
|
5000
|
+
"stroke-linejoin": "round"
|
|
5001
|
+
}
|
|
5002
|
+
), /* @__PURE__ */ React65.createElement(
|
|
5003
|
+
"path",
|
|
5004
|
+
{
|
|
5005
|
+
d: "M10.5833 6.00033C10.5833 5.39843 10.4648 4.80244 10.2344 4.24636C10.0041 3.69028 9.66651 3.18502 9.24091 2.75942C8.8153 2.33382 8.31004 1.99621 7.75397 1.76588C7.19789 1.53554 6.60189 1.41699 6 1.41699V6.00033H10.5833Z",
|
|
5006
|
+
stroke: "currentColor",
|
|
5007
|
+
"stroke-linecap": "round",
|
|
5008
|
+
"stroke-linejoin": "round"
|
|
5009
|
+
}
|
|
5010
|
+
))
|
|
5011
|
+
);
|
|
5012
|
+
var PieChart_default = PieChart2;
|
|
4754
5013
|
|
|
4755
5014
|
// src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
|
|
4756
|
-
var import_react53 = __toESM(require("react"));
|
|
4757
5015
|
var ProfitAndLossRow = ({
|
|
4758
5016
|
variant,
|
|
4759
5017
|
lineItem,
|
|
4760
5018
|
depth = 0,
|
|
4761
5019
|
maxDepth = 1,
|
|
4762
5020
|
direction = "DEBIT" /* DEBIT */,
|
|
4763
|
-
lockExpanded = false
|
|
5021
|
+
lockExpanded = false,
|
|
5022
|
+
scope,
|
|
5023
|
+
setSidebarScope
|
|
4764
5024
|
}) => {
|
|
4765
5025
|
if (!lineItem) {
|
|
4766
5026
|
return null;
|
|
4767
5027
|
}
|
|
4768
5028
|
const { value, display_name, line_items } = lineItem;
|
|
4769
|
-
const [expanded, setExpanded] = (0,
|
|
5029
|
+
const [expanded, setExpanded] = (0, import_react55.useState)(true);
|
|
4770
5030
|
const amount = value ?? 0;
|
|
4771
5031
|
const amountString = centsToDollars(Math.abs(amount));
|
|
4772
5032
|
const labelClasses = [
|
|
@@ -4797,20 +5057,36 @@ var ProfitAndLossRow = ({
|
|
|
4797
5057
|
);
|
|
4798
5058
|
displayChildren && expanded && labelClasses.push("Layer__profit-and-loss-row__label--expanded");
|
|
4799
5059
|
displayChildren && expanded && valueClasses.push("Layer__profit-and-loss-row__value--expanded");
|
|
4800
|
-
return /* @__PURE__ */
|
|
5060
|
+
return /* @__PURE__ */ import_react55.default.createElement(import_react55.default.Fragment, null, /* @__PURE__ */ import_react55.default.createElement(
|
|
4801
5061
|
"div",
|
|
4802
5062
|
{
|
|
4803
5063
|
className: labelClasses.join(" "),
|
|
4804
5064
|
onClick: () => !lockExpanded && toggleExpanded()
|
|
4805
5065
|
},
|
|
4806
|
-
!lockExpanded && variant !== "summation" ? /* @__PURE__ */
|
|
4807
|
-
|
|
4808
|
-
|
|
5066
|
+
/* @__PURE__ */ import_react55.default.createElement("span", { className: "Layer__profit-and-loss-row__label__title" }, !lockExpanded && variant !== "summation" ? /* @__PURE__ */ import_react55.default.createElement(
|
|
5067
|
+
ChevronDownFill_default,
|
|
5068
|
+
{
|
|
5069
|
+
size: 16,
|
|
5070
|
+
className: "Layer__profit-and-loss-row__label__chevron"
|
|
5071
|
+
}
|
|
5072
|
+
) : null, /* @__PURE__ */ import_react55.default.createElement(Text, null, display_name)),
|
|
5073
|
+
setSidebarScope && /* @__PURE__ */ import_react55.default.createElement(
|
|
5074
|
+
"span",
|
|
5075
|
+
{
|
|
5076
|
+
className: "Layer__profit-and-loss-row__detailed-chart-btn",
|
|
5077
|
+
onClick: (e) => {
|
|
5078
|
+
e.stopPropagation();
|
|
5079
|
+
setSidebarScope && setSidebarScope(scope ?? "expenses");
|
|
5080
|
+
}
|
|
5081
|
+
},
|
|
5082
|
+
/* @__PURE__ */ import_react55.default.createElement(PieChart_default, null)
|
|
5083
|
+
)
|
|
5084
|
+
), /* @__PURE__ */ import_react55.default.createElement("div", { className: valueClasses.join(" ") }, /* @__PURE__ */ import_react55.default.createElement(Text, null, amountString)), canGoDeeper && hasChildren && /* @__PURE__ */ import_react55.default.createElement(
|
|
4809
5085
|
"div",
|
|
4810
5086
|
{
|
|
4811
5087
|
className: `Layer__profit-and-loss-row__children ${expanded && "Layer__profit-and-loss-row__children--expanded"}`
|
|
4812
5088
|
},
|
|
4813
|
-
/* @__PURE__ */
|
|
5089
|
+
/* @__PURE__ */ import_react55.default.createElement("div", { className: "Layer__profit-and-loss-row__children--content" }, (line_items || []).map((line_item) => /* @__PURE__ */ import_react55.default.createElement(
|
|
4814
5090
|
ProfitAndLossRow,
|
|
4815
5091
|
{
|
|
4816
5092
|
key: line_item.display_name,
|
|
@@ -4873,26 +5149,34 @@ var empty_profit_and_loss_report_default = {
|
|
|
4873
5149
|
|
|
4874
5150
|
// src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
|
|
4875
5151
|
var ProfitAndLossTable = ({ lockExpanded }) => {
|
|
4876
|
-
const {
|
|
5152
|
+
const {
|
|
5153
|
+
data: actualData,
|
|
5154
|
+
isLoading,
|
|
5155
|
+
setSidebarScope
|
|
5156
|
+
} = (0, import_react56.useContext)(ProfitAndLoss.Context);
|
|
4877
5157
|
const data = !actualData || isLoading ? empty_profit_and_loss_report_default : actualData;
|
|
4878
5158
|
if (isLoading || actualData === void 0) {
|
|
4879
|
-
return /* @__PURE__ */
|
|
5159
|
+
return /* @__PURE__ */ import_react56.default.createElement("div", { className: "Layer__profit-and-loss-table__loader-container" }, /* @__PURE__ */ import_react56.default.createElement(Loader2, null));
|
|
4880
5160
|
}
|
|
4881
|
-
return /* @__PURE__ */
|
|
5161
|
+
return /* @__PURE__ */ import_react56.default.createElement(import_react56.default.Fragment, null, /* @__PURE__ */ import_react56.default.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table--main" }, /* @__PURE__ */ import_react56.default.createElement(
|
|
4882
5162
|
ProfitAndLossRow,
|
|
4883
5163
|
{
|
|
4884
5164
|
lineItem: data.income,
|
|
4885
5165
|
direction: "CREDIT" /* CREDIT */,
|
|
4886
|
-
lockExpanded
|
|
5166
|
+
lockExpanded,
|
|
5167
|
+
scope: "revenue",
|
|
5168
|
+
setSidebarScope
|
|
4887
5169
|
}
|
|
4888
|
-
), /* @__PURE__ */
|
|
5170
|
+
), /* @__PURE__ */ import_react56.default.createElement(
|
|
4889
5171
|
ProfitAndLossRow,
|
|
4890
5172
|
{
|
|
4891
5173
|
lineItem: data.cost_of_goods_sold,
|
|
4892
5174
|
direction: "DEBIT" /* DEBIT */,
|
|
4893
|
-
lockExpanded
|
|
5175
|
+
lockExpanded,
|
|
5176
|
+
scope: "expenses",
|
|
5177
|
+
setSidebarScope
|
|
4894
5178
|
}
|
|
4895
|
-
), /* @__PURE__ */
|
|
5179
|
+
), /* @__PURE__ */ import_react56.default.createElement(
|
|
4896
5180
|
ProfitAndLossRow,
|
|
4897
5181
|
{
|
|
4898
5182
|
lineItem: {
|
|
@@ -4901,16 +5185,20 @@ var ProfitAndLossTable = ({ lockExpanded }) => {
|
|
|
4901
5185
|
},
|
|
4902
5186
|
variant: "summation",
|
|
4903
5187
|
direction: "CREDIT" /* CREDIT */,
|
|
4904
|
-
lockExpanded
|
|
5188
|
+
lockExpanded,
|
|
5189
|
+
scope: "revenue",
|
|
5190
|
+
setSidebarScope
|
|
4905
5191
|
}
|
|
4906
|
-
), /* @__PURE__ */
|
|
5192
|
+
), /* @__PURE__ */ import_react56.default.createElement(
|
|
4907
5193
|
ProfitAndLossRow,
|
|
4908
5194
|
{
|
|
4909
5195
|
lineItem: data.expenses,
|
|
4910
5196
|
direction: "DEBIT" /* DEBIT */,
|
|
4911
|
-
lockExpanded
|
|
5197
|
+
lockExpanded,
|
|
5198
|
+
scope: "expenses",
|
|
5199
|
+
setSidebarScope
|
|
4912
5200
|
}
|
|
4913
|
-
), /* @__PURE__ */
|
|
5201
|
+
), /* @__PURE__ */ import_react56.default.createElement(
|
|
4914
5202
|
ProfitAndLossRow,
|
|
4915
5203
|
{
|
|
4916
5204
|
lineItem: {
|
|
@@ -4919,16 +5207,20 @@ var ProfitAndLossTable = ({ lockExpanded }) => {
|
|
|
4919
5207
|
},
|
|
4920
5208
|
variant: "summation",
|
|
4921
5209
|
direction: "CREDIT" /* CREDIT */,
|
|
4922
|
-
lockExpanded
|
|
5210
|
+
lockExpanded,
|
|
5211
|
+
scope: "revenue",
|
|
5212
|
+
setSidebarScope
|
|
4923
5213
|
}
|
|
4924
|
-
), /* @__PURE__ */
|
|
5214
|
+
), /* @__PURE__ */ import_react56.default.createElement(
|
|
4925
5215
|
ProfitAndLossRow,
|
|
4926
5216
|
{
|
|
4927
5217
|
lineItem: data.taxes,
|
|
4928
5218
|
direction: "DEBIT" /* DEBIT */,
|
|
4929
|
-
lockExpanded
|
|
5219
|
+
lockExpanded,
|
|
5220
|
+
scope: "expenses",
|
|
5221
|
+
setSidebarScope
|
|
4930
5222
|
}
|
|
4931
|
-
), /* @__PURE__ */
|
|
5223
|
+
), /* @__PURE__ */ import_react56.default.createElement(
|
|
4932
5224
|
ProfitAndLossRow,
|
|
4933
5225
|
{
|
|
4934
5226
|
lineItem: {
|
|
@@ -4939,26 +5231,26 @@ var ProfitAndLossTable = ({ lockExpanded }) => {
|
|
|
4939
5231
|
direction: "CREDIT" /* CREDIT */,
|
|
4940
5232
|
lockExpanded
|
|
4941
5233
|
}
|
|
4942
|
-
)), /* @__PURE__ */
|
|
5234
|
+
)), data.other_outflows || data.personal_expenses ? /* @__PURE__ */ import_react56.default.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table__outflows" }, /* @__PURE__ */ import_react56.default.createElement(
|
|
4943
5235
|
ProfitAndLossRow,
|
|
4944
5236
|
{
|
|
4945
5237
|
lineItem: data.other_outflows,
|
|
4946
5238
|
direction: "DEBIT" /* DEBIT */,
|
|
4947
5239
|
lockExpanded
|
|
4948
5240
|
}
|
|
4949
|
-
), /* @__PURE__ */
|
|
5241
|
+
), /* @__PURE__ */ import_react56.default.createElement(
|
|
4950
5242
|
ProfitAndLossRow,
|
|
4951
5243
|
{
|
|
4952
5244
|
lineItem: data.personal_expenses,
|
|
4953
5245
|
direction: "DEBIT" /* DEBIT */,
|
|
4954
5246
|
lockExpanded
|
|
4955
5247
|
}
|
|
4956
|
-
)));
|
|
5248
|
+
)) : null);
|
|
4957
5249
|
};
|
|
4958
5250
|
|
|
4959
5251
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
4960
5252
|
var import_date_fns13 = require("date-fns");
|
|
4961
|
-
var PNLContext = (0,
|
|
5253
|
+
var PNLContext = (0, import_react57.createContext)({
|
|
4962
5254
|
data: void 0,
|
|
4963
5255
|
filteredData: [],
|
|
4964
5256
|
filteredTotal: void 0,
|
|
@@ -4987,7 +5279,7 @@ var PNLContext = (0, import_react55.createContext)({
|
|
|
4987
5279
|
});
|
|
4988
5280
|
var ProfitAndLoss = ({ children, tagFilter, reportingBasis }) => {
|
|
4989
5281
|
const contextData = useProfitAndLoss({ tagFilter, reportingBasis });
|
|
4990
|
-
return /* @__PURE__ */
|
|
5282
|
+
return /* @__PURE__ */ import_react57.default.createElement(PNLContext.Provider, { value: contextData }, /* @__PURE__ */ import_react57.default.createElement("div", { className: "Layer__component Layer__profit-and-loss" }, children));
|
|
4991
5283
|
};
|
|
4992
5284
|
ProfitAndLoss.Chart = ProfitAndLossChart;
|
|
4993
5285
|
ProfitAndLoss.Context = PNLContext;
|
|
@@ -4996,15 +5288,218 @@ ProfitAndLoss.Summaries = ProfitAndLossSummaries;
|
|
|
4996
5288
|
ProfitAndLoss.Table = ProfitAndLossTable;
|
|
4997
5289
|
|
|
4998
5290
|
// src/components/ProfitAndLossView/ProfitAndLossView.tsx
|
|
4999
|
-
var
|
|
5291
|
+
var import_react62 = __toESM(require("react"));
|
|
5000
5292
|
|
|
5001
5293
|
// src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
|
|
5002
|
-
var
|
|
5003
|
-
|
|
5294
|
+
var import_react61 = __toESM(require("react"));
|
|
5295
|
+
|
|
5296
|
+
// src/icons/X.tsx
|
|
5297
|
+
var React69 = __toESM(require("react"));
|
|
5298
|
+
var X = ({ size = 18, ...props }) => /* @__PURE__ */ React69.createElement(
|
|
5299
|
+
"svg",
|
|
5300
|
+
{
|
|
5301
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5302
|
+
viewBox: "0 0 18 18",
|
|
5303
|
+
fill: "none",
|
|
5304
|
+
...props,
|
|
5305
|
+
width: size,
|
|
5306
|
+
height: size
|
|
5307
|
+
},
|
|
5308
|
+
/* @__PURE__ */ React69.createElement(
|
|
5309
|
+
"path",
|
|
5310
|
+
{
|
|
5311
|
+
d: "M13.5 4.5L4.5 13.5",
|
|
5312
|
+
stroke: "currentColor",
|
|
5313
|
+
strokeLinecap: "round",
|
|
5314
|
+
strokeLinejoin: "round"
|
|
5315
|
+
}
|
|
5316
|
+
),
|
|
5317
|
+
/* @__PURE__ */ React69.createElement(
|
|
5318
|
+
"path",
|
|
5319
|
+
{
|
|
5320
|
+
d: "M4.5 4.5L13.5 13.5",
|
|
5321
|
+
stroke: "currentColor",
|
|
5322
|
+
strokeLinecap: "round",
|
|
5323
|
+
strokeLinejoin: "round"
|
|
5324
|
+
}
|
|
5325
|
+
)
|
|
5326
|
+
);
|
|
5327
|
+
var X_default = X;
|
|
5328
|
+
|
|
5329
|
+
// src/components/ProfitAndLossDetailedCharts/DetailedChart.tsx
|
|
5330
|
+
var import_react58 = __toESM(require("react"));
|
|
5331
|
+
var import_recharts3 = require("recharts");
|
|
5332
|
+
var DetailedChart = ({
|
|
5333
|
+
filteredData,
|
|
5334
|
+
filteredTotal,
|
|
5335
|
+
hoveredItem,
|
|
5336
|
+
setHoveredItem,
|
|
5337
|
+
sidebarScope,
|
|
5338
|
+
date
|
|
5339
|
+
}) => {
|
|
5340
|
+
const chartData = (0, import_react58.useMemo)(() => {
|
|
5341
|
+
if (!filteredData) {
|
|
5342
|
+
return [];
|
|
5343
|
+
}
|
|
5344
|
+
return filteredData.map((x) => {
|
|
5345
|
+
if (x.hidden) {
|
|
5346
|
+
return {
|
|
5347
|
+
name: x.display_name,
|
|
5348
|
+
value: 0
|
|
5349
|
+
};
|
|
5350
|
+
}
|
|
5351
|
+
return {
|
|
5352
|
+
name: x.display_name,
|
|
5353
|
+
value: x.value
|
|
5354
|
+
};
|
|
5355
|
+
});
|
|
5356
|
+
}, [filteredData]);
|
|
5357
|
+
return /* @__PURE__ */ import_react58.default.createElement("div", { className: "chart-field" }, /* @__PURE__ */ import_react58.default.createElement("div", { className: "header--tablet" }, /* @__PURE__ */ import_react58.default.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, humanizeTitle(sidebarScope)), /* @__PURE__ */ import_react58.default.createElement(ProfitAndLossDatePicker, null)), /* @__PURE__ */ import_react58.default.createElement("div", { className: "chart-container" }, /* @__PURE__ */ import_react58.default.createElement(import_recharts3.ResponsiveContainer, null, /* @__PURE__ */ import_react58.default.createElement(import_recharts3.PieChart, null, /* @__PURE__ */ import_react58.default.createElement(
|
|
5358
|
+
import_recharts3.Pie,
|
|
5359
|
+
{
|
|
5360
|
+
data: chartData,
|
|
5361
|
+
dataKey: "value",
|
|
5362
|
+
nameKey: "name",
|
|
5363
|
+
cx: "50%",
|
|
5364
|
+
cy: "50%",
|
|
5365
|
+
innerRadius: 105,
|
|
5366
|
+
outerRadius: 120,
|
|
5367
|
+
paddingAngle: 0.5,
|
|
5368
|
+
fill: "#8884d8",
|
|
5369
|
+
animationDuration: 200,
|
|
5370
|
+
animationEasing: "ease-in-out"
|
|
5371
|
+
},
|
|
5372
|
+
chartData.map((entry, index) => {
|
|
5373
|
+
const colorConfig = DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length];
|
|
5374
|
+
let fill = colorConfig.color;
|
|
5375
|
+
let opacity = colorConfig.opacity;
|
|
5376
|
+
let active = true;
|
|
5377
|
+
if (hoveredItem && entry.name !== hoveredItem) {
|
|
5378
|
+
active = false;
|
|
5379
|
+
fill = void 0;
|
|
5380
|
+
opacity = INACTIVE_OPACITY_LEVELS[index % INACTIVE_OPACITY_LEVELS.length];
|
|
5381
|
+
}
|
|
5382
|
+
return /* @__PURE__ */ import_react58.default.createElement(
|
|
5383
|
+
import_recharts3.Cell,
|
|
5384
|
+
{
|
|
5385
|
+
key: `cell-${index}`,
|
|
5386
|
+
className: `Layer__profit-and-loss-detailed-charts__pie ${hoveredItem && active ? "active" : "inactive"}`,
|
|
5387
|
+
style: { fill },
|
|
5388
|
+
opacity,
|
|
5389
|
+
onMouseEnter: () => setHoveredItem(entry.name),
|
|
5390
|
+
onMouseLeave: () => setHoveredItem(void 0)
|
|
5391
|
+
}
|
|
5392
|
+
);
|
|
5393
|
+
}),
|
|
5394
|
+
/* @__PURE__ */ import_react58.default.createElement(
|
|
5395
|
+
import_recharts3.Label,
|
|
5396
|
+
{
|
|
5397
|
+
position: "center",
|
|
5398
|
+
value: "Total",
|
|
5399
|
+
className: "pie-center-label-title",
|
|
5400
|
+
content: (props) => {
|
|
5401
|
+
const { cx, cy } = props.viewBox ?? {
|
|
5402
|
+
cx: 0,
|
|
5403
|
+
cy: 0
|
|
5404
|
+
};
|
|
5405
|
+
const positioningProps = {
|
|
5406
|
+
x: cx,
|
|
5407
|
+
y: (cy || 0) - 15,
|
|
5408
|
+
textAnchor: "middle",
|
|
5409
|
+
verticalAnchor: "middle"
|
|
5410
|
+
};
|
|
5411
|
+
let text = "Total";
|
|
5412
|
+
if (hoveredItem) {
|
|
5413
|
+
text = hoveredItem;
|
|
5414
|
+
}
|
|
5415
|
+
return /* @__PURE__ */ import_react58.default.createElement(
|
|
5416
|
+
import_recharts3.Text,
|
|
5417
|
+
{
|
|
5418
|
+
...positioningProps,
|
|
5419
|
+
className: "pie-center-label__title"
|
|
5420
|
+
},
|
|
5421
|
+
text
|
|
5422
|
+
);
|
|
5423
|
+
}
|
|
5424
|
+
}
|
|
5425
|
+
),
|
|
5426
|
+
/* @__PURE__ */ import_react58.default.createElement(
|
|
5427
|
+
import_recharts3.Label,
|
|
5428
|
+
{
|
|
5429
|
+
position: "center",
|
|
5430
|
+
value: "Total",
|
|
5431
|
+
className: "pie-center-label-title",
|
|
5432
|
+
content: (props) => {
|
|
5433
|
+
const { cx, cy } = props.viewBox ?? {
|
|
5434
|
+
cx: 0,
|
|
5435
|
+
cy: 0
|
|
5436
|
+
};
|
|
5437
|
+
const positioningProps = {
|
|
5438
|
+
x: cx,
|
|
5439
|
+
y: (cy || 0) + 5,
|
|
5440
|
+
textAnchor: "middle",
|
|
5441
|
+
verticalAnchor: "middle"
|
|
5442
|
+
};
|
|
5443
|
+
let value = filteredTotal;
|
|
5444
|
+
if (hoveredItem) {
|
|
5445
|
+
value = filteredData.find(
|
|
5446
|
+
(x) => x.display_name === hoveredItem
|
|
5447
|
+
)?.value;
|
|
5448
|
+
}
|
|
5449
|
+
return /* @__PURE__ */ import_react58.default.createElement(
|
|
5450
|
+
import_recharts3.Text,
|
|
5451
|
+
{
|
|
5452
|
+
...positioningProps,
|
|
5453
|
+
className: "pie-center-label__value"
|
|
5454
|
+
},
|
|
5455
|
+
`$${centsToDollars(value)}`
|
|
5456
|
+
);
|
|
5457
|
+
}
|
|
5458
|
+
}
|
|
5459
|
+
),
|
|
5460
|
+
/* @__PURE__ */ import_react58.default.createElement(
|
|
5461
|
+
import_recharts3.Label,
|
|
5462
|
+
{
|
|
5463
|
+
position: "center",
|
|
5464
|
+
value: "Total",
|
|
5465
|
+
className: "pie-center-label-title",
|
|
5466
|
+
content: (props) => {
|
|
5467
|
+
const { cx, cy } = props.viewBox ?? {
|
|
5468
|
+
cx: 0,
|
|
5469
|
+
cy: 0
|
|
5470
|
+
};
|
|
5471
|
+
const positioningProps = {
|
|
5472
|
+
x: cx,
|
|
5473
|
+
y: (cy || 0) + 25,
|
|
5474
|
+
height: 20,
|
|
5475
|
+
textAnchor: "middle",
|
|
5476
|
+
verticalAnchor: "middle"
|
|
5477
|
+
};
|
|
5478
|
+
if (hoveredItem) {
|
|
5479
|
+
return /* @__PURE__ */ import_react58.default.createElement(
|
|
5480
|
+
import_recharts3.Text,
|
|
5481
|
+
{
|
|
5482
|
+
...positioningProps,
|
|
5483
|
+
className: "pie-center-label__share"
|
|
5484
|
+
},
|
|
5485
|
+
`${formatPercent(
|
|
5486
|
+
filteredData.find((x) => x.display_name === hoveredItem)?.share
|
|
5487
|
+
)}%`
|
|
5488
|
+
);
|
|
5489
|
+
}
|
|
5490
|
+
return;
|
|
5491
|
+
}
|
|
5492
|
+
}
|
|
5493
|
+
)
|
|
5494
|
+
)))));
|
|
5495
|
+
};
|
|
5496
|
+
|
|
5497
|
+
// src/components/ProfitAndLossDetailedCharts/DetailedTable.tsx
|
|
5498
|
+
var import_react59 = __toESM(require("react"));
|
|
5004
5499
|
|
|
5005
5500
|
// src/icons/SortArrows.tsx
|
|
5006
|
-
var
|
|
5007
|
-
var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */
|
|
5501
|
+
var React71 = __toESM(require("react"));
|
|
5502
|
+
var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React71.createElement(
|
|
5008
5503
|
"svg",
|
|
5009
5504
|
{
|
|
5010
5505
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -5014,7 +5509,7 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React66.createElem
|
|
|
5014
5509
|
width: size,
|
|
5015
5510
|
height: size
|
|
5016
5511
|
},
|
|
5017
|
-
/* @__PURE__ */
|
|
5512
|
+
/* @__PURE__ */ React71.createElement("g", { "clip-path": "url(#clip0_1758_75388)" }, /* @__PURE__ */ React71.createElement(
|
|
5018
5513
|
"path",
|
|
5019
5514
|
{
|
|
5020
5515
|
d: "M1.33325 8.5L3.99992 11.1667L6.66659 8.5",
|
|
@@ -5023,7 +5518,7 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React66.createElem
|
|
|
5023
5518
|
"stroke-linejoin": "round",
|
|
5024
5519
|
className: "desc-arrow"
|
|
5025
5520
|
}
|
|
5026
|
-
), /* @__PURE__ */
|
|
5521
|
+
), /* @__PURE__ */ React71.createElement(
|
|
5027
5522
|
"path",
|
|
5028
5523
|
{
|
|
5029
5524
|
d: "M4 2.5L4 11.1667",
|
|
@@ -5032,7 +5527,7 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React66.createElem
|
|
|
5032
5527
|
"stroke-linejoin": "round",
|
|
5033
5528
|
className: "desc-arrow"
|
|
5034
5529
|
}
|
|
5035
|
-
), /* @__PURE__ */
|
|
5530
|
+
), /* @__PURE__ */ React71.createElement(
|
|
5036
5531
|
"path",
|
|
5037
5532
|
{
|
|
5038
5533
|
d: "M5.99988 5.16602L8.66654 2.49935L11.3332 5.16602",
|
|
@@ -5041,7 +5536,7 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React66.createElem
|
|
|
5041
5536
|
"stroke-linejoin": "round",
|
|
5042
5537
|
className: "asc-arrow"
|
|
5043
5538
|
}
|
|
5044
|
-
), /* @__PURE__ */
|
|
5539
|
+
), /* @__PURE__ */ React71.createElement(
|
|
5045
5540
|
"path",
|
|
5046
5541
|
{
|
|
5047
5542
|
d: "M8.66663 11.166L8.66663 2.49935",
|
|
@@ -5051,7 +5546,7 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React66.createElem
|
|
|
5051
5546
|
className: "asc-arrow"
|
|
5052
5547
|
}
|
|
5053
5548
|
)),
|
|
5054
|
-
/* @__PURE__ */
|
|
5549
|
+
/* @__PURE__ */ React71.createElement("defs", null, /* @__PURE__ */ React71.createElement("clipPath", { id: "clip0_1758_75388" }, /* @__PURE__ */ React71.createElement(
|
|
5055
5550
|
"rect",
|
|
5056
5551
|
{
|
|
5057
5552
|
width: "12",
|
|
@@ -5063,121 +5558,119 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React66.createElem
|
|
|
5063
5558
|
);
|
|
5064
5559
|
var SortArrows_default = SortArrows;
|
|
5065
5560
|
|
|
5066
|
-
// src/
|
|
5067
|
-
var
|
|
5068
|
-
var
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5561
|
+
// src/components/ProfitAndLossDetailedCharts/DetailedTable.tsx
|
|
5562
|
+
var import_classnames24 = __toESM(require("classnames"));
|
|
5563
|
+
var DetailedTable = ({
|
|
5564
|
+
filteredData,
|
|
5565
|
+
sidebarScope,
|
|
5566
|
+
filters,
|
|
5567
|
+
sortBy,
|
|
5568
|
+
hoveredItem,
|
|
5569
|
+
setHoveredItem
|
|
5570
|
+
}) => {
|
|
5571
|
+
const buildColClass = (column) => {
|
|
5572
|
+
return (0, import_classnames24.default)(
|
|
5573
|
+
"Layer__sortable-col",
|
|
5574
|
+
sidebarScope && filters[sidebarScope]?.sortBy === column ? `sort--${(sidebarScope && filters[sidebarScope]?.sortDirection) ?? "desc"}` : ""
|
|
5575
|
+
);
|
|
5576
|
+
};
|
|
5577
|
+
return /* @__PURE__ */ import_react59.default.createElement("div", { className: "details-container" }, /* @__PURE__ */ import_react59.default.createElement("div", { className: "table" }, /* @__PURE__ */ import_react59.default.createElement("table", null, /* @__PURE__ */ import_react59.default.createElement("thead", null, /* @__PURE__ */ import_react59.default.createElement("tr", null, /* @__PURE__ */ import_react59.default.createElement(
|
|
5578
|
+
"th",
|
|
5080
5579
|
{
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
}
|
|
5086
|
-
),
|
|
5087
|
-
|
|
5088
|
-
"path",
|
|
5580
|
+
className: buildColClass("category"),
|
|
5581
|
+
onClick: () => sortBy(sidebarScope ?? "expenses", "category")
|
|
5582
|
+
},
|
|
5583
|
+
"Expense/Sale ",
|
|
5584
|
+
/* @__PURE__ */ import_react59.default.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
5585
|
+
), /* @__PURE__ */ import_react59.default.createElement(
|
|
5586
|
+
"th",
|
|
5089
5587
|
{
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5588
|
+
className: buildColClass("type"),
|
|
5589
|
+
onClick: () => sortBy(sidebarScope ?? "expenses", "type")
|
|
5590
|
+
},
|
|
5591
|
+
"Type ",
|
|
5592
|
+
/* @__PURE__ */ import_react59.default.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
5593
|
+
), /* @__PURE__ */ import_react59.default.createElement("th", null), /* @__PURE__ */ import_react59.default.createElement(
|
|
5594
|
+
"th",
|
|
5595
|
+
{
|
|
5596
|
+
className: buildColClass("value"),
|
|
5597
|
+
onClick: () => sortBy(sidebarScope ?? "expenses", "value")
|
|
5598
|
+
},
|
|
5599
|
+
"Value ",
|
|
5600
|
+
/* @__PURE__ */ import_react59.default.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
5601
|
+
))), /* @__PURE__ */ import_react59.default.createElement("tbody", null, filteredData.filter((x) => !x.hidden).map((item, idx) => {
|
|
5602
|
+
const colorConfig = DEFAULT_CHART_COLORS[idx % DEFAULT_CHART_COLORS.length];
|
|
5603
|
+
return /* @__PURE__ */ import_react59.default.createElement(
|
|
5604
|
+
"tr",
|
|
5605
|
+
{
|
|
5606
|
+
key: `pl-side-table-item-${idx}`,
|
|
5607
|
+
className: (0, import_classnames24.default)(
|
|
5608
|
+
"Layer__profit-and-loss-detailed-table__row",
|
|
5609
|
+
hoveredItem && hoveredItem === item.display_name ? "active" : ""
|
|
5610
|
+
),
|
|
5611
|
+
onMouseEnter: () => setHoveredItem(item.display_name),
|
|
5612
|
+
onMouseLeave: () => setHoveredItem(void 0)
|
|
5613
|
+
},
|
|
5614
|
+
/* @__PURE__ */ import_react59.default.createElement("td", { className: "category-col" }, item.display_name),
|
|
5615
|
+
/* @__PURE__ */ import_react59.default.createElement("td", { className: "type-col" }, item.type),
|
|
5616
|
+
/* @__PURE__ */ import_react59.default.createElement("td", { className: "value-col" }, "$", centsToDollars(item.value)),
|
|
5617
|
+
/* @__PURE__ */ import_react59.default.createElement("td", { className: "share-col" }, /* @__PURE__ */ import_react59.default.createElement("span", { className: "share-cell-content" }, formatPercent(item.share), "%", /* @__PURE__ */ import_react59.default.createElement(
|
|
5618
|
+
"div",
|
|
5619
|
+
{
|
|
5620
|
+
className: "share-icon",
|
|
5621
|
+
style: {
|
|
5622
|
+
background: colorConfig.color,
|
|
5623
|
+
opacity: colorConfig.opacity
|
|
5624
|
+
}
|
|
5625
|
+
}
|
|
5626
|
+
)))
|
|
5627
|
+
);
|
|
5628
|
+
})))));
|
|
5629
|
+
};
|
|
5630
|
+
|
|
5631
|
+
// src/components/ProfitAndLossDetailedCharts/Filters.tsx
|
|
5632
|
+
var import_react60 = __toESM(require("react"));
|
|
5633
|
+
var import_react_select4 = __toESM(require("react-select"));
|
|
5634
|
+
var Filters = ({
|
|
5635
|
+
filteredData,
|
|
5636
|
+
sidebarScope,
|
|
5637
|
+
filters,
|
|
5638
|
+
setFilterTypes
|
|
5639
|
+
}) => {
|
|
5640
|
+
return /* @__PURE__ */ import_react60.default.createElement("div", { className: "filters" }, /* @__PURE__ */ import_react60.default.createElement(Text, { size: "sm" /* sm */, className: "Layer__label" }, "Filters"), /* @__PURE__ */ import_react60.default.createElement(
|
|
5641
|
+
import_react_select4.default,
|
|
5642
|
+
{
|
|
5643
|
+
className: "Layer__select type-select",
|
|
5644
|
+
classNamePrefix: "Layer__select",
|
|
5645
|
+
value: sidebarScope && filters[sidebarScope]?.types ? sidebarScope && filters[sidebarScope]?.types?.map((x) => ({
|
|
5646
|
+
value: x,
|
|
5647
|
+
label: x
|
|
5648
|
+
})) : [],
|
|
5649
|
+
isMulti: true,
|
|
5650
|
+
isClearable: false,
|
|
5651
|
+
options: [...new Set(filteredData?.map((x) => x.type))].map((x) => ({
|
|
5652
|
+
label: x,
|
|
5653
|
+
value: x
|
|
5654
|
+
})),
|
|
5655
|
+
onChange: (selected) => {
|
|
5656
|
+
setFilterTypes(
|
|
5657
|
+
sidebarScope ?? "expenses",
|
|
5658
|
+
selected.map((x) => x.value)
|
|
5659
|
+
);
|
|
5660
|
+
},
|
|
5661
|
+
components: {
|
|
5662
|
+
DropdownIndicator: (props) => /* @__PURE__ */ import_react60.default.createElement(import_react_select4.components.DropdownIndicator, { ...props }, /* @__PURE__ */ import_react60.default.createElement(ChevronDown_default, null)),
|
|
5663
|
+
Placeholder: (props) => /* @__PURE__ */ import_react60.default.createElement(import_react_select4.components.Placeholder, { ...props }, /* @__PURE__ */ import_react60.default.createElement("div", { className: "Layer__select__multi-all-placeholder-badge" }, "All"))
|
|
5664
|
+
}
|
|
5094
5665
|
}
|
|
5095
|
-
)
|
|
5096
|
-
|
|
5097
|
-
var X_default = X;
|
|
5666
|
+
));
|
|
5667
|
+
};
|
|
5098
5668
|
|
|
5099
5669
|
// src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
|
|
5100
|
-
var
|
|
5670
|
+
var import_classnames25 = __toESM(require("classnames"));
|
|
5101
5671
|
var import_date_fns14 = require("date-fns");
|
|
5102
|
-
var import_recharts2 = require("recharts");
|
|
5103
|
-
var INACTIVE_OPACITY_LEVELS = [0.85, 0.7, 0.66, 0.55, 0.4, 0.33, 0.25, 0.15];
|
|
5104
|
-
var DEFAULT_CHART_COLORS = [
|
|
5105
|
-
{
|
|
5106
|
-
color: "#7417B3",
|
|
5107
|
-
opacity: 1
|
|
5108
|
-
},
|
|
5109
|
-
{
|
|
5110
|
-
color: "#7417B3",
|
|
5111
|
-
opacity: 0.8
|
|
5112
|
-
},
|
|
5113
|
-
{
|
|
5114
|
-
color: "#7417B3",
|
|
5115
|
-
opacity: 0.6
|
|
5116
|
-
},
|
|
5117
|
-
{
|
|
5118
|
-
color: "#7417B3",
|
|
5119
|
-
opacity: 0.4
|
|
5120
|
-
},
|
|
5121
|
-
{
|
|
5122
|
-
color: "#7417B3",
|
|
5123
|
-
opacity: 0.2
|
|
5124
|
-
},
|
|
5125
|
-
{
|
|
5126
|
-
color: "#7417B3",
|
|
5127
|
-
opacity: 0.1
|
|
5128
|
-
},
|
|
5129
|
-
{
|
|
5130
|
-
color: "#006A80",
|
|
5131
|
-
opacity: 1
|
|
5132
|
-
},
|
|
5133
|
-
{
|
|
5134
|
-
color: "#006A80",
|
|
5135
|
-
opacity: 0.8
|
|
5136
|
-
},
|
|
5137
|
-
{
|
|
5138
|
-
color: "#006A80",
|
|
5139
|
-
opacity: 0.6
|
|
5140
|
-
},
|
|
5141
|
-
{
|
|
5142
|
-
color: "#006A80",
|
|
5143
|
-
opacity: 0.4
|
|
5144
|
-
},
|
|
5145
|
-
{
|
|
5146
|
-
color: "#006A80",
|
|
5147
|
-
opacity: 0.2
|
|
5148
|
-
},
|
|
5149
|
-
{
|
|
5150
|
-
color: "#006A80",
|
|
5151
|
-
opacity: 0.1
|
|
5152
|
-
},
|
|
5153
|
-
{
|
|
5154
|
-
color: "#009930",
|
|
5155
|
-
opacity: 1
|
|
5156
|
-
},
|
|
5157
|
-
{
|
|
5158
|
-
color: "#009930",
|
|
5159
|
-
opacity: 0.8
|
|
5160
|
-
},
|
|
5161
|
-
{
|
|
5162
|
-
color: "#009930",
|
|
5163
|
-
opacity: 0.6
|
|
5164
|
-
},
|
|
5165
|
-
{
|
|
5166
|
-
color: "#009930",
|
|
5167
|
-
opacity: 0.4
|
|
5168
|
-
},
|
|
5169
|
-
{
|
|
5170
|
-
color: "#009930",
|
|
5171
|
-
opacity: 0.2
|
|
5172
|
-
},
|
|
5173
|
-
{
|
|
5174
|
-
color: "#009930",
|
|
5175
|
-
opacity: 0.1
|
|
5176
|
-
}
|
|
5177
|
-
];
|
|
5178
5672
|
var ProfitAndLossDetailedCharts = () => {
|
|
5179
5673
|
const {
|
|
5180
|
-
data,
|
|
5181
5674
|
filteredData,
|
|
5182
5675
|
filteredTotal,
|
|
5183
5676
|
sortBy,
|
|
@@ -5187,275 +5680,77 @@ var ProfitAndLossDetailedCharts = () => {
|
|
|
5187
5680
|
sidebarScope,
|
|
5188
5681
|
setSidebarScope,
|
|
5189
5682
|
setFilterTypes
|
|
5190
|
-
} = (0,
|
|
5191
|
-
const [hoveredItem, setHoveredItem] = (0,
|
|
5192
|
-
|
|
5193
|
-
if (!filteredData) {
|
|
5194
|
-
return [];
|
|
5195
|
-
}
|
|
5196
|
-
return filteredData.map((x) => {
|
|
5197
|
-
if (x.hidden) {
|
|
5198
|
-
return {
|
|
5199
|
-
name: x.display_name,
|
|
5200
|
-
value: 0
|
|
5201
|
-
};
|
|
5202
|
-
}
|
|
5203
|
-
return {
|
|
5204
|
-
name: x.display_name,
|
|
5205
|
-
value: x.value
|
|
5206
|
-
};
|
|
5207
|
-
});
|
|
5208
|
-
}, [filteredData]);
|
|
5209
|
-
const buildColClass = (column) => {
|
|
5210
|
-
return (0, import_classnames24.default)(
|
|
5211
|
-
"Layer__sortable-col",
|
|
5212
|
-
sidebarScope && filters[sidebarScope]?.sortBy === column ? `sort--${(sidebarScope && filters[sidebarScope]?.sortDirection) ?? "desc"}` : ""
|
|
5213
|
-
);
|
|
5214
|
-
};
|
|
5215
|
-
return /* @__PURE__ */ import_react56.default.createElement(
|
|
5683
|
+
} = (0, import_react61.useContext)(ProfitAndLoss.Context);
|
|
5684
|
+
const [hoveredItem, setHoveredItem] = (0, import_react61.useState)();
|
|
5685
|
+
return /* @__PURE__ */ import_react61.default.createElement(
|
|
5216
5686
|
"div",
|
|
5217
5687
|
{
|
|
5218
|
-
className: (0,
|
|
5688
|
+
className: (0, import_classnames25.default)(
|
|
5219
5689
|
"Layer__profit-and-loss__side-panel",
|
|
5220
5690
|
sidebarScope && "open"
|
|
5221
5691
|
)
|
|
5222
5692
|
},
|
|
5223
|
-
/* @__PURE__ */
|
|
5693
|
+
/* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts" }, /* @__PURE__ */ import_react61.default.createElement("header", { className: "Layer__profit-and-loss-detailed-charts__header" }, /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__head" }, /* @__PURE__ */ import_react61.default.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, humanizeTitle(sidebarScope)), /* @__PURE__ */ import_react61.default.createElement(Text, { size: "sm" /* sm */, className: "date" }, (0, import_date_fns14.format)(dateRange.startDate, "LLLL, y")), /* @__PURE__ */ import_react61.default.createElement(ProfitAndLossDatePicker, null)), /* @__PURE__ */ import_react61.default.createElement(
|
|
5224
5694
|
Button,
|
|
5225
5695
|
{
|
|
5226
|
-
rightIcon: /* @__PURE__ */
|
|
5696
|
+
rightIcon: /* @__PURE__ */ import_react61.default.createElement(X_default, null),
|
|
5227
5697
|
iconOnly: true,
|
|
5228
5698
|
onClick: () => setSidebarScope(void 0),
|
|
5229
5699
|
variant: "secondary" /* secondary */
|
|
5230
5700
|
}
|
|
5231
|
-
)), /* @__PURE__ */
|
|
5232
|
-
|
|
5701
|
+
)), /* @__PURE__ */ import_react61.default.createElement("header", { className: "Layer__profit-and-loss-detailed-charts__header--tablet" }, /* @__PURE__ */ import_react61.default.createElement(
|
|
5702
|
+
Button,
|
|
5233
5703
|
{
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
nameKey: "name",
|
|
5237
|
-
cx: "50%",
|
|
5238
|
-
cy: "50%",
|
|
5239
|
-
innerRadius: 105,
|
|
5240
|
-
outerRadius: 120,
|
|
5241
|
-
paddingAngle: 0.5,
|
|
5242
|
-
fill: "#8884d8"
|
|
5704
|
+
onClick: () => setSidebarScope(void 0),
|
|
5705
|
+
variant: "secondary" /* secondary */
|
|
5243
5706
|
},
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
let opacity = colorConfig.opacity;
|
|
5248
|
-
let active = true;
|
|
5249
|
-
if (hoveredItem && entry.name !== hoveredItem) {
|
|
5250
|
-
active = false;
|
|
5251
|
-
fill = void 0;
|
|
5252
|
-
opacity = INACTIVE_OPACITY_LEVELS[index % INACTIVE_OPACITY_LEVELS.length];
|
|
5253
|
-
}
|
|
5254
|
-
return /* @__PURE__ */ import_react56.default.createElement(
|
|
5255
|
-
import_recharts2.Cell,
|
|
5256
|
-
{
|
|
5257
|
-
key: `cell-${index}`,
|
|
5258
|
-
className: `Layer__profit-and-loss-detailed-charts__pie ${hoveredItem && active ? "active" : "inactive"}`,
|
|
5259
|
-
style: { fill },
|
|
5260
|
-
opacity,
|
|
5261
|
-
onMouseEnter: () => setHoveredItem(entry.name),
|
|
5262
|
-
onMouseLeave: () => setHoveredItem(void 0)
|
|
5263
|
-
}
|
|
5264
|
-
);
|
|
5265
|
-
}),
|
|
5266
|
-
/* @__PURE__ */ import_react56.default.createElement(
|
|
5267
|
-
import_recharts2.Label,
|
|
5268
|
-
{
|
|
5269
|
-
position: "center",
|
|
5270
|
-
value: "Total",
|
|
5271
|
-
className: "pie-center-label-title",
|
|
5272
|
-
content: (props) => {
|
|
5273
|
-
const { cx, cy } = props.viewBox ?? {
|
|
5274
|
-
cx: 0,
|
|
5275
|
-
cy: 0
|
|
5276
|
-
};
|
|
5277
|
-
const positioningProps = {
|
|
5278
|
-
x: cx,
|
|
5279
|
-
y: (cy || 0) - 15,
|
|
5280
|
-
textAnchor: "middle",
|
|
5281
|
-
verticalAnchor: "middle"
|
|
5282
|
-
};
|
|
5283
|
-
let text = "Total";
|
|
5284
|
-
if (hoveredItem) {
|
|
5285
|
-
text = hoveredItem;
|
|
5286
|
-
}
|
|
5287
|
-
return /* @__PURE__ */ import_react56.default.createElement(
|
|
5288
|
-
import_recharts2.Text,
|
|
5289
|
-
{
|
|
5290
|
-
...positioningProps,
|
|
5291
|
-
className: "pie-center-label__title"
|
|
5292
|
-
},
|
|
5293
|
-
text
|
|
5294
|
-
);
|
|
5295
|
-
}
|
|
5296
|
-
}
|
|
5297
|
-
),
|
|
5298
|
-
/* @__PURE__ */ import_react56.default.createElement(
|
|
5299
|
-
import_recharts2.Label,
|
|
5300
|
-
{
|
|
5301
|
-
position: "center",
|
|
5302
|
-
value: "Total",
|
|
5303
|
-
className: "pie-center-label-title",
|
|
5304
|
-
content: (props) => {
|
|
5305
|
-
const { cx, cy } = props.viewBox ?? {
|
|
5306
|
-
cx: 0,
|
|
5307
|
-
cy: 0
|
|
5308
|
-
};
|
|
5309
|
-
const positioningProps = {
|
|
5310
|
-
x: cx,
|
|
5311
|
-
y: (cy || 0) + 5,
|
|
5312
|
-
textAnchor: "middle",
|
|
5313
|
-
verticalAnchor: "middle"
|
|
5314
|
-
};
|
|
5315
|
-
let value = filteredTotal;
|
|
5316
|
-
if (hoveredItem) {
|
|
5317
|
-
value = filteredData.find(
|
|
5318
|
-
(x) => x.display_name === hoveredItem
|
|
5319
|
-
)?.value;
|
|
5320
|
-
}
|
|
5321
|
-
return /* @__PURE__ */ import_react56.default.createElement(
|
|
5322
|
-
import_recharts2.Text,
|
|
5323
|
-
{
|
|
5324
|
-
...positioningProps,
|
|
5325
|
-
className: "pie-center-label__value"
|
|
5326
|
-
},
|
|
5327
|
-
`$${centsToDollars(value)}`
|
|
5328
|
-
);
|
|
5329
|
-
}
|
|
5330
|
-
}
|
|
5331
|
-
),
|
|
5332
|
-
/* @__PURE__ */ import_react56.default.createElement(
|
|
5333
|
-
import_recharts2.Label,
|
|
5334
|
-
{
|
|
5335
|
-
position: "center",
|
|
5336
|
-
value: "Total",
|
|
5337
|
-
className: "pie-center-label-title",
|
|
5338
|
-
content: (props) => {
|
|
5339
|
-
const { cx, cy } = props.viewBox ?? {
|
|
5340
|
-
cx: 0,
|
|
5341
|
-
cy: 0
|
|
5342
|
-
};
|
|
5343
|
-
const positioningProps = {
|
|
5344
|
-
x: cx,
|
|
5345
|
-
y: (cy || 0) + 25,
|
|
5346
|
-
height: 20,
|
|
5347
|
-
textAnchor: "middle",
|
|
5348
|
-
verticalAnchor: "middle"
|
|
5349
|
-
};
|
|
5350
|
-
if (hoveredItem) {
|
|
5351
|
-
return /* @__PURE__ */ import_react56.default.createElement(
|
|
5352
|
-
import_recharts2.Text,
|
|
5353
|
-
{
|
|
5354
|
-
...positioningProps,
|
|
5355
|
-
className: "pie-center-label__share"
|
|
5356
|
-
},
|
|
5357
|
-
`${formatPercent(
|
|
5358
|
-
filteredData.find(
|
|
5359
|
-
(x) => x.display_name === hoveredItem
|
|
5360
|
-
)?.share
|
|
5361
|
-
)}%`
|
|
5362
|
-
);
|
|
5363
|
-
}
|
|
5364
|
-
return;
|
|
5365
|
-
}
|
|
5366
|
-
}
|
|
5367
|
-
)
|
|
5368
|
-
)))), /* @__PURE__ */ import_react56.default.createElement("div", { className: "filters" }, /* @__PURE__ */ import_react56.default.createElement(Text, { size: "sm" /* sm */, className: "Layer__label" }, "Filters"), /* @__PURE__ */ import_react56.default.createElement(
|
|
5369
|
-
import_react_select3.default,
|
|
5707
|
+
"Back"
|
|
5708
|
+
)), /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__content" }, /* @__PURE__ */ import_react61.default.createElement(
|
|
5709
|
+
DetailedChart,
|
|
5370
5710
|
{
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
isMulti: true,
|
|
5378
|
-
isClearable: false,
|
|
5379
|
-
options: [...new Set(filteredData?.map((x) => x.type))].map((x) => ({
|
|
5380
|
-
label: x,
|
|
5381
|
-
value: x
|
|
5382
|
-
})),
|
|
5383
|
-
onChange: (selected) => {
|
|
5384
|
-
setFilterTypes(
|
|
5385
|
-
sidebarScope ?? "expenses",
|
|
5386
|
-
selected.map((x) => x.value)
|
|
5387
|
-
);
|
|
5388
|
-
}
|
|
5711
|
+
filteredData,
|
|
5712
|
+
filteredTotal,
|
|
5713
|
+
hoveredItem,
|
|
5714
|
+
setHoveredItem,
|
|
5715
|
+
sidebarScope,
|
|
5716
|
+
date: dateRange.startDate
|
|
5389
5717
|
}
|
|
5390
|
-
)
|
|
5391
|
-
|
|
5718
|
+
), /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__table-wrapper" }, /* @__PURE__ */ import_react61.default.createElement(
|
|
5719
|
+
Filters,
|
|
5392
5720
|
{
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
), /* @__PURE__ */
|
|
5399
|
-
|
|
5400
|
-
{
|
|
5401
|
-
className: buildColClass("type"),
|
|
5402
|
-
onClick: () => sortBy(sidebarScope ?? "expenses", "type")
|
|
5403
|
-
},
|
|
5404
|
-
"Type ",
|
|
5405
|
-
/* @__PURE__ */ import_react56.default.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
|
|
5406
|
-
), /* @__PURE__ */ import_react56.default.createElement("th", null), /* @__PURE__ */ import_react56.default.createElement(
|
|
5407
|
-
"th",
|
|
5721
|
+
filteredData,
|
|
5722
|
+
sidebarScope,
|
|
5723
|
+
filters,
|
|
5724
|
+
setFilterTypes
|
|
5725
|
+
}
|
|
5726
|
+
), /* @__PURE__ */ import_react61.default.createElement(
|
|
5727
|
+
DetailedTable,
|
|
5408
5728
|
{
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
"tr",
|
|
5418
|
-
{
|
|
5419
|
-
key: `pl-side-table-item-${idx}`,
|
|
5420
|
-
className: (0, import_classnames24.default)(
|
|
5421
|
-
"Layer__profit-and-loss-detailed-table__row",
|
|
5422
|
-
hoveredItem && hoveredItem !== item.display_name ? "inactive" : ""
|
|
5423
|
-
),
|
|
5424
|
-
onMouseEnter: () => setHoveredItem(item.display_name),
|
|
5425
|
-
onMouseLeave: () => setHoveredItem(void 0)
|
|
5426
|
-
},
|
|
5427
|
-
/* @__PURE__ */ import_react56.default.createElement("td", { className: "category-col" }, item.display_name),
|
|
5428
|
-
/* @__PURE__ */ import_react56.default.createElement("td", { className: "type-col" }, item.type),
|
|
5429
|
-
/* @__PURE__ */ import_react56.default.createElement("td", { className: "value-col" }, "$", centsToDollars(item.value)),
|
|
5430
|
-
/* @__PURE__ */ import_react56.default.createElement("td", { className: "share-col" }, /* @__PURE__ */ import_react56.default.createElement("span", { className: "share-cell-content" }, formatPercent(item.share), "%", /* @__PURE__ */ import_react56.default.createElement(
|
|
5431
|
-
"div",
|
|
5432
|
-
{
|
|
5433
|
-
className: "share-icon",
|
|
5434
|
-
style: {
|
|
5435
|
-
background: colorConfig.color,
|
|
5436
|
-
opacity: colorConfig.opacity
|
|
5437
|
-
}
|
|
5438
|
-
}
|
|
5439
|
-
)))
|
|
5440
|
-
);
|
|
5441
|
-
}))))))
|
|
5729
|
+
filteredData,
|
|
5730
|
+
sidebarScope,
|
|
5731
|
+
filters,
|
|
5732
|
+
sortBy,
|
|
5733
|
+
hoveredItem,
|
|
5734
|
+
setHoveredItem
|
|
5735
|
+
}
|
|
5736
|
+
))))
|
|
5442
5737
|
);
|
|
5443
5738
|
};
|
|
5444
5739
|
|
|
5445
5740
|
// src/components/ProfitAndLossView/ProfitAndLossView.tsx
|
|
5446
5741
|
var COMPONENT_NAME3 = "profit-and-loss";
|
|
5447
5742
|
var ProfitAndLossView = (props) => {
|
|
5448
|
-
return /* @__PURE__ */
|
|
5743
|
+
return /* @__PURE__ */ import_react62.default.createElement(Container, { name: COMPONENT_NAME3 }, /* @__PURE__ */ import_react62.default.createElement(ProfitAndLoss, null, /* @__PURE__ */ import_react62.default.createElement("div", { className: `Layer__${COMPONENT_NAME3}__main-panel` }, /* @__PURE__ */ import_react62.default.createElement(Header, { className: `Layer__${COMPONENT_NAME3}__header` }, /* @__PURE__ */ import_react62.default.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Profit & Loss")), /* @__PURE__ */ import_react62.default.createElement(Components, { ...props })), props.showDetailedCharts !== false && /* @__PURE__ */ import_react62.default.createElement(ProfitAndLossDetailedCharts, null)));
|
|
5449
5744
|
};
|
|
5450
5745
|
var Components = ({
|
|
5451
5746
|
hideChart = false,
|
|
5452
5747
|
hideTable = false
|
|
5453
5748
|
}) => {
|
|
5454
|
-
const { error, isLoading, isValidating, refetch } = (0,
|
|
5749
|
+
const { error, isLoading, isValidating, refetch } = (0, import_react62.useContext)(
|
|
5455
5750
|
ProfitAndLoss.Context
|
|
5456
5751
|
);
|
|
5457
5752
|
if (!isLoading && error) {
|
|
5458
|
-
return /* @__PURE__ */
|
|
5753
|
+
return /* @__PURE__ */ import_react62.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react62.default.createElement(
|
|
5459
5754
|
DataState,
|
|
5460
5755
|
{
|
|
5461
5756
|
status: "failed" /* failed */,
|
|
@@ -5466,26 +5761,504 @@ var Components = ({
|
|
|
5466
5761
|
}
|
|
5467
5762
|
));
|
|
5468
5763
|
}
|
|
5469
|
-
return /* @__PURE__ */
|
|
5764
|
+
return /* @__PURE__ */ import_react62.default.createElement(import_react62.default.Fragment, null, !hideChart && /* @__PURE__ */ import_react62.default.createElement("div", { className: `Layer__${COMPONENT_NAME3}__chart_with_summaries` }, /* @__PURE__ */ import_react62.default.createElement(
|
|
5470
5765
|
"div",
|
|
5471
5766
|
{
|
|
5472
5767
|
className: `Layer__${COMPONENT_NAME3}__chart_with_summaries__summary-col`
|
|
5473
5768
|
},
|
|
5474
|
-
/* @__PURE__ */
|
|
5475
|
-
/* @__PURE__ */
|
|
5476
|
-
), /* @__PURE__ */
|
|
5769
|
+
/* @__PURE__ */ import_react62.default.createElement(ProfitAndLoss.DatePicker, null),
|
|
5770
|
+
/* @__PURE__ */ import_react62.default.createElement(ProfitAndLoss.Summaries, { vertical: true })
|
|
5771
|
+
), /* @__PURE__ */ import_react62.default.createElement(
|
|
5477
5772
|
"div",
|
|
5478
5773
|
{
|
|
5479
5774
|
className: `Layer__${COMPONENT_NAME3}__chart_with_summaries__chart-col`
|
|
5480
5775
|
},
|
|
5481
|
-
/* @__PURE__ */
|
|
5482
|
-
)), !hideTable && /* @__PURE__ */
|
|
5776
|
+
/* @__PURE__ */ import_react62.default.createElement(ProfitAndLoss.Chart, null)
|
|
5777
|
+
)), !hideTable && /* @__PURE__ */ import_react62.default.createElement(ProfitAndLoss.Table, null));
|
|
5483
5778
|
};
|
|
5484
5779
|
|
|
5485
|
-
// src/
|
|
5486
|
-
var
|
|
5487
|
-
|
|
5780
|
+
// src/components/LedgerAccounts/LedgerAccounts.tsx
|
|
5781
|
+
var import_react68 = __toESM(require("react"));
|
|
5782
|
+
|
|
5783
|
+
// src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
|
|
5784
|
+
var import_react63 = require("react");
|
|
5488
5785
|
var import_swr5 = __toESM(require("swr"));
|
|
5786
|
+
var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.sub_accounts || [])]).flat().filter((id) => id);
|
|
5787
|
+
var useLedgerAccounts = () => {
|
|
5788
|
+
const { auth, businessId, apiUrl } = useLayerContext();
|
|
5789
|
+
const [form, setForm] = (0, import_react63.useState)();
|
|
5790
|
+
const [showARForAccountId, setShowARForAccountId] = (0, import_react63.useState)();
|
|
5791
|
+
const { data, isLoading, isValidating, error, mutate } = (0, import_swr5.default)(
|
|
5792
|
+
businessId && auth?.access_token && `ledger-accounts-${businessId}`,
|
|
5793
|
+
Layer.getLedgerAccounts(apiUrl, auth?.access_token, {
|
|
5794
|
+
params: { businessId }
|
|
5795
|
+
})
|
|
5796
|
+
);
|
|
5797
|
+
const create = (newAccount) => {
|
|
5798
|
+
Layer.createAccount(apiUrl, auth?.access_token, {
|
|
5799
|
+
params: { businessId },
|
|
5800
|
+
body: newAccount
|
|
5801
|
+
}).then(({ data: data2 }) => (mutate(), data2));
|
|
5802
|
+
};
|
|
5803
|
+
const submitForm = () => {
|
|
5804
|
+
if (!form || !form.action) {
|
|
5805
|
+
return;
|
|
5806
|
+
}
|
|
5807
|
+
const data2 = {
|
|
5808
|
+
name: form.data.name || "Test name",
|
|
5809
|
+
normality: form.data.subType?.value,
|
|
5810
|
+
parent_id: form.data.parent ? {
|
|
5811
|
+
type: "AccountId",
|
|
5812
|
+
id: form.data.parent.value
|
|
5813
|
+
} : void 0,
|
|
5814
|
+
description: form.data.type?.value.toString() || "Test description"
|
|
5815
|
+
};
|
|
5816
|
+
if (form.action === "new") {
|
|
5817
|
+
create(data2);
|
|
5818
|
+
return;
|
|
5819
|
+
}
|
|
5820
|
+
if (form.action === "edit" && form.accountId) {
|
|
5821
|
+
return;
|
|
5822
|
+
}
|
|
5823
|
+
};
|
|
5824
|
+
const addAccount = () => setForm({
|
|
5825
|
+
action: "new",
|
|
5826
|
+
accountId: void 0,
|
|
5827
|
+
data: {
|
|
5828
|
+
parent: void 0,
|
|
5829
|
+
name: void 0,
|
|
5830
|
+
type: {
|
|
5831
|
+
value: "assets",
|
|
5832
|
+
label: "Assets"
|
|
5833
|
+
},
|
|
5834
|
+
subType: void 0,
|
|
5835
|
+
category: void 0
|
|
5836
|
+
}
|
|
5837
|
+
});
|
|
5838
|
+
const editAccount = (id) => {
|
|
5839
|
+
const allAccounts = flattenAccounts(data?.data?.accounts || []);
|
|
5840
|
+
const found = allAccounts?.find((x) => x.id === id);
|
|
5841
|
+
if (!found) {
|
|
5842
|
+
return;
|
|
5843
|
+
}
|
|
5844
|
+
const parent = allAccounts.find(
|
|
5845
|
+
(x) => x.sub_accounts?.find((el) => el.id === found.id)
|
|
5846
|
+
);
|
|
5847
|
+
setForm({
|
|
5848
|
+
action: "edit",
|
|
5849
|
+
accountId: id,
|
|
5850
|
+
data: {
|
|
5851
|
+
parent: parent ? {
|
|
5852
|
+
value: parent.id,
|
|
5853
|
+
label: parent.name
|
|
5854
|
+
} : void 0,
|
|
5855
|
+
name: found.name,
|
|
5856
|
+
type: {
|
|
5857
|
+
value: "assets",
|
|
5858
|
+
label: "Assets"
|
|
5859
|
+
},
|
|
5860
|
+
subType: void 0,
|
|
5861
|
+
category: void 0
|
|
5862
|
+
}
|
|
5863
|
+
});
|
|
5864
|
+
};
|
|
5865
|
+
const cancelForm = () => setForm(void 0);
|
|
5866
|
+
const changeFormData = (fieldName, value) => {
|
|
5867
|
+
if (!form) {
|
|
5868
|
+
return;
|
|
5869
|
+
}
|
|
5870
|
+
setForm({
|
|
5871
|
+
...form,
|
|
5872
|
+
data: {
|
|
5873
|
+
...form.data,
|
|
5874
|
+
[fieldName]: value
|
|
5875
|
+
}
|
|
5876
|
+
});
|
|
5877
|
+
};
|
|
5878
|
+
const refetch = () => mutate();
|
|
5879
|
+
return {
|
|
5880
|
+
data: data?.data,
|
|
5881
|
+
isLoading,
|
|
5882
|
+
isValidating,
|
|
5883
|
+
error,
|
|
5884
|
+
refetch,
|
|
5885
|
+
create,
|
|
5886
|
+
form,
|
|
5887
|
+
addAccount,
|
|
5888
|
+
editAccount,
|
|
5889
|
+
cancelForm,
|
|
5890
|
+
changeFormData,
|
|
5891
|
+
submitForm,
|
|
5892
|
+
showARForAccountId,
|
|
5893
|
+
setShowARForAccountId
|
|
5894
|
+
};
|
|
5895
|
+
};
|
|
5896
|
+
|
|
5897
|
+
// src/components/AccountsReceivable/AccountsReceivableIndex.tsx
|
|
5898
|
+
var import_react64 = __toESM(require("react"));
|
|
5899
|
+
var import_classnames26 = __toESM(require("classnames"));
|
|
5900
|
+
var import_date_fns15 = require("date-fns");
|
|
5901
|
+
var AccountsReceivable = () => {
|
|
5902
|
+
const { data, showARForAccountId, setShowARForAccountId } = (0, import_react64.useContext)(
|
|
5903
|
+
LedgerAccountsContext
|
|
5904
|
+
);
|
|
5905
|
+
const entry = (0, import_react64.useMemo)(() => {
|
|
5906
|
+
return flattenAccounts(data?.accounts || []).find(
|
|
5907
|
+
(x) => x.id === showARForAccountId
|
|
5908
|
+
);
|
|
5909
|
+
}, [showARForAccountId]);
|
|
5910
|
+
const baseClassName = (0, import_classnames26.default)(
|
|
5911
|
+
"Layer__accounts-receivable__index",
|
|
5912
|
+
showARForAccountId && "open"
|
|
5913
|
+
);
|
|
5914
|
+
const close = () => setShowARForAccountId(void 0);
|
|
5915
|
+
return /* @__PURE__ */ import_react64.default.createElement("div", { className: baseClassName }, /* @__PURE__ */ import_react64.default.createElement("div", { className: "Layer__accounts-receivable__header" }, /* @__PURE__ */ import_react64.default.createElement(Button, { onClick: close, variant: "secondary" /* secondary */ }, "Back"), /* @__PURE__ */ import_react64.default.createElement("div", { className: "Layer__accounts-receivable__title-container" }, /* @__PURE__ */ import_react64.default.createElement(
|
|
5916
|
+
Text,
|
|
5917
|
+
{
|
|
5918
|
+
weight: "bold" /* bold */,
|
|
5919
|
+
className: "Layer__accounts-receivable__title"
|
|
5920
|
+
},
|
|
5921
|
+
entry?.name || ""
|
|
5922
|
+
), /* @__PURE__ */ import_react64.default.createElement(
|
|
5923
|
+
Button,
|
|
5924
|
+
{
|
|
5925
|
+
variant: "secondary" /* secondary */,
|
|
5926
|
+
rightIcon: /* @__PURE__ */ import_react64.default.createElement(DownloadCloud_default, { size: 12 })
|
|
5927
|
+
},
|
|
5928
|
+
"Download"
|
|
5929
|
+
)), /* @__PURE__ */ import_react64.default.createElement("div", { className: "Layer__accounts-receivable__balance-container" }, /* @__PURE__ */ import_react64.default.createElement(
|
|
5930
|
+
Text,
|
|
5931
|
+
{
|
|
5932
|
+
weight: "bold" /* bold */,
|
|
5933
|
+
className: "Layer__accounts-receivable__balance-label"
|
|
5934
|
+
},
|
|
5935
|
+
"Current balance"
|
|
5936
|
+
), /* @__PURE__ */ import_react64.default.createElement(
|
|
5937
|
+
Text,
|
|
5938
|
+
{
|
|
5939
|
+
weight: "bold" /* bold */,
|
|
5940
|
+
className: "Layer__accounts-receivable__balance-value"
|
|
5941
|
+
},
|
|
5942
|
+
"$",
|
|
5943
|
+
centsToDollars(entry?.balance || 0)
|
|
5944
|
+
))), /* @__PURE__ */ import_react64.default.createElement("table", { className: "Layer__table Layer__accounts-receivable-table" }, /* @__PURE__ */ import_react64.default.createElement("thead", null, /* @__PURE__ */ import_react64.default.createElement("tr", null, /* @__PURE__ */ import_react64.default.createElement("th", { className: "Layer__table-header" }, "Date"), /* @__PURE__ */ import_react64.default.createElement("th", { className: "Layer__table-header" }, "Journal id #"), /* @__PURE__ */ import_react64.default.createElement("th", { className: "Layer__table-header" }, "Source"), /* @__PURE__ */ import_react64.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Debit"), /* @__PURE__ */ import_react64.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Credit"), /* @__PURE__ */ import_react64.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Running balance"))), /* @__PURE__ */ import_react64.default.createElement("tbody", null, entry?.entries?.map((x) => {
|
|
5945
|
+
return /* @__PURE__ */ import_react64.default.createElement("tr", { key: x.id }, /* @__PURE__ */ import_react64.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react64.default.createElement("span", { className: "Layer__table-cell-content" }, x.createdAt && (0, import_date_fns15.format)((0, import_date_fns15.parseISO)(x.createdAt), DATE_FORMAT))), /* @__PURE__ */ import_react64.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react64.default.createElement("span", { className: "Layer__table-cell-content" }, "TBD")), /* @__PURE__ */ import_react64.default.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ import_react64.default.createElement("span", { className: "Layer__table-cell-content" }, "TBD")), /* @__PURE__ */ import_react64.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, /* @__PURE__ */ import_react64.default.createElement("span", { className: "Layer__table-cell-content" }, x.direction, " TBD")), /* @__PURE__ */ import_react64.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, /* @__PURE__ */ import_react64.default.createElement("span", { className: "Layer__table-cell-content" }, "TBD")), /* @__PURE__ */ import_react64.default.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, /* @__PURE__ */ import_react64.default.createElement("span", { className: "Layer__table-cell-content" }, "TBD")));
|
|
5946
|
+
}))));
|
|
5947
|
+
};
|
|
5948
|
+
|
|
5949
|
+
// src/components/LedgerAccountsRow/LedgerAccountsRow.tsx
|
|
5950
|
+
var import_react65 = __toESM(require("react"));
|
|
5951
|
+
|
|
5952
|
+
// src/icons/ArrowRightCircle.tsx
|
|
5953
|
+
var React77 = __toESM(require("react"));
|
|
5954
|
+
var ArrowRightCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React77.createElement(
|
|
5955
|
+
"svg",
|
|
5956
|
+
{
|
|
5957
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5958
|
+
viewBox: "0 0 18 18",
|
|
5959
|
+
fill: "none",
|
|
5960
|
+
...props,
|
|
5961
|
+
width: size,
|
|
5962
|
+
height: size
|
|
5963
|
+
},
|
|
5964
|
+
/* @__PURE__ */ React77.createElement(
|
|
5965
|
+
"path",
|
|
5966
|
+
{
|
|
5967
|
+
d: "M9 16.5C13.1421 16.5 16.5 13.1421 16.5 9C16.5 4.85786 13.1421 1.5 9 1.5C4.85786 1.5 1.5 4.85786 1.5 9C1.5 13.1421 4.85786 16.5 9 16.5Z",
|
|
5968
|
+
stroke: "currentColor",
|
|
5969
|
+
"stroke-linecap": "round",
|
|
5970
|
+
"stroke-linejoin": "round"
|
|
5971
|
+
}
|
|
5972
|
+
),
|
|
5973
|
+
/* @__PURE__ */ React77.createElement(
|
|
5974
|
+
"path",
|
|
5975
|
+
{
|
|
5976
|
+
d: "M9 12L12 9L9 6",
|
|
5977
|
+
stroke: "currentColor",
|
|
5978
|
+
"stroke-linecap": "round",
|
|
5979
|
+
"stroke-linejoin": "round"
|
|
5980
|
+
}
|
|
5981
|
+
),
|
|
5982
|
+
/* @__PURE__ */ React77.createElement(
|
|
5983
|
+
"path",
|
|
5984
|
+
{
|
|
5985
|
+
d: "M6 9H12",
|
|
5986
|
+
stroke: "currentColor",
|
|
5987
|
+
"stroke-linecap": "round",
|
|
5988
|
+
"stroke-linejoin": "round"
|
|
5989
|
+
}
|
|
5990
|
+
)
|
|
5991
|
+
);
|
|
5992
|
+
var ArrowRightCircle_default = ArrowRightCircle;
|
|
5993
|
+
|
|
5994
|
+
// src/icons/Edit2.tsx
|
|
5995
|
+
var React78 = __toESM(require("react"));
|
|
5996
|
+
var Edit2 = ({ size = 18, ...props }) => /* @__PURE__ */ React78.createElement(
|
|
5997
|
+
"svg",
|
|
5998
|
+
{
|
|
5999
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6000
|
+
viewBox: "0 0 18 18",
|
|
6001
|
+
fill: "none",
|
|
6002
|
+
...props,
|
|
6003
|
+
width: size,
|
|
6004
|
+
height: size
|
|
6005
|
+
},
|
|
6006
|
+
/* @__PURE__ */ React78.createElement(
|
|
6007
|
+
"path",
|
|
6008
|
+
{
|
|
6009
|
+
d: "M12.75 2.25C12.947 2.05301 13.1808 1.89676 13.4382 1.79015C13.6956 1.68355 13.9714 1.62868 14.25 1.62868C14.5286 1.62868 14.8044 1.68355 15.0618 1.79015C15.3192 1.89676 15.553 2.05301 15.75 2.25C15.947 2.44698 16.1032 2.68083 16.2098 2.9382C16.3165 3.19557 16.3713 3.47142 16.3713 3.75C16.3713 4.02857 16.3165 4.30442 16.2098 4.56179C16.1032 4.81916 15.947 5.05302 15.75 5.25L5.625 15.375L1.5 16.5L2.625 12.375L12.75 2.25Z",
|
|
6010
|
+
stroke: "currentColor",
|
|
6011
|
+
"stroke-linecap": "round",
|
|
6012
|
+
"stroke-linejoin": "round"
|
|
6013
|
+
}
|
|
6014
|
+
)
|
|
6015
|
+
);
|
|
6016
|
+
var Edit2_default = Edit2;
|
|
6017
|
+
|
|
6018
|
+
// src/components/LedgerAccountsRow/LedgerAccountsRow.tsx
|
|
6019
|
+
var import_classnames27 = __toESM(require("classnames"));
|
|
6020
|
+
var INDENTATION = 12;
|
|
6021
|
+
var LedgerAccountsRow = ({
|
|
6022
|
+
account,
|
|
6023
|
+
depth = 0
|
|
6024
|
+
}) => {
|
|
6025
|
+
const { form, editAccount, setShowARForAccountId } = (0, import_react65.useContext)(
|
|
6026
|
+
LedgerAccountsContext
|
|
6027
|
+
);
|
|
6028
|
+
const [isOpen, setIsOpen] = (0, import_react65.useState)(false);
|
|
6029
|
+
const baseClass = (0, import_classnames27.default)(
|
|
6030
|
+
"Layer__alt-table-row",
|
|
6031
|
+
isOpen ? "Layer__alt-table-row--expanded" : "Layer__alt-table-row--collapsed",
|
|
6032
|
+
`Layer__alt-table-row--depth-${depth}`,
|
|
6033
|
+
form?.accountId === account.id && "active"
|
|
6034
|
+
);
|
|
6035
|
+
return /* @__PURE__ */ import_react65.default.createElement(import_react65.default.Fragment, null, /* @__PURE__ */ import_react65.default.createElement("div", { className: baseClass, onClick: () => setIsOpen(!isOpen) }, /* @__PURE__ */ import_react65.default.createElement(
|
|
6036
|
+
"div",
|
|
6037
|
+
{
|
|
6038
|
+
className: "Layer__alt-table__cell Layer__coa__name",
|
|
6039
|
+
style: { paddingLeft: INDENTATION * depth + 16 }
|
|
6040
|
+
},
|
|
6041
|
+
account.sub_accounts && account.sub_accounts.length > 0 && /* @__PURE__ */ import_react65.default.createElement(
|
|
6042
|
+
ChevronDownFill_default,
|
|
6043
|
+
{
|
|
6044
|
+
size: 16,
|
|
6045
|
+
className: "Layer__alt-table__expand-icon"
|
|
6046
|
+
}
|
|
6047
|
+
),
|
|
6048
|
+
/* @__PURE__ */ import_react65.default.createElement("span", { className: "Layer__coa__name__text" }, account.name)
|
|
6049
|
+
), /* @__PURE__ */ import_react65.default.createElement("div", { className: "Layer__alt-table__cell Layer__coa__type" }, account.normality), /* @__PURE__ */ import_react65.default.createElement("div", { className: "Layer__alt-table__cell Layer__coa__subtype" }, "Sub-Type"), /* @__PURE__ */ import_react65.default.createElement("div", { className: "Layer__alt-table__cell Layer__coa__balance" }, "$", centsToDollars(Math.abs(account.balance || 0))), /* @__PURE__ */ import_react65.default.createElement("div", { className: "Layer__alt-table__cell Layer__coa__actions" }, /* @__PURE__ */ import_react65.default.createElement(
|
|
6050
|
+
Button,
|
|
6051
|
+
{
|
|
6052
|
+
variant: "secondary" /* secondary */,
|
|
6053
|
+
rightIcon: /* @__PURE__ */ import_react65.default.createElement(Edit2_default, { size: 12 }),
|
|
6054
|
+
onClick: (e) => {
|
|
6055
|
+
e.preventDefault();
|
|
6056
|
+
e.stopPropagation();
|
|
6057
|
+
editAccount(account.id);
|
|
6058
|
+
}
|
|
6059
|
+
},
|
|
6060
|
+
"Edit"
|
|
6061
|
+
), /* @__PURE__ */ import_react65.default.createElement(
|
|
6062
|
+
Button,
|
|
6063
|
+
{
|
|
6064
|
+
variant: "secondary" /* secondary */,
|
|
6065
|
+
rightIcon: /* @__PURE__ */ import_react65.default.createElement(ArrowRightCircle_default, { size: 12 }),
|
|
6066
|
+
onClick: (e) => {
|
|
6067
|
+
e.preventDefault();
|
|
6068
|
+
e.stopPropagation();
|
|
6069
|
+
setShowARForAccountId(account.id);
|
|
6070
|
+
}
|
|
6071
|
+
},
|
|
6072
|
+
"Open"
|
|
6073
|
+
))), isOpen && (account.sub_accounts || []).map((subAccount) => /* @__PURE__ */ import_react65.default.createElement(
|
|
6074
|
+
LedgerAccountsRow,
|
|
6075
|
+
{
|
|
6076
|
+
key: subAccount.id,
|
|
6077
|
+
account: subAccount,
|
|
6078
|
+
depth: depth + 1
|
|
6079
|
+
}
|
|
6080
|
+
)));
|
|
6081
|
+
};
|
|
6082
|
+
|
|
6083
|
+
// src/components/LedgerAccountsSidebar/LedgerAccountsSidebar.tsx
|
|
6084
|
+
var import_react67 = __toESM(require("react"));
|
|
6085
|
+
|
|
6086
|
+
// src/components/LedgerAccountsForm/LedgerAccountsForm.tsx
|
|
6087
|
+
var import_react66 = __toESM(require("react"));
|
|
6088
|
+
var SUB_TYPE_OPTIONS = [
|
|
6089
|
+
{
|
|
6090
|
+
value: "DEBIT" /* DEBIT */,
|
|
6091
|
+
label: "Debit"
|
|
6092
|
+
},
|
|
6093
|
+
{
|
|
6094
|
+
value: "CREDIT" /* CREDIT */,
|
|
6095
|
+
label: "Credit"
|
|
6096
|
+
}
|
|
6097
|
+
];
|
|
6098
|
+
var LedgerAccountsForm = () => {
|
|
6099
|
+
const { form, data, changeFormData, cancelForm, submitForm } = (0, import_react66.useContext)(
|
|
6100
|
+
LedgerAccountsContext
|
|
6101
|
+
);
|
|
6102
|
+
const parentOptions = (0, import_react66.useMemo)(
|
|
6103
|
+
() => flattenAccounts(data?.accounts || []).sort((a, b) => a?.name && b?.name ? a.name.localeCompare(b.name) : 0).map((x) => {
|
|
6104
|
+
return {
|
|
6105
|
+
label: x.name,
|
|
6106
|
+
value: x.id
|
|
6107
|
+
};
|
|
6108
|
+
}),
|
|
6109
|
+
[data?.accounts?.length]
|
|
6110
|
+
);
|
|
6111
|
+
const entry = (0, import_react66.useMemo)(() => {
|
|
6112
|
+
if (form?.action === "edit" && form.accountId) {
|
|
6113
|
+
return flattenAccounts(data?.accounts || []).find(
|
|
6114
|
+
(x) => x.id === form.accountId
|
|
6115
|
+
);
|
|
6116
|
+
}
|
|
6117
|
+
return;
|
|
6118
|
+
}, [data, form?.accountId]);
|
|
6119
|
+
console.log(entry);
|
|
6120
|
+
if (!form) {
|
|
6121
|
+
return;
|
|
6122
|
+
}
|
|
6123
|
+
return /* @__PURE__ */ import_react66.default.createElement(
|
|
6124
|
+
"form",
|
|
6125
|
+
{
|
|
6126
|
+
onSubmit: (e) => {
|
|
6127
|
+
e.preventDefault();
|
|
6128
|
+
submitForm();
|
|
6129
|
+
}
|
|
6130
|
+
},
|
|
6131
|
+
/* @__PURE__ */ import_react66.default.createElement("div", { className: "Layer__ledger-accounts__sidebar__header" }, /* @__PURE__ */ import_react66.default.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, form?.action === "edit" ? "Edit" : "Add New", " Account"), /* @__PURE__ */ import_react66.default.createElement("div", { className: "actions" }, /* @__PURE__ */ import_react66.default.createElement(
|
|
6132
|
+
Button,
|
|
6133
|
+
{
|
|
6134
|
+
type: "button",
|
|
6135
|
+
onClick: cancelForm,
|
|
6136
|
+
variant: "secondary" /* secondary */
|
|
6137
|
+
},
|
|
6138
|
+
"Cancel"
|
|
6139
|
+
), /* @__PURE__ */ import_react66.default.createElement(SubmitButton, { type: "submit", noIcon: true, active: true }, "Save"))),
|
|
6140
|
+
entry && /* @__PURE__ */ import_react66.default.createElement("div", { className: "Layer__ledger-accounts__form-edit-entry" }, /* @__PURE__ */ import_react66.default.createElement(Text, { weight: "bold" /* bold */ }, entry.name), /* @__PURE__ */ import_react66.default.createElement(Text, { weight: "bold" /* bold */ }, "$", centsToDollars(entry.balance || 0))),
|
|
6141
|
+
/* @__PURE__ */ import_react66.default.createElement("div", { className: "Layer__ledger-accounts__form" }, /* @__PURE__ */ import_react66.default.createElement(InputGroup, { name: "parent", label: "Parent", inline: true }, /* @__PURE__ */ import_react66.default.createElement(
|
|
6142
|
+
Select3,
|
|
6143
|
+
{
|
|
6144
|
+
options: parentOptions,
|
|
6145
|
+
value: form?.data.parent,
|
|
6146
|
+
onChange: (sel) => changeFormData("parent", sel)
|
|
6147
|
+
}
|
|
6148
|
+
)), /* @__PURE__ */ import_react66.default.createElement(InputGroup, { name: "name", label: "Name", inline: true }, /* @__PURE__ */ import_react66.default.createElement(
|
|
6149
|
+
Input,
|
|
6150
|
+
{
|
|
6151
|
+
name: "name",
|
|
6152
|
+
value: form?.data.name,
|
|
6153
|
+
onChange: (e) => changeFormData("name", e.target.value)
|
|
6154
|
+
}
|
|
6155
|
+
)), /* @__PURE__ */ import_react66.default.createElement(InputGroup, { name: "type", label: "Type", inline: true }, /* @__PURE__ */ import_react66.default.createElement(
|
|
6156
|
+
Select3,
|
|
6157
|
+
{
|
|
6158
|
+
options: [],
|
|
6159
|
+
disabled: true,
|
|
6160
|
+
value: form?.data.type,
|
|
6161
|
+
onChange: (sel) => changeFormData("type", sel)
|
|
6162
|
+
}
|
|
6163
|
+
)), /* @__PURE__ */ import_react66.default.createElement(InputGroup, { name: "subType", label: "Sub-Type", inline: true }, /* @__PURE__ */ import_react66.default.createElement(
|
|
6164
|
+
Select3,
|
|
6165
|
+
{
|
|
6166
|
+
options: SUB_TYPE_OPTIONS,
|
|
6167
|
+
value: form?.data.subType,
|
|
6168
|
+
onChange: (sel) => changeFormData("subType", sel)
|
|
6169
|
+
}
|
|
6170
|
+
)), /* @__PURE__ */ import_react66.default.createElement(InputGroup, { name: "category", label: "Category", inline: true }, /* @__PURE__ */ import_react66.default.createElement(
|
|
6171
|
+
Select3,
|
|
6172
|
+
{
|
|
6173
|
+
options: [],
|
|
6174
|
+
value: form?.data.category,
|
|
6175
|
+
onChange: (sel) => changeFormData("category", sel)
|
|
6176
|
+
}
|
|
6177
|
+
)))
|
|
6178
|
+
);
|
|
6179
|
+
};
|
|
6180
|
+
|
|
6181
|
+
// src/components/LedgerAccountsSidebar/LedgerAccountsSidebar.tsx
|
|
6182
|
+
var import_classnames28 = __toESM(require("classnames"));
|
|
6183
|
+
var LedgerAccountsSidebar = () => {
|
|
6184
|
+
const { form } = (0, import_react67.useContext)(LedgerAccountsContext);
|
|
6185
|
+
return /* @__PURE__ */ import_react67.default.createElement(
|
|
6186
|
+
"div",
|
|
6187
|
+
{
|
|
6188
|
+
className: (0, import_classnames28.default)(
|
|
6189
|
+
"Layer__ledger-accounts__sidebar",
|
|
6190
|
+
form ? "open" : ""
|
|
6191
|
+
)
|
|
6192
|
+
},
|
|
6193
|
+
/* @__PURE__ */ import_react67.default.createElement("div", { className: "Layer__ledger-accounts__sidebar-content" }, /* @__PURE__ */ import_react67.default.createElement(LedgerAccountsForm, null))
|
|
6194
|
+
);
|
|
6195
|
+
};
|
|
6196
|
+
|
|
6197
|
+
// src/components/LedgerAccounts/LedgerAccounts.tsx
|
|
6198
|
+
var COMPONENT_NAME4 = "ledger-accounts";
|
|
6199
|
+
var LedgerAccountsContext = (0, import_react68.createContext)({
|
|
6200
|
+
data: void 0,
|
|
6201
|
+
isLoading: false,
|
|
6202
|
+
isValidating: false,
|
|
6203
|
+
error: void 0,
|
|
6204
|
+
refetch: () => {
|
|
6205
|
+
},
|
|
6206
|
+
create: () => {
|
|
6207
|
+
},
|
|
6208
|
+
form: void 0,
|
|
6209
|
+
addAccount: () => {
|
|
6210
|
+
},
|
|
6211
|
+
editAccount: () => {
|
|
6212
|
+
},
|
|
6213
|
+
cancelForm: () => {
|
|
6214
|
+
},
|
|
6215
|
+
changeFormData: () => {
|
|
6216
|
+
},
|
|
6217
|
+
submitForm: () => {
|
|
6218
|
+
},
|
|
6219
|
+
showARForAccountId: void 0,
|
|
6220
|
+
setShowARForAccountId: () => {
|
|
6221
|
+
}
|
|
6222
|
+
});
|
|
6223
|
+
var LedgerAccounts = () => {
|
|
6224
|
+
const contextData = useLedgerAccounts();
|
|
6225
|
+
return /* @__PURE__ */ import_react68.default.createElement(LedgerAccountsContext.Provider, { value: contextData }, /* @__PURE__ */ import_react68.default.createElement(LedgerAccountsContent, null));
|
|
6226
|
+
};
|
|
6227
|
+
var LedgerAccountsContent = () => {
|
|
6228
|
+
const { data, isLoading, addAccount, error, isValidating, refetch } = (0, import_react68.useContext)(LedgerAccountsContext);
|
|
6229
|
+
return /* @__PURE__ */ import_react68.default.createElement(Container, { name: COMPONENT_NAME4 }, /* @__PURE__ */ import_react68.default.createElement("div", { className: `Layer__${COMPONENT_NAME4}__main-panel` }, /* @__PURE__ */ import_react68.default.createElement(Header, { className: `Layer__${COMPONENT_NAME4}__header` }, /* @__PURE__ */ import_react68.default.createElement(Heading, { className: `Layer__${COMPONENT_NAME4}__title` }, "Chart of Accounts"), /* @__PURE__ */ import_react68.default.createElement("div", { className: `Layer__${COMPONENT_NAME4}__actions` }, /* @__PURE__ */ import_react68.default.createElement(
|
|
6230
|
+
Button,
|
|
6231
|
+
{
|
|
6232
|
+
variant: "secondary" /* secondary */,
|
|
6233
|
+
disabled: isLoading,
|
|
6234
|
+
rightIcon: /* @__PURE__ */ import_react68.default.createElement(DownloadCloud_default, { size: 12 })
|
|
6235
|
+
},
|
|
6236
|
+
"Download"
|
|
6237
|
+
), /* @__PURE__ */ import_react68.default.createElement(Button, { onClick: () => addAccount(), disabled: isLoading }, "Add Account"))), /* @__PURE__ */ import_react68.default.createElement("div", { className: `Layer__${COMPONENT_NAME4}__table` }, /* @__PURE__ */ import_react68.default.createElement("div", { className: "Layer__alt-table-row Layer__alt-table-row--header" }, /* @__PURE__ */ import_react68.default.createElement("div", { className: "Layer__alt-table__head-cell Layer__coa__name" }, "Name"), /* @__PURE__ */ import_react68.default.createElement("div", { className: "Layer__alt-table__head-cell Layer__coa__type" }, "Type"), /* @__PURE__ */ import_react68.default.createElement("div", { className: "Layer__alt-table__head-cell Layer__coa__subtype" }, "Sub-Type"), /* @__PURE__ */ import_react68.default.createElement("div", { className: "Layer__alt-table__head-cell Layer__coa__balance" }, "Balance"), /* @__PURE__ */ import_react68.default.createElement("div", { className: "Layer__alt-table__head-cell Layer__coa__actions" })), error ? /* @__PURE__ */ import_react68.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react68.default.createElement(
|
|
6238
|
+
DataState,
|
|
6239
|
+
{
|
|
6240
|
+
status: "failed" /* failed */,
|
|
6241
|
+
title: "Something went wrong",
|
|
6242
|
+
description: "We couldn\u2019t load your data.",
|
|
6243
|
+
onRefresh: () => refetch(),
|
|
6244
|
+
isLoading: isValidating || isLoading
|
|
6245
|
+
}
|
|
6246
|
+
)) : null, (!data || isLoading) && !error ? /* @__PURE__ */ import_react68.default.createElement("div", { className: `Layer__${COMPONENT_NAME4}__loader-container` }, /* @__PURE__ */ import_react68.default.createElement(Loader2, null)) : null, !error && data?.accounts.map((account) => /* @__PURE__ */ import_react68.default.createElement(LedgerAccountsRow, { key: account.id, account, depth: 0 })), !isLoading && !error && data?.accounts.length === 0 ? /* @__PURE__ */ import_react68.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react68.default.createElement(
|
|
6247
|
+
DataState,
|
|
6248
|
+
{
|
|
6249
|
+
status: "info" /* info */,
|
|
6250
|
+
title: "Accounts were not found",
|
|
6251
|
+
description: 'New account can be created with "Add Account".',
|
|
6252
|
+
onRefresh: () => refetch(),
|
|
6253
|
+
isLoading: isValidating
|
|
6254
|
+
}
|
|
6255
|
+
)) : null)), /* @__PURE__ */ import_react68.default.createElement(LedgerAccountsSidebar, null), /* @__PURE__ */ import_react68.default.createElement(AccountsReceivable, null));
|
|
6256
|
+
};
|
|
6257
|
+
|
|
6258
|
+
// src/providers/LayerProvider/LayerProvider.tsx
|
|
6259
|
+
var import_react69 = __toESM(require("react"));
|
|
6260
|
+
var import_date_fns16 = require("date-fns");
|
|
6261
|
+
var import_swr6 = __toESM(require("swr"));
|
|
5489
6262
|
var reducer = (state, action) => {
|
|
5490
6263
|
switch (action.type) {
|
|
5491
6264
|
case "LayerContext.setAuth" /* setAuth */:
|
|
@@ -5525,7 +6298,7 @@ var LayerProvider = ({
|
|
|
5525
6298
|
};
|
|
5526
6299
|
const colors = buildColorsPalette(theme);
|
|
5527
6300
|
const { url, scope, apiUrl } = LayerEnvironment[environment];
|
|
5528
|
-
const [state, dispatch] = (0,
|
|
6301
|
+
const [state, dispatch] = (0, import_react69.useReducer)(reducer, {
|
|
5529
6302
|
auth: {
|
|
5530
6303
|
access_token: "",
|
|
5531
6304
|
token_type: "",
|
|
@@ -5538,8 +6311,8 @@ var LayerProvider = ({
|
|
|
5538
6311
|
theme,
|
|
5539
6312
|
colors
|
|
5540
6313
|
});
|
|
5541
|
-
const { data: auth } = appId !== void 0 && appSecret !== void 0 ? (0,
|
|
5542
|
-
businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && (0,
|
|
6314
|
+
const { data: auth } = appId !== void 0 && appSecret !== void 0 ? (0, import_swr6.default)(
|
|
6315
|
+
businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && (0, import_date_fns16.isBefore)(state.auth.expires_at, /* @__PURE__ */ new Date()) && "authenticate",
|
|
5543
6316
|
Layer.authenticate({
|
|
5544
6317
|
appId,
|
|
5545
6318
|
appSecret,
|
|
@@ -5548,7 +6321,7 @@ var LayerProvider = ({
|
|
|
5548
6321
|
}),
|
|
5549
6322
|
defaultSWRConfig
|
|
5550
6323
|
) : { data: void 0 };
|
|
5551
|
-
(0,
|
|
6324
|
+
(0, import_react69.useEffect)(() => {
|
|
5552
6325
|
if (businessAccessToken) {
|
|
5553
6326
|
dispatch({
|
|
5554
6327
|
type: "LayerContext.setAuth" /* setAuth */,
|
|
@@ -5557,7 +6330,7 @@ var LayerProvider = ({
|
|
|
5557
6330
|
access_token: businessAccessToken,
|
|
5558
6331
|
token_type: "Bearer",
|
|
5559
6332
|
expires_in: 3600,
|
|
5560
|
-
expires_at: (0,
|
|
6333
|
+
expires_at: (0, import_date_fns16.add)(/* @__PURE__ */ new Date(), { seconds: 3600 })
|
|
5561
6334
|
}
|
|
5562
6335
|
}
|
|
5563
6336
|
});
|
|
@@ -5567,13 +6340,13 @@ var LayerProvider = ({
|
|
|
5567
6340
|
payload: {
|
|
5568
6341
|
auth: {
|
|
5569
6342
|
...auth,
|
|
5570
|
-
expires_at: (0,
|
|
6343
|
+
expires_at: (0, import_date_fns16.add)(/* @__PURE__ */ new Date(), { seconds: auth.expires_in })
|
|
5571
6344
|
}
|
|
5572
6345
|
}
|
|
5573
6346
|
});
|
|
5574
6347
|
}
|
|
5575
6348
|
}, [businessAccessToken, auth?.access_token]);
|
|
5576
|
-
(0,
|
|
6349
|
+
(0, import_swr6.default)(
|
|
5577
6350
|
businessId && auth?.access_token && `categories-${businessId}`,
|
|
5578
6351
|
Layer.getCategories(apiUrl, auth?.access_token, { params: { businessId } }),
|
|
5579
6352
|
{
|
|
@@ -5598,171 +6371,15 @@ var LayerProvider = ({
|
|
|
5598
6371
|
}
|
|
5599
6372
|
return;
|
|
5600
6373
|
};
|
|
5601
|
-
return /* @__PURE__ */
|
|
5602
|
-
};
|
|
5603
|
-
|
|
5604
|
-
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
5605
|
-
var import_react61 = __toESM(require("react"));
|
|
5606
|
-
|
|
5607
|
-
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
5608
|
-
var import_swr6 = __toESM(require("swr"));
|
|
5609
|
-
var useChartOfAccounts = () => {
|
|
5610
|
-
const { auth, businessId, apiUrl } = useLayerContext();
|
|
5611
|
-
const { data, isLoading, error, mutate } = (0, import_swr6.default)(
|
|
5612
|
-
businessId && auth?.access_token && `chart-of-accounts-${businessId}`,
|
|
5613
|
-
Layer.getChartOfAccounts(apiUrl, auth?.access_token, {
|
|
5614
|
-
params: { businessId }
|
|
5615
|
-
})
|
|
5616
|
-
);
|
|
5617
|
-
const create = (newAccount) => Layer.createAccount(apiUrl, auth?.access_token, {
|
|
5618
|
-
params: { businessId },
|
|
5619
|
-
body: newAccount
|
|
5620
|
-
}).then(({ data: data2 }) => (mutate(), data2));
|
|
5621
|
-
return { data: data?.data, isLoading, error, create };
|
|
5622
|
-
};
|
|
5623
|
-
|
|
5624
|
-
// src/components/ChartOfAccountsNewForm/ChartOfAccountsNewForm.tsx
|
|
5625
|
-
var import_react59 = __toESM(require("react"));
|
|
5626
|
-
var import_react_select4 = __toESM(require("react-select"));
|
|
5627
|
-
var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.subAccounts || [])]).flat().filter((id) => id);
|
|
5628
|
-
var ChartOfAccountsNewForm = () => {
|
|
5629
|
-
const { data, create: createAccount2 } = useChartOfAccounts();
|
|
5630
|
-
const accountOptions = (0, import_react59.useMemo)(
|
|
5631
|
-
() => flattenAccounts(data?.accounts || []).sort(
|
|
5632
|
-
(a, b) => a?.name && b?.name ? a.name.localeCompare(b.name) : 0
|
|
5633
|
-
),
|
|
5634
|
-
[data?.accounts?.length]
|
|
5635
|
-
);
|
|
5636
|
-
const [name, setName] = (0, import_react59.useState)("");
|
|
5637
|
-
const [description, setDescription] = (0, import_react59.useState)("");
|
|
5638
|
-
const [normality, setNormality] = (0, import_react59.useState)("DEBIT" /* DEBIT */);
|
|
5639
|
-
const [parentAccount, setParentAccount] = (0, import_react59.useState)(
|
|
5640
|
-
data?.accounts[0]
|
|
5641
|
-
);
|
|
5642
|
-
const save = () => {
|
|
5643
|
-
createAccount2({
|
|
5644
|
-
name,
|
|
5645
|
-
normality,
|
|
5646
|
-
parent_id: {
|
|
5647
|
-
type: "AccountId",
|
|
5648
|
-
id: parentAccount?.id || ""
|
|
5649
|
-
},
|
|
5650
|
-
description
|
|
5651
|
-
});
|
|
5652
|
-
};
|
|
5653
|
-
return /* @__PURE__ */ import_react59.default.createElement("div", { className: "Layer__chart-of-accounts-new-form" }, /* @__PURE__ */ import_react59.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react59.default.createElement("span", null, "Name"), /* @__PURE__ */ import_react59.default.createElement(
|
|
5654
|
-
"input",
|
|
5655
|
-
{
|
|
5656
|
-
name: "name",
|
|
5657
|
-
value: name,
|
|
5658
|
-
onChange: (event) => setName(event.target.value)
|
|
5659
|
-
}
|
|
5660
|
-
)), /* @__PURE__ */ import_react59.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react59.default.createElement("span", null, "Description"), /* @__PURE__ */ import_react59.default.createElement(
|
|
5661
|
-
"input",
|
|
5662
|
-
{
|
|
5663
|
-
name: "description",
|
|
5664
|
-
value: description,
|
|
5665
|
-
onChange: (event) => setDescription(event.target.value)
|
|
5666
|
-
}
|
|
5667
|
-
)), /* @__PURE__ */ import_react59.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react59.default.createElement("span", null, "Normality"), /* @__PURE__ */ import_react59.default.createElement(
|
|
5668
|
-
import_react_select4.default,
|
|
5669
|
-
{
|
|
5670
|
-
isSearchable: false,
|
|
5671
|
-
onChange: (value) => value && setNormality(value.value),
|
|
5672
|
-
options: [
|
|
5673
|
-
{ label: "Credit", value: "CREDIT" /* CREDIT */ },
|
|
5674
|
-
{ label: "Debit", value: "DEBIT" /* DEBIT */ }
|
|
5675
|
-
]
|
|
5676
|
-
}
|
|
5677
|
-
)), /* @__PURE__ */ import_react59.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react59.default.createElement("span", null, "Parent Account"), /* @__PURE__ */ import_react59.default.createElement(
|
|
5678
|
-
import_react_select4.default,
|
|
5679
|
-
{
|
|
5680
|
-
isSearchable: true,
|
|
5681
|
-
value: parentAccount,
|
|
5682
|
-
onChange: (value) => value && setParentAccount(value),
|
|
5683
|
-
getOptionLabel: (a) => a.name,
|
|
5684
|
-
getOptionValue: (a) => a.id,
|
|
5685
|
-
options: accountOptions
|
|
5686
|
-
}
|
|
5687
|
-
)), /* @__PURE__ */ import_react59.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field Layer__chart-of-accounts-new-form__field--actions" }, /* @__PURE__ */ import_react59.default.createElement("button", { onClick: save }, "Save")));
|
|
5688
|
-
};
|
|
5689
|
-
|
|
5690
|
-
// src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
|
|
5691
|
-
var import_react60 = __toESM(require("react"));
|
|
5692
|
-
var ChartOfAccountsRow = ({ account, depth = 0 }) => {
|
|
5693
|
-
const classNames24 = [
|
|
5694
|
-
"Layer__chart-of-accounts-row__table-cell",
|
|
5695
|
-
depth > 0 && `Layer__chart-of-accounts-row__table-cell--depth-${depth}`
|
|
5696
|
-
];
|
|
5697
|
-
const className = classNames24.filter((id) => id).join(" ");
|
|
5698
|
-
const amountClassName = account.balance < 0 ? "Layer__chart-of-accounts-row__table-cell--amount-negative" : "Layer__chart-of-accounts-row__table-cell--amount-positive";
|
|
5699
|
-
return /* @__PURE__ */ import_react60.default.createElement(import_react60.default.Fragment, null, /* @__PURE__ */ import_react60.default.createElement(
|
|
5700
|
-
"div",
|
|
5701
|
-
{
|
|
5702
|
-
className: `${className} Layer__chart-of-accounts-row__table-cell--name`
|
|
5703
|
-
},
|
|
5704
|
-
account.name
|
|
5705
|
-
), /* @__PURE__ */ import_react60.default.createElement(
|
|
5706
|
-
"div",
|
|
5707
|
-
{
|
|
5708
|
-
className: `${className} Layer__chart-of-accounts-row__table-cell--type`
|
|
5709
|
-
},
|
|
5710
|
-
"Assets"
|
|
5711
|
-
), /* @__PURE__ */ import_react60.default.createElement(
|
|
5712
|
-
"div",
|
|
5713
|
-
{
|
|
5714
|
-
className: `${className} Layer__chart-of-accounts-row__table-cell--subtype`
|
|
5715
|
-
},
|
|
5716
|
-
"Cash"
|
|
5717
|
-
), /* @__PURE__ */ import_react60.default.createElement(
|
|
5718
|
-
"div",
|
|
5719
|
-
{
|
|
5720
|
-
className: `${className} Layer__chart-of-accounts-row__table-cell--balance ${amountClassName}`
|
|
5721
|
-
},
|
|
5722
|
-
centsToDollars(Math.abs(account.balance || 0))
|
|
5723
|
-
), /* @__PURE__ */ import_react60.default.createElement(
|
|
5724
|
-
"div",
|
|
5725
|
-
{
|
|
5726
|
-
className: `${className} Layer__chart-of-accounts-row__table-cell--actions`
|
|
5727
|
-
},
|
|
5728
|
-
/* @__PURE__ */ import_react60.default.createElement("button", { className: "Layer__chart-of-accounts-row__view-entries-button" }, "View Entries")
|
|
5729
|
-
), (account.subAccounts || []).map((subAccount) => /* @__PURE__ */ import_react60.default.createElement(
|
|
5730
|
-
ChartOfAccountsRow,
|
|
5731
|
-
{
|
|
5732
|
-
key: subAccount.id,
|
|
5733
|
-
account: subAccount,
|
|
5734
|
-
depth: depth + 1
|
|
5735
|
-
}
|
|
5736
|
-
)));
|
|
5737
|
-
};
|
|
5738
|
-
|
|
5739
|
-
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
5740
|
-
var ChartOfAccounts = () => {
|
|
5741
|
-
const { data, isLoading } = useChartOfAccounts();
|
|
5742
|
-
const [showingForm, setShowingForm] = (0, import_react61.useState)(false);
|
|
5743
|
-
return /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__component Layer__chart-of-accounts" }, !data || isLoading ? "Loading." : /* @__PURE__ */ import_react61.default.createElement(import_react61.default.Fragment, null, /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__chart-of-accounts__header" }, /* @__PURE__ */ import_react61.default.createElement("h2", { className: "Layer__chart-of-accounts__title" }, "Chart of Accounts"), /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__chart-of-accounts__actions" }, /* @__PURE__ */ import_react61.default.createElement("button", { className: "Layer__chart-of-accounts__download-button" }, /* @__PURE__ */ import_react61.default.createElement(DownloadCloud_default, null), "Download"), /* @__PURE__ */ import_react61.default.createElement(
|
|
5744
|
-
"button",
|
|
5745
|
-
{
|
|
5746
|
-
className: "Layer__chart-of-accounts__edit-accounts-button",
|
|
5747
|
-
onClick: () => setShowingForm(!showingForm)
|
|
5748
|
-
},
|
|
5749
|
-
"Edit Accounts"
|
|
5750
|
-
))), showingForm && /* @__PURE__ */ import_react61.default.createElement(ChartOfAccountsNewForm, null), /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__chart-of-accounts__table" }, /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Name"), /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Type"), /* @__PURE__ */ import_react61.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Sub-Type"), /* @__PURE__ */ import_react61.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_react61.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }), data.accounts.map((account) => /* @__PURE__ */ import_react61.default.createElement(
|
|
5751
|
-
ChartOfAccountsRow,
|
|
5752
|
-
{
|
|
5753
|
-
key: account.id,
|
|
5754
|
-
account,
|
|
5755
|
-
depth: 0
|
|
5756
|
-
}
|
|
5757
|
-
)))));
|
|
6374
|
+
return /* @__PURE__ */ import_react69.default.createElement(import_swr6.SWRConfig, { value: defaultSWRConfig }, /* @__PURE__ */ import_react69.default.createElement(LayerContext.Provider, { value: { ...state, setTheme, getColor } }, children));
|
|
5758
6375
|
};
|
|
5759
6376
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5760
6377
|
0 && (module.exports = {
|
|
5761
6378
|
BalanceSheet,
|
|
5762
6379
|
BankTransactions,
|
|
5763
|
-
ChartOfAccounts,
|
|
5764
6380
|
Hello,
|
|
5765
6381
|
LayerProvider,
|
|
6382
|
+
LedgerAccounts,
|
|
5766
6383
|
LinkedAccounts,
|
|
5767
6384
|
ProfitAndLoss,
|
|
5768
6385
|
ProfitAndLossView
|