@appcorp/stellar-solutions-invoice-module 0.1.33 → 0.1.35

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.
@@ -307,10 +307,10 @@ var useInvoiceState = function () {
307
307
  };
308
308
  var handleAddItemProduct = function () {
309
309
  var newItem = {
310
+ id: '',
310
311
  mode: 'Create',
311
- productId: '',
312
- quantity: '1',
313
312
  price: '',
313
+ quantity: '1',
314
314
  rowTotal: '',
315
315
  };
316
316
  dispatch({
@@ -354,6 +354,7 @@ var useInvoiceState = function () {
354
354
  body: JSON.stringify({ id: id }),
355
355
  });
356
356
  };
357
+ console.log('state', state);
357
358
  var handleSubmit = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
358
359
  var validationResult, validationErrors_1;
359
360
  return __generator(this, function (_a) {
@@ -361,6 +362,7 @@ var useInvoiceState = function () {
361
362
  type: actions_1.INVOICE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
362
363
  payload: { disableSaveButton: true },
363
364
  });
365
+ console.log('submit', updatedParams);
364
366
  try {
365
367
  validationResult = validate_1.formValidation === null || validate_1.formValidation === void 0 ? void 0 : validate_1.formValidation.safeParse(__assign({}, updatedParams));
366
368
  if (validationResult === null || validationResult === void 0 ? void 0 : validationResult.error) {
@@ -463,11 +465,11 @@ var useInvoiceState = function () {
463
465
  var _b, _c, _d;
464
466
  var index = _a.index, key = _a.key, value = _a.value;
465
467
  var updatedItems = __spreadArray([], state.products, true);
466
- if (key === 'productId' && typeof value === 'string') {
468
+ if (key === 'id' && typeof value === 'string') {
467
469
  var matchingProduct = products === null || products === void 0 ? void 0 : products.find(function (product) { return product.id === value; });
468
470
  if (matchingProduct) {
469
471
  var quantity = parseFloat(String(updatedItems[index].quantity)) || 0;
470
- var rowTotal = (quantity * Number(matchingProduct.salePrice)).toFixed(2);
472
+ var rowTotal = (quantity * parseFloat(matchingProduct.salePrice)).toFixed(2);
471
473
  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));
472
474
  var allServices = state.services;
473
475
  var subtotal = (0, calculate_subtotal_1.calculateSubtotal)(allServices, updatedItems);
@@ -38,7 +38,7 @@ var ProductsSection = function () {
38
38
  key: k,
39
39
  value: val.id,
40
40
  });
41
- }, handleOnBlur: handleChange, handleInputOnChange: handleChange, label: "Product", listItems: productList, nodeQueryKey: 'productQuery', nodeSelectKey: 'productId', query: '', selectKey1: 'name', selectedItem: { id: products[index].productId } })),
41
+ }, handleOnBlur: handleChange, handleInputOnChange: handleChange, label: "Product", listItems: productList, nodeQueryKey: 'productQuery', nodeSelectKey: 'id', query: '', selectKey1: 'name', selectedItem: { id: products[index].id } })),
42
42
  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(products[index].quantity), type: 'text' }),
43
43
  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: products[index].price, type: 'number' }),
44
44
  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: products[index].rowTotal, type: 'number', readOnly: true }),
@@ -93,7 +93,7 @@ exports.initialInvoiceState = {
93
93
  {
94
94
  mode: 'Create',
95
95
  price: '',
96
- productId: '',
96
+ id: '',
97
97
  quantity: '1',
98
98
  rowTotal: '',
99
99
  },
@@ -44,10 +44,10 @@ export interface InvoiceContextType {
44
44
  updateLoading: boolean;
45
45
  }
46
46
  export interface Product {
47
- productId: string;
48
- quantity: string;
49
- price: string;
47
+ id: string;
50
48
  mode: 'Create' | 'Edit' | '';
49
+ price: string;
50
+ quantity: string;
51
51
  rowTotal: string;
52
52
  }
53
53
  export interface Service {
@@ -16,14 +16,14 @@ export declare const formValidation: z.ZodObject<{
16
16
  price: z.ZodOptional<z.ZodString>;
17
17
  total: z.ZodOptional<z.ZodString>;
18
18
  }, "strip", z.ZodTypeAny, {
19
- quantity?: string | undefined;
20
19
  price?: string | undefined;
20
+ quantity?: string | undefined;
21
21
  name?: string | undefined;
22
22
  description?: string | undefined;
23
23
  total?: string | undefined;
24
24
  }, {
25
- quantity?: string | undefined;
26
25
  price?: string | undefined;
26
+ quantity?: string | undefined;
27
27
  name?: string | undefined;
28
28
  description?: string | undefined;
29
29
  total?: string | undefined;
@@ -32,24 +32,24 @@ export declare const formValidation: z.ZodObject<{
32
32
  productId: z.ZodOptional<z.ZodString>;
33
33
  quantity: z.ZodOptional<z.ZodString>;
34
34
  }, "strip", z.ZodTypeAny, {
35
- productId?: string | undefined;
36
35
  quantity?: string | undefined;
37
- }, {
38
36
  productId?: string | undefined;
37
+ }, {
39
38
  quantity?: string | undefined;
39
+ productId?: string | undefined;
40
40
  }>, "many">;
41
41
  }, "strip", z.ZodTypeAny, {
42
42
  currency: string;
43
43
  date: string;
44
44
  expiryDate: string;
45
45
  products: {
46
- productId?: string | undefined;
47
46
  quantity?: string | undefined;
47
+ productId?: string | undefined;
48
48
  }[];
49
49
  ref: string;
50
50
  services: {
51
- quantity?: string | undefined;
52
51
  price?: string | undefined;
52
+ quantity?: string | undefined;
53
53
  name?: string | undefined;
54
54
  description?: string | undefined;
55
55
  total?: string | undefined;
@@ -64,13 +64,13 @@ export declare const formValidation: z.ZodObject<{
64
64
  date: string;
65
65
  expiryDate: string;
66
66
  products: {
67
- productId?: string | undefined;
68
67
  quantity?: string | undefined;
68
+ productId?: string | undefined;
69
69
  }[];
70
70
  ref: string;
71
71
  services: {
72
- quantity?: string | undefined;
73
72
  price?: string | undefined;
73
+ quantity?: string | undefined;
74
74
  name?: string | undefined;
75
75
  description?: string | undefined;
76
76
  total?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/stellar-solutions-invoice-module",
3
- "version": "0.1.33",
3
+ "version": "0.1.35",
4
4
  "scripts": {
5
5
  "build": "yarn clean && yarn build:ts && cp package.json lib && cp README.md lib",
6
6
  "build:next": "next build",