@layerfi/components 0.1.106-alpha → 0.1.106-alpha.1
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 +1163 -402
- package/dist/esm/index.mjs +1193 -433
- package/dist/index.css +201 -96
- package/dist/index.d.ts +1503 -186
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -5603,7 +5603,7 @@ var import_react12 = require("react");
|
|
|
5603
5603
|
var import_react10 = require("react");
|
|
5604
5604
|
|
|
5605
5605
|
// package.json
|
|
5606
|
-
var version = "0.1.106-alpha";
|
|
5606
|
+
var version = "0.1.106-alpha.1";
|
|
5607
5607
|
|
|
5608
5608
|
// src/models/APIError.ts
|
|
5609
5609
|
var APIError = class _APIError extends Error {
|
|
@@ -7118,48 +7118,28 @@ var _RANGE_PICKER_MODES = [
|
|
|
7118
7118
|
var isDateRangePickerMode = (mode) => {
|
|
7119
7119
|
return _RANGE_PICKER_MODES.includes(mode);
|
|
7120
7120
|
};
|
|
7121
|
-
function startOfNextDay(date) {
|
|
7122
|
-
return (0, import_date_fns3.startOfDay)((0, import_date_fns3.addDays)(date, 1));
|
|
7123
|
-
}
|
|
7124
7121
|
function clampToPresentOrPast(date, cutoff = (0, import_date_fns3.endOfDay)(/* @__PURE__ */ new Date())) {
|
|
7125
7122
|
return (0, import_date_fns3.min)([date, cutoff]);
|
|
7126
7123
|
}
|
|
7127
|
-
function withShiftedEnd(fn) {
|
|
7128
|
-
return ({ currentStart, currentEnd, newEnd }) => {
|
|
7129
|
-
const shiftedCurrentEnd = startOfNextDay(currentEnd);
|
|
7130
|
-
const shiftedNewEnd = clampToPresentOrPast(startOfNextDay(newEnd), startOfNextDay(/* @__PURE__ */ new Date()));
|
|
7131
|
-
return fn({ currentStart, shiftedCurrentEnd, shiftedNewEnd });
|
|
7132
|
-
};
|
|
7133
|
-
}
|
|
7134
7124
|
var RANGE_MODE_LOOKUP = {
|
|
7125
|
+
dayPicker: {
|
|
7126
|
+
getStart: ({ start }) => start,
|
|
7127
|
+
getEnd: ({ end }) => clampToPresentOrPast((0, import_date_fns3.endOfDay)(end))
|
|
7128
|
+
},
|
|
7135
7129
|
dayRangePicker: {
|
|
7136
7130
|
getStart: ({ start }) => start,
|
|
7137
|
-
getShiftedStart: withShiftedEnd(({ currentStart, shiftedCurrentEnd, shiftedNewEnd }) => {
|
|
7138
|
-
const fullDayCount = (0, import_date_fns3.differenceInDays)(shiftedCurrentEnd, currentStart);
|
|
7139
|
-
return (0, import_date_fns3.subDays)(shiftedNewEnd, fullDayCount);
|
|
7140
|
-
}),
|
|
7141
7131
|
getEnd: ({ end }) => clampToPresentOrPast((0, import_date_fns3.endOfDay)(end))
|
|
7142
7132
|
},
|
|
7143
7133
|
monthPicker: {
|
|
7144
7134
|
getStart: ({ start }) => (0, import_date_fns3.startOfMonth)(start),
|
|
7145
|
-
getShiftedStart: withShiftedEnd(({ shiftedNewEnd }) => {
|
|
7146
|
-
return (0, import_date_fns3.subMonths)(shiftedNewEnd, 1);
|
|
7147
|
-
}),
|
|
7148
7135
|
getEnd: ({ end }) => clampToPresentOrPast((0, import_date_fns3.endOfMonth)(end))
|
|
7149
7136
|
},
|
|
7150
7137
|
monthRangePicker: {
|
|
7151
7138
|
getStart: ({ start }) => (0, import_date_fns3.startOfMonth)(start),
|
|
7152
|
-
getShiftedStart: withShiftedEnd(({ currentStart, shiftedCurrentEnd, shiftedNewEnd }) => {
|
|
7153
|
-
const fullMonthCount = (0, import_date_fns3.differenceInMonths)(shiftedCurrentEnd, currentStart);
|
|
7154
|
-
return (0, import_date_fns3.subMonths)(shiftedNewEnd, fullMonthCount);
|
|
7155
|
-
}),
|
|
7156
7139
|
getEnd: ({ end }) => clampToPresentOrPast((0, import_date_fns3.endOfMonth)(end))
|
|
7157
7140
|
},
|
|
7158
7141
|
yearPicker: {
|
|
7159
7142
|
getStart: ({ start }) => (0, import_date_fns3.startOfYear)(start),
|
|
7160
|
-
getShiftedStart: withShiftedEnd(({ shiftedNewEnd }) => {
|
|
7161
|
-
return (0, import_date_fns3.subYears)(shiftedNewEnd, 1);
|
|
7162
|
-
}),
|
|
7163
7143
|
getEnd: ({ end }) => clampToPresentOrPast((0, import_date_fns3.endOfYear)(end))
|
|
7164
7144
|
}
|
|
7165
7145
|
};
|
|
@@ -7175,6 +7155,12 @@ function withCorrectedRange(fn) {
|
|
|
7175
7155
|
function buildStore() {
|
|
7176
7156
|
const now = /* @__PURE__ */ new Date();
|
|
7177
7157
|
return (0, import_zustand.createStore)((set2) => {
|
|
7158
|
+
const setDate = ({ date }) => {
|
|
7159
|
+
set2({
|
|
7160
|
+
start: RANGE_MODE_LOOKUP.dayPicker.getStart({ start: date }),
|
|
7161
|
+
end: RANGE_MODE_LOOKUP.dayPicker.getEnd({ end: date })
|
|
7162
|
+
});
|
|
7163
|
+
};
|
|
7178
7164
|
const setDateRange = withCorrectedRange(({ start, end }) => {
|
|
7179
7165
|
set2({
|
|
7180
7166
|
start: RANGE_MODE_LOOKUP.dayRangePicker.getStart({ start }),
|
|
@@ -7202,9 +7188,12 @@ function buildStore() {
|
|
|
7202
7188
|
const setRangeWithExplicitDisplayMode = ({
|
|
7203
7189
|
start,
|
|
7204
7190
|
end,
|
|
7205
|
-
|
|
7191
|
+
displayMode
|
|
7206
7192
|
}) => {
|
|
7207
|
-
switch (
|
|
7193
|
+
switch (displayMode) {
|
|
7194
|
+
case "dayPicker":
|
|
7195
|
+
setDate({ date: end });
|
|
7196
|
+
break;
|
|
7208
7197
|
case "dayRangePicker":
|
|
7209
7198
|
setDateRange({ start, end });
|
|
7210
7199
|
break;
|
|
@@ -7219,8 +7208,8 @@ function buildStore() {
|
|
|
7219
7208
|
break;
|
|
7220
7209
|
default:
|
|
7221
7210
|
safeAssertUnreachable({
|
|
7222
|
-
value:
|
|
7223
|
-
message: "Invalid `
|
|
7211
|
+
value: displayMode,
|
|
7212
|
+
message: "Invalid `displayMode`"
|
|
7224
7213
|
});
|
|
7225
7214
|
}
|
|
7226
7215
|
};
|
|
@@ -7228,22 +7217,7 @@ function buildStore() {
|
|
|
7228
7217
|
start: (0, import_date_fns3.startOfMonth)(now),
|
|
7229
7218
|
end: clampToPresentOrPast((0, import_date_fns3.endOfMonth)(now)),
|
|
7230
7219
|
actions: {
|
|
7231
|
-
setDate
|
|
7232
|
-
set2(({
|
|
7233
|
-
start: currentStart,
|
|
7234
|
-
end: currentEnd
|
|
7235
|
-
}) => {
|
|
7236
|
-
const newEnd = RANGE_MODE_LOOKUP.dayRangePicker.getEnd({ end: date });
|
|
7237
|
-
return {
|
|
7238
|
-
start: RANGE_MODE_LOOKUP.dayRangePicker.getShiftedStart({
|
|
7239
|
-
currentStart,
|
|
7240
|
-
currentEnd,
|
|
7241
|
-
newEnd
|
|
7242
|
-
}),
|
|
7243
|
-
end: newEnd
|
|
7244
|
-
};
|
|
7245
|
-
});
|
|
7246
|
-
},
|
|
7220
|
+
setDate,
|
|
7247
7221
|
setRangeWithExplicitDisplayMode,
|
|
7248
7222
|
setDateRange,
|
|
7249
7223
|
setMonth,
|
|
@@ -12307,8 +12281,7 @@ var LinkedAccountsContent = ({
|
|
|
12307
12281
|
asWidget,
|
|
12308
12282
|
showLedgerBalance,
|
|
12309
12283
|
showUnlinkItem,
|
|
12310
|
-
showBreakConnection
|
|
12311
|
-
showAddAccount
|
|
12284
|
+
showBreakConnection
|
|
12312
12285
|
}) => {
|
|
12313
12286
|
const { data, addConnection } = (0, import_react48.useContext)(LinkedAccountsContext);
|
|
12314
12287
|
const linkedAccountsNewAccountClassName = (0, import_classnames25.default)(
|
|
@@ -12331,7 +12304,7 @@ var LinkedAccountsContent = ({
|
|
|
12331
12304
|
},
|
|
12332
12305
|
index
|
|
12333
12306
|
)),
|
|
12334
|
-
|
|
12307
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
|
|
12335
12308
|
"div",
|
|
12336
12309
|
{
|
|
12337
12310
|
role: "button",
|
|
@@ -12892,6 +12865,25 @@ var highlightNextArrow = ({
|
|
|
12892
12865
|
}
|
|
12893
12866
|
return false;
|
|
12894
12867
|
};
|
|
12868
|
+
var getDateFormat = (mode) => {
|
|
12869
|
+
switch (mode) {
|
|
12870
|
+
case "dayPicker":
|
|
12871
|
+
case "dayRangePicker":
|
|
12872
|
+
return "MMM d, yyyy";
|
|
12873
|
+
case "monthPicker":
|
|
12874
|
+
case "monthRangePicker":
|
|
12875
|
+
return "MMM yyyy";
|
|
12876
|
+
case "yearPicker":
|
|
12877
|
+
return "yyyy";
|
|
12878
|
+
case "timePicker":
|
|
12879
|
+
return "h:mm aa";
|
|
12880
|
+
default:
|
|
12881
|
+
unsafeAssertUnreachable({
|
|
12882
|
+
value: mode,
|
|
12883
|
+
message: "Invalid datepicker mode"
|
|
12884
|
+
});
|
|
12885
|
+
}
|
|
12886
|
+
};
|
|
12895
12887
|
var DatePicker = (_a) => {
|
|
12896
12888
|
var _b = _a, {
|
|
12897
12889
|
selected,
|
|
@@ -12899,7 +12891,7 @@ var DatePicker = (_a) => {
|
|
|
12899
12891
|
disabled,
|
|
12900
12892
|
displayMode = "dayPicker",
|
|
12901
12893
|
allowedModes,
|
|
12902
|
-
dateFormat = displayMode
|
|
12894
|
+
dateFormat = getDateFormat(displayMode),
|
|
12903
12895
|
timeIntervals = 15,
|
|
12904
12896
|
timeCaption,
|
|
12905
12897
|
placeholderText: _placeholderText,
|
|
@@ -13623,11 +13615,10 @@ var LinkedAccounts = (props) => {
|
|
|
13623
13615
|
};
|
|
13624
13616
|
var LinkedAccountsComponent = ({
|
|
13625
13617
|
asWidget,
|
|
13626
|
-
elevated,
|
|
13618
|
+
elevated = false,
|
|
13627
13619
|
showLedgerBalance = true,
|
|
13628
13620
|
showUnlinkItem = false,
|
|
13629
13621
|
showBreakConnection = false,
|
|
13630
|
-
showAddAccount = true,
|
|
13631
13622
|
stringOverrides
|
|
13632
13623
|
}) => {
|
|
13633
13624
|
const {
|
|
@@ -13662,8 +13653,7 @@ var LinkedAccountsComponent = ({
|
|
|
13662
13653
|
asWidget,
|
|
13663
13654
|
showLedgerBalance,
|
|
13664
13655
|
showUnlinkItem,
|
|
13665
|
-
showBreakConnection
|
|
13666
|
-
showAddAccount
|
|
13656
|
+
showBreakConnection
|
|
13667
13657
|
}
|
|
13668
13658
|
) : null,
|
|
13669
13659
|
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(OpeningBalanceModal, {})
|
|
@@ -16455,6 +16445,7 @@ function buildCustomPlaceholder({ placeholder }) {
|
|
|
16455
16445
|
} = _b, restProps = __objRest(_b, [
|
|
16456
16446
|
"children"
|
|
16457
16447
|
]);
|
|
16448
|
+
if (!placeholder) return null;
|
|
16458
16449
|
return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
|
|
16459
16450
|
import_react_select4.components.Placeholder,
|
|
16460
16451
|
__spreadProps(__spreadValues({}, restProps), {
|
|
@@ -21562,7 +21553,7 @@ var HEADER_HEIGHT = 41;
|
|
|
21562
21553
|
var CONTAINER_HEIGHT = ROW_HEIGHT * MAX_NUM_ROWS + HEADER_HEIGHT - 1;
|
|
21563
21554
|
var CSS_PREFIX = "Layer__csv-upload__validate-csv-table";
|
|
21564
21555
|
function ValidateCsvTable({ data, headers, formatters: formatters2, className }) {
|
|
21565
|
-
const
|
|
21556
|
+
const columns = (0, import_react107.useMemo)(
|
|
21566
21557
|
() => {
|
|
21567
21558
|
const columnDefs = [{
|
|
21568
21559
|
id: "row",
|
|
@@ -21616,7 +21607,7 @@ function ValidateCsvTable({ data, headers, formatters: formatters2, className })
|
|
|
21616
21607
|
}), []);
|
|
21617
21608
|
const table = (0, import_react_table.useReactTable)({
|
|
21618
21609
|
data,
|
|
21619
|
-
columns
|
|
21610
|
+
columns,
|
|
21620
21611
|
state,
|
|
21621
21612
|
getCoreRowModel: (0, import_react_table.getCoreRowModel)(),
|
|
21622
21613
|
getSortedRowModel: (0, import_react_table.getSortedRowModel)()
|
|
@@ -22875,12 +22866,11 @@ var Integrations = (props) => {
|
|
|
22875
22866
|
return /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(QuickbooksContextProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime190.jsx)(IntegrationsComponent, __spreadValues({}, props)) });
|
|
22876
22867
|
};
|
|
22877
22868
|
var IntegrationsComponent = ({
|
|
22878
|
-
elevated,
|
|
22879
22869
|
stringOverrides
|
|
22880
22870
|
}) => {
|
|
22881
22871
|
const { quickbooksConnectionStatus } = (0, import_react123.useContext)(QuickbooksContext);
|
|
22882
22872
|
const isLoading = quickbooksConnectionStatus === void 0;
|
|
22883
|
-
return /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(Container, { name: COMPONENT_NAME3,
|
|
22873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(Container, { name: COMPONENT_NAME3, children: [
|
|
22884
22874
|
/* @__PURE__ */ (0, import_jsx_runtime190.jsxs)(Header, { className: "Layer__linked-accounts__header", children: [
|
|
22885
22875
|
/* @__PURE__ */ (0, import_jsx_runtime190.jsx)(
|
|
22886
22876
|
Heading,
|
|
@@ -23212,6 +23202,7 @@ var defaultModeByReport = {
|
|
|
23212
23202
|
};
|
|
23213
23203
|
var ReportsModeStoreContext = (0, import_react127.createContext)(
|
|
23214
23204
|
(0, import_zustand3.createStore)(() => ({
|
|
23205
|
+
resetPnLModeToDefaultOnMount: true,
|
|
23215
23206
|
modeByReport: {},
|
|
23216
23207
|
actions: {
|
|
23217
23208
|
setModeForReport: () => {
|
|
@@ -23219,6 +23210,10 @@ var ReportsModeStoreContext = (0, import_react127.createContext)(
|
|
|
23219
23210
|
}
|
|
23220
23211
|
}))
|
|
23221
23212
|
);
|
|
23213
|
+
function useReportModeStore() {
|
|
23214
|
+
const store = (0, import_react127.useContext)(ReportsModeStoreContext);
|
|
23215
|
+
return (0, import_zustand3.useStore)(store);
|
|
23216
|
+
}
|
|
23222
23217
|
function useReportMode(report) {
|
|
23223
23218
|
const store = (0, import_react127.useContext)(ReportsModeStoreContext);
|
|
23224
23219
|
return (0, import_zustand3.useStore)(store, (state) => state.modeByReport[report]);
|
|
@@ -23234,11 +23229,13 @@ function useReportModeWithFallback(report, fallback) {
|
|
|
23234
23229
|
}
|
|
23235
23230
|
function ReportsModeStoreProvider({
|
|
23236
23231
|
children,
|
|
23237
|
-
initialModes
|
|
23232
|
+
initialModes,
|
|
23233
|
+
resetPnLModeToDefaultOnMount = true
|
|
23238
23234
|
}) {
|
|
23239
23235
|
const [store] = (0, import_react127.useState)(
|
|
23240
23236
|
() => (0, import_zustand3.createStore)((set2) => ({
|
|
23241
23237
|
modeByReport: __spreadValues(__spreadValues({}, defaultModeByReport), initialModes),
|
|
23238
|
+
resetPnLModeToDefaultOnMount,
|
|
23242
23239
|
actions: {
|
|
23243
23240
|
setModeForReport: (report, mode) => set2((state) => ({
|
|
23244
23241
|
modeByReport: __spreadProps(__spreadValues({}, state.modeByReport), {
|
|
@@ -24633,21 +24630,11 @@ function useGlobalDateRangePicker({ displayMode, setDisplayMode }) {
|
|
|
24633
24630
|
setDisplayMode(newMode);
|
|
24634
24631
|
}
|
|
24635
24632
|
}, [setDisplayMode]);
|
|
24636
|
-
const
|
|
24633
|
+
const dateOrDateRange = (0, import_react132.useMemo)(() => {
|
|
24637
24634
|
if (displayMode === "monthPicker") {
|
|
24638
|
-
return
|
|
24639
|
-
dateOrDateRange: start,
|
|
24640
|
-
dateFormat: void 0
|
|
24641
|
-
};
|
|
24635
|
+
return start;
|
|
24642
24636
|
}
|
|
24643
|
-
return
|
|
24644
|
-
/*
|
|
24645
|
-
* This intentionally needs to be cast to a mutable array. The `DatePicker`
|
|
24646
|
-
* component should accept a readonly array, but that refactor is out of scope.
|
|
24647
|
-
*/
|
|
24648
|
-
dateOrDateRange: [start, end],
|
|
24649
|
-
dateFormat: "MMM d"
|
|
24650
|
-
};
|
|
24637
|
+
return [start, end];
|
|
24651
24638
|
}, [
|
|
24652
24639
|
start,
|
|
24653
24640
|
end,
|
|
@@ -24656,10 +24643,9 @@ function useGlobalDateRangePicker({ displayMode, setDisplayMode }) {
|
|
|
24656
24643
|
const onChangeDateOrDateRange = (0, import_react132.useCallback)((dates) => {
|
|
24657
24644
|
var _a;
|
|
24658
24645
|
const dateProps = dates instanceof Date ? { start: dates, end: dates } : { start: dates[0], end: (_a = dates[1]) != null ? _a : dates[0] };
|
|
24659
|
-
setRangeWithExplicitDisplayMode(__spreadProps(__spreadValues({}, dateProps), {
|
|
24646
|
+
setRangeWithExplicitDisplayMode(__spreadProps(__spreadValues({}, dateProps), { displayMode }));
|
|
24660
24647
|
}, [displayMode, setRangeWithExplicitDisplayMode]);
|
|
24661
24648
|
return {
|
|
24662
|
-
dateFormat,
|
|
24663
24649
|
rangeDisplayMode: displayMode,
|
|
24664
24650
|
onChangeMode,
|
|
24665
24651
|
dateOrDateRange,
|
|
@@ -24677,24 +24663,24 @@ var ProfitAndLossDatePicker = ({
|
|
|
24677
24663
|
const isMounted = (0, import_react133.useRef)(false);
|
|
24678
24664
|
const { business } = useLayerContext();
|
|
24679
24665
|
const displayMode = useReportModeWithFallback("ProfitAndLoss" /* ProfitAndLoss */, "monthPicker");
|
|
24666
|
+
const { resetPnLModeToDefaultOnMount } = useReportModeStore();
|
|
24680
24667
|
const { setModeForReport } = useReportModeActions();
|
|
24681
24668
|
const setDisplayMode = (0, import_react133.useCallback)((mode) => {
|
|
24682
24669
|
setModeForReport("ProfitAndLoss" /* ProfitAndLoss */, mode);
|
|
24683
24670
|
}, [setModeForReport]);
|
|
24684
24671
|
(0, import_react133.useEffect)(() => {
|
|
24685
24672
|
const initialDatePickerMode = getInitialDateRangePickerMode({ allowedDatePickerModes, defaultDatePickerMode });
|
|
24686
|
-
if (!isMounted.current && displayMode !== initialDatePickerMode) {
|
|
24673
|
+
if (!isMounted.current && resetPnLModeToDefaultOnMount && displayMode !== initialDatePickerMode) {
|
|
24687
24674
|
setDisplayMode(initialDatePickerMode);
|
|
24688
24675
|
}
|
|
24689
24676
|
isMounted.current = true;
|
|
24690
|
-
}, [allowedDatePickerModes, defaultDatePickerMode, displayMode, setDisplayMode]);
|
|
24677
|
+
}, [resetPnLModeToDefaultOnMount, allowedDatePickerModes, defaultDatePickerMode, displayMode, setDisplayMode]);
|
|
24691
24678
|
const cleanedAllowedModes = getAllowedDateRangePickerModes({ allowedDatePickerModes, defaultDatePickerMode });
|
|
24692
24679
|
const {
|
|
24693
24680
|
rangeDisplayMode,
|
|
24694
24681
|
onChangeMode,
|
|
24695
24682
|
dateOrDateRange,
|
|
24696
|
-
onChangeDateOrDateRange
|
|
24697
|
-
dateFormat
|
|
24683
|
+
onChangeDateOrDateRange
|
|
24698
24684
|
} = useGlobalDateRangePicker({ displayMode, setDisplayMode });
|
|
24699
24685
|
const minDate = getEarliestDateToBrowse(business);
|
|
24700
24686
|
return /* @__PURE__ */ (0, import_jsx_runtime198.jsx)(
|
|
@@ -24708,7 +24694,6 @@ var ProfitAndLossDatePicker = ({
|
|
|
24708
24694
|
slots: {
|
|
24709
24695
|
ModeSelector: DatePickerModeSelector
|
|
24710
24696
|
},
|
|
24711
|
-
dateFormat,
|
|
24712
24697
|
customDateRanges,
|
|
24713
24698
|
minDate
|
|
24714
24699
|
}
|
|
@@ -27450,7 +27435,6 @@ function StatementOfCashFlowDatePicker({
|
|
|
27450
27435
|
setModeForReport("StatementOfCashFlows" /* StatementOfCashFlows */, mode);
|
|
27451
27436
|
}, [setModeForReport]);
|
|
27452
27437
|
const {
|
|
27453
|
-
dateFormat,
|
|
27454
27438
|
rangeDisplayMode,
|
|
27455
27439
|
onChangeMode,
|
|
27456
27440
|
dateOrDateRange,
|
|
@@ -27469,7 +27453,6 @@ function StatementOfCashFlowDatePicker({
|
|
|
27469
27453
|
slots: {
|
|
27470
27454
|
ModeSelector: DatePickerModeSelector
|
|
27471
27455
|
},
|
|
27472
|
-
dateFormat,
|
|
27473
27456
|
customDateRanges,
|
|
27474
27457
|
minDate
|
|
27475
27458
|
}
|
|
@@ -29510,7 +29493,7 @@ var DetailsListItem = ({
|
|
|
29510
29493
|
}) => {
|
|
29511
29494
|
return /* @__PURE__ */ (0, import_jsx_runtime250.jsxs)("li", { className: "Layer__details-list-item", children: [
|
|
29512
29495
|
/* @__PURE__ */ (0, import_jsx_runtime250.jsx)("label", { className: "Layer__details-list-item__label", children: label }),
|
|
29513
|
-
/* @__PURE__ */ (0, import_jsx_runtime250.jsx)("
|
|
29496
|
+
/* @__PURE__ */ (0, import_jsx_runtime250.jsx)("div", { className: "Layer__details-list-item__value", children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(SkeletonLoader, {}) : renderValue(children) })
|
|
29514
29497
|
] });
|
|
29515
29498
|
};
|
|
29516
29499
|
|
|
@@ -30630,7 +30613,10 @@ var JournalEntryDetails = () => {
|
|
|
30630
30613
|
/* @__PURE__ */ (0, import_jsx_runtime255.jsxs)(
|
|
30631
30614
|
DetailsList,
|
|
30632
30615
|
{
|
|
30633
|
-
title:
|
|
30616
|
+
title: /* @__PURE__ */ (0, import_jsx_runtime255.jsxs)(VStack, { children: [
|
|
30617
|
+
/* @__PURE__ */ (0, import_jsx_runtime255.jsx)(Span, { children: "Journal Entry" }),
|
|
30618
|
+
entry && /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(Span, { variant: "subtle", size: "xs", children: `Journal ID #${entryNumber(entry)}` })
|
|
30619
|
+
] }),
|
|
30634
30620
|
className: "Layer__border-top",
|
|
30635
30621
|
children: [
|
|
30636
30622
|
/* @__PURE__ */ (0, import_jsx_runtime255.jsx)(DetailsListItem, { label: "Entry type", isLoading: isLoadingEntry, children: humanizeEnum((_c = entry == null ? void 0 : entry.entry_type) != null ? _c : "") }),
|
|
@@ -34444,7 +34430,6 @@ var BookkeepingOverview = ({
|
|
|
34444
34430
|
{
|
|
34445
34431
|
name: "bookkeeping-overview-profit-and-loss",
|
|
34446
34432
|
asWidget: true,
|
|
34447
|
-
elevated: true,
|
|
34448
34433
|
style: {
|
|
34449
34434
|
position: "relative",
|
|
34450
34435
|
zIndex: 2
|
|
@@ -34582,7 +34567,6 @@ var AccountingOverview = ({
|
|
|
34582
34567
|
{
|
|
34583
34568
|
name: "accounting-overview-profit-and-loss",
|
|
34584
34569
|
asWidget: true,
|
|
34585
|
-
elevated: true,
|
|
34586
34570
|
children: [
|
|
34587
34571
|
/* @__PURE__ */ (0, import_jsx_runtime302.jsx)(
|
|
34588
34572
|
ProfitAndLoss.Header,
|
|
@@ -34669,7 +34653,7 @@ var BankTransactionsWithLinkedAccounts = ({
|
|
|
34669
34653
|
title,
|
|
34670
34654
|
// deprecated
|
|
34671
34655
|
showTitle = true,
|
|
34672
|
-
elevatedLinkedAccounts =
|
|
34656
|
+
elevatedLinkedAccounts = false,
|
|
34673
34657
|
mode,
|
|
34674
34658
|
showBreakConnection = false,
|
|
34675
34659
|
showCustomerVendor = false,
|
|
@@ -34680,7 +34664,6 @@ var BankTransactionsWithLinkedAccounts = ({
|
|
|
34680
34664
|
showTooltips = false,
|
|
34681
34665
|
showUnlinkItem = false,
|
|
34682
34666
|
showUploadOptions = false,
|
|
34683
|
-
showAddAccount = true,
|
|
34684
34667
|
mobileComponent,
|
|
34685
34668
|
stringOverrides
|
|
34686
34669
|
}) => {
|
|
@@ -34697,7 +34680,6 @@ var BankTransactionsWithLinkedAccounts = ({
|
|
|
34697
34680
|
showLedgerBalance,
|
|
34698
34681
|
showUnlinkItem,
|
|
34699
34682
|
showBreakConnection,
|
|
34700
|
-
showAddAccount,
|
|
34701
34683
|
stringOverrides: stringOverrides == null ? void 0 : stringOverrides.linkedAccounts
|
|
34702
34684
|
}
|
|
34703
34685
|
),
|
|
@@ -37052,7 +37034,7 @@ var Reports = ({
|
|
|
37052
37034
|
onChange: (opt) => setActiveTab(opt.target.value)
|
|
37053
37035
|
}
|
|
37054
37036
|
) }),
|
|
37055
|
-
/* @__PURE__ */ (0, import_jsx_runtime325.jsx)(Container, { name: "reports", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(ReportsModeStoreProvider, { initialModes, children: /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(ProfitAndLoss, { asContainer: false, comparisonConfig, withReportsModeProvider: false, children: /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(
|
|
37037
|
+
/* @__PURE__ */ (0, import_jsx_runtime325.jsx)(Container, { name: "reports", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(ReportsModeStoreProvider, { initialModes, resetPnLModeToDefaultOnMount: false, children: /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(ProfitAndLoss, { asContainer: false, comparisonConfig, withReportsModeProvider: false, children: /* @__PURE__ */ (0, import_jsx_runtime325.jsx)(
|
|
37056
37038
|
ReportsPanel,
|
|
37057
37039
|
{
|
|
37058
37040
|
openReport: activeTab,
|
|
@@ -37188,31 +37170,339 @@ var Components = ({
|
|
|
37188
37170
|
] });
|
|
37189
37171
|
};
|
|
37190
37172
|
|
|
37191
|
-
// src/components/Invoices/
|
|
37192
|
-
var
|
|
37173
|
+
// src/components/Invoices/Invoices.tsx
|
|
37174
|
+
var import_react237 = require("react");
|
|
37193
37175
|
|
|
37194
|
-
// src/
|
|
37195
|
-
var
|
|
37176
|
+
// src/components/Invoices/InvoiceDetail/InvoiceDetail.tsx
|
|
37177
|
+
var import_react231 = require("react");
|
|
37178
|
+
|
|
37179
|
+
// src/components/BaseDetailView/BaseDetailView.tsx
|
|
37180
|
+
var import_jsx_runtime327 = require("react/jsx-runtime");
|
|
37181
|
+
var BaseDetailView = ({ name, onGoBack, slots, children }) => {
|
|
37182
|
+
const { Header: Header6 } = slots;
|
|
37183
|
+
return /* @__PURE__ */ (0, import_jsx_runtime327.jsxs)(Container, { name, className: "Layer__BaseDetailView", children: [
|
|
37184
|
+
/* @__PURE__ */ (0, import_jsx_runtime327.jsxs)(HStack, { align: "center", gap: "md", className: "Layer__BaseDetailView__Header", children: [
|
|
37185
|
+
/* @__PURE__ */ (0, import_jsx_runtime327.jsx)(Button2, { variant: "outlined", icon: true, onPress: onGoBack, children: /* @__PURE__ */ (0, import_jsx_runtime327.jsx)(BackArrow_default, {}) }),
|
|
37186
|
+
/* @__PURE__ */ (0, import_jsx_runtime327.jsx)(Header6, {})
|
|
37187
|
+
] }),
|
|
37188
|
+
children
|
|
37189
|
+
] });
|
|
37190
|
+
};
|
|
37191
|
+
|
|
37192
|
+
// src/components/Invoices/InvoiceForm/useInvoiceForm.ts
|
|
37193
|
+
var import_react229 = require("react");
|
|
37194
|
+
var import_react_form7 = require("@tanstack/react-form");
|
|
37195
|
+
|
|
37196
|
+
// src/features/forms/hooks/useForm.tsx
|
|
37197
|
+
var import_react_form6 = require("@tanstack/react-form");
|
|
37198
|
+
|
|
37199
|
+
// src/components/ui/Form/Form.tsx
|
|
37196
37200
|
var import_react220 = require("react");
|
|
37197
|
-
var
|
|
37198
|
-
var
|
|
37201
|
+
var import_react_aria_components14 = require("react-aria-components");
|
|
37202
|
+
var import_classnames88 = __toESM(require("classnames"));
|
|
37203
|
+
var import_jsx_runtime328 = require("react/jsx-runtime");
|
|
37204
|
+
var FORM_CLASS_NAME = "Layer__UI__Form";
|
|
37205
|
+
var Form = (0, import_react220.forwardRef)(
|
|
37206
|
+
function Form2(_a, ref) {
|
|
37207
|
+
var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
|
|
37208
|
+
return /* @__PURE__ */ (0, import_jsx_runtime328.jsx)(import_react_aria_components14.Form, __spreadProps(__spreadValues({}, restProps), { className: (0, import_classnames88.default)(FORM_CLASS_NAME, className), ref, children }));
|
|
37209
|
+
}
|
|
37210
|
+
);
|
|
37211
|
+
var TEXT_FIELD_CLASS_NAME = "Layer__UI__TextField";
|
|
37212
|
+
var TextField = (0, import_react220.forwardRef)(
|
|
37213
|
+
function TextField2(_a, ref) {
|
|
37214
|
+
var _b = _a, { children, inline, textarea, className } = _b, restProps = __objRest(_b, ["children", "inline", "textarea", "className"]);
|
|
37215
|
+
const dataProperties = toDataProperties({ inline, textarea });
|
|
37216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime328.jsx)(import_react_aria_components14.TextField, __spreadProps(__spreadValues(__spreadValues({}, restProps), dataProperties), { className: (0, import_classnames88.default)(TEXT_FIELD_CLASS_NAME, className), ref, children: withRenderProp(children, (node) => node) }));
|
|
37217
|
+
}
|
|
37218
|
+
);
|
|
37219
|
+
var FIELD_ERROR_CLASS_NAME = "Layer__UI__FieldError";
|
|
37220
|
+
var FieldError = (0, import_react220.forwardRef)(
|
|
37221
|
+
function FieldError2({ children }, ref) {
|
|
37222
|
+
return /* @__PURE__ */ (0, import_jsx_runtime328.jsx)(import_react_aria_components14.FieldError, { className: FIELD_ERROR_CLASS_NAME, ref, children: withRenderProp(children, (node) => node) });
|
|
37223
|
+
}
|
|
37224
|
+
);
|
|
37199
37225
|
|
|
37200
|
-
// src/
|
|
37226
|
+
// src/features/forms/components/BaseFormTextField.tsx
|
|
37227
|
+
var import_jsx_runtime329 = require("react/jsx-runtime");
|
|
37228
|
+
function BaseFormTextField({
|
|
37229
|
+
label,
|
|
37230
|
+
className,
|
|
37231
|
+
inline = false,
|
|
37232
|
+
showLabel = true,
|
|
37233
|
+
showFieldError = true,
|
|
37234
|
+
isTextArea = false,
|
|
37235
|
+
children
|
|
37236
|
+
}) {
|
|
37237
|
+
const field = useFieldContext();
|
|
37238
|
+
const { name, state } = field;
|
|
37239
|
+
const { meta } = state;
|
|
37240
|
+
const { errors, isValid: isValid2 } = meta;
|
|
37241
|
+
const errorMessage = errors.length !== 0 ? errors[0] : void 0;
|
|
37242
|
+
const shouldShowErrorMessage = showFieldError && errorMessage;
|
|
37243
|
+
const additionalAriaProps = !showLabel && { "aria-label": label };
|
|
37244
|
+
return /* @__PURE__ */ (0, import_jsx_runtime329.jsxs)(TextField, __spreadProps(__spreadValues({ name, isInvalid: !isValid2, inline, className, textarea: isTextArea }, additionalAriaProps), { children: [
|
|
37245
|
+
showLabel && /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(Label, __spreadProps(__spreadValues({ size: "sm", htmlFor: name }, !inline && { pbe: "3xs" }), { children: label })),
|
|
37246
|
+
children,
|
|
37247
|
+
shouldShowErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(FieldError, { children: errorMessage })
|
|
37248
|
+
] }));
|
|
37249
|
+
}
|
|
37250
|
+
|
|
37251
|
+
// src/features/forms/components/FormBigDecimalField.tsx
|
|
37252
|
+
var import_react223 = require("react");
|
|
37253
|
+
|
|
37254
|
+
// src/components/ui/Input/InputGroup.tsx
|
|
37255
|
+
var import_react221 = require("react");
|
|
37256
|
+
var import_react_aria_components15 = require("react-aria-components");
|
|
37257
|
+
var import_jsx_runtime330 = require("react/jsx-runtime");
|
|
37258
|
+
var INPUT_GROUP_CLASS_NAME = "Layer__InputGroup";
|
|
37259
|
+
var InputGroup2 = (0, import_react221.forwardRef)(
|
|
37260
|
+
function InputGroup3(_a, ref) {
|
|
37261
|
+
var _b = _a, { actionCount } = _b, restProps = __objRest(_b, ["actionCount"]);
|
|
37262
|
+
const dataProperties = toDataProperties({ "action-count": actionCount });
|
|
37263
|
+
return /* @__PURE__ */ (0, import_jsx_runtime330.jsx)(
|
|
37264
|
+
import_react_aria_components15.Group,
|
|
37265
|
+
__spreadProps(__spreadValues(__spreadValues({}, restProps), dataProperties), {
|
|
37266
|
+
className: INPUT_GROUP_CLASS_NAME,
|
|
37267
|
+
ref
|
|
37268
|
+
})
|
|
37269
|
+
);
|
|
37270
|
+
}
|
|
37271
|
+
);
|
|
37272
|
+
|
|
37273
|
+
// src/features/forms/components/FormBigDecimalField.tsx
|
|
37274
|
+
var import_effect10 = require("effect");
|
|
37275
|
+
|
|
37276
|
+
// src/components/ui/Input/Input.tsx
|
|
37277
|
+
var import_react222 = require("react");
|
|
37278
|
+
var import_react_aria_components16 = require("react-aria-components");
|
|
37279
|
+
var import_jsx_runtime331 = require("react/jsx-runtime");
|
|
37280
|
+
var INPUT_CLASS_NAME = "Layer__UI__Input";
|
|
37281
|
+
var Input2 = (0, import_react222.forwardRef)(
|
|
37282
|
+
function Input3(_a, ref) {
|
|
37283
|
+
var _b = _a, { inset, placement } = _b, restProps = __objRest(_b, ["inset", "placement"]);
|
|
37284
|
+
const dataProperties = toDataProperties({ inset, placement });
|
|
37285
|
+
return /* @__PURE__ */ (0, import_jsx_runtime331.jsx)(
|
|
37286
|
+
import_react_aria_components16.Input,
|
|
37287
|
+
__spreadProps(__spreadValues(__spreadValues({}, restProps), dataProperties), {
|
|
37288
|
+
className: INPUT_CLASS_NAME,
|
|
37289
|
+
ref
|
|
37290
|
+
})
|
|
37291
|
+
);
|
|
37292
|
+
}
|
|
37293
|
+
);
|
|
37294
|
+
|
|
37295
|
+
// src/utils/bigDecimalUtils.ts
|
|
37201
37296
|
var import_effect9 = require("effect");
|
|
37202
|
-
var
|
|
37203
|
-
|
|
37204
|
-
|
|
37205
|
-
|
|
37206
|
-
|
|
37207
|
-
|
|
37208
|
-
|
|
37209
|
-
|
|
37210
|
-
|
|
37211
|
-
|
|
37297
|
+
var BIG_DECIMAL_ZERO = import_effect9.BigDecimal.fromBigInt(BigInt(0));
|
|
37298
|
+
var BIG_DECIMAL_ONE = import_effect9.BigDecimal.fromBigInt(BigInt(1));
|
|
37299
|
+
var BIG_DECIMAL_ONE_HUNDRED = import_effect9.BigDecimal.fromBigInt(BigInt(100));
|
|
37300
|
+
var DECIMAL_CHARS_REGEX = /^[\d.,-]+$/;
|
|
37301
|
+
var NON_NEGATIVE_DECIMAL_CHARS_REGEX = /^[\d.,]+$/;
|
|
37302
|
+
var convertBigDecimalToCents = (amount) => {
|
|
37303
|
+
const scaled = import_effect9.BigDecimal.multiply(amount, BIG_DECIMAL_ONE_HUNDRED);
|
|
37304
|
+
const rounded = import_effect9.BigDecimal.round(scaled, { scale: 0 });
|
|
37305
|
+
return Number(rounded.value);
|
|
37306
|
+
};
|
|
37307
|
+
var convertCentsToBigDecimal = (cents) => {
|
|
37308
|
+
const decimalCents = import_effect9.BigDecimal.fromBigInt(BigInt(cents));
|
|
37309
|
+
return import_effect9.BigDecimal.unsafeDivide(decimalCents, BIG_DECIMAL_ONE_HUNDRED);
|
|
37310
|
+
};
|
|
37311
|
+
function formatBigDecimalToString(value, maxDecimalPlaces = 10) {
|
|
37312
|
+
const normalizedBigDecimal = import_effect9.BigDecimal.normalize(value);
|
|
37313
|
+
const formatter2 = new Intl.NumberFormat(
|
|
37314
|
+
"en-US",
|
|
37315
|
+
{
|
|
37316
|
+
minimumFractionDigits: 0,
|
|
37317
|
+
maximumFractionDigits: maxDecimalPlaces
|
|
37318
|
+
}
|
|
37319
|
+
);
|
|
37320
|
+
let decimalAsNumber = 0;
|
|
37321
|
+
try {
|
|
37322
|
+
decimalAsNumber = import_effect9.BigDecimal.unsafeToNumber(normalizedBigDecimal);
|
|
37323
|
+
} catch (e) {
|
|
37324
|
+
}
|
|
37325
|
+
return formatter2.format(decimalAsNumber);
|
|
37326
|
+
}
|
|
37327
|
+
|
|
37328
|
+
// src/features/forms/components/FormBigDecimalField.tsx
|
|
37329
|
+
var import_jsx_runtime332 = require("react/jsx-runtime");
|
|
37330
|
+
var DEFAULT_MAX_INPUT_LENGTH = 10;
|
|
37331
|
+
function FormBigDecimalField({
|
|
37332
|
+
slotProps,
|
|
37333
|
+
maxInputLength = DEFAULT_MAX_INPUT_LENGTH,
|
|
37334
|
+
allowNegative = false
|
|
37335
|
+
}) {
|
|
37336
|
+
const field = useFieldContext();
|
|
37337
|
+
const { name, state, handleChange, handleBlur } = field;
|
|
37338
|
+
const { value } = state;
|
|
37339
|
+
const [inputValue, setInputValue] = (0, import_react223.useState)(formatBigDecimalToString(value, maxInputLength));
|
|
37340
|
+
const onInputChange = (0, import_react223.useCallback)((e) => {
|
|
37341
|
+
setInputValue(e.target.value);
|
|
37342
|
+
}, []);
|
|
37343
|
+
const onInputBlur = (0, import_react223.useCallback)(() => {
|
|
37344
|
+
const cleaned = inputValue.replace(/,/g, "");
|
|
37345
|
+
const maybeDecimal = import_effect10.BigDecimal.fromString(cleaned);
|
|
37346
|
+
const decimal = import_effect10.Option.match(maybeDecimal, {
|
|
37347
|
+
onNone: () => BIG_DECIMAL_ZERO,
|
|
37348
|
+
onSome: (amount) => amount
|
|
37349
|
+
});
|
|
37350
|
+
const normalizedDecimal = import_effect10.BigDecimal.normalize(decimal);
|
|
37351
|
+
handleChange(normalizedDecimal);
|
|
37352
|
+
handleBlur();
|
|
37353
|
+
setInputValue(formatBigDecimalToString(normalizedDecimal, maxInputLength));
|
|
37354
|
+
}, [inputValue, handleBlur, handleChange, maxInputLength]);
|
|
37355
|
+
const allowedChars = (0, import_react223.useMemo)(
|
|
37356
|
+
() => allowNegative ? DECIMAL_CHARS_REGEX : NON_NEGATIVE_DECIMAL_CHARS_REGEX,
|
|
37357
|
+
[allowNegative]
|
|
37358
|
+
);
|
|
37359
|
+
const onBeforeInput = (0, import_react223.useCallback)((e) => {
|
|
37360
|
+
if (e.data && !allowedChars.test(e.data)) {
|
|
37361
|
+
e.preventDefault();
|
|
37362
|
+
}
|
|
37363
|
+
}, [allowedChars]);
|
|
37364
|
+
const onPaste = (0, import_react223.useCallback)((e) => {
|
|
37365
|
+
const pastedText = e.clipboardData.getData("text");
|
|
37366
|
+
if (!allowedChars.test(pastedText)) {
|
|
37367
|
+
e.preventDefault();
|
|
37368
|
+
}
|
|
37369
|
+
}, [allowedChars]);
|
|
37370
|
+
(0, import_react223.useEffect)(() => {
|
|
37371
|
+
setInputValue(formatBigDecimalToString(value, maxInputLength));
|
|
37372
|
+
}, [value, maxInputLength]);
|
|
37373
|
+
return /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(BaseFormTextField, __spreadProps(__spreadValues({}, slotProps.BaseFormTextField), { inputMode: "decimal", children: /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(InputGroup2, { children: /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(
|
|
37374
|
+
Input2,
|
|
37375
|
+
{
|
|
37376
|
+
inset: true,
|
|
37377
|
+
id: name,
|
|
37378
|
+
name,
|
|
37379
|
+
value: inputValue,
|
|
37380
|
+
onChange: onInputChange,
|
|
37381
|
+
onBlur: onInputBlur,
|
|
37382
|
+
maxLength: maxInputLength,
|
|
37383
|
+
onBeforeInput,
|
|
37384
|
+
onPaste
|
|
37385
|
+
}
|
|
37386
|
+
) }) }));
|
|
37387
|
+
}
|
|
37388
|
+
|
|
37389
|
+
// src/features/forms/components/FormCurrencyField.tsx
|
|
37390
|
+
var import_react224 = require("react");
|
|
37391
|
+
var import_react_currency_input_field2 = __toESM(require("react-currency-input-field"));
|
|
37392
|
+
var import_effect11 = require("effect");
|
|
37393
|
+
var import_jsx_runtime333 = require("react/jsx-runtime");
|
|
37394
|
+
var ZERO_CENTS_INPUT_VALUE = "0.00";
|
|
37395
|
+
var getCurrencyInputValueFromCents = (cents) => !Number.isNaN(cents) ? centsToDollarsWithoutCommas(cents) : ZERO_CENTS_INPUT_VALUE;
|
|
37396
|
+
function FormCurrencyField({ slotProps }) {
|
|
37397
|
+
const field = useFieldContext();
|
|
37398
|
+
const label = slotProps.BaseFormTextField.label;
|
|
37399
|
+
const { name, state, handleChange, handleBlur } = field;
|
|
37400
|
+
const { value } = state;
|
|
37401
|
+
const [inputValue, setInputValue] = (0, import_react224.useState)(getCurrencyInputValueFromCents(value));
|
|
37402
|
+
const onInputChange = (0, import_react224.useCallback)((newValue) => {
|
|
37403
|
+
setInputValue(newValue != null ? newValue : ZERO_CENTS_INPUT_VALUE);
|
|
37404
|
+
}, []);
|
|
37405
|
+
const onInputBlur = (0, import_react224.useCallback)(() => {
|
|
37406
|
+
const maybeAmount = import_effect11.BigDecimal.fromString(inputValue);
|
|
37407
|
+
const cents = import_effect11.Option.match(maybeAmount, {
|
|
37408
|
+
onNone: () => 0,
|
|
37409
|
+
onSome: (amount) => convertBigDecimalToCents(amount)
|
|
37410
|
+
});
|
|
37411
|
+
handleChange(cents);
|
|
37412
|
+
handleBlur();
|
|
37413
|
+
setInputValue(getCurrencyInputValueFromCents(cents));
|
|
37414
|
+
}, [inputValue, handleChange, handleBlur]);
|
|
37415
|
+
(0, import_react224.useEffect)(() => {
|
|
37416
|
+
setInputValue(getCurrencyInputValueFromCents(value));
|
|
37417
|
+
}, [value]);
|
|
37418
|
+
return /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(BaseFormTextField, __spreadProps(__spreadValues({}, slotProps.BaseFormTextField), { children: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(InputGroup2, { children: /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(
|
|
37419
|
+
import_react_currency_input_field2.default,
|
|
37420
|
+
{
|
|
37421
|
+
name,
|
|
37422
|
+
intlConfig: {
|
|
37423
|
+
locale: "en-US",
|
|
37424
|
+
currency: "USD"
|
|
37425
|
+
},
|
|
37426
|
+
prefix: "$",
|
|
37427
|
+
decimalScale: 2,
|
|
37428
|
+
decimalsLimit: 2,
|
|
37429
|
+
disableAbbreviations: true,
|
|
37430
|
+
value: inputValue,
|
|
37431
|
+
onValueChange: onInputChange,
|
|
37432
|
+
onBlur: onInputBlur,
|
|
37433
|
+
className: "Layer__UI__Input",
|
|
37434
|
+
"data-inset": "true",
|
|
37435
|
+
"aria-label": label
|
|
37436
|
+
}
|
|
37437
|
+
) }) }));
|
|
37438
|
+
}
|
|
37439
|
+
|
|
37440
|
+
// src/features/forms/components/FormTextAreaField.tsx
|
|
37441
|
+
var import_react226 = require("react");
|
|
37442
|
+
|
|
37443
|
+
// src/components/ui/Input/TextArea.tsx
|
|
37444
|
+
var import_react225 = require("react");
|
|
37445
|
+
var import_react_aria_components17 = require("react-aria-components");
|
|
37446
|
+
var import_jsx_runtime334 = require("react/jsx-runtime");
|
|
37447
|
+
var TEXTAREA_CLASS_NAME = "Layer__UI__TextArea";
|
|
37448
|
+
var TextArea = (0, import_react225.forwardRef)(
|
|
37449
|
+
function TextArea2(_a, ref) {
|
|
37450
|
+
var _b = _a, { resize = "none" } = _b, restProps = __objRest(_b, ["resize"]);
|
|
37451
|
+
const dataProperties = toDataProperties({ resize });
|
|
37452
|
+
return /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(
|
|
37453
|
+
import_react_aria_components17.TextArea,
|
|
37454
|
+
__spreadProps(__spreadValues(__spreadValues({}, restProps), dataProperties), {
|
|
37455
|
+
className: TEXTAREA_CLASS_NAME,
|
|
37456
|
+
ref
|
|
37457
|
+
})
|
|
37458
|
+
);
|
|
37459
|
+
}
|
|
37460
|
+
);
|
|
37461
|
+
|
|
37462
|
+
// src/features/forms/components/FormTextAreaField.tsx
|
|
37463
|
+
var import_jsx_runtime335 = require("react/jsx-runtime");
|
|
37464
|
+
function FormTextAreaField({ slotProps }) {
|
|
37465
|
+
const field = useFieldContext();
|
|
37466
|
+
const { name, state, handleChange, handleBlur } = field;
|
|
37467
|
+
const { value } = state;
|
|
37468
|
+
const onChange = (0, import_react226.useCallback)((e) => {
|
|
37469
|
+
handleChange(e.target.value);
|
|
37470
|
+
}, [handleChange]);
|
|
37471
|
+
return /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(BaseFormTextField, __spreadProps(__spreadValues({}, slotProps.BaseFormTextField), { children: /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(TextArea, { id: name, name, value, onChange, onBlur: handleBlur }) }));
|
|
37472
|
+
}
|
|
37473
|
+
|
|
37474
|
+
// src/features/forms/components/FormTextField.tsx
|
|
37475
|
+
var import_react227 = require("react");
|
|
37476
|
+
var import_jsx_runtime336 = require("react/jsx-runtime");
|
|
37477
|
+
function FormTextField({ slotProps }) {
|
|
37478
|
+
const field = useFieldContext();
|
|
37479
|
+
const { name, state, handleChange, handleBlur } = field;
|
|
37480
|
+
const { value } = state;
|
|
37481
|
+
const onChange = (0, import_react227.useCallback)((e) => {
|
|
37482
|
+
handleChange(e.target.value);
|
|
37483
|
+
}, [handleChange]);
|
|
37484
|
+
return /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(BaseFormTextField, __spreadProps(__spreadValues({}, slotProps.BaseFormTextField), { children: /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(InputGroup2, { children: /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(Input2, { inset: true, id: name, name, value, onChange, onBlur: handleBlur }) }) }));
|
|
37485
|
+
}
|
|
37486
|
+
|
|
37487
|
+
// src/features/forms/hooks/useForm.tsx
|
|
37488
|
+
var { fieldContext, useFieldContext, formContext, useFormContext } = (0, import_react_form6.createFormHookContexts)();
|
|
37489
|
+
var { useAppForm, withForm } = (0, import_react_form6.createFormHook)({
|
|
37490
|
+
fieldComponents: {
|
|
37491
|
+
BaseFormTextField,
|
|
37492
|
+
FormBigDecimalField,
|
|
37493
|
+
FormCurrencyField,
|
|
37494
|
+
FormTextAreaField,
|
|
37495
|
+
FormTextField
|
|
37496
|
+
},
|
|
37497
|
+
formComponents: {
|
|
37498
|
+
// TODO: define a submit button component
|
|
37499
|
+
},
|
|
37500
|
+
fieldContext,
|
|
37501
|
+
formContext
|
|
37212
37502
|
});
|
|
37213
37503
|
|
|
37214
37504
|
// src/features/invoices/invoiceSchemas.ts
|
|
37215
|
-
var
|
|
37505
|
+
var import_effect12 = require("effect");
|
|
37216
37506
|
var InvoiceStatus = /* @__PURE__ */ ((InvoiceStatus3) => {
|
|
37217
37507
|
InvoiceStatus3["Voided"] = "VOIDED";
|
|
37218
37508
|
InvoiceStatus3["Paid"] = "PAID";
|
|
@@ -37222,10 +37512,10 @@ var InvoiceStatus = /* @__PURE__ */ ((InvoiceStatus3) => {
|
|
|
37222
37512
|
InvoiceStatus3["Sent"] = "SENT";
|
|
37223
37513
|
return InvoiceStatus3;
|
|
37224
37514
|
})(InvoiceStatus || {});
|
|
37225
|
-
var InvoiceStatusSchema =
|
|
37226
|
-
var TransformedInvoiceStatusSchema =
|
|
37227
|
-
|
|
37228
|
-
|
|
37515
|
+
var InvoiceStatusSchema = import_effect12.Schema.Enums(InvoiceStatus);
|
|
37516
|
+
var TransformedInvoiceStatusSchema = import_effect12.Schema.transform(
|
|
37517
|
+
import_effect12.Schema.NonEmptyTrimmedString,
|
|
37518
|
+
import_effect12.Schema.typeSchema(InvoiceStatusSchema),
|
|
37229
37519
|
{
|
|
37230
37520
|
decode: (input) => {
|
|
37231
37521
|
if (Object.values(InvoiceStatusSchema.enums).includes(input)) {
|
|
@@ -37236,163 +37526,685 @@ var TransformedInvoiceStatusSchema = import_effect10.Schema.transform(
|
|
|
37236
37526
|
encode: (input) => input
|
|
37237
37527
|
}
|
|
37238
37528
|
);
|
|
37239
|
-
var InvoiceLineItemSchema =
|
|
37240
|
-
id:
|
|
37241
|
-
externalId: (0,
|
|
37242
|
-
|
|
37243
|
-
|
|
37529
|
+
var InvoiceLineItemSchema = import_effect12.Schema.Struct({
|
|
37530
|
+
id: import_effect12.Schema.UUID,
|
|
37531
|
+
externalId: (0, import_effect12.pipe)(
|
|
37532
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.NullOr(import_effect12.Schema.String)),
|
|
37533
|
+
import_effect12.Schema.fromKey("external_id")
|
|
37244
37534
|
),
|
|
37245
|
-
invoiceId: (0,
|
|
37246
|
-
|
|
37247
|
-
|
|
37535
|
+
invoiceId: (0, import_effect12.pipe)(
|
|
37536
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.UUID),
|
|
37537
|
+
import_effect12.Schema.fromKey("invoice_id")
|
|
37248
37538
|
),
|
|
37249
|
-
description:
|
|
37250
|
-
product:
|
|
37251
|
-
unitPrice: (0,
|
|
37252
|
-
|
|
37253
|
-
|
|
37539
|
+
description: import_effect12.Schema.NullOr(import_effect12.Schema.String),
|
|
37540
|
+
product: import_effect12.Schema.NullOr(import_effect12.Schema.String),
|
|
37541
|
+
unitPrice: (0, import_effect12.pipe)(
|
|
37542
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.Number),
|
|
37543
|
+
import_effect12.Schema.fromKey("unit_price")
|
|
37254
37544
|
),
|
|
37255
|
-
quantity:
|
|
37256
|
-
subtotal:
|
|
37257
|
-
discountAmount: (0,
|
|
37258
|
-
|
|
37259
|
-
|
|
37545
|
+
quantity: import_effect12.Schema.BigDecimal,
|
|
37546
|
+
subtotal: import_effect12.Schema.Number,
|
|
37547
|
+
discountAmount: (0, import_effect12.pipe)(
|
|
37548
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.Number),
|
|
37549
|
+
import_effect12.Schema.fromKey("discount_amount")
|
|
37260
37550
|
),
|
|
37261
|
-
salesTaxTotal: (0,
|
|
37262
|
-
|
|
37263
|
-
|
|
37551
|
+
salesTaxTotal: (0, import_effect12.pipe)(
|
|
37552
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.Number),
|
|
37553
|
+
import_effect12.Schema.fromKey("sales_taxes_total")
|
|
37264
37554
|
),
|
|
37265
|
-
totalAmount: (0,
|
|
37266
|
-
|
|
37267
|
-
|
|
37555
|
+
totalAmount: (0, import_effect12.pipe)(
|
|
37556
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.Number),
|
|
37557
|
+
import_effect12.Schema.fromKey("total_amount")
|
|
37268
37558
|
),
|
|
37269
|
-
memo:
|
|
37559
|
+
memo: import_effect12.Schema.NullOr(import_effect12.Schema.String)
|
|
37270
37560
|
});
|
|
37271
|
-
var InvoiceSchema =
|
|
37272
|
-
id:
|
|
37273
|
-
businessId: (0,
|
|
37274
|
-
|
|
37275
|
-
|
|
37561
|
+
var InvoiceSchema = import_effect12.Schema.Struct({
|
|
37562
|
+
id: import_effect12.Schema.UUID,
|
|
37563
|
+
businessId: (0, import_effect12.pipe)(
|
|
37564
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.UUID),
|
|
37565
|
+
import_effect12.Schema.fromKey("business_id")
|
|
37276
37566
|
),
|
|
37277
|
-
externalId: (0,
|
|
37278
|
-
|
|
37279
|
-
|
|
37567
|
+
externalId: (0, import_effect12.pipe)(
|
|
37568
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.NullOr(import_effect12.Schema.String)),
|
|
37569
|
+
import_effect12.Schema.fromKey("external_id")
|
|
37280
37570
|
),
|
|
37281
37571
|
status: TransformedInvoiceStatusSchema,
|
|
37282
|
-
sentAt: (0,
|
|
37283
|
-
|
|
37284
|
-
|
|
37572
|
+
sentAt: (0, import_effect12.pipe)(
|
|
37573
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.NullOr(import_effect12.Schema.Date)),
|
|
37574
|
+
import_effect12.Schema.fromKey("sent_at")
|
|
37285
37575
|
),
|
|
37286
|
-
dueAt: (0,
|
|
37287
|
-
|
|
37288
|
-
|
|
37576
|
+
dueAt: (0, import_effect12.pipe)(
|
|
37577
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.NullOr(import_effect12.Schema.Date)),
|
|
37578
|
+
import_effect12.Schema.fromKey("due_at")
|
|
37289
37579
|
),
|
|
37290
|
-
paidAt: (0,
|
|
37291
|
-
|
|
37292
|
-
|
|
37580
|
+
paidAt: (0, import_effect12.pipe)(
|
|
37581
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.NullOr(import_effect12.Schema.Date)),
|
|
37582
|
+
import_effect12.Schema.fromKey("paid_at")
|
|
37293
37583
|
),
|
|
37294
|
-
voidedAt: (0,
|
|
37295
|
-
|
|
37296
|
-
|
|
37584
|
+
voidedAt: (0, import_effect12.pipe)(
|
|
37585
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.NullOr(import_effect12.Schema.Date)),
|
|
37586
|
+
import_effect12.Schema.fromKey("voided_at")
|
|
37297
37587
|
),
|
|
37298
|
-
invoiceNumber: (0,
|
|
37299
|
-
|
|
37300
|
-
|
|
37588
|
+
invoiceNumber: (0, import_effect12.pipe)(
|
|
37589
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.NullOr(import_effect12.Schema.String)),
|
|
37590
|
+
import_effect12.Schema.fromKey("invoice_number")
|
|
37301
37591
|
),
|
|
37302
|
-
recipientName: (0,
|
|
37303
|
-
|
|
37304
|
-
|
|
37592
|
+
recipientName: (0, import_effect12.pipe)(
|
|
37593
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.NullOr(import_effect12.Schema.String)),
|
|
37594
|
+
import_effect12.Schema.fromKey("recipient_name")
|
|
37305
37595
|
),
|
|
37306
|
-
customer:
|
|
37307
|
-
lineItems: (0,
|
|
37308
|
-
|
|
37309
|
-
|
|
37596
|
+
customer: import_effect12.Schema.NullOr(CustomerSchema),
|
|
37597
|
+
lineItems: (0, import_effect12.pipe)(
|
|
37598
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.Array(InvoiceLineItemSchema)),
|
|
37599
|
+
import_effect12.Schema.fromKey("line_items")
|
|
37310
37600
|
),
|
|
37311
|
-
subtotal:
|
|
37312
|
-
additionalDiscount: (0,
|
|
37313
|
-
|
|
37314
|
-
|
|
37601
|
+
subtotal: import_effect12.Schema.Number,
|
|
37602
|
+
additionalDiscount: (0, import_effect12.pipe)(
|
|
37603
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.Number),
|
|
37604
|
+
import_effect12.Schema.fromKey("additional_discount")
|
|
37315
37605
|
),
|
|
37316
|
-
additionalSalesTaxesTotal: (0,
|
|
37317
|
-
|
|
37318
|
-
|
|
37606
|
+
additionalSalesTaxesTotal: (0, import_effect12.pipe)(
|
|
37607
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.Number),
|
|
37608
|
+
import_effect12.Schema.fromKey("additional_sales_taxes_total")
|
|
37319
37609
|
),
|
|
37320
|
-
totalAmount: (0,
|
|
37321
|
-
|
|
37322
|
-
|
|
37610
|
+
totalAmount: (0, import_effect12.pipe)(
|
|
37611
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.Number),
|
|
37612
|
+
import_effect12.Schema.fromKey("total_amount")
|
|
37323
37613
|
),
|
|
37324
|
-
outstandingBalance: (0,
|
|
37325
|
-
|
|
37326
|
-
|
|
37614
|
+
outstandingBalance: (0, import_effect12.pipe)(
|
|
37615
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.Number),
|
|
37616
|
+
import_effect12.Schema.fromKey("outstanding_balance")
|
|
37327
37617
|
),
|
|
37328
|
-
importedAt: (0,
|
|
37329
|
-
|
|
37330
|
-
|
|
37618
|
+
importedAt: (0, import_effect12.pipe)(
|
|
37619
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.Date),
|
|
37620
|
+
import_effect12.Schema.fromKey("imported_at")
|
|
37331
37621
|
),
|
|
37332
|
-
updatedAt: (0,
|
|
37333
|
-
|
|
37334
|
-
|
|
37622
|
+
updatedAt: (0, import_effect12.pipe)(
|
|
37623
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.NullOr(import_effect12.Schema.Date)),
|
|
37624
|
+
import_effect12.Schema.fromKey("updated_at")
|
|
37335
37625
|
),
|
|
37336
|
-
memo:
|
|
37626
|
+
memo: import_effect12.Schema.NullOr(import_effect12.Schema.String)
|
|
37337
37627
|
});
|
|
37338
|
-
var UpsertInvoiceTaxLineItemSchema =
|
|
37339
|
-
amount:
|
|
37628
|
+
var UpsertInvoiceTaxLineItemSchema = import_effect12.Schema.Struct({
|
|
37629
|
+
amount: import_effect12.Schema.Number
|
|
37340
37630
|
});
|
|
37341
|
-
var UpsertInvoiceLineItemSchema =
|
|
37342
|
-
description:
|
|
37343
|
-
|
|
37344
|
-
|
|
37345
|
-
|
|
37346
|
-
|
|
37347
|
-
import_effect10.Schema.propertySignature(import_effect10.Schema.String),
|
|
37348
|
-
import_effect10.Schema.fromKey("product")
|
|
37631
|
+
var UpsertInvoiceLineItemSchema = import_effect12.Schema.Struct({
|
|
37632
|
+
description: import_effect12.Schema.String,
|
|
37633
|
+
product: import_effect12.Schema.String,
|
|
37634
|
+
unitPrice: (0, import_effect12.pipe)(
|
|
37635
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.Number),
|
|
37636
|
+
import_effect12.Schema.fromKey("unit_price")
|
|
37349
37637
|
),
|
|
37350
|
-
|
|
37351
|
-
import_effect10.Schema.propertySignature(import_effect10.Schema.NumberFromString.pipe(import_effect10.Schema.int())),
|
|
37352
|
-
import_effect10.Schema.fromKey("unit_price")
|
|
37353
|
-
),
|
|
37354
|
-
quantity: (0, import_effect10.pipe)(
|
|
37355
|
-
import_effect10.Schema.propertySignature(import_effect10.Schema.BigDecimal),
|
|
37356
|
-
import_effect10.Schema.fromKey("quantity")
|
|
37357
|
-
)
|
|
37638
|
+
quantity: import_effect12.Schema.BigDecimal
|
|
37358
37639
|
});
|
|
37359
|
-
var UpsertInvoiceSchema =
|
|
37360
|
-
sentAt: (0,
|
|
37361
|
-
|
|
37362
|
-
|
|
37640
|
+
var UpsertInvoiceSchema = import_effect12.Schema.Struct({
|
|
37641
|
+
sentAt: (0, import_effect12.pipe)(
|
|
37642
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.Date),
|
|
37643
|
+
import_effect12.Schema.fromKey("sent_at")
|
|
37363
37644
|
),
|
|
37364
|
-
dueAt: (0,
|
|
37365
|
-
|
|
37366
|
-
|
|
37645
|
+
dueAt: (0, import_effect12.pipe)(
|
|
37646
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.Date),
|
|
37647
|
+
import_effect12.Schema.fromKey("due_at")
|
|
37367
37648
|
),
|
|
37368
|
-
invoiceNumber: (0,
|
|
37369
|
-
|
|
37370
|
-
|
|
37649
|
+
invoiceNumber: (0, import_effect12.pipe)(
|
|
37650
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.UndefinedOr(import_effect12.Schema.String)),
|
|
37651
|
+
import_effect12.Schema.fromKey("invoice_number")
|
|
37371
37652
|
),
|
|
37372
|
-
customerId: (0,
|
|
37373
|
-
|
|
37374
|
-
|
|
37653
|
+
customerId: (0, import_effect12.pipe)(
|
|
37654
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.UUID),
|
|
37655
|
+
import_effect12.Schema.fromKey("customer_id")
|
|
37375
37656
|
),
|
|
37376
|
-
memo:
|
|
37377
|
-
lineItems: (0,
|
|
37378
|
-
|
|
37379
|
-
|
|
37657
|
+
memo: import_effect12.Schema.NullOr(import_effect12.Schema.String),
|
|
37658
|
+
lineItems: (0, import_effect12.pipe)(
|
|
37659
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.Array(UpsertInvoiceLineItemSchema)),
|
|
37660
|
+
import_effect12.Schema.fromKey("line_items")
|
|
37380
37661
|
),
|
|
37381
|
-
additionalDiscount: (0,
|
|
37382
|
-
|
|
37383
|
-
|
|
37662
|
+
additionalDiscount: (0, import_effect12.pipe)(
|
|
37663
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.UndefinedOr(import_effect12.Schema.Number)),
|
|
37664
|
+
import_effect12.Schema.fromKey("additional_discount")
|
|
37384
37665
|
),
|
|
37385
|
-
additionalSalesTaxes: (0,
|
|
37386
|
-
|
|
37387
|
-
|
|
37666
|
+
additionalSalesTaxes: (0, import_effect12.pipe)(
|
|
37667
|
+
import_effect12.Schema.propertySignature(import_effect12.Schema.UndefinedOr(import_effect12.Schema.Array(UpsertInvoiceTaxLineItemSchema))),
|
|
37668
|
+
import_effect12.Schema.fromKey("additional_sales_taxes")
|
|
37669
|
+
)
|
|
37670
|
+
});
|
|
37671
|
+
|
|
37672
|
+
// src/features/invoices/api/useUpsertInvoice.tsx
|
|
37673
|
+
var import_react228 = require("react");
|
|
37674
|
+
var import_mutation26 = __toESM(require("swr/mutation"));
|
|
37675
|
+
var import_effect13 = require("effect");
|
|
37676
|
+
var UPSERT_INVOICES_TAG_KEY = "#upsert-invoice";
|
|
37677
|
+
var createInvoice = post(({ businessId }) => `/v1/businesses/${businessId}/invoices`);
|
|
37678
|
+
var updateInvoice = put(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}`);
|
|
37679
|
+
function buildKey39({
|
|
37680
|
+
access_token: accessToken,
|
|
37681
|
+
apiUrl,
|
|
37682
|
+
businessId,
|
|
37683
|
+
invoiceId = void 0
|
|
37684
|
+
}) {
|
|
37685
|
+
if (accessToken && apiUrl) {
|
|
37686
|
+
return {
|
|
37687
|
+
accessToken,
|
|
37688
|
+
apiUrl,
|
|
37689
|
+
businessId,
|
|
37690
|
+
invoiceId,
|
|
37691
|
+
tags: [UPSERT_INVOICES_TAG_KEY]
|
|
37692
|
+
};
|
|
37693
|
+
}
|
|
37694
|
+
}
|
|
37695
|
+
var UpsertInvoiceReturnSchema = import_effect13.Schema.Struct({
|
|
37696
|
+
data: InvoiceSchema
|
|
37697
|
+
});
|
|
37698
|
+
var UpsertInvoiceSWRResponse = class {
|
|
37699
|
+
constructor(swrResponse) {
|
|
37700
|
+
__publicField(this, "swrResponse");
|
|
37701
|
+
this.swrResponse = swrResponse;
|
|
37702
|
+
}
|
|
37703
|
+
get data() {
|
|
37704
|
+
return this.swrResponse.data;
|
|
37705
|
+
}
|
|
37706
|
+
get trigger() {
|
|
37707
|
+
return this.swrResponse.trigger;
|
|
37708
|
+
}
|
|
37709
|
+
get isMutating() {
|
|
37710
|
+
return this.swrResponse.isMutating;
|
|
37711
|
+
}
|
|
37712
|
+
get isError() {
|
|
37713
|
+
return this.swrResponse.error !== void 0;
|
|
37714
|
+
}
|
|
37715
|
+
};
|
|
37716
|
+
var CreateParamsSchema = import_effect13.Schema.Struct({
|
|
37717
|
+
businessId: import_effect13.Schema.String
|
|
37718
|
+
});
|
|
37719
|
+
var UpdateParamsSchema = import_effect13.Schema.Struct({
|
|
37720
|
+
businessId: import_effect13.Schema.String,
|
|
37721
|
+
invoiceId: import_effect13.Schema.String
|
|
37722
|
+
});
|
|
37723
|
+
var isParamsValidForMode = (mode, params) => {
|
|
37724
|
+
if (mode === "Update" /* Update */) {
|
|
37725
|
+
return import_effect13.Effect.runSync(import_effect13.Effect.either(import_effect13.Schema.decodeUnknown(UpdateParamsSchema)(params)))._tag === "Right";
|
|
37726
|
+
}
|
|
37727
|
+
if (mode === "Create" /* Create */) {
|
|
37728
|
+
return import_effect13.Effect.runSync(import_effect13.Effect.either(import_effect13.Schema.decodeUnknown(CreateParamsSchema)(params)))._tag === "Right";
|
|
37729
|
+
}
|
|
37730
|
+
return false;
|
|
37731
|
+
};
|
|
37732
|
+
function getRequestFn(mode, params) {
|
|
37733
|
+
if (mode === "Update" /* Update */) {
|
|
37734
|
+
if (!isParamsValidForMode("Update" /* Update */, params)) {
|
|
37735
|
+
throw new Error("Invalid params for upsert mode");
|
|
37736
|
+
}
|
|
37737
|
+
return ({ apiUrl, accessToken, body }) => updateInvoice(apiUrl, accessToken, { params, body });
|
|
37738
|
+
} else {
|
|
37739
|
+
if (!isParamsValidForMode("Create" /* Create */, params)) {
|
|
37740
|
+
throw new Error("Invalid params for create mode");
|
|
37741
|
+
}
|
|
37742
|
+
return ({ apiUrl, accessToken, body }) => createInvoice(apiUrl, accessToken, { params, body });
|
|
37743
|
+
}
|
|
37744
|
+
}
|
|
37745
|
+
var useUpsertInvoice = (props) => {
|
|
37746
|
+
const { data } = useAuth();
|
|
37747
|
+
const { businessId } = useLayerContext();
|
|
37748
|
+
const { mode } = props;
|
|
37749
|
+
const invoiceId = mode === "Update" /* Update */ ? props.invoiceId : void 0;
|
|
37750
|
+
const rawMutationResponse = (0, import_mutation26.default)(
|
|
37751
|
+
() => buildKey39(__spreadProps(__spreadValues({}, data), {
|
|
37752
|
+
businessId,
|
|
37753
|
+
invoiceId
|
|
37754
|
+
})),
|
|
37755
|
+
({ accessToken, apiUrl, businessId: businessId2, invoiceId: invoiceId2 }, { arg: body }) => {
|
|
37756
|
+
const request2 = getRequestFn(mode, { businessId: businessId2, invoiceId: invoiceId2 });
|
|
37757
|
+
return request2({
|
|
37758
|
+
apiUrl,
|
|
37759
|
+
accessToken,
|
|
37760
|
+
body
|
|
37761
|
+
}).then(import_effect13.Schema.decodeUnknownPromise(UpsertInvoiceReturnSchema));
|
|
37762
|
+
},
|
|
37763
|
+
{
|
|
37764
|
+
revalidate: false
|
|
37765
|
+
}
|
|
37766
|
+
);
|
|
37767
|
+
const mutationResponse = new UpsertInvoiceSWRResponse(rawMutationResponse);
|
|
37768
|
+
const originalTrigger = mutationResponse.trigger;
|
|
37769
|
+
const stableProxiedTrigger = (0, import_react228.useCallback)(
|
|
37770
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
37771
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
37772
|
+
return triggerResult;
|
|
37773
|
+
}),
|
|
37774
|
+
[originalTrigger]
|
|
37775
|
+
);
|
|
37776
|
+
return new Proxy(mutationResponse, {
|
|
37777
|
+
get(target, prop) {
|
|
37778
|
+
if (prop === "trigger") {
|
|
37779
|
+
return stableProxiedTrigger;
|
|
37780
|
+
}
|
|
37781
|
+
return Reflect.get(target, prop);
|
|
37782
|
+
}
|
|
37783
|
+
});
|
|
37784
|
+
};
|
|
37785
|
+
|
|
37786
|
+
// src/components/Invoices/InvoiceForm/useInvoiceForm.ts
|
|
37787
|
+
var import_effect14 = require("effect");
|
|
37788
|
+
var EMPTY_LINE_ITEM = {
|
|
37789
|
+
product: "",
|
|
37790
|
+
description: "",
|
|
37791
|
+
unitPrice: 0,
|
|
37792
|
+
quantity: BIG_DECIMAL_ONE,
|
|
37793
|
+
amount: 0
|
|
37794
|
+
};
|
|
37795
|
+
var DEFAULT_FORM_VALUES = {
|
|
37796
|
+
invoiceNumber: "",
|
|
37797
|
+
customer: null,
|
|
37798
|
+
email: "",
|
|
37799
|
+
address: "",
|
|
37800
|
+
lineItems: [EMPTY_LINE_ITEM]
|
|
37801
|
+
};
|
|
37802
|
+
var getInvoiceLineItemAmount = (lineItem) => {
|
|
37803
|
+
const { unitPrice, quantity } = lineItem;
|
|
37804
|
+
return convertBigDecimalToCents(import_effect14.BigDecimal.multiply(quantity, convertCentsToBigDecimal(unitPrice)));
|
|
37805
|
+
};
|
|
37806
|
+
var getAugmentedInvoiceFormLineItem = (lineItem) => {
|
|
37807
|
+
return __spreadProps(__spreadValues({}, lineItem), {
|
|
37808
|
+
amount: getInvoiceLineItemAmount(lineItem)
|
|
37809
|
+
});
|
|
37810
|
+
};
|
|
37811
|
+
var getInvoiceFormDefaultValues = (invoice) => {
|
|
37812
|
+
var _a, _b;
|
|
37813
|
+
return {
|
|
37814
|
+
invoiceNumber: invoice.invoiceNumber,
|
|
37815
|
+
customer: invoice.customer,
|
|
37816
|
+
email: (_a = invoice.customer) == null ? void 0 : _a.email,
|
|
37817
|
+
address: (_b = invoice.customer) == null ? void 0 : _b.addressString,
|
|
37818
|
+
lineItems: invoice.lineItems.map(getAugmentedInvoiceFormLineItem)
|
|
37819
|
+
};
|
|
37820
|
+
};
|
|
37821
|
+
var useInvoiceForm = (props) => {
|
|
37822
|
+
const [submitError, setSubmitError] = (0, import_react229.useState)(void 0);
|
|
37823
|
+
const { onSuccess, mode } = props;
|
|
37824
|
+
const upsertInvoiceProps = mode === "Update" /* Update */ ? { mode, invoiceId: props.invoice.id } : { mode };
|
|
37825
|
+
const { trigger: upsertInvoice } = useUpsertInvoice(upsertInvoiceProps);
|
|
37826
|
+
const defaultValues = mode === "Update" /* Update */ ? getInvoiceFormDefaultValues(props.invoice) : DEFAULT_FORM_VALUES;
|
|
37827
|
+
const form = useAppForm({
|
|
37828
|
+
defaultValues,
|
|
37829
|
+
onSubmit: (_0) => __async(null, [_0], function* ({ value }) {
|
|
37830
|
+
var _a;
|
|
37831
|
+
try {
|
|
37832
|
+
const payload = __spreadProps(__spreadValues({}, value), {
|
|
37833
|
+
customerId: (_a = value == null ? void 0 : value.customer) == null ? void 0 : _a.id
|
|
37834
|
+
});
|
|
37835
|
+
const invoiceParams = import_effect14.Schema.validateSync(UpsertInvoiceSchema)(payload);
|
|
37836
|
+
const { data: invoice } = yield upsertInvoice(invoiceParams);
|
|
37837
|
+
setSubmitError(void 0);
|
|
37838
|
+
onSuccess == null ? void 0 : onSuccess(invoice);
|
|
37839
|
+
} catch (e) {
|
|
37840
|
+
setSubmitError("Something went wrong. Please try again.");
|
|
37841
|
+
}
|
|
37842
|
+
})
|
|
37843
|
+
});
|
|
37844
|
+
const isFormValid = (0, import_react_form7.useStore)(form.store, (state) => state.isValid);
|
|
37845
|
+
return { form, submitError, isFormValid };
|
|
37846
|
+
};
|
|
37847
|
+
|
|
37848
|
+
// src/components/Invoices/InvoiceForm/InvoiceForm.tsx
|
|
37849
|
+
var import_lucide_react16 = require("lucide-react");
|
|
37850
|
+
var import_effect15 = require("effect");
|
|
37851
|
+
|
|
37852
|
+
// src/features/customers/components/CustomerSelector.tsx
|
|
37853
|
+
var import_react230 = require("react");
|
|
37854
|
+
var import_classnames89 = __toESM(require("classnames"));
|
|
37855
|
+
var import_jsx_runtime337 = require("react/jsx-runtime");
|
|
37856
|
+
function getCustomerName(customer) {
|
|
37857
|
+
var _a, _b, _c;
|
|
37858
|
+
return (_c = (_b = (_a = customer.individualName) != null ? _a : customer.companyName) != null ? _b : customer.externalId) != null ? _c : "Unknown Customer";
|
|
37859
|
+
}
|
|
37860
|
+
var CustomerAsOption = class {
|
|
37861
|
+
constructor(customer) {
|
|
37862
|
+
__publicField(this, "internalCustomer");
|
|
37863
|
+
this.internalCustomer = customer;
|
|
37864
|
+
}
|
|
37865
|
+
get original() {
|
|
37866
|
+
return this.internalCustomer;
|
|
37867
|
+
}
|
|
37868
|
+
get label() {
|
|
37869
|
+
return getCustomerName(this.internalCustomer);
|
|
37870
|
+
}
|
|
37871
|
+
get id() {
|
|
37872
|
+
return this.internalCustomer.id;
|
|
37873
|
+
}
|
|
37874
|
+
get value() {
|
|
37875
|
+
return this.internalCustomer.id;
|
|
37876
|
+
}
|
|
37877
|
+
};
|
|
37878
|
+
function CustomerSelector({
|
|
37879
|
+
selectedCustomer,
|
|
37880
|
+
onSelectedCustomerChange,
|
|
37881
|
+
placeholder,
|
|
37882
|
+
isReadOnly,
|
|
37883
|
+
inline,
|
|
37884
|
+
className
|
|
37885
|
+
}) {
|
|
37886
|
+
const combinedClassName = (0, import_classnames89.default)(
|
|
37887
|
+
"Layer__CustomerSelector",
|
|
37888
|
+
inline && "Layer__CustomerSelector--inline",
|
|
37889
|
+
className
|
|
37890
|
+
);
|
|
37891
|
+
const { searchQuery, handleInputChange } = useDebouncedSearchInput({
|
|
37892
|
+
initialInputState: () => ""
|
|
37893
|
+
});
|
|
37894
|
+
const effectiveSearchQuery = searchQuery === "" ? void 0 : searchQuery;
|
|
37895
|
+
const { data, isLoading, isError } = useListCustomers({ query: effectiveSearchQuery });
|
|
37896
|
+
const options = (0, import_react230.useMemo)(
|
|
37897
|
+
() => (data == null ? void 0 : data.flatMap(({ data: data2 }) => data2).map((customer) => new CustomerAsOption(customer))) || [],
|
|
37898
|
+
[data]
|
|
37899
|
+
);
|
|
37900
|
+
const selectedCustomerId = selectedCustomer == null ? void 0 : selectedCustomer.id;
|
|
37901
|
+
const handleSelectionChange = (0, import_react230.useCallback)(
|
|
37902
|
+
(selectedOption) => {
|
|
37903
|
+
if (selectedOption === null) {
|
|
37904
|
+
handleInputChange("");
|
|
37905
|
+
if (selectedCustomerId) {
|
|
37906
|
+
onSelectedCustomerChange(null);
|
|
37907
|
+
}
|
|
37908
|
+
return;
|
|
37909
|
+
}
|
|
37910
|
+
const selectedCustomer2 = options.find(({ id }) => id === selectedOption.value);
|
|
37911
|
+
if (selectedCustomer2) {
|
|
37912
|
+
const selectedCustomerWithType = selectedCustomer2.original;
|
|
37913
|
+
if (selectedCustomer2.id !== selectedCustomerId) {
|
|
37914
|
+
onSelectedCustomerChange(selectedCustomerWithType);
|
|
37915
|
+
}
|
|
37916
|
+
handleInputChange("");
|
|
37917
|
+
return;
|
|
37918
|
+
}
|
|
37919
|
+
},
|
|
37920
|
+
[options, handleInputChange, selectedCustomerId, onSelectedCustomerChange]
|
|
37921
|
+
);
|
|
37922
|
+
const selectedCustomerForComboBox = (0, import_react230.useMemo)(
|
|
37923
|
+
() => {
|
|
37924
|
+
if (selectedCustomer === null) {
|
|
37925
|
+
return null;
|
|
37926
|
+
}
|
|
37927
|
+
return {
|
|
37928
|
+
label: getCustomerName(selectedCustomer),
|
|
37929
|
+
value: selectedCustomer.id
|
|
37930
|
+
};
|
|
37931
|
+
},
|
|
37932
|
+
[selectedCustomer]
|
|
37933
|
+
);
|
|
37934
|
+
const EmptyMessage = (0, import_react230.useMemo)(
|
|
37935
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(P, { variant: "subtle", children: "No matching customer" }),
|
|
37936
|
+
[]
|
|
37937
|
+
);
|
|
37938
|
+
const ErrorMessage = (0, import_react230.useMemo)(
|
|
37939
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(
|
|
37940
|
+
P,
|
|
37941
|
+
{
|
|
37942
|
+
size: "xs",
|
|
37943
|
+
status: "error",
|
|
37944
|
+
children: "An error occurred while loading customers."
|
|
37945
|
+
}
|
|
37946
|
+
),
|
|
37947
|
+
[]
|
|
37948
|
+
);
|
|
37949
|
+
const inputId = (0, import_react230.useId)();
|
|
37950
|
+
const isFiltered = effectiveSearchQuery !== void 0;
|
|
37951
|
+
const noCustomersExist = !isLoading && !isFiltered && data !== void 0 && data.every(({ data: data2 }) => data2.length === 0);
|
|
37952
|
+
const shouldHideComponent = noCustomersExist || isReadOnly && selectedCustomer === null;
|
|
37953
|
+
if (shouldHideComponent) {
|
|
37954
|
+
return null;
|
|
37955
|
+
}
|
|
37956
|
+
const isLoadingWithoutFallback = isLoading && !data;
|
|
37957
|
+
const shouldDisableComboBox = isLoadingWithoutFallback || isError;
|
|
37958
|
+
return /* @__PURE__ */ (0, import_jsx_runtime337.jsxs)(VStack, { className: combinedClassName, children: [
|
|
37959
|
+
/* @__PURE__ */ (0, import_jsx_runtime337.jsx)(Label, { htmlFor: inputId, size: "sm", children: "Customer" }),
|
|
37960
|
+
/* @__PURE__ */ (0, import_jsx_runtime337.jsx)(
|
|
37961
|
+
ComboBox,
|
|
37962
|
+
{
|
|
37963
|
+
selectedValue: selectedCustomerForComboBox,
|
|
37964
|
+
onSelectedValueChange: handleSelectionChange,
|
|
37965
|
+
options,
|
|
37966
|
+
onInputValueChange: handleInputChange,
|
|
37967
|
+
inputId,
|
|
37968
|
+
placeholder,
|
|
37969
|
+
slots: { EmptyMessage, ErrorMessage },
|
|
37970
|
+
isDisabled: isReadOnly || shouldDisableComboBox,
|
|
37971
|
+
isError,
|
|
37972
|
+
isLoading: isLoadingWithoutFallback
|
|
37973
|
+
}
|
|
37974
|
+
)
|
|
37975
|
+
] });
|
|
37976
|
+
}
|
|
37977
|
+
|
|
37978
|
+
// src/components/Invoices/InvoiceForm/InvoiceForm.tsx
|
|
37979
|
+
var import_jsx_runtime338 = require("react/jsx-runtime");
|
|
37980
|
+
var INVOICE_FORM_CSS_PREFIX = "Layer__InvoiceForm";
|
|
37981
|
+
var INVOICE_FORM_FIELD_CSS_PREFIX = `${INVOICE_FORM_CSS_PREFIX}__Field`;
|
|
37982
|
+
var InvoiceForm = (props) => {
|
|
37983
|
+
const { onSuccess, mode } = props;
|
|
37984
|
+
const { form } = useInvoiceForm(
|
|
37985
|
+
__spreadValues({ onSuccess }, mode === "Update" /* Update */ ? { mode, invoice: props.invoice } : { mode })
|
|
37986
|
+
);
|
|
37987
|
+
return /* @__PURE__ */ (0, import_jsx_runtime338.jsxs)(Form, { className: INVOICE_FORM_CSS_PREFIX, children: [
|
|
37988
|
+
/* @__PURE__ */ (0, import_jsx_runtime338.jsxs)(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__Metadata`, gap: "xs", children: [
|
|
37989
|
+
/* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
|
|
37990
|
+
form.Field,
|
|
37991
|
+
{
|
|
37992
|
+
name: "customer",
|
|
37993
|
+
listeners: {
|
|
37994
|
+
onChange: ({ value: customer }) => {
|
|
37995
|
+
form.setFieldValue("email", customer == null ? void 0 : customer.email);
|
|
37996
|
+
form.setFieldValue("address", customer == null ? void 0 : customer.addressString);
|
|
37997
|
+
}
|
|
37998
|
+
},
|
|
37999
|
+
children: (field) => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
|
|
38000
|
+
CustomerSelector,
|
|
38001
|
+
{
|
|
38002
|
+
className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Customer`,
|
|
38003
|
+
selectedCustomer: field.state.value,
|
|
38004
|
+
onSelectedCustomerChange: field.handleChange,
|
|
38005
|
+
inline: true
|
|
38006
|
+
}
|
|
38007
|
+
)
|
|
38008
|
+
}
|
|
38009
|
+
),
|
|
38010
|
+
/* @__PURE__ */ (0, import_jsx_runtime338.jsx)(form.AppField, { name: "email", children: (field) => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(field.FormTextField, { slotProps: { BaseFormTextField: { label: "Email", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Email` } } }) }),
|
|
38011
|
+
/* @__PURE__ */ (0, import_jsx_runtime338.jsx)(form.AppField, { name: "address", children: (field) => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(field.FormTextAreaField, { slotProps: { BaseFormTextField: { label: "Billing address", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Address` } } }) })
|
|
38012
|
+
] }),
|
|
38013
|
+
/* @__PURE__ */ (0, import_jsx_runtime338.jsx)(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__LineItems`, gap: "xs", children: /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(form.AppField, { name: "lineItems", mode: "array", children: (field) => /* @__PURE__ */ (0, import_jsx_runtime338.jsxs)(VStack, { gap: "xs", align: "baseline", children: [
|
|
38014
|
+
field.state.value.map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime338.jsxs)(HStack, { gap: "xs", align: "end", className: `${INVOICE_FORM_CSS_PREFIX}__LineItem`, children: [
|
|
38015
|
+
/* @__PURE__ */ (0, import_jsx_runtime338.jsx)(form.AppField, { name: `lineItems[${index}].product`, children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(innerField.FormTextField, { slotProps: { BaseFormTextField: { label: "Product", showLabel: index === 0 } } }) }),
|
|
38016
|
+
/* @__PURE__ */ (0, import_jsx_runtime338.jsx)(form.AppField, { name: `lineItems[${index}].description`, children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(innerField.FormTextField, { slotProps: { BaseFormTextField: { label: "Description", showLabel: index === 0 } } }) }),
|
|
38017
|
+
/* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
|
|
38018
|
+
form.AppField,
|
|
38019
|
+
{
|
|
38020
|
+
name: `lineItems[${index}].quantity`,
|
|
38021
|
+
listeners: {
|
|
38022
|
+
onBlur: ({ value: quantity }) => {
|
|
38023
|
+
const unitPrice = form.getFieldValue(`lineItems[${index}].unitPrice`);
|
|
38024
|
+
const nextAmount = import_effect15.BigDecimal.multiply(convertCentsToBigDecimal(unitPrice), quantity);
|
|
38025
|
+
form.setFieldValue(`lineItems[${index}].amount`, convertBigDecimalToCents(nextAmount));
|
|
38026
|
+
}
|
|
38027
|
+
},
|
|
38028
|
+
children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(innerField.FormBigDecimalField, { slotProps: { BaseFormTextField: { label: "Quantity", showLabel: index === 0 } } })
|
|
38029
|
+
}
|
|
38030
|
+
),
|
|
38031
|
+
/* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
|
|
38032
|
+
form.AppField,
|
|
38033
|
+
{
|
|
38034
|
+
name: `lineItems[${index}].unitPrice`,
|
|
38035
|
+
listeners: {
|
|
38036
|
+
onBlur: ({ value: unitPrice }) => {
|
|
38037
|
+
const quantity = form.getFieldValue(`lineItems[${index}].quantity`);
|
|
38038
|
+
const nextAmount = import_effect15.BigDecimal.multiply(convertCentsToBigDecimal(unitPrice), quantity);
|
|
38039
|
+
form.setFieldValue(`lineItems[${index}].amount`, convertBigDecimalToCents(nextAmount));
|
|
38040
|
+
}
|
|
38041
|
+
},
|
|
38042
|
+
children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(innerField.FormCurrencyField, { slotProps: { BaseFormTextField: { label: "Rate", showLabel: index === 0 } } })
|
|
38043
|
+
}
|
|
38044
|
+
),
|
|
38045
|
+
/* @__PURE__ */ (0, import_jsx_runtime338.jsx)(
|
|
38046
|
+
form.AppField,
|
|
38047
|
+
{
|
|
38048
|
+
name: `lineItems[${index}].amount`,
|
|
38049
|
+
listeners: {
|
|
38050
|
+
onBlur: ({ value: amount }) => {
|
|
38051
|
+
const quantity = form.getFieldValue(`lineItems[${index}].quantity`);
|
|
38052
|
+
let nextUnitPrice = BIG_DECIMAL_ZERO;
|
|
38053
|
+
try {
|
|
38054
|
+
nextUnitPrice = import_effect15.BigDecimal.unsafeDivide(convertCentsToBigDecimal(amount), quantity);
|
|
38055
|
+
} catch (e) {
|
|
38056
|
+
}
|
|
38057
|
+
form.setFieldValue(`lineItems[${index}].unitPrice`, convertBigDecimalToCents(nextUnitPrice));
|
|
38058
|
+
}
|
|
38059
|
+
},
|
|
38060
|
+
children: (innerField) => /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(innerField.FormCurrencyField, { slotProps: { BaseFormTextField: { label: "Amount", showLabel: index === 0 } } })
|
|
38061
|
+
}
|
|
38062
|
+
),
|
|
38063
|
+
/* @__PURE__ */ (0, import_jsx_runtime338.jsx)(Button2, { variant: "outlined", icon: true, "aria-label": "Delete line item", onClick: () => field.removeValue(index), children: /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(import_lucide_react16.Trash, { size: 16 }) })
|
|
38064
|
+
] }, `lineItems[${index}]`)),
|
|
38065
|
+
/* @__PURE__ */ (0, import_jsx_runtime338.jsxs)(Button2, { variant: "outlined", onClick: () => field.pushValue(EMPTY_LINE_ITEM), children: [
|
|
38066
|
+
"Add line item",
|
|
38067
|
+
/* @__PURE__ */ (0, import_jsx_runtime338.jsx)(import_lucide_react16.Plus, { size: 16 })
|
|
38068
|
+
] })
|
|
38069
|
+
] }) }) })
|
|
38070
|
+
] });
|
|
38071
|
+
};
|
|
38072
|
+
|
|
38073
|
+
// src/components/DataPoint/DataPoint.tsx
|
|
38074
|
+
var import_jsx_runtime339 = require("react/jsx-runtime");
|
|
38075
|
+
var DataPoint = ({ label, children }) => {
|
|
38076
|
+
return /* @__PURE__ */ (0, import_jsx_runtime339.jsxs)(VStack, { gap: "3xs", children: [
|
|
38077
|
+
/* @__PURE__ */ (0, import_jsx_runtime339.jsx)(Span, { variant: "subtle", size: "xs", children: label }),
|
|
38078
|
+
children
|
|
38079
|
+
] });
|
|
38080
|
+
};
|
|
38081
|
+
|
|
38082
|
+
// src/components/Invoices/InvoiceStatusCell/InvoiceStatusCell.tsx
|
|
38083
|
+
var import_pluralize6 = __toESM(require("pluralize"));
|
|
38084
|
+
var import_jsx_runtime340 = require("react/jsx-runtime");
|
|
38085
|
+
var getDueStatusConfig = (invoice, { inline }) => {
|
|
38086
|
+
const badgeSize = inline ? "xs" /* EXTRA_SMALL */ : "small" /* SMALL */;
|
|
38087
|
+
const iconSize = inline ? 10 : 12;
|
|
38088
|
+
switch (invoice.status) {
|
|
38089
|
+
case "WRITTEN_OFF" /* WrittenOff */: {
|
|
38090
|
+
return { text: "Written Off" };
|
|
38091
|
+
}
|
|
38092
|
+
case "PARTIALLY_WRITTEN_OFF" /* PartiallyWrittenOff */: {
|
|
38093
|
+
return { text: "Partially Written Off" };
|
|
38094
|
+
}
|
|
38095
|
+
case "PAID" /* Paid */: {
|
|
38096
|
+
return {
|
|
38097
|
+
text: "Paid",
|
|
38098
|
+
badge: /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(Badge, { variant: "success" /* SUCCESS */, size: badgeSize, icon: /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(CheckCircle_default, { size: iconSize }), iconOnly: true })
|
|
38099
|
+
};
|
|
38100
|
+
}
|
|
38101
|
+
case "VOIDED" /* Voided */: {
|
|
38102
|
+
return { text: "Voided" };
|
|
38103
|
+
}
|
|
38104
|
+
case "SENT" /* Sent */:
|
|
38105
|
+
case "PARTIALLY_PAID" /* PartiallyPaid */: {
|
|
38106
|
+
if (invoice.dueAt === null) {
|
|
38107
|
+
return {
|
|
38108
|
+
text: invoice.status === "PARTIALLY_PAID" /* PartiallyPaid */ ? "Partially Paid" : "Sent"
|
|
38109
|
+
};
|
|
38110
|
+
}
|
|
38111
|
+
const dueDifference = getDueDifference(invoice.dueAt);
|
|
38112
|
+
if (dueDifference === 0) {
|
|
38113
|
+
return {
|
|
38114
|
+
text: "Due Today"
|
|
38115
|
+
};
|
|
38116
|
+
}
|
|
38117
|
+
if (dueDifference < 0) {
|
|
38118
|
+
return {
|
|
38119
|
+
text: "Overdue",
|
|
38120
|
+
subText: `Due ${(0, import_pluralize6.default)("day", Math.abs(dueDifference), true)} ago`,
|
|
38121
|
+
badge: /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(Badge, { variant: "warning" /* WARNING */, size: badgeSize, icon: /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(AlertCircle_default, { size: iconSize }), iconOnly: true })
|
|
38122
|
+
};
|
|
38123
|
+
}
|
|
38124
|
+
return {
|
|
38125
|
+
text: "Sent",
|
|
38126
|
+
subText: `Due in ${(0, import_pluralize6.default)("day", Math.abs(dueDifference), true)}`
|
|
38127
|
+
};
|
|
38128
|
+
}
|
|
38129
|
+
default: {
|
|
38130
|
+
unsafeAssertUnreachable({
|
|
38131
|
+
value: invoice.status,
|
|
38132
|
+
message: "Unexpected invoice status"
|
|
38133
|
+
});
|
|
38134
|
+
}
|
|
38135
|
+
}
|
|
38136
|
+
};
|
|
38137
|
+
var InvoiceStatusCell = ({ invoice, inline = false }) => {
|
|
38138
|
+
const dueStatus = getDueStatusConfig(invoice, { inline });
|
|
38139
|
+
const Stack3 = inline ? HStack : VStack;
|
|
38140
|
+
const subText = inline && dueStatus.subText ? `(${dueStatus.subText})` : dueStatus.subText;
|
|
38141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime340.jsxs)(HStack, { gap: "xs", align: "center", children: [
|
|
38142
|
+
dueStatus.badge,
|
|
38143
|
+
/* @__PURE__ */ (0, import_jsx_runtime340.jsxs)(Stack3, __spreadProps(__spreadValues({}, inline && { gap: "3xs", align: "center" }), { children: [
|
|
38144
|
+
/* @__PURE__ */ (0, import_jsx_runtime340.jsx)(Span, { children: dueStatus.text }),
|
|
38145
|
+
subText && /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(Span, { variant: "subtle", size: "sm", children: subText })
|
|
38146
|
+
] }))
|
|
38147
|
+
] });
|
|
38148
|
+
};
|
|
38149
|
+
|
|
38150
|
+
// src/components/Invoices/InvoiceDetail/InvoiceDetail.tsx
|
|
38151
|
+
var import_jsx_runtime341 = require("react/jsx-runtime");
|
|
38152
|
+
var InvoiceDetail = (props) => {
|
|
38153
|
+
const _a = props, { onSuccess: _onSuccess, onGoBack } = _a, restProps = __objRest(_a, ["onSuccess", "onGoBack"]);
|
|
38154
|
+
const Header6 = (0, import_react231.useCallback)(() => {
|
|
38155
|
+
return /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(InvoiceDetailHeader, __spreadValues({}, restProps));
|
|
38156
|
+
}, [restProps]);
|
|
38157
|
+
return /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(BaseDetailView, { slots: { Header: Header6 }, name: "Invoice Detail View", onGoBack, children: [
|
|
38158
|
+
restProps.mode === "Update" /* Update */ && /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(InvoiceDetailSubHeader, { invoice: restProps.invoice }),
|
|
38159
|
+
/* @__PURE__ */ (0, import_jsx_runtime341.jsx)(InvoiceForm, __spreadValues({}, props))
|
|
38160
|
+
] });
|
|
38161
|
+
};
|
|
38162
|
+
var InvoiceDetailHeader = (props) => {
|
|
38163
|
+
const { mode } = props;
|
|
38164
|
+
if (mode === "Create" /* Create */) {
|
|
38165
|
+
return /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(Heading2, { children: "Create Invoice" });
|
|
38166
|
+
}
|
|
38167
|
+
const invoice = props.invoice;
|
|
38168
|
+
const { invoiceNumber } = invoice;
|
|
38169
|
+
return /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(Heading2, { children: invoiceNumber ? `Invoice ${invoiceNumber}` : "View Invoice" });
|
|
38170
|
+
};
|
|
38171
|
+
var InvoiceDetailSubHeader = ({ invoice }) => {
|
|
38172
|
+
const { outstandingBalance, totalAmount } = invoice;
|
|
38173
|
+
return /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(HStack, { className: "Layer__InvoiceDetail__SubHeader", children: /* @__PURE__ */ (0, import_jsx_runtime341.jsxs)(HStack, { gap: "5xl", children: [
|
|
38174
|
+
/* @__PURE__ */ (0, import_jsx_runtime341.jsx)(DataPoint, { label: "Balance due", children: /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(Span, { children: convertCentsToCurrency(outstandingBalance) }) }),
|
|
38175
|
+
/* @__PURE__ */ (0, import_jsx_runtime341.jsx)(DataPoint, { label: "Open balance", children: /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(Span, { children: convertCentsToCurrency(totalAmount) }) }),
|
|
38176
|
+
/* @__PURE__ */ (0, import_jsx_runtime341.jsx)(DataPoint, { label: "Status", children: /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(InvoiceStatusCell, { invoice, inline: true }) })
|
|
38177
|
+
] }) });
|
|
38178
|
+
};
|
|
38179
|
+
|
|
38180
|
+
// src/components/Invoices/InvoicesTable/InvoicesTable.tsx
|
|
38181
|
+
var import_react236 = require("react");
|
|
38182
|
+
|
|
38183
|
+
// src/features/invoices/api/useListInvoices.tsx
|
|
38184
|
+
var import_infinite7 = __toESM(require("swr/infinite"));
|
|
38185
|
+
var import_react232 = require("react");
|
|
38186
|
+
var import_lodash6 = __toESM(require_lodash());
|
|
38187
|
+
var import_effect17 = require("effect");
|
|
38188
|
+
|
|
38189
|
+
// src/types/utility/pagination.ts
|
|
38190
|
+
var import_effect16 = require("effect");
|
|
38191
|
+
var PaginatedResponseMetaSchema = import_effect16.Schema.Struct({
|
|
38192
|
+
cursor: import_effect16.Schema.NullOr(import_effect16.Schema.String),
|
|
38193
|
+
hasMore: (0, import_effect16.pipe)(
|
|
38194
|
+
import_effect16.Schema.propertySignature(import_effect16.Schema.Boolean),
|
|
38195
|
+
import_effect16.Schema.fromKey("has_more")
|
|
38196
|
+
),
|
|
38197
|
+
totalCount: (0, import_effect16.pipe)(
|
|
38198
|
+
import_effect16.Schema.propertySignature(import_effect16.Schema.UndefinedOr(import_effect16.Schema.Number)),
|
|
38199
|
+
import_effect16.Schema.fromKey("total_count")
|
|
37388
38200
|
)
|
|
37389
38201
|
});
|
|
37390
38202
|
|
|
37391
38203
|
// src/features/invoices/api/useListInvoices.tsx
|
|
37392
38204
|
var LIST_INVOICES_TAG_KEY = "#list-invoices";
|
|
37393
|
-
var ListInvoicesReturnSchema =
|
|
37394
|
-
data:
|
|
37395
|
-
meta:
|
|
38205
|
+
var ListInvoicesReturnSchema = import_effect17.Schema.Struct({
|
|
38206
|
+
data: import_effect17.Schema.Array(InvoiceSchema),
|
|
38207
|
+
meta: import_effect17.Schema.Struct({
|
|
37396
38208
|
pagination: PaginatedResponseMetaSchema
|
|
37397
38209
|
})
|
|
37398
38210
|
});
|
|
@@ -37520,7 +38332,7 @@ function useListInvoices({
|
|
|
37520
38332
|
showTotalCount: showTotalCount2
|
|
37521
38333
|
}
|
|
37522
38334
|
}
|
|
37523
|
-
)().then(
|
|
38335
|
+
)().then(import_effect17.Schema.decodeUnknownPromise(ListInvoicesReturnSchema)),
|
|
37524
38336
|
{
|
|
37525
38337
|
keepPreviousData: true,
|
|
37526
38338
|
revalidateFirstPage: false,
|
|
@@ -37534,20 +38346,20 @@ function useListInvoices({
|
|
|
37534
38346
|
var import_react_table2 = require("@tanstack/react-table");
|
|
37535
38347
|
|
|
37536
38348
|
// src/components/DataTable/DataTable.tsx
|
|
37537
|
-
var
|
|
38349
|
+
var import_react234 = require("react");
|
|
37538
38350
|
|
|
37539
38351
|
// src/components/ui/Table/Table.tsx
|
|
37540
|
-
var
|
|
37541
|
-
var
|
|
37542
|
-
var
|
|
37543
|
-
var
|
|
38352
|
+
var import_react233 = require("react");
|
|
38353
|
+
var import_react_aria_components18 = require("react-aria-components");
|
|
38354
|
+
var import_classnames90 = __toESM(require("classnames"));
|
|
38355
|
+
var import_jsx_runtime342 = require("react/jsx-runtime");
|
|
37544
38356
|
var CSS_PREFIX2 = "Layer__UI__Table";
|
|
37545
|
-
var getClassName = (component, additionalClassNames) => (0,
|
|
37546
|
-
var Table2 = (0,
|
|
38357
|
+
var getClassName = (component, additionalClassNames) => (0, import_classnames90.default)(`${CSS_PREFIX2}-${component}`, additionalClassNames);
|
|
38358
|
+
var Table2 = (0, import_react233.forwardRef)(
|
|
37547
38359
|
(_a, ref) => {
|
|
37548
38360
|
var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
|
|
37549
|
-
return /* @__PURE__ */ (0,
|
|
37550
|
-
|
|
38361
|
+
return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(
|
|
38362
|
+
import_react_aria_components18.Table,
|
|
37551
38363
|
__spreadProps(__spreadValues({
|
|
37552
38364
|
className: getClassName("Table" /* Table */, className)
|
|
37553
38365
|
}, restProps), {
|
|
@@ -37560,8 +38372,8 @@ var Table2 = (0, import_react221.forwardRef)(
|
|
|
37560
38372
|
Table2.displayName = "Table" /* Table */;
|
|
37561
38373
|
var TableHeaderInner = (_a, ref) => {
|
|
37562
38374
|
var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
|
|
37563
|
-
return /* @__PURE__ */ (0,
|
|
37564
|
-
|
|
38375
|
+
return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(
|
|
38376
|
+
import_react_aria_components18.TableHeader,
|
|
37565
38377
|
__spreadProps(__spreadValues({
|
|
37566
38378
|
className: getClassName("TableHeader" /* TableHeader */, className)
|
|
37567
38379
|
}, restProps), {
|
|
@@ -37570,12 +38382,12 @@ var TableHeaderInner = (_a, ref) => {
|
|
|
37570
38382
|
})
|
|
37571
38383
|
);
|
|
37572
38384
|
};
|
|
37573
|
-
var TableHeader = (0,
|
|
38385
|
+
var TableHeader = (0, import_react233.forwardRef)(TableHeaderInner);
|
|
37574
38386
|
TableHeader.displayName = "TableHeader" /* TableHeader */;
|
|
37575
38387
|
var TableBodyInner = (_a, ref) => {
|
|
37576
38388
|
var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
|
|
37577
|
-
return /* @__PURE__ */ (0,
|
|
37578
|
-
|
|
38389
|
+
return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(
|
|
38390
|
+
import_react_aria_components18.TableBody,
|
|
37579
38391
|
__spreadProps(__spreadValues({
|
|
37580
38392
|
className: getClassName("TableBody" /* TableBody */, className)
|
|
37581
38393
|
}, restProps), {
|
|
@@ -37584,12 +38396,12 @@ var TableBodyInner = (_a, ref) => {
|
|
|
37584
38396
|
})
|
|
37585
38397
|
);
|
|
37586
38398
|
};
|
|
37587
|
-
var TableBody2 = (0,
|
|
38399
|
+
var TableBody2 = (0, import_react233.forwardRef)(TableBodyInner);
|
|
37588
38400
|
TableBody2.displayName = "TableBody" /* TableBody */;
|
|
37589
38401
|
var RowInner = (_a, ref) => {
|
|
37590
38402
|
var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
|
|
37591
|
-
return /* @__PURE__ */ (0,
|
|
37592
|
-
|
|
38403
|
+
return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(
|
|
38404
|
+
import_react_aria_components18.Row,
|
|
37593
38405
|
__spreadProps(__spreadValues({
|
|
37594
38406
|
className: getClassName("Row" /* Row */, className)
|
|
37595
38407
|
}, restProps), {
|
|
@@ -37598,14 +38410,14 @@ var RowInner = (_a, ref) => {
|
|
|
37598
38410
|
})
|
|
37599
38411
|
);
|
|
37600
38412
|
};
|
|
37601
|
-
var Row2 = (0,
|
|
38413
|
+
var Row2 = (0, import_react233.forwardRef)(RowInner);
|
|
37602
38414
|
Row2.displayName = "Row" /* Row */;
|
|
37603
|
-
var Column = (0,
|
|
38415
|
+
var Column = (0, import_react233.forwardRef)(
|
|
37604
38416
|
(_a, ref) => {
|
|
37605
38417
|
var _b = _a, { children, className, textAlign = "left" } = _b, restProps = __objRest(_b, ["children", "className", "textAlign"]);
|
|
37606
38418
|
const dataProperties = toDataProperties({ "text-align": textAlign });
|
|
37607
|
-
return /* @__PURE__ */ (0,
|
|
37608
|
-
|
|
38419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(
|
|
38420
|
+
import_react_aria_components18.Column,
|
|
37609
38421
|
__spreadProps(__spreadValues(__spreadValues({
|
|
37610
38422
|
className: getClassName("Column" /* Column */, className)
|
|
37611
38423
|
}, restProps), dataProperties), {
|
|
@@ -37616,11 +38428,11 @@ var Column = (0, import_react221.forwardRef)(
|
|
|
37616
38428
|
}
|
|
37617
38429
|
);
|
|
37618
38430
|
Column.displayName = "Column" /* Column */;
|
|
37619
|
-
var Cell5 = (0,
|
|
38431
|
+
var Cell5 = (0, import_react233.forwardRef)(
|
|
37620
38432
|
(_a, ref) => {
|
|
37621
38433
|
var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
|
|
37622
|
-
return /* @__PURE__ */ (0,
|
|
37623
|
-
|
|
38434
|
+
return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(
|
|
38435
|
+
import_react_aria_components18.Cell,
|
|
37624
38436
|
__spreadProps(__spreadValues({
|
|
37625
38437
|
className: getClassName("Cell" /* Cell */, className)
|
|
37626
38438
|
}, restProps), {
|
|
@@ -37633,7 +38445,7 @@ var Cell5 = (0, import_react221.forwardRef)(
|
|
|
37633
38445
|
Cell5.displayName = "Cell" /* Cell */;
|
|
37634
38446
|
|
|
37635
38447
|
// src/components/DataTable/DataTable.tsx
|
|
37636
|
-
var
|
|
38448
|
+
var import_jsx_runtime343 = require("react/jsx-runtime");
|
|
37637
38449
|
var DataTable = ({
|
|
37638
38450
|
columnConfig,
|
|
37639
38451
|
data,
|
|
@@ -37643,19 +38455,20 @@ var DataTable = ({
|
|
|
37643
38455
|
ariaLabel,
|
|
37644
38456
|
slots
|
|
37645
38457
|
}) => {
|
|
37646
|
-
const
|
|
38458
|
+
const columns = Object.values(columnConfig);
|
|
37647
38459
|
const { EmptyState, ErrorState } = slots;
|
|
37648
|
-
const
|
|
38460
|
+
const isEmptyTable = (data == null ? void 0 : data.length) === 0;
|
|
38461
|
+
const renderTableBody = (0, import_react234.useMemo)(() => {
|
|
37649
38462
|
if (isError) {
|
|
37650
|
-
return /* @__PURE__ */ (0,
|
|
38463
|
+
return /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Row2, { children: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(ErrorState, {}) }) });
|
|
37651
38464
|
}
|
|
37652
38465
|
if (isLoading) {
|
|
37653
|
-
return /* @__PURE__ */ (0,
|
|
38466
|
+
return /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Row2, { children: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Loader2, {}) }) });
|
|
37654
38467
|
}
|
|
37655
|
-
if (
|
|
37656
|
-
return /* @__PURE__ */ (0,
|
|
38468
|
+
if (isEmptyTable) {
|
|
38469
|
+
return /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Row2, { children: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(EmptyState, {}) }) });
|
|
37657
38470
|
}
|
|
37658
|
-
const RowRenderer = (row) => /* @__PURE__ */ (0,
|
|
38471
|
+
const RowRenderer = (row) => /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Row2, { children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(
|
|
37659
38472
|
Cell5,
|
|
37660
38473
|
{
|
|
37661
38474
|
className: `Layer__UI__Table-Cell__${componentName}--${col.id}`,
|
|
@@ -37665,16 +38478,16 @@ var DataTable = ({
|
|
|
37665
38478
|
)) }, row.id);
|
|
37666
38479
|
RowRenderer.displayName = "Row";
|
|
37667
38480
|
return RowRenderer;
|
|
37668
|
-
}, [isLoading,
|
|
37669
|
-
return /* @__PURE__ */ (0,
|
|
37670
|
-
/* @__PURE__ */ (0,
|
|
37671
|
-
/* @__PURE__ */ (0,
|
|
38481
|
+
}, [isError, isLoading, isEmptyTable, columns, ErrorState, EmptyState, componentName]);
|
|
38482
|
+
return /* @__PURE__ */ (0, import_jsx_runtime343.jsxs)(Table2, { "aria-label": ariaLabel, className: `Layer__UI__Table__${componentName}`, children: [
|
|
38483
|
+
/* @__PURE__ */ (0, import_jsx_runtime343.jsx)(TableHeader, { columns, children: ({ id, header, isRowHeader }) => /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(Column, { isRowHeader, className: `Layer__UI__Table-Column__${componentName}--${id}`, children: header }, id) }),
|
|
38484
|
+
/* @__PURE__ */ (0, import_jsx_runtime343.jsx)(TableBody2, { items: data, children: renderTableBody })
|
|
37672
38485
|
] });
|
|
37673
38486
|
};
|
|
37674
38487
|
|
|
37675
38488
|
// src/components/DataTable/PaginatedTable.tsx
|
|
37676
|
-
var
|
|
37677
|
-
var
|
|
38489
|
+
var import_react235 = require("react");
|
|
38490
|
+
var import_jsx_runtime344 = require("react/jsx-runtime");
|
|
37678
38491
|
var EMPTY_ARRAY = [];
|
|
37679
38492
|
function PaginatedTable({
|
|
37680
38493
|
data,
|
|
@@ -37687,10 +38500,10 @@ function PaginatedTable({
|
|
|
37687
38500
|
slots
|
|
37688
38501
|
}) {
|
|
37689
38502
|
const { pageSize = 20, hasMore, fetchMore } = paginationProps;
|
|
37690
|
-
const [pagination, setPagination] = (0,
|
|
38503
|
+
const [pagination, setPagination] = (0, import_react235.useState)({ pageIndex: 0, pageSize });
|
|
37691
38504
|
const columnHelper = (0, import_react_table2.createColumnHelper)();
|
|
37692
|
-
const
|
|
37693
|
-
const columnDefs =
|
|
38505
|
+
const columns = Object.values(columnConfig);
|
|
38506
|
+
const columnDefs = columns.map((col) => {
|
|
37694
38507
|
return columnHelper.display({
|
|
37695
38508
|
id: col.id,
|
|
37696
38509
|
header: () => col.header,
|
|
@@ -37707,12 +38520,12 @@ function PaginatedTable({
|
|
|
37707
38520
|
autoResetPageIndex: false
|
|
37708
38521
|
});
|
|
37709
38522
|
const { rows } = table.getRowModel();
|
|
37710
|
-
const rowData = (0,
|
|
37711
|
-
const onPageChange = (0,
|
|
38523
|
+
const rowData = (0, import_react235.useMemo)(() => rows.map((r) => r.original), [rows]);
|
|
38524
|
+
const onPageChange = (0, import_react235.useCallback)((page) => {
|
|
37712
38525
|
table.setPageIndex(page - 1);
|
|
37713
38526
|
}, [table]);
|
|
37714
|
-
return /* @__PURE__ */ (0,
|
|
37715
|
-
/* @__PURE__ */ (0,
|
|
38527
|
+
return /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)(VStack, { children: [
|
|
38528
|
+
/* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
|
|
37716
38529
|
DataTable,
|
|
37717
38530
|
{
|
|
37718
38531
|
ariaLabel,
|
|
@@ -37724,7 +38537,7 @@ function PaginatedTable({
|
|
|
37724
38537
|
slots
|
|
37725
38538
|
}
|
|
37726
38539
|
),
|
|
37727
|
-
!isError && !isLoading && /* @__PURE__ */ (0,
|
|
38540
|
+
!isError && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
|
|
37728
38541
|
Pagination,
|
|
37729
38542
|
{
|
|
37730
38543
|
currentPage: table.getState().pagination.pageIndex + 1,
|
|
@@ -37738,14 +38551,11 @@ function PaginatedTable({
|
|
|
37738
38551
|
] });
|
|
37739
38552
|
}
|
|
37740
38553
|
|
|
37741
|
-
// src/components/Invoices/InvoicesTable.tsx
|
|
37742
|
-
var import_pluralize6 = __toESM(require("pluralize"));
|
|
37743
|
-
|
|
37744
38554
|
// src/icons/ChevronRightFill.tsx
|
|
37745
|
-
var
|
|
38555
|
+
var import_jsx_runtime345 = require("react/jsx-runtime");
|
|
37746
38556
|
var ChevronRightFill = (_a) => {
|
|
37747
38557
|
var _b = _a, { size = 18 } = _b, props = __objRest(_b, ["size"]);
|
|
37748
|
-
return /* @__PURE__ */ (0,
|
|
38558
|
+
return /* @__PURE__ */ (0, import_jsx_runtime345.jsxs)(
|
|
37749
38559
|
"svg",
|
|
37750
38560
|
__spreadProps(__spreadValues({
|
|
37751
38561
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -37755,8 +38565,8 @@ var ChevronRightFill = (_a) => {
|
|
|
37755
38565
|
width: size,
|
|
37756
38566
|
height: size,
|
|
37757
38567
|
children: [
|
|
37758
|
-
/* @__PURE__ */ (0,
|
|
37759
|
-
/* @__PURE__ */ (0,
|
|
38568
|
+
/* @__PURE__ */ (0, import_jsx_runtime345.jsx)("path", { d: "M6.75 4.5L11.25 9L6.75 13.5", fill: "currentColor" }),
|
|
38569
|
+
/* @__PURE__ */ (0, import_jsx_runtime345.jsx)(
|
|
37760
38570
|
"path",
|
|
37761
38571
|
{
|
|
37762
38572
|
d: "M6.75 4.5L11.25 9L6.75 13.5Z",
|
|
@@ -37771,38 +38581,38 @@ var ChevronRightFill = (_a) => {
|
|
|
37771
38581
|
};
|
|
37772
38582
|
var ChevronRightFill_default = ChevronRightFill;
|
|
37773
38583
|
|
|
37774
|
-
// src/components/Invoices/InvoicesTable.tsx
|
|
37775
|
-
var
|
|
38584
|
+
// src/components/Invoices/InvoicesTable/InvoicesTable.tsx
|
|
38585
|
+
var import_lucide_react17 = require("lucide-react");
|
|
37776
38586
|
|
|
37777
38587
|
// src/components/DataTable/DataTableHeader.tsx
|
|
37778
|
-
var
|
|
38588
|
+
var import_jsx_runtime346 = require("react/jsx-runtime");
|
|
37779
38589
|
var DataTableHeader = ({ name, count, slotProps = {}, slots = {} }) => {
|
|
37780
38590
|
const { showCount, totalCount } = count != null ? count : {};
|
|
37781
38591
|
const { Filters: Filters2, HeaderActions, HeaderFilters } = slots;
|
|
37782
|
-
return /* @__PURE__ */ (0,
|
|
37783
|
-
/* @__PURE__ */ (0,
|
|
37784
|
-
/* @__PURE__ */ (0,
|
|
37785
|
-
/* @__PURE__ */ (0,
|
|
37786
|
-
/* @__PURE__ */ (0,
|
|
37787
|
-
showCount && (totalCount ? /* @__PURE__ */ (0,
|
|
38592
|
+
return /* @__PURE__ */ (0, import_jsx_runtime346.jsxs)(VStack, { children: [
|
|
38593
|
+
/* @__PURE__ */ (0, import_jsx_runtime346.jsxs)(HStack, { justify: "space-between", align: "center", className: "Layer__DataTableHeader__Header", children: [
|
|
38594
|
+
/* @__PURE__ */ (0, import_jsx_runtime346.jsxs)(HStack, { pis: "md", align: "center", gap: "xl", children: [
|
|
38595
|
+
/* @__PURE__ */ (0, import_jsx_runtime346.jsxs)(HStack, { align: "center", gap: "sm", children: [
|
|
38596
|
+
/* @__PURE__ */ (0, import_jsx_runtime346.jsx)(Span, { weight: "bold", size: "lg", children: name }),
|
|
38597
|
+
showCount && (totalCount ? /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(Badge, { variant: "default" /* DEFAULT */, size: "medium" /* MEDIUM */, children: totalCount }) : /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(BadgeLoader, {}))
|
|
37788
38598
|
] }),
|
|
37789
|
-
HeaderFilters && /* @__PURE__ */ (0,
|
|
38599
|
+
HeaderFilters && /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(HeaderFilters, {})
|
|
37790
38600
|
] }),
|
|
37791
|
-
/* @__PURE__ */ (0,
|
|
37792
|
-
slotProps.SearchField && /* @__PURE__ */ (0,
|
|
37793
|
-
HeaderActions && /* @__PURE__ */ (0,
|
|
38601
|
+
/* @__PURE__ */ (0, import_jsx_runtime346.jsxs)(HStack, { pie: "md", align: "center", gap: "3xs", children: [
|
|
38602
|
+
slotProps.SearchField && /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(SearchField, __spreadValues({}, slotProps.SearchField)),
|
|
38603
|
+
HeaderActions && /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(HeaderActions, {})
|
|
37794
38604
|
] })
|
|
37795
38605
|
] }),
|
|
37796
|
-
Filters2 && /* @__PURE__ */ (0,
|
|
37797
|
-
/* @__PURE__ */ (0,
|
|
37798
|
-
slotProps.ClearFiltersButton && /* @__PURE__ */ (0,
|
|
38606
|
+
Filters2 && /* @__PURE__ */ (0, import_jsx_runtime346.jsxs)(HStack, { pis: "md", pie: "md", justify: "space-between", align: "center", className: "Layer__DataTableHeader__Filters", children: [
|
|
38607
|
+
/* @__PURE__ */ (0, import_jsx_runtime346.jsx)(Filters2, {}),
|
|
38608
|
+
slotProps.ClearFiltersButton && /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(Button2, __spreadProps(__spreadValues({ variant: "outlined" }, slotProps.ClearFiltersButton), { children: "Clear All Filters" }))
|
|
37799
38609
|
] })
|
|
37800
38610
|
] });
|
|
37801
38611
|
};
|
|
37802
38612
|
|
|
37803
|
-
// src/components/Invoices/InvoicesTable.tsx
|
|
38613
|
+
// src/components/Invoices/InvoicesTable/InvoicesTable.tsx
|
|
37804
38614
|
var import_date_fns51 = require("date-fns");
|
|
37805
|
-
var
|
|
38615
|
+
var import_jsx_runtime347 = require("react/jsx-runtime");
|
|
37806
38616
|
var COMPONENT_NAME10 = "InvoicesTable";
|
|
37807
38617
|
var InvoiceStatusOptionConfig = {
|
|
37808
38618
|
["All" /* All */]: { label: "All", value: "All" /* All */ },
|
|
@@ -37823,12 +38633,12 @@ var AmountCell = ({ invoice }) => {
|
|
|
37823
38633
|
case "WRITTEN_OFF" /* WrittenOff */:
|
|
37824
38634
|
case "VOIDED" /* Voided */:
|
|
37825
38635
|
case "SENT" /* Sent */: {
|
|
37826
|
-
return /* @__PURE__ */ (0,
|
|
38636
|
+
return /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(VStack, { children: /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(Span, { align: "right", children: totalAmount }) });
|
|
37827
38637
|
}
|
|
37828
38638
|
case "PARTIALLY_PAID" /* PartiallyPaid */: {
|
|
37829
|
-
return /* @__PURE__ */ (0,
|
|
37830
|
-
/* @__PURE__ */ (0,
|
|
37831
|
-
/* @__PURE__ */ (0,
|
|
38639
|
+
return /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(VStack, { children: [
|
|
38640
|
+
/* @__PURE__ */ (0, import_jsx_runtime347.jsx)(Span, { align: "right", children: totalAmount }),
|
|
38641
|
+
/* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(Span, { align: "right", variant: "subtle", size: "sm", children: [
|
|
37832
38642
|
outstandingBalance,
|
|
37833
38643
|
" ",
|
|
37834
38644
|
"outstanding"
|
|
@@ -37843,71 +38653,11 @@ var AmountCell = ({ invoice }) => {
|
|
|
37843
38653
|
}
|
|
37844
38654
|
}
|
|
37845
38655
|
};
|
|
37846
|
-
var
|
|
37847
|
-
switch (invoice.status) {
|
|
37848
|
-
case "WRITTEN_OFF" /* WrittenOff */: {
|
|
37849
|
-
return { text: "Written Off" };
|
|
37850
|
-
}
|
|
37851
|
-
case "PARTIALLY_WRITTEN_OFF" /* PartiallyWrittenOff */: {
|
|
37852
|
-
return { text: "Partially Written Off" };
|
|
37853
|
-
}
|
|
37854
|
-
case "PAID" /* Paid */: {
|
|
37855
|
-
return {
|
|
37856
|
-
text: "Paid",
|
|
37857
|
-
badge: /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(Badge, { variant: "success" /* SUCCESS */, size: "small" /* SMALL */, icon: /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(CheckCircle_default, { size: 12 }), iconOnly: true })
|
|
37858
|
-
};
|
|
37859
|
-
}
|
|
37860
|
-
case "VOIDED" /* Voided */: {
|
|
37861
|
-
return { text: "Voided" };
|
|
37862
|
-
}
|
|
37863
|
-
case "SENT" /* Sent */:
|
|
37864
|
-
case "PARTIALLY_PAID" /* PartiallyPaid */: {
|
|
37865
|
-
if (invoice.dueAt === null) {
|
|
37866
|
-
return {
|
|
37867
|
-
text: invoice.status === "PARTIALLY_PAID" /* PartiallyPaid */ ? "Partially Paid" : "Sent"
|
|
37868
|
-
};
|
|
37869
|
-
}
|
|
37870
|
-
const dueDifference = getDueDifference(invoice.dueAt);
|
|
37871
|
-
if (dueDifference === 0) {
|
|
37872
|
-
return {
|
|
37873
|
-
text: "Due Today"
|
|
37874
|
-
};
|
|
37875
|
-
}
|
|
37876
|
-
if (dueDifference < 0) {
|
|
37877
|
-
return {
|
|
37878
|
-
text: "Overdue",
|
|
37879
|
-
subText: `Due ${(0, import_pluralize6.default)("day", Math.abs(dueDifference), true)} ago`,
|
|
37880
|
-
badge: /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(Badge, { variant: "warning" /* WARNING */, size: "small" /* SMALL */, icon: /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(AlertCircle_default, { size: 12 }), iconOnly: true })
|
|
37881
|
-
};
|
|
37882
|
-
}
|
|
37883
|
-
return {
|
|
37884
|
-
text: "Sent",
|
|
37885
|
-
subText: `Due in ${(0, import_pluralize6.default)("day", Math.abs(dueDifference), true)}`
|
|
37886
|
-
};
|
|
37887
|
-
}
|
|
37888
|
-
default: {
|
|
37889
|
-
unsafeAssertUnreachable({
|
|
37890
|
-
value: invoice.status,
|
|
37891
|
-
message: "Unexpected invoice status"
|
|
37892
|
-
});
|
|
37893
|
-
}
|
|
37894
|
-
}
|
|
37895
|
-
};
|
|
37896
|
-
var StatusCell = ({ invoice }) => {
|
|
37897
|
-
const dueStatus = getDueStatusConfig(invoice);
|
|
37898
|
-
return /* @__PURE__ */ (0, import_jsx_runtime332.jsxs)(HStack, { gap: "xs", align: "center", children: [
|
|
37899
|
-
dueStatus.badge,
|
|
37900
|
-
/* @__PURE__ */ (0, import_jsx_runtime332.jsxs)(VStack, { children: [
|
|
37901
|
-
/* @__PURE__ */ (0, import_jsx_runtime332.jsx)(Span, { children: dueStatus.text }),
|
|
37902
|
-
/* @__PURE__ */ (0, import_jsx_runtime332.jsx)(Span, { variant: "subtle", size: "sm", children: dueStatus.subText })
|
|
37903
|
-
] })
|
|
37904
|
-
] });
|
|
37905
|
-
};
|
|
37906
|
-
var getCustomerName = (invoice) => {
|
|
38656
|
+
var getCustomerName2 = (invoice) => {
|
|
37907
38657
|
const { recipientName, customer } = invoice;
|
|
37908
38658
|
return recipientName || (customer == null ? void 0 : customer.individualName) || (customer == null ? void 0 : customer.companyName);
|
|
37909
38659
|
};
|
|
37910
|
-
var
|
|
38660
|
+
var getColumnConfig = (onSelectInvoice) => ({
|
|
37911
38661
|
["SentAt" /* SentAt */]: {
|
|
37912
38662
|
id: "SentAt" /* SentAt */,
|
|
37913
38663
|
header: "Sent Date",
|
|
@@ -37922,35 +38672,35 @@ var columns = {
|
|
|
37922
38672
|
["Customer" /* Customer */]: {
|
|
37923
38673
|
id: "Customer" /* Customer */,
|
|
37924
38674
|
header: "Customer",
|
|
37925
|
-
cell: (row) =>
|
|
38675
|
+
cell: (row) => getCustomerName2(row)
|
|
37926
38676
|
},
|
|
37927
38677
|
["Total" /* Total */]: {
|
|
37928
38678
|
id: "Total" /* Total */,
|
|
37929
38679
|
header: "Amount",
|
|
37930
|
-
cell: (row) => /* @__PURE__ */ (0,
|
|
38680
|
+
cell: (row) => /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(AmountCell, { invoice: row })
|
|
37931
38681
|
},
|
|
37932
38682
|
["Status" /* Status */]: {
|
|
37933
38683
|
id: "Status" /* Status */,
|
|
37934
38684
|
header: "Status",
|
|
37935
|
-
cell: (row) => /* @__PURE__ */ (0,
|
|
38685
|
+
cell: (row) => /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(InvoiceStatusCell, { invoice: row })
|
|
37936
38686
|
},
|
|
37937
38687
|
["Expand" /* Expand */]: {
|
|
37938
38688
|
id: "Expand" /* Expand */,
|
|
37939
|
-
cell: (
|
|
38689
|
+
cell: (row) => /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(Button2, { inset: true, icon: true, onPress: () => onSelectInvoice(row), "aria-label": "View invoice", variant: "ghost", children: /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(ChevronRightFill_default, {}) })
|
|
37940
38690
|
}
|
|
37941
|
-
};
|
|
37942
|
-
var
|
|
38691
|
+
});
|
|
38692
|
+
var UNPAID_STATUSES2 = ["SENT" /* Sent */, "PARTIALLY_PAID" /* PartiallyPaid */];
|
|
37943
38693
|
var getListInvoiceParams = ({ statusFilter }) => {
|
|
37944
38694
|
if (!statusFilter) return {};
|
|
37945
38695
|
switch (statusFilter) {
|
|
37946
38696
|
case "All" /* All */:
|
|
37947
38697
|
return {};
|
|
37948
38698
|
case "Unpaid" /* Unpaid */:
|
|
37949
|
-
return { status:
|
|
38699
|
+
return { status: UNPAID_STATUSES2 };
|
|
37950
38700
|
case "Overdue" /* Overdue */:
|
|
37951
|
-
return { status:
|
|
38701
|
+
return { status: UNPAID_STATUSES2, dueAtEnd: (0, import_date_fns51.endOfYesterday)() };
|
|
37952
38702
|
case "Sent" /* Sent */:
|
|
37953
|
-
return { status:
|
|
38703
|
+
return { status: UNPAID_STATUSES2, dueAtStart: (0, import_date_fns51.startOfToday)() };
|
|
37954
38704
|
case "Paid" /* Paid */:
|
|
37955
38705
|
return { status: ["PAID" /* Paid */, "PARTIALLY_WRITTEN_OFF" /* PartiallyWrittenOff */] };
|
|
37956
38706
|
case "Written Off" /* WrittenOff */:
|
|
@@ -37964,9 +38714,9 @@ var getListInvoiceParams = ({ statusFilter }) => {
|
|
|
37964
38714
|
});
|
|
37965
38715
|
}
|
|
37966
38716
|
};
|
|
37967
|
-
var InvoicesTable = () => {
|
|
37968
|
-
const [selectedInvoiceStatusOption, setSelectedInvoiceStatusOption] = (0,
|
|
37969
|
-
const listInvoiceParams = (0,
|
|
38717
|
+
var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
|
|
38718
|
+
const [selectedInvoiceStatusOption, setSelectedInvoiceStatusOption] = (0, import_react236.useState)(ALL_OPTION);
|
|
38719
|
+
const listInvoiceParams = (0, import_react236.useMemo)(
|
|
37970
38720
|
() => getListInvoiceParams({ statusFilter: selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.value }),
|
|
37971
38721
|
[selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.value]
|
|
37972
38722
|
);
|
|
@@ -37974,25 +38724,25 @@ var InvoicesTable = () => {
|
|
|
37974
38724
|
const invoices = data == null ? void 0 : data.flatMap(({ data: data2 }) => data2);
|
|
37975
38725
|
const paginationMeta = data == null ? void 0 : data[data.length - 1].meta.pagination;
|
|
37976
38726
|
const hasMore = paginationMeta == null ? void 0 : paginationMeta.hasMore;
|
|
37977
|
-
const fetchMore = (0,
|
|
38727
|
+
const fetchMore = (0, import_react236.useCallback)(() => {
|
|
37978
38728
|
if (hasMore) {
|
|
37979
38729
|
void setSize(size + 1);
|
|
37980
38730
|
}
|
|
37981
38731
|
}, [hasMore, setSize, size]);
|
|
37982
|
-
const paginationProps = (0,
|
|
38732
|
+
const paginationProps = (0, import_react236.useMemo)(() => {
|
|
37983
38733
|
return {
|
|
37984
38734
|
pageSize: 10,
|
|
37985
38735
|
hasMore,
|
|
37986
38736
|
fetchMore
|
|
37987
38737
|
};
|
|
37988
38738
|
}, [fetchMore, hasMore]);
|
|
37989
|
-
const options = (0,
|
|
37990
|
-
const SelectedValue = (0,
|
|
38739
|
+
const options = (0, import_react236.useMemo)(() => Object.values(InvoiceStatusOptionConfig), []);
|
|
38740
|
+
const SelectedValue = (0, import_react236.useMemo)(() => {
|
|
37991
38741
|
const label = selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.label;
|
|
37992
38742
|
return label ? `Status: ${label}` : "Status";
|
|
37993
38743
|
}, [selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.label]);
|
|
37994
|
-
const StatusFilter = (0,
|
|
37995
|
-
() => /* @__PURE__ */ (0,
|
|
38744
|
+
const StatusFilter = (0, import_react236.useCallback)(
|
|
38745
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(
|
|
37996
38746
|
ComboBox,
|
|
37997
38747
|
{
|
|
37998
38748
|
className: "Layer__InvoicesTable__StatusFilter",
|
|
@@ -38008,27 +38758,27 @@ var InvoicesTable = () => {
|
|
|
38008
38758
|
),
|
|
38009
38759
|
[SelectedValue, options, selectedInvoiceStatusOption]
|
|
38010
38760
|
);
|
|
38011
|
-
const CreateInvoiceButton = (0,
|
|
38012
|
-
() => /* @__PURE__ */ (0,
|
|
38761
|
+
const CreateInvoiceButton = (0, import_react236.useCallback)(
|
|
38762
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(Button2, { onPress: onCreateInvoice, children: [
|
|
38013
38763
|
"Create Invoice",
|
|
38014
|
-
/* @__PURE__ */ (0,
|
|
38764
|
+
/* @__PURE__ */ (0, import_jsx_runtime347.jsx)(import_lucide_react17.Plus, { size: 16 })
|
|
38015
38765
|
] }),
|
|
38016
|
-
[]
|
|
38766
|
+
[onCreateInvoice]
|
|
38017
38767
|
);
|
|
38018
|
-
const InvoicesTableEmptyState = (0,
|
|
38768
|
+
const InvoicesTableEmptyState = (0, import_react236.useCallback)(() => {
|
|
38019
38769
|
const isFiltered = selectedInvoiceStatusOption && selectedInvoiceStatusOption !== ALL_OPTION;
|
|
38020
|
-
return /* @__PURE__ */ (0,
|
|
38770
|
+
return /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(
|
|
38021
38771
|
DataState,
|
|
38022
38772
|
{
|
|
38023
38773
|
status: "allDone" /* allDone */,
|
|
38024
38774
|
title: isFiltered ? "No results found" : "No invoices yet",
|
|
38025
38775
|
description: isFiltered ? "We couldn\u2019t find any invoices with the current filters. Try changing or clearing them to see more results." : "Add your first invoice to start tracking what your customers owe you.",
|
|
38026
|
-
icon: isFiltered ? /* @__PURE__ */ (0,
|
|
38776
|
+
icon: isFiltered ? /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(import_lucide_react17.Search, {}) : /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(import_lucide_react17.HandCoins, {}),
|
|
38027
38777
|
spacing: true
|
|
38028
38778
|
}
|
|
38029
38779
|
);
|
|
38030
38780
|
}, [selectedInvoiceStatusOption]);
|
|
38031
|
-
const InvoicesTableErrorState = (0,
|
|
38781
|
+
const InvoicesTableErrorState = (0, import_react236.useCallback)(() => /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(
|
|
38032
38782
|
DataState,
|
|
38033
38783
|
{
|
|
38034
38784
|
status: "failed" /* failed */,
|
|
@@ -38040,8 +38790,9 @@ var InvoicesTable = () => {
|
|
|
38040
38790
|
spacing: true
|
|
38041
38791
|
}
|
|
38042
38792
|
), [refetch]);
|
|
38043
|
-
|
|
38044
|
-
|
|
38793
|
+
const columnConfig = (0, import_react236.useMemo)(() => getColumnConfig(onSelectInvoice), [onSelectInvoice]);
|
|
38794
|
+
return /* @__PURE__ */ (0, import_jsx_runtime347.jsxs)(Container, { name: "InvoicesTable", children: [
|
|
38795
|
+
/* @__PURE__ */ (0, import_jsx_runtime347.jsx)(
|
|
38045
38796
|
DataTableHeader,
|
|
38046
38797
|
{
|
|
38047
38798
|
name: "Invoices",
|
|
@@ -38051,14 +38802,14 @@ var InvoicesTable = () => {
|
|
|
38051
38802
|
}
|
|
38052
38803
|
}
|
|
38053
38804
|
),
|
|
38054
|
-
/* @__PURE__ */ (0,
|
|
38805
|
+
/* @__PURE__ */ (0, import_jsx_runtime347.jsx)(
|
|
38055
38806
|
PaginatedTable,
|
|
38056
38807
|
{
|
|
38057
38808
|
ariaLabel: "Invoices",
|
|
38058
38809
|
data: invoices,
|
|
38059
38810
|
isLoading: data === void 0 || isLoading,
|
|
38060
38811
|
isError,
|
|
38061
|
-
columnConfig
|
|
38812
|
+
columnConfig,
|
|
38062
38813
|
paginationProps,
|
|
38063
38814
|
componentName: COMPONENT_NAME10,
|
|
38064
38815
|
slots: {
|
|
@@ -38071,28 +38822,38 @@ var InvoicesTable = () => {
|
|
|
38071
38822
|
};
|
|
38072
38823
|
|
|
38073
38824
|
// src/components/Invoices/Invoices.tsx
|
|
38074
|
-
var
|
|
38825
|
+
var import_jsx_runtime348 = require("react/jsx-runtime");
|
|
38075
38826
|
var unstable_Invoices = ({
|
|
38076
38827
|
showTitle = true,
|
|
38077
38828
|
stringOverrides
|
|
38078
38829
|
}) => {
|
|
38079
|
-
|
|
38830
|
+
const [invoiceFormMode, setInvoiceFormMode] = (0, import_react237.useState)(null);
|
|
38831
|
+
const goBackToInvoicesTable = (0, import_react237.useCallback)(() => {
|
|
38832
|
+
setInvoiceFormMode(null);
|
|
38833
|
+
}, []);
|
|
38834
|
+
const onCreateInvoice = (0, import_react237.useCallback)(() => {
|
|
38835
|
+
setInvoiceFormMode({ mode: "Create" /* Create */ });
|
|
38836
|
+
}, []);
|
|
38837
|
+
const onSelectInvoice = (0, import_react237.useCallback)((invoice) => {
|
|
38838
|
+
setInvoiceFormMode({ mode: "Update" /* Update */, invoice });
|
|
38839
|
+
}, []);
|
|
38840
|
+
return /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(
|
|
38080
38841
|
View,
|
|
38081
38842
|
{
|
|
38082
38843
|
title: (stringOverrides == null ? void 0 : stringOverrides.title) || "Invoices",
|
|
38083
38844
|
showHeader: showTitle,
|
|
38084
|
-
children: /* @__PURE__ */ (0,
|
|
38845
|
+
children: invoiceFormMode !== null ? /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(InvoiceDetail, __spreadProps(__spreadValues({}, invoiceFormMode), { onGoBack: goBackToInvoicesTable })) : /* @__PURE__ */ (0, import_jsx_runtime348.jsx)(InvoicesTable, { onCreateInvoice, onSelectInvoice })
|
|
38085
38846
|
}
|
|
38086
38847
|
);
|
|
38087
38848
|
};
|
|
38088
38849
|
|
|
38089
38850
|
// src/providers/BankTransactionsProvider/BankTransactionsProvider.tsx
|
|
38090
|
-
var
|
|
38851
|
+
var import_jsx_runtime349 = require("react/jsx-runtime");
|
|
38091
38852
|
var BankTransactionsProvider = ({
|
|
38092
38853
|
children
|
|
38093
38854
|
}) => {
|
|
38094
38855
|
const bankTransactionsContextData = useAugmentedBankTransactions();
|
|
38095
|
-
return /* @__PURE__ */ (0,
|
|
38856
|
+
return /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(BankTransactionsContext.Provider, { value: bankTransactionsContextData, children });
|
|
38096
38857
|
};
|
|
38097
38858
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38098
38859
|
0 && (module.exports = {
|