@appcorp/stellar-solutions-invoice-module 0.1.60 → 0.1.61

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.
@@ -16,16 +16,16 @@ var lucide_react_1 = require("lucide-react");
16
16
  var button_1 = require("@appcorp/shadcn/components/button");
17
17
  var context_1 = require("./context");
18
18
  var AddServiceProductSection = function () {
19
- var t = (0, next_intl_1.useTranslations)("invoicePage");
19
+ var t = (0, next_intl_1.useTranslations)("invoice");
20
20
  var _a = (0, context_1.useInvoiceStateContext)(), handleAddItemProduct = _a.handleAddItemProduct, handleAddItemService = _a.handleAddItemService;
21
21
  return (react_1.default.createElement("div", { className: "flex items-center justify-center gap-3 rounded-lg border-2 border-dashed border-muted-foreground/25 p-6 hover:border-muted-foreground/50 transition-colors" },
22
- react_1.default.createElement("span", { className: "text-sm text-muted-foreground" }, t("addItemPrompt")),
22
+ react_1.default.createElement("span", { className: "text-sm text-muted-foreground" }, t("addItem")),
23
23
  react_1.default.createElement(button_1.Button, { onClick: handleAddItemService, size: "sm", type: "button", variant: "outline" },
24
24
  react_1.default.createElement(lucide_react_1.Plus, { className: "h-4 w-4 mr-2" }),
25
- t("buttonAddService")),
25
+ t("addItemService")),
26
26
  react_1.default.createElement("span", { className: "text-sm text-muted-foreground" }, t("addItemOr")),
27
27
  react_1.default.createElement(button_1.Button, { onClick: handleAddItemProduct, size: "sm", type: "button", variant: "outline" },
28
28
  react_1.default.createElement(lucide_react_1.Plus, { className: "h-4 w-4 mr-2" }),
29
- t("buttonAddProduct"))));
29
+ t("addItemProduct"))));
30
30
  };
31
31
  exports.AddServiceProductSection = AddServiceProductSection;
@@ -50,7 +50,7 @@ var context_1 = require("@appcorp/stellar-solutions-modules/global-modules/prefe
50
50
  var actions_1 = require("./actions");
51
51
  var context_2 = require("./context");
52
52
  var CompanySection = function () {
53
- var t = (0, next_intl_1.useTranslations)("invoicePage");
53
+ var t = (0, next_intl_1.useTranslations)("invoice");
54
54
  var currencies = (0, context_1.usePreferenceStateContext)().currencies;
55
55
  var _a = (0, context_2.useInvoiceStateContext)(), companiesList = _a.companiesList, companyId = _a.companyId, currency = _a.currency, date = _a.date, dispatch = _a.dispatch, errors = _a.errors, expiryDate = _a.expiryDate, note = _a.note, ref = _a.ref;
56
56
  var handleInputChange = (0, react_1.useCallback)(function (key, value) {
@@ -107,19 +107,19 @@ var CompanySection = function () {
107
107
  name: curr.code,
108
108
  }); });
109
109
  return (react_1.default.createElement("div", { className: "flex flex-col gap-4" },
110
- react_1.default.createElement("h3", { className: "text-lg font-semibold border-b pb-2" }, t("companySectionTitle")),
110
+ react_1.default.createElement("h3", { className: "text-lg font-semibold border-b pb-2" }, t("companyFormSectionTitle")),
111
111
  react_1.default.createElement("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4" },
112
112
  react_1.default.createElement("div", { className: "space-y-2" },
113
- react_1.default.createElement(combobox_1.CompanyCombobox, { companies: companiesList || [], error: errors.companyId, id: "companyId", label: t("formLabelCompany"), onSearchChange: handleCompanySearch, onValueChange: handleCompanyChange, placeholder: t("formPlaceholderCompany"), required: true, value: companyId || "" })),
113
+ react_1.default.createElement(combobox_1.CompanyCombobox, { companies: companiesList || [], error: errors.companyId, id: "companyId", info: t("companyFormInfoCompany"), label: t("companyFormLabelCompany"), onSearchChange: handleCompanySearch, onValueChange: handleCompanyChange, placeholder: t("companyFormPlaceholderCompany"), required: true, value: companyId || "" })),
114
114
  react_1.default.createElement("div", { className: "space-y-2" },
115
- react_1.default.createElement(input_1.Input, { error: errors.date, id: "date", label: t("formLabelDate"), onChange: function (e) { return handleInputChange("date", e.target.value); }, required: true, type: "date", value: date ? (0, date_fns_1.format)(new Date(date), "yyyy-MM-dd") : "" })),
115
+ react_1.default.createElement(input_1.Input, { error: errors.date, id: "date", info: t("companyFormInfoDate"), label: t("companyFormLabelDate"), onChange: function (e) { return handleInputChange("date", e.target.value); }, placeholder: t("companyFormPlaceholderDate"), required: true, type: "date", value: date ? (0, date_fns_1.format)(new Date(date), "yyyy-MM-dd") : "" })),
116
116
  react_1.default.createElement("div", { className: "space-y-2" },
117
- react_1.default.createElement(input_1.Input, { error: errors.expiryDate, id: "expiryDate", label: t("formLabelExpiryDate"), onChange: function (e) { return handleInputChange("expiryDate", e.target.value); }, required: true, type: "date", value: expiryDate ? (0, date_fns_1.format)(new Date(expiryDate), "yyyy-MM-dd") : "" })),
117
+ react_1.default.createElement(input_1.Input, { error: errors.expiryDate, id: "expiryDate", info: t("companyFormInfoExpiryDate"), label: t("companyFormLabelExpiryDate"), onChange: function (e) { return handleInputChange("expiryDate", e.target.value); }, placeholder: t("companyFormPlaceholderExpiryDate"), required: true, type: "date", value: expiryDate ? (0, date_fns_1.format)(new Date(expiryDate), "yyyy-MM-dd") : "" })),
118
118
  react_1.default.createElement("div", { className: "space-y-2" },
119
- react_1.default.createElement(combobox_1.CompanyCombobox, { companies: currencyOptions, error: errors.currency, id: "currency", label: t("formLabelCurrency"), onSearchChange: function () { }, onValueChange: handleCurrencyChange, placeholder: t("formPlaceholderCurrency"), required: true, value: currency || "" })),
119
+ react_1.default.createElement(combobox_1.CompanyCombobox, { companies: currencyOptions, error: errors.currency, id: "currency", info: t("companyFormInfoCurrency"), label: t("companyFormLabelCurrency"), onSearchChange: function () { }, onValueChange: handleCurrencyChange, placeholder: t("companyFormPlaceholderCurrency"), required: true, value: currency || "" })),
120
120
  react_1.default.createElement("div", { className: "space-y-2" },
121
- react_1.default.createElement(textarea_1.Textarea, { error: errors.note, id: "note", label: t("formLabelNote"), onChange: function (e) { return handleInputChange("note", e.target.value); }, placeholder: t("formPlaceholderNote"), rows: 3, value: note || "" })),
121
+ react_1.default.createElement(textarea_1.Textarea, { error: errors.note, id: "note", info: t("companyFormInfoNote"), label: t("companyFormLabelNote"), onChange: function (e) { return handleInputChange("note", e.target.value); }, placeholder: t("companyFormPlaceholderNote"), rows: 3, value: note || "" })),
122
122
  react_1.default.createElement("div", { className: "space-y-2" },
123
- react_1.default.createElement(input_1.Input, { error: errors.ref, id: "ref", label: t("formLabelRef"), onChange: function (e) { return handleInputChange("ref", e.target.value); }, readOnly: true, required: true, type: "text", value: ref || "" })))));
123
+ react_1.default.createElement(input_1.Input, { error: errors.ref, id: "ref", info: t("companyFormInfoReference"), label: t("companyFormLabelReference"), onChange: function (e) { return handleInputChange("ref", e.target.value); }, placeholder: t("companyFormPlaceholderReference"), readOnly: true, required: true, type: "text", value: ref || "" })))));
124
124
  };
