@appcorp/stellar-solutions-invoice-module 0.1.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/README.md +36 -0
- package/base-modules/invoice/actions.d.ts +134 -0
- package/base-modules/invoice/actions.js +29 -0
- package/base-modules/invoice/add-service-product-section.d.ts +2 -0
- package/base-modules/invoice/add-service-product-section.js +21 -0
- package/base-modules/invoice/calculate-subtotal.d.ts +2 -0
- package/base-modules/invoice/calculate-subtotal.js +20 -0
- package/base-modules/invoice/constants.d.ts +42 -0
- package/base-modules/invoice/constants.js +450 -0
- package/base-modules/invoice/context.d.ts +10 -0
- package/base-modules/invoice/context.js +661 -0
- package/base-modules/invoice/drawer.d.ts +8 -0
- package/base-modules/invoice/drawer.js +19 -0
- package/base-modules/invoice/form.d.ts +8 -0
- package/base-modules/invoice/form.js +67 -0
- package/base-modules/invoice/invoice.d.ts +10 -0
- package/base-modules/invoice/invoice.js +90 -0
- package/base-modules/invoice/pricing-form-elements.d.ts +3 -0
- package/base-modules/invoice/pricing-form-elements.js +41 -0
- package/base-modules/invoice/pricing-form-section.d.ts +2 -0
- package/base-modules/invoice/pricing-form-section.js +20 -0
- package/base-modules/invoice/products-form-elements.d.ts +4 -0
- package/base-modules/invoice/products-form-elements.js +41 -0
- package/base-modules/invoice/products-form-section.d.ts +2 -0
- package/base-modules/invoice/products-form-section.js +17 -0
- package/base-modules/invoice/reducer.d.ts +4 -0
- package/base-modules/invoice/reducer.js +138 -0
- package/base-modules/invoice/services-form-elements.d.ts +4 -0
- package/base-modules/invoice/services-form-elements.js +41 -0
- package/base-modules/invoice/services-form-section.d.ts +2 -0
- package/base-modules/invoice/services-form-section.js +17 -0
- package/base-modules/invoice/types.d.ts +163 -0
- package/base-modules/invoice/types.js +40 -0
- package/base-modules/invoice/validate.d.ts +36 -0
- package/base-modules/invoice/validate.js +17 -0
- package/base-modules/product/actions.d.ts +113 -0
- package/base-modules/product/actions.js +22 -0
- package/base-modules/product/constants.d.ts +33 -0
- package/base-modules/product/constants.js +204 -0
- package/base-modules/product/context.d.ts +10 -0
- package/base-modules/product/context.js +557 -0
- package/base-modules/product/drawer.d.ts +8 -0
- package/base-modules/product/drawer.js +19 -0
- package/base-modules/product/form-elements.d.ts +2 -0
- package/base-modules/product/form-elements.js +41 -0
- package/base-modules/product/form.d.ts +8 -0
- package/base-modules/product/form.js +107 -0
- package/base-modules/product/product.d.ts +10 -0
- package/base-modules/product/product.js +80 -0
- package/base-modules/product/reducer.d.ts +4 -0
- package/base-modules/product/reducer.js +88 -0
- package/base-modules/product/types.d.ts +87 -0
- package/base-modules/product/types.js +28 -0
- package/base-modules/product/validate.d.ts +36 -0
- package/base-modules/product/validate.js +17 -0
- package/base-modules/product-category/actions.d.ts +90 -0
- package/base-modules/product-category/actions.js +19 -0
- package/base-modules/product-category/constants.d.ts +28 -0
- package/base-modules/product-category/constants.js +74 -0
- package/base-modules/product-category/context.d.ts +10 -0
- package/base-modules/product-category/context.js +390 -0
- package/base-modules/product-category/drawer.d.ts +8 -0
- package/base-modules/product-category/drawer.js +19 -0
- package/base-modules/product-category/form-elements.d.ts +2 -0
- package/base-modules/product-category/form-elements.js +41 -0
- package/base-modules/product-category/form.d.ts +8 -0
- package/base-modules/product-category/form.js +81 -0
- package/base-modules/product-category/product-category.d.ts +10 -0
- package/base-modules/product-category/product-category.js +53 -0
- package/base-modules/product-category/reducer.d.ts +4 -0
- package/base-modules/product-category/reducer.js +73 -0
- package/base-modules/product-category/types.d.ts +59 -0
- package/base-modules/product-category/types.js +11 -0
- package/base-modules/product-category/validate.d.ts +12 -0
- package/base-modules/product-category/validate.js +11 -0
- package/package.json +60 -0
|
@@ -0,0 +1,661 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(o, k2, desc);
|
|
21
|
+
}) : (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
}));
|
|
25
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
27
|
+
}) : function(o, v) {
|
|
28
|
+
o["default"] = v;
|
|
29
|
+
});
|
|
30
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
31
|
+
var ownKeys = function(o) {
|
|
32
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
33
|
+
var ar = [];
|
|
34
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
35
|
+
return ar;
|
|
36
|
+
};
|
|
37
|
+
return ownKeys(o);
|
|
38
|
+
};
|
|
39
|
+
return function (mod) {
|
|
40
|
+
if (mod && mod.__esModule) return mod;
|
|
41
|
+
var result = {};
|
|
42
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
43
|
+
__setModuleDefault(result, mod);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
48
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
49
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
50
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
51
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
52
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
53
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
57
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
58
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
59
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
60
|
+
function step(op) {
|
|
61
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
62
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
63
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
64
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
65
|
+
switch (op[0]) {
|
|
66
|
+
case 0: case 1: t = op; break;
|
|
67
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
68
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
69
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
70
|
+
default:
|
|
71
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
72
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
73
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
74
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
75
|
+
if (t[2]) _.ops.pop();
|
|
76
|
+
_.trys.pop(); continue;
|
|
77
|
+
}
|
|
78
|
+
op = body.call(thisArg, _);
|
|
79
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
80
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
84
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
85
|
+
if (ar || !(i in from)) {
|
|
86
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
87
|
+
ar[i] = from[i];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
91
|
+
};
|
|
92
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
93
|
+
exports.useInvoiceStateContext = exports.InvoiceStateContextProvider = exports.InvoiceStateContext = void 0;
|
|
94
|
+
var react_1 = __importStar(require("react"));
|
|
95
|
+
var util_functions_1 = require("@react-pakistan/util-functions");
|
|
96
|
+
var form_schema_1 = require("@appcorp/app-corp-vista/utils/form-schema");
|
|
97
|
+
var vista_notification_type_1 = require("@appcorp/app-corp-vista/type/vista-notification-type");
|
|
98
|
+
var actions_1 = require("./actions");
|
|
99
|
+
var constants_1 = require("./constants");
|
|
100
|
+
var reducer_1 = require("./reducer");
|
|
101
|
+
var types_1 = require("./types");
|
|
102
|
+
var validate_1 = require("./validate");
|
|
103
|
+
var generate_toast_1 = require("@appcorp/app-corp-vista/utils/generate-toast");
|
|
104
|
+
var calculate_subtotal_1 = require("./calculate-subtotal");
|
|
105
|
+
var context_1 = require("@appcorp/stellar-solutions-product-module/base-modules/product/context");
|
|
106
|
+
var useInvoiceState = function () {
|
|
107
|
+
var _a = (0, react_1.useReducer)(reducer_1.invoiceReducer, reducer_1.initialInvoiceState), state = _a[0], dispatch = _a[1];
|
|
108
|
+
var products = (0, context_1.useProductStateContext)().products;
|
|
109
|
+
var debouncedQuery = (0, util_functions_1.useDebounce)(state.searchQuery, 800);
|
|
110
|
+
var listParams = {
|
|
111
|
+
currentPage: state.currentPage,
|
|
112
|
+
pageLimit: state.pageLimit,
|
|
113
|
+
searchQuery: state.searchQuery,
|
|
114
|
+
};
|
|
115
|
+
var listCallback = function (_a) {
|
|
116
|
+
var data = _a.data, error = _a.error;
|
|
117
|
+
if (error) {
|
|
118
|
+
(0, generate_toast_1.generateToast)({
|
|
119
|
+
variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
|
|
120
|
+
description: constants_1.messages.error,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
if (data === null || data === void 0 ? void 0 : data.items) {
|
|
124
|
+
dispatch({
|
|
125
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_INVOICES,
|
|
126
|
+
payload: { invoices: data.items },
|
|
127
|
+
});
|
|
128
|
+
dispatch({
|
|
129
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_COUNT,
|
|
130
|
+
payload: { count: data === null || data === void 0 ? void 0 : data.count },
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
// const updateParams: Omit<InvoiceTypeBE, 'createdAt' | 'updatedAt' | 'serial' | 'isDeleted'> = useMemo(() => ({
|
|
135
|
+
// buyPrice: state.buyPrice,
|
|
136
|
+
// currency: state.currency,
|
|
137
|
+
// description: state.description,
|
|
138
|
+
// id: state.id,
|
|
139
|
+
// images: state.images,
|
|
140
|
+
// name: state.name,
|
|
141
|
+
// productCategoryId: state.productCategoryId,
|
|
142
|
+
// quantity: state.quantity,
|
|
143
|
+
// ref: state.ref,
|
|
144
|
+
// salePrice: state.salePrice,
|
|
145
|
+
// }), [state]);
|
|
146
|
+
var updateCallback = function (_a) {
|
|
147
|
+
var data = _a.data, error = _a.error;
|
|
148
|
+
if (error) {
|
|
149
|
+
(0, generate_toast_1.generateToast)({
|
|
150
|
+
description: constants_1.messages.error,
|
|
151
|
+
variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
if (data) {
|
|
155
|
+
(0, generate_toast_1.generateToast)({
|
|
156
|
+
description: constants_1.messages.success,
|
|
157
|
+
variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.SUCCESS,
|
|
158
|
+
});
|
|
159
|
+
dispatch({
|
|
160
|
+
type: actions_1.INVOICE_ACTION_TYPES.RESET_FORM,
|
|
161
|
+
});
|
|
162
|
+
listFetchNow();
|
|
163
|
+
dispatch({
|
|
164
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_DRAWER,
|
|
165
|
+
payload: { drawer: null },
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
var byIdParams = {
|
|
170
|
+
id: state.id,
|
|
171
|
+
};
|
|
172
|
+
var byIdCallback = function (_a) {
|
|
173
|
+
var data = _a.data, error = _a.error;
|
|
174
|
+
if (error) {
|
|
175
|
+
(0, generate_toast_1.generateToast)({
|
|
176
|
+
description: constants_1.messages.error,
|
|
177
|
+
variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
if (data) {
|
|
181
|
+
var updatedData = __assign(__assign(__assign(__assign({}, data), (!data.description && { description: '' })), (!data.ref && { ref: '' })), (!data.image && { image: [] }));
|
|
182
|
+
dispatch({
|
|
183
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_FORM,
|
|
184
|
+
payload: { form: updatedData },
|
|
185
|
+
});
|
|
186
|
+
dispatch({
|
|
187
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_DRAWER,
|
|
188
|
+
payload: { drawer: types_1.INVOICE_DRAWER.INVOICE_COMPANY_FORM_DRAWER },
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
var deleteParams = {
|
|
193
|
+
id: state.id,
|
|
194
|
+
};
|
|
195
|
+
var deleteCallback = function (_a) {
|
|
196
|
+
var data = _a.data, error = _a.error;
|
|
197
|
+
if (error) {
|
|
198
|
+
(0, generate_toast_1.generateToast)({
|
|
199
|
+
description: constants_1.messages.error,
|
|
200
|
+
variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
if (data) {
|
|
204
|
+
(0, generate_toast_1.generateToast)({
|
|
205
|
+
description: constants_1.messages.success,
|
|
206
|
+
variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.SUCCESS,
|
|
207
|
+
});
|
|
208
|
+
dispatch({
|
|
209
|
+
type: actions_1.INVOICE_ACTION_TYPES.RESET_FORM,
|
|
210
|
+
});
|
|
211
|
+
listFetchNow();
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
var _b = (0, util_functions_1.useModuleEntity)({
|
|
215
|
+
byIdCallback: byIdCallback,
|
|
216
|
+
byIdParams: byIdParams,
|
|
217
|
+
deleteCallback: deleteCallback,
|
|
218
|
+
deleteParams: deleteParams,
|
|
219
|
+
listCallback: listCallback,
|
|
220
|
+
listParams: listParams,
|
|
221
|
+
listUrl: constants_1.INVOICE_API_ROUTES.INVOICES,
|
|
222
|
+
searchQuery: debouncedQuery,
|
|
223
|
+
unitByIdUrl: constants_1.INVOICE_API_ROUTES.INVOICE_BY_ID,
|
|
224
|
+
unitUrl: constants_1.INVOICE_API_ROUTES.INVOICE,
|
|
225
|
+
updateCallback: updateCallback,
|
|
226
|
+
updateDeps: [state],
|
|
227
|
+
updateParams: {},
|
|
228
|
+
}), byIdError = _b.byIdError, byIdFetchNow = _b.byIdFetchNow, byIdLoading = _b.byIdLoading, deleteError = _b.deleteError, deleteFetchNow = _b.deleteFetchNow, deleteLoading = _b.deleteLoading, listError = _b.listError, listFetchNow = _b.listFetchNow, listLoading = _b.listLoading, updateError = _b.updateError, updateFetchNow = _b.updateFetchNow, updateLoading = _b.updateLoading;
|
|
229
|
+
(0, react_1.useEffect)(function () {
|
|
230
|
+
listFetchNow();
|
|
231
|
+
// eslint-disable-next-line
|
|
232
|
+
}, [
|
|
233
|
+
debouncedQuery,
|
|
234
|
+
state.currentPage,
|
|
235
|
+
state.pageLimit,
|
|
236
|
+
]);
|
|
237
|
+
var handleCreate = function (text) {
|
|
238
|
+
if (text === 'company') {
|
|
239
|
+
dispatch({
|
|
240
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_DRAWER,
|
|
241
|
+
payload: { drawer: types_1.INVOICE_DRAWER.INVOICE_COMPANY_FORM_DRAWER },
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
if (text === 'customer') {
|
|
245
|
+
dispatch({
|
|
246
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_DRAWER,
|
|
247
|
+
payload: { drawer: types_1.INVOICE_DRAWER.INVOICE_CUSTOMER_FORM_DRAWER },
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
var handleEdit = function (id) {
|
|
252
|
+
byIdFetchNow(undefined, {
|
|
253
|
+
body: JSON.stringify({ id: id }),
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
var handleDelete = function (id) {
|
|
257
|
+
deleteFetchNow === null || deleteFetchNow === void 0 ? void 0 : deleteFetchNow(undefined, {
|
|
258
|
+
body: JSON.stringify({ id: id }),
|
|
259
|
+
});
|
|
260
|
+
};
|
|
261
|
+
// const handleUploadImage = useCallback(async () => {
|
|
262
|
+
// const urls: string[] = [];
|
|
263
|
+
// if (state?.images?.some((u) => u.startsWith('blob:'))) {
|
|
264
|
+
// await Promise.all(state.images.map(async (url) => {
|
|
265
|
+
// const blob = await fetch(url).then((r) => r.blob());
|
|
266
|
+
// const webpBlob = await blobToWebP(blob, { quality: 1 });
|
|
267
|
+
// const { data } = await uploadBlobToPublicSupabase({
|
|
268
|
+
// blob: webpBlob,
|
|
269
|
+
// supabase: supabaseClient,
|
|
270
|
+
// fileRef: `products/${uuidv4()}.webp`,
|
|
271
|
+
// contentType: 'image/webp',
|
|
272
|
+
// upsert: true,
|
|
273
|
+
// });
|
|
274
|
+
// if (data) {
|
|
275
|
+
// urls.push(`${supabasePublicStorageUrl}/${data.path}`);
|
|
276
|
+
// }
|
|
277
|
+
// return urls;
|
|
278
|
+
// }));
|
|
279
|
+
// }
|
|
280
|
+
// if (urls.length) {
|
|
281
|
+
// dispatch({
|
|
282
|
+
// type: INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
283
|
+
// payload: { key: 'images', value: urls },
|
|
284
|
+
// });
|
|
285
|
+
// }
|
|
286
|
+
// return urls;
|
|
287
|
+
// }, [state.images]);
|
|
288
|
+
var handleSubmit = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
289
|
+
var validationResult, validationErrors_1;
|
|
290
|
+
return __generator(this, function (_a) {
|
|
291
|
+
// let urls;
|
|
292
|
+
// if (state.images?.length) {
|
|
293
|
+
// urls = await handleUploadImage();
|
|
294
|
+
// }
|
|
295
|
+
dispatch({
|
|
296
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
297
|
+
payload: { disableSaveButton: true },
|
|
298
|
+
});
|
|
299
|
+
try {
|
|
300
|
+
validationResult = validate_1.formValidation === null || validate_1.formValidation === void 0 ? void 0 : validate_1.formValidation.safeParse(__assign({}));
|
|
301
|
+
if (validationResult === null || validationResult === void 0 ? void 0 : validationResult.error) {
|
|
302
|
+
validationErrors_1 = {};
|
|
303
|
+
validationResult === null || validationResult === void 0 ? void 0 : validationResult.error.errors.forEach(function (err) {
|
|
304
|
+
validationErrors_1[err.path[0]] = err.message;
|
|
305
|
+
});
|
|
306
|
+
dispatch({
|
|
307
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_ERRORS,
|
|
308
|
+
payload: validationErrors_1,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
if (validationResult === null || validationResult === void 0 ? void 0 : validationResult.success) {
|
|
312
|
+
updateFetchNow(undefined, {
|
|
313
|
+
body: JSON.stringify(__assign({})),
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
// eslint-disable-next-line
|
|
317
|
+
}
|
|
318
|
+
catch (err) {
|
|
319
|
+
(0, generate_toast_1.generateToast)({
|
|
320
|
+
description: constants_1.messages.error,
|
|
321
|
+
variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
dispatch({
|
|
325
|
+
type: actions_1.INVOICE_ACTION_TYPES.RESET_FORM,
|
|
326
|
+
});
|
|
327
|
+
dispatch({
|
|
328
|
+
type: actions_1.INVOICE_ACTION_TYPES.CLEAR_ERRORS,
|
|
329
|
+
});
|
|
330
|
+
return [2 /*return*/];
|
|
331
|
+
});
|
|
332
|
+
}); }, [updateFetchNow]);
|
|
333
|
+
var handleChange = function (key, value) {
|
|
334
|
+
dispatch({
|
|
335
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
336
|
+
payload: { key: key, value: String(value).trim(), },
|
|
337
|
+
});
|
|
338
|
+
dispatch({
|
|
339
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
340
|
+
payload: { disableSaveButton: false },
|
|
341
|
+
});
|
|
342
|
+
dispatch({
|
|
343
|
+
type: actions_1.INVOICE_ACTION_TYPES.CLEAR_ERRORS,
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
var handleItemChangeServices = (0, react_1.useCallback)(function (_a) {
|
|
347
|
+
var _b;
|
|
348
|
+
var index = _a.index, key = _a.key, value = _a.value;
|
|
349
|
+
var updatedItems = __spreadArray([], state.services, true);
|
|
350
|
+
updatedItems[index] = __assign(__assign({}, updatedItems[index]), (_b = {}, _b[key] = value, _b.mode = updatedItems[index].mode === 'Create' ? 'Create' : 'Edit', _b));
|
|
351
|
+
var quantity = parseFloat(updatedItems[index].quantity) || 0;
|
|
352
|
+
var price = parseFloat(updatedItems[index].price) || 0;
|
|
353
|
+
var rowTotal = (quantity * price).toFixed(2);
|
|
354
|
+
updatedItems[index].rowTotal = rowTotal;
|
|
355
|
+
var allProducts = state.products;
|
|
356
|
+
var subtotal = (0, calculate_subtotal_1.calculateSubtotal)(updatedItems, allProducts);
|
|
357
|
+
dispatch({
|
|
358
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
359
|
+
payload: { key: 'subTotal', value: subtotal },
|
|
360
|
+
});
|
|
361
|
+
dispatch({
|
|
362
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
363
|
+
payload: { key: 'services', value: updatedItems },
|
|
364
|
+
});
|
|
365
|
+
}, [state.products, state.services]);
|
|
366
|
+
var handleItemChangeProducts = (0, react_1.useCallback)(function (_a) {
|
|
367
|
+
var _b, _c, _d;
|
|
368
|
+
var index = _a.index, key = _a.key, value = _a.value;
|
|
369
|
+
var updatedItems = __spreadArray([], state.products, true);
|
|
370
|
+
if (key === 'productId' && typeof value === 'string') {
|
|
371
|
+
var matchingProduct = products === null || products === void 0 ? void 0 : products.find(function (product) { return product.id === value; });
|
|
372
|
+
if (matchingProduct) {
|
|
373
|
+
var quantity = parseFloat(String(updatedItems[index].quantity)) || 0;
|
|
374
|
+
var rowTotal = (quantity * Number(matchingProduct.salePrice)).toFixed(2);
|
|
375
|
+
updatedItems[index] = __assign(__assign({}, updatedItems[index]), (_b = {}, _b[key] = value, _b.price = matchingProduct.salePrice, _b.mode = updatedItems[index].mode === 'Create' ? 'Create' : 'Edit', _b.rowTotal = rowTotal, _b));
|
|
376
|
+
var allServices = state.services;
|
|
377
|
+
var subtotal = (0, calculate_subtotal_1.calculateSubtotal)(allServices, updatedItems);
|
|
378
|
+
dispatch({
|
|
379
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
380
|
+
payload: { key: 'subTotal', value: subtotal },
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
updatedItems[index] = __assign(__assign({}, updatedItems[index]), (_c = {}, _c[key] = value, _c.mode = updatedItems[index].mode === 'Create' ? 'Create' : 'Edit', _c));
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
updatedItems[index] = __assign(__assign({}, updatedItems[index]), (_d = {}, _d[key] = value, _d.mode = updatedItems[index].mode === 'Create' ? 'Create' : 'Edit', _d));
|
|
389
|
+
var quantity = parseFloat(String(updatedItems[index].quantity)) || 0;
|
|
390
|
+
var price = parseFloat(updatedItems[index].price) || 0;
|
|
391
|
+
var rowTotal = (quantity * price).toFixed(2);
|
|
392
|
+
updatedItems[index] = __assign(__assign({}, updatedItems[index]), { rowTotal: rowTotal });
|
|
393
|
+
var allServices = state.services;
|
|
394
|
+
var subtotal = (0, calculate_subtotal_1.calculateSubtotal)(allServices, updatedItems);
|
|
395
|
+
dispatch({
|
|
396
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
397
|
+
payload: { key: 'subTotal', value: subtotal },
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
dispatch({
|
|
401
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
402
|
+
payload: { key: 'products', value: updatedItems },
|
|
403
|
+
});
|
|
404
|
+
}, [state.services, state.products, products]);
|
|
405
|
+
// const handleSelectInputChange = useCallback(async (key: string, value: string) => {
|
|
406
|
+
// const response = await fetch(INVOICE_CATEGORY_API_ROUTES.INVOICE_CATEGORIES, {
|
|
407
|
+
// method: API_METHODS.POST,
|
|
408
|
+
// body: JSON.stringify({
|
|
409
|
+
// searchQuery: debouncedList,
|
|
410
|
+
// pageLimit: 1000,
|
|
411
|
+
// currentPage: 1,
|
|
412
|
+
// }),
|
|
413
|
+
// });
|
|
414
|
+
// const result = await response.json();
|
|
415
|
+
// dispatch({
|
|
416
|
+
// type: INVOICE_ACTION_TYPES.SET_INVOICE_CATEGORIES,
|
|
417
|
+
// payload: { productCategories: result as ProductCategoryBE[] },
|
|
418
|
+
// });
|
|
419
|
+
// dispatch({
|
|
420
|
+
// type: INVOICE_ACTION_TYPES.SET_INVOICE_QUERY,
|
|
421
|
+
// payload: { productCategoryQuery: value },
|
|
422
|
+
// });
|
|
423
|
+
// }, []);
|
|
424
|
+
var handleSelectChange = function (key, value) {
|
|
425
|
+
var val = __assign({}, value);
|
|
426
|
+
if (key === 'currency') {
|
|
427
|
+
dispatch({
|
|
428
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
429
|
+
payload: {
|
|
430
|
+
key: key,
|
|
431
|
+
value: val['option'],
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
dispatch({
|
|
437
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
438
|
+
payload: {
|
|
439
|
+
key: key,
|
|
440
|
+
value: val['id'],
|
|
441
|
+
},
|
|
442
|
+
});
|
|
443
|
+
};
|
|
444
|
+
var handleNextClick = function () {
|
|
445
|
+
dispatch({
|
|
446
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
447
|
+
payload: { currentPage: state.currentPage + 1 },
|
|
448
|
+
});
|
|
449
|
+
};
|
|
450
|
+
var handlePreviousClick = function () {
|
|
451
|
+
dispatch({
|
|
452
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
453
|
+
payload: { currentPage: state.currentPage - 1 },
|
|
454
|
+
});
|
|
455
|
+
};
|
|
456
|
+
var handlePageLimit = function (k, value) {
|
|
457
|
+
var val = __assign({}, value);
|
|
458
|
+
dispatch({
|
|
459
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_PAGE_LIMIT,
|
|
460
|
+
payload: { pageLimit: Number(val.option) },
|
|
461
|
+
});
|
|
462
|
+
};
|
|
463
|
+
var searchOnChange = function (k, v) {
|
|
464
|
+
dispatch({
|
|
465
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_SEARCH_QUERY,
|
|
466
|
+
payload: { searchQuery: v },
|
|
467
|
+
});
|
|
468
|
+
};
|
|
469
|
+
var clearSearch = function () {
|
|
470
|
+
dispatch({
|
|
471
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_SEARCH_QUERY,
|
|
472
|
+
payload: { searchQuery: '' },
|
|
473
|
+
});
|
|
474
|
+
};
|
|
475
|
+
var closeDrawer = function () {
|
|
476
|
+
dispatch({
|
|
477
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_DRAWER,
|
|
478
|
+
payload: { drawer: null },
|
|
479
|
+
});
|
|
480
|
+
dispatch({
|
|
481
|
+
type: actions_1.INVOICE_ACTION_TYPES.RESET_FORM,
|
|
482
|
+
});
|
|
483
|
+
dispatch({
|
|
484
|
+
type: actions_1.INVOICE_ACTION_TYPES.CLEAR_ERRORS,
|
|
485
|
+
});
|
|
486
|
+
};
|
|
487
|
+
var dynamicFormElements = (0, react_1.useMemo)(function () {
|
|
488
|
+
var _a, _b, _c, _d, _e;
|
|
489
|
+
var elements = __assign({}, constants_1.staticCompanySection);
|
|
490
|
+
var textInputElements = (_a = elements[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_INPUT_V1]) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.order - b.order; });
|
|
491
|
+
if (textInputElements) {
|
|
492
|
+
textInputElements === null || textInputElements === void 0 ? void 0 : textInputElements.map(function (_a, i) {
|
|
493
|
+
var id = _a.id;
|
|
494
|
+
textInputElements[i].value = state[id];
|
|
495
|
+
textInputElements[i].handleOnChange = handleChange;
|
|
496
|
+
textInputElements[i].error = state.errors[id];
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
var textAreaElements = (_b = elements[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_AREA_V1]) === null || _b === void 0 ? void 0 : _b.sort(function (a, b) { return a.order - b.order; });
|
|
500
|
+
if (textAreaElements) {
|
|
501
|
+
textAreaElements === null || textAreaElements === void 0 ? void 0 : textAreaElements.forEach(function (_a, i) {
|
|
502
|
+
var id = _a.id;
|
|
503
|
+
textAreaElements[i].value = state[id];
|
|
504
|
+
textAreaElements[i].handleOnChange = handleChange;
|
|
505
|
+
textAreaElements[i].error = state.errors.description;
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
var selectElements = (_c = elements[form_schema_1.VISTA_FORM_ELEMENTS.SELECT_V1]) === null || _c === void 0 ? void 0 : _c.sort(function (a, b) { return a.order - b.order; });
|
|
509
|
+
if (selectElements) {
|
|
510
|
+
selectElements === null || selectElements === void 0 ? void 0 : selectElements.forEach(function (_a, i) {
|
|
511
|
+
var nodeSelectKey = _a.nodeSelectKey;
|
|
512
|
+
selectElements[i].handleOnChange = handleSelectChange;
|
|
513
|
+
selectElements[i].selectedItem = { option: state[nodeSelectKey] };
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
var comboboxElements = (_d = elements[form_schema_1.VISTA_FORM_ELEMENTS.COMBOBOX_V1]) === null || _d === void 0 ? void 0 : _d.sort(function (a, b) { return a.order - b.order; });
|
|
517
|
+
if (comboboxElements) {
|
|
518
|
+
// comboboxElements?.forEach(({ nodeSelectKey }, i) => {
|
|
519
|
+
// comboboxElements[i].handleOnChange = handleSelectChange;
|
|
520
|
+
// comboboxElements[i].selectedItem = { id: state[nodeSelectKey as 'productCategoryId'] };
|
|
521
|
+
// comboboxElements[i].listItems = productCategories.map((item) => ({ ...item, option: item.name }));
|
|
522
|
+
// comboboxElements[i].query = state.productCategoryQuery;
|
|
523
|
+
// comboboxElements[i].handleInputOnChange = handleSelectInputChange;
|
|
524
|
+
// comboboxElements[i].handleOnBlur = handleSelectInputChange;
|
|
525
|
+
// });
|
|
526
|
+
}
|
|
527
|
+
var uploadElements = (_e = elements[form_schema_1.VISTA_FORM_ELEMENTS.UPLOAD_V1]) === null || _e === void 0 ? void 0 : _e.sort(function (a, b) { return a.order - b.order; });
|
|
528
|
+
if (uploadElements) {
|
|
529
|
+
// uploadElements?.forEach((_, i) => {
|
|
530
|
+
// uploadElements[i].imageUrls = state.images;
|
|
531
|
+
// uploadElements[i].handleOnChange = handleFileChange;
|
|
532
|
+
// uploadElements[i].handleClearImage = () => dispatch({
|
|
533
|
+
// type: INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
534
|
+
// payload: { key: 'images', value: [] },
|
|
535
|
+
// });
|
|
536
|
+
// });
|
|
537
|
+
}
|
|
538
|
+
return elements;
|
|
539
|
+
}, [state]);
|
|
540
|
+
var dynamicPricingFormElements = (0, react_1.useMemo)(function () {
|
|
541
|
+
var elements = __assign({}, constants_1.staticPricingSection);
|
|
542
|
+
return elements;
|
|
543
|
+
}, []);
|
|
544
|
+
var dynamicServiceFormElements = (0, react_1.useMemo)(function () {
|
|
545
|
+
var _a, _b;
|
|
546
|
+
var elements = __assign({}, constants_1.staticServiceSection);
|
|
547
|
+
var textInputElements = (_a = elements[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_INPUT_V1]) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.order - b.order; });
|
|
548
|
+
if (textInputElements) {
|
|
549
|
+
(_b = state.services) === null || _b === void 0 ? void 0 : _b.forEach(function (service, i) {
|
|
550
|
+
textInputElements[0].value = state.services[0].name;
|
|
551
|
+
textInputElements[0].handleOnChange = function (k, v) { return handleItemChangeServices({
|
|
552
|
+
index: i,
|
|
553
|
+
key: k,
|
|
554
|
+
value: v,
|
|
555
|
+
}); };
|
|
556
|
+
// textInputElements[i].error = state.errors[id];
|
|
557
|
+
textInputElements[1].value = state.services[0].description;
|
|
558
|
+
textInputElements[1].handleOnChange = function (k, v) { return handleItemChangeServices({
|
|
559
|
+
index: i,
|
|
560
|
+
key: k,
|
|
561
|
+
value: v,
|
|
562
|
+
}); };
|
|
563
|
+
// textInputElements[i].error = state.errors[id];
|
|
564
|
+
textInputElements[2].value = state.services[0].quantity;
|
|
565
|
+
textInputElements[2].handleOnChange = function (k, v) { return handleItemChangeServices({
|
|
566
|
+
index: i,
|
|
567
|
+
key: k,
|
|
568
|
+
value: v,
|
|
569
|
+
}); };
|
|
570
|
+
// textInputElements[i].error = state.errors[id];
|
|
571
|
+
textInputElements[3].value = state.services[0].price;
|
|
572
|
+
textInputElements[3].handleOnChange = function (k, v) { return handleItemChangeServices({
|
|
573
|
+
index: i,
|
|
574
|
+
key: k,
|
|
575
|
+
value: v,
|
|
576
|
+
}); };
|
|
577
|
+
// textInputElements[i].error = state.errors[id];
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
return elements;
|
|
581
|
+
}, [state.services, handleItemChangeServices]);
|
|
582
|
+
var dynamicProductFormElements = (0, react_1.useMemo)(function () {
|
|
583
|
+
var _a, _b, _c, _d;
|
|
584
|
+
var elements = __assign({}, constants_1.staticProductSection);
|
|
585
|
+
var textInputElements = (_a = elements[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_INPUT_V1]) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.order - b.order; });
|
|
586
|
+
if (textInputElements) {
|
|
587
|
+
(_b = state.products) === null || _b === void 0 ? void 0 : _b.forEach(function (product, i) {
|
|
588
|
+
textInputElements[0].value = String(product.quantity);
|
|
589
|
+
textInputElements[0].handleOnChange = function (k, v) { return handleItemChangeProducts({
|
|
590
|
+
index: i,
|
|
591
|
+
key: k,
|
|
592
|
+
value: Number(v),
|
|
593
|
+
}); };
|
|
594
|
+
// textInputElements[i].error = state.errors[id];
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
var comboboxElements = (_c = elements[form_schema_1.VISTA_FORM_ELEMENTS.COMBOBOX_V1]) === null || _c === void 0 ? void 0 : _c.sort(function (a, b) { return a.order - b.order; });
|
|
598
|
+
if (comboboxElements) {
|
|
599
|
+
(_d = state.products) === null || _d === void 0 ? void 0 : _d.forEach(function (product, i) {
|
|
600
|
+
comboboxElements[0].listItems = [];
|
|
601
|
+
comboboxElements[0].handleOnChange = function (k, v) {
|
|
602
|
+
var val = __assign({}, v);
|
|
603
|
+
handleItemChangeProducts({
|
|
604
|
+
index: i,
|
|
605
|
+
key: k,
|
|
606
|
+
value: val.id,
|
|
607
|
+
});
|
|
608
|
+
};
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
return elements;
|
|
612
|
+
}, [state, handleItemChangeProducts]);
|
|
613
|
+
var headerActions = [
|
|
614
|
+
{
|
|
615
|
+
enabled: true,
|
|
616
|
+
handleOnClick: function () { return handleCreate('company'); },
|
|
617
|
+
label: 'Invoice for Company',
|
|
618
|
+
order: 1,
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
enabled: true,
|
|
622
|
+
handleOnClick: function () { return handleCreate('customer'); },
|
|
623
|
+
label: 'Invoice for Customer',
|
|
624
|
+
order: 1,
|
|
625
|
+
},
|
|
626
|
+
];
|
|
627
|
+
var rowActions = [
|
|
628
|
+
{
|
|
629
|
+
enabled: true,
|
|
630
|
+
handleAction: function (id) { return handleEdit(id); },
|
|
631
|
+
label: 'Edit',
|
|
632
|
+
order: 1,
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
enabled: true,
|
|
636
|
+
handleAction: function (id) { return handleDelete(id); },
|
|
637
|
+
label: 'Delete',
|
|
638
|
+
order: 2,
|
|
639
|
+
},
|
|
640
|
+
];
|
|
641
|
+
return __assign(__assign({}, state), { byIdError: byIdError, byIdLoading: byIdLoading, clearSearch: clearSearch, closeDrawer: closeDrawer, deleteError: deleteError, deleteLoading: deleteLoading, dispatch: dispatch, dynamicFormElements: dynamicFormElements, dynamicPricingFormElements: dynamicPricingFormElements, dynamicProductFormElements: dynamicProductFormElements, dynamicServiceFormElements: dynamicServiceFormElements, handleChange: handleChange, handleNextClick: handleNextClick, handlePageLimit: handlePageLimit, handlePreviousClick: handlePreviousClick, handleSubmit: handleSubmit,
|
|
642
|
+
// handleUploadImage,
|
|
643
|
+
headerActions: headerActions, listError: listError, listFetchNow: listFetchNow, listLoading: listLoading, rowActions: rowActions, searchOnChange: searchOnChange, updateError: updateError, updateLoading: updateLoading });
|
|
644
|
+
};
|
|
645
|
+
exports.InvoiceStateContext = (0, react_1.createContext)(__assign(__assign({}, reducer_1.initialInvoiceState), { byIdError: undefined, byIdLoading: false, clearSearch: function () { return void 0; }, closeDrawer: function () { return void 0; }, deleteError: undefined, deleteLoading: false, dispatch: function () { return void 0; }, dynamicFormElements: {}, dynamicPricingFormElements: {}, dynamicProductFormElements: {}, dynamicServiceFormElements: {}, handleChange: function () { return void 0; }, handleNextClick: function () { return void 0; }, handlePageLimit: function () { return void 0; }, handlePreviousClick: function () { return void 0; }, handleSubmit: function () { return void 0; },
|
|
646
|
+
// handleUploadImage: () => void 0,
|
|
647
|
+
headerActions: [], listError: undefined, listFetchNow: function () { return void 0; }, listLoading: false, rowActions: [], searchOnChange: function () { return void 0; }, updateError: undefined, updateLoading: false }));
|
|
648
|
+
var InvoiceStateContextProvider = function (_a) {
|
|
649
|
+
var children = _a.children;
|
|
650
|
+
var state = useInvoiceState();
|
|
651
|
+
return (react_1.default.createElement(exports.InvoiceStateContext.Provider, { value: state }, children));
|
|
652
|
+
};
|
|
653
|
+
exports.InvoiceStateContextProvider = InvoiceStateContextProvider;
|
|
654
|
+
var useInvoiceStateContext = function () {
|
|
655
|
+
var state = (0, react_1.useContext)(exports.InvoiceStateContext);
|
|
656
|
+
if (state === undefined) {
|
|
657
|
+
throw new Error('useInvoiceStateContext must be used within an InvoiceContextProvider');
|
|
658
|
+
}
|
|
659
|
+
return state;
|
|
660
|
+
};
|
|
661
|
+
exports.useInvoiceStateContext = useInvoiceStateContext;
|