@appcorp/stellar-solutions-invoice-module 0.1.55 → 0.1.56

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.
@@ -57,6 +57,13 @@ export declare const validationErrors: {
57
57
  total: string;
58
58
  subTotal: string;
59
59
  taxRate: string;
60
+ customerPhone: string;
61
+ customerFirstName: string;
62
+ customerLastName: string;
63
+ customerAddress: string;
64
+ customerCity: string;
65
+ customerCountry: string;
66
+ customerEmail: string;
60
67
  services: {
61
68
  name: string;
62
69
  description: string;
@@ -67,5 +74,7 @@ export declare const validationErrors: {
67
74
  products: {
68
75
  id: string;
69
76
  quantity: string;
77
+ price: string;
78
+ total: string;
70
79
  };
71
80
  };
@@ -52,7 +52,7 @@ exports.staticCompanySection = (_a = {},
52
52
  error: '',
53
53
  handleOnChange: function () { return void 0; },
54
54
  id: 'expiryDate',
55
- label: 'Expire Date',
55
+ label: 'Expiry Date',
56
56
  order: 3,
57
57
  placeholder: '',
58
58
  required: true,
@@ -203,7 +203,7 @@ exports.staticCustomerSection = (_b = {},
203
203
  enabled: true,
204
204
  handleInputOnChange: function () { return void 0; },
205
205
  handleOnBlur: function () { return void 0; },
206
- handleOnChange: function () { },
206
+ handleOnChange: function () { return void 0; },
207
207
  label: 'Country',
208
208
  listItems: [],
209
209
  nodeQueryKey: 'countryQuery',
@@ -219,7 +219,7 @@ exports.staticCustomerSection = (_b = {},
219
219
  enabled: true,
220
220
  handleInputOnChange: function () { return void 0; },
221
221
  handleOnBlur: function () { return void 0; },
222
- handleOnChange: function () { },
222
+ handleOnChange: function () { return void 0; },
223
223
  label: 'Currency',
224
224
  listItems: [],
225
225
  nodeQueryKey: '',
@@ -575,6 +575,13 @@ exports.validationErrors = {
575
575
  total: 'Please enter net total',
576
576
  subTotal: 'Please enter sub total',
577
577
  taxRate: 'Please enter tax value',
578
+ customerPhone: 'Please enter phone',
579
+ customerFirstName: 'Please enter first name',
580
+ customerLastName: 'Please enter last name',
581
+ customerAddress: 'Please enter address',
582
+ customerCity: 'Please enter city',
583
+ customerCountry: 'Please enter country',
584
+ customerEmail: 'Please enter email',
578
585
  services: {
579
586
  name: 'Item is required',
580
587
  description: 'Description is required',
@@ -585,5 +592,7 @@ exports.validationErrors = {
585
592
  products: {
586
593
  id: 'Please select a product',
587
594
  quantity: 'Please enter Quantity',
595
+ price: 'Price is required',
596
+ total: 'Total price is required',
588
597
  },
589
598
  };
@@ -155,7 +155,7 @@ var useInvoiceState = function () {
155
155
  }
156
156
  };
157
157
  var updateParams = (0, react_1.useMemo)(function () {
158
- var _a;
158
+ var _a, _b, _c, _d, _e, _f, _g, _h;
159
159
  return ({
160
160
  category: state.category,
161
161
  companyId: state.companyId,
@@ -164,18 +164,32 @@ var useInvoiceState = function () {
164
164
  date: state.date,
165
165
  discount: (_a = state === null || state === void 0 ? void 0 : state.discount) === null || _a === void 0 ? void 0 : _a.trim(),
166
166
  discountUnit: state.discountUnit,
167
+ drawer: state.drawer,
167
168
  expiryDate: state.expiryDate,
168
169
  id: state.id,
169
170
  invoiceStatus: state.invoiceStatus,
170
171
  mode: state.mode,
171
172
  note: state.note.trim(),
172
- products: state.products,
173
+ productsList: state.productsList.filter(function (_a) {
174
+ var id = _a.id;
175
+ return id;
176
+ }),
173
177
  quoteStatus: state.quoteStatus,
174
178
  ref: state.ref,
175
- services: state.services,
179
+ servicesList: state.servicesList.filter(function (_a) {
180
+ var name = _a.name;
181
+ return name;
182
+ }),
176
183
  subTotal: state.subTotal,
177
184
  taxRate: state.taxRate,
178
185
  total: state.total,
186
+ phone: (_b = state.customer) === null || _b === void 0 ? void 0 : _b.phone,
187
+ firstName: (_c = state.customer) === null || _c === void 0 ? void 0 : _c.firstName,
188
+ lastName: (_d = state.customer) === null || _d === void 0 ? void 0 : _d.lastName,
189
+ email: (_e = state.customer) === null || _e === void 0 ? void 0 : _e.email,
190
+ address: (_f = state.customer) === null || _f === void 0 ? void 0 : _f.address,
191
+ city: (_g = state.customer) === null || _g === void 0 ? void 0 : _g.city,
192
+ country: (_h = state.customer) === null || _h === void 0 ? void 0 : _h.country,
179
193
  });
180
194
  }, [state]);
181
195
  var updateCallback = function (_a) {
@@ -208,7 +222,7 @@ var useInvoiceState = function () {
208
222
  id: state.id,
209
223
  };
210
224
  var byIdCallback = function (_a) {
211
- var _b, _c, _d, _e, _f, _g, _h;
225
+ var _b, _c, _d, _e, _f;
212
226
  var data = _a.data, error = _a.error;
213
227
  if (error) {
214
228
  (0, generate_toast_1.generateToast)({
@@ -222,16 +236,16 @@ var useInvoiceState = function () {
222
236
  return (__assign(__assign({}, item), { rowTotal: Number(item.quantity) * Number(item.price) }));
223
237
  });
224
238
  var updatedProducts = __spreadArray([], data.products, true).map(function (item) { return (__assign(__assign({}, item), { price: item.product.salePrice, id: item.productId, quantity: item.quantity, rowTotal: parseFloat(item.product.salePrice) * parseInt(item.quantity) })); });
225
- var updatedData = __assign(__assign(__assign(__assign({}, data), { mode: 'Edit', companyId: ((_b = data === null || data === void 0 ? void 0 : data.company) === null || _b === void 0 ? void 0 : _b.id) || '', customerId: ((_c = data === null || data === void 0 ? void 0 : data.customer) === null || _c === void 0 ? void 0 : _c.id) || '' }), (((_d = data === null || data === void 0 ? void 0 : data.customer) === null || _d === void 0 ? void 0 : _d.id) && {
239
+ var updatedData = __assign(__assign(__assign(__assign({}, data), { mode: 'Edit', companyId: (data === null || data === void 0 ? void 0 : data.companyId) || '', customerId: (data === null || data === void 0 ? void 0 : data.customerId) || '' }), (((_b = data === null || data === void 0 ? void 0 : data.customer) === null || _b === void 0 ? void 0 : _b.id) && {
226
240
  customer: __assign({}, data.customer),
227
- })), { services: __spreadArray([], updatedServices, true).filter(function (item) { return item.name; }), products: __spreadArray([], updatedProducts, true).filter(function (item) { return item.id; }) });
228
- if ((_e = updatedData === null || updatedData === void 0 ? void 0 : updatedData.company) === null || _e === void 0 ? void 0 : _e.name) {
241
+ })), { servicesList: __spreadArray([], updatedServices, true).filter(function (item) { return item.name; }), productsList: __spreadArray([], updatedProducts, true).filter(function (item) { return item.id; }), companiesList: [__assign({}, data.company)] });
242
+ if ((_c = updatedData === null || updatedData === void 0 ? void 0 : updatedData.company) === null || _c === void 0 ? void 0 : _c.name) {
229
243
  dispatch({
230
244
  type: actions_1.INVOICE_ACTION_TYPES.SET_DRAWER,
231
245
  payload: { drawer: types_1.INVOICE_DRAWER.INVOICE_COMPANY_FORM_DRAWER },
232
246
  });
233
247
  }
234
- if ((_f = updatedData === null || updatedData === void 0 ? void 0 : updatedData.customer) === null || _f === void 0 ? void 0 : _f.firstName) {
248
+ if ((_d = updatedData === null || updatedData === void 0 ? void 0 : updatedData.customer) === null || _d === void 0 ? void 0 : _d.firstName) {
235
249
  dispatch({
236
250
  type: actions_1.INVOICE_ACTION_TYPES.SET_DRAWER,
237
251
  payload: { drawer: types_1.INVOICE_DRAWER.INVOICE_CUSTOMER_FORM_DRAWER },
@@ -241,13 +255,13 @@ var useInvoiceState = function () {
241
255
  type: actions_1.INVOICE_ACTION_TYPES.SET_FORM,
242
256
  payload: { form: updatedData },
243
257
  });
244
- if ((_g = updatedData === null || updatedData === void 0 ? void 0 : updatedData.company) === null || _g === void 0 ? void 0 : _g.name) {
258
+ if ((_e = updatedData === null || updatedData === void 0 ? void 0 : updatedData.company) === null || _e === void 0 ? void 0 : _e.name) {
245
259
  dispatch({
246
260
  type: actions_1.INVOICE_ACTION_TYPES.SET_DRAWER,
247
261
  payload: { drawer: types_1.INVOICE_DRAWER.INVOICE_COMPANY_FORM_DRAWER },
248
262
  });
249
263
  }
250
- if ((_h = updatedData === null || updatedData === void 0 ? void 0 : updatedData.customer) === null || _h === void 0 ? void 0 : _h.firstName) {
264
+ if ((_f = updatedData === null || updatedData === void 0 ? void 0 : updatedData.customer) === null || _f === void 0 ? void 0 : _f.firstName) {
251
265
  dispatch({
252
266
  type: actions_1.INVOICE_ACTION_TYPES.SET_DRAWER,
253
267
  payload: { drawer: types_1.INVOICE_DRAWER.INVOICE_CUSTOMER_FORM_DRAWER },
@@ -492,13 +506,21 @@ var useInvoiceState = function () {
492
506
  });
493
507
  };
494
508
  var handleSubmit = (0, react_1.useCallback)(function () {
509
+ if (!state.servicesList[0].name && !state.productsList[0].id) {
510
+ console.log('inside', state.servicesList, state.productsList);
511
+ dispatch({
512
+ type: actions_1.INVOICE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
513
+ payload: { disableSaveButton: true },
514
+ });
515
+ return;
516
+ }
495
517
  dispatch({
496
518
  type: actions_1.INVOICE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
497
519
  payload: { disableSaveButton: true },
498
520
  });
499
521
  (0, util_functions_1.validateForm)({
500
522
  params: __assign(__assign({}, updateParams), { currency: updateParams.currency || defaultCurrency.code, taxRate: updateParams.taxRate || defaultTax.taxRate }),
501
- schema: validate_1.formValidation,
523
+ schema: validate_1.formValid,
502
524
  successCallback: function () {
503
525
  updateFetchNow(undefined, {
504
526
  body: JSON.stringify(__assign(__assign({}, updateParams), { products: state.productsList.filter(function (item) { return item.id; }), services: state.servicesList.filter(function (item) { return item.name; }), currency: updateParams.currency || defaultCurrency.code, taxRate: updateParams.taxRate || defaultTax.taxRate })),
@@ -576,6 +598,10 @@ var useInvoiceState = function () {
576
598
  var handleItemChangeServices = (0, react_1.useCallback)(function (_a) {
577
599
  var _b;
578
600
  var index = _a.index, key = _a.key, value = _a.value;
601
+ dispatch({
602
+ type: actions_1.INVOICE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
603
+ payload: { disableSaveButton: false },
604
+ });
579
605
  var updatedItems = __spreadArray([], state.servicesList, true);
580
606
  updatedItems[index] = __assign(__assign({}, updatedItems[index]), (_b = {}, _b[key] = value, _b.mode = updatedItems[index].mode === 'Create' ? 'Create' : 'Edit', _b));
581
607
  var quantity = parseFloat(updatedItems[index].quantity) || 0;
@@ -597,6 +623,10 @@ var useInvoiceState = function () {
597
623
  var _b, _c, _d;
598
624
  var _e;
599
625
  var index = _a.index, key = _a.key, value = _a.value;
626
+ dispatch({
627
+ type: actions_1.INVOICE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
628
+ payload: { disableSaveButton: false },
629
+ });
600
630
  var updatedItems = __spreadArray([], state.productsList, true);
601
631
  if (key === 'id' && typeof value === 'string') {
602
632
  var matchingProduct = (_e = state.getProducts) === null || _e === void 0 ? void 0 : _e.find(function (product) { return product.id === value; });
@@ -746,6 +776,7 @@ var useInvoiceState = function () {
746
776
  comboboxElements[0].handleOnChange = handleSelectChange;
747
777
  comboboxElements[0].handleInputOnChange = handleChange;
748
778
  comboboxElements[0].handleOnBlur = handleChange;
779
+ comboboxElements[0].error = state.errors.companyId;
749
780
  comboboxElements[1].selectedItem = { code: state.currency || (defaultCurrency === null || defaultCurrency === void 0 ? void 0 : defaultCurrency.code) };
750
781
  comboboxElements[1].listItems = currencies;
751
782
  comboboxElements[1].handleOnChange = handleSelectChange;
@@ -753,6 +784,7 @@ var useInvoiceState = function () {
753
784
  }
754
785
  return elements;
755
786
  }, [state, handleChange, currencies, defaultCurrency]);
787
+ console.log('state', state);
756
788
  var dynamicCustomerFormElements = (0, react_1.useMemo)(function () {
757
789
  var _a, _b, _c;
758
790
  var elements = __assign({}, constants_1.staticCustomerSection);
@@ -774,6 +806,7 @@ var useInvoiceState = function () {
774
806
  comboboxElements[0].handleOnChange = handleSelectChange;
775
807
  comboboxElements[0].handleInputOnChange = handleCustomerChange;
776
808
  comboboxElements[0].handleOnBlur = handleCustomerChange;
809
+ comboboxElements[0].error = state.errors.country;
777
810
  comboboxElements[1].selectedItem = { code: state.currency || (defaultCurrency === null || defaultCurrency === void 0 ? void 0 : defaultCurrency.code) };
778
811
  comboboxElements[1].listItems = currencies;
779
812
  comboboxElements[1].handleOnChange = handleSelectChange;
@@ -24,10 +24,10 @@ var solid_1 = require("@heroicons/react/24/solid");
24
24
  var vista_button_type_1 = require("@appcorp/app-corp-vista/type/vista-button-type");
25
25
  var vista_combobox_v1_1 = require("@appcorp/app-corp-vista/molecules/vista-combobox-v1/vista-combobox-v1");
26
26
  var ProductsSection = function () {
27
- var _a = (0, context_1.useInvoiceStateContext)(), handleChange = _a.handleChange, handleDeleteServiceRow = _a.handleDeleteServiceRow, handleItemChangeProducts = _a.handleItemChangeProducts, productsList = _a.productsList, getProducts = _a.getProducts;
27
+ var _a = (0, context_1.useInvoiceStateContext)(), errors = _a.errors, getProducts = _a.getProducts, handleChange = _a.handleChange, handleDeleteServiceRow = _a.handleDeleteServiceRow, handleItemChangeProducts = _a.handleItemChangeProducts, productsList = _a.productsList;
28
28
  return (react_1.default.createElement("div", { className: "flex flex-col gap-4" },
29
29
  react_1.default.createElement(vista_vertical_divider_v4_1.VistaVerticalDividerV4, { label: "Products" }),
30
- productsList.length > 0 && (productsList === null || productsList === void 0 ? void 0 : productsList.map(function (row, index) { return (react_1.default.createElement("div", { key: index, className: 'grid grid-cols-[17.5%_17.5%_17.5%_17.5%_17.5%_auto] items-end justify-between gap-4' },
30
+ productsList.length > 0 && (productsList === null || productsList === void 0 ? void 0 : productsList.map(function (row, index) { return (react_1.default.createElement("div", { key: index, className: 'grid grid-cols-[17.5%_17.5%_17.5%_17.5%_17.5%_auto] items-start justify-between gap-4' },
31
31
  react_1.default.createElement("div", { className: 'col-span-2' },
32
32
  react_1.default.createElement(vista_combobox_v1_1.VistaComboboxV1, { handleOnChange: function (k, v) {
33
33
  var val = __assign({}, v);
@@ -36,10 +36,11 @@ var ProductsSection = function () {
36
36
  key: k,
37
37
  value: val.id,
38
38
  });
39
- }, handleOnBlur: handleChange, handleInputOnChange: handleChange, label: "Product", listItems: getProducts, nodeQueryKey: 'productQuery', nodeSelectKey: 'id', query: '', selectKey1: 'name', selectedItem: { id: productsList[index].id } })),
40
- react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeProducts({ index: index, key: k, value: v }); }, id: 'quantity', label: 'Quantity', placeholder: '1', value: String(productsList[index].quantity), type: 'number' }),
41
- react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeProducts({ index: index, key: k, value: v }); }, id: 'price', label: 'Price', placeholder: '0.00', value: productsList[index].price, type: 'number' }),
42
- react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeProducts({ index: index, key: k, value: v }); }, id: 'rowTotal', label: 'Row Total', placeholder: '0.00', value: productsList[index].rowTotal, type: 'number', readOnly: true }),
43
- react_1.default.createElement(vista_button_v1_1.VistaButtonV1, { className: 'flex justify-center items-end', handleOnClick: function () { return handleDeleteServiceRow(index); }, icon: react_1.default.createElement(solid_1.TrashIcon, { className: "size-6" }), variant: vista_button_type_1.VISTA_BUTTON_VARIANT.ICON }))); }))));
39
+ }, handleOnBlur: handleChange, handleInputOnChange: handleChange, label: "Product", listItems: getProducts, nodeQueryKey: 'productQuery', nodeSelectKey: 'id', query: '', selectKey1: 'name', selectedItem: { id: productsList[index].id }, error: errors["productsList-".concat(index, "-id")] })),
40
+ react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeProducts({ index: index, key: k, value: v }); }, id: 'quantity', label: 'Quantity', placeholder: '1', value: String(productsList[index].quantity), type: 'number', error: errors["productsList-".concat(index, "-quantity")] }),
41
+ react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeProducts({ index: index, key: k, value: v }); }, id: 'price', label: 'Price', placeholder: '0.00', value: productsList[index].price, type: 'number', error: errors["productsList-".concat(index, "-price")] }),
42
+ react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeProducts({ index: index, key: k, value: v }); }, id: 'rowTotal', label: 'Row Total', placeholder: '0.00', value: productsList[index].rowTotal, type: 'number', readOnly: true, error: errors["productsList-".concat(index, "-rowTotal")] }),
43
+ react_1.default.createElement("div", { className: 'h-full flex flex-col justify-center' },
44
+ react_1.default.createElement(vista_button_v1_1.VistaButtonV1, { className: 'flex justify-center items-end', handleOnClick: function () { return handleDeleteServiceRow(index); }, icon: react_1.default.createElement(solid_1.TrashIcon, { className: "size-6" }), variant: vista_button_type_1.VISTA_BUTTON_VARIANT.ICON })))); }))));
44
45
  };
45
46
  exports.ProductsSection = ProductsSection;
@@ -55,9 +55,7 @@ exports.initialInvoiceState = {
55
55
  discount: '0',
56
56
  discountUnit: types_1.DISCOUNT_UNIT.FIXED_VALUE,
57
57
  drawer: null,
58
- errors: {
59
- phone: 'Phone number is not well formatted',
60
- },
58
+ errors: {},
61
59
  expiryDate: (0, date_fns_1.addDays)(new Date(), 7).toISOString(),
62
60
  id: '',
63
61
  invoiceStatus: types_1.INVOICE_STATUS.UNPAID,
@@ -94,19 +92,19 @@ exports.initialInvoiceState = {
94
92
  },
95
93
  servicesList: [
96
94
  {
95
+ description: '',
97
96
  mode: 'Create',
98
97
  name: '',
99
- description: '',
100
- quantity: '1',
101
98
  price: '',
99
+ quantity: '1',
102
100
  rowTotal: '',
103
101
  },
104
102
  ],
105
103
  productsList: [
106
104
  {
105
+ id: '',
107
106
  mode: 'Create',
108
107
  price: '',
109
- id: '',
110
108
  quantity: '1',
111
109
  rowTotal: '',
112
110
  },
@@ -124,7 +122,7 @@ function invoiceReducer(state, action) {
124
122
  customer: __assign({}, exports.initialInvoiceState.customer),
125
123
  }))), (state.company && ({
126
124
  company: __assign({}, exports.initialInvoiceState.company),
127
- }))), { productsList: __assign({}, exports.initialInvoiceState.productsList), servicesList: __assign({}, exports.initialInvoiceState.servicesList), subTotal: exports.initialInvoiceState.subTotal, discount: exports.initialInvoiceState.discount, discountUnit: exports.initialInvoiceState.discountUnit, afterDiscount: exports.initialInvoiceState.afterDiscount, tax: exports.initialInvoiceState.tax, total: exports.initialInvoiceState.total, category: exports.initialInvoiceState.category, companyId: exports.initialInvoiceState.companyId, companyQuery: exports.initialInvoiceState.companyQuery, countryQuery: exports.initialInvoiceState.companyQuery, currency: exports.initialInvoiceState.currency, contactsList: exports.initialInvoiceState.contactsList, customerId: exports.initialInvoiceState.customerId, date: exports.initialInvoiceState.date, disableSaveButton: exports.initialInvoiceState.disableSaveButton, expiryDate: exports.initialInvoiceState.expiryDate, id: exports.initialInvoiceState.id, invoiceStatus: exports.initialInvoiceState.invoiceStatus, loading: exports.initialInvoiceState.loading, getProducts: exports.initialInvoiceState.getProducts, mode: exports.initialInvoiceState.mode, netTotal: exports.initialInvoiceState.netTotal, note: exports.initialInvoiceState.note, payments: exports.initialInvoiceState.payments, companiesList: exports.initialInvoiceState.companiesList, productQuery: exports.initialInvoiceState.productQuery, taxRate: exports.initialInvoiceState.taxRate, taxQuery: exports.initialInvoiceState.taxQuery, taxes: exports.initialInvoiceState.taxes });
125
+ }))), { productsList: __spreadArray([], exports.initialInvoiceState.productsList, true), servicesList: __spreadArray([], exports.initialInvoiceState.servicesList, true), subTotal: exports.initialInvoiceState.subTotal, discount: exports.initialInvoiceState.discount, discountUnit: exports.initialInvoiceState.discountUnit, afterDiscount: exports.initialInvoiceState.afterDiscount, tax: exports.initialInvoiceState.tax, total: exports.initialInvoiceState.total, category: exports.initialInvoiceState.category, companyId: exports.initialInvoiceState.companyId, companyQuery: exports.initialInvoiceState.companyQuery, countryQuery: exports.initialInvoiceState.companyQuery, currency: exports.initialInvoiceState.currency, contactsList: exports.initialInvoiceState.contactsList, customerId: exports.initialInvoiceState.customerId, date: exports.initialInvoiceState.date, disableSaveButton: exports.initialInvoiceState.disableSaveButton, expiryDate: exports.initialInvoiceState.expiryDate, id: exports.initialInvoiceState.id, invoiceStatus: exports.initialInvoiceState.invoiceStatus, loading: exports.initialInvoiceState.loading, getProducts: exports.initialInvoiceState.getProducts, mode: exports.initialInvoiceState.mode, netTotal: exports.initialInvoiceState.netTotal, note: exports.initialInvoiceState.note, payments: exports.initialInvoiceState.payments, companiesList: exports.initialInvoiceState.companiesList, productQuery: exports.initialInvoiceState.productQuery, taxRate: exports.initialInvoiceState.taxRate, taxQuery: exports.initialInvoiceState.taxQuery, taxes: exports.initialInvoiceState.taxes });
128
126
  case actions_1.INVOICE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON:
