@appcorp/stellar-solutions-invoice-module 0.1.73 → 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 +542 -340
  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 -41
  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 +312 -240
  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 +431 -293
  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 -3
  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 +12 -11
  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
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { FC } from "react";
8
8
  interface Props {
9
- isRTL: boolean;
9
+ isRTL?: boolean;
10
10
  }
11
11
  export declare const CustomerSection: FC<Props>;
12
12
  export {};
@@ -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,36 @@ 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)("quote");
52
- var _a = (0, context_1.useQuoteStateContext)(), customer = _a.customer, errors = _a.errors, dispatch = _a.dispatch;
62
+ var _a = (0, context_1.useQuoteModule)(), customer = _a.customer, errors = _a.errors, dispatch = _a.dispatch;
53
63
  var handleCustomerChange = (0, react_1.useCallback)(function (key, value) {
64
+ var _a, _b;
54
65
  if (key === "phone") {
55
66
  var formattedResult = (0, util_functions_1.formatPhone)(value);
56
67
  var formattedPhone = (formattedResult === null || formattedResult === void 0 ? void 0 : formattedResult.international) || value;
57
68
  dispatch({
58
- type: actions_1.QUOTE_ACTION_TYPES.SET_CUSTOMER_FORM,
59
- payload: { key: key, value: formattedPhone },
69
+ type: context_1.QUOTE_ACTION_TYPES.SET_INPUT_FIELD,
70
+ payload: {
71
+ key: "customer",
72
+ value: __assign(__assign({}, customer), (_a = {}, _a[key] = formattedPhone, _a)),
73
+ },
60
74
  });
61
75
  return;
62
76
  }
63
77
  dispatch({
64
- type: actions_1.QUOTE_ACTION_TYPES.SET_CUSTOMER_FORM,
65
- payload: { key: key, value: value },
78
+ type: context_1.QUOTE_ACTION_TYPES.SET_INPUT_FIELD,
79
+ payload: { key: "customer", value: __assign(__assign({}, customer), (_b = {}, _b[key] = value, _b)) },
66
80
  });
67
81
  dispatch({
68
- type: actions_1.QUOTE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
82
+ type: context_1.QUOTE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
69
83
  payload: { disableSaveButton: false },
70
84
  });
71
85
  dispatch({
72
- type: actions_1.QUOTE_ACTION_TYPES.RESET_ERRORS,
86
+ type: context_1.QUOTE_ACTION_TYPES.SET_ERRORS,
87
+ payload: { errors: {} },
73
88
  });
74
- }, [dispatch]);
89
+ }, [dispatch, customer]);
75
90
  var handleInputChange = function (field, value) {
76
91
  handleCustomerChange(field, value);
77
92
  };
@@ -1,6 +1,2 @@
1
1
  import { FC } from "react";
2
- interface Props {
3
- isRTL: boolean;
4
- }
5
- export declare const QuoteForm: FC<Props>;
6
- export {};
2
+ export declare const QuoteForm: FC;
@@ -12,16 +12,15 @@ 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 QuoteForm = function (_a) {
17
- var isRTL = _a.isRTL;
18
- var drawer = (0, context_1.useQuoteStateContext)().drawer;
15
+ // import { INVOICE_MODE } from "../invoice/types";
16
+ var QuoteForm = function () {
17
+ var quoteMode = (0, context_1.useQuoteModule)().quoteMode;
19
18
  return (react_1.default.createElement("div", { className: "flex flex-col gap-8" },
20
- drawer === types_1.QUOTE_DRAWER.QUOTE_CUSTOMER_FORM_DRAWER && (react_1.default.createElement(customer_form_section_1.CustomerSection, { isRTL: isRTL })),
21
- drawer === types_1.QUOTE_DRAWER.QUOTE_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 }),
19
+ quoteMode === "INVOICE_MODE.CUSTOMER" && react_1.default.createElement(customer_form_section_1.CustomerSection, null),
20
+ quoteMode === "INVOICE_MODE.COMPANY" && react_1.default.createElement(company_form_section_1.CompanySection, null),
21
+ react_1.default.createElement(services_form_section_1.ServicesSection, null),
22
+ react_1.default.createElement(products_form_section_1.ProductsSection, null),
23
+ react_1.default.createElement(add_service_product_section_1.AddServiceProductSection, null),
25
24
  react_1.default.createElement(pricing_form_section_1.PricingSection, null)));
