@appcorp/stellar-solutions-invoice-module 0.1.74 → 0.1.75

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.
Files changed (89) hide show
  1. package/base-modules/invoice/add-service-product-section.d.ts +1 -5
  2. package/base-modules/invoice/add-service-product-section.js +3 -3
  3. package/base-modules/invoice/cache.d.ts +15 -0
  4. package/base-modules/invoice/cache.js +50 -0
  5. package/base-modules/invoice/calculate-subtotal.d.ts +6 -1
  6. package/base-modules/invoice/calculate-subtotal.js +2 -2
  7. package/base-modules/invoice/calculate-total.d.ts +1 -1
  8. package/base-modules/invoice/calculate-total.js +8 -8
  9. package/base-modules/invoice/company-form-section.d.ts +1 -5
  10. package/base-modules/invoice/company-form-section.js +25 -22
  11. package/base-modules/invoice/constants.d.ts +2 -3
  12. package/base-modules/invoice/constants.js +2 -3
  13. package/base-modules/invoice/context.d.ts +556 -20
  14. package/base-modules/invoice/context.js +530 -342
  15. package/base-modules/invoice/customer-form-section.d.ts +1 -5
  16. package/base-modules/invoice/customer-form-section.js +25 -9
  17. package/base-modules/invoice/form.d.ts +1 -5
  18. package/base-modules/invoice/form.js +9 -9
  19. package/base-modules/invoice/page.d.ts +8 -0
  20. package/base-modules/invoice/page.js +171 -0
  21. package/base-modules/invoice/pricing-form-section.d.ts +1 -5
  22. package/base-modules/invoice/pricing-form-section.js +16 -11
  23. package/base-modules/invoice/products-form-section.d.ts +1 -5
  24. package/base-modules/invoice/products-form-section.js +49 -40
  25. package/base-modules/invoice/services-form-section.d.ts +1 -5
  26. package/base-modules/invoice/services-form-section.js +10 -9
  27. package/base-modules/invoice/validate.d.ts +83 -25
  28. package/base-modules/invoice/validate.js +4 -4
  29. package/base-modules/payment/cache.d.ts +15 -0
  30. package/base-modules/payment/cache.js +52 -0
  31. package/base-modules/payment/constants.d.ts +1 -14
  32. package/base-modules/payment/constants.js +2 -15
  33. package/base-modules/payment/context.d.ts +214 -48
  34. package/base-modules/payment/context.js +266 -237
  35. package/base-modules/payment/drawer.d.ts +0 -6
  36. package/base-modules/payment/drawer.js +89 -44
  37. package/base-modules/payment/form.js +3 -2
  38. package/base-modules/payment/{payment.js → page.js} +2 -5
  39. package/base-modules/payment/types.d.ts +0 -85
  40. package/base-modules/payment/types.js +74 -21
  41. package/base-modules/payment/validate.d.ts +12 -0
  42. package/base-modules/payment/validate.js +19 -8
  43. package/base-modules/payment/view.d.ts +1 -5
  44. package/base-modules/payment/view.js +4 -3
  45. package/base-modules/quote/add-service-product-section.js +1 -1
  46. package/base-modules/quote/cache.d.ts +15 -0
  47. package/base-modules/quote/cache.js +50 -0
  48. package/base-modules/quote/company-form-section.d.ts +1 -1
  49. package/base-modules/quote/company-form-section.js +14 -12
  50. package/base-modules/quote/constants.js +1 -0
  51. package/base-modules/quote/context.d.ts +656 -46
  52. package/base-modules/quote/context.js +413 -289
  53. package/base-modules/quote/customer-form-section.d.ts +1 -1
  54. package/base-modules/quote/customer-form-section.js +24 -9
  55. package/base-modules/quote/form.d.ts +1 -5
  56. package/base-modules/quote/form.js +8 -9
  57. package/base-modules/quote/page.d.ts +8 -0
  58. package/base-modules/quote/page.js +163 -0
  59. package/base-modules/quote/pricing-form-section.js +9 -8
  60. package/base-modules/quote/products-form-section.js +2 -2
  61. package/base-modules/quote/services-form-section.js +1 -1
  62. package/base-modules/quote/types.d.ts +0 -127
  63. package/base-modules/quote/types.js +92 -35
  64. package/base-modules/quote/validate.d.ts +82 -25
  65. package/base-modules/quote/validate.js +3 -4
  66. package/package.json +8 -8
  67. package/base-modules/invoice/actions.d.ts +0 -215
  68. package/base-modules/invoice/actions.js +0 -38
  69. package/base-modules/invoice/drawer.d.ts +0 -13
  70. package/base-modules/invoice/drawer.js +0 -46
  71. package/base-modules/invoice/invoice.d.ts +0 -8
  72. package/base-modules/invoice/invoice.js +0 -69
  73. package/base-modules/invoice/reducer.d.ts +0 -4
  74. package/base-modules/invoice/reducer.js +0 -180
  75. package/base-modules/invoice/types.d.ts +0 -211
  76. package/base-modules/invoice/types.js +0 -43
  77. package/base-modules/payment/actions.d.ts +0 -203
  78. package/base-modules/payment/actions.js +0 -50
  79. package/base-modules/payment/reducer.d.ts +0 -29
  80. package/base-modules/payment/reducer.js +0 -215
  81. package/base-modules/quote/actions.d.ts +0 -215
  82. package/base-modules/quote/actions.js +0 -38
  83. package/base-modules/quote/drawer.d.ts +0 -13
  84. package/base-modules/quote/drawer.js +0 -46
  85. package/base-modules/quote/quote.d.ts +0 -8
  86. package/base-modules/quote/quote.js +0 -69
  87. package/base-modules/quote/reducer.d.ts +0 -4
  88. package/base-modules/quote/reducer.js +0 -181
  89. /package/base-modules/payment/{payment.d.ts → page.d.ts} +0 -0