129
127
  return __assign(__assign({}, state), { disableSaveButton: action.payload.disableSaveButton });
130
128
  case actions_1.INVOICE_ACTION_TYPES.SET_CURRENT_PAGE:
@@ -12,15 +12,16 @@ var vista_button_type_1 = require("@appcorp/app-corp-vista/type/vista-button-typ
12
12
  var solid_1 = require("@heroicons/react/24/solid");
13
13
  var context_1 = require("./context");
14
14
  var ServicesSection = function () {
15
- var _a = (0, context_1.useInvoiceStateContext)(), servicesList = _a.servicesList, handleItemChangeServices = _a.handleItemChangeServices, handleDeleteServiceRow = _a.handleDeleteServiceRow;
15
+ var _a = (0, context_1.useInvoiceStateContext)(), servicesList = _a.servicesList, errors = _a.errors, handleItemChangeServices = _a.handleItemChangeServices, handleDeleteServiceRow = _a.handleDeleteServiceRow;
16
16
  return (react_1.default.createElement("div", { className: "flex flex-col gap-4" },
17
17
  react_1.default.createElement(vista_vertical_divider_v4_1.VistaVerticalDividerV4, { label: "Services" }),
18
- servicesList.length > 0 && (servicesList === null || servicesList === void 0 ? void 0 : servicesList.map(function (row, index) { return (react_1.default.createElement("div", { key: index, className: 'grid grid-cols-[17.5%_17.5%_17.5%_17.5%_17.5%_auto] items-end justify-between gap-4' },
19
- react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'name', label: 'Service Name', placeholder: 'Service Name', value: servicesList[index].name, type: 'text' }),
20
- react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'description', label: 'Service Description', placeholder: 'Service Description', value: servicesList[index].description, type: 'text' }),
21
- react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'quantity', label: 'Quantity', placeholder: '1', value: servicesList[index].quantity, type: 'number' }),
22
- react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'price', label: 'Price', placeholder: '0.00', value: servicesList[index].price, type: 'number' }),
23
- react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'rowTotal', label: 'Row Total', placeholder: '0.00', value: servicesList[index].rowTotal, type: 'number', readOnly: true }),
24
- react_1.default.createElement(vista_button_v1_1.VistaButtonV1, { className: 'flex justify-center items-end', handleOnClick: function () { return handleDeleteServiceRow(index); }, icon: react_1.default.createElement(solid_1.TrashIcon, { className: "size-6" }), variant: vista_button_type_1.VISTA_BUTTON_VARIANT.ICON }))); }))));
18
+ servicesList.length > 0 && (servicesList === null || servicesList === void 0 ? void 0 : servicesList.map(function (row, index) { return (react_1.default.createElement("div", { key: index, className: 'grid grid-cols-[17.5%_17.5%_17.5%_17.5%_17.5%_auto] items-start justify-between gap-4' },
19
+ react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'name', label: 'Service Name', placeholder: 'Service Name', value: servicesList[index].name, type: 'text', error: errors["servicesList-".concat(index, "-name")] }),
20
+ react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'description', label: 'Service Description', placeholder: 'Service Description', value: servicesList[index].description, type: 'text', error: errors["servicesList-".concat(index, "-description")] }),
21
+ react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'quantity', label: 'Quantity', placeholder: '1', value: servicesList[index].quantity, type: 'number', error: errors["servicesList-".concat(index, "-quantity")] }),
22
+ react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'price', label: 'Price', placeholder: '0.00', value: servicesList[index].price, type: 'number', error: errors["servicesList-".concat(index, "-price")] }),
23
+ react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'rowTotal', label: 'Row Total', placeholder: '0.00', value: servicesList[index].rowTotal, type: 'number', readOnly: true, error: errors["servicesList-".concat(index, "-rowTotal")] }),
24
+ react_1.default.createElement("div", { className: 'h-full flex flex-col justify-center' },
25
+ react_1.default.createElement(vista_button_v1_1.VistaButtonV1, { className: 'flex justify-center items-end', handleOnClick: function () { return handleDeleteServiceRow(index); }, icon: react_1.default.createElement(solid_1.TrashIcon, { className: "size-6" }), variant: vista_button_type_1.VISTA_BUTTON_VARIANT.ICON })))); }))));
25
26
  };
