@appcorp/stellar-solutions-invoice-module 0.1.48 → 0.1.49

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.
@@ -10,7 +10,7 @@ var calculateTotal = function (subtotal, taxRate, discountUnit, discount) {
10
10
  ? (subtotalValue * discountValue) / 100
11
11
  : discountValue;
12
12
  var afterDiscount = subtotalValue - discountedAmount;
13
- var tax = ((afterDiscount * parseFloat(taxRate)) / 100).toFixed(2);
13
+ var tax = taxRate ? ((afterDiscount * parseFloat(taxRate)) / 100).toFixed(2) : Number(0).toFixed(2);
14
14
  var total = (subtotalValue +
15
15
  parseFloat(tax) -
16
16
  discountedAmount).toFixed(2);
@@ -38,6 +38,12 @@ export declare const tableBodyCols: ({
38
38
  componentType: VISTA_TABLE_CELL_TYPE;
39
39
  key: string[];
40
40
  expression: (text: string) => string;
41
+ } | {
42
+ componentType: VISTA_TABLE_CELL_TYPE;
43
+ key: string;
44
+ expression: (text: string, obj: {
45
+ currency: string;
46
+ }) => string;
41
47
  } | {
42
48
  componentType: VISTA_TABLE_CELL_TYPE;
43
49
  key?: undefined;
@@ -128,7 +128,6 @@ exports.staticCompanySection = (_a = {},
128
128
  exports.staticCustomerSection = (_b = {},
129
129
  _b[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_INPUT_V1] = [
130
130
  {
131
- className: 'col-span-2',
132
131
  disabled: false,
133
132
  enabled: true,
134
133
  error: '',
@@ -136,7 +135,7 @@ exports.staticCustomerSection = (_b = {},
136
135
  id: 'phone',
137
136
  label: 'Phone',
138
137
  order: 1,
139
- placeholder: '03** *****',
138
+ placeholder: '+92 300 0000000',
140
139
  required: true,
141
140
  type: 'text',
142
141
  value: ''
@@ -224,6 +223,22 @@ exports.staticCustomerSection = (_b = {},
224
223
  selectKey1: 'name',
225
224
  selectedItem: { name: '' },
226
225
  },
226
+ {
227
+ enabled: true,
228
+ handleInputOnChange: function () { return void 0; },
229
+ handleOnBlur: function () { return void 0; },
230
+ handleOnChange: function () { },
231
+ label: 'Currency',
232
+ listItems: [],
233
+ nodeQueryKey: '',
234
+ nodeSelectKey: 'currency',
235
+ order: 7,
236
+ placeholder: '',
237
+ query: '',
238
+ required: true,
239
+ selectKey1: 'code',
240
+ selectedItem: { code: '' },
241
+ },
227
242
  ],
228
243
  _b);
229
244
  exports.staticPricingSection = (_c = {},
@@ -515,21 +530,13 @@ exports.tableBodyCols = [
515
530
  },
516
531
  {
517
532
  componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.OBJECT,
518
- key: ['company', 'name'],
519
- },
520
- {
521
- componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
522
- key: 'currency',
533
+ key: ['company:customer', 'name:firstName'],
523
534
  },
524
535
  {
525
536
  componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.MULTIPLE_TEXT_LINES,
526
537
  key: ['date', 'expiryDate'],
527
538
  expression: function (text) { return (0, util_functions_1.formatDate)(text, util_functions_1.DATE_FORMATS.LOCALE_DATE); },
528
539
  },
529
- {
530
- componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
531
- key: 'note',
532
- },
533
540
  {
534
541
  componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
535
542
  key: 'ref',
@@ -537,6 +544,7 @@ exports.tableBodyCols = [
537
544
  {
538
545
  componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
539
546
  key: 'subTotal',
547
+ expression: function (text, obj) { return "".concat(obj.currency).concat(text); },
540
548
  },
541
549
  {
542
550
  componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
@@ -549,6 +557,7 @@ exports.tableBodyCols = [
549
557
  {
550
558
  componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
551
559
  key: 'total',
560
+ expression: function (text, obj) { return "".concat(obj.currency).concat(text); },
552
561
  },
553
562
  {
554
563
  componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
@@ -107,10 +107,12 @@ var date_fns_1 = require("date-fns");
107
107
  var calculate_total_1 = require("./calculate-total");
108
108
  var util_functions_2 = require("@react-pakistan/util-functions");
109
109
  var context_2 = require("@appcorp/stellar-solutions-modules/global-modules/tax/context");
110
+ var context_3 = require("@appcorp/stellar-solutions-modules/global-modules/preferences/context");
110
111
  var useInvoiceState = function () {
111
112
  var _a = (0, react_1.useReducer)(reducer_1.invoiceReducer, reducer_1.initialInvoiceState), state = _a[0], dispatch = _a[1];
112
113
  var companies = (0, context_1.useCompanyStateContext)().companies;
113
114
  var taxes = (0, context_2.useTaxStateContext)().taxes;
115
+ var currencies = (0, context_3.usePreferenceStateContext)().currencies;
114
116
  var debouncedQuery = (0, util_functions_1.useDebounce)(state.searchQuery, 800);
115
117
  var debouncedProductList = (0, util_functions_1.useDebounce)(state.productQuery, 800);
116
118
  var debouncedCustomerList = (0, util_functions_1.useDebounce)(state.phone, 800);
@@ -121,6 +123,12 @@ var useInvoiceState = function () {
121
123
  return isDefault;
122
124
  })[0];
123
125
  }, [taxes]);
126
+ var defaultCurrency = (0, react_1.useMemo)(function () {
127
+ return currencies.filter(function (_a) {
128
+ var isDefault = _a.isDefault;
129
+ return isDefault;
130
+ })[0];
131
+ }, [currencies]);
124
132
  var listParams = {
125
133
  category: types_1.QUOTE_INVOICE.INVOICE,
126
134
  currentPage: state.currentPage,
@@ -150,6 +158,12 @@ var useInvoiceState = function () {
150
158
  category: state.category,
151
159
  companyId: state.companyId,
152
160
  currency: state.currency,
161
+ city: state.city,
162
+ country: state.country,
163
+ firstName: state.firstName,
164
+ lastName: state.lastName,
165
+ address: state.address,
166
+ phone: state.phone,
153
167
  customerId: state.customerId,
154
168
  date: state.date,
155
169
  discount: state.discount.trim(),
@@ -307,7 +321,7 @@ var useInvoiceState = function () {
307
321
  }); })();
308
322
  }, [debouncedProductList]);
309
323
  (0, react_1.useEffect)(function () {
310
- if (state.formToRender === 'customer' && debouncedCustomerList) {
324
+ if (state.drawer === types_1.INVOICE_DRAWER.INVOICE_CUSTOMER_FORM_DRAWER && debouncedCustomerList) {
311
325
  (function () { return __awaiter(void 0, void 0, void 0, function () {
312
326
  var data;
313
327
  return __generator(this, function (_a) {
@@ -324,7 +338,7 @@ var useInvoiceState = function () {
324
338
  if (data) {
325
339
  dispatch({
326
340
  type: actions_1.INVOICE_ACTION_TYPES.SET_CUSTOMER,
327
- payload: { customer: __assign({}, data.data) },
341
+ payload: { customer: __assign(__assign({}, data), { customerId: data.id }) },
328
342
  });
329
343
  }
330
344
  return [2 /*return*/];
@@ -338,7 +352,7 @@ var useInvoiceState = function () {
338
352
  payload: { customer: { phone: '', firstName: '', lastName: '', email: '', address: '', city: '', country: '', createdAt: '', updatedAt: '', id: '', invoices: [] } },
339
353
  });
340
354
  }
341
- }, [debouncedCustomerList, state.formToRender]);
355
+ }, [debouncedCustomerList, state.formToRender, state.drawer]);
342
356
  (0, react_1.useEffect)(function () {
343
357
  (function () { return __awaiter(void 0, void 0, void 0, function () {
344
358
  var data;
@@ -429,20 +443,12 @@ var useInvoiceState = function () {
429
443
  type: actions_1.INVOICE_ACTION_TYPES.SET_DRAWER,
430
444
  payload: { drawer: types_1.INVOICE_DRAWER.INVOICE_COMPANY_FORM_DRAWER },
431
445
  });
432
- dispatch({
433
- type: actions_1.INVOICE_ACTION_TYPES.SET_FORM_TO_RENDER,
434
- payload: { formToRender: 'company' },
435
- });
436
446
  }
437
447
  if (text === 'customer') {
438
448
  dispatch({
439
449
  type: actions_1.INVOICE_ACTION_TYPES.SET_DRAWER,
440
450
  payload: { drawer: types_1.INVOICE_DRAWER.INVOICE_CUSTOMER_FORM_DRAWER },
441
451
  });
442
- dispatch({
443
- type: actions_1.INVOICE_ACTION_TYPES.SET_FORM_TO_RENDER,
444
- payload: { formToRender: 'customer' },
445
- });
446
452
  }
447
453
  };
448
454
  var handleEdit = function (id) {
@@ -461,11 +467,11 @@ var useInvoiceState = function () {
461
467
  payload: { disableSaveButton: true },
462
468
  });
463
469
  (0, util_functions_1.validateForm)({
464
- params: updateParams,
470
+ params: __assign(__assign({}, updateParams), { currency: updateParams.currency || defaultCurrency.code, taxRate: updateParams.taxRate || defaultTax.taxRate }),
465
471
  schema: validate_1.formValidation,
466
472
  successCallback: function () {
467
473
  updateFetchNow(undefined, {
468
- body: JSON.stringify(__assign(__assign({}, updateParams), { products: updateParams.products.filter(function (item) { return item.id; }), services: updateParams.services.filter(function (item) { return item.name; }) })),
474
+ body: JSON.stringify(__assign(__assign({}, updateParams), { products: updateParams.products.filter(function (item) { return item.id; }), services: updateParams.services.filter(function (item) { return item.name; }), currency: updateParams.currency || defaultCurrency.code, taxRate: updateParams.taxRate || defaultTax.taxRate })),
469
475
  });
470
476
  },
471
477
  errorCallback: function (e) {
@@ -475,18 +481,8 @@ var useInvoiceState = function () {
475
481
  });
476
482
  },
477
483
  });
478
- }, [updateFetchNow, updateParams]);
484
+ }, [updateFetchNow, updateParams, defaultCurrency, defaultTax]);
479
485
  var handleChange = (0, react_1.useCallback)(function (key, value) {
480
- console.log({ key: key, value: value });
481
- // if (key === 'taxRate') {
482
- // dispatch({
483
- // type: INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
484
- // payload: {
485
- // key: key as keyof InvoiceTypeBE,
486
- // value: value,
487
- // },
488
- // });
489
- // }
490
486
  dispatch({
491
487
  type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
492
488
  payload: { key: key, value: String(value) },
@@ -587,47 +583,26 @@ var useInvoiceState = function () {
587
583
  type: actions_1.INVOICE_ACTION_TYPES.SET_DISCOUNT_UNIT,
588
584
  payload: { discountUnit: v },
589
585
  });
590
- // if (e.target.value === 'Percentage(%)') {
591
- // invoiceDispatch({
592
- // type: INVOICE_ACTION_TYPES.SET_DISCOUNT_UNIT,
593
- // payload: '%',
594
- // });
595
- // } else {
596
- // invoiceDispatch({
597
- // type: INVOICE_ACTION_TYPES.SET_DISCOUNT_UNIT,
598
- // payload: '',
599
- // });
600
- // }
601
586
  };
602
- // const handleSelectInputChange = useCallback(async (key: string, value: string) => {
603
- // const response = await fetch(INVOICE_CATEGORY_API_ROUTES.INVOICE_CATEGORIES, {
604
- // method: API_METHODS.POST,
605
- // body: JSON.stringify({
606
- // searchQuery: debouncedList,
607
- // pageLimit: 1000,
608
- // currentPage: 1,
609
- // }),
610
- // });
611
- // const result = await response.json();
612
- // dispatch({
613
- // type: INVOICE_ACTION_TYPES.SET_INVOICE_CATEGORIES,
614
- // payload: { productCategories: result as ProductCategoryBE[] },
615
- // });
616
- // dispatch({
617
- // type: INVOICE_ACTION_TYPES.SET_INVOICE_QUERY,
618
- // payload: { productCategoryQuery: value },
619
- // });
620
- // }, []);
621
587
  var handleSelectChange = function (key, value) {
622
588
  var val = __assign({}, value);
623
- console.log('seleect', key, value);
624
589
  if (key === 'taxRate') {
625
590
  dispatch({
626
591
  type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
627
592
  payload: {
628
593
  key: key,
629
- value: val[key],
630
- }
594
+ value: val.taxRate,
595
+ },
596
+ });
597
+ return;
598
+ }
599
+ if (key === 'country') {
600
+ dispatch({
601
+ type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
602
+ payload: {
603
+ key: key,
604
+ value: val.name,
605
+ },
631
606
  });
632
607
  return;
633
608
  }
@@ -636,8 +611,8 @@ var useInvoiceState = function () {
636
611
  type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
637
612
  payload: {
638
613
  key: key,
639
- value: val['option'],
640
- }
614
+ value: val.code,
615
+ },
641
616
  });
642
617
  return;
643
618
  }
@@ -741,9 +716,13 @@ var useInvoiceState = function () {
741
716
  comboboxElements[0].handleOnChange = handleSelectChange;
742
717
  comboboxElements[0].handleInputOnChange = handleChange;
743
718
  comboboxElements[0].handleOnBlur = handleChange;
719
+ comboboxElements[1].selectedItem = { code: state.currency || (defaultCurrency === null || defaultCurrency === void 0 ? void 0 : defaultCurrency.code) };
720
+ comboboxElements[1].listItems = currencies;
721
+ comboboxElements[1].handleOnChange = handleSelectChange;
722
+ comboboxElements[1].handleInputOnChange = handleChange;
744
723
  }
745
724
  return elements;
746
- }, [state, handleChange]);
725
+ }, [state, handleChange, currencies, defaultCurrency]);
747
726
  var dynamicPricingFormElements = (0, react_1.useMemo)(function () {
748
727
  var _a, _b, _c, _d, _e, _f;
749
728
  var elements = __assign({}, constants_1.staticPricingSection);
@@ -796,113 +775,6 @@ var useInvoiceState = function () {
796
775
  });
797
776
  }
798
777
  };
799
- // const dynamicServiceFormElements: VistaFormElements[] = useMemo(() => {
800
- // const elements: VistaFormElements = { ...staticServiceSection };
801
- // const servicesElements = state.services.map(() => ({
802
- // ...elements,
803
- // }));
804
- // servicesElements?.map((element, i) => {
805
- // const textInputElements: VistaTextInputV1Props[] | undefined = element[VISTA_FORM_ELEMENTS.TEXT_INPUT_V1]?.sort((a, b) => a.order - b.order);
806
- // if (textInputElements) {
807
- // textInputElements[0].value = state.services[i].name;
808
- // textInputElements[0].handleOnChange = (k, v) => handleItemChangeServices({
809
- // index: i,
810
- // key: k as keyof Service,
811
- // value: v,
812
- // });
813
- // textInputElements[1].value = state.services[i].description;
814
- // textInputElements[1].handleOnChange = (k, v) => handleItemChangeServices({
815
- // index: i,
816
- // key: k as keyof Service,
817
- // value: v,
818
- // });
819
- // textInputElements[2].value = state.services[i].quantity;
820
- // textInputElements[2].handleOnChange = (k, v) => handleItemChangeServices({
821
- // index: i,
822
- // key: k as keyof Service,
823
- // value: v,
824
- // });
825
- // textInputElements[3].value = state.services[i].price;
826
- // textInputElements[3].handleOnChange = (k, v) => handleItemChangeServices({
827
- // index: i,
828
- // key: k as keyof Service,
829
- // value: v,
830
- // });
831
- // textInputElements[4].value = state.services[i].rowTotal;
832
- // }
833
- // // state.services?.forEach((service, i) => {
834
- // // textInputElements[i].error = state.errors[id];
835
- // // textInputElements[i].error = state.errors[id];
836
- // // textInputElements[i].error = state.errors[id];
837
- // // textInputElements[i].error = state.errors[id];
838
- // // textInputElements[i].error = state.errors[id];
839
- // const buttonElements = element[VISTA_FORM_ELEMENTS.BUTTON_V1]?.sort((a, b) => a.order - b.order);
840
- // if (buttonElements) {
841
- // // state.services?.forEach((service, i) => {
842
- // buttonElements[0].handleOnClick = () => {
843
- // if (state.services.length > 1) {
844
- // const res = state.services.splice(i, 1);
845
- // dispatch({
846
- // type: INVOICE_ACTION_TYPES.DELETE_ITEM_SERVICE,
847
- // payload: { services: [...res] },
848
- // });
849
- // }
850
- // }
851
- // // });
852
- // }
853
- // });
854
- // // }
855
- // return servicesElements;
856
- // }, [state.services, handleItemChangeServices]);
857
- // const dynamicProductFormElements: VistaFormElements = useMemo(() => {
858
- // const elements: VistaFormElements = { ...staticProductSection };
859
- // const textInputElements: VistaTextInputV1Props[] | undefined = elements[VISTA_FORM_ELEMENTS.TEXT_INPUT_V1]?.sort((a, b) => a.order - b.order);
860
- // if (textInputElements) {
861
- // state.products?.forEach((product, i) => {
862
- // textInputElements[0].value = String(product.quantity);
863
- // textInputElements[0].handleOnChange = (k, v) => handleItemChangeProducts({
864
- // index: i,
865
- // key: k as keyof Product,
866
- // value: Number(v),
867
- // });
868
- // // textInputElements[i].error = state.errors[id];
869
- // textInputElements[2].value = product.rowTotal;
870
- // });
871
- // }
872
- // const comboboxElements: VistaComboboxV1Props[] | undefined = elements[VISTA_FORM_ELEMENTS.COMBOBOX_V1]?.sort((a, b) => a.order - b.order);
873
- // if (comboboxElements) {
874
- // state.products?.forEach((product, i) => {
875
- // comboboxElements[0].listItems = products;
876
- // comboboxElements[0].query = state.productQuery;
877
- // comboboxElements[0].handleInputOnChange = handleChange;
878
- // comboboxElements[0].handleOnBlur = handleChange;
879
- // comboboxElements[0].handleOnChange = (k, v: object) => {
880
- // console.log('_>>>>>>>>>', k, v);
881
- // const val = { ...v } as { id: string };
882
- // handleItemChangeProducts({
883
- // index: i,
884
- // key: k as keyof Product,
885
- // value: val.id,
886
- // });
887
- // }
888
- // })
889
- // }
890
- // const buttonElements = elements[VISTA_FORM_ELEMENTS.BUTTON_V1]?.sort((a, b) => a.order - b.order);
891
- // if (buttonElements) {
892
- // state.products?.forEach((product, i) => {
893
- // buttonElements[0].handleOnClick = () => {
894
- // if (state.products.length > 1) {
895
- // const res = state.products.splice(i, 1);
896
- // dispatch({
897
- // type: INVOICE_ACTION_TYPES.DELETE_ITEM_PRODUCT,
898
- // payload: { products: [...res] },
899
- // });
900
- // }
901
- // }
902
- // });
903
- // }
904
- // return elements;
905
- // }, [state, handleItemChangeProducts, products, handleChange]);
906
778
  var headerActions = [
907
779
  {
908
780
  enabled: true,
@@ -914,7 +786,7 @@ var useInvoiceState = function () {
914
786
  enabled: true,
915
787
  handleOnClick: function () { return handleCreate('customer'); },
916
788
  label: 'Invoice for Customer',
917
- order: 1,
789
+ order: 2,
918
790
  },
919
791
  ];
920
792
  var rowActions = [
@@ -931,16 +803,9 @@ var useInvoiceState = function () {
931
803
  order: 2,
932
804
  },
933
805
  ];
934
- return __assign(__assign({}, state), { byIdError: byIdError, byIdLoading: byIdLoading, clearSearch: clearSearch, closeDrawer: closeDrawer, deleteError: deleteError, deleteLoading: deleteLoading, dispatch: dispatch, dynamicCompanyFormElements: dynamicCompanyFormElements, dynamicPricingFormElements: dynamicPricingFormElements,
935
- // dynamicProductFormElements,
936
- // dynamicServiceFormElements,
937
- dynamicCustomerFormElements: dynamicCustomerFormElements, handleChange: handleChange, handleNextClick: handleNextClick, handlePageLimit: handlePageLimit, handlePreviousClick: handlePreviousClick, handleSubmit: handleSubmit,
938
- // handleUploadImage,
939
- headerActions: headerActions, listError: listError, listFetchNow: listFetchNow, listLoading: listLoading, rowActions: rowActions, searchOnChange: searchOnChange, updateError: updateError, updateLoading: updateLoading, handleAddItemService: handleAddItemService, handleAddItemProduct: handleAddItemProduct, handleItemChangeServices: handleItemChangeServices, handleDeleteServiceRow: handleDeleteServiceRow, handleItemChangeProducts: handleItemChangeProducts, handleDeleteProductRow: handleDeleteProductRow });
806
+ return __assign(__assign({}, state), { byIdError: byIdError, byIdLoading: byIdLoading, clearSearch: clearSearch, closeDrawer: closeDrawer, deleteError: deleteError, deleteLoading: deleteLoading, dispatch: dispatch, dynamicCompanyFormElements: dynamicCompanyFormElements, dynamicPricingFormElements: dynamicPricingFormElements, dynamicCustomerFormElements: dynamicCustomerFormElements, handleChange: handleChange, handleNextClick: handleNextClick, handlePageLimit: handlePageLimit, handlePreviousClick: handlePreviousClick, handleSubmit: handleSubmit, headerActions: headerActions, listError: listError, listFetchNow: listFetchNow, listLoading: listLoading, rowActions: rowActions, searchOnChange: searchOnChange, updateError: updateError, updateLoading: updateLoading, handleAddItemService: handleAddItemService, handleAddItemProduct: handleAddItemProduct, handleItemChangeServices: handleItemChangeServices, handleDeleteServiceRow: handleDeleteServiceRow, handleItemChangeProducts: handleItemChangeProducts, handleDeleteProductRow: handleDeleteProductRow });
940
807
  };
941
- 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; }, dynamicCompanyFormElements: {}, dynamicPricingFormElements: {}, dynamicCustomerFormElements: {}, 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; },
942
- // handleUploadImage: () => void 0,
943
- headerActions: [], listError: undefined, listFetchNow: function () { return void 0; }, listLoading: false, rowActions: [], searchOnChange: function () { return void 0; }, updateError: undefined, updateLoading: false, handleAddItemService: function () { return void 0; }, handleAddItemProduct: function () { return void 0; }, handleItemChangeServices: function () { return void 0; }, handleDeleteServiceRow: function () { return void 0; }, handleItemChangeProducts: function () { return void 0; }, handleDeleteProductRow: function () { return void 0; } }));
808
+ 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; }, dynamicCompanyFormElements: {}, dynamicPricingFormElements: {}, dynamicCustomerFormElements: {}, 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; }, headerActions: [], listError: undefined, listFetchNow: function () { return void 0; }, listLoading: false, rowActions: [], searchOnChange: function () { return void 0; }, updateError: undefined, updateLoading: false, handleAddItemService: function () { return void 0; }, handleAddItemProduct: function () { return void 0; }, handleItemChangeServices: function () { return void 0; }, handleDeleteServiceRow: function () { return void 0; }, handleItemChangeProducts: function () { return void 0; }, handleDeleteProductRow: function () { return void 0; } }));
944
809
  var InvoiceStateContextProvider = function (_a) {
945
810
  var children = _a.children;
946
811
  var state = useInvoiceState();
@@ -12,11 +12,12 @@ var services_form_section_1 = require("./services-form-section");
12
12
  var company_form_section_1 = require("./company-form-section");
13
13
  var context_1 = require("./context");
14
14
  var customer_form_section_1 = require("./customer-form-section");
15
+ var types_1 = require("./types");
15
16
  var InvoiceForm = function () {
16
- var formToRender = (0, context_1.useInvoiceStateContext)().formToRender;
17
+ var drawer = (0, context_1.useInvoiceStateContext)().drawer;
17
18
  return (react_1.default.createElement("div", { className: "flex flex-col gap-8" },
18
- formToRender === 'customer' && (react_1.default.createElement(customer_form_section_1.CustomerSection, null)),
19
- formToRender === 'company' && (react_1.default.createElement(company_form_section_1.CompanySection, null)),
19
+ drawer === types_1.INVOICE_DRAWER.INVOICE_CUSTOMER_FORM_DRAWER && (react_1.default.createElement(customer_form_section_1.CustomerSection, null)),
20
+ drawer === types_1.INVOICE_DRAWER.INVOICE_COMPANY_FORM_DRAWER && (react_1.default.createElement(company_form_section_1.CompanySection, null)),
20
21
  react_1.default.createElement(services_form_section_1.ServicesSection, null),
21
22
  react_1.default.createElement(products_form_section_1.ProductsSection, null),
22
23
  react_1.default.createElement(add_service_product_section_1.AddServiceProductSection, null),
@@ -14,9 +14,7 @@ var constants_1 = require("./constants");
14
14
  var drawer_1 = require("./drawer");
15
15
  var generate_toast_1 = require("@appcorp/app-corp-vista/utils/generate-toast");
16
16
  var InvoicePage = function () {
17
- var _a = (0, context_1.useInvoiceStateContext)(), count = _a.count, currentPage = _a.currentPage, pageLimit = _a.pageLimit, handleNextClick = _a.handleNextClick, handlePreviousClick = _a.handlePreviousClick,
18
- // toggleDrawerOpen,
19
- headerActions = _a.headerActions, handlePageLimit = _a.handlePageLimit, searchQuery = _a.searchQuery, searchOnChange = _a.searchOnChange, rowActions = _a.rowActions, invoices = _a.invoices, listLoading = _a.listLoading;
17
+ var _a = (0, context_1.useInvoiceStateContext)(), count = _a.count, currentPage = _a.currentPage, pageLimit = _a.pageLimit, handleNextClick = _a.handleNextClick, handlePreviousClick = _a.handlePreviousClick, headerActions = _a.headerActions, handlePageLimit = _a.handlePageLimit, searchQuery = _a.searchQuery, searchOnChange = _a.searchOnChange, rowActions = _a.rowActions, invoices = _a.invoices, listLoading = _a.listLoading;
20
18
  var t = (0, next_intl_1.useTranslations)('invoicePage');
21
19
  var translationMap = {
22
20
  formLabelName: 'formLabelName',
@@ -38,18 +36,10 @@ var InvoicePage = function () {
38
36
  label: t('tableColumnHeaderName'),
39
37
  width: '10%',
40
38
  },
41
- {
42
- label: t('tableColumnHeaderCurrency'),
43
- width: '5%',
44
- },
45
39
  {
46
40
  label: t('tableColumnHeaderIssueExpiryDate'),
47
41
  width: '10%',
48
42
  },
49
- {
50
- label: t('tableColumnHeaderNote'),
51
- width: '5%',
52
- },
53
43
  {
54
44
  label: t('tableColumnHeaderRef'),
55
45
  width: '5%',
@@ -36,7 +36,7 @@ exports.initialInvoiceState = {
36
36
  count: 0,
37
37
  country: '',
38
38
  countryQuery: '',
39
- currency: 'PKR',
39
+ currency: '',
40
40
  contactsList: [],
41
41
  currentPage: 1,
42
42
  customerId: '',
@@ -26,9 +26,6 @@ var products = zod_1.z.object({
26
26
  exports.formValidation = zod_1.z.object({
27
27
  companyId: zod_1.z.string().optional(),
28
28
  ref: zod_1.z.string().nonempty(constants_1.validationErrors.ref),
29
- // invoiceStatus: z
30
- // .string()
31
- // .nonempty(formErrors[DASHBOARD_DRAWERS_FORMS.INVOICE].status),
32
29
  date: zod_1.z.string().nonempty(constants_1.validationErrors.date),
33
30
  expiryDate: zod_1.z
34
31
  .string()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/stellar-solutions-invoice-module",
3
- "version": "0.1.48",
3
+ "version": "0.1.49",
4
4
  "scripts": {
5
5
  "build": "yarn clean && yarn build:ts && cp package.json lib && cp README.md lib && cp yarn.lock lib",
6
6
  "build:next": "next build",
@@ -17,14 +17,14 @@
17
17
  "upgrade": "ncu -u"
18
18
  },
19
19
  "devDependencies": {
20
- "@appcorp/app-corp-vista": "^0.2.88",
20
+ "@appcorp/app-corp-vista": "^0.2.99",
21
21
  "@appcorp/stellar-solutions-company-module": "^0.1.29",
22
22
  "@appcorp/stellar-solutions-modules": "^0.1.28",
23
23
  "@appcorp/stellar-solutions-product-module": "^0.2.5",
24
24
  "@eslint/eslintrc": "^3",
25
25
  "@headlessui/react": "^2",
26
26
  "@heroicons/react": "^2",
27
- "@react-pakistan/util-functions": "^1.24.38",
27
+ "@react-pakistan/util-functions": "^1.24.39",
28
28
  "@supabase/supabase-js": "^2",
29
29
  "@tailwindcss/forms": "^0.5.10",
30
30
  "@tailwindcss/postcss": "^4",