@@ -5,8 +5,4 @@
5
5
  * Uses Shadcn UI components with RTL support and i18n.
6
6
  */
7
7
  import { FC } from "react";
8
- interface Props {
9
- isRTL: boolean;
10
- }
11
- export declare const CustomerSection: FC<Props>;
12
- export {};
8
+ export declare const CustomerSection: FC;
@@ -5,6 +5,17 @@
5
5
  * Form section for creating/editing customer information in invoices.
6
6
  * Uses Shadcn UI components with RTL support and i18n.
7
7
  */
8
+ var __assign = (this && this.__assign) || function () {
9
+ __assign = Object.assign || function(t) {
10
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
11
+ s = arguments[i];
12
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
13
+ t[p] = s[p];
14
+ }
15
+ return t;
16
+ };
17
+ return __assign.apply(this, arguments);
18
+ };
8
19
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
20
  if (k2 === undefined) k2 = k;
10
21
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -46,32 +57,37 @@ var util_functions_1 = require("@react-pakistan/util-functions");
46
57
  var enhanced_combobox_1 = require("@appcorp/shadcn/components/enhanced-combobox");
47
58
  var enhanced_input_1 = require("@appcorp/shadcn/components/enhanced-input");
48
59
  var context_1 = require("./context");
49
- var actions_1 = require("./actions");
50
60
  var CustomerSection = function () {
51
61
  var t = (0, next_intl_1.useTranslations)("invoice");
52
- var _a = (0, context_1.useInvoiceStateContext)(), customer = _a.customer, errors = _a.errors, dispatch = _a.dispatch;
62
+ var _a = (0, context_1.useInvoiceModule)(), state = _a.state, dispatch = _a.dispatch;
63
+ var customer = state.customer, errors = state.errors;
53
64
  var handleCustomerChange = (0, react_1.useCallback)(function (key, value) {
65
+ var _a, _b;
54
66
  if (key === "phone") {
55
67
  var formattedResult = (0, util_functions_1.formatPhone)(value);
56
68
  var formattedPhone = (formattedResult === null || formattedResult === void 0 ? void 0 : formattedResult.international) || value;
57
69
  dispatch({
58
- type: actions_1.INVOICE_ACTION_TYPES.SET_CUSTOMER_FORM,
59
- payload: { key: key, value: formattedPhone },
70
+ type: context_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
71
+ payload: {
72
+ key: "customer",
73
+ value: __assign(__assign({}, customer), (_a = {}, _a[key] = formattedPhone, _a)),
74
+ },
60
75
  });
61
76
  return;
62
77
  }
63
78
  dispatch({
64
- type: actions_1.INVOICE_ACTION_TYPES.SET_CUSTOMER_FORM,
65
- payload: { key: key, value: value },
79
+ type: context_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
80
+ payload: { key: "customer", value: __assign(__assign({}, customer), (_b = {}, _b[key] = value, _b)) },
66
81
  });
67
82
  dispatch({
68
- type: actions_1.INVOICE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
83
+ type: context_1.INVOICE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
69
84
  payload: { disableSaveButton: false },
70
85
  });
71
86
  dispatch({
72
- type: actions_1.INVOICE_ACTION_TYPES.RESET_ERRORS,
87
+ type: context_1.INVOICE_ACTION_TYPES.SET_ERRORS,
88
+ payload: { errors: {} },
73
89
  });
74
- }, [dispatch]);
90
+ }, [dispatch, customer]);
75
91
  var handleInputChange = function (field, value) {
76
92
  handleCustomerChange(field, value);
77
93
  };
@@ -1,6 +1,2 @@
1
1
  import { FC } from "react";