26
25
  };
27
26
  exports.QuoteForm = QuoteForm;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Generic Quote Page Component
3
+ *
4
+ * Uses the generic component factory pattern with quote-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 QuotePage: FC;
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Generic Quote Page Component
3
+ *
4
+ * Uses the generic component factory pattern with quote-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.QuotePage = 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
+ // QUOTE MODULE CONFIGURATION
64
+ // ============================================================================
65
+ var quoteConfig = {
66
+ moduleName: "quote",
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: "drawerTitleQuote",
81
+ filterContent: null,
82
+ formContent: react_1.default.createElement(form_1.QuoteForm, null),
83
+ moreActionsContent: null,
84
+ saveLabel: "drawerButtonSave",
85
+ searchPlaceholder: "tableSearchPlaceholder",
86
+ tableDescription: "tableDescription",
87
+ tableTitle: "tableTitle",
88
+ viewContent: null,
89
+ size: "full",
90
+ };
91
+ // ============================================================================
92
+ // ICON MAPPING
93
+ // ============================================================================
94
+ var ICON_MAP = {
95
+ delete: lucide_react_1.Trash2,
96
+ edit: lucide_react_1.Edit,
97
+ view: lucide_react_1.Eye,
98
+ };
99
+ // ============================================================================
100
+ // GENERIC QUOTE PAGE COMPONENT
101
+ // ============================================================================
102
+ var GenericQuotePage = (0, generic_component_factory_1.createGenericModulePage)(quoteConfig);
103
+ var QuotePageInner = function () {
104
+ var t = (0, next_intl_1.useTranslations)("quote");
105
+ var context = (0, context_1.useQuoteModule)();
106
+ // ============================================================================
107
+ // HEADER ACTIONS
108
+ // ============================================================================
109
+ var headerActions = (0, react_1.useMemo)(function () { return [
110
+ {
111
+ enabled: true,
112
+ handleOnClick: function () { return context.handleCreate("company"); },
113
+ icon: lucide_react_1.Building2,
114
+ label: t("actionsQuoteCompany"),
115
+ order: 1,
116
+ },
117
+ {
118
+ enabled: true,
119
+ handleOnClick: function () { return context.handleCreate("customer"); },
120
+ icon: lucide_react_1.User,
121
+ label: t("actionsQuoteCustomer"),
122
+ order: 2,
123
+ },
124
+ ]; }, [context, t]);
125
+ // ============================================================================
126
+ // ROW ACTIONS
127
+ // ============================================================================
128
+ var rowActions = (0, react_1.useMemo)(function () { return [
129
+ {
130
+ enabled: true,
131
+ handleOnClick: function (row) { return context.handleView(row); },
132
+ icon: ICON_MAP.view,
133
+ label: t("actionsButtonView"),
134
+ order: 1,
135
+ },
136
+ {
137
+ enabled: true,
138
+ handleOnClick: function (row) { return context.handleEdit(row); },
139
+ icon: ICON_MAP.edit,
140
+ label: t("actionsButtonEdit"),
141
+ order: 2,
142
+ },
143
+ {
144
+ enabled: true,
145
+ handleOnClick: function (row) { return context.handleDelete(row); },
146
+ icon: ICON_MAP.delete,
147
+ label: t("actionsButtonDelete"),
148
+ order: 3,
149
+ },
150
+ ]; }, [context, t]);
151
+ // ============================================================================
152
+ // ENHANCED CONTEXT WITH ACTIONS
153
+ // ============================================================================
154
+ var enhancedContext = (0, react_1.useMemo)(function () { return (__assign(__assign({}, context), { headerActions: headerActions, rowActions: rowActions, handleNextClick: function () {
155
+ return context.handlePageChange(context.state.currentPage + 1);
156
+ }, handlePreviousClick: function () {
157
+ return context.handlePageChange(context.state.currentPage - 1);
158
+ }, handlePageLimit: function (limit) { return context.handlePageLimitChange(limit); }, searchOnChange: function (query) { return context.handleSearch(query); }, closeDrawer: context.handleCloseDrawer })); }, [context, headerActions, rowActions]);
159
+ return (react_1.default.createElement(GenericQuotePage, { config: quoteConfig, context: enhancedContext, tableBodyCols: constants_1.tableBodyCols }));
160
+ };
161
+ var QuotePage = function () { return (react_1.default.createElement(context_1.QuoteProvider, null,
162
+ react_1.default.createElement(QuotePageInner, null))); };
163
+ exports.QuotePage = QuotePage;
@@ -48,11 +48,12 @@ var label_1 = require("@appcorp/shadcn/components/ui/label");
48
48
  var button_1 = require("@appcorp/shadcn/components/ui/button");
