@layerfi/components 0.1.117-alpha.1 → 0.1.118-alpha
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/cjs/index.cjs +458 -406
- package/dist/esm/index.mjs +459 -407
- package/dist/index.css +16 -22
- package/dist/index.d.ts +10 -6
- package/package.json +1 -1
package/dist/esm/index.mjs
CHANGED
|
@@ -54,12 +54,12 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
|
54
54
|
import { createContext, useState, useContext, useMemo, useEffect, forwardRef, useCallback, useRef, isValidElement, cloneElement, useLayoutEffect, memo, useId, Children, useImperativeHandle, createElement, Component, Fragment as Fragment$1, useReducer } from "react";
|
|
55
55
|
import { createStore, useStore } from "zustand";
|
|
56
56
|
import { usePlaidLink } from "react-plaid-link";
|
|
57
|
-
import { formatISO, differenceInDays, isWithinInterval, parseISO, endOfDay, startOfMonth, endOfMonth, min, max, differenceInCalendarMonths, format, isValid, startOfYear, subMonths, getYear, getMonth, subYears, differenceInCalendarYears, sub, differenceInMonths, add, startOfDay,
|
|
57
|
+
import { formatISO, differenceInDays, isWithinInterval, parseISO, endOfDay, startOfMonth, endOfMonth, min, max, differenceInCalendarMonths, format, isValid, startOfYear, subMonths, getYear, getMonth, subYears, differenceInCalendarYears, sub, differenceInMonths, add, startOfDay, isEqual, addYears, endOfYear, subQuarters, addQuarters, endOfQuarter, startOfQuarter, addMonths, set, startOfToday, endOfYesterday, formatDate as formatDate$1 } from "date-fns";
|
|
58
|
+
import { Schema, pipe, BigDecimal, Option, Effect } from "effect";
|
|
58
59
|
import { fromDate, getLocalTimeZone, DateFormatter, CalendarDate, ZonedDateTime, toCalendarDate, today, parseDate } from "@internationalized/date";
|
|
59
60
|
import useSWR, { unstable_serialize, useSWRConfig, SWRConfig } from "swr";
|
|
60
61
|
import classNames from "classnames";
|
|
61
62
|
import { Schema as Schema$1, pipe as pipe$1 } from "effect/index";
|
|
62
|
-
import { Schema, pipe, BigDecimal, Option, Effect } from "effect";
|
|
63
63
|
import { debounce, uniqBy, merge, uniqueId } from "lodash-es";
|
|
64
64
|
import useSWRInfinite from "swr/infinite";
|
|
65
65
|
import { useStoreWithEqualityFn } from "zustand/traditional";
|
|
@@ -149,6 +149,13 @@ function toSnakeCase(input) {
|
|
|
149
149
|
const segments = (_a = input.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)) != null ? _a : [];
|
|
150
150
|
return segments.map((segment) => segment.toLowerCase()).join("_");
|
|
151
151
|
}
|
|
152
|
+
Schema.Union(
|
|
153
|
+
Schema.Date,
|
|
154
|
+
Schema.String,
|
|
155
|
+
Schema.Array(Schema.String),
|
|
156
|
+
Schema.Number,
|
|
157
|
+
Schema.Boolean
|
|
158
|
+
);
|
|
152
159
|
function toDefinedSearchParameters(input) {
|
|
153
160
|
const definedParameterPairs = Object.entries(input).flatMap(([key, value]) => {
|
|
154
161
|
if (value === null || value === void 0) {
|
|
@@ -202,7 +209,7 @@ class ErrorHandlerClass {
|
|
|
202
209
|
}
|
|
203
210
|
const errorHandler = new ErrorHandlerClass();
|
|
204
211
|
const reportError = (payload) => errorHandler.onError(payload);
|
|
205
|
-
const version = "0.1.
|
|
212
|
+
const version = "0.1.118-alpha";
|
|
206
213
|
const pkg = {
|
|
207
214
|
version
|
|
208
215
|
};
|
|
@@ -3182,10 +3189,6 @@ function clampToPresentOrPast(date, cutoff = endOfDay(/* @__PURE__ */ new Date()
|
|
|
3182
3189
|
return min([date, cutoff]);
|
|
3183
3190
|
}
|
|
3184
3191
|
const RANGE_MODE_LOOKUP = {
|
|
3185
|
-
date: {
|
|
3186
|
-
getStartDate: ({ startDate }) => startOfMonth(startDate),
|
|
3187
|
-
getEndDate: ({ endDate }) => clampToPresentOrPast(endOfDay(endDate))
|
|
3188
|
-
},
|
|
3189
3192
|
full: {
|
|
3190
3193
|
getStartDate: ({ startDate }) => startDate,
|
|
3191
3194
|
getEndDate: ({ endDate }) => clampToPresentOrPast(endOfDay(endDate))
|
|
@@ -3212,8 +3215,8 @@ function buildStore$2() {
|
|
|
3212
3215
|
return next;
|
|
3213
3216
|
};
|
|
3214
3217
|
const setDate = ({ date }) => {
|
|
3215
|
-
const s = RANGE_MODE_LOOKUP.
|
|
3216
|
-
const e = RANGE_MODE_LOOKUP.
|
|
3218
|
+
const s = RANGE_MODE_LOOKUP.month.getStartDate({ startDate: date });
|
|
3219
|
+
const e = RANGE_MODE_LOOKUP.full.getEndDate({ endDate: date });
|
|
3217
3220
|
return apply({ startDate: s, endDate: e });
|
|
3218
3221
|
};
|
|
3219
3222
|
const setDateRange = withCorrectedRange(({ startDate, endDate }) => {
|
|
@@ -3226,30 +3229,11 @@ function buildStore$2() {
|
|
|
3226
3229
|
const e = RANGE_MODE_LOOKUP.month.getEndDate({ endDate: startDate });
|
|
3227
3230
|
return apply({ startDate: s, endDate: e });
|
|
3228
3231
|
};
|
|
3229
|
-
const setRangeWithExplicitDisplayMode = ({
|
|
3230
|
-
startDate,
|
|
3231
|
-
endDate,
|
|
3232
|
-
displayMode
|
|
3233
|
-
}) => {
|
|
3234
|
-
switch (displayMode) {
|
|
3235
|
-
case "date":
|
|
3236
|
-
return setDate({ date: endDate });
|
|
3237
|
-
case "full":
|
|
3238
|
-
return setDateRange({ startDate, endDate });
|
|
3239
|
-
case "month":
|
|
3240
|
-
return setMonth({ startDate });
|
|
3241
|
-
default:
|
|
3242
|
-
unsafeAssertUnreachable({
|
|
3243
|
-
message: "Invalid `displayMode`"
|
|
3244
|
-
});
|
|
3245
|
-
}
|
|
3246
|
-
};
|
|
3247
3232
|
return {
|
|
3248
3233
|
startDate: startOfMonth(now),
|
|
3249
3234
|
endDate: clampToPresentOrPast(endOfMonth(now)),
|
|
3250
3235
|
actions: {
|
|
3251
3236
|
setDate,
|
|
3252
|
-
setRangeWithExplicitDisplayMode,
|
|
3253
3237
|
setDateRange,
|
|
3254
3238
|
setMonth,
|
|
3255
3239
|
setMonthByPeriod: ({ monthNumber, yearNumber }) => {
|
|
@@ -3261,10 +3245,17 @@ function buildStore$2() {
|
|
|
3261
3245
|
});
|
|
3262
3246
|
}
|
|
3263
3247
|
const GlobalDateStoreContext = createContext(buildStore$2());
|
|
3264
|
-
|
|
3248
|
+
const getEffectiveDateForMode = (mode, { date }) => {
|
|
3249
|
+
const rangeModifierForMode = RANGE_MODE_LOOKUP[mode];
|
|
3250
|
+
return { date: rangeModifierForMode.getEndDate({ endDate: date }) };
|
|
3251
|
+
};
|
|
3252
|
+
function useGlobalDate({ dateSelectionMode = "full" } = {}) {
|
|
3265
3253
|
const store = useContext(GlobalDateStoreContext);
|
|
3266
|
-
const
|
|
3267
|
-
return
|
|
3254
|
+
const rawDate = useStoreWithDateSelected(store, ({ endDate }) => endDate);
|
|
3255
|
+
return useMemo(
|
|
3256
|
+
() => getEffectiveDateForMode(dateSelectionMode, { date: rawDate }),
|
|
3257
|
+
[dateSelectionMode, rawDate]
|
|
3258
|
+
);
|
|
3268
3259
|
}
|
|
3269
3260
|
function useGlobalDateActions() {
|
|
3270
3261
|
const store = useContext(GlobalDateStoreContext);
|
|
@@ -3278,28 +3269,23 @@ const getEffectiveDateRangeForMode = (mode, { startDate, endDate }) => {
|
|
|
3278
3269
|
endDate: rangeModifierForMode.getEndDate({ endDate })
|
|
3279
3270
|
};
|
|
3280
3271
|
};
|
|
3281
|
-
function useGlobalDateRange({
|
|
3272
|
+
function useGlobalDateRange({ dateSelectionMode }) {
|
|
3282
3273
|
const store = useContext(GlobalDateStoreContext);
|
|
3283
3274
|
const rawStartDate = useStoreWithDateSelected(store, ({ startDate }) => startDate);
|
|
3284
3275
|
const rawEndDate = useStoreWithDateSelected(store, ({ endDate }) => endDate);
|
|
3285
3276
|
return useMemo(
|
|
3286
3277
|
() => getEffectiveDateRangeForMode(
|
|
3287
|
-
|
|
3278
|
+
dateSelectionMode,
|
|
3288
3279
|
{ startDate: rawStartDate, endDate: rawEndDate }
|
|
3289
3280
|
),
|
|
3290
|
-
[
|
|
3281
|
+
[dateSelectionMode, rawEndDate, rawStartDate]
|
|
3291
3282
|
);
|
|
3292
3283
|
}
|
|
3293
3284
|
function useGlobalDateRangeActions() {
|
|
3294
3285
|
const store = useContext(GlobalDateStoreContext);
|
|
3295
|
-
const setRangeWithExplicitDisplayMode = useStore(
|
|
3296
|
-
store,
|
|
3297
|
-
({ actions: { setRangeWithExplicitDisplayMode: setRangeWithExplicitDisplayMode2 } }) => setRangeWithExplicitDisplayMode2
|
|
3298
|
-
);
|
|
3299
3286
|
const setDateRange = useStore(store, ({ actions: { setDateRange: setDateRange2 } }) => setDateRange2);
|
|
3300
3287
|
const setMonth = useStore(store, ({ actions: { setMonth: setMonth2 } }) => setMonth2);
|
|
3301
3288
|
return {
|
|
3302
|
-
setRangeWithExplicitDisplayMode,
|
|
3303
3289
|
setDateRange,
|
|
3304
3290
|
setMonth
|
|
3305
3291
|
};
|
|
@@ -3317,7 +3303,7 @@ function GlobalDateStoreProvider({
|
|
|
3317
3303
|
}
|
|
3318
3304
|
const useBankTransactionsFilters = (params) => {
|
|
3319
3305
|
const dateFilterMode = (params == null ? void 0 : params.applyGlobalDateRange) ? BankTransactionsDateFilterMode.GlobalDateRange : (params == null ? void 0 : params.monthlyView) ? BankTransactionsDateFilterMode.MonthlyView : void 0;
|
|
3320
|
-
const globalDateRange = useGlobalDateRange({
|
|
3306
|
+
const globalDateRange = useGlobalDateRange({ dateSelectionMode: "full" });
|
|
3321
3307
|
const defaultDateRange = {
|
|
3322
3308
|
startDate: startOfMonth(/* @__PURE__ */ new Date()),
|
|
3323
3309
|
endDate: endOfMonth(/* @__PURE__ */ new Date())
|
|
@@ -11278,6 +11264,10 @@ const InvoicePaymentLedgerEntrySourceSchema = Schema.Struct({
|
|
|
11278
11264
|
Schema.propertySignature(Schema.String),
|
|
11279
11265
|
Schema.fromKey("invoice_id")
|
|
11280
11266
|
),
|
|
11267
|
+
invoicePaymentId: pipe(
|
|
11268
|
+
Schema.propertySignature(Schema.String),
|
|
11269
|
+
Schema.fromKey("invoice_payment_id")
|
|
11270
|
+
),
|
|
11281
11271
|
invoiceNumber: pipe(
|
|
11282
11272
|
Schema.propertySignature(Schema.NullOr(Schema.String)),
|
|
11283
11273
|
Schema.fromKey("invoice_number")
|
|
@@ -11740,6 +11730,10 @@ const BillPaymentLedgerEntrySourceSchema = Schema.Struct({
|
|
|
11740
11730
|
Schema.optional(Schema.NullOr(Schema.String)),
|
|
11741
11731
|
Schema.fromKey("external_id")
|
|
11742
11732
|
),
|
|
11733
|
+
billPaymentId: pipe(
|
|
11734
|
+
Schema.propertySignature(Schema.String),
|
|
11735
|
+
Schema.fromKey("bill_payment_id")
|
|
11736
|
+
),
|
|
11743
11737
|
billId: pipe(
|
|
11744
11738
|
Schema.propertySignature(Schema.String),
|
|
11745
11739
|
Schema.fromKey("bill_id")
|
|
@@ -11865,7 +11859,7 @@ const convertLedgerEntrySourceToLinkingMetadata = (ledgerEntrySource) => {
|
|
|
11865
11859
|
baseMetadata.id = ledgerEntrySource.manualEntryId;
|
|
11866
11860
|
break;
|
|
11867
11861
|
case "Invoice_Payment_Ledger_Entry_Source":
|
|
11868
|
-
baseMetadata.id = ledgerEntrySource.
|
|
11862
|
+
baseMetadata.id = ledgerEntrySource.invoicePaymentId;
|
|
11869
11863
|
baseMetadata.entityName = EntityName.InvoicePayment;
|
|
11870
11864
|
if (ledgerEntrySource.invoiceIdentifiers) {
|
|
11871
11865
|
baseMetadata.relatedEntityLinkingMetadata = ledgerEntrySource.invoiceIdentifiers.map((identifier) => ({
|
|
@@ -11971,7 +11965,7 @@ const convertLedgerEntrySourceToLinkingMetadata = (ledgerEntrySource) => {
|
|
|
11971
11965
|
baseMetadata.entityName = EntityName.Bill;
|
|
11972
11966
|
break;
|
|
11973
11967
|
case "Bill_Payment_Ledger_Entry_Source":
|
|
11974
|
-
baseMetadata.id = ledgerEntrySource.
|
|
11968
|
+
baseMetadata.id = ledgerEntrySource.billPaymentId;
|
|
11975
11969
|
baseMetadata.entityName = EntityName.BillPayment;
|
|
11976
11970
|
if (ledgerEntrySource.billIdentifiers) {
|
|
11977
11971
|
baseMetadata.relatedEntityLinkingMetadata = ledgerEntrySource.billIdentifiers.map((identifier) => ({
|
|
@@ -12706,11 +12700,13 @@ const CSS_PREFIX$1 = "Layer__UI__Table";
|
|
|
12706
12700
|
const getClassName = (component, additionalClassNames, withHidden) => classNames(`${CSS_PREFIX$1}-${component}`, withHidden && `${CSS_PREFIX$1}-${component}--hidden`, additionalClassNames);
|
|
12707
12701
|
const Table$1 = forwardRef(
|
|
12708
12702
|
(_rb, ref) => {
|
|
12709
|
-
var _sb = _rb, { children, className } = _sb, restProps = __objRest(_sb, ["children", "className"]);
|
|
12703
|
+
var _sb = _rb, { children, className, nonAria, slot } = _sb, restProps = __objRest(_sb, ["children", "className", "nonAria", "slot"]);
|
|
12704
|
+
const TableComponent = nonAria ? "table" : Table$2;
|
|
12710
12705
|
return /* @__PURE__ */ jsx(
|
|
12711
|
-
|
|
12706
|
+
TableComponent,
|
|
12712
12707
|
__spreadProps(__spreadValues({
|
|
12713
|
-
className: getClassName("Table", className)
|
|
12708
|
+
className: getClassName("Table", className),
|
|
12709
|
+
slot: slot != null ? slot : void 0
|
|
12714
12710
|
}, restProps), {
|
|
12715
12711
|
ref,
|
|
12716
12712
|
children
|
|
@@ -12720,9 +12716,10 @@ const Table$1 = forwardRef(
|
|
|
12720
12716
|
);
|
|
12721
12717
|
Table$1.displayName = "Table";
|
|
12722
12718
|
const TableHeaderInner = (_tb, ref) => {
|
|
12723
|
-
var _ub = _tb, { children, className, hideHeader } = _ub, restProps = __objRest(_ub, ["children", "className", "hideHeader"]);
|
|
12719
|
+
var _ub = _tb, { children, className, hideHeader, nonAria } = _ub, restProps = __objRest(_ub, ["children", "className", "hideHeader", "nonAria"]);
|
|
12720
|
+
const TableHeaderComponent = nonAria ? "thead" : TableHeader$1;
|
|
12724
12721
|
return /* @__PURE__ */ jsx(
|
|
12725
|
-
|
|
12722
|
+
TableHeaderComponent,
|
|
12726
12723
|
__spreadProps(__spreadValues({
|
|
12727
12724
|
className: getClassName("TableHeader", className, hideHeader)
|
|
12728
12725
|
}, restProps), {
|
|
@@ -12734,9 +12731,10 @@ const TableHeaderInner = (_tb, ref) => {
|
|
|
12734
12731
|
const TableHeader = forwardRef(TableHeaderInner);
|
|
12735
12732
|
TableHeader.displayName = "TableHeader";
|
|
12736
12733
|
const TableBodyInner = (_vb, ref) => {
|
|
12737
|
-
var _wb = _vb, { children, className } = _wb, restProps = __objRest(_wb, ["children", "className"]);
|
|
12734
|
+
var _wb = _vb, { children, className, nonAria } = _wb, restProps = __objRest(_wb, ["children", "className", "nonAria"]);
|
|
12735
|
+
const TableBodyComponent = nonAria ? "tbody" : TableBody$2;
|
|
12738
12736
|
return /* @__PURE__ */ jsx(
|
|
12739
|
-
|
|
12737
|
+
TableBodyComponent,
|
|
12740
12738
|
__spreadProps(__spreadValues({
|
|
12741
12739
|
className: getClassName("TableBody", className)
|
|
12742
12740
|
}, restProps), {
|
|
@@ -12748,14 +12746,16 @@ const TableBodyInner = (_vb, ref) => {
|
|
|
12748
12746
|
const TableBody$1 = forwardRef(TableBodyInner);
|
|
12749
12747
|
TableBody$1.displayName = "TableBody";
|
|
12750
12748
|
const RowInner = (_xb, ref) => {
|
|
12751
|
-
var _yb = _xb, { children, className, depth = 0 } = _yb, restProps = __objRest(_yb, ["children", "className", "depth"]);
|
|
12749
|
+
var _yb = _xb, { children, className, depth = 0, nonAria, id } = _yb, restProps = __objRest(_yb, ["children", "className", "depth", "nonAria", "id"]);
|
|
12752
12750
|
const dataProperties = toDataProperties({ depth });
|
|
12751
|
+
const RowComponent = nonAria ? "tr" : Row$1;
|
|
12753
12752
|
return /* @__PURE__ */ jsx(
|
|
12754
|
-
|
|
12753
|
+
RowComponent,
|
|
12755
12754
|
__spreadProps(__spreadValues(__spreadValues({
|
|
12756
12755
|
className: getClassName("Row", className)
|
|
12757
12756
|
}, restProps), dataProperties), {
|
|
12758
12757
|
ref,
|
|
12758
|
+
id: id == null ? void 0 : id.toString(),
|
|
12759
12759
|
children: withRenderProp(children, (node) => node)
|
|
12760
12760
|
})
|
|
12761
12761
|
);
|
|
@@ -12764,14 +12764,18 @@ const Row = forwardRef(RowInner);
|
|
|
12764
12764
|
Row.displayName = "Row";
|
|
12765
12765
|
const Column = forwardRef(
|
|
12766
12766
|
(_zb, ref) => {
|
|
12767
|
-
var _Ab = _zb, { children, className, textAlign = "left" } = _Ab, restProps = __objRest(_Ab, ["children", "className", "textAlign"]);
|
|
12767
|
+
var _Ab = _zb, { children, className, nonAria, id, textAlign = "left", colSpan = 1 } = _Ab, restProps = __objRest(_Ab, ["children", "className", "nonAria", "id", "textAlign", "colSpan"]);
|
|
12768
12768
|
const dataProperties = toDataProperties({ "text-align": textAlign });
|
|
12769
|
+
const columnClassName = getClassName("Column", className);
|
|
12770
|
+
const ColumnComponent = nonAria ? "th" : Column$1;
|
|
12769
12771
|
return /* @__PURE__ */ jsx(
|
|
12770
|
-
|
|
12772
|
+
ColumnComponent,
|
|
12771
12773
|
__spreadProps(__spreadValues(__spreadValues({
|
|
12772
|
-
className:
|
|
12774
|
+
className: columnClassName
|
|
12773
12775
|
}, restProps), dataProperties), {
|
|
12774
12776
|
ref,
|
|
12777
|
+
id: id == null ? void 0 : id.toString(),
|
|
12778
|
+
colSpan,
|
|
12775
12779
|
children: withRenderProp(children, (node) => node)
|
|
12776
12780
|
})
|
|
12777
12781
|
);
|
|
@@ -12780,19 +12784,44 @@ const Column = forwardRef(
|
|
|
12780
12784
|
Column.displayName = "Column";
|
|
12781
12785
|
const Cell = forwardRef(
|
|
12782
12786
|
(_Bb, ref) => {
|
|
12783
|
-
var _Cb = _Bb, { children, className } = _Cb, restProps = __objRest(_Cb, ["children", "className"]);
|
|
12787
|
+
var _Cb = _Bb, { children, className, nonAria, id } = _Cb, restProps = __objRest(_Cb, ["children", "className", "nonAria", "id"]);
|
|
12788
|
+
const CellComponent = nonAria ? "td" : Cell$1;
|
|
12784
12789
|
return /* @__PURE__ */ jsx(
|
|
12785
|
-
|
|
12790
|
+
CellComponent,
|
|
12786
12791
|
__spreadProps(__spreadValues({
|
|
12787
12792
|
className: getClassName("Cell", className)
|
|
12788
12793
|
}, restProps), {
|
|
12789
12794
|
ref,
|
|
12795
|
+
id: id == null ? void 0 : id.toString(),
|
|
12790
12796
|
children: withRenderProp(children, (node) => node)
|
|
12791
12797
|
})
|
|
12792
12798
|
);
|
|
12793
12799
|
}
|
|
12794
12800
|
);
|
|
12795
12801
|
Cell.displayName = "Cell";
|
|
12802
|
+
const isLeafColumn = (col) => {
|
|
12803
|
+
return "cell" in col;
|
|
12804
|
+
};
|
|
12805
|
+
const getColumnDefs = (columnConfig) => {
|
|
12806
|
+
const columnHelper = createColumnHelper();
|
|
12807
|
+
return columnConfig.map((col) => {
|
|
12808
|
+
if (isLeafColumn(col)) {
|
|
12809
|
+
return columnHelper.display({
|
|
12810
|
+
id: col.id,
|
|
12811
|
+
header: () => col.header,
|
|
12812
|
+
cell: ({ row }) => col.cell(row),
|
|
12813
|
+
meta: {
|
|
12814
|
+
isRowHeader: col.isRowHeader || false
|
|
12815
|
+
}
|
|
12816
|
+
});
|
|
12817
|
+
}
|
|
12818
|
+
return columnHelper.group({
|
|
12819
|
+
id: col.id,
|
|
12820
|
+
header: () => col.header,
|
|
12821
|
+
columns: getColumnDefs(col.columns)
|
|
12822
|
+
});
|
|
12823
|
+
});
|
|
12824
|
+
};
|
|
12796
12825
|
const Loader = ({ children, size = 28 }) => {
|
|
12797
12826
|
return /* @__PURE__ */ jsxs("span", { className: "Layer__loader", children: [
|
|
12798
12827
|
/* @__PURE__ */ jsx(Loader$1, { size, className: "Layer__anim--rotating" }),
|
|
@@ -12828,19 +12857,8 @@ const VirtualizedDataTable = ({
|
|
|
12828
12857
|
const calculatedHeight = actualRowCount * rowHeight + HEADER_HEIGHT + 1;
|
|
12829
12858
|
return Math.min(height, calculatedHeight);
|
|
12830
12859
|
}, [data, height, rowHeight, shrinkHeightToFitRows]);
|
|
12831
|
-
const columnHelper = createColumnHelper();
|
|
12832
|
-
const columns = Object.values(columnConfig);
|
|
12833
12860
|
const tableData = data != null ? data : EMPTY_ARRAY$2;
|
|
12834
|
-
const columnDefs =
|
|
12835
|
-
return columnHelper.display({
|
|
12836
|
-
id: col.id,
|
|
12837
|
-
header: () => col.header,
|
|
12838
|
-
cell: ({ row }) => col.cell(row.original),
|
|
12839
|
-
meta: {
|
|
12840
|
-
isRowHeader: col.isRowHeader || false
|
|
12841
|
-
}
|
|
12842
|
-
});
|
|
12843
|
-
});
|
|
12861
|
+
const columnDefs = getColumnDefs(columnConfig);
|
|
12844
12862
|
const table2 = useReactTable({
|
|
12845
12863
|
data: tableData,
|
|
12846
12864
|
columns: columnDefs,
|
|
@@ -12938,43 +12956,34 @@ const AffectedTransactionsTable = ({
|
|
|
12938
12956
|
isLoading = false,
|
|
12939
12957
|
isError = false
|
|
12940
12958
|
}) => {
|
|
12941
|
-
const columnConfig = useMemo(() =>
|
|
12942
|
-
|
|
12943
|
-
"Date"
|
|
12944
|
-
/* Date */
|
|
12945
|
-
]: {
|
|
12959
|
+
const columnConfig = useMemo(() => [
|
|
12960
|
+
{
|
|
12946
12961
|
id: "Date",
|
|
12947
12962
|
header: "Date",
|
|
12948
12963
|
cell: (row) => /* @__PURE__ */ jsx(
|
|
12949
12964
|
DateTime,
|
|
12950
12965
|
{
|
|
12951
|
-
valueAsDate: row.date,
|
|
12966
|
+
valueAsDate: row.original.date,
|
|
12952
12967
|
onlyDate: true,
|
|
12953
12968
|
slotProps: { Date: { size: TextSize.md, weight: TextWeight.normal, variant: "subtle" } }
|
|
12954
12969
|
}
|
|
12955
12970
|
)
|
|
12956
12971
|
},
|
|
12957
|
-
|
|
12958
|
-
"Description"
|
|
12959
|
-
/* Description */
|
|
12960
|
-
]: {
|
|
12972
|
+
{
|
|
12961
12973
|
id: "Description",
|
|
12962
12974
|
header: "Description",
|
|
12963
|
-
cell: (row) => /* @__PURE__ */ jsx(Span, { withTooltip: true, children: row.counterpartyName || row.description || "-" }),
|
|
12975
|
+
cell: (row) => /* @__PURE__ */ jsx(Span, { withTooltip: true, children: row.original.counterpartyName || row.original.description || "-" }),
|
|
12964
12976
|
isRowHeader: true
|
|
12965
12977
|
},
|
|
12966
|
-
|
|
12967
|
-
"Amount"
|
|
12968
|
-
/* Amount */
|
|
12969
|
-
]: {
|
|
12978
|
+
{
|
|
12970
12979
|
id: "Amount",
|
|
12971
12980
|
header: "Amount",
|
|
12972
12981
|
cell: (row) => {
|
|
12973
|
-
const amount = row.direction === BankTransactionDirection.Credit ? row.amount : -row.amount;
|
|
12982
|
+
const amount = row.original.direction === BankTransactionDirection.Credit ? row.original.amount : -row.original.amount;
|
|
12974
12983
|
return /* @__PURE__ */ jsx(MoneySpan, { amount });
|
|
12975
12984
|
}
|
|
12976
12985
|
}
|
|
12977
|
-
|
|
12986
|
+
], []);
|
|
12978
12987
|
return /* @__PURE__ */ jsx(VStack, { className: "Layer__AffectedTransactionsTable", children: /* @__PURE__ */ jsx(
|
|
12979
12988
|
VirtualizedDataTable,
|
|
12980
12989
|
{
|
|
@@ -16350,7 +16359,7 @@ const ExpandedBankTransactionRow = ({
|
|
|
16350
16359
|
className: `${className} ${className}--${isOpen ? "expanded" : "collapsed"}`,
|
|
16351
16360
|
children: isOpen && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
16352
16361
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
16353
|
-
/* @__PURE__ */ jsx("span", { className: `${className}__wrapper`, ref: bodyRef, children: /* @__PURE__ */ jsxs(VStack, { pis: variant === "row" ? "md" : void 0, pbs: "sm", children: [
|
|
16362
|
+
/* @__PURE__ */ jsx("span", { className: `${className}__wrapper`, ref: bodyRef, children: /* @__PURE__ */ jsxs(VStack, { pis: variant === "row" ? "md" : void 0, pbs: "sm", pbe: "md", children: [
|
|
16354
16363
|
categorizationEnabled && /* @__PURE__ */ jsx(HStack, { pi: "md", pbe: "md", pbs: "3xs", children: /* @__PURE__ */ jsx(
|
|
16355
16364
|
Toggle,
|
|
16356
16365
|
{
|
|
@@ -17008,7 +17017,7 @@ const BankTransactionsListItem = ({
|
|
|
17008
17017
|
onValidityChange: setIsExpandedRowValid
|
|
17009
17018
|
}
|
|
17010
17019
|
) }, `expanded-${bankTransaction.id}`) }),
|
|
17011
|
-
categorizationEnabled && !displayAsCategorized && /* @__PURE__ */ jsx("div", { onClick: preventRowExpansion, children: /* @__PURE__ */ jsxs(HStack, { pi: "md", gap: "md",
|
|
17020
|
+
categorizationEnabled && !displayAsCategorized && /* @__PURE__ */ jsx("div", { onClick: preventRowExpansion, children: /* @__PURE__ */ jsxs(HStack, { pi: "md", gap: "md", pbe: "md", justify: "end", children: [
|
|
17012
17021
|
!openExpandedRow && /* @__PURE__ */ jsx(
|
|
17013
17022
|
BankTransactionCategoryComboBox,
|
|
17014
17023
|
{
|
|
@@ -17117,16 +17126,13 @@ const BankTransactionsMobileBulkActionsHeader = ({
|
|
|
17117
17126
|
gap: "md",
|
|
17118
17127
|
align: "center",
|
|
17119
17128
|
justify: "space-between",
|
|
17120
|
-
|
|
17121
|
-
pie: "md",
|
|
17129
|
+
pi: "md",
|
|
17122
17130
|
pb: "xs",
|
|
17123
|
-
className: "Layer__BankTransactionsMobileBulkActionsHeader",
|
|
17124
17131
|
children: [
|
|
17125
17132
|
/* @__PURE__ */ jsx(
|
|
17126
17133
|
HStack,
|
|
17127
17134
|
{
|
|
17128
17135
|
align: "center",
|
|
17129
|
-
pi: "xs",
|
|
17130
17136
|
gap: "xs",
|
|
17131
17137
|
children: bulkActionsEnabled && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
17132
17138
|
/* @__PURE__ */ jsx(
|
|
@@ -17480,20 +17486,37 @@ const BankTransactionsMobileListBusinessForm = ({
|
|
|
17480
17486
|
)
|
|
17481
17487
|
] });
|
|
17482
17488
|
};
|
|
17483
|
-
var
|
|
17484
|
-
|
|
17485
|
-
|
|
17486
|
-
return
|
|
17487
|
-
})(
|
|
17489
|
+
var PersonalStableName = /* @__PURE__ */ ((PersonalStableName2) => {
|
|
17490
|
+
PersonalStableName2["CREDIT"] = "CONTRIBUTIONS";
|
|
17491
|
+
PersonalStableName2["DEBIT"] = "PERSONAL_EXPENSES";
|
|
17492
|
+
return PersonalStableName2;
|
|
17493
|
+
})(PersonalStableName || {});
|
|
17494
|
+
var LegacyPersonalCategories = /* @__PURE__ */ ((LegacyPersonalCategories2) => {
|
|
17495
|
+
LegacyPersonalCategories2["INCOME"] = "PERSONAL_INFLOWS";
|
|
17496
|
+
LegacyPersonalCategories2["EXPENSES"] = "PERSONAL_EXPENSES";
|
|
17497
|
+
return LegacyPersonalCategories2;
|
|
17498
|
+
})(LegacyPersonalCategories || {});
|
|
17488
17499
|
const isAlreadyAssigned = (bankTransaction) => {
|
|
17489
17500
|
if (bankTransaction.categorization_status === CategorizationStatus.MATCHED || (bankTransaction == null ? void 0 : bankTransaction.categorization_status) === CategorizationStatus.SPLIT) {
|
|
17490
17501
|
return false;
|
|
17491
17502
|
}
|
|
17492
|
-
|
|
17493
|
-
|
|
17494
|
-
|
|
17495
|
-
|
|
17496
|
-
)
|
|
17503
|
+
if (!bankTransaction.category) {
|
|
17504
|
+
return false;
|
|
17505
|
+
}
|
|
17506
|
+
const category = bankTransaction.category;
|
|
17507
|
+
if (category.type === "Account" && "stable_name" in category) {
|
|
17508
|
+
const stableName = category.stable_name;
|
|
17509
|
+
if (stableName === PersonalStableName.CREDIT || stableName === PersonalStableName.DEBIT) {
|
|
17510
|
+
return true;
|
|
17511
|
+
}
|
|
17512
|
+
}
|
|
17513
|
+
if (category.type === "Exclusion") {
|
|
17514
|
+
const displayName = category.display_name;
|
|
17515
|
+
if (Object.values(LegacyPersonalCategories).includes(displayName)) {
|
|
17516
|
+
return true;
|
|
17517
|
+
}
|
|
17518
|
+
}
|
|
17519
|
+
return false;
|
|
17497
17520
|
};
|
|
17498
17521
|
const BankTransactionsMobileListPersonalForm = ({
|
|
17499
17522
|
bankTransaction,
|
|
@@ -17522,8 +17545,8 @@ const BankTransactionsMobileListPersonalForm = ({
|
|
|
17522
17545
|
{
|
|
17523
17546
|
type: "Category",
|
|
17524
17547
|
category: {
|
|
17525
|
-
type: "
|
|
17526
|
-
|
|
17548
|
+
type: "StableName",
|
|
17549
|
+
stableName: isCredit(bankTransaction) ? PersonalStableName.CREDIT : PersonalStableName.DEBIT
|
|
17527
17550
|
}
|
|
17528
17551
|
},
|
|
17529
17552
|
true
|
|
@@ -18061,9 +18084,24 @@ const BankTransactionsMobileListItemExpandedRow = ({
|
|
|
18061
18084
|
)
|
|
18062
18085
|
] });
|
|
18063
18086
|
};
|
|
18087
|
+
const isPersonalCategory = (category) => {
|
|
18088
|
+
if (!category) {
|
|
18089
|
+
return false;
|
|
18090
|
+
}
|
|
18091
|
+
if (category.type === "Account" && "stable_name" in category) {
|
|
18092
|
+
const stableName = category.stable_name;
|
|
18093
|
+
if (stableName === PersonalStableName.CREDIT || stableName === PersonalStableName.DEBIT) {
|
|
18094
|
+
return true;
|
|
18095
|
+
}
|
|
18096
|
+
}
|
|
18097
|
+
if (category.type === "Exclusion") {
|
|
18098
|
+
return true;
|
|
18099
|
+
}
|
|
18100
|
+
return false;
|
|
18101
|
+
};
|
|
18064
18102
|
const getInitialPurpose = (bankTransaction) => {
|
|
18065
18103
|
if (bankTransaction.category) {
|
|
18066
|
-
if (bankTransaction.category
|
|
18104
|
+
if (isPersonalCategory(bankTransaction.category)) {
|
|
18067
18105
|
return Purpose.personal;
|
|
18068
18106
|
}
|
|
18069
18107
|
if (bankTransaction.categorization_status === CategorizationStatus.SPLIT) {
|
|
@@ -18596,43 +18634,56 @@ function useArchiveCategorizationRule() {
|
|
|
18596
18634
|
});
|
|
18597
18635
|
}
|
|
18598
18636
|
const DataTable = ({
|
|
18599
|
-
columnConfig,
|
|
18600
|
-
data,
|
|
18601
18637
|
isLoading,
|
|
18602
18638
|
isError,
|
|
18603
18639
|
componentName,
|
|
18604
18640
|
ariaLabel,
|
|
18605
18641
|
slots,
|
|
18606
18642
|
hideHeader,
|
|
18607
|
-
dependencies
|
|
18643
|
+
dependencies,
|
|
18644
|
+
data,
|
|
18645
|
+
headerGroups,
|
|
18646
|
+
numColumns
|
|
18608
18647
|
}) => {
|
|
18609
|
-
const
|
|
18648
|
+
const nonAria = headerGroups.length > 1;
|
|
18610
18649
|
const { EmptyState: EmptyState2, ErrorState: ErrorState2 } = slots;
|
|
18611
18650
|
const isEmptyTable = (data == null ? void 0 : data.length) === 0;
|
|
18612
18651
|
const renderTableBody = useMemo(() => {
|
|
18613
18652
|
if (isError) {
|
|
18614
|
-
return /* @__PURE__ */ jsx(Row, { className: "Layer__DataTable__EmptyState__Row", children: /* @__PURE__ */ jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan:
|
|
18653
|
+
return /* @__PURE__ */ jsx(Row, { className: "Layer__DataTable__EmptyState__Row", nonAria, children: /* @__PURE__ */ jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan: numColumns, nonAria, children: /* @__PURE__ */ jsx(ErrorState2, {}) }) });
|
|
18615
18654
|
}
|
|
18616
18655
|
if (isLoading) {
|
|
18617
|
-
return /* @__PURE__ */ jsx(Row, { className: "Layer__DataTable__EmptyState__Row", children: /* @__PURE__ */ jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan:
|
|
18656
|
+
return /* @__PURE__ */ jsx(Row, { className: "Layer__DataTable__EmptyState__Row", nonAria, children: /* @__PURE__ */ jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan: numColumns, nonAria, children: /* @__PURE__ */ jsx(Loader, {}) }) });
|
|
18618
18657
|
}
|
|
18619
18658
|
if (isEmptyTable) {
|
|
18620
|
-
return /* @__PURE__ */ jsx(Row, { className: "Layer__DataTable__EmptyState__Row", children: /* @__PURE__ */ jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan:
|
|
18659
|
+
return /* @__PURE__ */ jsx(Row, { className: "Layer__DataTable__EmptyState__Row", nonAria, children: /* @__PURE__ */ jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan: numColumns, nonAria, children: /* @__PURE__ */ jsx(EmptyState2, {}) }) });
|
|
18621
18660
|
}
|
|
18622
|
-
|
|
18661
|
+
return /* @__PURE__ */ jsx(Fragment, { children: data == null ? void 0 : data.map((row) => /* @__PURE__ */ jsx(Row, { depth: row.depth, nonAria, children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(
|
|
18623
18662
|
Cell,
|
|
18624
18663
|
{
|
|
18625
|
-
className: `Layer__UI__Table-Cell__${componentName}--${
|
|
18626
|
-
|
|
18664
|
+
className: `Layer__UI__Table-Cell__${componentName}--${cell.column.id}`,
|
|
18665
|
+
nonAria,
|
|
18666
|
+
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
18627
18667
|
},
|
|
18628
|
-
`${row.id}-${
|
|
18629
|
-
)) }, row.id);
|
|
18630
|
-
|
|
18631
|
-
|
|
18632
|
-
|
|
18633
|
-
|
|
18634
|
-
|
|
18635
|
-
|
|
18668
|
+
`${row.id}-${cell.id}`
|
|
18669
|
+
)) }, row.id)) });
|
|
18670
|
+
}, [isError, isLoading, isEmptyTable, data, nonAria, numColumns, ErrorState2, EmptyState2, componentName]);
|
|
18671
|
+
return /* @__PURE__ */ jsxs(Table$1, { "aria-label": ariaLabel, className: `Layer__UI__Table__${componentName}`, nonAria, children: [
|
|
18672
|
+
/* @__PURE__ */ jsx(TableHeader, { hideHeader, nonAria, children: headerGroups.map((headerGroup) => /* @__PURE__ */ jsx(Row, { nonAria, children: headerGroup.headers.map((header) => {
|
|
18673
|
+
var _a;
|
|
18674
|
+
return /* @__PURE__ */ jsx(
|
|
18675
|
+
Column,
|
|
18676
|
+
{
|
|
18677
|
+
isRowHeader: (_a = header.column.columnDef.meta) == null ? void 0 : _a.isRowHeader,
|
|
18678
|
+
className: `Layer__UI__Table-Column__${componentName}--${header.id}`,
|
|
18679
|
+
nonAria,
|
|
18680
|
+
colSpan: header.colSpan,
|
|
18681
|
+
children: header.isPlaceholder ? null : typeof header.column.columnDef.header === "function" ? header.column.columnDef.header(header.getContext()) : header.column.columnDef.header
|
|
18682
|
+
},
|
|
18683
|
+
header.id
|
|
18684
|
+
);
|
|
18685
|
+
}) }, headerGroup.id)) }),
|
|
18686
|
+
/* @__PURE__ */ jsx(TableBody$1, { dependencies, nonAria, children: renderTableBody })
|
|
18636
18687
|
] });
|
|
18637
18688
|
};
|
|
18638
18689
|
var Dots = /* @__PURE__ */ ((Dots2) => {
|
|
@@ -18786,15 +18837,7 @@ function PaginatedTable({
|
|
|
18786
18837
|
var _a;
|
|
18787
18838
|
const { pageSize = 20, hasMore, fetchMore, initialPage = 0, onSetPage, autoResetPageIndexRef } = paginationProps;
|
|
18788
18839
|
const [pagination, setPagination] = useState({ pageIndex: initialPage, pageSize });
|
|
18789
|
-
const
|
|
18790
|
-
const columns = Object.values(columnConfig);
|
|
18791
|
-
const columnDefs = columns.map((col) => {
|
|
18792
|
-
return columnHelper.display({
|
|
18793
|
-
id: col.id,
|
|
18794
|
-
header: () => col.header,
|
|
18795
|
-
cell: ({ row }) => col.cell(row.original)
|
|
18796
|
-
});
|
|
18797
|
-
});
|
|
18840
|
+
const columnDefs = getColumnDefs(columnConfig);
|
|
18798
18841
|
const table2 = useReactTable({
|
|
18799
18842
|
data: data != null ? data : [],
|
|
18800
18843
|
columns: columnDefs,
|
|
@@ -18809,21 +18852,23 @@ function PaginatedTable({
|
|
|
18809
18852
|
autoResetPageIndex: (_a = autoResetPageIndexRef == null ? void 0 : autoResetPageIndexRef.current) != null ? _a : false
|
|
18810
18853
|
});
|
|
18811
18854
|
const { rows } = table2.getRowModel();
|
|
18812
|
-
const rowData = useMemo(() => rows.map((r) => r.original), [rows]);
|
|
18813
18855
|
const onPageChange = useCallback((page) => {
|
|
18814
18856
|
table2.setPageIndex(page - 1);
|
|
18815
18857
|
}, [table2]);
|
|
18858
|
+
const headerGroups = table2.getHeaderGroups();
|
|
18859
|
+
const numColumns = table2.getVisibleLeafColumns().length;
|
|
18816
18860
|
return /* @__PURE__ */ jsxs(VStack, { children: [
|
|
18817
18861
|
/* @__PURE__ */ jsx(
|
|
18818
18862
|
DataTable,
|
|
18819
18863
|
{
|
|
18820
18864
|
ariaLabel,
|
|
18821
|
-
|
|
18822
|
-
data:
|
|
18865
|
+
numColumns,
|
|
18866
|
+
data: rows,
|
|
18823
18867
|
isLoading,
|
|
18824
18868
|
isError,
|
|
18825
18869
|
componentName,
|
|
18826
|
-
slots
|
|
18870
|
+
slots,
|
|
18871
|
+
headerGroups
|
|
18827
18872
|
}
|
|
18828
18873
|
),
|
|
18829
18874
|
!isError && !isLoading && /* @__PURE__ */ jsx(
|
|
@@ -18913,34 +18958,25 @@ const CategorizationRulesTable = () => {
|
|
|
18913
18958
|
spacing: true
|
|
18914
18959
|
}
|
|
18915
18960
|
), [refetch]);
|
|
18916
|
-
const columnConfig = useMemo(() =>
|
|
18917
|
-
|
|
18918
|
-
"Counterparty"
|
|
18919
|
-
/* Counterparty */
|
|
18920
|
-
]: {
|
|
18961
|
+
const columnConfig = useMemo(() => [
|
|
18962
|
+
{
|
|
18921
18963
|
id: "Counterparty",
|
|
18922
18964
|
header: "Counterparty",
|
|
18923
18965
|
cell: (row) => {
|
|
18924
18966
|
var _a2;
|
|
18925
|
-
return /* @__PURE__ */ jsx(Span, { ellipsis: true, children: (_a2 = row.counterpartyFilter) == null ? void 0 : _a2.name });
|
|
18967
|
+
return /* @__PURE__ */ jsx(Span, { ellipsis: true, children: (_a2 = row.original.counterpartyFilter) == null ? void 0 : _a2.name });
|
|
18926
18968
|
}
|
|
18927
18969
|
},
|
|
18928
|
-
|
|
18929
|
-
"Category"
|
|
18930
|
-
/* Category */
|
|
18931
|
-
]: {
|
|
18970
|
+
{
|
|
18932
18971
|
id: "Category",
|
|
18933
18972
|
header: "Category",
|
|
18934
18973
|
cell: (row) => {
|
|
18935
|
-
const accountIdentifier = row.category;
|
|
18974
|
+
const accountIdentifier = row.original.category;
|
|
18936
18975
|
return accountIdentifier && /* @__PURE__ */ jsx(CategoryDisplay, { accountIdentifier, options: options2 });
|
|
18937
18976
|
},
|
|
18938
18977
|
isRowHeader: true
|
|
18939
18978
|
},
|
|
18940
|
-
|
|
18941
|
-
"Delete"
|
|
18942
|
-
/* Delete */
|
|
18943
|
-
]: {
|
|
18979
|
+
{
|
|
18944
18980
|
id: "Delete",
|
|
18945
18981
|
cell: (row) => /* @__PURE__ */ jsx(
|
|
18946
18982
|
Button,
|
|
@@ -18948,7 +18984,7 @@ const CategorizationRulesTable = () => {
|
|
|
18948
18984
|
inset: true,
|
|
18949
18985
|
icon: true,
|
|
18950
18986
|
onPress: () => {
|
|
18951
|
-
setSelectedRule(row);
|
|
18987
|
+
setSelectedRule(row.original);
|
|
18952
18988
|
setShowDeletionConfirmationModal(true);
|
|
18953
18989
|
},
|
|
18954
18990
|
"aria-label": "Delete rule",
|
|
@@ -18957,7 +18993,7 @@ const CategorizationRulesTable = () => {
|
|
|
18957
18993
|
}
|
|
18958
18994
|
)
|
|
18959
18995
|
}
|
|
18960
|
-
|
|
18996
|
+
], [options2]);
|
|
18961
18997
|
return /* @__PURE__ */ jsxs(Container, { name: "CategorizationRulesTable", children: [
|
|
18962
18998
|
/* @__PURE__ */ jsx(
|
|
18963
18999
|
PaginatedTable,
|
|
@@ -21075,7 +21111,7 @@ const DatePicker = ({
|
|
|
21075
21111
|
const getIsDateInvalid = (date, { minDate, maxDate }) => {
|
|
21076
21112
|
if (date === null) return "Cannot select empty date";
|
|
21077
21113
|
if (minDate && date.compare(minDate) < 0) return "Cannot select date before the business activation date";
|
|
21078
|
-
if (maxDate && date.compare(maxDate) > 0) return "Cannot select date
|
|
21114
|
+
if (maxDate && date.compare(maxDate) > 0) return "Cannot select date in the future";
|
|
21079
21115
|
return null;
|
|
21080
21116
|
};
|
|
21081
21117
|
const useDatePickerState = ({ date, setDate, minDate = null, maxDate = null }) => {
|
|
@@ -21593,8 +21629,8 @@ const sortPnlLineItemsAndCalculateTotal = (items, filter) => {
|
|
|
21593
21629
|
};
|
|
21594
21630
|
const useProfitAndLoss = ({ tagFilter, reportingBasis }) => {
|
|
21595
21631
|
var _a;
|
|
21596
|
-
const [
|
|
21597
|
-
const dateRange = useGlobalDateRange({
|
|
21632
|
+
const [dateSelectionMode, setDateSelectionMode] = useState("month");
|
|
21633
|
+
const dateRange = useGlobalDateRange({ dateSelectionMode });
|
|
21598
21634
|
const [filters, setFilters] = useState({
|
|
21599
21635
|
expenses: void 0,
|
|
21600
21636
|
revenue: void 0
|
|
@@ -21653,8 +21689,8 @@ const useProfitAndLoss = ({ tagFilter, reportingBasis }) => {
|
|
|
21653
21689
|
dateRange,
|
|
21654
21690
|
selectedLineItem,
|
|
21655
21691
|
setSelectedLineItem,
|
|
21656
|
-
|
|
21657
|
-
|
|
21692
|
+
setDateSelectionMode,
|
|
21693
|
+
dateSelectionMode
|
|
21658
21694
|
};
|
|
21659
21695
|
};
|
|
21660
21696
|
function isArrayWithAtLeastOne(list) {
|
|
@@ -21841,9 +21877,9 @@ const ProfitAndLossContext = createContext({
|
|
|
21841
21877
|
selectedLineItem: null,
|
|
21842
21878
|
setSelectedLineItem: () => {
|
|
21843
21879
|
},
|
|
21844
|
-
|
|
21880
|
+
setDateSelectionMode: () => {
|
|
21845
21881
|
},
|
|
21846
|
-
|
|
21882
|
+
dateSelectionMode: "month"
|
|
21847
21883
|
});
|
|
21848
21884
|
const isNotOnlyNoneTag = (compareOptions) => {
|
|
21849
21885
|
return Boolean(
|
|
@@ -21875,8 +21911,8 @@ function useProfitAndLossComparison({
|
|
|
21875
21911
|
}) {
|
|
21876
21912
|
var _a;
|
|
21877
21913
|
const [comparisonPeriodMode, setComparisonPeriodMode] = useState(DateGroupBy.AllTime);
|
|
21878
|
-
const {
|
|
21879
|
-
const { startDate, endDate } = useGlobalDateRange({
|
|
21914
|
+
const { dateSelectionMode } = useContext(ProfitAndLossContext);
|
|
21915
|
+
const { startDate, endDate } = useGlobalDateRange({ dateSelectionMode: "month" });
|
|
21880
21916
|
const comparePeriods = useMemo(() => {
|
|
21881
21917
|
if (!comparisonPeriodMode || comparisonPeriodMode === DateGroupBy.AllTime) {
|
|
21882
21918
|
return 1;
|
|
@@ -21889,7 +21925,7 @@ function useProfitAndLossComparison({
|
|
|
21889
21925
|
const [selectedCompareOptions, setSelectedCompareOptionsState] = useState(
|
|
21890
21926
|
(comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter) ? [comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter] : []
|
|
21891
21927
|
);
|
|
21892
|
-
const dateRange = useGlobalDateRange({
|
|
21928
|
+
const dateRange = useGlobalDateRange({ dateSelectionMode });
|
|
21893
21929
|
const compareModeActive = useMemo(() => comparePeriods > 1 || selectedCompareOptions.length > 1 || selectedCompareOptions.length === 1 && isNotOnlyNoneTag(selectedCompareOptions), [comparePeriods, selectedCompareOptions]);
|
|
21894
21930
|
const setSelectedCompareOptions = (values) => {
|
|
21895
21931
|
const options2 = values.map(
|
|
@@ -22237,7 +22273,7 @@ const ProfitAndLossChart = ({
|
|
|
22237
22273
|
const [compactView, setCompactView] = useState(false);
|
|
22238
22274
|
const barSize = compactView ? 10 : 20;
|
|
22239
22275
|
const { getColor, business } = useLayerContext();
|
|
22240
|
-
const dateRange = useGlobalDateRange({
|
|
22276
|
+
const dateRange = useGlobalDateRange({ dateSelectionMode: "month" });
|
|
22241
22277
|
const { setMonth } = useGlobalDateRangeActions();
|
|
22242
22278
|
const [customCursorSize, setCustomCursorSize] = useState({
|
|
22243
22279
|
width: 0,
|
|
@@ -22870,14 +22906,19 @@ const BackButton = (_Ec) => {
|
|
|
22870
22906
|
const baseClassName2 = classNames("Layer__btn", "Layer__back-btn", className);
|
|
22871
22907
|
return /* @__PURE__ */ jsx("button", __spreadProps(__spreadValues({}, props), { className: baseClassName2, children: textOnly ? "Back" : /* @__PURE__ */ jsx(BackArrow, { size: 16 }) }));
|
|
22872
22908
|
};
|
|
22873
|
-
|
|
22909
|
+
function useGlobalDatePickerBounds() {
|
|
22874
22910
|
const rawActivationDate = useBusinessActivationDate();
|
|
22875
|
-
const
|
|
22911
|
+
const minDate = useMemo(() => rawActivationDate ? startOfDay(rawActivationDate) : null, [rawActivationDate]);
|
|
22912
|
+
const maxDate = useMemo(() => endOfDay(/* @__PURE__ */ new Date()), []);
|
|
22913
|
+
return useMemo(() => ({ minDate, maxDate }), [minDate, maxDate]);
|
|
22914
|
+
}
|
|
22915
|
+
const GlobalMonthPicker = ({ truncateMonth }) => {
|
|
22916
|
+
const { minDate, maxDate } = useGlobalDatePickerBounds();
|
|
22876
22917
|
const { setMonth } = useGlobalDateRangeActions();
|
|
22877
|
-
const { date } = useGlobalDate();
|
|
22918
|
+
const { date } = useGlobalDate({ dateSelectionMode: "month" });
|
|
22878
22919
|
const dateZdt = useMemo(() => convertDateToZonedDateTime(date), [date]);
|
|
22879
|
-
const minDateZdt = useMemo(() =>
|
|
22880
|
-
const maxDateZdt = useMemo(() => convertDateToZonedDateTime(
|
|
22920
|
+
const minDateZdt = useMemo(() => minDate ? convertDateToZonedDateTime(minDate) : null, [minDate]);
|
|
22921
|
+
const maxDateZdt = useMemo(() => convertDateToZonedDateTime(maxDate), [maxDate]);
|
|
22881
22922
|
const onChange = useCallback((val) => {
|
|
22882
22923
|
setMonth({ startDate: val.toDate() });
|
|
22883
22924
|
}, [setMonth]);
|
|
@@ -24184,30 +24225,24 @@ const ProfitAndLossDetailReport = ({
|
|
|
24184
24225
|
total: runningBalance
|
|
24185
24226
|
};
|
|
24186
24227
|
}, [data == null ? void 0 : data.lines]);
|
|
24187
|
-
const columnConfig = useMemo(() =>
|
|
24188
|
-
|
|
24189
|
-
"Date"
|
|
24190
|
-
/* Date */
|
|
24191
|
-
]: {
|
|
24228
|
+
const columnConfig = useMemo(() => [
|
|
24229
|
+
{
|
|
24192
24230
|
id: "Date",
|
|
24193
24231
|
header: (stringOverrides == null ? void 0 : stringOverrides.dateColumnHeader) || "Date",
|
|
24194
24232
|
cell: (row) => /* @__PURE__ */ jsx(
|
|
24195
24233
|
DateTime,
|
|
24196
24234
|
{
|
|
24197
|
-
value: row.date,
|
|
24235
|
+
value: row.original.date,
|
|
24198
24236
|
onlyDate: true,
|
|
24199
24237
|
slotProps: { Date: { size: TextSize.md, weight: TextWeight.normal, variant: "subtle" } }
|
|
24200
24238
|
}
|
|
24201
24239
|
)
|
|
24202
24240
|
},
|
|
24203
|
-
|
|
24204
|
-
"Type"
|
|
24205
|
-
/* Type */
|
|
24206
|
-
]: {
|
|
24241
|
+
{
|
|
24207
24242
|
id: "Type",
|
|
24208
24243
|
header: (stringOverrides == null ? void 0 : stringOverrides.typeColumnHeader) || "Type",
|
|
24209
24244
|
cell: (row) => {
|
|
24210
|
-
const { source } = row;
|
|
24245
|
+
const { source } = row.original;
|
|
24211
24246
|
return source ? /* @__PURE__ */ jsx(
|
|
24212
24247
|
Button,
|
|
24213
24248
|
{
|
|
@@ -24218,10 +24253,7 @@ const ProfitAndLossDetailReport = ({
|
|
|
24218
24253
|
) : "-";
|
|
24219
24254
|
}
|
|
24220
24255
|
},
|
|
24221
|
-
|
|
24222
|
-
"Account"
|
|
24223
|
-
/* Account */
|
|
24224
|
-
]: {
|
|
24256
|
+
{
|
|
24225
24257
|
id: "Account",
|
|
24226
24258
|
header: (stringOverrides == null ? void 0 : stringOverrides.accountColumnHeader) || "Account",
|
|
24227
24259
|
cell: (row) => /* @__PURE__ */ jsx(
|
|
@@ -24230,14 +24262,11 @@ const ProfitAndLossDetailReport = ({
|
|
|
24230
24262
|
as: "span",
|
|
24231
24263
|
withDeprecatedTooltip: TextUseTooltip.whenTruncated,
|
|
24232
24264
|
ellipsis: true,
|
|
24233
|
-
children: row.account.name || "-"
|
|
24265
|
+
children: row.original.account.name || "-"
|
|
24234
24266
|
}
|
|
24235
24267
|
)
|
|
24236
24268
|
},
|
|
24237
|
-
|
|
24238
|
-
"Description"
|
|
24239
|
-
/* Description */
|
|
24240
|
-
]: {
|
|
24269
|
+
{
|
|
24241
24270
|
id: "Description",
|
|
24242
24271
|
header: (stringOverrides == null ? void 0 : stringOverrides.descriptionColumnHeader) || "Description",
|
|
24243
24272
|
cell: (row) => {
|
|
@@ -24248,33 +24277,27 @@ const ProfitAndLossDetailReport = ({
|
|
|
24248
24277
|
as: "span",
|
|
24249
24278
|
withDeprecatedTooltip: TextUseTooltip.whenTruncated,
|
|
24250
24279
|
ellipsis: true,
|
|
24251
|
-
children: ((_a = row.source) == null ? void 0 : _a.displayDescription) || row.account.accountSubtype.displayName || "-"
|
|
24280
|
+
children: ((_a = row.original.source) == null ? void 0 : _a.displayDescription) || row.original.account.accountSubtype.displayName || "-"
|
|
24252
24281
|
}
|
|
24253
24282
|
);
|
|
24254
24283
|
},
|
|
24255
24284
|
isRowHeader: true
|
|
24256
24285
|
},
|
|
24257
|
-
|
|
24258
|
-
"Amount"
|
|
24259
|
-
/* Amount */
|
|
24260
|
-
]: {
|
|
24286
|
+
{
|
|
24261
24287
|
id: "Amount",
|
|
24262
24288
|
header: (stringOverrides == null ? void 0 : stringOverrides.amountColumnHeader) || "Amount",
|
|
24263
24289
|
cell: (row) => {
|
|
24264
|
-
return /* @__PURE__ */ jsx(MoneySpan, { amount: row.direction === Direction.CREDIT ? row.amount : -row.amount });
|
|
24290
|
+
return /* @__PURE__ */ jsx(MoneySpan, { amount: row.original.direction === Direction.CREDIT ? row.original.amount : -row.original.amount });
|
|
24265
24291
|
}
|
|
24266
24292
|
},
|
|
24267
|
-
|
|
24268
|
-
"Balance"
|
|
24269
|
-
/* Balance */
|
|
24270
|
-
]: {
|
|
24293
|
+
{
|
|
24271
24294
|
id: "Balance",
|
|
24272
24295
|
header: (stringOverrides == null ? void 0 : stringOverrides.balanceColumnHeader) || "Balance",
|
|
24273
24296
|
cell: (row) => {
|
|
24274
|
-
return /* @__PURE__ */ jsx(MoneySpan, { amount: row.runningBalance });
|
|
24297
|
+
return /* @__PURE__ */ jsx(MoneySpan, { amount: row.original.runningBalance });
|
|
24275
24298
|
}
|
|
24276
24299
|
}
|
|
24277
|
-
|
|
24300
|
+
], [stringOverrides, handleSourceClick]);
|
|
24278
24301
|
const Header3 = useCallback(() => {
|
|
24279
24302
|
return /* @__PURE__ */ jsx(
|
|
24280
24303
|
DetailReportBreadcrumb,
|
|
@@ -24594,7 +24617,7 @@ const options$3 = Object.values(dateSelectionOptionConfig).filter((opt) => opt.v
|
|
|
24594
24617
|
const DateSelectionComboBox = () => {
|
|
24595
24618
|
const [lastPreset, setLastPreset] = useState(null);
|
|
24596
24619
|
const { business } = useLayerContext();
|
|
24597
|
-
const dateRange = useGlobalDateRange({
|
|
24620
|
+
const dateRange = useGlobalDateRange({ dateSelectionMode: "full" });
|
|
24598
24621
|
const { setDateRange } = useGlobalDateRangeActions();
|
|
24599
24622
|
const selectedPreset = presetForDateRange(dateRange, lastPreset, getActivationDate(business));
|
|
24600
24623
|
const selectedOption = dateSelectionOptionConfig[selectedPreset != null ? selectedPreset : DatePreset.Custom];
|
|
@@ -24617,10 +24640,10 @@ const DateSelectionComboBox = () => {
|
|
|
24617
24640
|
}
|
|
24618
24641
|
);
|
|
24619
24642
|
};
|
|
24620
|
-
const
|
|
24621
|
-
const { startDate: globalStartDate, endDate: globalEndDate } = useGlobalDateRange({
|
|
24643
|
+
const GlobalDateRangePicker = () => {
|
|
24644
|
+
const { startDate: globalStartDate, endDate: globalEndDate } = useGlobalDateRange({ dateSelectionMode: "full" });
|
|
24622
24645
|
const { setDateRange: setGlobalDateRange } = useGlobalDateRangeActions();
|
|
24623
|
-
const {
|
|
24646
|
+
const { minDate, maxDate } = useGlobalDatePickerBounds();
|
|
24624
24647
|
const {
|
|
24625
24648
|
localDate: localStartDate,
|
|
24626
24649
|
onChange: onChangeStartDate,
|
|
@@ -24652,6 +24675,39 @@ const DateRangeSelection = ({ minDate, maxDate }) => {
|
|
|
24652
24675
|
const next = { startDate: localStartDate.toDate(), endDate: localEndDate.toDate() };
|
|
24653
24676
|
setGlobalDateRange(next);
|
|
24654
24677
|
}, [startDateInvalid, endDateInvalid, localStartDate, localEndDate, setGlobalDateRange]);
|
|
24678
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
24679
|
+
/* @__PURE__ */ jsx(
|
|
24680
|
+
DatePicker,
|
|
24681
|
+
{
|
|
24682
|
+
label: "Start Date",
|
|
24683
|
+
showLabel: false,
|
|
24684
|
+
date: localStartDate,
|
|
24685
|
+
onChange: onChangeStartDate,
|
|
24686
|
+
minDate: minStartDate,
|
|
24687
|
+
maxDate: maxStartDate,
|
|
24688
|
+
isInvalid: startDateInvalid,
|
|
24689
|
+
errorText: startDateErrorText,
|
|
24690
|
+
onBlur: onBlurStartDate
|
|
24691
|
+
}
|
|
24692
|
+
),
|
|
24693
|
+
/* @__PURE__ */ jsx(
|
|
24694
|
+
DatePicker,
|
|
24695
|
+
{
|
|
24696
|
+
label: "End Date",
|
|
24697
|
+
showLabel: false,
|
|
24698
|
+
date: localEndDate,
|
|
24699
|
+
onChange: onChangeEndDate,
|
|
24700
|
+
minDate: minEndDate,
|
|
24701
|
+
maxDate: maxEndDate,
|
|
24702
|
+
isInvalid: endDateInvalid,
|
|
24703
|
+
errorText: endDateErrorText,
|
|
24704
|
+
onBlur: onBlurEndDate
|
|
24705
|
+
}
|
|
24706
|
+
)
|
|
24707
|
+
] });
|
|
24708
|
+
};
|
|
24709
|
+
const DateRangeSelection = () => {
|
|
24710
|
+
const { value } = useSizeClass();
|
|
24655
24711
|
return /* @__PURE__ */ jsxs(
|
|
24656
24712
|
HStack,
|
|
24657
24713
|
{
|
|
@@ -24660,34 +24716,7 @@ const DateRangeSelection = ({ minDate, maxDate }) => {
|
|
|
24660
24716
|
}),
|
|
24661
24717
|
children: [
|
|
24662
24718
|
/* @__PURE__ */ jsx(DateSelectionComboBox, {}),
|
|
24663
|
-
/* @__PURE__ */ jsx(
|
|
24664
|
-
DatePicker,
|
|
24665
|
-
{
|
|
24666
|
-
label: "Start Date",
|
|
24667
|
-
showLabel: false,
|
|
24668
|
-
date: localStartDate,
|
|
24669
|
-
onChange: onChangeStartDate,
|
|
24670
|
-
minDate: minStartDate,
|
|
24671
|
-
maxDate: maxStartDate,
|
|
24672
|
-
isInvalid: startDateInvalid,
|
|
24673
|
-
errorText: startDateErrorText,
|
|
24674
|
-
onBlur: onBlurStartDate
|
|
24675
|
-
}
|
|
24676
|
-
),
|
|
24677
|
-
/* @__PURE__ */ jsx(
|
|
24678
|
-
DatePicker,
|
|
24679
|
-
{
|
|
24680
|
-
label: "End Date",
|
|
24681
|
-
showLabel: false,
|
|
24682
|
-
date: localEndDate,
|
|
24683
|
-
onChange: onChangeEndDate,
|
|
24684
|
-
minDate: minEndDate,
|
|
24685
|
-
maxDate: maxEndDate,
|
|
24686
|
-
isInvalid: endDateInvalid,
|
|
24687
|
-
errorText: endDateErrorText,
|
|
24688
|
-
onBlur: onBlurEndDate
|
|
24689
|
-
}
|
|
24690
|
-
)
|
|
24719
|
+
/* @__PURE__ */ jsx(GlobalDateRangePicker, {})
|
|
24691
24720
|
]
|
|
24692
24721
|
}
|
|
24693
24722
|
);
|
|
@@ -25012,7 +25041,7 @@ const ProfitAndLossCompareOptions = () => {
|
|
|
25012
25041
|
comparisonPeriodMode,
|
|
25013
25042
|
setComparisonPeriodMode
|
|
25014
25043
|
} = useContext(ProfitAndLossComparisonContext);
|
|
25015
|
-
const {
|
|
25044
|
+
const { dateSelectionMode } = useContext(ProfitAndLossContext);
|
|
25016
25045
|
const tagComparisonSelectOptions = compareOptions.map(
|
|
25017
25046
|
(tagComparisonOption) => {
|
|
25018
25047
|
return {
|
|
@@ -25025,7 +25054,7 @@ const ProfitAndLossCompareOptions = () => {
|
|
|
25025
25054
|
return null;
|
|
25026
25055
|
}
|
|
25027
25056
|
return /* @__PURE__ */ jsxs(HStack, { align: "center", gap: "xs", children: [
|
|
25028
|
-
|
|
25057
|
+
dateSelectionMode === "full" && /* @__PURE__ */ jsx(DateGroupByComboBox, { value: comparisonPeriodMode, onValueChange: setComparisonPeriodMode }),
|
|
25029
25058
|
/* @__PURE__ */ jsx(
|
|
25030
25059
|
MultiSelect,
|
|
25031
25060
|
{
|
|
@@ -25200,7 +25229,7 @@ const useTableExpandRow = () => {
|
|
|
25200
25229
|
const ProfitAndLossCompareTable = ({
|
|
25201
25230
|
stringOverrides
|
|
25202
25231
|
}) => {
|
|
25203
|
-
const { dateRange,
|
|
25232
|
+
const { dateRange, dateSelectionMode } = useContext(ProfitAndLossContext);
|
|
25204
25233
|
const {
|
|
25205
25234
|
data: comparisonData,
|
|
25206
25235
|
isLoading,
|
|
@@ -25217,7 +25246,7 @@ const ProfitAndLossCompareTable = ({
|
|
|
25217
25246
|
return /* @__PURE__ */ jsx("div", { className: "Layer__profit-and-loss-table__loader-container", children: /* @__PURE__ */ jsx(Loader, {}) });
|
|
25218
25247
|
}
|
|
25219
25248
|
const getBookkeepingPeriodStatus = (date) => {
|
|
25220
|
-
if (!bookkeepingPeriods ||
|
|
25249
|
+
if (!bookkeepingPeriods || dateSelectionMode !== "month") {
|
|
25221
25250
|
return;
|
|
25222
25251
|
}
|
|
25223
25252
|
const currentMonth = date.getMonth() + 1;
|
|
@@ -25646,11 +25675,11 @@ const ProfitAndLossReport = ({
|
|
|
25646
25675
|
hideHeader
|
|
25647
25676
|
}) => {
|
|
25648
25677
|
var _a;
|
|
25649
|
-
const { selectedLineItem, setSelectedLineItem,
|
|
25678
|
+
const { selectedLineItem, setSelectedLineItem, setDateSelectionMode } = useContext(ProfitAndLossContext);
|
|
25650
25679
|
const { comparisonConfig } = useContext(ProfitAndLossComparisonContext);
|
|
25651
25680
|
useEffect(() => {
|
|
25652
|
-
|
|
25653
|
-
}, [dateSelectionMode,
|
|
25681
|
+
setDateSelectionMode(dateSelectionMode);
|
|
25682
|
+
}, [dateSelectionMode, setDateSelectionMode]);
|
|
25654
25683
|
const breadcrumbIndexMap = useMemo(() => {
|
|
25655
25684
|
if (!selectedLineItem) return {};
|
|
25656
25685
|
return selectedLineItem.breadcrumbPath.reduce((acc, item, index) => {
|
|
@@ -25997,7 +26026,7 @@ function Internal_ProfitAndLossSummaries({
|
|
|
25997
26026
|
setSidebarScope,
|
|
25998
26027
|
sidebarScope
|
|
25999
26028
|
} = useContext(ProfitAndLossContext);
|
|
26000
|
-
const { startDate, endDate: _endDate } = useGlobalDateRange({
|
|
26029
|
+
const { startDate, endDate: _endDate } = useGlobalDateRange({ dateSelectionMode: "month" });
|
|
26001
26030
|
const previousMonthStart = sub(startDate, { months: 1 });
|
|
26002
26031
|
const { data: previousData } = useProfitAndLossSummaries({
|
|
26003
26032
|
startYear: previousMonthStart.getFullYear(),
|
|
@@ -26504,18 +26533,16 @@ const BalanceSheetTable = ({
|
|
|
26504
26533
|
] });
|
|
26505
26534
|
};
|
|
26506
26535
|
const GlobalDatePicker = () => {
|
|
26507
|
-
const { date } = useGlobalDate();
|
|
26536
|
+
const { date } = useGlobalDate({ dateSelectionMode: "full" });
|
|
26508
26537
|
const { setDate: setGlobalDate } = useGlobalDateActions();
|
|
26509
|
-
const
|
|
26510
|
-
const activationDate = useMemo(() => rawActivationDate ? startOfDay(rawActivationDate) : null, [rawActivationDate]);
|
|
26511
|
-
const maxDate = useMemo(() => endOfDay(/* @__PURE__ */ new Date()), []);
|
|
26538
|
+
const { minDate, maxDate } = useGlobalDatePickerBounds();
|
|
26512
26539
|
const setDate = useCallback((date2) => {
|
|
26513
26540
|
setGlobalDate({ date: date2 });
|
|
26514
26541
|
}, [setGlobalDate]);
|
|
26515
26542
|
const { localDate, onChange, minDateZdt, maxDateZdt, errorText, onBlur, isInvalid } = useDatePickerState({
|
|
26516
26543
|
date,
|
|
26517
26544
|
setDate,
|
|
26518
|
-
minDate
|
|
26545
|
+
minDate,
|
|
26519
26546
|
maxDate
|
|
26520
26547
|
});
|
|
26521
26548
|
return /* @__PURE__ */ jsx(
|
|
@@ -26550,7 +26577,7 @@ const DateSelection = () => {
|
|
|
26550
26577
|
};
|
|
26551
26578
|
const CombinedDateSelection = ({ mode }) => {
|
|
26552
26579
|
if (mode === "month") {
|
|
26553
|
-
return /* @__PURE__ */ jsx(
|
|
26580
|
+
return /* @__PURE__ */ jsx(GlobalMonthPicker, {});
|
|
26554
26581
|
}
|
|
26555
26582
|
return /* @__PURE__ */ jsx(DateSelection, {});
|
|
26556
26583
|
};
|
|
@@ -26570,7 +26597,7 @@ const BalanceSheetView = ({
|
|
|
26570
26597
|
stringOverrides,
|
|
26571
26598
|
dateSelectionMode = "full"
|
|
26572
26599
|
}) => {
|
|
26573
|
-
const { date: effectiveDate } = useGlobalDate();
|
|
26600
|
+
const { date: effectiveDate } = useGlobalDate({ dateSelectionMode });
|
|
26574
26601
|
const { data, isLoading } = useBalanceSheet({ effectiveDate });
|
|
26575
26602
|
const { view, containerRef } = useElementViewSize();
|
|
26576
26603
|
if (asWidget) {
|
|
@@ -26885,7 +26912,7 @@ const StatementOfCashFlowView = ({
|
|
|
26885
26912
|
stringOverrides,
|
|
26886
26913
|
dateSelectionMode = "full"
|
|
26887
26914
|
}) => {
|
|
26888
|
-
const dateRange = useGlobalDateRange({
|
|
26915
|
+
const dateRange = useGlobalDateRange({ dateSelectionMode });
|
|
26889
26916
|
const { data, isLoading } = useStatementOfCashFlow(dateRange);
|
|
26890
26917
|
const { view, containerRef } = useElementViewSize();
|
|
26891
26918
|
return /* @__PURE__ */ jsx(TableProvider, { children: /* @__PURE__ */ jsx(
|
|
@@ -27551,7 +27578,7 @@ const useChartOfAccounts = ({ withDates = false } = {}) => {
|
|
|
27551
27578
|
const { businessId } = useLayerContext();
|
|
27552
27579
|
const { apiUrl } = useEnvironment();
|
|
27553
27580
|
const { data: auth } = useAuth();
|
|
27554
|
-
const { startDate, endDate } = useGlobalDateRange({
|
|
27581
|
+
const { startDate, endDate } = useGlobalDateRange({ dateSelectionMode: "month" });
|
|
27555
27582
|
const [form, setForm] = useState();
|
|
27556
27583
|
const [sendingForm, setSendingForm] = useState(false);
|
|
27557
27584
|
const [apiError, setApiError] = useState(void 0);
|
|
@@ -35533,56 +35560,38 @@ const AmountCell = ({ invoice }) => {
|
|
|
35533
35560
|
}
|
|
35534
35561
|
}
|
|
35535
35562
|
};
|
|
35536
|
-
const getColumnConfig$1 = (onSelectInvoice) =>
|
|
35537
|
-
|
|
35538
|
-
"SentAt"
|
|
35539
|
-
/* SentAt */
|
|
35540
|
-
]: {
|
|
35563
|
+
const getColumnConfig$1 = (onSelectInvoice) => [
|
|
35564
|
+
{
|
|
35541
35565
|
id: "SentAt",
|
|
35542
35566
|
header: "Sent Date",
|
|
35543
|
-
cell: (row) => row.sentAt ? formatDate(row.sentAt) : null
|
|
35567
|
+
cell: (row) => row.original.sentAt ? formatDate(row.original.sentAt) : null
|
|
35544
35568
|
},
|
|
35545
|
-
|
|
35546
|
-
"InvoiceNo"
|
|
35547
|
-
/* InvoiceNo */
|
|
35548
|
-
]: {
|
|
35569
|
+
{
|
|
35549
35570
|
id: "InvoiceNo",
|
|
35550
35571
|
header: "No.",
|
|
35551
|
-
cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, children: row.invoiceNumber }),
|
|
35572
|
+
cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, children: row.original.invoiceNumber }),
|
|
35552
35573
|
isRowHeader: true
|
|
35553
35574
|
},
|
|
35554
|
-
|
|
35555
|
-
"Customer"
|
|
35556
|
-
/* Customer */
|
|
35557
|
-
]: {
|
|
35575
|
+
{
|
|
35558
35576
|
id: "Customer",
|
|
35559
35577
|
header: "Customer",
|
|
35560
|
-
cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, children: getCustomerName(row.customer) })
|
|
35578
|
+
cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, children: getCustomerName(row.original.customer) })
|
|
35561
35579
|
},
|
|
35562
|
-
|
|
35563
|
-
"Total"
|
|
35564
|
-
/* Total */
|
|
35565
|
-
]: {
|
|
35580
|
+
{
|
|
35566
35581
|
id: "Total",
|
|
35567
35582
|
header: "Amount",
|
|
35568
|
-
cell: (row) => /* @__PURE__ */ jsx(AmountCell, { invoice: row })
|
|
35583
|
+
cell: (row) => /* @__PURE__ */ jsx(AmountCell, { invoice: row.original })
|
|
35569
35584
|
},
|
|
35570
|
-
|
|
35571
|
-
"Status"
|
|
35572
|
-
/* Status */
|
|
35573
|
-
]: {
|
|
35585
|
+
{
|
|
35574
35586
|
id: "Status",
|
|
35575
35587
|
header: "Status",
|
|
35576
|
-
cell: (row) => /* @__PURE__ */ jsx(InvoiceStatusCell, { invoice: row })
|
|
35588
|
+
cell: (row) => /* @__PURE__ */ jsx(InvoiceStatusCell, { invoice: row.original })
|
|
35577
35589
|
},
|
|
35578
|
-
|
|
35579
|
-
"Expand"
|
|
35580
|
-
/* Expand */
|
|
35581
|
-
]: {
|
|
35590
|
+
{
|
|
35582
35591
|
id: "Expand",
|
|
35583
|
-
cell: (row) => /* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onSelectInvoice(row), "aria-label": "View invoice", variant: "ghost", children: /* @__PURE__ */ jsx(ChevronRightFill, {}) })
|
|
35592
|
+
cell: (row) => /* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onSelectInvoice(row.original), "aria-label": "View invoice", variant: "ghost", children: /* @__PURE__ */ jsx(ChevronRightFill, {}) })
|
|
35584
35593
|
}
|
|
35585
|
-
|
|
35594
|
+
];
|
|
35586
35595
|
const UNPAID_STATUSES$1 = [InvoiceStatus.Sent, InvoiceStatus.PartiallyPaid];
|
|
35587
35596
|
const getStatusFilterParams = (statusFilter) => {
|
|
35588
35597
|
switch (statusFilter) {
|
|
@@ -38292,15 +38301,72 @@ Schema.Union(
|
|
|
38292
38301
|
DateQueryParamsSchema,
|
|
38293
38302
|
DateRangeQueryParamsSchema
|
|
38294
38303
|
);
|
|
38304
|
+
const unifiedReportColumnFields = {
|
|
38305
|
+
columnKey: pipe(
|
|
38306
|
+
Schema.propertySignature(Schema.String),
|
|
38307
|
+
Schema.fromKey("column_key")
|
|
38308
|
+
),
|
|
38309
|
+
displayName: pipe(
|
|
38310
|
+
Schema.propertySignature(Schema.String),
|
|
38311
|
+
Schema.fromKey("display_name")
|
|
38312
|
+
)
|
|
38313
|
+
};
|
|
38314
|
+
const UnifiedReportColumnSchema = Schema.Struct(__spreadProps(__spreadValues({}, unifiedReportColumnFields), {
|
|
38315
|
+
columns: Schema.optional(
|
|
38316
|
+
Schema.Array(
|
|
38317
|
+
Schema.suspend(() => UnifiedReportColumnSchema)
|
|
38318
|
+
)
|
|
38319
|
+
)
|
|
38320
|
+
}));
|
|
38321
|
+
const UnifiedCellValueAmountSchema = Schema.Struct({
|
|
38322
|
+
type: Schema.Literal("Amount"),
|
|
38323
|
+
value: Schema.Number
|
|
38324
|
+
});
|
|
38325
|
+
const UnifiedCellValueEmptySchema = Schema.Struct({
|
|
38326
|
+
type: Schema.Literal("Empty")
|
|
38327
|
+
});
|
|
38328
|
+
const UnifiedCellValueUnknownSchema = Schema.Struct({
|
|
38329
|
+
type: Schema.String,
|
|
38330
|
+
value: Schema.optional(Schema.Unknown)
|
|
38331
|
+
});
|
|
38332
|
+
const UnifiedCellValueSchema = Schema.Union(
|
|
38333
|
+
UnifiedCellValueAmountSchema,
|
|
38334
|
+
UnifiedCellValueEmptySchema,
|
|
38335
|
+
UnifiedCellValueUnknownSchema
|
|
38336
|
+
);
|
|
38337
|
+
const isAmountCellValue = (value) => value.type === "Amount";
|
|
38338
|
+
const isEmptyCellValue = (value) => value.type === "Empty";
|
|
38339
|
+
const UnifiedReportCellSchema = Schema.Struct({
|
|
38340
|
+
value: UnifiedCellValueSchema
|
|
38341
|
+
});
|
|
38342
|
+
const unifiedReportRowFields = {
|
|
38343
|
+
rowKey: pipe(
|
|
38344
|
+
Schema.propertySignature(Schema.String),
|
|
38345
|
+
Schema.fromKey("row_key")
|
|
38346
|
+
),
|
|
38347
|
+
displayName: pipe(
|
|
38348
|
+
Schema.propertySignature(Schema.String),
|
|
38349
|
+
Schema.fromKey("display_name")
|
|
38350
|
+
),
|
|
38351
|
+
cells: Schema.Record({
|
|
38352
|
+
key: Schema.String,
|
|
38353
|
+
value: Schema.NullishOr(UnifiedReportCellSchema)
|
|
38354
|
+
})
|
|
38355
|
+
};
|
|
38356
|
+
const UnifiedReportRowSchema = Schema.Struct(__spreadProps(__spreadValues({}, unifiedReportRowFields), {
|
|
38357
|
+
rows: Schema.optional(
|
|
38358
|
+
Schema.Array(
|
|
38359
|
+
Schema.suspend(() => UnifiedReportRowSchema)
|
|
38360
|
+
)
|
|
38361
|
+
)
|
|
38362
|
+
}));
|
|
38295
38363
|
const UnifiedReportSchema = Schema.Struct({
|
|
38296
38364
|
businessId: pipe(
|
|
38297
38365
|
Schema.propertySignature(Schema.UUID),
|
|
38298
38366
|
Schema.fromKey("business_id")
|
|
38299
38367
|
),
|
|
38300
|
-
|
|
38301
|
-
|
|
38302
|
-
Schema.fromKey("line_items")
|
|
38303
|
-
)
|
|
38368
|
+
columns: Schema.Array(UnifiedReportColumnSchema),
|
|
38369
|
+
rows: Schema.Array(UnifiedReportRowSchema)
|
|
38304
38370
|
});
|
|
38305
38371
|
var UnifiedReportDateVariant = /* @__PURE__ */ ((UnifiedReportDateVariant2) => {
|
|
38306
38372
|
UnifiedReportDateVariant2["Date"] = "Date";
|
|
@@ -38322,10 +38388,10 @@ function useUnifiedReportDateVariant() {
|
|
|
38322
38388
|
const report = useStore(store, (state) => state.report);
|
|
38323
38389
|
return reportToDateVariantMap[report];
|
|
38324
38390
|
}
|
|
38325
|
-
function useUnifiedReportWithDateParams() {
|
|
38391
|
+
function useUnifiedReportWithDateParams({ dateSelectionMode }) {
|
|
38326
38392
|
const store = useContext(UnifiedReportStoreContext);
|
|
38327
|
-
const { date: effectiveDate } = useGlobalDate();
|
|
38328
|
-
const { startDate, endDate } = useGlobalDateRange({
|
|
38393
|
+
const { date: effectiveDate } = useGlobalDate({ dateSelectionMode });
|
|
38394
|
+
const { startDate, endDate } = useGlobalDateRange({ dateSelectionMode });
|
|
38329
38395
|
const report = useStore(store, (state) => state.report);
|
|
38330
38396
|
const dateVariant = reportToDateVariantMap[report];
|
|
38331
38397
|
switch (dateVariant) {
|
|
@@ -38385,33 +38451,13 @@ function ExpandableDataTable({
|
|
|
38385
38451
|
ariaLabel,
|
|
38386
38452
|
slots,
|
|
38387
38453
|
hideHeader,
|
|
38388
|
-
getSubRows: getSubRows2
|
|
38454
|
+
getSubRows: getSubRows2,
|
|
38455
|
+
getRowId
|
|
38389
38456
|
}) {
|
|
38390
|
-
const columnHelper = createColumnHelper();
|
|
38391
|
-
const columns = Object.values(columnConfig);
|
|
38392
38457
|
const { expanded, setExpanded } = useContext(ExpandableDataTableContext);
|
|
38393
|
-
const columnDefs = columns.map((col) => {
|
|
38394
|
-
return columnHelper.display({
|
|
38395
|
-
id: col.id,
|
|
38396
|
-
header: () => col.header,
|
|
38397
|
-
cell: ({ row }) => col.cell(row)
|
|
38398
|
-
});
|
|
38399
|
-
});
|
|
38400
|
-
const table2 = useReactTable({
|
|
38401
|
-
data: data != null ? data : EMPTY_ARRAY,
|
|
38402
|
-
columns: columnDefs,
|
|
38403
|
-
getSubRows: getSubRows2,
|
|
38404
|
-
getCoreRowModel: getCoreRowModel(),
|
|
38405
|
-
getExpandedRowModel: getExpandedRowModel(),
|
|
38406
|
-
state: { expanded },
|
|
38407
|
-
onExpandedChange: setExpanded,
|
|
38408
|
-
autoResetPageIndex: false,
|
|
38409
|
-
getRowId: (row) => row.id
|
|
38410
|
-
});
|
|
38411
|
-
const { rows } = table2.getExpandedRowModel();
|
|
38412
38458
|
const wrappedColumnConfig = useMemo(() => {
|
|
38413
|
-
|
|
38414
|
-
|
|
38459
|
+
const [first, ...rest] = columnConfig;
|
|
38460
|
+
if (!first || !isLeafColumn(first)) return columnConfig;
|
|
38415
38461
|
const originalFirstCell = first.cell;
|
|
38416
38462
|
const firstWithChevron = __spreadProps(__spreadValues({}, first), {
|
|
38417
38463
|
cell: (row) => {
|
|
@@ -38424,26 +38470,37 @@ function ExpandableDataTable({
|
|
|
38424
38470
|
] }) });
|
|
38425
38471
|
}
|
|
38426
38472
|
});
|
|
38427
|
-
return
|
|
38428
|
-
|
|
38429
|
-
|
|
38430
|
-
|
|
38431
|
-
|
|
38432
|
-
|
|
38433
|
-
|
|
38473
|
+
return [firstWithChevron, ...rest];
|
|
38474
|
+
}, [columnConfig]);
|
|
38475
|
+
const columnDefs = getColumnDefs(wrappedColumnConfig);
|
|
38476
|
+
const table2 = useReactTable({
|
|
38477
|
+
data: data != null ? data : EMPTY_ARRAY,
|
|
38478
|
+
columns: columnDefs,
|
|
38479
|
+
getSubRows: getSubRows2,
|
|
38480
|
+
getCoreRowModel: getCoreRowModel(),
|
|
38481
|
+
getExpandedRowModel: getExpandedRowModel(),
|
|
38482
|
+
state: { expanded },
|
|
38483
|
+
onExpandedChange: setExpanded,
|
|
38484
|
+
autoResetPageIndex: false,
|
|
38485
|
+
getRowId
|
|
38486
|
+
});
|
|
38487
|
+
const { rows } = table2.getExpandedRowModel();
|
|
38434
38488
|
const dependencies = useMemo(() => [expanded], [expanded]);
|
|
38489
|
+
const headerGroups = table2.getHeaderGroups();
|
|
38490
|
+
const numColumns = table2.getVisibleLeafColumns().length;
|
|
38435
38491
|
return /* @__PURE__ */ jsx(
|
|
38436
38492
|
DataTable,
|
|
38437
38493
|
{
|
|
38438
38494
|
ariaLabel,
|
|
38439
|
-
|
|
38495
|
+
numColumns,
|
|
38440
38496
|
data: rows,
|
|
38441
38497
|
isLoading,
|
|
38442
38498
|
isError,
|
|
38443
38499
|
componentName,
|
|
38444
38500
|
slots,
|
|
38445
38501
|
hideHeader,
|
|
38446
|
-
dependencies
|
|
38502
|
+
dependencies,
|
|
38503
|
+
headerGroups
|
|
38447
38504
|
}
|
|
38448
38505
|
);
|
|
38449
38506
|
}
|
|
@@ -38475,10 +38532,6 @@ const getUnifiedReport = get((_md) => {
|
|
|
38475
38532
|
const parameters = toDefinedSearchParameters(__spreadValues({}, dateParams));
|
|
38476
38533
|
return `/v1/businesses/${businessId}/reports/unified/${report}?${parameters}`;
|
|
38477
38534
|
});
|
|
38478
|
-
const addIdToLineItem = (li) => __spreadProps(__spreadValues({}, li), {
|
|
38479
|
-
id: li.name,
|
|
38480
|
-
lineItems: li.lineItems.map(addIdToLineItem)
|
|
38481
|
-
});
|
|
38482
38535
|
class UnifiedReportSWRResponse {
|
|
38483
38536
|
constructor(swrResponse) {
|
|
38484
38537
|
__publicField(this, "swrResponse");
|
|
@@ -38513,45 +38566,64 @@ function useUnifiedReport(_od) {
|
|
|
38513
38566
|
}), dateParams)),
|
|
38514
38567
|
({ accessToken, apiUrl: apiUrl2, businessId: businessId2 }) => getUnifiedReport(apiUrl2, accessToken, {
|
|
38515
38568
|
params: __spreadValues({ businessId: businessId2, report }, dateParams)
|
|
38516
|
-
})().then(
|
|
38517
|
-
({ data }) => Schema.decodeUnknownPromise(UnifiedReportSchema)(data).then((rep) => __spreadProps(__spreadValues({}, rep), {
|
|
38518
|
-
lineItems: rep.lineItems.map(addIdToLineItem)
|
|
38519
|
-
}))
|
|
38520
|
-
)
|
|
38569
|
+
})().then(({ data }) => Schema.decodeUnknownPromise(UnifiedReportSchema)(data))
|
|
38521
38570
|
);
|
|
38522
38571
|
return new UnifiedReportSWRResponse(swrResponse);
|
|
38523
38572
|
}
|
|
38524
38573
|
const COMPONENT_NAME$2 = "UnifiedReport";
|
|
38525
|
-
const
|
|
38526
|
-
|
|
38527
|
-
|
|
38528
|
-
|
|
38529
|
-
|
|
38530
|
-
|
|
38531
|
-
|
|
38574
|
+
const makeLeafColumn = (col) => ({
|
|
38575
|
+
id: col.columnKey,
|
|
38576
|
+
header: col.displayName,
|
|
38577
|
+
cell: (row) => {
|
|
38578
|
+
var _a;
|
|
38579
|
+
const cellValue = (_a = row.original.cells[col.columnKey]) == null ? void 0 : _a.value;
|
|
38580
|
+
if (!cellValue || isEmptyCellValue(cellValue)) {
|
|
38581
|
+
return null;
|
|
38582
|
+
}
|
|
38583
|
+
if (isAmountCellValue(cellValue)) {
|
|
38584
|
+
return /* @__PURE__ */ jsx(MoneySpan, { ellipsis: true, amount: cellValue.value });
|
|
38585
|
+
}
|
|
38586
|
+
if (isEmptyCellValue(cellValue)) {
|
|
38587
|
+
return null;
|
|
38588
|
+
}
|
|
38589
|
+
return /* @__PURE__ */ jsx(Span, { ellipsis: true, children: String(cellValue.value) });
|
|
38590
|
+
}
|
|
38591
|
+
});
|
|
38592
|
+
const makeGroupColumn = (col) => ({
|
|
38593
|
+
id: col.columnKey,
|
|
38594
|
+
header: col.displayName,
|
|
38595
|
+
columns: buildNestedColumnConfig(col.columns)
|
|
38596
|
+
});
|
|
38597
|
+
const isGroupColumn = (col) => col.columns !== void 0 && col.columns.length > 0;
|
|
38598
|
+
const buildNestedColumnConfig = (columns) => {
|
|
38599
|
+
return columns.map((col) => {
|
|
38600
|
+
if (isGroupColumn(col)) {
|
|
38601
|
+
return makeGroupColumn(col);
|
|
38602
|
+
}
|
|
38603
|
+
return makeLeafColumn(col);
|
|
38604
|
+
});
|
|
38605
|
+
};
|
|
38606
|
+
const buildColumnConfig = (columns) => {
|
|
38607
|
+
const displayNameColumn = {
|
|
38608
|
+
id: "displayName",
|
|
38609
|
+
header: "",
|
|
38532
38610
|
cell: (row) => /* @__PURE__ */ jsx(Span, { weight: row.depth === 0 ? "bold" : "normal", ellipsis: true, children: row.original.displayName }),
|
|
38533
38611
|
isRowHeader: true
|
|
38534
|
-
}
|
|
38535
|
-
[
|
|
38536
|
-
"Value"
|
|
38537
|
-
/* Value */
|
|
38538
|
-
]: {
|
|
38539
|
-
id: "Value",
|
|
38540
|
-
header: "Amount",
|
|
38541
|
-
cell: (row) => /* @__PURE__ */ jsx(MoneySpan, { amount: row.original.value })
|
|
38542
|
-
}
|
|
38612
|
+
};
|
|
38613
|
+
return [displayNameColumn, ...buildNestedColumnConfig(columns)];
|
|
38543
38614
|
};
|
|
38544
|
-
const getSubRows = (
|
|
38545
|
-
const UnifiedReportTable = () => {
|
|
38546
|
-
const _a = useUnifiedReportWithDateParams(), { report } = _a, dateParams = __objRest(_a, ["report"]);
|
|
38615
|
+
const getSubRows = (row) => row.rows ? asMutable(row.rows) : void 0;
|
|
38616
|
+
const UnifiedReportTable = ({ dateSelectionMode }) => {
|
|
38617
|
+
const _a = useUnifiedReportWithDateParams({ dateSelectionMode }), { report } = _a, dateParams = __objRest(_a, ["report"]);
|
|
38547
38618
|
const { data, isLoading, isError, refetch } = useUnifiedReport(__spreadValues({ report }, dateParams));
|
|
38548
38619
|
const { setExpanded } = useContext(ExpandableDataTableContext);
|
|
38549
|
-
const
|
|
38620
|
+
const mutableRows = (data == null ? void 0 : data.rows) ? asMutable(data.rows) : void 0;
|
|
38621
|
+
const columnConfig = useMemo(() => data ? buildColumnConfig(data.columns) : [], [data]);
|
|
38550
38622
|
useEffect(() => {
|
|
38551
|
-
if (
|
|
38552
|
-
setExpanded(Object.fromEntries(
|
|
38623
|
+
if (mutableRows !== void 0) {
|
|
38624
|
+
setExpanded(Object.fromEntries(mutableRows.map((d) => [d.rowKey, true])));
|
|
38553
38625
|
}
|
|
38554
|
-
}, [
|
|
38626
|
+
}, [mutableRows, setExpanded]);
|
|
38555
38627
|
const UnifiedReportEmptyState = useCallback(() => {
|
|
38556
38628
|
return /* @__PURE__ */ jsx(
|
|
38557
38629
|
DataState,
|
|
@@ -38579,17 +38651,17 @@ const UnifiedReportTable = () => {
|
|
|
38579
38651
|
ExpandableDataTable,
|
|
38580
38652
|
{
|
|
38581
38653
|
ariaLabel: "Report",
|
|
38582
|
-
data:
|
|
38654
|
+
data: mutableRows,
|
|
38583
38655
|
isLoading: data === void 0 || isLoading,
|
|
38584
38656
|
isError,
|
|
38585
|
-
columnConfig
|
|
38657
|
+
columnConfig,
|
|
38586
38658
|
componentName: COMPONENT_NAME$2,
|
|
38587
38659
|
slots: {
|
|
38588
38660
|
ErrorState: UnifiedReportErrorState,
|
|
38589
38661
|
EmptyState: UnifiedReportEmptyState
|
|
38590
38662
|
},
|
|
38591
38663
|
getSubRows,
|
|
38592
|
-
|
|
38664
|
+
getRowId: (row) => row.rowKey
|
|
38593
38665
|
}
|
|
38594
38666
|
);
|
|
38595
38667
|
};
|
|
@@ -38668,10 +38740,10 @@ function downloadReport(apiUrl, accessToken, businessId, unifiedReportParams) {
|
|
|
38668
38740
|
});
|
|
38669
38741
|
}
|
|
38670
38742
|
}
|
|
38671
|
-
function useUnifiedReportDownload({ onSuccess }
|
|
38743
|
+
function useUnifiedReportDownload({ dateSelectionMode, onSuccess }) {
|
|
38672
38744
|
const { data: auth } = useAuth();
|
|
38673
38745
|
const { businessId } = useLayerContext();
|
|
38674
|
-
const reportWithDateParams = useUnifiedReportWithDateParams();
|
|
38746
|
+
const reportWithDateParams = useUnifiedReportWithDateParams({ dateSelectionMode });
|
|
38675
38747
|
const rawMutationResponse = useSWRMutation(
|
|
38676
38748
|
() => buildKey$a(__spreadProps(__spreadValues({}, auth), {
|
|
38677
38749
|
businessId,
|
|
@@ -38688,9 +38760,10 @@ function useUnifiedReportDownload({ onSuccess } = {}) {
|
|
|
38688
38760
|
);
|
|
38689
38761
|
return new DownloadUnifiedReportSWRResponse(rawMutationResponse);
|
|
38690
38762
|
}
|
|
38691
|
-
function UnifiedReportDownloadButton() {
|
|
38763
|
+
function UnifiedReportDownloadButton({ dateSelectionMode }) {
|
|
38692
38764
|
const { invisibleDownloadRef, triggerInvisibleDownload } = useInvisibleDownload();
|
|
38693
38765
|
const { trigger, isMutating, isError } = useUnifiedReportDownload({
|
|
38766
|
+
dateSelectionMode,
|
|
38694
38767
|
onSuccess: ({ presignedUrl }) => triggerInvisibleDownload({ url: presignedUrl })
|
|
38695
38768
|
});
|
|
38696
38769
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -38712,7 +38785,7 @@ function UnifiedReportDownloadButton() {
|
|
|
38712
38785
|
/* @__PURE__ */ jsx(InvisibleDownload, { ref: invisibleDownloadRef })
|
|
38713
38786
|
] });
|
|
38714
38787
|
}
|
|
38715
|
-
const UnifiedReportTableHeader = () => {
|
|
38788
|
+
const UnifiedReportTableHeader = ({ dateSelectionMode }) => {
|
|
38716
38789
|
const dateVariant = useUnifiedReportDateVariant();
|
|
38717
38790
|
const { expanded, setExpanded } = useContext(ExpandableDataTableContext);
|
|
38718
38791
|
const shouldCollapse = expanded === true;
|
|
@@ -38724,17 +38797,17 @@ const UnifiedReportTableHeader = () => {
|
|
|
38724
38797
|
}
|
|
38725
38798
|
}, [setExpanded, shouldCollapse]);
|
|
38726
38799
|
return /* @__PURE__ */ jsxs(HStack, { fluid: true, justify: "space-between", align: "center", className: "Layer__UnifiedReport__Header", children: [
|
|
38727
|
-
/* @__PURE__ */ jsx(HStack, { pi: "md", children: dateVariant === UnifiedReportDateVariant.DateRange ? /* @__PURE__ */ jsx(
|
|
38800
|
+
/* @__PURE__ */ jsx(HStack, { pi: "md", children: dateVariant === UnifiedReportDateVariant.DateRange ? /* @__PURE__ */ jsx(CombinedDateRangeSelection, { mode: dateSelectionMode }) : /* @__PURE__ */ jsx(CombinedDateSelection, { mode: dateSelectionMode }) }),
|
|
38728
38801
|
/* @__PURE__ */ jsxs(HStack, { pi: "md", className: "Layer__UnifiedReport__Header__SecondaryActions", children: [
|
|
38729
38802
|
/* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: onClickExpandOrCollapse, children: shouldCollapse ? "Collapse All" : "Expand All" }),
|
|
38730
|
-
/* @__PURE__ */ jsx(UnifiedReportDownloadButton, {})
|
|
38803
|
+
/* @__PURE__ */ jsx(UnifiedReportDownloadButton, { dateSelectionMode })
|
|
38731
38804
|
] })
|
|
38732
38805
|
] });
|
|
38733
38806
|
};
|
|
38734
|
-
const UnifiedReport = () => {
|
|
38807
|
+
const UnifiedReport = ({ dateSelectionMode }) => {
|
|
38735
38808
|
return /* @__PURE__ */ jsx(Container, { name: "UnifiedReport", children: /* @__PURE__ */ jsx(UnifiedReportStoreProvider, { children: /* @__PURE__ */ jsxs(ExpandableDataTableProvider, { children: [
|
|
38736
|
-
/* @__PURE__ */ jsx(UnifiedReportTableHeader, {}),
|
|
38737
|
-
/* @__PURE__ */ jsx(UnifiedReportTable, {})
|
|
38809
|
+
/* @__PURE__ */ jsx(UnifiedReportTableHeader, { dateSelectionMode }),
|
|
38810
|
+
/* @__PURE__ */ jsx(UnifiedReportTable, { dateSelectionMode })
|
|
38738
38811
|
] }) }) });
|
|
38739
38812
|
};
|
|
38740
38813
|
const AccountingOverview = ({
|
|
@@ -42477,80 +42550,59 @@ const TripsTableHeaderMenu = () => {
|
|
|
42477
42550
|
);
|
|
42478
42551
|
};
|
|
42479
42552
|
const COMPONENT_NAME = "TripsTable";
|
|
42480
|
-
const getColumnConfig = ({ onSelectTrip, onDeleteTrip }) =>
|
|
42481
|
-
|
|
42482
|
-
"TripDate"
|
|
42483
|
-
/* TripDate */
|
|
42484
|
-
]: {
|
|
42553
|
+
const getColumnConfig = ({ onSelectTrip, onDeleteTrip }) => [
|
|
42554
|
+
{
|
|
42485
42555
|
id: "TripDate",
|
|
42486
42556
|
header: "Date",
|
|
42487
|
-
cell: (row) => formatCalendarDate(row.tripDate)
|
|
42557
|
+
cell: (row) => formatCalendarDate(row.original.tripDate)
|
|
42488
42558
|
},
|
|
42489
|
-
|
|
42490
|
-
"Vehicle"
|
|
42491
|
-
/* Vehicle */
|
|
42492
|
-
]: {
|
|
42559
|
+
{
|
|
42493
42560
|
id: "Vehicle",
|
|
42494
42561
|
header: "Vehicle",
|
|
42495
|
-
cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, withTooltip: true, children: getVehicleDisplayName(row.vehicle) }),
|
|
42562
|
+
cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, withTooltip: true, children: getVehicleDisplayName(row.original.vehicle) }),
|
|
42496
42563
|
isRowHeader: true
|
|
42497
42564
|
},
|
|
42498
|
-
|
|
42499
|
-
"Distance"
|
|
42500
|
-
/* Distance */
|
|
42501
|
-
]: {
|
|
42565
|
+
{
|
|
42502
42566
|
id: "Distance",
|
|
42503
42567
|
header: "Distance",
|
|
42504
|
-
cell: (row) => /* @__PURE__ */ jsx(Span, { align: "right", children: formatDistance(row.distance) })
|
|
42568
|
+
cell: (row) => /* @__PURE__ */ jsx(Span, { align: "right", children: formatDistance(row.original.distance) })
|
|
42505
42569
|
},
|
|
42506
|
-
|
|
42507
|
-
"Purpose"
|
|
42508
|
-
/* Purpose */
|
|
42509
|
-
]: {
|
|
42570
|
+
{
|
|
42510
42571
|
id: "Purpose",
|
|
42511
42572
|
header: "Purpose",
|
|
42512
|
-
cell: (row) => getPurposeLabel(row.purpose)
|
|
42573
|
+
cell: (row) => getPurposeLabel(row.original.purpose)
|
|
42513
42574
|
},
|
|
42514
|
-
|
|
42515
|
-
"Address"
|
|
42516
|
-
/* Address */
|
|
42517
|
-
]: {
|
|
42575
|
+
{
|
|
42518
42576
|
id: "Address",
|
|
42519
42577
|
header: "Address",
|
|
42520
42578
|
cell: (row) => {
|
|
42521
42579
|
return /* @__PURE__ */ jsxs(VStack, { gap: "3xs", overflow: "auto", children: [
|
|
42522
|
-
row.startAddress && /* @__PURE__ */ jsxs(Span, { ellipsis: true, size: "sm", withTooltip: true, children: [
|
|
42580
|
+
row.original.startAddress && /* @__PURE__ */ jsxs(Span, { ellipsis: true, size: "sm", withTooltip: true, children: [
|
|
42523
42581
|
/* @__PURE__ */ jsx("strong", { children: "Start:" }),
|
|
42524
42582
|
" ",
|
|
42525
|
-
row.startAddress
|
|
42583
|
+
row.original.startAddress
|
|
42526
42584
|
] }),
|
|
42527
|
-
row.endAddress && /* @__PURE__ */ jsxs(Span, { ellipsis: true, size: "sm", withTooltip: true, children: [
|
|
42585
|
+
row.original.endAddress && /* @__PURE__ */ jsxs(Span, { ellipsis: true, size: "sm", withTooltip: true, children: [
|
|
42528
42586
|
/* @__PURE__ */ jsx("strong", { children: "End:" }),
|
|
42529
42587
|
" ",
|
|
42530
|
-
row.endAddress
|
|
42588
|
+
row.original.endAddress
|
|
42531
42589
|
] })
|
|
42532
42590
|
] });
|
|
42533
42591
|
}
|
|
42534
42592
|
},
|
|
42535
|
-
|
|
42536
|
-
"Description"
|
|
42537
|
-
/* Description */
|
|
42538
|
-
]: {
|
|
42593
|
+
{
|
|
42539
42594
|
id: "Description",
|
|
42540
42595
|
header: "Description",
|
|
42541
|
-
cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, withTooltip: true, children: row.description })
|
|
42596
|
+
cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, withTooltip: true, children: row.original.description })
|
|
42542
42597
|
},
|
|
42543
|
-
|
|
42544
|
-
"Actions"
|
|
42545
|
-
/* Actions */
|
|
42546
|
-
]: {
|
|
42598
|
+
{
|
|
42547
42599
|
id: "Actions",
|
|
42548
42600
|
cell: (row) => /* @__PURE__ */ jsxs(HStack, { gap: "3xs", children: [
|
|
42549
|
-
/* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onSelectTrip(row), "aria-label": "View trip", variant: "ghost", children: /* @__PURE__ */ jsx(Edit, { size: 20 }) }),
|
|
42550
|
-
/* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onDeleteTrip(row), "aria-label": "Delete trip", variant: "ghost", children: /* @__PURE__ */ jsx(Trash2, { size: 20 }) })
|
|
42601
|
+
/* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onSelectTrip(row.original), "aria-label": "View trip", variant: "ghost", children: /* @__PURE__ */ jsx(Edit, { size: 20 }) }),
|
|
42602
|
+
/* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onDeleteTrip(row.original), "aria-label": "Delete trip", variant: "ghost", children: /* @__PURE__ */ jsx(Trash2, { size: 20 }) })
|
|
42551
42603
|
] })
|
|
42552
42604
|
}
|
|
42553
|
-
|
|
42605
|
+
];
|
|
42554
42606
|
const TripsTable = () => {
|
|
42555
42607
|
var _a;
|
|
42556
42608
|
const [isTripDrawerOpen, setIsTripDrawerOpen] = useState(false);
|
|
@@ -44033,7 +44085,7 @@ const BusinessProvider = ({
|
|
|
44033
44085
|
hasBeenTouched,
|
|
44034
44086
|
resetCaches
|
|
44035
44087
|
} = useDataSync();
|
|
44036
|
-
const globalDateRange = useGlobalDateRange({
|
|
44088
|
+
const globalDateRange = useGlobalDateRange({ dateSelectionMode: "full" });
|
|
44037
44089
|
const { setDateRange } = useGlobalDateRangeActions();
|
|
44038
44090
|
const dateRange = useMemo(() => ({
|
|
44039
44091
|
range: globalDateRange,
|