125
125
  exports.CompanySection = CompanySection;
@@ -155,7 +155,8 @@ var useInvoiceState = function () {
155
155
  // State & Core Hooks
156
156
  // ---------------------------------------------------------------------------
157
157
  var _b = (0, react_1.useReducer)(reducer_1.invoiceReducer, reducer_1.initialInvoiceState), state = _b[0], dispatch = _b[1];
158
- var t = (0, next_intl_1.useTranslations)("toastMessages");
158
+ var t = (0, next_intl_1.useTranslations)("invoice");
159
+ var tCommon = (0, next_intl_1.useTranslations)("common");
159
160
  var theme = (0, next_themes_1.useTheme)().theme;
160
161
  var taxes = (0, context_1.useTaxStateContext)().taxes;
161
162
  var currencies = (0, context_2.usePreferenceStateContext)().currencies;
@@ -201,16 +202,16 @@ var useInvoiceState = function () {
201
202
  })[0];
202
203
  }, [currencies]);
203
204
  // ---------------------------------------------------------------------------
204
- // API Parameters (Memoized)
205
+ // API PARAMETERS
205
206
  // ---------------------------------------------------------------------------
206
- var listParams = {
207
+ var listParams = (0, react_1.useMemo)(function () { return ({
207
208
  category: types_1.QUOTE_INVOICE_CATEGORY.INVOICE,
208
209
  currentPage: state.currentPage,
210
+ includeCompany: true,
211
+ includeCustomer: true,
209
212
  pageLimit: state.pageLimit,
210
213
  searchQuery: state.searchQuery,
211
- includeCustomer: true,
212
- includeCompany: true,
213
- };
214
+ }); }, [state.currentPage, state.pageLimit, state.searchQuery]);
214
215
  var updateParams = (0, react_1.useMemo)(function () {
215
216
  var _a, _b, _c, _d, _e, _f, _g, _h;
216
217
  return ({
@@ -249,19 +250,16 @@ var useInvoiceState = function () {
249
250
  country: (_h = state.customer) === null || _h === void 0 ? void 0 : _h.country,
250
251
  });
251
252
  }, [state]);
252
- var byIdParams = {
253
- id: state.id,
254
- };
255
- var deleteParams = {
256
- id: state.id,
257
- };
253
+ var byIdParams = (0, react_1.useMemo)(function () { return ({ id: state.id }); }, [state.id]);
254
+ var deleteParams = (0, react_1.useMemo)(function () { return ({ id: state.id }); }, [state.id]);
258
255
  // ---------------------------------------------------------------------------
259
- // API Callbacks
256
+ // API CALLBACKS
260
257
  // ---------------------------------------------------------------------------
261
258
  var listCallback = (0, react_1.useCallback)(function (_a) {
262
259
  var data = _a.data, error = _a.error;
263
260
  if (error) {
264
- showErrorToast(t("networkError"));
261
+ showErrorToast(tCommon("messagesNetworkError"));
262
+ return;
265
263
  }
266
264
  if (data === null || data === void 0 ? void 0 : data.items) {
267
265
  dispatch({
@@ -273,20 +271,21 @@ var useInvoiceState = function () {
273
271
  payload: { count: data === null || data === void 0 ? void 0 : data.count },
274
272
  });
275
273
  }
276
- }, [t, showErrorToast]);
274
+ },
275
+ // eslint-disable-next-line react-hooks/exhaustive-deps
276
+ [showErrorToast]);
277
277
  var updateCallback = (0, react_1.useCallback)(function (_a) {
278
278
  var data = _a.data, error = _a.error;
279
279
  if (error) {
280
- showErrorToast(t("networkError"));
280
+ showErrorToast(tCommon("messagesNetworkError"));
281
+ return;
281
282
  }
282
283
  if (data) {
283
- showSuccessToast(state.mode === "Edit" ? t("invoiceUpdated") : t("invoiceCreated"));
284
- dispatch({
285
- type: actions_1.INVOICE_ACTION_TYPES.RESET_FORM,
286
- });
287
- dispatch({
288
- type: actions_1.INVOICE_ACTION_TYPES.RESET_ERRORS,
289
- });
284
+ showSuccessToast(state.mode === "Edit"
285
+ ? t("messagesInvoiceUpdated")
286
+ : t("messagesInvoiceCreated"));
287
+ dispatch({ type: actions_1.INVOICE_ACTION_TYPES.RESET_FORM });
288
+ dispatch({ type: actions_1.INVOICE_ACTION_TYPES.RESET_ERRORS });
290
289
  listFetchNow();
291
290
  dispatch({
292
291
  type: actions_1.INVOICE_ACTION_TYPES.SET_DRAWER,
@@ -295,12 +294,13 @@ var useInvoiceState = function () {
295
294
  }
296
295
  },
297
296
  // eslint-disable-next-line react-hooks/exhaustive-deps
298
- [t, state.mode, showErrorToast, showSuccessToast]);
297
+ [t, tCommon, state.mode, showErrorToast, showSuccessToast]);
299
298
  var byIdCallback = (0, react_1.useCallback)(function (_a) {
300
299
  var _b, _c, _d, _e, _f;
301
300
  var data = _a.data, error = _a.error;
302
301
  if (error) {
303
- showErrorToast(t("invoiceFetchError"));
302
+ showErrorToast(t("messagesInvoiceFetchError"));
303
+ return;
304
304
  }
305
305
  if (data) {
306
306
  var updatedServices = __spreadArray([], data === null || data === void 0 ? void 0 : data.services, true).map(function (item) {
@@ -347,18 +347,17 @@ var useInvoiceState = function () {
347
347
  var deleteCallback = (0, react_1.useCallback)(function (_a) {
348
348
  var data = _a.data, error = _a.error;
349
349
  if (error) {
350
- showErrorToast(t("networkError"));
350
+ showErrorToast(tCommon("messagesNetworkError"));
351
+ return;
351
352
  }
352
353
  if (data) {
353
- showSuccessToast(t("invoiceUpdated"));
354
- dispatch({
355
- type: actions_1.INVOICE_ACTION_TYPES.RESET_FORM,
356
- });
354
+ showSuccessToast(t("messagesInvoiceDeleted"));
355
+ dispatch({ type: actions_1.INVOICE_ACTION_TYPES.RESET_FORM });
357
356
  listFetchNow();
358
357
  }
359
358
  },
360
359
  // eslint-disable-next-line react-hooks/exhaustive-deps
361
- [t, showErrorToast, showSuccessToast]);
360
+ [t, tCommon, showErrorToast, showSuccessToast]);
362
361
  // ---------------------------------------------------------------------------
363
362
  // Module Entity Hook
364
363
  // ---------------------------------------------------------------------------
@@ -719,56 +718,69 @@ var useInvoiceState = function () {
719
718
  payload: { key: "productsList", value: updatedItems },
720
719
  });
721
720
  }, [state.servicesList, state.productsList, state.getProducts]);
722
- var handleNextClick = function () {
721
+ // ---------------------------------------------------------------------------
722
+ // PAGINATION HANDLERS
723
+ // ---------------------------------------------------------------------------
724
+ var handleNextClick = (0, react_1.useCallback)(function () {
723
725
  dispatch({
724
726
  type: actions_1.INVOICE_ACTION_TYPES.SET_CURRENT_PAGE,
725
727
  payload: { currentPage: state.currentPage + 1 },
726
728
  });
727
- };
728
- var handlePreviousClick = function () {
729
+ }, [state.currentPage]);
730
+ var handlePreviousClick = (0, react_1.useCallback)(function () {
729
731
  dispatch({
730
732
  type: actions_1.INVOICE_ACTION_TYPES.SET_CURRENT_PAGE,
731
733
  payload: { currentPage: state.currentPage - 1 },
732
734
  });
733
- };
734
- var handlePageLimit = function (k, value) {
735
+ }, [state.currentPage]);
736
+ var handlePageLimit = (0, react_1.useCallback)(function (k, value) {
735
737
  var val = __assign({}, value);
736
738
  dispatch({
737
739
  type: actions_1.INVOICE_ACTION_TYPES.SET_PAGE_LIMIT,
738
740
  payload: { pageLimit: Number(val.option) },
739
741
  });
740
- };
741
- var searchOnChange = function (k, v) {
742
+ // Reset to page 1 when page limit changes
743
+ dispatch({
744
+ type: actions_1.INVOICE_ACTION_TYPES.SET_CURRENT_PAGE,
745
+ payload: { currentPage: 1 },
746
+ });
747
+ }, []);
748
+ var searchOnChange = (0, react_1.useCallback)(function (k, v) {
742
749
  dispatch({
743
750
  type: actions_1.INVOICE_ACTION_TYPES.SET_SEARCH_QUERY,
744
751
  payload: { searchQuery: v },
745
752
  });
746
- };
747
- var clearSearch = function () {
753
+ }, []);
754
+ var clearSearch = (0, react_1.useCallback)(function () {
748
755
  dispatch({
749
756
  type: actions_1.INVOICE_ACTION_TYPES.SET_SEARCH_QUERY,
750
757
  payload: { searchQuery: "" },
751
758
  });
752
- };
753
- var handleTaxSearch = function (searchQuery) {
759
+ }, []);
760
+ // ---------------------------------------------------------------------------
761
+ // SEARCH HANDLERS
762
+ // ---------------------------------------------------------------------------
763
+ var handleTaxSearch = (0, react_1.useCallback)(function (searchQuery) {
754
764
  dispatch({
755
765
  type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
756
766
  payload: { key: "taxQuery", value: searchQuery },
757
767
  });
758
- };
759
- var closeDrawer = function () {
768
+ }, []);
769
+ // ---------------------------------------------------------------------------
770
+ // DRAWER & MODAL HANDLERS
771
+ // ---------------------------------------------------------------------------
772
+ var closeDrawer = (0, react_1.useCallback)(function () {
760
773
  dispatch({
761
774
  type: actions_1.INVOICE_ACTION_TYPES.SET_DRAWER,
762
775
  payload: { drawer: null },
763
776
  });
764
- dispatch({
765
- type: actions_1.INVOICE_ACTION_TYPES.RESET_FORM,
766
- });
767
- dispatch({
768
- type: actions_1.INVOICE_ACTION_TYPES.RESET_ERRORS,
769
- });
770
- };
771
- var handleDeleteServiceRow = function (i) {
777
+ dispatch({ type: actions_1.INVOICE_ACTION_TYPES.RESET_FORM });
778
+ dispatch({ type: actions_1.INVOICE_ACTION_TYPES.RESET_ERRORS });
779
+ }, []);
780
+ // ---------------------------------------------------------------------------
781
+ // FORM HANDLERS
782
+ // ---------------------------------------------------------------------------
783
+ var handleDeleteServiceRow = (0, react_1.useCallback)(function (i) {
772
784
  if (state.servicesList.length > 1) {
773
785
  var res = state.servicesList.splice(i, 1);
774
786
  dispatch({
@@ -776,8 +788,8 @@ var useInvoiceState = function () {
776
788
  payload: { servicesList: __spreadArray([], res, true) },
777
789
  });
778
790
  }
779
- };
780
- var handleDeleteProductRow = function (i) {
791
+ }, [state.servicesList]);
792
+ var handleDeleteProductRow = (0, react_1.useCallback)(function (i) {
781
793
  if (state.productsList.length > 1) {
782
794
  var res = state.productsList.splice(i, 1);
783
795
  dispatch({
@@ -785,8 +797,11 @@ var useInvoiceState = function () {
785
797
  payload: { productsList: __spreadArray([], res, true) },
786
798
  });
787
799
  }
788
- };
789
- var headerActions = [
800
+ }, [state.productsList]);
801
+ // ---------------------------------------------------------------------------
802
+ // TABLE ACTIONS
803
+ // ---------------------------------------------------------------------------
804
+ var headerActions = (0, react_1.useMemo)(function () { return [
790
805
  {
791
806
  enabled: true,
792
807
  handleOnClick: function () { return handleCreate("company"); },
@@ -799,8 +814,8 @@ var useInvoiceState = function () {
799
814
  label: "Invoice for Customer",
800
815
  order: 2,
801
816
  },
802
- ];
803
- var rowActions = [
817
+ ]; }, [handleCreate]);
818
+ var rowActions = (0, react_1.useMemo)(function () { return [
804
819
  {
805
820
  enabled: true,
806
821
  handleAction: function (id) { return handleEdit(id); },
@@ -819,7 +834,10 @@ var useInvoiceState = function () {
819
834
  label: "Delete",
820
835
  order: 3,
821
836
  },
822
- ];
837
+ ]; }, [handleEdit, handleRecordPayment, handleDelete]);
838
+ // ---------------------------------------------------------------------------
839
+ // RETURN STATE
840
+ // ---------------------------------------------------------------------------
823
841
  return __assign(__assign({}, state), { byIdError: byIdError, byIdLoading: byIdLoading, clearSearch: clearSearch, closeDrawer: closeDrawer, deleteError: deleteError, deleteLoading: deleteLoading, dispatch: dispatch, handleAddItemProduct: handleAddItemProduct, handleAddItemService: handleAddItemService, handleChange: handleChange, handleDeleteProductRow: handleDeleteProductRow, handleDeleteServiceRow: handleDeleteServiceRow, handleItemChangeProducts: handleItemChangeProducts, handleItemChangeServices: handleItemChangeServices, handleNextClick: handleNextClick, handlePageLimit: handlePageLimit, handlePreviousClick: handlePreviousClick, handleSubmit: handleSubmit, headerActions: headerActions, listError: listError, listFetchNow: listFetchNow, listLoading: listLoading, rowActions: rowActions, searchOnChange: searchOnChange, handleTaxSearch: handleTaxSearch, updateError: updateError, updateLoading: updateLoading });
824
842
  };
825
843
  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; }, handleAddItemProduct: function () { return void 0; }, handleAddItemService: function () { return void 0; }, handleChange: function () { return void 0; }, handleDeleteProductRow: function () { return void 0; }, handleDeleteServiceRow: function () { return void 0; }, handleItemChangeProducts: function () { return void 0; }, handleItemChangeServices: 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; }, handleTaxSearch: function () { return void 0; }, updateError: undefined, updateLoading: false }));
@@ -48,7 +48,7 @@ var input_1 = require("@appcorp/shadcn/components/input");
48
48
  var context_1 = require("./context");
49
49
  var actions_1 = require("./actions");
50
50
  var CustomerSection = function () {
51
- var t = (0, next_intl_1.useTranslations)("invoicePage");
51
+ var t = (0, next_intl_1.useTranslations)("invoice");
52
52
  var _a = (0, context_1.useInvoiceStateContext)(), customer = _a.customer, errors = _a.errors, dispatch = _a.dispatch;
53
53
  var handleCustomerChange = (0, react_1.useCallback)(function (key, value) {
54
54
  if (key === "phone") {
@@ -79,21 +79,21 @@ var CustomerSection = function () {
79
79
  handleCustomerChange("country", country);
80
80
  };
81
81
  return (react_1.default.createElement("div", { className: "flex flex-col gap-4" },
82
- react_1.default.createElement("h3", { className: "text-lg font-semibold border-b pb-2" }, t("customerSectionTitle")),
82
+ react_1.default.createElement("h3", { className: "text-lg font-semibold border-b pb-2" }, t("customerFormSectionTitle")),
83
83
  react_1.default.createElement("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4" },
84
84
  react_1.default.createElement("div", { className: "space-y-2" },
85
- react_1.default.createElement(input_1.Input, { id: "phone", type: "tel", label: t("formLabelPhone"), value: (customer === null || customer === void 0 ? void 0 : customer.phone) || "", onChange: function (e) { return handleCustomerChange("phone", e.target.value); }, placeholder: "+92 300 0000000", error: errors.phone, required: true })),
85
+ react_1.default.createElement(input_1.Input, { error: errors.phone, id: "phone", info: t("customerFormInfoPhone"), label: t("customerFormLabelPhone"), onChange: function (e) { return handleCustomerChange("phone", e.target.value); }, placeholder: t("customerFormPlaceholderPhone"), required: true, type: "tel", value: (customer === null || customer === void 0 ? void 0 : customer.phone) || "" })),
86
86
  react_1.default.createElement("div", { className: "space-y-2" },
87
- react_1.default.createElement(input_1.Input, { id: "firstName", type: "text", label: t("formLabelFirstName"), value: (customer === null || customer === void 0 ? void 0 : customer.firstName) || "", onChange: function (e) { return handleInputChange("firstName", e.target.value); }, placeholder: "John", error: errors.firstName, required: true })),
87
+ react_1.default.createElement(input_1.Input, { error: errors.firstName, id: "firstName", info: t("customerFormInfoFirstName"), label: t("customerFormLabelFirstName"), onChange: function (e) { return handleInputChange("firstName", e.target.value); }, placeholder: t("customerFormPlaceholderFirstName"), required: true, type: "text", value: (customer === null || customer === void 0 ? void 0 : customer.firstName) || "" })),
88
88
  react_1.default.createElement("div", { className: "space-y-2" },
89
- react_1.default.createElement(input_1.Input, { id: "lastName", type: "text", label: t("formLabelLastName"), value: (customer === null || customer === void 0 ? void 0 : customer.lastName) || "", onChange: function (e) { return handleInputChange("lastName", e.target.value); }, placeholder: "Doe", error: errors.lastName, required: true })),
89
+ react_1.default.createElement(input_1.Input, { error: errors.lastName, id: "lastName", info: t("customerFormInfoLastName"), label: t("customerFormLabelLastName"), onChange: function (e) { return handleInputChange("lastName", e.target.value); }, placeholder: t("customerFormPlaceholderLastName"), required: true, type: "text", value: (customer === null || customer === void 0 ? void 0 : customer.lastName) || "" })),
90
90
  react_1.default.createElement("div", { className: "space-y-2" },
91
- react_1.default.createElement(input_1.Input, { id: "email", type: "email", label: t("formLabelEmail"), value: (customer === null || customer === void 0 ? void 0 : customer.email) || "", onChange: function (e) { return handleInputChange("email", e.target.value); }, placeholder: "name@company.com", error: errors.email })),
91
+ react_1.default.createElement(input_1.Input, { error: errors.email, id: "email", info: t("customerFormInfoEmail"), label: t("customerFormLabelEmail"), onChange: function (e) { return handleInputChange("email", e.target.value); }, placeholder: t("customerFormPlaceholderEmail"), type: "email", value: (customer === null || customer === void 0 ? void 0 : customer.email) || "" })),
92
92
  react_1.default.createElement("div", { className: "space-y-2" },
93
- react_1.default.createElement(input_1.Input, { id: "address", type: "text", label: t("formLabelAddress"), value: (customer === null || customer === void 0 ? void 0 : customer.address) || "", onChange: function (e) { return handleInputChange("address", e.target.value); }, placeholder: "123 Street", error: errors.address })),
93
+ react_1.default.createElement(input_1.Input, { error: errors.address, id: "address", info: t("customerFormInfoAddress"), label: t("customerFormLabelAddress"), onChange: function (e) { return handleInputChange("address", e.target.value); }, placeholder: t("customerFormPlaceholderAddress"), type: "text", value: (customer === null || customer === void 0 ? void 0 : customer.address) || "" })),
94
94
  react_1.default.createElement("div", { className: "space-y-2" },
95
- react_1.default.createElement(input_1.Input, { id: "city", type: "text", label: t("formLabelCity"), value: (customer === null || customer === void 0 ? void 0 : customer.city) || "", onChange: function (e) { return handleInputChange("city", e.target.value); }, placeholder: "New York", error: errors.city, required: true })),
95
+ react_1.default.createElement(input_1.Input, { error: errors.city, id: "city", info: t("customerFormInfoCity"), label: t("customerFormLabelCity"), onChange: function (e) { return handleInputChange("city", e.target.value); }, placeholder: t("customerFormPlaceholderCity"), required: true, type: "text", value: (customer === null || customer === void 0 ? void 0 : customer.city) || "" })),
96
96
  react_1.default.createElement("div", { className: "space-y-2" },
97
- react_1.default.createElement(combobox_1.CountryCombobox, { countries: util_functions_1.countriesTimeZones, id: "country", label: t("formLabelCountry"), value: (customer === null || customer === void 0 ? void 0 : customer.country) || "", onValueChange: handleCountryChange, placeholder: t("formPlaceholderCountry"), error: errors.country, required: true })))));
97
+ react_1.default.createElement(combobox_1.CountryCombobox, { countries: util_functions_1.countriesTimeZones, error: errors.country, id: "country", info: t("customerFormInfoCountry"), label: t("customerFormLabelCountry"), onValueChange: handleCountryChange, placeholder: t("customerFormPlaceholderCountry"), required: true, value: (customer === null || customer === void 0 ? void 0 : customer.country) || "" })))));
98
98
  };
