@layerfi/components 0.1.13 → 0.1.14
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 +653 -299
- package/dist/esm/index.js.map +4 -4
- package/dist/index.d.ts +64 -2
- package/dist/index.js +911 -557
- package/dist/index.js.map +4 -4
- package/dist/styles/index.css +20 -2
- package/dist/styles/index.css.map +2 -2
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -4315,7 +4315,7 @@ var useLinkedAccounts = () => {
|
|
|
4315
4315
|
const exchangePublicToken = async (publicToken, metadata) => {
|
|
4316
4316
|
await Layer.exchangePlaidPublicToken(apiUrl, auth?.access_token, {
|
|
4317
4317
|
params: { businessId },
|
|
4318
|
-
body: { public_token: publicToken,
|
|
4318
|
+
body: { public_token: publicToken, institution: metadata.institution }
|
|
4319
4319
|
});
|
|
4320
4320
|
refetchAccounts();
|
|
4321
4321
|
};
|
|
@@ -5015,12 +5015,12 @@ var applyShare = (items, total) => {
|
|
|
5015
5015
|
});
|
|
5016
5016
|
};
|
|
5017
5017
|
|
|
5018
|
-
// src/hooks/useProfitAndLoss/
|
|
5018
|
+
// src/hooks/useProfitAndLoss/useProfitAndLossQuery.tsx
|
|
5019
5019
|
import { startOfMonth, endOfMonth, formatISO } from "date-fns";
|
|
5020
5020
|
import useSWR5 from "swr";
|
|
5021
|
-
var
|
|
5022
|
-
startDate
|
|
5023
|
-
endDate
|
|
5021
|
+
var useProfitAndLossQuery = ({
|
|
5022
|
+
startDate,
|
|
5023
|
+
endDate,
|
|
5024
5024
|
tagFilter,
|
|
5025
5025
|
reportingBasis
|
|
5026
5026
|
} = {
|
|
@@ -5028,17 +5028,6 @@ var useProfitAndLoss = ({
|
|
|
5028
5028
|
endDate: endOfMonth(/* @__PURE__ */ new Date())
|
|
5029
5029
|
}) => {
|
|
5030
5030
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
5031
|
-
const [startDate, setStartDate] = useState13(
|
|
5032
|
-
initialStartDate || startOfMonth(Date.now())
|
|
5033
|
-
);
|
|
5034
|
-
const [endDate, setEndDate] = useState13(
|
|
5035
|
-
initialEndDate || endOfMonth(Date.now())
|
|
5036
|
-
);
|
|
5037
|
-
const [filters, setFilters] = useState13({
|
|
5038
|
-
expenses: void 0,
|
|
5039
|
-
revenue: void 0
|
|
5040
|
-
});
|
|
5041
|
-
const [sidebarScope, setSidebarScope] = useState13(void 0);
|
|
5042
5031
|
const {
|
|
5043
5032
|
data: rawData,
|
|
5044
5033
|
isLoading,
|
|
@@ -5052,15 +5041,83 @@ var useProfitAndLoss = ({
|
|
|
5052
5041
|
Layer.getProfitAndLoss(apiUrl, auth?.access_token, {
|
|
5053
5042
|
params: {
|
|
5054
5043
|
businessId,
|
|
5055
|
-
startDate: formatISO(startDate),
|
|
5056
|
-
endDate: formatISO(endDate),
|
|
5044
|
+
startDate: formatISO(startDate.valueOf()),
|
|
5045
|
+
endDate: formatISO(endDate.valueOf()),
|
|
5057
5046
|
tagKey: tagFilter?.key,
|
|
5058
5047
|
tagValues: tagFilter?.values?.join(","),
|
|
5059
5048
|
reportingBasis
|
|
5060
5049
|
}
|
|
5061
5050
|
})
|
|
5062
5051
|
);
|
|
5063
|
-
const
|
|
5052
|
+
const refetch = () => {
|
|
5053
|
+
mutate();
|
|
5054
|
+
};
|
|
5055
|
+
return {
|
|
5056
|
+
startDate,
|
|
5057
|
+
endDate,
|
|
5058
|
+
data: rawData?.data,
|
|
5059
|
+
isLoading,
|
|
5060
|
+
isValidating,
|
|
5061
|
+
error: rawError,
|
|
5062
|
+
refetch
|
|
5063
|
+
};
|
|
5064
|
+
};
|
|
5065
|
+
|
|
5066
|
+
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
5067
|
+
import { startOfMonth as startOfMonth2, endOfMonth as endOfMonth2 } from "date-fns";
|
|
5068
|
+
var useProfitAndLoss = ({
|
|
5069
|
+
startDate: initialStartDate,
|
|
5070
|
+
endDate: initialEndDate,
|
|
5071
|
+
tagFilter,
|
|
5072
|
+
reportingBasis,
|
|
5073
|
+
fetchMultipleMonths = false
|
|
5074
|
+
} = {
|
|
5075
|
+
startDate: startOfMonth2(/* @__PURE__ */ new Date()),
|
|
5076
|
+
endDate: endOfMonth2(/* @__PURE__ */ new Date())
|
|
5077
|
+
}) => {
|
|
5078
|
+
const [startDate, setStartDate] = useState13(
|
|
5079
|
+
initialStartDate || startOfMonth2(Date.now())
|
|
5080
|
+
);
|
|
5081
|
+
const [endDate, setEndDate] = useState13(
|
|
5082
|
+
initialEndDate || endOfMonth2(Date.now())
|
|
5083
|
+
);
|
|
5084
|
+
const [filters, setFilters] = useState13({
|
|
5085
|
+
expenses: void 0,
|
|
5086
|
+
revenue: void 0
|
|
5087
|
+
});
|
|
5088
|
+
const [sidebarScope, setSidebarScope] = useState13(void 0);
|
|
5089
|
+
const { data, isLoading, isValidating, error, refetch } = useProfitAndLossQuery({
|
|
5090
|
+
startDate,
|
|
5091
|
+
endDate,
|
|
5092
|
+
tagFilter,
|
|
5093
|
+
reportingBasis
|
|
5094
|
+
});
|
|
5095
|
+
const changeDateRange = ({
|
|
5096
|
+
startDate: newStartDate,
|
|
5097
|
+
endDate: newEndDate
|
|
5098
|
+
}) => {
|
|
5099
|
+
newStartDate && setStartDate(newStartDate);
|
|
5100
|
+
newEndDate && setEndDate(newEndDate);
|
|
5101
|
+
};
|
|
5102
|
+
const sortBy = (scope, field, direction) => {
|
|
5103
|
+
setFilters({
|
|
5104
|
+
...filters,
|
|
5105
|
+
[scope]: {
|
|
5106
|
+
...filters[scope],
|
|
5107
|
+
sortBy: field,
|
|
5108
|
+
sortDirection: direction ?? filters[scope]?.sortDirection === "desc" ? "asc" : "desc"
|
|
5109
|
+
}
|
|
5110
|
+
});
|
|
5111
|
+
};
|
|
5112
|
+
const setFilterTypes = (scope, types) => {
|
|
5113
|
+
setFilters({
|
|
5114
|
+
...filters,
|
|
5115
|
+
[scope]: {
|
|
5116
|
+
...filters[scope],
|
|
5117
|
+
types
|
|
5118
|
+
}
|
|
5119
|
+
});
|
|
5120
|
+
};
|
|
5064
5121
|
const { filteredDataRevenue, filteredTotalRevenue } = useMemo3(() => {
|
|
5065
5122
|
if (!data) {
|
|
5066
5123
|
return { filteredDataRevenue: [], filteredTotalRevenue: void 0 };
|
|
@@ -5135,35 +5192,6 @@ var useProfitAndLoss = ({
|
|
|
5135
5192
|
const withShare = applyShare(sorted, total);
|
|
5136
5193
|
return { filteredDataExpenses: withShare, filteredTotalExpenses: total };
|
|
5137
5194
|
}, [data, startDate, filters, sidebarScope]);
|
|
5138
|
-
const changeDateRange = ({
|
|
5139
|
-
startDate: newStartDate,
|
|
5140
|
-
endDate: newEndDate
|
|
5141
|
-
}) => {
|
|
5142
|
-
newStartDate && setStartDate(newStartDate);
|
|
5143
|
-
newEndDate && setEndDate(newEndDate);
|
|
5144
|
-
};
|
|
5145
|
-
const refetch = () => {
|
|
5146
|
-
mutate();
|
|
5147
|
-
};
|
|
5148
|
-
const sortBy = (scope, field, direction) => {
|
|
5149
|
-
setFilters({
|
|
5150
|
-
...filters,
|
|
5151
|
-
[scope]: {
|
|
5152
|
-
...filters[scope],
|
|
5153
|
-
sortBy: field,
|
|
5154
|
-
sortDirection: direction ?? filters[scope]?.sortDirection === "desc" ? "asc" : "desc"
|
|
5155
|
-
}
|
|
5156
|
-
});
|
|
5157
|
-
};
|
|
5158
|
-
const setFilterTypes = (scope, types) => {
|
|
5159
|
-
setFilters({
|
|
5160
|
-
...filters,
|
|
5161
|
-
[scope]: {
|
|
5162
|
-
...filters[scope],
|
|
5163
|
-
types
|
|
5164
|
-
}
|
|
5165
|
-
});
|
|
5166
|
-
};
|
|
5167
5195
|
return {
|
|
5168
5196
|
data,
|
|
5169
5197
|
filteredDataRevenue,
|
|
@@ -5172,7 +5200,7 @@ var useProfitAndLoss = ({
|
|
|
5172
5200
|
filteredTotalExpenses,
|
|
5173
5201
|
isLoading,
|
|
5174
5202
|
isValidating,
|
|
5175
|
-
error
|
|
5203
|
+
error,
|
|
5176
5204
|
dateRange: { startDate, endDate },
|
|
5177
5205
|
refetch,
|
|
5178
5206
|
changeDateRange,
|
|
@@ -5185,7 +5213,350 @@ var useProfitAndLoss = ({
|
|
|
5185
5213
|
};
|
|
5186
5214
|
|
|
5187
5215
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
5188
|
-
import React66, { useContext as useContext2, useMemo as
|
|
5216
|
+
import React66, { useContext as useContext2, useEffect as useEffect12, useMemo as useMemo5, useState as useState16 } from "react";
|
|
5217
|
+
|
|
5218
|
+
// src/hooks/useProfitAndLoss/useProfitAndLossLTM.tsx
|
|
5219
|
+
import { useEffect as useEffect10, useMemo as useMemo4, useState as useState14 } from "react";
|
|
5220
|
+
import { startOfMonth as startOfMonth3, endOfMonth as endOfMonth3, sub } from "date-fns";
|
|
5221
|
+
var buildDates = ({ currentDate }) => {
|
|
5222
|
+
const list = [];
|
|
5223
|
+
for (let i = 11; i > 0; i--) {
|
|
5224
|
+
const startDateWithOffset = startOfMonth3(sub(currentDate, { months: i }));
|
|
5225
|
+
const endDateWithOffset = endOfMonth3(sub(currentDate, { months: i }));
|
|
5226
|
+
list.push({
|
|
5227
|
+
startDate: startDateWithOffset,
|
|
5228
|
+
endDate: endDateWithOffset
|
|
5229
|
+
});
|
|
5230
|
+
}
|
|
5231
|
+
list.push({
|
|
5232
|
+
startDate: startOfMonth3(currentDate),
|
|
5233
|
+
endDate: endOfMonth3(currentDate)
|
|
5234
|
+
});
|
|
5235
|
+
return list;
|
|
5236
|
+
};
|
|
5237
|
+
var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
5238
|
+
currentDate: /* @__PURE__ */ new Date()
|
|
5239
|
+
}) => {
|
|
5240
|
+
const { businessId } = useLayerContext();
|
|
5241
|
+
const [loaded, setLoaded] = useState14("initial");
|
|
5242
|
+
const dates = useMemo4(() => {
|
|
5243
|
+
return buildDates({ currentDate });
|
|
5244
|
+
}, [currentDate, businessId, tagFilter, reportingBasis]);
|
|
5245
|
+
const {
|
|
5246
|
+
data: data0,
|
|
5247
|
+
isLoading: isLoading0,
|
|
5248
|
+
error: error0,
|
|
5249
|
+
startDate: startDate0,
|
|
5250
|
+
endDate: endDate0
|
|
5251
|
+
} = useProfitAndLossQuery({
|
|
5252
|
+
startDate: dates[0].startDate,
|
|
5253
|
+
endDate: dates[0].endDate,
|
|
5254
|
+
tagFilter,
|
|
5255
|
+
reportingBasis
|
|
5256
|
+
});
|
|
5257
|
+
const {
|
|
5258
|
+
data: data1,
|
|
5259
|
+
isLoading: isLoading1,
|
|
5260
|
+
error: error1,
|
|
5261
|
+
startDate: startDate1,
|
|
5262
|
+
endDate: endDate1
|
|
5263
|
+
} = useProfitAndLossQuery({
|
|
5264
|
+
startDate: dates[1].startDate,
|
|
5265
|
+
endDate: dates[1].endDate,
|
|
5266
|
+
tagFilter,
|
|
5267
|
+
reportingBasis
|
|
5268
|
+
});
|
|
5269
|
+
const {
|
|
5270
|
+
data: data2,
|
|
5271
|
+
isLoading: isLoading2,
|
|
5272
|
+
error: error2,
|
|
5273
|
+
startDate: startDate2,
|
|
5274
|
+
endDate: endDate2
|
|
5275
|
+
} = useProfitAndLossQuery({
|
|
5276
|
+
startDate: dates[2].startDate,
|
|
5277
|
+
endDate: dates[2].endDate,
|
|
5278
|
+
tagFilter,
|
|
5279
|
+
reportingBasis
|
|
5280
|
+
});
|
|
5281
|
+
const {
|
|
5282
|
+
data: data3,
|
|
5283
|
+
isLoading: isLoading3,
|
|
5284
|
+
error: error3,
|
|
5285
|
+
startDate: startDate3,
|
|
5286
|
+
endDate: endDate3
|
|
5287
|
+
} = useProfitAndLossQuery({
|
|
5288
|
+
startDate: dates[3].startDate,
|
|
5289
|
+
endDate: dates[3].endDate,
|
|
5290
|
+
tagFilter,
|
|
5291
|
+
reportingBasis
|
|
5292
|
+
});
|
|
5293
|
+
const {
|
|
5294
|
+
data: data4,
|
|
5295
|
+
isLoading: isLoading4,
|
|
5296
|
+
error: error4,
|
|
5297
|
+
startDate: startDate4,
|
|
5298
|
+
endDate: endDate4
|
|
5299
|
+
} = useProfitAndLossQuery({
|
|
5300
|
+
startDate: dates[4].startDate,
|
|
5301
|
+
endDate: dates[4].endDate,
|
|
5302
|
+
tagFilter,
|
|
5303
|
+
reportingBasis
|
|
5304
|
+
});
|
|
5305
|
+
const {
|
|
5306
|
+
data: data5,
|
|
5307
|
+
isLoading: isLoading5,
|
|
5308
|
+
error: error5,
|
|
5309
|
+
startDate: startDate5,
|
|
5310
|
+
endDate: endDate5
|
|
5311
|
+
} = useProfitAndLossQuery({
|
|
5312
|
+
startDate: dates[5].startDate,
|
|
5313
|
+
endDate: dates[5].endDate,
|
|
5314
|
+
tagFilter,
|
|
5315
|
+
reportingBasis
|
|
5316
|
+
});
|
|
5317
|
+
const {
|
|
5318
|
+
data: data6,
|
|
5319
|
+
isLoading: isLoading6,
|
|
5320
|
+
error: error6,
|
|
5321
|
+
startDate: startDate6,
|
|
5322
|
+
endDate: endDate6
|
|
5323
|
+
} = useProfitAndLossQuery({
|
|
5324
|
+
startDate: dates[6].startDate,
|
|
5325
|
+
endDate: dates[6].endDate,
|
|
5326
|
+
tagFilter,
|
|
5327
|
+
reportingBasis
|
|
5328
|
+
});
|
|
5329
|
+
const {
|
|
5330
|
+
data: data7,
|
|
5331
|
+
isLoading: isLoading7,
|
|
5332
|
+
error: error7,
|
|
5333
|
+
startDate: startDate7,
|
|
5334
|
+
endDate: endDate7
|
|
5335
|
+
} = useProfitAndLossQuery({
|
|
5336
|
+
startDate: dates[7].startDate,
|
|
5337
|
+
endDate: dates[7].endDate,
|
|
5338
|
+
tagFilter,
|
|
5339
|
+
reportingBasis
|
|
5340
|
+
});
|
|
5341
|
+
const {
|
|
5342
|
+
data: data8,
|
|
5343
|
+
isLoading: isLoading8,
|
|
5344
|
+
error: error8,
|
|
5345
|
+
startDate: startDate8,
|
|
5346
|
+
endDate: endDate8
|
|
5347
|
+
} = useProfitAndLossQuery({
|
|
5348
|
+
startDate: dates[8].startDate,
|
|
5349
|
+
endDate: dates[8].endDate,
|
|
5350
|
+
tagFilter,
|
|
5351
|
+
reportingBasis
|
|
5352
|
+
});
|
|
5353
|
+
const {
|
|
5354
|
+
data: data9,
|
|
5355
|
+
isLoading: isLoading9,
|
|
5356
|
+
error: error9,
|
|
5357
|
+
startDate: startDate9,
|
|
5358
|
+
endDate: endDate9
|
|
5359
|
+
} = useProfitAndLossQuery({
|
|
5360
|
+
startDate: dates[9].startDate,
|
|
5361
|
+
endDate: dates[9].endDate,
|
|
5362
|
+
tagFilter,
|
|
5363
|
+
reportingBasis
|
|
5364
|
+
});
|
|
5365
|
+
const {
|
|
5366
|
+
data: data10,
|
|
5367
|
+
isLoading: isLoading10,
|
|
5368
|
+
error: error10,
|
|
5369
|
+
startDate: startDate10,
|
|
5370
|
+
endDate: endDate10
|
|
5371
|
+
} = useProfitAndLossQuery({
|
|
5372
|
+
startDate: dates[10].startDate,
|
|
5373
|
+
endDate: dates[10].endDate,
|
|
5374
|
+
tagFilter,
|
|
5375
|
+
reportingBasis
|
|
5376
|
+
});
|
|
5377
|
+
const {
|
|
5378
|
+
data: data11,
|
|
5379
|
+
isLoading: isLoading11,
|
|
5380
|
+
error: error11,
|
|
5381
|
+
startDate: startDate11,
|
|
5382
|
+
endDate: endDate11
|
|
5383
|
+
} = useProfitAndLossQuery({
|
|
5384
|
+
startDate: dates[11].startDate,
|
|
5385
|
+
endDate: dates[11].endDate,
|
|
5386
|
+
tagFilter,
|
|
5387
|
+
reportingBasis
|
|
5388
|
+
});
|
|
5389
|
+
const { data, isLoading, error } = useMemo4(() => {
|
|
5390
|
+
return {
|
|
5391
|
+
data: [
|
|
5392
|
+
{
|
|
5393
|
+
data: data0,
|
|
5394
|
+
isLoading: isLoading0,
|
|
5395
|
+
error: error0,
|
|
5396
|
+
startDate: startDate0,
|
|
5397
|
+
endDate: endDate0
|
|
5398
|
+
},
|
|
5399
|
+
{
|
|
5400
|
+
data: data1,
|
|
5401
|
+
isLoading: isLoading1,
|
|
5402
|
+
error: error1,
|
|
5403
|
+
startDate: startDate1,
|
|
5404
|
+
endDate: endDate1
|
|
5405
|
+
},
|
|
5406
|
+
{
|
|
5407
|
+
data: data2,
|
|
5408
|
+
isLoading: isLoading2,
|
|
5409
|
+
error: error2,
|
|
5410
|
+
startDate: startDate2,
|
|
5411
|
+
endDate: endDate2
|
|
5412
|
+
},
|
|
5413
|
+
{
|
|
5414
|
+
data: data3,
|
|
5415
|
+
isLoading: isLoading3,
|
|
5416
|
+
error: error3,
|
|
5417
|
+
startDate: startDate3,
|
|
5418
|
+
endDate: endDate3
|
|
5419
|
+
},
|
|
5420
|
+
{
|
|
5421
|
+
data: data4,
|
|
5422
|
+
isLoading: isLoading4,
|
|
5423
|
+
error: error4,
|
|
5424
|
+
startDate: startDate4,
|
|
5425
|
+
endDate: endDate4
|
|
5426
|
+
},
|
|
5427
|
+
{
|
|
5428
|
+
data: data5,
|
|
5429
|
+
isLoading: isLoading5,
|
|
5430
|
+
error: error5,
|
|
5431
|
+
startDate: startDate5,
|
|
5432
|
+
endDate: endDate5
|
|
5433
|
+
},
|
|
5434
|
+
{
|
|
5435
|
+
data: data6,
|
|
5436
|
+
isLoading: isLoading6,
|
|
5437
|
+
error: error6,
|
|
5438
|
+
startDate: startDate6,
|
|
5439
|
+
endDate: endDate6
|
|
5440
|
+
},
|
|
5441
|
+
{
|
|
5442
|
+
data: data7,
|
|
5443
|
+
isLoading: isLoading7,
|
|
5444
|
+
error: error7,
|
|
5445
|
+
startDate: startDate7,
|
|
5446
|
+
endDate: endDate7
|
|
5447
|
+
},
|
|
5448
|
+
{
|
|
5449
|
+
data: data8,
|
|
5450
|
+
isLoading: isLoading8,
|
|
5451
|
+
error: error8,
|
|
5452
|
+
startDate: startDate8,
|
|
5453
|
+
endDate: endDate8
|
|
5454
|
+
},
|
|
5455
|
+
{
|
|
5456
|
+
data: data9,
|
|
5457
|
+
isLoading: isLoading9,
|
|
5458
|
+
error: error9,
|
|
5459
|
+
startDate: startDate9,
|
|
5460
|
+
endDate: endDate9
|
|
5461
|
+
},
|
|
5462
|
+
{
|
|
5463
|
+
data: data10,
|
|
5464
|
+
isLoading: isLoading10,
|
|
5465
|
+
error: error10,
|
|
5466
|
+
startDate: startDate10,
|
|
5467
|
+
endDate: endDate10
|
|
5468
|
+
},
|
|
5469
|
+
{
|
|
5470
|
+
data: data11,
|
|
5471
|
+
isLoading: isLoading11,
|
|
5472
|
+
error: error11,
|
|
5473
|
+
startDate: startDate11,
|
|
5474
|
+
endDate: endDate11
|
|
5475
|
+
}
|
|
5476
|
+
],
|
|
5477
|
+
error: [
|
|
5478
|
+
error0,
|
|
5479
|
+
error1,
|
|
5480
|
+
error2,
|
|
5481
|
+
error3,
|
|
5482
|
+
error4,
|
|
5483
|
+
error5,
|
|
5484
|
+
error6,
|
|
5485
|
+
error7,
|
|
5486
|
+
error8,
|
|
5487
|
+
error9,
|
|
5488
|
+
error10,
|
|
5489
|
+
error11
|
|
5490
|
+
].find((x) => !!x),
|
|
5491
|
+
isLoading: [
|
|
5492
|
+
isLoading0,
|
|
5493
|
+
isLoading1,
|
|
5494
|
+
isLoading2,
|
|
5495
|
+
isLoading3,
|
|
5496
|
+
isLoading4,
|
|
5497
|
+
isLoading5,
|
|
5498
|
+
isLoading6,
|
|
5499
|
+
isLoading7,
|
|
5500
|
+
isLoading8,
|
|
5501
|
+
isLoading9,
|
|
5502
|
+
isLoading10,
|
|
5503
|
+
isLoading11
|
|
5504
|
+
].find((x) => !!x)
|
|
5505
|
+
};
|
|
5506
|
+
}, [
|
|
5507
|
+
data0,
|
|
5508
|
+
data1,
|
|
5509
|
+
data2,
|
|
5510
|
+
data3,
|
|
5511
|
+
data4,
|
|
5512
|
+
data5,
|
|
5513
|
+
data6,
|
|
5514
|
+
data7,
|
|
5515
|
+
data8,
|
|
5516
|
+
data9,
|
|
5517
|
+
data10,
|
|
5518
|
+
data11,
|
|
5519
|
+
isLoading0,
|
|
5520
|
+
isLoading1,
|
|
5521
|
+
isLoading2,
|
|
5522
|
+
isLoading3,
|
|
5523
|
+
isLoading4,
|
|
5524
|
+
isLoading5,
|
|
5525
|
+
isLoading6,
|
|
5526
|
+
isLoading7,
|
|
5527
|
+
isLoading8,
|
|
5528
|
+
isLoading9,
|
|
5529
|
+
isLoading10,
|
|
5530
|
+
isLoading11,
|
|
5531
|
+
error0,
|
|
5532
|
+
error1,
|
|
5533
|
+
error2,
|
|
5534
|
+
error3,
|
|
5535
|
+
error4,
|
|
5536
|
+
error5,
|
|
5537
|
+
error6,
|
|
5538
|
+
error7,
|
|
5539
|
+
error8,
|
|
5540
|
+
error9,
|
|
5541
|
+
error10,
|
|
5542
|
+
error11
|
|
5543
|
+
]);
|
|
5544
|
+
useEffect10(() => {
|
|
5545
|
+
if (isLoading && loaded === "initial") {
|
|
5546
|
+
setLoaded("loading");
|
|
5547
|
+
return;
|
|
5548
|
+
}
|
|
5549
|
+
if (!isLoading && data && !data.find((x) => !x.data && !x.error)) {
|
|
5550
|
+
setLoaded("complete");
|
|
5551
|
+
}
|
|
5552
|
+
}, [data, isLoading]);
|
|
5553
|
+
return {
|
|
5554
|
+
data,
|
|
5555
|
+
isLoading,
|
|
5556
|
+
loaded,
|
|
5557
|
+
error
|
|
5558
|
+
};
|
|
5559
|
+
};
|
|
5189
5560
|
|
|
5190
5561
|
// src/utils/format.ts
|
|
5191
5562
|
var capitalizeFirstLetter = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
@@ -5226,46 +5597,69 @@ var humanizeEnum = (text) => {
|
|
|
5226
5597
|
};
|
|
5227
5598
|
|
|
5228
5599
|
// src/components/ProfitAndLossChart/Indicator.tsx
|
|
5229
|
-
import React65, { useEffect as
|
|
5600
|
+
import React65, { useEffect as useEffect11, useState as useState15 } from "react";
|
|
5230
5601
|
var emptyViewBox = { x: 0, y: 0, width: 0, height: 0 };
|
|
5231
5602
|
var Indicator = ({
|
|
5232
|
-
viewBox = {},
|
|
5233
5603
|
className,
|
|
5234
5604
|
animateFrom,
|
|
5235
|
-
setAnimateFrom
|
|
5605
|
+
setAnimateFrom,
|
|
5606
|
+
customCursorSize,
|
|
5607
|
+
setCustomCursorSize,
|
|
5608
|
+
viewBox = {}
|
|
5236
5609
|
}) => {
|
|
5237
5610
|
if (!className?.match(/selected/)) {
|
|
5238
5611
|
return null;
|
|
5239
5612
|
}
|
|
5613
|
+
const [opacityIndicator, setOpacityIndicator] = useState15(0);
|
|
5240
5614
|
const { x: animateTo = 0, width = 0 } = "x" in viewBox ? viewBox : emptyViewBox;
|
|
5241
5615
|
const margin = width > 12 ? 4 : 1;
|
|
5242
5616
|
const boxWidth = width * 2 + margin;
|
|
5243
5617
|
const multiplier = width > 12 ? 1.2 : 1;
|
|
5244
5618
|
const xOffset = (boxWidth * multiplier - boxWidth) / 2;
|
|
5245
|
-
const borderRadius =
|
|
5246
|
-
|
|
5619
|
+
const borderRadius = 6;
|
|
5620
|
+
const rectWidth = `${boxWidth * multiplier}px`;
|
|
5621
|
+
const rectHeight = "calc(100% - 38px)";
|
|
5622
|
+
useEffect11(() => {
|
|
5623
|
+
if (Math.abs(animateTo - animateFrom) < 30) {
|
|
5624
|
+
setOpacityIndicator(0);
|
|
5625
|
+
}
|
|
5247
5626
|
setAnimateFrom(animateTo);
|
|
5627
|
+
setTimeout(() => {
|
|
5628
|
+
setOpacityIndicator(1);
|
|
5629
|
+
}, 200);
|
|
5248
5630
|
}, [animateTo]);
|
|
5631
|
+
const rectRef = (ref) => {
|
|
5632
|
+
if (ref) {
|
|
5633
|
+
const refRectWidth = ref.getBoundingClientRect().width;
|
|
5634
|
+
const refRectHeight = ref.getBoundingClientRect().height;
|
|
5635
|
+
if (customCursorSize.width !== refRectWidth || customCursorSize.height !== refRectHeight) {
|
|
5636
|
+
setCustomCursorSize(refRectWidth, refRectHeight, actualX - xOffset);
|
|
5637
|
+
}
|
|
5638
|
+
}
|
|
5639
|
+
};
|
|
5249
5640
|
const actualX = animateFrom === -1 ? animateTo : animateFrom;
|
|
5250
5641
|
return /* @__PURE__ */ React65.createElement(
|
|
5251
5642
|
"rect",
|
|
5252
5643
|
{
|
|
5644
|
+
ref: rectRef,
|
|
5253
5645
|
className: "Layer__profit-and-loss-chart__selection-indicator",
|
|
5254
5646
|
rx: borderRadius,
|
|
5255
5647
|
ry: borderRadius,
|
|
5256
5648
|
style: {
|
|
5257
|
-
width:
|
|
5649
|
+
width: rectWidth,
|
|
5258
5650
|
// @ts-expect-error -- y is fine but x apparently isn't!
|
|
5259
5651
|
x: actualX - xOffset,
|
|
5260
|
-
y:
|
|
5261
|
-
height:
|
|
5652
|
+
y: 1,
|
|
5653
|
+
height: rectHeight,
|
|
5654
|
+
opacity: opacityIndicator
|
|
5262
5655
|
}
|
|
5263
5656
|
}
|
|
5264
5657
|
);
|
|
5265
5658
|
};
|
|
5266
5659
|
|
|
5267
5660
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
5268
|
-
import
|
|
5661
|
+
import classNames26 from "classnames";
|
|
5662
|
+
import { format as format4, parseISO as parseISO8, startOfMonth as startOfMonth4 } from "date-fns";
|
|
5269
5663
|
import {
|
|
5270
5664
|
BarChart,
|
|
5271
5665
|
XAxis,
|
|
@@ -5283,82 +5677,24 @@ var barSize = 20;
|
|
|
5283
5677
|
var ProfitAndLossChart = () => {
|
|
5284
5678
|
const { getColor } = useLayerContext();
|
|
5285
5679
|
const { changeDateRange, dateRange } = useContext2(ProfitAndLoss.Context);
|
|
5286
|
-
const
|
|
5680
|
+
const [customCursorSize, setCustomCursorSize] = useState16({
|
|
5681
|
+
width: 0,
|
|
5682
|
+
height: 0,
|
|
5683
|
+
x: 0
|
|
5684
|
+
});
|
|
5685
|
+
const [barAnimActive, setBarAnimActive] = useState16(true);
|
|
5287
5686
|
const startSelectionMonth = dateRange.startDate.getMonth();
|
|
5288
5687
|
const endSelectionMonth = dateRange.endDate.getMonth();
|
|
5289
|
-
const
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
endDate: endOfMonth2(sub(thisMonth, { months: 10 }))
|
|
5300
|
-
})?.data
|
|
5301
|
-
);
|
|
5302
|
-
monthData.push(
|
|
5303
|
-
useProfitAndLoss({
|
|
5304
|
-
startDate: startOfMonth2(sub(thisMonth, { months: 9 })),
|
|
5305
|
-
endDate: endOfMonth2(sub(thisMonth, { months: 9 }))
|
|
5306
|
-
})?.data
|
|
5307
|
-
);
|
|
5308
|
-
monthData.push(
|
|
5309
|
-
useProfitAndLoss({
|
|
5310
|
-
startDate: startOfMonth2(sub(thisMonth, { months: 8 })),
|
|
5311
|
-
endDate: endOfMonth2(sub(thisMonth, { months: 8 }))
|
|
5312
|
-
})?.data
|
|
5313
|
-
);
|
|
5314
|
-
monthData.push(
|
|
5315
|
-
useProfitAndLoss({
|
|
5316
|
-
startDate: startOfMonth2(sub(thisMonth, { months: 7 })),
|
|
5317
|
-
endDate: endOfMonth2(sub(thisMonth, { months: 7 }))
|
|
5318
|
-
})?.data
|
|
5319
|
-
);
|
|
5320
|
-
monthData.push(
|
|
5321
|
-
useProfitAndLoss({
|
|
5322
|
-
startDate: startOfMonth2(sub(thisMonth, { months: 6 })),
|
|
5323
|
-
endDate: endOfMonth2(sub(thisMonth, { months: 6 }))
|
|
5324
|
-
})?.data
|
|
5325
|
-
);
|
|
5326
|
-
monthData.push(
|
|
5327
|
-
useProfitAndLoss({
|
|
5328
|
-
startDate: startOfMonth2(sub(thisMonth, { months: 5 })),
|
|
5329
|
-
endDate: endOfMonth2(sub(thisMonth, { months: 5 }))
|
|
5330
|
-
})?.data
|
|
5331
|
-
);
|
|
5332
|
-
monthData.push(
|
|
5333
|
-
useProfitAndLoss({
|
|
5334
|
-
startDate: startOfMonth2(sub(thisMonth, { months: 4 })),
|
|
5335
|
-
endDate: endOfMonth2(sub(thisMonth, { months: 4 }))
|
|
5336
|
-
})?.data
|
|
5337
|
-
);
|
|
5338
|
-
monthData.push(
|
|
5339
|
-
useProfitAndLoss({
|
|
5340
|
-
startDate: startOfMonth2(sub(thisMonth, { months: 3 })),
|
|
5341
|
-
endDate: endOfMonth2(sub(thisMonth, { months: 3 }))
|
|
5342
|
-
})?.data
|
|
5343
|
-
);
|
|
5344
|
-
monthData.push(
|
|
5345
|
-
useProfitAndLoss({
|
|
5346
|
-
startDate: startOfMonth2(sub(thisMonth, { months: 2 })),
|
|
5347
|
-
endDate: endOfMonth2(sub(thisMonth, { months: 2 }))
|
|
5348
|
-
})?.data
|
|
5349
|
-
);
|
|
5350
|
-
monthData.push(
|
|
5351
|
-
useProfitAndLoss({
|
|
5352
|
-
startDate: startOfMonth2(sub(thisMonth, { months: 1 })),
|
|
5353
|
-
endDate: endOfMonth2(sub(thisMonth, { months: 1 }))
|
|
5354
|
-
})?.data
|
|
5355
|
-
);
|
|
5356
|
-
monthData.push(
|
|
5357
|
-
useProfitAndLoss({
|
|
5358
|
-
startDate: thisMonth,
|
|
5359
|
-
endDate: endOfMonth2(thisMonth)
|
|
5360
|
-
})?.data
|
|
5361
|
-
);
|
|
5688
|
+
const { data, loaded } = useProfitAndLossLTM({
|
|
5689
|
+
currentDate: startOfMonth4(Date.now())
|
|
5690
|
+
});
|
|
5691
|
+
useEffect12(() => {
|
|
5692
|
+
if (loaded === "complete") {
|
|
5693
|
+
setTimeout(() => {
|
|
5694
|
+
setBarAnimActive(false);
|
|
5695
|
+
}, 1e3);
|
|
5696
|
+
}
|
|
5697
|
+
}, [loaded]);
|
|
5362
5698
|
const getMonthName = (pnl) => pnl ? format4(parseISO8(pnl.start_date), "LLL") : "";
|
|
5363
5699
|
const summarizePnL = (pnl) => ({
|
|
5364
5700
|
name: getMonthName(pnl),
|
|
@@ -5368,56 +5704,68 @@ var ProfitAndLossChart = () => {
|
|
|
5368
5704
|
selected: !!pnl && parseISO8(pnl.start_date).getMonth() >= startSelectionMonth && parseISO8(pnl.end_date).getMonth() <= endSelectionMonth
|
|
5369
5705
|
});
|
|
5370
5706
|
const onClick = ({ activeTooltipIndex }) => {
|
|
5371
|
-
const selection =
|
|
5372
|
-
if (selection) {
|
|
5373
|
-
const { start_date
|
|
5707
|
+
const selection = data[activeTooltipIndex || -1];
|
|
5708
|
+
if (selection && selection.data) {
|
|
5709
|
+
const { start_date, end_date } = selection.data;
|
|
5374
5710
|
changeDateRange({
|
|
5375
|
-
startDate: parseISO8(
|
|
5376
|
-
endDate: parseISO8(
|
|
5711
|
+
startDate: parseISO8(start_date),
|
|
5712
|
+
endDate: parseISO8(end_date)
|
|
5377
5713
|
});
|
|
5378
5714
|
}
|
|
5379
5715
|
};
|
|
5380
|
-
const CustomTooltip = ({
|
|
5381
|
-
active,
|
|
5382
|
-
payload,
|
|
5383
|
-
label
|
|
5384
|
-
}) => {
|
|
5716
|
+
const CustomTooltip = ({ active, payload }) => {
|
|
5385
5717
|
if (active && payload && payload.length) {
|
|
5386
5718
|
const netProfit = payload[0].payload.netProfit ?? 0;
|
|
5387
5719
|
const netProfitClass = netProfit > 0 ? "positive" : netProfit < 0 ? "negative" : "";
|
|
5388
|
-
return /* @__PURE__ */ React66.createElement("div", { className: "Layer__chart__tooltip" }, /* @__PURE__ */ React66.createElement("ul", { className: "Layer__chart__tooltip-list" }, /* @__PURE__ */ React66.createElement("li", null, /* @__PURE__ */ React66.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[0].name ?? "")), /* @__PURE__ */ React66.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[0].value ?? 0)))), /* @__PURE__ */ React66.createElement("li", null, /* @__PURE__ */ React66.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[1].name ?? "")), /* @__PURE__ */ React66.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[1].value ?? 0)))), /* @__PURE__ */ React66.createElement("li", null, /* @__PURE__ */ React66.createElement("label", { className: "Layer__chart__tooltip-label" }, "Net Profit"), /* @__PURE__ */ React66.createElement(
|
|
5720
|
+
return /* @__PURE__ */ React66.createElement("div", { className: "Layer__chart__tooltip" }, loaded !== "complete" ? /* @__PURE__ */ React66.createElement(Text, null, "Loading...") : /* @__PURE__ */ React66.createElement("ul", { className: "Layer__chart__tooltip-list" }, /* @__PURE__ */ React66.createElement("li", null, /* @__PURE__ */ React66.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[0].name ?? "")), /* @__PURE__ */ React66.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[0].value ?? 0)))), /* @__PURE__ */ React66.createElement("li", null, /* @__PURE__ */ React66.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[1].name ?? "")), /* @__PURE__ */ React66.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[1].value ?? 0)))), /* @__PURE__ */ React66.createElement("li", null, /* @__PURE__ */ React66.createElement("label", { className: "Layer__chart__tooltip-label" }, "Net Profit"), /* @__PURE__ */ React66.createElement(
|
|
5721
|
+
"span",
|
|
5722
|
+
{
|
|
5723
|
+
className: `Layer__chart__tooltip-value ${netProfitClass}`
|
|
5724
|
+
},
|
|
5725
|
+
"$",
|
|
5726
|
+
centsToDollars(netProfit)
|
|
5727
|
+
))));
|
|
5389
5728
|
}
|
|
5390
5729
|
return null;
|
|
5391
5730
|
};
|
|
5392
5731
|
const CustomizedCursor = (props) => {
|
|
5393
|
-
const { x,
|
|
5732
|
+
const { x, y } = props;
|
|
5733
|
+
const { width, height } = customCursorSize;
|
|
5734
|
+
const offsetX = width * 0.1;
|
|
5394
5735
|
return /* @__PURE__ */ React66.createElement(
|
|
5395
5736
|
Rectangle,
|
|
5396
5737
|
{
|
|
5397
|
-
fill:
|
|
5738
|
+
fill: "#F7F8FA",
|
|
5398
5739
|
stroke: "none",
|
|
5399
|
-
x: x +
|
|
5400
|
-
y
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5740
|
+
x: x + offsetX,
|
|
5741
|
+
y,
|
|
5742
|
+
width,
|
|
5743
|
+
height,
|
|
5744
|
+
radius: 6,
|
|
5404
5745
|
className: "Layer__chart__tooltip-cursor"
|
|
5405
5746
|
}
|
|
5406
5747
|
);
|
|
5407
5748
|
};
|
|
5408
|
-
const
|
|
5409
|
-
(
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5749
|
+
const theData = useMemo5(() => {
|
|
5750
|
+
if (loaded !== "complete") {
|
|
5751
|
+
return data?.map((x) => ({
|
|
5752
|
+
name: format4(x.startDate, "LLL"),
|
|
5753
|
+
revenue: 1,
|
|
5754
|
+
expenses: 1,
|
|
5755
|
+
netProfit: 0,
|
|
5756
|
+
selected: false
|
|
5757
|
+
}));
|
|
5758
|
+
}
|
|
5759
|
+
return data?.map((x) => summarizePnL(x.data));
|
|
5760
|
+
}, [startSelectionMonth, endSelectionMonth, loaded]);
|
|
5761
|
+
const [animateFrom, setAnimateFrom] = useState16(-1);
|
|
5417
5762
|
return /* @__PURE__ */ React66.createElement(
|
|
5418
5763
|
ResponsiveContainer,
|
|
5419
5764
|
{
|
|
5420
|
-
className:
|
|
5765
|
+
className: classNames26(
|
|
5766
|
+
"Layer__chart-container",
|
|
5767
|
+
loaded !== "complete" && "Layer__chart-container--loading"
|
|
5768
|
+
),
|
|
5421
5769
|
width: "100%",
|
|
5422
5770
|
height: "100%",
|
|
5423
5771
|
minHeight: 200
|
|
@@ -5426,7 +5774,7 @@ var ProfitAndLossChart = () => {
|
|
|
5426
5774
|
BarChart,
|
|
5427
5775
|
{
|
|
5428
5776
|
margin: { left: 12, right: 12, bottom: 12 },
|
|
5429
|
-
data,
|
|
5777
|
+
data: theData,
|
|
5430
5778
|
onClick,
|
|
5431
5779
|
barGap,
|
|
5432
5780
|
className: "Layer__profit-and-loss-chart"
|
|
@@ -5452,9 +5800,9 @@ var ProfitAndLossChart = () => {
|
|
|
5452
5800
|
/* @__PURE__ */ React66.createElement(
|
|
5453
5801
|
Legend,
|
|
5454
5802
|
{
|
|
5455
|
-
verticalAlign: "
|
|
5803
|
+
verticalAlign: "bottom",
|
|
5456
5804
|
align: "left",
|
|
5457
|
-
wrapperStyle: {
|
|
5805
|
+
wrapperStyle: { bottom: 0 },
|
|
5458
5806
|
payload: [
|
|
5459
5807
|
{
|
|
5460
5808
|
value: "Revenue",
|
|
@@ -5475,7 +5823,7 @@ var ProfitAndLossChart = () => {
|
|
|
5475
5823
|
{
|
|
5476
5824
|
dataKey: "revenue",
|
|
5477
5825
|
barSize,
|
|
5478
|
-
isAnimationActive:
|
|
5826
|
+
isAnimationActive: barAnimActive,
|
|
5479
5827
|
radius: [2, 2, 0, 0],
|
|
5480
5828
|
className: "Layer__profit-and-loss-chart__bar--income"
|
|
5481
5829
|
},
|
|
@@ -5485,30 +5833,34 @@ var ProfitAndLossChart = () => {
|
|
|
5485
5833
|
content: /* @__PURE__ */ React66.createElement(
|
|
5486
5834
|
Indicator,
|
|
5487
5835
|
{
|
|
5836
|
+
setCustomCursorSize: (width, height, x) => setCustomCursorSize({ width, height, x }),
|
|
5837
|
+
customCursorSize,
|
|
5488
5838
|
animateFrom,
|
|
5489
5839
|
setAnimateFrom
|
|
5490
5840
|
}
|
|
5491
5841
|
)
|
|
5492
5842
|
}
|
|
5493
5843
|
),
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5844
|
+
theData?.map((entry) => {
|
|
5845
|
+
return /* @__PURE__ */ React66.createElement(
|
|
5846
|
+
Cell,
|
|
5847
|
+
{
|
|
5848
|
+
key: entry.name,
|
|
5849
|
+
className: entry.selected ? "Layer__profit-and-loss-chart__cell--selected" : ""
|
|
5850
|
+
}
|
|
5851
|
+
);
|
|
5852
|
+
})
|
|
5501
5853
|
),
|
|
5502
5854
|
/* @__PURE__ */ React66.createElement(
|
|
5503
5855
|
Bar,
|
|
5504
5856
|
{
|
|
5505
5857
|
dataKey: "expenses",
|
|
5506
5858
|
barSize,
|
|
5507
|
-
isAnimationActive:
|
|
5859
|
+
isAnimationActive: barAnimActive,
|
|
5508
5860
|
radius: [2, 2, 0, 0],
|
|
5509
5861
|
className: "Layer__profit-and-loss-chart__bar--expenses"
|
|
5510
5862
|
},
|
|
5511
|
-
|
|
5863
|
+
theData.map((entry) => /* @__PURE__ */ React66.createElement(
|
|
5512
5864
|
Cell,
|
|
5513
5865
|
{
|
|
5514
5866
|
key: entry.name,
|
|
@@ -5521,19 +5873,19 @@ var ProfitAndLossChart = () => {
|
|
|
5521
5873
|
};
|
|
5522
5874
|
|
|
5523
5875
|
// src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
|
|
5524
|
-
import React67, { useContext as useContext3, useState as
|
|
5525
|
-
import { add, endOfMonth as
|
|
5876
|
+
import React67, { useContext as useContext3, useState as useState17, useEffect as useEffect13 } from "react";
|
|
5877
|
+
import { add, endOfMonth as endOfMonth4, format as format5, startOfMonth as startOfMonth5 } from "date-fns";
|
|
5526
5878
|
var ProfitAndLossDatePicker = () => {
|
|
5527
5879
|
const { changeDateRange, dateRange } = useContext3(ProfitAndLoss.Context);
|
|
5528
|
-
const [isAnimating, setIsAnimating] =
|
|
5529
|
-
const [localDate, setLocalDate] =
|
|
5530
|
-
const [nextOpacity, setNextOpacity] =
|
|
5531
|
-
const [currentOpacity, setCurrentOpacity] =
|
|
5532
|
-
const [transformStyle, setTransformStyle] =
|
|
5880
|
+
const [isAnimating, setIsAnimating] = useState17(false);
|
|
5881
|
+
const [localDate, setLocalDate] = useState17(dateRange.startDate);
|
|
5882
|
+
const [nextOpacity, setNextOpacity] = useState17(0);
|
|
5883
|
+
const [currentOpacity, setCurrentOpacity] = useState17(1);
|
|
5884
|
+
const [transformStyle, setTransformStyle] = useState17({
|
|
5533
5885
|
transform: "translateX(33%)",
|
|
5534
5886
|
transition: "ease"
|
|
5535
5887
|
});
|
|
5536
|
-
|
|
5888
|
+
useEffect13(() => {
|
|
5537
5889
|
if (dateRange.startDate !== localDate && !isAnimating) {
|
|
5538
5890
|
setLocalDate(dateRange.startDate);
|
|
5539
5891
|
setTransformStyle({ transform: "translateX(33%)", transition: "none" });
|
|
@@ -5549,8 +5901,8 @@ var ProfitAndLossDatePicker = () => {
|
|
|
5549
5901
|
setCurrentOpacity(0);
|
|
5550
5902
|
}
|
|
5551
5903
|
changeDateRange({
|
|
5552
|
-
startDate:
|
|
5553
|
-
endDate:
|
|
5904
|
+
startDate: startOfMonth5(newDate),
|
|
5905
|
+
endDate: endOfMonth4(newDate)
|
|
5554
5906
|
});
|
|
5555
5907
|
const translateXValue = monthsToAdd > 0 ? "0%" : "66%";
|
|
5556
5908
|
setTransformStyle({
|
|
@@ -5571,64 +5923,64 @@ var ProfitAndLossDatePicker = () => {
|
|
|
5571
5923
|
const currentLabel = format5(localDate, "LLLL, y");
|
|
5572
5924
|
const prevLabel = format5(add(localDate, { months: -1 }), "LLLL, y");
|
|
5573
5925
|
const nextLabel = format5(add(localDate, { months: 1 }), "LLLL, y");
|
|
5574
|
-
return /* @__PURE__ */ React67.createElement(
|
|
5926
|
+
return /* @__PURE__ */ React67.createElement("div", { className: "Layer__profit-and-loss-date-picker" }, /* @__PURE__ */ React67.createElement(
|
|
5575
5927
|
"div",
|
|
5576
5928
|
{
|
|
5577
|
-
className: "Layer__profit-and-loss-date-
|
|
5929
|
+
className: "Layer__profit-and-loss-date-picker__labels-container",
|
|
5930
|
+
style: transformStyle
|
|
5578
5931
|
},
|
|
5579
|
-
/* @__PURE__ */ React67.createElement("
|
|
5932
|
+
/* @__PURE__ */ React67.createElement("span", { className: "Layer__profit-and-loss-date-picker__label" }, prevLabel),
|
|
5933
|
+
/* @__PURE__ */ React67.createElement(
|
|
5580
5934
|
"span",
|
|
5581
5935
|
{
|
|
5582
5936
|
className: "Layer__profit-and-loss-date-picker__label",
|
|
5583
5937
|
style: { opacity: currentOpacity }
|
|
5584
5938
|
},
|
|
5585
5939
|
currentLabel
|
|
5586
|
-
),
|
|
5940
|
+
),
|
|
5941
|
+
/* @__PURE__ */ React67.createElement(
|
|
5587
5942
|
"span",
|
|
5588
5943
|
{
|
|
5589
5944
|
className: "Layer__profit-and-loss-date-picker__label",
|
|
5590
5945
|
style: { opacity: nextOpacity }
|
|
5591
5946
|
},
|
|
5592
5947
|
nextLabel
|
|
5593
|
-
)
|
|
5948
|
+
)
|
|
5949
|
+
), /* @__PURE__ */ React67.createElement(
|
|
5950
|
+
"button",
|
|
5951
|
+
{
|
|
5952
|
+
"aria-label": "View Previous Month",
|
|
5953
|
+
className: "Layer__profit-and-loss-date-picker__button",
|
|
5954
|
+
onClick: () => change(-1),
|
|
5955
|
+
disabled: isAnimating
|
|
5956
|
+
},
|
|
5594
5957
|
/* @__PURE__ */ React67.createElement(
|
|
5595
|
-
|
|
5958
|
+
ChevronLeft_default,
|
|
5596
5959
|
{
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
),
|
|
5960
|
+
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
5961
|
+
size: 16
|
|
5962
|
+
}
|
|
5963
|
+
)
|
|
5964
|
+
), /* @__PURE__ */ React67.createElement(
|
|
5965
|
+
"button",
|
|
5966
|
+
{
|
|
5967
|
+
"aria-label": "View Next Month",
|
|
5968
|
+
className: "Layer__profit-and-loss-date-picker__button",
|
|
5969
|
+
onClick: () => change(1),
|
|
5970
|
+
disabled: isAnimating
|
|
5971
|
+
},
|
|
5610
5972
|
/* @__PURE__ */ React67.createElement(
|
|
5611
|
-
|
|
5973
|
+
ChevronRight_default,
|
|
5612
5974
|
{
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
/* @__PURE__ */ React67.createElement(
|
|
5619
|
-
ChevronRight_default,
|
|
5620
|
-
{
|
|
5621
|
-
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
5622
|
-
size: 16
|
|
5623
|
-
}
|
|
5624
|
-
)
|
|
5625
|
-
),
|
|
5626
|
-
/* @__PURE__ */ React67.createElement("div", { className: "Layer__profit-and-loss-date-picker__effect-blur" })
|
|
5627
|
-
);
|
|
5975
|
+
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
5976
|
+
size: 16
|
|
5977
|
+
}
|
|
5978
|
+
)
|
|
5979
|
+
), /* @__PURE__ */ React67.createElement("div", { className: "Layer__profit-and-loss-date-picker__effect-blur" }));
|
|
5628
5980
|
};
|
|
5629
5981
|
|
|
5630
5982
|
// src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
|
|
5631
|
-
import React73, { useContext as useContext4, useState as
|
|
5983
|
+
import React73, { useContext as useContext4, useState as useState18 } from "react";
|
|
5632
5984
|
|
|
5633
5985
|
// src/icons/X.tsx
|
|
5634
5986
|
import * as React68 from "react";
|
|
@@ -5664,7 +6016,7 @@ var X = ({ size = 18, ...props }) => /* @__PURE__ */ React68.createElement(
|
|
|
5664
6016
|
var X_default = X;
|
|
5665
6017
|
|
|
5666
6018
|
// src/components/ProfitAndLossDetailedCharts/DetailedChart.tsx
|
|
5667
|
-
import React69, { useMemo as
|
|
6019
|
+
import React69, { useMemo as useMemo6 } from "react";
|
|
5668
6020
|
|
|
5669
6021
|
// src/config/charts.ts
|
|
5670
6022
|
var INACTIVE_OPACITY_LEVELS = [
|
|
@@ -5770,7 +6122,7 @@ var DetailedChart = ({
|
|
|
5770
6122
|
date,
|
|
5771
6123
|
isLoading
|
|
5772
6124
|
}) => {
|
|
5773
|
-
const chartData =
|
|
6125
|
+
const chartData = useMemo6(() => {
|
|
5774
6126
|
if (!filteredData) {
|
|
5775
6127
|
return [];
|
|
5776
6128
|
}
|
|
@@ -6041,7 +6393,7 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React70.createElem
|
|
|
6041
6393
|
width: size,
|
|
6042
6394
|
height: size
|
|
6043
6395
|
},
|
|
6044
|
-
/* @__PURE__ */ React70.createElement("g", {
|
|
6396
|
+
/* @__PURE__ */ React70.createElement("g", { clipPath: "url(#clip0_1758_75388)" }, /* @__PURE__ */ React70.createElement(
|
|
6045
6397
|
"path",
|
|
6046
6398
|
{
|
|
6047
6399
|
d: "M1.33325 8.5L3.99992 11.1667L6.66659 8.5",
|
|
@@ -6091,7 +6443,7 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React70.createElem
|
|
|
6091
6443
|
var SortArrows_default = SortArrows;
|
|
6092
6444
|
|
|
6093
6445
|
// src/components/ProfitAndLossDetailedCharts/DetailedTable.tsx
|
|
6094
|
-
import
|
|
6446
|
+
import classNames27 from "classnames";
|
|
6095
6447
|
var DetailedTable = ({
|
|
6096
6448
|
filteredData,
|
|
6097
6449
|
sidebarScope,
|
|
@@ -6101,7 +6453,7 @@ var DetailedTable = ({
|
|
|
6101
6453
|
setHoveredItem
|
|
6102
6454
|
}) => {
|
|
6103
6455
|
const buildColClass = (column) => {
|
|
6104
|
-
return
|
|
6456
|
+
return classNames27(
|
|
6105
6457
|
"Layer__sortable-col",
|
|
6106
6458
|
sidebarScope && filters[sidebarScope]?.sortBy === column ? `sort--${(sidebarScope && filters[sidebarScope]?.sortDirection) ?? "desc"}` : ""
|
|
6107
6459
|
);
|
|
@@ -6136,7 +6488,7 @@ var DetailedTable = ({
|
|
|
6136
6488
|
"tr",
|
|
6137
6489
|
{
|
|
6138
6490
|
key: `pl-side-table-item-${idx}`,
|
|
6139
|
-
className:
|
|
6491
|
+
className: classNames27(
|
|
6140
6492
|
"Layer__profit-and-loss-detailed-table__row",
|
|
6141
6493
|
hoveredItem && hoveredItem === item.display_name ? "active" : ""
|
|
6142
6494
|
),
|
|
@@ -6221,7 +6573,7 @@ var ProfitAndLossDetailedCharts = ({
|
|
|
6221
6573
|
const theScope = scope ? scope : sidebarScope;
|
|
6222
6574
|
const data = theScope === "revenue" ? filteredDataRevenue : filteredDataExpenses;
|
|
6223
6575
|
const total = theScope === "revenue" ? filteredTotalRevenue : filteredTotalExpenses;
|
|
6224
|
-
const [hoveredItem, setHoveredItem] =
|
|
6576
|
+
const [hoveredItem, setHoveredItem] = useState18();
|
|
6225
6577
|
return /* @__PURE__ */ React73.createElement("div", { className: "Layer__profit-and-loss-detailed-charts" }, /* @__PURE__ */ React73.createElement("header", { className: "Layer__profit-and-loss-detailed-charts__header" }, /* @__PURE__ */ React73.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__head" }, /* @__PURE__ */ React73.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, humanizeTitle(theScope)), /* @__PURE__ */ React73.createElement(Text, { size: "sm" /* sm */, className: "date" }, format6(dateRange.startDate, "LLLL, y")), showDatePicker && /* @__PURE__ */ React73.createElement(ProfitAndLossDatePicker, null)), !hideClose && /* @__PURE__ */ React73.createElement(
|
|
6226
6578
|
Button,
|
|
6227
6579
|
{
|
|
@@ -6263,17 +6615,17 @@ var ProfitAndLossDetailedCharts = ({
|
|
|
6263
6615
|
};
|
|
6264
6616
|
|
|
6265
6617
|
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
6266
|
-
import React76, { useContext as useContext5, useMemo as
|
|
6618
|
+
import React76, { useContext as useContext5, useMemo as useMemo7 } from "react";
|
|
6267
6619
|
|
|
6268
6620
|
// src/components/SkeletonLoader/SkeletonLoader.tsx
|
|
6269
6621
|
import React74 from "react";
|
|
6270
|
-
import
|
|
6622
|
+
import classNames28 from "classnames";
|
|
6271
6623
|
var SkeletonLoader = ({
|
|
6272
6624
|
height,
|
|
6273
6625
|
width,
|
|
6274
6626
|
className
|
|
6275
6627
|
}) => {
|
|
6276
|
-
const baseClassName =
|
|
6628
|
+
const baseClassName = classNames28(
|
|
6277
6629
|
"Layer__skeleton-loader Layer__anim--skeleton-loading",
|
|
6278
6630
|
className
|
|
6279
6631
|
);
|
|
@@ -6317,7 +6669,7 @@ var MiniChart = ({ data }) => {
|
|
|
6317
6669
|
};
|
|
6318
6670
|
|
|
6319
6671
|
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
6320
|
-
import
|
|
6672
|
+
import classNames29 from "classnames";
|
|
6321
6673
|
var CHART_PLACEHOLDER = [
|
|
6322
6674
|
{
|
|
6323
6675
|
name: "placeholder",
|
|
@@ -6355,13 +6707,14 @@ var ProfitAndLossSummaries = ({
|
|
|
6355
6707
|
setSidebarScope,
|
|
6356
6708
|
sidebarScope
|
|
6357
6709
|
} = useContext5(ProfitAndLoss.Context);
|
|
6358
|
-
const
|
|
6359
|
-
|
|
6710
|
+
const dataItem = Array.isArray(storedData) ? storedData[storedData.length - 1] : storedData;
|
|
6711
|
+
const expensesChartData = useMemo7(() => {
|
|
6712
|
+
return buildMiniChartData("expenses", dataItem);
|
|
6360
6713
|
}, [storedData]);
|
|
6361
|
-
const revenueChartData =
|
|
6362
|
-
return buildMiniChartData("revenue",
|
|
6714
|
+
const revenueChartData = useMemo7(() => {
|
|
6715
|
+
return buildMiniChartData("revenue", dataItem);
|
|
6363
6716
|
}, [storedData]);
|
|
6364
|
-
const data =
|
|
6717
|
+
const data = dataItem ? dataItem : { income: { value: NaN }, net_profit: NaN };
|
|
6365
6718
|
const incomeDirectionClass = (data.income.value ?? NaN) < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
6366
6719
|
const expensesDirectionClass = (data?.income?.value ?? NaN) - data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
6367
6720
|
const netProfitDirectionClass = data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
|
|
@@ -6373,7 +6726,7 @@ var ProfitAndLossSummaries = ({
|
|
|
6373
6726
|
/* @__PURE__ */ React76.createElement(
|
|
6374
6727
|
"div",
|
|
6375
6728
|
{
|
|
6376
|
-
className:
|
|
6729
|
+
className: classNames29(
|
|
6377
6730
|
"Layer__profit-and-loss-summaries__summary",
|
|
6378
6731
|
actionable && "Layer__actionable",
|
|
6379
6732
|
"Layer__profit-and-loss-summaries__summary--income",
|
|
@@ -6395,7 +6748,7 @@ var ProfitAndLossSummaries = ({
|
|
|
6395
6748
|
/* @__PURE__ */ React76.createElement(
|
|
6396
6749
|
"div",
|
|
6397
6750
|
{
|
|
6398
|
-
className:
|
|
6751
|
+
className: classNames29(
|
|
6399
6752
|
"Layer__profit-and-loss-summaries__summary",
|
|
6400
6753
|
actionable && "Layer__actionable",
|
|
6401
6754
|
"Layer__profit-and-loss-summaries__summary--expenses",
|
|
@@ -6419,7 +6772,7 @@ var ProfitAndLossSummaries = ({
|
|
|
6419
6772
|
/* @__PURE__ */ React76.createElement(
|
|
6420
6773
|
"div",
|
|
6421
6774
|
{
|
|
6422
|
-
className:
|
|
6775
|
+
className: classNames29(
|
|
6423
6776
|
"Layer__profit-and-loss-summaries__summary net-profit Layer__profit-and-loss-summaries__summary--net-profit",
|
|
6424
6777
|
actionable && "Layer__actionable"
|
|
6425
6778
|
)
|
|
@@ -6439,7 +6792,7 @@ var ProfitAndLossSummaries = ({
|
|
|
6439
6792
|
import React79, { useContext as useContext6 } from "react";
|
|
6440
6793
|
|
|
6441
6794
|
// src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
|
|
6442
|
-
import React78, { useState as
|
|
6795
|
+
import React78, { useState as useState19 } from "react";
|
|
6443
6796
|
|
|
6444
6797
|
// src/icons/PieChart.tsx
|
|
6445
6798
|
import * as React77 from "react";
|
|
@@ -6488,7 +6841,7 @@ var ProfitAndLossRow = ({
|
|
|
6488
6841
|
return null;
|
|
6489
6842
|
}
|
|
6490
6843
|
const { value, display_name, line_items } = lineItem;
|
|
6491
|
-
const [expanded, setExpanded] =
|
|
6844
|
+
const [expanded, setExpanded] = useState19(true);
|
|
6492
6845
|
const amount = value ?? 0;
|
|
6493
6846
|
const amountString = centsToDollars(Math.abs(amount));
|
|
6494
6847
|
const labelClasses = [
|
|
@@ -6610,19 +6963,20 @@ var empty_profit_and_loss_report_default = {
|
|
|
6610
6963
|
};
|
|
6611
6964
|
|
|
6612
6965
|
// src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
|
|
6613
|
-
import
|
|
6966
|
+
import classNames30 from "classnames";
|
|
6614
6967
|
var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
|
|
6615
6968
|
const {
|
|
6616
6969
|
data: actualData,
|
|
6617
6970
|
isLoading,
|
|
6618
6971
|
setSidebarScope
|
|
6619
6972
|
} = useContext6(ProfitAndLoss.Context);
|
|
6620
|
-
const
|
|
6973
|
+
const currentData = Array.isArray(actualData) ? actualData[actualData.length - 1] : actualData;
|
|
6974
|
+
const data = !currentData || isLoading ? empty_profit_and_loss_report_default : currentData;
|
|
6621
6975
|
if (isLoading || actualData === void 0) {
|
|
6622
6976
|
return /* @__PURE__ */ React79.createElement(
|
|
6623
6977
|
"div",
|
|
6624
6978
|
{
|
|
6625
|
-
className:
|
|
6979
|
+
className: classNames30(
|
|
6626
6980
|
"Layer__profit-and-loss-table__loader-container",
|
|
6627
6981
|
asContainer && "Layer__component-container"
|
|
6628
6982
|
)
|
|
@@ -6633,7 +6987,7 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
|
|
|
6633
6987
|
return /* @__PURE__ */ React79.createElement(React79.Fragment, null, /* @__PURE__ */ React79.createElement(
|
|
6634
6988
|
"div",
|
|
6635
6989
|
{
|
|
6636
|
-
className:
|
|
6990
|
+
className: classNames30(
|
|
6637
6991
|
"Layer__profit-and-loss-table Layer__profit-and-loss-table--main",
|
|
6638
6992
|
asContainer && "Layer__component-container"
|
|
6639
6993
|
)
|
|
@@ -6736,7 +7090,7 @@ var ProfitAndLossTable = ({ lockExpanded, asContainer }) => {
|
|
|
6736
7090
|
};
|
|
6737
7091
|
|
|
6738
7092
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
6739
|
-
import { endOfMonth as
|
|
7093
|
+
import { endOfMonth as endOfMonth5, startOfMonth as startOfMonth6 } from "date-fns";
|
|
6740
7094
|
var PNLContext = createContext2({
|
|
6741
7095
|
data: void 0,
|
|
6742
7096
|
filteredDataRevenue: [],
|
|
@@ -6747,8 +7101,8 @@ var PNLContext = createContext2({
|
|
|
6747
7101
|
isValidating: false,
|
|
6748
7102
|
error: void 0,
|
|
6749
7103
|
dateRange: {
|
|
6750
|
-
startDate:
|
|
6751
|
-
endDate:
|
|
7104
|
+
startDate: startOfMonth6(/* @__PURE__ */ new Date()),
|
|
7105
|
+
endDate: endOfMonth5(/* @__PURE__ */ new Date())
|
|
6752
7106
|
},
|
|
6753
7107
|
changeDateRange: () => {
|
|
6754
7108
|
},
|
|
@@ -6786,8 +7140,8 @@ ProfitAndLoss.DetailedCharts = ProfitAndLossDetailedCharts;
|
|
|
6786
7140
|
import React82, { useContext as useContext7, useRef as useRef14 } from "react";
|
|
6787
7141
|
|
|
6788
7142
|
// src/components/Panel/Panel.tsx
|
|
6789
|
-
import React81, { useEffect as
|
|
6790
|
-
import
|
|
7143
|
+
import React81, { useEffect as useEffect14, useState as useState20 } from "react";
|
|
7144
|
+
import classNames31 from "classnames";
|
|
6791
7145
|
var Panel = ({
|
|
6792
7146
|
children,
|
|
6793
7147
|
className,
|
|
@@ -6796,8 +7150,8 @@ var Panel = ({
|
|
|
6796
7150
|
sidebarIsOpen,
|
|
6797
7151
|
parentRef
|
|
6798
7152
|
}) => {
|
|
6799
|
-
const [sidebarHeight, setSidebarHeight] =
|
|
6800
|
-
|
|
7153
|
+
const [sidebarHeight, setSidebarHeight] = useState20(0);
|
|
7154
|
+
useEffect14(() => {
|
|
6801
7155
|
if (parentRef?.current?.offsetHeight) {
|
|
6802
7156
|
setSidebarHeight(parentRef?.current?.offsetHeight - 1);
|
|
6803
7157
|
}
|
|
@@ -6805,7 +7159,7 @@ var Panel = ({
|
|
|
6805
7159
|
return /* @__PURE__ */ React81.createElement(
|
|
6806
7160
|
"div",
|
|
6807
7161
|
{
|
|
6808
|
-
className:
|
|
7162
|
+
className: classNames31(
|
|
6809
7163
|
"Layer__panel",
|
|
6810
7164
|
className,
|
|
6811
7165
|
sidebarIsOpen && "Layer__panel--open"
|
|
@@ -6883,10 +7237,10 @@ var Components = ({
|
|
|
6883
7237
|
};
|
|
6884
7238
|
|
|
6885
7239
|
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
6886
|
-
import React96, { createContext as createContext3, useContext as useContext14, useState as
|
|
7240
|
+
import React96, { createContext as createContext3, useContext as useContext14, useState as useState26 } from "react";
|
|
6887
7241
|
|
|
6888
7242
|
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
6889
|
-
import { useState as
|
|
7243
|
+
import { useState as useState21 } from "react";
|
|
6890
7244
|
|
|
6891
7245
|
// src/components/ChartOfAccountsForm/constants.ts
|
|
6892
7246
|
var LEDGER_ACCOUNT_TYPES = [
|
|
@@ -7170,9 +7524,9 @@ var validateName = (formData) => {
|
|
|
7170
7524
|
var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.sub_accounts || [])]).flat().filter((id) => id);
|
|
7171
7525
|
var useChartOfAccounts = () => {
|
|
7172
7526
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
7173
|
-
const [form, setForm] =
|
|
7174
|
-
const [sendingForm, setSendingForm] =
|
|
7175
|
-
const [apiError, setApiError] =
|
|
7527
|
+
const [form, setForm] = useState21();
|
|
7528
|
+
const [sendingForm, setSendingForm] = useState21(false);
|
|
7529
|
+
const [apiError, setApiError] = useState21(void 0);
|
|
7176
7530
|
const { data, isLoading, isValidating, error, mutate } = useSWR6(
|
|
7177
7531
|
businessId && auth?.access_token && `chart-of-accounts-${businessId}`,
|
|
7178
7532
|
Layer.getLedgerAccountBalances(apiUrl, auth?.access_token, {
|
|
@@ -7356,12 +7710,12 @@ var useChartOfAccounts = () => {
|
|
|
7356
7710
|
};
|
|
7357
7711
|
|
|
7358
7712
|
// src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
|
|
7359
|
-
import { useState as
|
|
7713
|
+
import { useState as useState22 } from "react";
|
|
7360
7714
|
import useSWR7 from "swr";
|
|
7361
7715
|
var useLedgerAccounts = () => {
|
|
7362
7716
|
const { auth, businessId, apiUrl } = useLayerContext();
|
|
7363
|
-
const [accountId, setAccountId] =
|
|
7364
|
-
const [selectedEntryId, setSelectedEntryId] =
|
|
7717
|
+
const [accountId, setAccountId] = useState22();
|
|
7718
|
+
const [selectedEntryId, setSelectedEntryId] = useState22();
|
|
7365
7719
|
const { data, isLoading, isValidating, error, mutate } = useSWR7(
|
|
7366
7720
|
businessId && accountId && auth?.access_token && `ledger-accounts-lines-${businessId}-${accountId}`,
|
|
7367
7721
|
Layer.getLedgerAccountsLines(apiUrl, auth?.access_token, {
|
|
@@ -7407,7 +7761,7 @@ var useLedgerAccounts = () => {
|
|
|
7407
7761
|
import React88, { useContext as useContext10 } from "react";
|
|
7408
7762
|
|
|
7409
7763
|
// src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
|
|
7410
|
-
import React84, { useContext as useContext8, useEffect as
|
|
7764
|
+
import React84, { useContext as useContext8, useEffect as useEffect15, useState as useState23 } from "react";
|
|
7411
7765
|
|
|
7412
7766
|
// src/icons/Edit2.tsx
|
|
7413
7767
|
import * as React83 from "react";
|
|
@@ -7434,7 +7788,7 @@ var Edit2 = ({ size = 18, ...props }) => /* @__PURE__ */ React83.createElement(
|
|
|
7434
7788
|
var Edit2_default = Edit2;
|
|
7435
7789
|
|
|
7436
7790
|
// src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
|
|
7437
|
-
import
|
|
7791
|
+
import classNames32 from "classnames";
|
|
7438
7792
|
var INDENTATION = 24;
|
|
7439
7793
|
var MOBILE_INDENTATION = 12;
|
|
7440
7794
|
var EXPANDED_STYLE = {
|
|
@@ -7468,7 +7822,7 @@ var ChartOfAccountsRow = ({
|
|
|
7468
7822
|
const { form, editAccount } = useContext8(ChartOfAccountsContext);
|
|
7469
7823
|
const { setAccountId } = useContext8(LedgerAccountsContext);
|
|
7470
7824
|
const baseStyle = view === "desktop" ? EXPANDED_STYLE : EXPANDED_MOBILE_STYLE;
|
|
7471
|
-
const [isOpen, setIsOpen] =
|
|
7825
|
+
const [isOpen, setIsOpen] = useState23(defaultOpen);
|
|
7472
7826
|
const style = expanded ? {
|
|
7473
7827
|
...baseStyle,
|
|
7474
7828
|
transitionDelay: `${15 * index}ms`
|
|
@@ -7476,14 +7830,14 @@ var ChartOfAccountsRow = ({
|
|
|
7476
7830
|
...COLLAPSED_STYLE,
|
|
7477
7831
|
transitionDelay: `${acountsLength - 15 * index}ms`
|
|
7478
7832
|
};
|
|
7479
|
-
const [showComponent, setShowComponent] =
|
|
7480
|
-
|
|
7833
|
+
const [showComponent, setShowComponent] = useState23(false);
|
|
7834
|
+
useEffect15(() => {
|
|
7481
7835
|
const timeoutId = setTimeout(() => {
|
|
7482
7836
|
setShowComponent(true);
|
|
7483
7837
|
}, cumulativeIndex * 50);
|
|
7484
7838
|
return () => clearTimeout(timeoutId);
|
|
7485
7839
|
}, []);
|
|
7486
|
-
const baseClass =
|
|
7840
|
+
const baseClass = classNames32(
|
|
7487
7841
|
"Layer__table-row",
|
|
7488
7842
|
isOpen ? "Layer__table-row--expanded" : "Layer__table-row--collapsed",
|
|
7489
7843
|
!expanded && "Layer__table-row--hidden",
|
|
@@ -7491,11 +7845,11 @@ var ChartOfAccountsRow = ({
|
|
|
7491
7845
|
form?.accountId === account.id && "Layer__table-row--active",
|
|
7492
7846
|
!showComponent && "Layer__table-row--anim-starting-state"
|
|
7493
7847
|
);
|
|
7494
|
-
const desktopRowClass =
|
|
7848
|
+
const desktopRowClass = classNames32(
|
|
7495
7849
|
baseClass,
|
|
7496
7850
|
"Layer__chart-of-accounts__row---desktop"
|
|
7497
7851
|
);
|
|
7498
|
-
const mobileRowClass =
|
|
7852
|
+
const mobileRowClass = classNames32(
|
|
7499
7853
|
baseClass,
|
|
7500
7854
|
"Layer__chart-of-accounts__row---mobile"
|
|
7501
7855
|
);
|
|
@@ -7653,11 +8007,11 @@ var ChartOfAccountsRow = ({
|
|
|
7653
8007
|
import React87 from "react";
|
|
7654
8008
|
|
|
7655
8009
|
// src/components/ChartOfAccountsForm/ChartOfAccountsForm.tsx
|
|
7656
|
-
import React86, { useContext as useContext9, useMemo as
|
|
8010
|
+
import React86, { useContext as useContext9, useMemo as useMemo9 } from "react";
|
|
7657
8011
|
|
|
7658
8012
|
// src/components/ChartOfAccountsForm/useParentOptions.ts
|
|
7659
|
-
import { useMemo as
|
|
7660
|
-
var useParentOptions = (data) =>
|
|
8013
|
+
import { useMemo as useMemo8 } from "react";
|
|
8014
|
+
var useParentOptions = (data) => useMemo8(
|
|
7661
8015
|
() => flattenAccounts(data?.accounts || []).sort((a, b) => a?.name && b?.name ? a.name.localeCompare(b.name) : 0).map((x) => {
|
|
7662
8016
|
return {
|
|
7663
8017
|
label: x.name,
|
|
@@ -7679,7 +8033,7 @@ var ChartOfAccountsForm = () => {
|
|
|
7679
8033
|
apiError
|
|
7680
8034
|
} = useContext9(ChartOfAccountsContext);
|
|
7681
8035
|
const parentOptions = useParentOptions(data);
|
|
7682
|
-
const entry =
|
|
8036
|
+
const entry = useMemo9(() => {
|
|
7683
8037
|
if (form?.action === "edit" && form.accountId) {
|
|
7684
8038
|
return flattenAccounts(data?.accounts || []).find(
|
|
7685
8039
|
(x) => x.id === form.accountId
|
|
@@ -7866,19 +8220,19 @@ var ChartOfAccountsTable = ({
|
|
|
7866
8220
|
// src/components/LedgerAccount/LedgerAccountIndex.tsx
|
|
7867
8221
|
import React95, {
|
|
7868
8222
|
useContext as useContext13,
|
|
7869
|
-
useEffect as
|
|
7870
|
-
useMemo as
|
|
7871
|
-
useState as
|
|
8223
|
+
useEffect as useEffect17,
|
|
8224
|
+
useMemo as useMemo11,
|
|
8225
|
+
useState as useState25
|
|
7872
8226
|
} from "react";
|
|
7873
8227
|
|
|
7874
8228
|
// src/components/LedgerAccountEntryDetails/LedgerAccountEntryDetails.tsx
|
|
7875
|
-
import React93, { useContext as useContext11, useMemo as
|
|
8229
|
+
import React93, { useContext as useContext11, useMemo as useMemo10 } from "react";
|
|
7876
8230
|
|
|
7877
8231
|
// src/components/Card/Card.tsx
|
|
7878
8232
|
import React89 from "react";
|
|
7879
|
-
import
|
|
8233
|
+
import classNames33 from "classnames";
|
|
7880
8234
|
var Card = ({ children, className }) => {
|
|
7881
|
-
return /* @__PURE__ */ React89.createElement("div", { className:
|
|
8235
|
+
return /* @__PURE__ */ React89.createElement("div", { className: classNames33("Layer__card", className) }, children);
|
|
7882
8236
|
};
|
|
7883
8237
|
|
|
7884
8238
|
// src/components/DateTime/DateTime.tsx
|
|
@@ -7920,14 +8274,14 @@ var DateTime = ({
|
|
|
7920
8274
|
|
|
7921
8275
|
// src/components/DetailsList/DetailsList.tsx
|
|
7922
8276
|
import React91 from "react";
|
|
7923
|
-
import
|
|
8277
|
+
import classNames34 from "classnames";
|
|
7924
8278
|
var DetailsList = ({
|
|
7925
8279
|
title,
|
|
7926
8280
|
children,
|
|
7927
8281
|
className,
|
|
7928
8282
|
actions
|
|
7929
8283
|
}) => {
|
|
7930
|
-
return /* @__PURE__ */ React91.createElement("div", { className:
|
|
8284
|
+
return /* @__PURE__ */ React91.createElement("div", { className: classNames34("Layer__details-list", className) }, title && /* @__PURE__ */ React91.createElement(Header, null, /* @__PURE__ */ React91.createElement(Heading, { size: "secondary" /* secondary */ }, title), actions && /* @__PURE__ */ React91.createElement("div", { className: "Layer__details-list__actions" }, actions)), /* @__PURE__ */ React91.createElement("ul", { className: "Layer__details-list__list" }, children));
|
|
7931
8285
|
};
|
|
7932
8286
|
|
|
7933
8287
|
// src/components/DetailsList/DetailsListItem.tsx
|
|
@@ -7983,7 +8337,7 @@ var SourceDetailView = ({ source }) => {
|
|
|
7983
8337
|
};
|
|
7984
8338
|
var LedgerAccountEntryDetails = () => {
|
|
7985
8339
|
const { entryData, isLoadingEntry, closeSelectedEntry, errorEntry } = useContext11(LedgerAccountsContext);
|
|
7986
|
-
const { totalDebit, totalCredit } =
|
|
8340
|
+
const { totalDebit, totalCredit } = useMemo10(() => {
|
|
7987
8341
|
let totalDebit2 = 0;
|
|
7988
8342
|
let totalCredit2 = 0;
|
|
7989
8343
|
entryData?.line_items?.forEach((item) => {
|
|
@@ -8024,8 +8378,8 @@ var LedgerAccountEntryDetails = () => {
|
|
|
8024
8378
|
};
|
|
8025
8379
|
|
|
8026
8380
|
// src/components/LedgerAccount/LedgerAccountRow.tsx
|
|
8027
|
-
import React94, { useContext as useContext12, useEffect as
|
|
8028
|
-
import
|
|
8381
|
+
import React94, { useContext as useContext12, useEffect as useEffect16, useState as useState24 } from "react";
|
|
8382
|
+
import classNames35 from "classnames";
|
|
8029
8383
|
import { parseISO as parseISO10, format as formatTime8 } from "date-fns";
|
|
8030
8384
|
var LedgerAccountRow = ({
|
|
8031
8385
|
row,
|
|
@@ -8034,8 +8388,8 @@ var LedgerAccountRow = ({
|
|
|
8034
8388
|
view
|
|
8035
8389
|
}) => {
|
|
8036
8390
|
const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = useContext12(LedgerAccountsContext);
|
|
8037
|
-
const [showComponent, setShowComponent] =
|
|
8038
|
-
|
|
8391
|
+
const [showComponent, setShowComponent] = useState24(false);
|
|
8392
|
+
useEffect16(() => {
|
|
8039
8393
|
if (initialLoad) {
|
|
8040
8394
|
const timeoutId = setTimeout(() => {
|
|
8041
8395
|
setShowComponent(true);
|
|
@@ -8049,7 +8403,7 @@ var LedgerAccountRow = ({
|
|
|
8049
8403
|
return /* @__PURE__ */ React94.createElement(
|
|
8050
8404
|
"tr",
|
|
8051
8405
|
{
|
|
8052
|
-
className:
|
|
8406
|
+
className: classNames35(
|
|
8053
8407
|
"Layer__table-row",
|
|
8054
8408
|
row.entry_id === selectedEntryId && "Layer__table-row--active",
|
|
8055
8409
|
initialLoad && "initial-load",
|
|
@@ -8082,7 +8436,7 @@ var LedgerAccountRow = ({
|
|
|
8082
8436
|
return /* @__PURE__ */ React94.createElement(
|
|
8083
8437
|
"tr",
|
|
8084
8438
|
{
|
|
8085
|
-
className:
|
|
8439
|
+
className: classNames35(
|
|
8086
8440
|
"Layer__table-row",
|
|
8087
8441
|
row.entry_id === selectedEntryId && "Layer__table-row--active",
|
|
8088
8442
|
initialLoad && "initial-load",
|
|
@@ -8111,7 +8465,7 @@ var LedgerAccountRow = ({
|
|
|
8111
8465
|
return /* @__PURE__ */ React94.createElement(
|
|
8112
8466
|
"tr",
|
|
8113
8467
|
{
|
|
8114
|
-
className:
|
|
8468
|
+
className: classNames35(
|
|
8115
8469
|
"Layer__table-row",
|
|
8116
8470
|
row.entry_id === selectedEntryId && "Layer__table-row--active",
|
|
8117
8471
|
initialLoad && "initial-load",
|
|
@@ -8137,14 +8491,14 @@ var LedgerAccountRow = ({
|
|
|
8137
8491
|
};
|
|
8138
8492
|
|
|
8139
8493
|
// src/components/LedgerAccount/LedgerAccountIndex.tsx
|
|
8140
|
-
import
|
|
8494
|
+
import classNames36 from "classnames";
|
|
8141
8495
|
var LedgerAccount = ({
|
|
8142
8496
|
containerRef,
|
|
8143
8497
|
pageSize = 15,
|
|
8144
8498
|
view
|
|
8145
8499
|
}) => {
|
|
8146
|
-
const [currentPage, setCurrentPage] =
|
|
8147
|
-
const [initialLoad, setInitialLoad] =
|
|
8500
|
+
const [currentPage, setCurrentPage] = useState25(1);
|
|
8501
|
+
const [initialLoad, setInitialLoad] = useState25(true);
|
|
8148
8502
|
const { data: accountData } = useContext13(ChartOfAccountsContext);
|
|
8149
8503
|
const {
|
|
8150
8504
|
data: rawData,
|
|
@@ -8157,7 +8511,7 @@ var LedgerAccount = ({
|
|
|
8157
8511
|
closeSelectedEntry,
|
|
8158
8512
|
refetch
|
|
8159
8513
|
} = useContext13(LedgerAccountsContext);
|
|
8160
|
-
|
|
8514
|
+
useEffect17(() => {
|
|
8161
8515
|
if (!isLoading) {
|
|
8162
8516
|
const timeoutLoad = setTimeout(() => {
|
|
8163
8517
|
setInitialLoad(false);
|
|
@@ -8165,16 +8519,16 @@ var LedgerAccount = ({
|
|
|
8165
8519
|
return () => clearTimeout(timeoutLoad);
|
|
8166
8520
|
}
|
|
8167
8521
|
}, [isLoading]);
|
|
8168
|
-
const baseClassName =
|
|
8522
|
+
const baseClassName = classNames36(
|
|
8169
8523
|
"Layer__ledger-account__index",
|
|
8170
8524
|
accountId && "open"
|
|
8171
8525
|
);
|
|
8172
|
-
const entry =
|
|
8526
|
+
const entry = useMemo11(() => {
|
|
8173
8527
|
return flattenAccounts(accountData?.accounts || []).find(
|
|
8174
8528
|
(x) => x.id === accountId
|
|
8175
8529
|
);
|
|
8176
8530
|
}, [accountId]);
|
|
8177
|
-
const data =
|
|
8531
|
+
const data = useMemo11(() => {
|
|
8178
8532
|
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
8179
8533
|
const lastPageIndex = firstPageIndex + pageSize;
|
|
8180
8534
|
return rawData?.sort((a, b) => Date.parse(b.date) - Date.parse(a.date))?.slice(firstPageIndex, lastPageIndex);
|
|
@@ -8311,7 +8665,7 @@ var ChartOfAccounts = (props) => {
|
|
|
8311
8665
|
};
|
|
8312
8666
|
var ChartOfAccountsContent = ({ asWidget }) => {
|
|
8313
8667
|
const { accountId } = useContext14(LedgerAccountsContext);
|
|
8314
|
-
const [view, setView] =
|
|
8668
|
+
const [view, setView] = useState26("desktop");
|
|
8315
8669
|
const containerRef = useElementSize((_a, _b, { width }) => {
|
|
8316
8670
|
if (width) {
|
|
8317
8671
|
if (width >= BREAKPOINTS.TABLET && view !== "desktop") {
|
|
@@ -8327,7 +8681,7 @@ var ChartOfAccountsContent = ({ asWidget }) => {
|
|
|
8327
8681
|
};
|
|
8328
8682
|
|
|
8329
8683
|
// src/providers/LayerProvider/LayerProvider.tsx
|
|
8330
|
-
import React97, { useReducer, useEffect as
|
|
8684
|
+
import React97, { useReducer, useEffect as useEffect18 } from "react";
|
|
8331
8685
|
import { add as add2, isBefore } from "date-fns";
|
|
8332
8686
|
import useSWR8, { SWRConfig } from "swr";
|
|
8333
8687
|
var reducer = (state, action) => {
|
|
@@ -8392,7 +8746,7 @@ var LayerProvider = ({
|
|
|
8392
8746
|
}),
|
|
8393
8747
|
defaultSWRConfig
|
|
8394
8748
|
) : { data: void 0 };
|
|
8395
|
-
|
|
8749
|
+
useEffect18(() => {
|
|
8396
8750
|
if (businessAccessToken) {
|
|
8397
8751
|
dispatch({
|
|
8398
8752
|
type: "LayerContext.setAuth" /* setAuth */,
|