2
- interface Props {
3
- isRTL: boolean;
4
- }
5
- export declare const InvoiceForm: FC<Props>;
6
- export {};
2
+ export declare const InvoiceForm: FC;
@@ -12,16 +12,16 @@ 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");
16
- var InvoiceForm = function (_a) {
17
- var isRTL = _a.isRTL;
18
- var drawer = (0, context_1.useInvoiceStateContext)().drawer;
15
+ var util_functions_1 = require("@react-pakistan/util-functions");
16
+ var InvoiceForm = function () {
17
+ var state = (0, context_1.useInvoiceModule)().state;
18
+ var invoiceMode = state.invoiceMode;
19
19
  return (react_1.default.createElement("div", { className: "flex flex-col gap-8" },
20
- drawer === types_1.INVOICE_DRAWER.INVOICE_CUSTOMER_FORM_DRAWER && (react_1.default.createElement(customer_form_section_1.CustomerSection, { isRTL: isRTL })),
21
- drawer === types_1.INVOICE_DRAWER.INVOICE_COMPANY_FORM_DRAWER && (react_1.default.createElement(company_form_section_1.CompanySection, { isRTL: isRTL })),
22
- react_1.default.createElement(services_form_section_1.ServicesSection, { isRTL: isRTL }),
23
- react_1.default.createElement(products_form_section_1.ProductsSection, { isRTL: isRTL }),
24
- react_1.default.createElement(add_service_product_section_1.AddServiceProductSection, { isRTL: isRTL }),
20
+ invoiceMode === util_functions_1.QUOTE_INVOICE_MODE.CUSTOMER && react_1.default.createElement(customer_form_section_1.CustomerSection, null),
21
+ invoiceMode === util_functions_1.QUOTE_INVOICE_MODE.COMPANY && react_1.default.createElement(company_form_section_1.CompanySection, null),
22
+ react_1.default.createElement(services_form_section_1.ServicesSection, null),
23
+ react_1.default.createElement(products_form_section_1.ProductsSection, null),
24
+ react_1.default.createElement(add_service_product_section_1.AddServiceProductSection, null),
25
25
  react_1.default.createElement(pricing_form_section_1.PricingSection, null)));
26
26
  };
27
27
  exports.InvoiceForm = InvoiceForm;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Generic Invoice Page Component
3
+ *
4
+ * Uses the generic component factory pattern with invoice-specific configuration.
5
+ * Demonstrates how to create a complete CRUD page using the reusable component factory.
6
+ */
7
+ import { FC } from "react";
8
+ export declare const InvoicePage: FC;
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Generic Invoice Page Component
3
+ *
4
+ * Uses the generic component factory pattern with invoice-specific configuration.
5
+ * Demonstrates how to create a complete CRUD page using the reusable component factory.
6
+ */
7
+ "use client";
8
+ "use strict";
9
+ var __assign = (this && this.__assign) || function () {
10
+ __assign = Object.assign || function(t) {
11
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
12
+ s = arguments[i];
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
14
+ t[p] = s[p];
15
+ }
16
+ return t;
17
+ };
18
+ return __assign.apply(this, arguments);
19
+ };
20
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ var desc = Object.getOwnPropertyDescriptor(m, k);
23
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
24
+ desc = { enumerable: true, get: function() { return m[k]; } };
25
+ }
26
+ Object.defineProperty(o, k2, desc);
27
+ }) : (function(o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ o[k2] = m[k];
30
+ }));
31
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
32
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
33
+ }) : function(o, v) {
34
+ o["default"] = v;
35
+ });
36
+ var __importStar = (this && this.__importStar) || (function () {
37
+ var ownKeys = function(o) {
38
+ ownKeys = Object.getOwnPropertyNames || function (o) {
39
+ var ar = [];
40
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
41
+ return ar;
42
+ };
43
+ return ownKeys(o);
44
+ };
45
+ return function (mod) {
46
+ if (mod && mod.__esModule) return mod;
47
+ var result = {};
48
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
49
+ __setModuleDefault(result, mod);
50
+ return result;
51
+ };
52
+ })();
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.InvoicePage = void 0;
55
+ var react_1 = __importStar(require("react"));
56
+ var next_intl_1 = require("next-intl");
57
+ var lucide_react_1 = require("lucide-react");
58
+ var generic_component_factory_1 = require("@react-pakistan/util-functions/factory/generic-component-factory");
59
+ var context_1 = require("./context");
60
+ var form_1 = require("./form");
61
+ var constants_1 = require("./constants");
62
+ // ============================================================================
63
+ // INVOICE MODULE CONFIGURATION
64
+ // ============================================================================
65
+ var invoiceConfig = {
66
+ moduleName: "invoice",
67
+ tableColumns: [
68
+ { label: "tableColumnHeaderId", width: "5%" },
69
+ { label: "tableColumnHeaderName", width: "10%" },
70
+ { label: "tableColumnHeaderIssueExpiryDate", width: "10%" },
71
+ { label: "tableColumnHeaderRef", width: "5%" },
72
+ { label: "tableColumnHeaderSubTotal", width: "5%" },
73
+ { label: "tableColumnHeaderTaxValue", width: "5%" },
74
+ { label: "tableColumnHeaderDiscountPrice", width: "5%" },
75
+ { label: "tableColumnHeaderTotalPrice", width: "5%" },
76
+ { label: "tableColumnHeaderCategory", width: "5%" },
77
+ { label: "tableColumnHeaderActions", width: "5%" },
78
+ ],
79
+ cancelLabel: "drawerButtonCancel",
80
+ drawerTitle: "drawerTitleInvoice",
81
+ filterContent: null,
82
+ formContent: react_1.default.createElement(form_1.InvoiceForm, null),
83
+ moreActionsContent: null,
84
+ saveLabel: "drawerButtonSave",
85
+ searchPlaceholder: "tableSearchPlaceholder",
86
+ tableDescription: "tableDescription",
87
+ tableTitle: "tableTitle",
88
+ viewContent: null,
89
+ size: "large",
90
+ };
91
+ // ============================================================================
92
+ // ICON MAPPING
93
+ // ============================================================================
94
+ var ICON_MAP = {
95
+ delete: lucide_react_1.Trash2,
96
+ edit: lucide_react_1.Edit,
97
+ recordPayment: lucide_react_1.CreditCard,
98
+ view: lucide_react_1.Eye,
99
+ };
100
+ // ============================================================================
101
+ // GENERIC INVOICE PAGE COMPONENT
102
+ // ============================================================================
103
+ var GenericInvoicePage = (0, generic_component_factory_1.createGenericModulePage)(invoiceConfig);
104
+ var InvoicePageInner = function () {
105
+ var t = (0, next_intl_1.useTranslations)("invoice");
106
+ var context = (0, context_1.useInvoiceModule)();
107
+ // ============================================================================
108
+ // HEADER ACTIONS
109
+ // ============================================================================
110
+ var headerActions = (0, react_1.useMemo)(function () { return [
111
+ {
112
+ enabled: true,
113
+ handleOnClick: function () { return context.handleCreate("company"); },
114
+ icon: lucide_react_1.Building2,
115
+ label: t("actionsInvoiceCompany"),
116
+ order: 1,
117
+ },
118
+ {
119
+ enabled: true,
120
+ handleOnClick: function () { return context.handleCreate("customer"); },
121
+ icon: lucide_react_1.User,
122
+ label: t("actionsInvoiceCustomer"),
123
+ order: 2,
124
+ },
125
+ ]; }, [context, t]);
126
+ // ============================================================================
127
+ // ROW ACTIONS
128
+ // ============================================================================
129
+ var rowActions = (0, react_1.useMemo)(function () { return [
130
+ {
131
+ enabled: true,
132
+ handleOnClick: function (row) { return context.handleView(row); },
133
+ icon: ICON_MAP.view,
134
+ label: t("actionsButtonView"),
135
+ order: 1,
136
+ },
137
+ {
138
+ enabled: true,
139
+ handleOnClick: function (row) { return context.handleEdit(row); },
140
+ icon: ICON_MAP.edit,
141
+ label: t("actionsButtonEdit"),
142
+ order: 2,
143
+ },
144
+ {
145
+ enabled: true,
146
+ handleOnClick: function (row) { return context.handleRecordPayment(row); },
147
+ icon: ICON_MAP.recordPayment,
148
+ label: t("actionsButtonRecordPayment"),
149
+ order: 3,
150
+ },
151
+ {
152
+ enabled: true,
153
+ handleOnClick: function (row) { return context.handleDelete(row); },
154
+ icon: ICON_MAP.delete,
155
+ label: t("actionsButtonDelete"),
156
+ order: 4,
157
+ },
158
+ ]; }, [context, t]);
159
+ // ============================================================================
160
+ // ENHANCED CONTEXT WITH ACTIONS
161
+ // ============================================================================
162
+ var enhancedContext = (0, react_1.useMemo)(function () { return (__assign(__assign({}, context), { headerActions: headerActions, rowActions: rowActions, handleNextClick: function () {
163
+ return context.handlePageChange(context.state.currentPage + 1);
164
+ }, handlePreviousClick: function () {
165
+ return context.handlePageChange(context.state.currentPage - 1);
166
+ }, handlePageLimit: function (limit) { return context.handlePageLimitChange(limit); }, searchOnChange: function (query) { return context.handleSearch(query); }, closeDrawer: context.handleCloseDrawer })); }, [context, headerActions, rowActions]);
167
+ return (react_1.default.createElement(GenericInvoicePage, { config: invoiceConfig, context: enhancedContext, tableBodyCols: constants_1.tableBodyCols }));
168
+ };
169
+ var InvoicePage = function () { return (react_1.default.createElement(context_1.InvoiceProvider, null,
170
+ react_1.default.createElement(InvoicePageInner, null))); };
171
+ exports.InvoicePage = InvoicePage;
@@ -5,8 +5,4 @@
5
5
  * Uses Shadcn UI components with RTL support and i18n.