49
49
  var context_1 = require("@appcorp/stellar-solutions-modules/global-modules/tax/context");
50
50
  var context_2 = require("./context");
51
- var types_1 = require("./types");
51
+ var util_functions_1 = require("@react-pakistan/util-functions");
52
52
  var PricingSection = function () {
53
53
  var t = (0, next_intl_1.useTranslations)("quote");
54
- var _a = (0, context_1.useTaxStateContext)(), taxesFromTaxContext = _a.taxes, taxesLoading = _a.listLoading;
55
- var _b = (0, context_2.useQuoteStateContext)(), 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
+ var _a = (0, context_1.useTaxModule)(), taxesLoading = _a.listLoading, taxState = _a.state;
55
+ var taxesFromTaxContext = taxState.items;
56
+ var _b = (0, context_2.useQuoteModule)(), 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
57
  // Find the current tax based on taxRate value
57
58
  var currentTax = (0, react_1.useMemo)(function () {
58
59
  return taxesFromTaxContext === null || taxesFromTaxContext === void 0 ? void 0 : taxesFromTaxContext.find(function (t) { return String(t.taxRate) === String(taxRate); });
@@ -70,13 +71,13 @@ var PricingSection = function () {
70
71
  react_1.default.createElement("p", { className: "text-sm text-muted-foreground" }, t("pricingFormDescriptionDiscountUnit")),
71
72
  react_1.default.createElement("div", { className: "flex gap-2" },
72
73
  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
74
+ return handleChange("discountUnit", util_functions_1.DISCOUNT_UNIT.FIXED_VALUE);
75
+ }, size: "sm", type: "button", variant: discountUnit === util_functions_1.DISCOUNT_UNIT.FIXED_VALUE
75
76
  ? "default"
76
77
  : "outline" }, t("pricingFormDiscountFixedValue")),
77
78
  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
79
+ return handleChange("discountUnit", util_functions_1.DISCOUNT_UNIT.PERCENTAGE_VALUE);
80
+ }, size: "sm", type: "button", variant: discountUnit === util_functions_1.DISCOUNT_UNIT.PERCENTAGE_VALUE
80
81
  ? "default"
81
82
  : "outline" }, t("pricingFormDiscountPercentageValue")))),