99
99
  exports.CustomerSection = CustomerSection;
@@ -21,7 +21,7 @@ var form_1 = require("./form");
21
21
  var types_1 = require("./types");
22
22
  var Drawer = function (_a) {
23
23
  var isRTL = _a.isRTL;
24
- var t = (0, next_intl_1.useTranslations)("invoicePage");
24
+ var t = (0, next_intl_1.useTranslations)("invoice");
25
25
  var _b = (0, context_1.useInvoiceStateContext)(), closeDrawer = _b.closeDrawer, disableSaveButton = _b.disableSaveButton, drawer = _b.drawer, handleSubmit = _b.handleSubmit;
26
26
  var isFormDrawer = drawer === types_1.INVOICE_DRAWER.INVOICE_COMPANY_FORM_DRAWER ||
27
27
  drawer === types_1.INVOICE_DRAWER.INVOICE_CUSTOMER_FORM_DRAWER;
@@ -17,7 +17,7 @@ var drawer_1 = require("./drawer");
17
17
  var InvoicePage = function () {
18
18
  var _a = (0, context_1.useInvoiceStateContext)(), count = _a.count, currentPage = _a.currentPage, handleNextClick = _a.handleNextClick, handlePageLimit = _a.handlePageLimit, handlePreviousClick = _a.handlePreviousClick, headerActions = _a.headerActions, invoices = _a.invoices, listLoading = _a.listLoading, pageLimit = _a.pageLimit, rowActions = _a.rowActions, searchOnChange = _a.searchOnChange, searchQuery = _a.searchQuery;
19
19
  var isRTL = (0, use_rtl_1.useRTL)();
20
- var t = (0, next_intl_1.useTranslations)("invoicePage");
20
+ var t = (0, next_intl_1.useTranslations)("invoice");
21
21
  var tableHeadItems = [
22
22
  {
23
23
  label: t("tableColumnHeaderId"),
@@ -62,7 +62,7 @@ var InvoicePage = function () {
62
62
  ];
63
63
  var totalPages = (0, util_functions_1.calculatePages)(count, pageLimit);
64
64
  return (react_1.default.createElement("div", { className: "space-y-4 ".concat(isRTL ? "rtl" : "ltr"), dir: isRTL ? "rtl" : "ltr" },
65
- react_1.default.createElement(enhanced_table_1.EnhancedTable, { currentPage: Number(currentPage), handleNextOnClick: handleNextClick, handleOnSelect: handlePageLimit, handlePreviousOnClick: handlePreviousClick, handleSearchInput: searchOnChange, headerActions: headerActions, isNextDisabled: (0, util_functions_1.isNextButtonDisabled)(currentPage, totalPages), isPreviousDisabled: (0, util_functions_1.isPreviousButtonDisabled)(currentPage), listOptions: (0, util_functions_1.getAvailablePageLimits)(count), loading: listLoading, nodeSelectKey: "pageLimit", pageLimit: pageLimit, rowActions: rowActions, searchDisabled: false, searchEnabled: true, searchId: "invoice-search", searchPlaceholder: "Enter ID or Name...", searchValue: searchQuery, tableBodyCols: constants_1.tableBodyCols, tableBodyRows: invoices, tableDescription: t("subTitle"), tableHeadItems: tableHeadItems, tableHeading: t("title"), totalPages: totalPages }),
65
+ react_1.default.createElement(enhanced_table_1.EnhancedTable, { currentPage: Number(currentPage), handleNextOnClick: handleNextClick, handleOnSelect: handlePageLimit, handlePreviousOnClick: handlePreviousClick, handleSearchInput: searchOnChange, headerActions: headerActions, isNextDisabled: (0, util_functions_1.isNextButtonDisabled)(currentPage, totalPages), isPreviousDisabled: (0, util_functions_1.isPreviousButtonDisabled)(currentPage), listOptions: (0, util_functions_1.getAvailablePageLimits)(count), loading: listLoading, nodeSelectKey: "pageLimit", pageLimit: pageLimit, rowActions: rowActions, searchDisabled: false, searchEnabled: true, searchId: "invoice-search", searchPlaceholder: t("tableSearchPlaceholder"), searchValue: searchQuery, tableBodyCols: constants_1.tableBodyCols, tableBodyRows: invoices, tableDescription: t("tableDescription"), tableHeadItems: tableHeadItems, tableHeading: t("tableTitle"), totalPages: totalPages }),
66
66
  react_1.default.createElement(drawer_1.Drawer, { isRTL: isRTL }),
67
67
  react_1.default.createElement(sonner_1.Toaster, null)));
68
68
  };
@@ -50,7 +50,7 @@ var context_1 = require("@appcorp/stellar-solutions-modules/global-modules/tax/c
50
50
  var context_2 = require("./context");
51
51
  var types_1 = require("./types");
52
52
  var PricingSection = function () {
53
- var t = (0, next_intl_1.useTranslations)("invoicePage");
53
+ var t = (0, next_intl_1.useTranslations)("invoice");
54
54
  var _a = (0, context_1.useTaxStateContext)(), taxesFromTaxContext = _a.taxes, taxesLoading = _a.listLoading;
55
55
  var _b = (0, context_2.useInvoiceStateContext)(), afterDiscount = _b.afterDiscount, discount = _b.discount, discountUnit = _b.discountUnit, errors = _b.errors, handleChange = _b.handleChange, handleTaxSearch = _b.handleTaxSearch, subTotal = _b.subTotal, tax = _b.tax, taxRate = _b.taxRate, total = _b.total;
56
56
  // Find the current tax based on taxRate value
@@ -58,42 +58,42 @@ var PricingSection = function () {
58
58
  return taxesFromTaxContext === null || taxesFromTaxContext === void 0 ? void 0 : taxesFromTaxContext.find(function (t) { return String(t.taxRate) === String(taxRate); });
59
59
  }, [taxesFromTaxContext, taxRate]);
60
60
  return (react_1.default.createElement("div", { className: "flex flex-col gap-6" },
61
- react_1.default.createElement("h3", { className: "text-lg font-semibold border-b pb-2" }, t("pricingSectionTitle")),
61
+ react_1.default.createElement("h3", { className: "text-lg font-semibold border-b pb-2" }, t("pricingFormSectionTitle")),
62
62
  react_1.default.createElement("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6" },
63
63
  react_1.default.createElement("div", { className: "hidden lg:block" }),
64
64
  react_1.default.createElement("div", { className: "hidden lg:block" }),
65
65
  react_1.default.createElement("div", { className: "flex flex-col gap-4" },
66
66
  react_1.default.createElement("div", { className: "space-y-2" },
67
- react_1.default.createElement(input_1.Input, { error: errors.subTotal, id: "subTotal", label: t("formLabelSubTotal"), onChange: function (e) { return handleChange("subTotal", e.target.value); }, placeholder: "0.00", readOnly: true, type: "text", value: subTotal || "0" })),
67
+ react_1.default.createElement(input_1.Input, { error: errors.subTotal, id: "subTotal", label: t("pricingFormLabelSubTotal"), onChange: function (e) { return handleChange("subTotal", e.target.value); }, placeholder: t("pricingFormPlaceholderSubTotal"), readOnly: true, type: "text", value: subTotal || "0", info: t("pricingFormInfoSubTotal") })),
68
68
  react_1.default.createElement("div", { className: "space-y-3" },
69
- react_1.default.createElement(label_1.Label, null, t("formLabelDiscountUnit")),
70
- react_1.default.createElement("p", { className: "text-sm text-muted-foreground" }, t("discountUnitDescription")),
69
+ react_1.default.createElement(label_1.Label, null, t("pricingFormLabelDiscountUnit")),
70
+ react_1.default.createElement("p", { className: "text-sm text-muted-foreground" }, t("pricingFormDescriptionDiscountUnit")),
71
71
  react_1.default.createElement("div", { className: "flex gap-2" },
72
72
  react_1.default.createElement(button_1.Button, { onClick: function () {
73
73
  return handleChange("discountUnit", types_1.DISCOUNT_UNIT.FIXED_VALUE);
74
74
  }, size: "sm", type: "button", variant: discountUnit === types_1.DISCOUNT_UNIT.FIXED_VALUE
75
75
  ? "default"
76
- : "outline" }, t("discountUnitFixedValue")),
76
+ : "outline" }, t("pricingFormDiscountFixedValue")),
77
77
  react_1.default.createElement(button_1.Button, { onClick: function () {
78
78
  return handleChange("discountUnit", types_1.DISCOUNT_UNIT.PERCENTAGE_VALUE);
79
79
  }, size: "sm", type: "button", variant: discountUnit === types_1.DISCOUNT_UNIT.PERCENTAGE_VALUE
80
80
  ? "default"
81
- : "outline" }, t("discountUnitPercentageValue")))),
81
+ : "outline" }, t("pricingFormDiscountPercentageValue")))),
82
82
  react_1.default.createElement("div", { className: "space-y-2" },
83
- react_1.default.createElement(input_1.Input, { error: errors.discount, id: "discount", label: t("formLabelDiscount"), onChange: function (e) { return handleChange("discount", e.target.value); }, placeholder: "0.00", type: "number", value: discount || "0" })),
83
+ react_1.default.createElement(input_1.Input, { error: errors.discount, id: "discount", info: t("pricingFormInfoDiscount"), label: t("pricingFormLabelDiscount"), onChange: function (e) { return handleChange("discount", e.target.value); }, placeholder: t("pricingFormPlaceholderDiscount"), type: "number", value: discount || "0" })),
84
84
  react_1.default.createElement("div", { className: "space-y-2" },
85
- react_1.default.createElement(input_1.Input, { id: "afterDiscount", label: t("formLabelAfterDiscount"), onChange: function (e) { return handleChange("afterDiscount", e.target.value); }, placeholder: "0.00", readOnly: true, type: "text", value: afterDiscount || "0" })),
85
+ react_1.default.createElement(input_1.Input, { id: "afterDiscount", label: t("pricingFormLabelAfterDiscount"), onChange: function (e) { return handleChange("afterDiscount", e.target.value); }, placeholder: t("pricingFormPlaceholderAfterDiscount"), readOnly: true, type: "text", value: afterDiscount || "0", info: t("pricingFormInfoAfterDiscount") })),
86
86
  react_1.default.createElement("div", { className: "space-y-2" },
87
- react_1.default.createElement(combobox_1.Combobox, { id: "taxRate", label: t("formLabelTax"), value: (currentTax === null || currentTax === void 0 ? void 0 : currentTax.taxRate) || "", onValueChange: function (v) { return handleChange("taxRate", v); }, onSearchChange: handleTaxSearch, loading: taxesLoading, options: (taxesFromTaxContext || [])
87
+ react_1.default.createElement(combobox_1.Combobox, { id: "taxRate", label: t("pricingFormLabelTax"), value: (currentTax === null || currentTax === void 0 ? void 0 : currentTax.taxRate) || "", onValueChange: function (v) { return handleChange("taxRate", v); }, onSearchChange: handleTaxSearch, loading: taxesLoading, options: (taxesFromTaxContext || [])
88
88
  .slice()
89
89
  .sort(function (a, b) { return a.taxName.localeCompare(b.taxName); })
90
90
  .map(function (tax) { return ({
91
91
  label: "".concat(tax.taxName, " (").concat(tax.taxRate, "%)"),
92
92
  value: tax.taxRate.toString(),
93
- }); }), placeholder: t("formPlaceholderTax"), searchPlaceholder: "Search taxes...", info: t("formInfoTax"), error: errors.taxRate, required: true })),
93
+ }); }), placeholder: t("pricingFormPlaceholderTax"), searchPlaceholder: t("pricingFormLabelSearchPlaceholder"), info: t("pricingFormInfoTax"), error: errors.taxRate, required: true })),
94
94
  react_1.default.createElement("div", { className: "space-y-2" },
95
- react_1.default.createElement(input_1.Input, { id: "afterTax", label: t("formLabelAfterTax"), placeholder: "0.00", readOnly: true, type: "text", value: isNaN(Number(tax)) ? "0" : tax || "0" })),
95
+ react_1.default.createElement(input_1.Input, { id: "afterTax", label: t("pricingFormLabelAfterTax"), placeholder: t("pricingFormPlaceholderAfterTax"), readOnly: true, type: "text", value: isNaN(Number(tax)) ? "0" : tax || "0", info: t("pricingFormInfoAfterTax") })),
96
96
  react_1.default.createElement("div", { className: "space-y-2" },
97
- react_1.default.createElement(input_1.Input, { error: errors.total, id: "total", label: t("formLabelTotal"), onChange: function (e) { return handleChange("total", e.target.value); }, placeholder: "0.00", readOnly: true, required: true, type: "text", value: isNaN(Number(total)) ? "0" : String(total || "0") }))))));
97
+ react_1.default.createElement(input_1.Input, { error: errors.total, id: "total", label: t("pricingFormLabelTotal"), onChange: function (e) { return handleChange("total", e.target.value); }, placeholder: t("pricingFormPlaceholderTotal"), readOnly: true, required: true, type: "text", value: isNaN(Number(total)) ? "0" : String(total || "0"), info: t("pricingFormInfoTotal") }))))));
98
98
  };