6
6
  */
7
7
  import { FC } from "react";
8
- interface Props {
9
- isRTL?: boolean;
10
- }
11
- export declare const PricingSection: FC<Props>;
12
- export {};
8
+ export declare const PricingSection: FC;
@@ -46,13 +46,16 @@ var enhanced_combobox_1 = require("@appcorp/shadcn/components/enhanced-combobox"
46
46
  var enhanced_input_1 = require("@appcorp/shadcn/components/enhanced-input");
47
47
  var label_1 = require("@appcorp/shadcn/components/ui/label");
48
48
  var button_1 = require("@appcorp/shadcn/components/ui/button");
49
- var context_1 = require("@appcorp/stellar-solutions-modules/global-modules/tax/context");
50
- var context_2 = require("./context");
51
- var types_1 = require("./types");
49
+ var context_1 = require("./context");
50
+ var util_functions_1 = require("@react-pakistan/util-functions");
51
+ var cache_1 = require("@appcorp/stellar-solutions-modules/global-modules/tax/cache");
52
52
  var PricingSection = function () {
53
53
  var t = (0, next_intl_1.useTranslations)("invoice");
54
- var _a = (0, context_1.useTaxStateContext)(), taxesFromTaxContext = _a.taxes, taxesLoading = _a.listLoading;
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;
54
+ // const { listLoading: taxesLoading, state: taxState } = useTaxModule();
55
+ var taxes = (0, cache_1.getCachedTaxesSync)();
56
+ var taxesFromTaxContext = taxes === null || taxes === void 0 ? void 0 : taxes.items;
57
+ var _a = (0, context_1.useInvoiceModule)(), state = _a.state, handleChange = _a.handleChange, handleTaxSearch = _a.handleTaxSearch;
58
+ var afterDiscount = state.afterDiscount, discount = state.discount, discountUnit = state.discountUnit, errors = state.errors, subTotal = state.subTotal, tax = state.tax, taxRate = state.taxRate, total = state.total;
56
59
  // Find the current tax based on taxRate value
57
60
  var currentTax = (0, react_1.useMemo)(function () {
58
61
  return taxesFromTaxContext === null || taxesFromTaxContext === void 0 ? void 0 : taxesFromTaxContext.find(function (t) { return String(t.taxRate) === String(taxRate); });
@@ -70,13 +73,13 @@ var PricingSection = function () {
70
73
  react_1.default.createElement("p", { className: "text-sm text-muted-foreground" }, t("pricingFormDescriptionDiscountUnit")),
71
74
  react_1.default.createElement("div", { className: "flex gap-2" },
72
75
  react_1.default.createElement(button_1.Button, { onClick: function () {
73
- return handleChange("discountUnit", types_1.DISCOUNT_UNIT.FIXED_VALUE);
74
- }, size: "sm", type: "button", variant: discountUnit === types_1.DISCOUNT_UNIT.FIXED_VALUE
76
+ return handleChange("discountUnit", util_functions_1.DISCOUNT_UNIT.FIXED_VALUE);
77
+ }, size: "sm", type: "button", variant: discountUnit === util_functions_1.DISCOUNT_UNIT.FIXED_VALUE
75
78
  ? "default"
76
79
  : "outline" }, t("pricingFormDiscountFixedValue")),
77
80
  react_1.default.createElement(button_1.Button, { onClick: function () {
78
- return handleChange("discountUnit", types_1.DISCOUNT_UNIT.PERCENTAGE_VALUE);
79
- }, size: "sm", type: "button", variant: discountUnit === types_1.DISCOUNT_UNIT.PERCENTAGE_VALUE
81
+ return handleChange("discountUnit", util_functions_1.DISCOUNT_UNIT.PERCENTAGE_VALUE);
82
+ }, size: "sm", type: "button", variant: discountUnit === util_functions_1.DISCOUNT_UNIT.PERCENTAGE_VALUE
80
83
  ? "default"
81
84
  : "outline" }, t("pricingFormDiscountPercentageValue")))),
82
85
  react_1.default.createElement("div", { className: "space-y-2" },
@@ -84,7 +87,9 @@ var PricingSection = function () {
84
87
  react_1.default.createElement("div", { className: "space-y-2" },
85
88
  react_1.default.createElement(enhanced_input_1.EnhancedInput, { 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
89
  react_1.default.createElement("div", { className: "space-y-2" },
87
- react_1.default.createElement(enhanced_combobox_1.EnhancedCombobox, { 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 || [])
90
+ react_1.default.createElement(enhanced_combobox_1.EnhancedCombobox, { id: "taxRate", label: t("pricingFormLabelTax"), value: (currentTax === null || currentTax === void 0 ? void 0 : currentTax.taxRate) != null ? String(currentTax.taxRate) : "", onValueChange: function (v) { return handleChange("taxRate", v); }, onSearchChange: handleTaxSearch,
91
+ // loading={taxesLoading}
92
+ options: (taxesFromTaxContext || [])
88
93
  .slice()
89
94
  .sort(function (a, b) { return a.taxName.localeCompare(b.taxName); })
90
95
  .map(function (tax) { return ({
@@ -94,6 +99,6 @@ var PricingSection = function () {
94
99
  react_1.default.createElement("div", { className: "space-y-2" },
95
100
  react_1.default.createElement(enhanced_input_1.EnhancedInput, { id: "afterTax", label: t("pricingFormLabelAfterTax"), placeholder: t("pricingFormPlaceholderAfterTax"), readOnly: true, type: "text", value: isNaN(Number(tax)) ? "0" : tax || "0", info: t("pricingFormInfoAfterTax") })),
96
101
  react_1.default.createElement("div", { className: "space-y-2" },
97
- react_1.default.createElement(enhanced_input_1.EnhancedInput, { 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") }))))));
102
+ react_1.default.createElement(enhanced_input_1.EnhancedInput, { error: errors.total, id: "total", info: t("pricingFormInfoTotal"), 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") }))))));
98
103
  };
99
104
  exports.PricingSection = PricingSection;
@@ -5,8 +5,4 @@
5
5
  * Uses Shadcn UI components with RTL support and i18n.
6
6
  */
7
7
  import { FC } from "react";
8
- interface Props {
9
- isRTL?: boolean;
10
- }
11
- export declare const ProductsSection: FC<Props>;
12
- export {};
8
+ export declare const ProductsSection: FC;
@@ -17,54 +17,63 @@ var button_1 = require("@appcorp/shadcn/components/ui/button");
17
17
  var enhanced_combobox_1 = require("@appcorp/shadcn/components/enhanced-combobox");
18
18
  var enhanced_input_1 = require("@appcorp/shadcn/components/enhanced-input");
19
19
  var context_1 = require("./context");
20
+ var cache_1 = require("@appcorp/stellar-solutions-product-module/base-modules/product/cache");
20
21
  var ProductsSection = function () {
21
22
  var t = (0, next_intl_1.useTranslations)("invoice");
22
- var _a = (0, context_1.useInvoiceStateContext)(), errors = _a.errors, getProducts = _a.getProducts, handleDeleteProductRow = _a.handleDeleteProductRow, handleItemChangeProducts = _a.handleItemChangeProducts, productsList = _a.productsList;
23
- if (!productsList || productsList.length === 0) {
23
+ var products = (0, cache_1.getCachedProductsSync)();
24
+ var _a = (0, context_1.useInvoiceModule)(), state = _a.state, handleDeleteProductRow = _a.handleDeleteProductRow, handleItemChangeProducts = _a.handleItemChangeProducts;
25
+ var errors = state.errors, productList = state.productList;
26
+ if (!productList || productList.length === 0) {
24
27
  return null;
25
28
  }
26
- var handleProductSearch = function (_searchQuery) {
29
+ var handleProductSearch = function () {
27
30
  // Product search is handled by getProducts filter in context
28
31
  // This is a placeholder to satisfy CompanyCombobox props
29
32
  };
30
33
  return (react_1.default.createElement("div", { className: "flex flex-col gap-4" },
31
34
  react_1.default.createElement("h3", { className: "text-lg font-semibold border-b pb-2" }, t("productFormSectionTitle")),
32
- 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" },
33
- react_1.default.createElement("div", { className: "space-y-2" },
34
- react_1.default.createElement(enhanced_combobox_1.CompanyCombobox, { companies: getProducts || [], error: errors["productsList-".concat(index, "-id")], id: "product-id-".concat(index), label: t("productFormLabelProductName"), onSearchChange: handleProductSearch, onValueChange: function (selectedProductId) {
35
- return handleItemChangeProducts({
36
- index: index,
37
- key: "id",
38
- value: selectedProductId,
39
- });
40
- }, placeholder: t("productFormPlaceholderProductName"), required: true, value: productsList[index].id || "", info: t("productFormInfoProductName") })),
41
- react_1.default.createElement("div", { className: "space-y-2" },
42
- react_1.default.createElement(enhanced_input_1.EnhancedInput, { error: errors["productsList-".concat(index, "-quantity")], id: "product-quantity-".concat(index), label: t("productFormLabelQuantity"), onChange: function (e) {
43
- return handleItemChangeProducts({
44
- index: index,
45
- key: "quantity",
46
- value: e.target.value,
47
- });
48
- }, placeholder: t("productFormPlaceholderQuantity"), required: true, type: "number", value: String(productsList[index].quantity || ""), info: t("productFormInfoQuantity") })),
49
- react_1.default.createElement("div", { className: "space-y-2" },
50
- react_1.default.createElement(enhanced_input_1.EnhancedInput, { error: errors["productsList-".concat(index, "-price")], id: "product-price-".concat(index), label: t("productFormLabelPrice"), onChange: function (e) {
51
- return handleItemChangeProducts({
52
- index: index,
53
- key: "price",
54
- value: e.target.value,
55
- });
56
- }, placeholder: t("productFormPlaceholderPrice"), required: true, type: "number", value: productsList[index].price || "", info: t("productFormInfoPrice") })),
57
- react_1.default.createElement("div", { className: "space-y-2" },
58
- react_1.default.createElement(enhanced_input_1.EnhancedInput, { error: errors["productsList-".concat(index, "-rowTotal")], id: "product-rowTotal-".concat(index), label: t("productFormLabelServiceRowTotal"), onChange: function (e) {
59
- return handleItemChangeProducts({
60
- index: index,
61
- key: "rowTotal",
62
- value: e.target.value,
63
- });
64
- }, placeholder: t("productFormPlaceholderServiceRowTotal"), readOnly: true, required: true, type: "number", value: productsList[index].rowTotal || "", info: t("productFormInfoServiceRowTotal") })),
65
- react_1.default.createElement("div", { className: "flex items-end h-full" },
66
- react_1.default.createElement(button_1.Button, { onClick: function () { return handleDeleteProductRow(index); }, size: "icon", type: "button", variant: "ghost" },
67
- react_1.default.createElement(lucide_react_1.Trash2, { className: "h-4 w-4" }),
68
- react_1.default.createElement("span", { className: "sr-only" }, t("productFormButtonDeleteService")))))); }))));
35
+ react_1.default.createElement("div", { className: "flex flex-col gap-4" }, productList.map(function (row, index) {
36
+ var _a, _b, _c, _d, _e;
37
+ 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" },
38
+ react_1.default.createElement("div", { className: "space-y-2" },
39
+ react_1.default.createElement(enhanced_combobox_1.EnhancedCombobox, { id: "product-id-".concat(index), label: t("productFormLabelProductName"), value: ((_a = productList[index]) === null || _a === void 0 ? void 0 : _a.id) || "", onValueChange: function (selectedProductId) {
40
+ return handleItemChangeProducts({
41
+ index: index,
42
+ key: "id",
43
+ value: selectedProductId,
44
+ });
45
+ }, onSearchChange: handleProductSearch, options: ((_b = products === null || products === void 0 ? void 0 : products.items) === null || _b === void 0 ? void 0 : _b.map(function (p) { return ({
46
+ label: (p === null || p === void 0 ? void 0 : p.name) || (p === null || p === void 0 ? void 0 : p.id) || "",
47
+ value: p === null || p === void 0 ? void 0 : p.id,
48
+ }); })) || [], placeholder: t("productFormPlaceholderProductName"), info: t("productFormInfoProductName"), error: errors["products-".concat(index, "-id")], required: true })),
49
+ react_1.default.createElement("div", { className: "space-y-2" },
50
+ react_1.default.createElement(enhanced_input_1.EnhancedInput, { error: errors["products-".concat(index, "-quantity")], id: "product-quantity-".concat(index), label: t("productFormLabelQuantity"), onChange: function (e) {
51
+ return handleItemChangeProducts({
52
+ index: index,
53
+ key: "quantity",
54
+ value: e.target.value,
55
+ });
56
+ }, placeholder: t("productFormPlaceholderQuantity"), required: true, type: "number", value: String(((_c = productList === null || productList === void 0 ? void 0 : productList[index]) === null || _c === void 0 ? void 0 : _c.quantity) || ""), info: t("productFormInfoQuantity") })),
57
+ react_1.default.createElement("div", { className: "space-y-2" },
58
+ react_1.default.createElement(enhanced_input_1.EnhancedInput, { error: errors["products-".concat(index, "-price")], id: "product-price-".concat(index), label: t("productFormLabelPrice"), onChange: function (e) {
59
+ return handleItemChangeProducts({
60
+ index: index,
61
+ key: "price",
62
+ value: e.target.value,
63
+ });
64
+ }, placeholder: t("productFormPlaceholderPrice"), required: true, type: "number", value: ((_d = productList === null || productList === void 0 ? void 0 : productList[index]) === null || _d === void 0 ? void 0 : _d.price) || "", info: t("productFormInfoPrice") })),
65
+ react_1.default.createElement("div", { className: "space-y-2" },
66
+ react_1.default.createElement(enhanced_input_1.EnhancedInput, { error: errors["products-".concat(index, "-rowTotal")], id: "product-rowTotal-".concat(index), label: t("productFormLabelServiceRowTotal"), onChange: function (e) {
67
+ return handleItemChangeProducts({
68
+ index: index,
69
+ key: "rowTotal",
70
+ value: e.target.value,
71
+ });
72
+ }, placeholder: t("productFormPlaceholderServiceRowTotal"), readOnly: true, required: true, type: "number", value: ((_e = productList[index]) === null || _e === void 0 ? void 0 : _e.rowTotal) || "", info: t("productFormInfoServiceRowTotal") })),
73
+ react_1.default.createElement("div", { className: "flex items-center h-full" },
74
+ react_1.default.createElement(button_1.Button, { onClick: function () { return handleDeleteProductRow(index); }, size: "icon", type: "button", variant: "ghost" },
75
+ react_1.default.createElement(lucide_react_1.Trash2, { className: "h-4 w-4" }),
76
+ react_1.default.createElement("span", { className: "sr-only" }, t("productFormButtonDeleteService"))))));
77
+ }))));
69
78
  };
70
79
  exports.ProductsSection = ProductsSection;
@@ -5,8 +5,4 @@
5
5
  * Uses Shadcn UI components with RTL support and i18n.
6
6
  */
7
7
  import { FC } from "react";
8
- interface Props {
9
- isRTL?: boolean;
10
- }
11
- export declare const ServicesSection: FC<Props>;
12
- export {};
8
+ export declare const ServicesSection: FC;
@@ -18,13 +18,14 @@ var enhanced_input_1 = require("@appcorp/shadcn/components/enhanced-input");
18
18
  var context_1 = require("./context");
19
19
  var ServicesSection = function () {
20
20
  var t = (0, next_intl_1.useTranslations)("invoice");
21
- var _a = (0, context_1.useInvoiceStateContext)(), errors = _a.errors, handleDeleteServiceRow = _a.handleDeleteServiceRow, handleItemChangeServices = _a.handleItemChangeServices, servicesList = _a.servicesList;
22
- if (!servicesList || servicesList.length === 0) {
21
+ var _a = (0, context_1.useInvoiceModule)(), state = _a.state, handleDeleteServiceRow = _a.handleDeleteServiceRow, handleItemChangeServices = _a.handleItemChangeServices;
22
+ var errors = state.errors, serviceList = state.serviceList;
23
+ if (!serviceList || serviceList.length === 0) {
23
24
  return null;
24
25
  }
25
26
  return (react_1.default.createElement("div", { className: "flex flex-col gap-4" },
26
27
  react_1.default.createElement("h3", { className: "text-lg font-semibold border-b pb-2" }, t("serviceFormSectionTitle")),
27
- react_1.default.createElement("div", { className: "flex flex-col gap-4" }, servicesList.map(function (row, index) { return (react_1.default.createElement("div", { key: index, className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-[1fr_1fr_0.75fr_0.75fr_0.75fr_auto] gap-4 items-end p-4 border rounded-lg" },
28
+ react_1.default.createElement("div", { className: "flex flex-col gap-4" }, serviceList.map(function (row, index) { return (react_1.default.createElement("div", { key: index, className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-[1fr_1fr_0.75fr_0.75fr_0.75fr_auto] gap-4 items-end p-4 border rounded-lg" },
28
29
  react_1.default.createElement("div", { className: "space-y-2" },
29
30
  react_1.default.createElement(enhanced_input_1.EnhancedInput, { error: errors["servicesList-".concat(index, "-name")], id: "service-name-".concat(index), label: t("serviceFormLabelServiceName"), onChange: function (e) {
30
31
  return handleItemChangeServices({
@@ -32,7 +33,7 @@ var ServicesSection = function () {
32
33
  key: "name",
33
34
  value: e.target.value,
34
35
  });
35
- }, placeholder: t("serviceFormPlaceholderServiceName"), required: true, type: "text", value: servicesList[index].name || "", info: t("serviceFormInfoServiceName") })),
36
+ }, placeholder: t("serviceFormPlaceholderServiceName"), required: true, type: "text", value: serviceList[index].name || "", info: t("serviceFormInfoServiceName") })),
36
37
  react_1.default.createElement("div", { className: "space-y-2" },
37
38
  react_1.default.createElement(enhanced_input_1.EnhancedInput, { error: errors["servicesList-".concat(index, "-description")], id: "service-description-".concat(index), label: t("serviceFormLabelServiceDescription"), onChange: function (e) {
38
39
  return handleItemChangeServices({
@@ -40,7 +41,7 @@ var ServicesSection = function () {
40
41
  key: "description",
41
42
  value: e.target.value,
42
43
  });
43
- }, placeholder: t("serviceFormPlaceholderServiceDescription"), type: "text", value: servicesList[index].description || "", info: t("serviceFormInfoServiceDescription") })),
44
+ }, placeholder: t("serviceFormPlaceholderServiceDescription"), type: "text", value: serviceList[index].description || "", info: t("serviceFormInfoServiceDescription") })),
44
45
  react_1.default.createElement("div", { className: "space-y-2" },
45
46
  react_1.default.createElement(enhanced_input_1.EnhancedInput, { error: errors["servicesList-".concat(index, "-quantity")], id: "service-quantity-".concat(index), label: t("serviceFormLabelServiceQuantity"), onChange: function (e) {
46
47
  return handleItemChangeServices({
@@ -48,7 +49,7 @@ var ServicesSection = function () {
48
49
  key: "quantity",
49
50
  value: e.target.value,
50
51
  });
51
- }, placeholder: t("serviceFormPlaceholderServiceQuantity"), required: true, type: "number", value: servicesList[index].quantity || "", info: t("serviceFormInfoServiceQuantity") })),
52
+ }, placeholder: t("serviceFormPlaceholderServiceQuantity"), required: true, type: "number", value: serviceList[index].quantity || "", info: t("serviceFormInfoServiceQuantity") })),
52
53
  react_1.default.createElement("div", { className: "space-y-2" },
53
54
  react_1.default.createElement(enhanced_input_1.EnhancedInput, { error: errors["servicesList-".concat(index, "-price")], id: "service-price-".concat(index), label: t("serviceFormLabelServicePrice"), onChange: function (e) {
54
55
  return handleItemChangeServices({
@@ -56,7 +57,7 @@ var ServicesSection = function () {
56
57
  key: "price",
57
58
  value: e.target.value,
58
59
  });
59
- }, placeholder: t("serviceFormPlaceholderServicePrice"), required: true, type: "number", value: servicesList[index].price || "", info: t("serviceFormInfoServicePrice") })),
60
+ }, placeholder: t("serviceFormPlaceholderServicePrice"), required: true, type: "number", value: serviceList[index].price || "", info: t("serviceFormInfoServicePrice") })),
60
61
  react_1.default.createElement("div", { className: "space-y-2" },
61
62
  react_1.default.createElement(enhanced_input_1.EnhancedInput, { error: errors["servicesList-".concat(index, "-rowTotal")], id: "service-rowTotal-".concat(index), label: t("serviceFormLabelServiceRowTotal"), onChange: function (e) {
62
63
  return handleItemChangeServices({
@@ -64,8 +65,8 @@ var ServicesSection = function () {
64
65
  key: "rowTotal",
65
66
  value: e.target.value,
66
67
  });
67
- }, placeholder: t("serviceFormPlaceholderServiceRowTotal"), readOnly: true, required: true, type: "number", value: servicesList[index].rowTotal || "", info: t("serviceFormInfoServiceRowTotal") })),
68
- react_1.default.createElement("div", { className: "flex items-end h-full" },
68
+ }, placeholder: t("serviceFormPlaceholderServiceRowTotal"), readOnly: true, required: true, type: "number", value: serviceList[index].rowTotal || "", info: t("serviceFormInfoServiceRowTotal") })),
69
+ react_1.default.createElement("div", { className: "flex items-center h-full" },
69
70
  react_1.default.createElement(button_1.Button, { onClick: function () { return handleDeleteServiceRow(index); }, size: "icon", type: "button", variant: "ghost" },
70
71
  react_1.default.createElement(lucide_react_1.Trash2, { className: "h-4 w-4" }),
71
72
  react_1.default.createElement("span", { className: "sr-only" }, t("serviceFormButtonDeleteService")))))); }))));