82
83
  react_1.default.createElement("div", { className: "space-y-2" },
@@ -84,7 +85,7 @@ var PricingSection = function () {
84
85
  react_1.default.createElement("div", { className: "space-y-2" },
85
86
  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
87
  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 || [])
88
+ 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, loading: taxesLoading, options: (taxesFromTaxContext || [])
88
89
  .slice()
89
90
  .sort(function (a, b) { return a.taxName.localeCompare(b.taxName); })
90
91
  .map(function (tax) { return ({
@@ -19,12 +19,11 @@ var enhanced_input_1 = require("@appcorp/shadcn/components/enhanced-input");
19
19
  var context_1 = require("./context");
20
20
  var ProductsSection = function () {
21
21
  var t = (0, next_intl_1.useTranslations)("quote");
22
- var _a = (0, context_1.useQuoteStateContext)(), errors = _a.errors, getProducts = _a.getProducts, handleDeleteProductRow = _a.handleDeleteProductRow, handleItemChangeProducts = _a.handleItemChangeProducts, productsList = _a.productsList;
22
+ var _a = (0, context_1.useQuoteModule)(), 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;
25
25
  }
26
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
27
- var handleProductSearch = function (_searchQuery) {
26
+ var handleProductSearch = function () {
28
27
  // Product search is handled by getProducts filter in context
29
28
  // This is a placeholder to satisfy CompanyCombobox props
30
29
  };
@@ -18,7 +18,7 @@ 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)("quote");
21
- var _a = (0, context_1.useQuoteStateContext)(), errors = _a.errors, handleDeleteServiceRow = _a.handleDeleteServiceRow, handleItemChangeServices = _a.handleItemChangeServices, servicesList = _a.servicesList;
21
+ var _a = (0, context_1.useQuoteModule)(), errors = _a.errors, handleDeleteServiceRow = _a.handleDeleteServiceRow, handleItemChangeServices = _a.handleItemChangeServices, servicesList = _a.servicesList;
22
22
  if (!servicesList || servicesList.length === 0) {
23
23
  return null;
24
24
  }
@@ -1,127 +0,0 @@
1
- import { CompanyTypeBE } from "@appcorp/stellar-solutions-company-module/base-modules/company/types";
2
- import { Dispatch } from "react";
3
- import { QuoteActions } from "./actions";
4
- import { ProductTypeBE } from "@appcorp/stellar-solutions-product-module/base-modules/product/types";
5
- import { PaymentTypeBE, TaxTypeBE } from "@appcorp/stellar-solutions-modules/global-modules/preferences/types";
6
- import { HeaderAction, RowAction } from "@appcorp/shadcn/components/enhanced-table";
7
- import { Product, QuoteInvoiceTypeBE, Service } from "../invoice/types";
8
- import { ContactTypeBE } from "@appcorp/stellar-solutions-company-module/base-modules/contact/types";
9
- import { CustomerTypeBE } from "@appcorp/stellar-solutions-company-module/base-modules/customer/types";
10
- export interface QuoteContextType {
11
- byIdError?: Error;
12
- byIdLoading: boolean;
13
- clearSearch: () => void;
14
- closeDrawer: () => void;
15
- deleteError?: Error;
16
- deleteLoading: boolean;
17
- dispatch: Dispatch<QuoteActions>;
18
- handleAddItemProduct: () => void;
19
- handleAddItemService: () => void;
20
- handleChange: (field: string, value: string) => void;
21
- handleDeleteProductRow: (i: number) => void;
22
- handleDeleteServiceRow: (i: number) => void;
23
- handleItemChangeProducts: ({ index, key, value, }: {
24
- index: number;
25
- key: keyof Product;
26
- value: string | number;
27
- }) => void;
28
- handleItemChangeServices: ({ index, key, value, }: {
29
- index: number;
30
- key: keyof Service;
31
- value: string | number;
32
- }) => void;
33
- handleNextClick: () => void;
34
- handlePageLimit: (node: string, value: object) => void;
35
- handlePreviousClick: () => void;
36
- handleSubmit: () => void;
37
- handleTaxSearch: (searchQuery: string) => void;
38
- headerActions: HeaderAction[];
39
- listError?: Error;
40
- listFetchNow: () => void;
41
- listLoading: boolean;
42
- rowActions: RowAction[];
43
- searchOnChange: (k: string, v: string) => void;
44
- updateError?: Error;
45
- updateLoading: boolean;
46
- }
47
- export interface QuoteState extends Omit<QuoteInvoiceTypeBE, "createdAt" | "updatedAt"> {
48
- afterDiscount: string;
49
- companiesList: CompanyTypeBE[];
50
- companyQuery: string;
51
- contactsList: ContactTypeBE[];
52
- count: number;
53
- countryQuery: string;
54
- currentPage: number;
55
- customerId?: string;
56
- disableSaveButton: boolean;
57
- drawer: null | QUOTE_DRAWER;
58
- errors: {
59
- [key: string]: string;
60
- };
61
- getProducts: ProductTypeBE[];
62
- quotes: QuoteInvoiceTypeBE[];
63
- loading: boolean;
64
- modal: null | QUOTE_MODAL;
65
- mode: "Create" | "Edit";
66
- netTotal: string;
67
- pageLimit: number;
68
- productQuery: string;
69
- productsList: Product[];
70
- searchQuery: string;
71
- servicesList: Service[];
72
- tax: string;
73
- taxQuery: string;
74
- taxes: TaxTypeBE[];
75
- }
76
- export interface QuoteInvoiceTypeFE {
77
- category: QUOTE_INVOICE_CATEGORY;
78
- company?: CompanyTypeBE;
79
- companyId?: string;
80
- createdAt: string;
81
- currency: string;
82
- customer?: CustomerTypeBE;
83
- customerId?: string;
84
- date: string;
85
- discount?: string;
86
- discountUnit: DISCOUNT_UNIT;
87
- expiryDate: string;
88
- id: string;
89
- invoiceStatus: INVOICE_STATUS;
90
- note: string;
91
- payments: PaymentTypeBE[];
92
- productsList: Product[];
93
- quoteStatus: QUOTE_STATUS;
94
- ref: string;
95
- servicesList: Service[];
96
- subTotal: string;
97
- taxRate: string;
98
- total: string;
99
- updatedAt: string;
100
- }
101
- export declare enum QUOTE_DRAWER {
102
- QUOTE_COMPANY_FORM_DRAWER = "QUOTE_COMPANY_FORM_DRAWER",
103
- QUOTE_CUSTOMER_FORM_DRAWER = "QUOTE_CUSTOMER_FORM_DRAWER"
104
- }
105
- export declare enum QUOTE_MODAL {
106
- DUMMY = "DUMMY"
107
- }
108
- export declare enum QUOTE_INVOICE_CATEGORY {
109
- QUOTE = "QUOTE",
110
- INVOICE = "INVOICE"
111
- }
112
- export declare enum INVOICE_STATUS {
113
- UNPAID = "UNPAID",
114
- PAID = "PAID"
115
- }
116
- export declare enum QUOTE_STATUS {
117
- DRAFT = "DRAFT",
118
- PENDING = "PENDING",
119
- SENT = "SENT",
120
- ACCEPTED = "ACCEPTED",
121
- DECLINED = "DECLINED"
122
- }
123
- export declare enum DISCOUNT_UNIT {
124
- FIXED_VALUE = "FIXED_VALUE",
125
- PERCENTAGE_VALUE = "PERCENTAGE_VALUE"
126
- }
127
- export type { Product, Service, QuoteInvoiceTypeBE };
@@ -1,35 +1,92 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DISCOUNT_UNIT = exports.QUOTE_STATUS = exports.INVOICE_STATUS = exports.QUOTE_INVOICE_CATEGORY = exports.QUOTE_MODAL = exports.QUOTE_DRAWER = void 0;
4
- var QUOTE_DRAWER;
5
- (function (QUOTE_DRAWER) {
6
- QUOTE_DRAWER["QUOTE_COMPANY_FORM_DRAWER"] = "QUOTE_COMPANY_FORM_DRAWER";
7
- QUOTE_DRAWER["QUOTE_CUSTOMER_FORM_DRAWER"] = "QUOTE_CUSTOMER_FORM_DRAWER";
8
- })(QUOTE_DRAWER || (exports.QUOTE_DRAWER = QUOTE_DRAWER = {}));
9
- var QUOTE_MODAL;
10
- (function (QUOTE_MODAL) {
11
- QUOTE_MODAL["DUMMY"] = "DUMMY";
12
- })(QUOTE_MODAL || (exports.QUOTE_MODAL = QUOTE_MODAL = {}));
13
- var QUOTE_INVOICE_CATEGORY;
14
- (function (QUOTE_INVOICE_CATEGORY) {
15
- QUOTE_INVOICE_CATEGORY["QUOTE"] = "QUOTE";
16
- QUOTE_INVOICE_CATEGORY["INVOICE"] = "INVOICE";
17
- })(QUOTE_INVOICE_CATEGORY || (exports.QUOTE_INVOICE_CATEGORY = QUOTE_INVOICE_CATEGORY = {}));
18
- var INVOICE_STATUS;
19
- (function (INVOICE_STATUS) {
20
- INVOICE_STATUS["UNPAID"] = "UNPAID";
21
- INVOICE_STATUS["PAID"] = "PAID";
22
- })(INVOICE_STATUS || (exports.INVOICE_STATUS = INVOICE_STATUS = {}));
23
- var QUOTE_STATUS;
24
- (function (QUOTE_STATUS) {
25
- QUOTE_STATUS["DRAFT"] = "DRAFT";
26
- QUOTE_STATUS["PENDING"] = "PENDING";
27
- QUOTE_STATUS["SENT"] = "SENT";
28
- QUOTE_STATUS["ACCEPTED"] = "ACCEPTED";
29
- QUOTE_STATUS["DECLINED"] = "DECLINED";
30
- })(QUOTE_STATUS || (exports.QUOTE_STATUS = QUOTE_STATUS = {}));
31
- var DISCOUNT_UNIT;
32
- (function (DISCOUNT_UNIT) {
33
- DISCOUNT_UNIT["FIXED_VALUE"] = "FIXED_VALUE";
34
- DISCOUNT_UNIT["PERCENTAGE_VALUE"] = "PERCENTAGE_VALUE";
35
- })(DISCOUNT_UNIT || (exports.DISCOUNT_UNIT = DISCOUNT_UNIT = {}));
1
+ // import { CompanyTypeBE } from "@appcorp/stellar-solutions-company-module/base-modules/company/types";
2
+ // import { ProductTypeBE } from "@appcorp/stellar-solutions-product-module/base-modules/product/types";
3
+ // import {
4
+ // PaymentTypeBE,
5
+ // TaxTypeBE,
6
+ // } from "@appcorp/stellar-solutions-modules/global-modules/preferences/types";
7
+ // import { Product, QuoteInvoiceTypeBE, Service } from "../invoice/types";
8
+ // import { ContactTypeBE } from "@appcorp/stellar-solutions-company-module/base-modules/contact/types";
9
+ // import { CustomerTypeBE } from "@appcorp/stellar-solutions-company-module/base-modules/customer/types";
10
+ // export interface QuoteState extends Omit<
11
+ // QuoteInvoiceTypeBE,
12
+ // "createdAt" | "updatedAt"
13
+ // > {
14
+ // afterDiscount: string;
15
+ // companiesList: CompanyTypeBE[];
16
+ // companyQuery: string;
17
+ // contactsList: ContactTypeBE[];
18
+ // count: number;
19
+ // countryQuery: string;
20
+ // currentPage: number;
21
+ // customerId?: string;
22
+ // disableSaveButton: boolean;
23
+ // drawer: null | QUOTE_DRAWER;
24
+ // errors: { [key: string]: string };
25
+ // getProducts: ProductTypeBE[];
26
+ // quotes: QuoteInvoiceTypeBE[];
27
+ // loading: boolean;
28
+ // modal: null | QUOTE_MODAL;
29
+ // mode: "Create" | "Edit";
30
+ // netTotal: string;
31
+ // pageLimit: number;
32
+ // productQuery: string;
33
+ // productsList: Product[];
34
+ // searchQuery: string;
35
+ // servicesList: Service[];
36
+ // tax: string;
37
+ // taxQuery: string;
38
+ // taxes: TaxTypeBE[];
39
+ // }
40
+ // export interface QuoteInvoiceTypeFE {
41
+ // category: QUOTE_INVOICE_CATEGORY;
42
+ // company?: CompanyTypeBE;
43
+ // companyId?: string;
44
+ // createdAt: string;
45
+ // currency: string;
46
+ // customer?: CustomerTypeBE;
47
+ // customerId?: string;
48
+ // date: string;
49
+ // discount?: string;
50
+ // discountUnit: DISCOUNT_UNIT;
51
+ // expiryDate: string;
52
+ // id: string;
53
+ // invoiceStatus: INVOICE_STATUS;
54
+ // note: string;
55
+ // payments: PaymentTypeBE[];
56
+ // productsList: Product[];
57
+ // quoteStatus: QUOTE_STATUS;
58
+ // ref: string;
59
+ // servicesList: Service[];
60
+ // subTotal: string;
61
+ // taxRate: string;
62
+ // total: string;
63
+ // updatedAt: string;
64
+ // }
65
+ // export enum QUOTE_DRAWER {
66
+ // QUOTE_COMPANY_FORM_DRAWER = "QUOTE_COMPANY_FORM_DRAWER",
67
+ // QUOTE_CUSTOMER_FORM_DRAWER = "QUOTE_CUSTOMER_FORM_DRAWER",
68
+ // }
69
+ // export enum QUOTE_MODAL {
70
+ // DUMMY = "DUMMY",
71
+ // }
72
+ // export enum QUOTE_INVOICE_CATEGORY {
73
+ // QUOTE = "QUOTE",
74
+ // INVOICE = "INVOICE",
75
+ // }
76
+ // export enum INVOICE_STATUS {
77
+ // UNPAID = "UNPAID",
78
+ // PAID = "PAID",
79
+ // }
80
+ // export enum QUOTE_STATUS {
81
+ // DRAFT = "DRAFT",
82
+ // PENDING = "PENDING",
83
+ // SENT = "SENT",
84
+ // ACCEPTED = "ACCEPTED",
85
+ // DECLINED = "DECLINED",
86
+ // }
87
+ // export enum DISCOUNT_UNIT {
88
+ // FIXED_VALUE = "FIXED_VALUE",
89
+ // PERCENTAGE_VALUE = "PERCENTAGE_VALUE",
90
+ // }
91
+ // // Re-export shared types
92
+ // export type { Product, Service, QuoteInvoiceTypeBE };