99
99
  exports.PricingSection = PricingSection;
@@ -18,7 +18,7 @@ var combobox_1 = require("@appcorp/shadcn/components/combobox");
18
18
  var input_1 = require("@appcorp/shadcn/components/input");
19
19
  var context_1 = require("./context");
20
20
  var ProductsSection = function () {
21
- var t = (0, next_intl_1.useTranslations)("invoicePage");
21
+ var t = (0, next_intl_1.useTranslations)("invoice");
22
22
  var _a = (0, context_1.useInvoiceStateContext)(), errors = _a.errors, getProducts = _a.getProducts, handleDeleteProductRow = _a.handleDeleteProductRow, handleItemChangeProducts = _a.handleItemChangeProducts, productsList = _a.productsList;
23
23
  if (!productsList || productsList.length === 0) {
24
24
  return null;
@@ -29,43 +29,43 @@ var ProductsSection = function () {
29
29
  // This is a placeholder to satisfy CompanyCombobox props
30
30
  };
31
31
  return (react_1.default.createElement("div", { className: "flex flex-col gap-4" },
32
- react_1.default.createElement("h3", { className: "text-lg font-semibold border-b pb-2" }, t("productsSectionTitle")),
32
+ react_1.default.createElement("h3", { className: "text-lg font-semibold border-b pb-2" }, t("productFormSectionTitle")),
33
33
  react_1.default.createElement("div", { className: "flex flex-col gap-4" }, productsList.map(function (row, index) { return (react_1.default.createElement("div", { key: index, className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-[2fr_0.75fr_0.75fr_0.75fr_auto] gap-4 items-start p-4 border rounded-lg" },
34
34
  react_1.default.createElement("div", { className: "space-y-2" },
35
- react_1.default.createElement(combobox_1.CompanyCombobox, { companies: getProducts || [], error: errors["productsList-".concat(index, "-id")], id: "product-id-".concat(index), label: t("formLabelProduct"), onSearchChange: handleProductSearch, onValueChange: function (selectedProductId) {
35
+ react_1.default.createElement(combobox_1.CompanyCombobox, { companies: getProducts || [], error: errors["productsList-".concat(index, "-id")], id: "product-id-".concat(index), label: t("productFormLabelProductName"), onSearchChange: handleProductSearch, onValueChange: function (selectedProductId) {
36
36
  return handleItemChangeProducts({
37
37
  index: index,
38
38
  key: "id",
39
39
  value: selectedProductId,
40
40
  });
41
- }, placeholder: t("formPlaceholderProduct"), required: true, value: productsList[index].id || "" })),
41
+ }, placeholder: t("productFormPlaceholderProductName"), required: true, value: productsList[index].id || "", info: t("productFormInfoProductName") })),
42
42
  react_1.default.createElement("div", { className: "space-y-2" },
43
- react_1.default.createElement(input_1.Input, { error: errors["productsList-".concat(index, "-quantity")], id: "product-quantity-".concat(index), label: t("formLabelQuantity"), onChange: function (e) {
43
+ react_1.default.createElement(input_1.Input, { error: errors["productsList-".concat(index, "-quantity")], id: "product-quantity-".concat(index), label: t("productFormLabelQuantity"), onChange: function (e) {
44
44
  return handleItemChangeProducts({
45
45
  index: index,
46
46
  key: "quantity",
47
47
  value: e.target.value,
48
48
  });
49
- }, placeholder: "1", required: true, type: "number", value: String(productsList[index].quantity || "") })),
49
+ }, placeholder: t("productFormPlaceholderQuantity"), required: true, type: "number", value: String(productsList[index].quantity || ""), info: t("productFormInfoQuantity") })),
50
50
  react_1.default.createElement("div", { className: "space-y-2" },
51
- react_1.default.createElement(input_1.Input, { error: errors["productsList-".concat(index, "-price")], id: "product-price-".concat(index), label: t("formLabelPrice"), onChange: function (e) {
51
+ react_1.default.createElement(input_1.Input, { error: errors["productsList-".concat(index, "-price")], id: "product-price-".concat(index), label: t("productFormLabelPrice"), onChange: function (e) {
52
52
  return handleItemChangeProducts({
53
53
  index: index,
54
54
  key: "price",
55
55
  value: e.target.value,
56
56
  });
57
- }, placeholder: "0.00", required: true, type: "number", value: productsList[index].price || "" })),
57
+ }, placeholder: t("productFormPlaceholderPrice"), required: true, type: "number", value: productsList[index].price || "", info: t("productFormInfoPrice") })),
58
58
  react_1.default.createElement("div", { className: "space-y-2" },
59
- react_1.default.createElement(input_1.Input, { error: errors["productsList-".concat(index, "-rowTotal")], id: "product-rowTotal-".concat(index), label: t("formLabelRowTotal"), onChange: function (e) {
59
+ react_1.default.createElement(input_1.Input, { error: errors["productsList-".concat(index, "-rowTotal")], id: "product-rowTotal-".concat(index), label: t("productFormLabelServiceRowTotal"), onChange: function (e) {
60
60
  return handleItemChangeProducts({
61
61
  index: index,
62
62
  key: "rowTotal",
63
63
  value: e.target.value,
64
64
  });
65
- }, placeholder: "0.00", readOnly: true, required: true, type: "number", value: productsList[index].rowTotal || "" })),
65
+ }, placeholder: t("productFormPlaceholderServiceRowTotal"), readOnly: true, required: true, type: "number", value: productsList[index].rowTotal || "", info: t("productFormInfoServiceRowTotal") })),
66
66
  react_1.default.createElement("div", { className: "flex items-end h-full" },
67
67
  react_1.default.createElement(button_1.Button, { onClick: function () { return handleDeleteProductRow(index); }, size: "icon", type: "button", variant: "ghost" },
68
68
  react_1.default.createElement(lucide_react_1.Trash2, { className: "h-4 w-4" }),
69
- react_1.default.createElement("span", { className: "sr-only" }, t("buttonDeleteProduct")))))); }))));
69
+ react_1.default.createElement("span", { className: "sr-only" }, t("productFormButtonDeleteService")))))); }))));
70
70
  };
71
71
  exports.ProductsSection = ProductsSection;