26
27
  exports.ServicesSection = ServicesSection;
@@ -112,7 +112,7 @@ export interface QuoteInvoiceTypeBE {
112
112
  invoiceStatus: INVOICE_STATUS;
113
113
  note: string;
114
114
  payments: PaymentTypeBE[];
115
- products: QuoteInvoiceProduct[];
115
+ products: QuoteInvoiceProductTypeBE[];
116
116
  quoteStatus: QUOTE_STATUS;
117
117
  ref: string;
118
118
  services: ServiceTypeBE[];
@@ -121,7 +121,32 @@ export interface QuoteInvoiceTypeBE {
121
121
  total: string;
122
122
  updatedAt: string;
123
123
  }
124
- export interface QuoteInvoiceProduct {
124
+ export interface QuoteInvoiceTypeFE {
125
+ category: QUOTE_INVOICE_CATEGORY;
126
+ company?: CompanyTypeBE;
127
+ companyId?: string;
128
+ createdAt: string;
129
+ currency: string;
130
+ customer?: CustomerTypeBE;
131
+ customerId?: string;
132
+ date: string;
133
+ discount?: string;
134
+ discountUnit: DISCOUNT_UNIT;
135
+ expiryDate: string;
136
+ id: string;
137
+ invoiceStatus: INVOICE_STATUS;
138
+ note: string;
139
+ payments: PaymentTypeBE[];
140
+ productsList: Product[];
141
+ quoteStatus: QUOTE_STATUS;
142
+ ref: string;
143
+ servicesList: Service[];
144
+ subTotal: string;
145
+ taxRate: string;
146
+ total: string;
147
+ updatedAt: string;
148
+ }
149
+ export interface QuoteInvoiceProductTypeBE {
125
150
  quoteInvoiceId: string;
126
151
  productId: string;
127
152
  product: ProductTypeBE;