@appcorp/stellar-solutions-invoice-module 0.1.56 → 0.1.59

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 (92) hide show
  1. package/base-modules/invoice/add-service-product-section.d.ts +12 -2
  2. package/base-modules/invoice/add-service-product-section.js +20 -10
  3. package/base-modules/invoice/company-form-section.d.ts +12 -2
  4. package/base-modules/invoice/company-form-section.js +118 -10
  5. package/base-modules/invoice/constants.d.ts +9 -25
  6. package/base-modules/invoice/constants.js +66 -557
  7. package/base-modules/invoice/context.d.ts +42 -2
  8. package/base-modules/invoice/context.js +232 -312
  9. package/base-modules/invoice/customer-form-section.d.ts +12 -2
  10. package/base-modules/invoice/customer-form-section.js +91 -9
  11. package/base-modules/invoice/drawer.d.ts +9 -4
  12. package/base-modules/invoice/drawer.js +32 -6
  13. package/base-modules/invoice/form.d.ts +2 -4
  14. package/base-modules/invoice/form.js +7 -6
  15. package/base-modules/invoice/invoice.d.ts +2 -2
  16. package/base-modules/invoice/invoice.js +33 -42
  17. package/base-modules/invoice/pricing-form-section.d.ts +12 -2
  18. package/base-modules/invoice/pricing-form-section.js +65 -9
  19. package/base-modules/invoice/products-form-section.d.ts +12 -2
  20. package/base-modules/invoice/products-form-section.js +57 -32
  21. package/base-modules/invoice/reducer.d.ts +2 -2
  22. package/base-modules/invoice/reducer.js +56 -53
  23. package/base-modules/invoice/services-form-section.d.ts +12 -2
  24. package/base-modules/invoice/services-form-section.js +61 -15
  25. package/base-modules/invoice/types.d.ts +16 -21
  26. package/base-modules/invoice/validate.d.ts +23 -3
  27. package/base-modules/invoice/validate.js +61 -61
  28. package/base-modules/payment/actions.d.ts +196 -0
  29. package/base-modules/payment/actions.js +49 -0
  30. package/base-modules/payment/constants.d.ts +101 -0
  31. package/base-modules/payment/constants.js +165 -0
  32. package/base-modules/payment/context.d.ts +56 -0
  33. package/base-modules/payment/context.js +421 -0
  34. package/base-modules/payment/drawer.d.ts +6 -0
  35. package/base-modules/payment/drawer.js +39 -0
  36. package/base-modules/payment/form.d.ts +18 -0
  37. package/base-modules/payment/form.js +90 -0
  38. package/base-modules/payment/index.d.ts +0 -0
  39. package/base-modules/payment/index.js +13 -0
  40. package/base-modules/payment/payment.d.ts +8 -0
  41. package/base-modules/payment/payment.js +39 -0
  42. package/base-modules/payment/reducer.d.ts +29 -0
  43. package/base-modules/payment/reducer.js +211 -0
  44. package/base-modules/payment/types.d.ts +82 -0
  45. package/base-modules/payment/types.js +19 -0
  46. package/base-modules/payment/validate.d.ts +20 -0
  47. package/base-modules/payment/validate.js +23 -0
  48. package/base-modules/quote/actions.d.ts +215 -0
  49. package/base-modules/quote/actions.js +38 -0
  50. package/base-modules/quote/add-service-product-section.d.ts +12 -0
  51. package/base-modules/quote/add-service-product-section.js +31 -0
  52. package/base-modules/quote/calculate-subtotal.d.ts +1 -0
  53. package/base-modules/quote/calculate-subtotal.js +6 -0
  54. package/base-modules/quote/calculate-total.d.ts +1 -0
  55. package/base-modules/quote/calculate-total.js +6 -0
  56. package/base-modules/quote/company-form-section.d.ts +12 -0
  57. package/base-modules/quote/company-form-section.js +125 -0
  58. package/base-modules/quote/constants.d.ts +64 -0
  59. package/base-modules/quote/constants.js +107 -0
  60. package/base-modules/quote/context.d.ts +50 -0
  61. package/base-modules/quote/context.js +822 -0
  62. package/base-modules/quote/customer-form-section.d.ts +12 -0
  63. package/base-modules/quote/customer-form-section.js +99 -0
  64. package/base-modules/quote/drawer.d.ts +13 -0
  65. package/base-modules/quote/drawer.js +45 -0
  66. package/base-modules/quote/form.d.ts +6 -0
  67. package/base-modules/quote/form.js +27 -0
  68. package/base-modules/quote/pricing-form-section.d.ts +12 -0
  69. package/base-modules/quote/pricing-form-section.js +76 -0
  70. package/base-modules/quote/products-form-section.d.ts +12 -0
  71. package/base-modules/quote/products-form-section.js +71 -0
  72. package/base-modules/quote/quote.d.ts +8 -0
  73. package/base-modules/quote/quote.js +69 -0
  74. package/base-modules/quote/reducer.d.ts +4 -0
  75. package/base-modules/quote/reducer.js +181 -0
  76. package/base-modules/quote/services-form-section.d.ts +12 -0
  77. package/base-modules/quote/services-form-section.js +73 -0
  78. package/base-modules/quote/types.d.ts +126 -0
  79. package/base-modules/quote/types.js +35 -0
  80. package/base-modules/quote/validate.d.ts +856 -0
  81. package/base-modules/quote/validate.js +85 -0
  82. package/i18n/navigation.d.ts +342 -0
  83. package/i18n/navigation.js +9 -0
  84. package/i18n/routing.d.ts +18 -0
  85. package/i18n/routing.js +9 -0
  86. package/package.json +21 -8
  87. package/base-modules/invoice/company-form-elements.d.ts +0 -3
  88. package/base-modules/invoice/company-form-elements.js +0 -41
  89. package/base-modules/invoice/customer-form-elements.d.ts +0 -3
  90. package/base-modules/invoice/customer-form-elements.js +0 -41
  91. package/base-modules/invoice/pricing-form-elements.d.ts +0 -3
  92. package/base-modules/invoice/pricing-form-elements.js +0 -41
@@ -1,2 +1,12 @@
1
- import React from 'react';
2
- export declare const CustomerSection: () => React.JSX.Element;
1
+ /**
2
+ * Customer Form Section Component
3
+ *
4
+ * Form section for creating/editing customer information in invoices.
5
+ * Uses Shadcn UI components with RTL support and i18n.
6
+ */
7
+ import { FC } from "react";
8
+ interface Props {
9
+ isRTL: boolean;
10
+ }
11
+ export declare const CustomerSection: FC<Props>;
12
+ export {};
@@ -1,17 +1,99 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ /**
3
+ * Customer Form Section Component
4
+ *
5
+ * Form section for creating/editing customer information in invoices.
6
+ * Uses Shadcn UI components with RTL support and i18n.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
5
41
  Object.defineProperty(exports, "__esModule", { value: true });
6
42
  exports.CustomerSection = void 0;
7
- var react_1 = __importDefault(require("react"));
8
- var vista_vertical_divider_v4_1 = require("@appcorp/app-corp-vista/molecules/vista-vertical-divider-v4");
9
- var customer_form_elements_1 = require("./customer-form-elements");
43
+ var react_1 = __importStar(require("react"));
44
+ var next_intl_1 = require("next-intl");
45
+ var util_functions_1 = require("@react-pakistan/util-functions");
46
+ var combobox_1 = require("@appcorp/shadcn/components/combobox");
47
+ var input_1 = require("@appcorp/shadcn/components/input");
10
48
  var context_1 = require("./context");
49
+ var actions_1 = require("./actions");
11
50
  var CustomerSection = function () {
12
- var dynamicCustomerFormElements = (0, context_1.useInvoiceStateContext)().dynamicCustomerFormElements;
51
+ var t = (0, next_intl_1.useTranslations)("invoicePage");
52
+ var _a = (0, context_1.useInvoiceStateContext)(), customer = _a.customer, errors = _a.errors, dispatch = _a.dispatch;
53
+ var handleCustomerChange = (0, react_1.useCallback)(function (key, value) {
54
+ if (key === "phone") {
55
+ var formattedResult = (0, util_functions_1.formatPhone)(value);
56
+ var formattedPhone = (formattedResult === null || formattedResult === void 0 ? void 0 : formattedResult.international) || value;
57
+ dispatch({
58
+ type: actions_1.INVOICE_ACTION_TYPES.SET_CUSTOMER_FORM,
59
+ payload: { key: key, value: formattedPhone },
60
+ });
61
+ return;
62
+ }
63
+ dispatch({
64
+ type: actions_1.INVOICE_ACTION_TYPES.SET_CUSTOMER_FORM,
65
+ payload: { key: key, value: value },
66
+ });
67
+ dispatch({
68
+ type: actions_1.INVOICE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
69
+ payload: { disableSaveButton: false },
70
+ });
71
+ dispatch({
72
+ type: actions_1.INVOICE_ACTION_TYPES.RESET_ERRORS,
73
+ });
74
+ }, [dispatch]);
75
+ var handleInputChange = function (field, value) {
76
+ handleCustomerChange(field, value);
77
+ };
78
+ var handleCountryChange = function (country) {
79
+ handleCustomerChange("country", country);
80
+ };
13
81
  return (react_1.default.createElement("div", { className: "flex flex-col gap-4" },
14
- react_1.default.createElement(vista_vertical_divider_v4_1.VistaVerticalDividerV4, { label: "Customer" }),
15
- (0, customer_form_elements_1.renderCustomerFormElements)(dynamicCustomerFormElements)));
82
+ react_1.default.createElement("h3", { className: "text-lg font-semibold border-b pb-2" }, t("customerSectionTitle")),
83
+ react_1.default.createElement("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4" },
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 })),
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 })),
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 })),
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 })),
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 })),
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 })),
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 })))));
16
98
  };
17
99
  exports.CustomerSection = CustomerSection;
@@ -1,8 +1,13 @@
1
- import { FC } from 'react';
1
+ /**
2
+ * Invoice Drawer Component
3
+ *
4
+ * A full-screen drawer component for creating/editing invoices with multi-section forms.
5
+ * Supports both company and customer invoices with dynamic form sections.
6
+ * Features RTL support and internationalization.
7
+ */
8
+ import { FC } from "react";
2
9
  interface Props {
3
- translationMap: {
4
- [key: string]: string;
5
- };
10
+ isRTL: boolean;
6
11
  }
7
12
  export declare const Drawer: FC<Props>;
8
13
  export {};
@@ -1,19 +1,45 @@
1
1
  "use strict";
2
+ /**
3
+ * Invoice Drawer Component
4
+ *
5
+ * A full-screen drawer component for creating/editing invoices with multi-section forms.
6
+ * Supports both company and customer invoices with dynamic form sections.
7
+ * Features RTL support and internationalization.
8
+ */
2
9
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
10
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
11
  };
5
12
  Object.defineProperty(exports, "__esModule", { value: true });
6
13
  exports.Drawer = void 0;
7
14
  var react_1 = __importDefault(require("react"));
8
- var vista_drawer_v1_1 = require("@appcorp/app-corp-vista/molecules/vista-drawer-v1/vista-drawer-v1");
9
- var vista_drawer_type_1 = require("@appcorp/app-corp-vista/type/vista-drawer-type");
10
- var vista_button_type_1 = require("@appcorp/app-corp-vista/type/vista-button-type");
15
+ var lucide_react_1 = require("lucide-react");
16
+ var next_intl_1 = require("next-intl");
17
+ var button_1 = require("@appcorp/shadcn/components/button");
18
+ var drawer_1 = require("@appcorp/shadcn/components/drawer");
11
19
  var context_1 = require("./context");
12
20
  var form_1 = require("./form");
21
+ var types_1 = require("./types");
13
22
  var Drawer = function (_a) {
14
- var translationMap = _a.translationMap;
23
+ var isRTL = _a.isRTL;
24
+ var t = (0, next_intl_1.useTranslations)("invoicePage");
15
25
  var _b = (0, context_1.useInvoiceStateContext)(), closeDrawer = _b.closeDrawer, disableSaveButton = _b.disableSaveButton, drawer = _b.drawer, handleSubmit = _b.handleSubmit;
16
- return (react_1.default.createElement(vista_drawer_v1_1.VistaDrawerV1, { cancelLabel: "Cancel", cancelRounded: vista_button_type_1.VISTA_BUTTON_ROUNDED.MD, cancelSize: vista_button_type_1.VISTA_BUTTON_SIZE.LG, handleCancelOnClick: closeDrawer, handleSaveOnClick: handleSubmit, handleSetIsOpen: closeDrawer, isOpen: !!drawer, saveDisabled: disableSaveButton, saveLabel: 'Save', saveRounded: vista_button_type_1.VISTA_BUTTON_ROUNDED.MD, saveSize: vista_button_type_1.VISTA_BUTTON_SIZE.LG, size: vista_drawer_type_1.VISTA_DRAWER_SIZE.XL, title: 'Invoice' },
17
- react_1.default.createElement(form_1.InvoiceForm, { translationMap: translationMap })));
26
+ var isFormDrawer = drawer === types_1.INVOICE_DRAWER.INVOICE_COMPANY_FORM_DRAWER ||
27
+ drawer === types_1.INVOICE_DRAWER.INVOICE_CUSTOMER_FORM_DRAWER;
28
+ var drawerTitle = t("drawerTitleInvoice");
29
+ var drawerWidth = "data-[vaul-drawer-direction=right]:sm:max-w-5xl";
30
+ var drawerDirection = isRTL ? "left" : "right";
31
+ return (react_1.default.createElement(drawer_1.Drawer, { open: !!drawer, onOpenChange: function (open) { return !open && closeDrawer(); }, direction: drawerDirection },
32
+ react_1.default.createElement(drawer_1.DrawerContent, { className: "h-full ".concat(drawerWidth, " ").concat(isRTL ? "rtl" : "ltr"), dir: isRTL ? "rtl" : "ltr" },
33
+ react_1.default.createElement(drawer_1.DrawerHeader, { className: "flex-row items-center justify-between border-b pb-4 ".concat(isRTL ? "flex-row-reverse" : "") },
34
+ react_1.default.createElement(drawer_1.DrawerTitle, { className: "text-xl font-semibold flex items-center ".concat(isRTL ? "flex-row-reverse gap-2" : "gap-2") }, drawerTitle),
35
+ react_1.default.createElement(drawer_1.DrawerClose, { asChild: true },
36
+ react_1.default.createElement(button_1.Button, { variant: "ghost", size: "icon", className: "h-8 w-8" },
37
+ react_1.default.createElement(lucide_react_1.X, { className: "h-4 w-4" }),
38
+ react_1.default.createElement("span", { className: "sr-only" }, t("drawerButtonClose"))))),
39
+ react_1.default.createElement("div", { className: "flex-1 overflow-y-auto px-4 py-6 ".concat(isRTL ? "text-right" : "text-left") }, isFormDrawer && react_1.default.createElement(form_1.InvoiceForm, { isRTL: isRTL })),
40
+ react_1.default.createElement(drawer_1.DrawerFooter, { className: "border-t pt-4" },
41
+ react_1.default.createElement("div", { className: "flex gap-2 ".concat(isRTL ? "flex-row-reverse" : "") },
42
+ react_1.default.createElement(button_1.Button, { variant: "outline", onClick: closeDrawer, className: "flex-1" }, t("drawerButtonCancel")),
43
+ isFormDrawer && (react_1.default.createElement(button_1.Button, { onClick: handleSubmit, disabled: disableSaveButton, className: "flex-1" }, t("drawerButtonSave"))))))));
18
44
  };
19
45
  exports.Drawer = Drawer;
@@ -1,8 +1,6 @@
1
- import { FC } from 'react';
1
+ import { FC } from "react";
2
2
  interface Props {
3
- translationMap: {
4
- [key: string]: string;
5
- };
3
+ isRTL: boolean;
6
4
  }
7
5
  export declare const InvoiceForm: FC<Props>;
8
6
  export {};
@@ -13,14 +13,15 @@ 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
15
  var types_1 = require("./types");
16
- var InvoiceForm = function () {
16
+ var InvoiceForm = function (_a) {
17
+ var isRTL = _a.isRTL;
17
18
  var drawer = (0, context_1.useInvoiceStateContext)().drawer;
18
19
  return (react_1.default.createElement("div", { className: "flex flex-col gap-8" },
19
- drawer === types_1.INVOICE_DRAWER.INVOICE_CUSTOMER_FORM_DRAWER && (react_1.default.createElement(customer_form_section_1.CustomerSection, null)),
20
- drawer === types_1.INVOICE_DRAWER.INVOICE_COMPANY_FORM_DRAWER && (react_1.default.createElement(company_form_section_1.CompanySection, null)),
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),
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 }),
24
25
  react_1.default.createElement(pricing_form_section_1.PricingSection, null)));
25
26
  };
26
27
  exports.InvoiceForm = InvoiceForm;
@@ -1,7 +1,7 @@
1
- import { FC } from 'react';
1
+ import { FC } from "react";
2
2
  interface Props {
3
3
  params: Promise<{
4
- locale: 'en' | 'ur';
4
+ locale: "en" | "ur";
5
5
  }>;
6
6
  }
7
7
  export declare const InvoicePage: FC<Props>;
@@ -1,4 +1,4 @@
1
- 'use client';
1
+ "use client";
2
2
  "use strict";
3
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -8,71 +8,62 @@ exports.InvoicePage = void 0;
8
8
  var react_1 = __importDefault(require("react"));
9
9
  var next_intl_1 = require("next-intl");
10
10
  var util_functions_1 = require("@react-pakistan/util-functions");
11
- var context_1 = require("./context");
12
- var vista_table_v1_1 = require("@appcorp/app-corp-vista/organisms/vista-table-v1/vista-table-v1");
11
+ var use_rtl_1 = require("@appcorp/stellar-solutions-modules/hooks/use-rtl");
12
+ var enhanced_table_1 = require("@appcorp/shadcn/components/enhanced-table");
13
+ var sonner_1 = require("@appcorp/shadcn/components/sonner");
13
14
  var constants_1 = require("./constants");
15
+ var context_1 = require("./context");
14
16
  var drawer_1 = require("./drawer");
15
- var generate_toast_1 = require("@appcorp/app-corp-vista/utils/generate-toast");
16
17
  var InvoicePage = function () {
17
- var _a = (0, context_1.useInvoiceStateContext)(), count = _a.count, currentPage = _a.currentPage, pageLimit = _a.pageLimit, handleNextClick = _a.handleNextClick, handlePreviousClick = _a.handlePreviousClick, headerActions = _a.headerActions, handlePageLimit = _a.handlePageLimit, searchQuery = _a.searchQuery, searchOnChange = _a.searchOnChange, rowActions = _a.rowActions, invoices = _a.invoices, listLoading = _a.listLoading;
18
- var t = (0, next_intl_1.useTranslations)('invoicePage');
19
- var translationMap = {
20
- formLabelName: 'formLabelName',
21
- formLabelBuyPrice: 'formLabelBuyPrice',
22
- formLabelDescription: 'formLabelDescription',
23
- formLabelQuantity: 'formLabelQuantity',
24
- formLabelSalePrice: 'formLabelSalePrice',
25
- formLabelRef: 'formLabelRef',
26
- formLabelCurrency: 'formLabelCurrency',
27
- formLabelImage: 'formLabelImage',
28
- formLabelProductCategory: 'formLabelProductCategory',
29
- };
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
+ var isRTL = (0, use_rtl_1.useRTL)();
20
+ var t = (0, next_intl_1.useTranslations)("invoicePage");
30
21
  var tableHeadItems = [
31
22
  {
32
- label: t('tableColumnHeaderId'),
33
- width: '5%',
23
+ label: t("tableColumnHeaderId"),
24
+ width: "5%",
34
25
  },
35
26
  {
36
- label: t('tableColumnHeaderName'),
37
- width: '10%',
27
+ label: t("tableColumnHeaderName"),
28
+ width: "10%",
38
29
  },
39
30
  {
40
- label: t('tableColumnHeaderIssueExpiryDate'),
41
- width: '10%',
31
+ label: t("tableColumnHeaderIssueExpiryDate"),
32
+ width: "10%",
42
33
  },
43
34
  {
44
- label: t('tableColumnHeaderRef'),
45
- width: '5%',
35
+ label: t("tableColumnHeaderRef"),
36
+ width: "5%",
46
37
  },
47
38
  {
48
- label: t('tableColumnHeaderSubTotal'),
49
- width: '5%',
39
+ label: t("tableColumnHeaderSubTotal"),
40
+ width: "5%",
50
41
  },
51
42
  {
52
- label: t('tableColumnHeaderTaxValue'),
53
- width: '5%',
43
+ label: t("tableColumnHeaderTaxValue"),
44
+ width: "5%",
54
45
  },
55
46
  {
56
- label: t('tableColumnHeaderDiscountPrice'),
57
- width: '5%',
47
+ label: t("tableColumnHeaderDiscountPrice"),
48
+ width: "5%",
58
49
  },
59
50
  {
60
- label: t('tableColumnHeaderTotalPrice'),
61
- width: '5%',
51
+ label: t("tableColumnHeaderTotalPrice"),
52
+ width: "5%",
62
53
  },
63
54
  {
64
- label: t('tableColumnHeaderCategory'),
65
- width: '5%',
55
+ label: t("tableColumnHeaderCategory"),
56
+ width: "5%",
66
57
  },
67
58
  {
68
- label: t('tableColumnHeaderActions'),
69
- width: '5%',
59
+ label: t("tableColumnHeaderActions"),
60
+ width: "5%",
70
61
  },
71
62
  ];
72
- var totalPagePerRecord = (0, util_functions_1.calculatePages)(count, pageLimit);
73
- return (react_1.default.createElement(react_1.default.Fragment, null,
74
- react_1.default.createElement(vista_table_v1_1.VistaTableV1, { currentPage: currentPage, handleNextOnClick: handleNextClick, handleOnSelect: handlePageLimit, handlePreviousOnClick: handlePreviousClick, handleSearchInput: searchOnChange, headerActions: headerActions, isNextDisabled: (0, util_functions_1.isNextButtonDisabled)(currentPage, totalPagePerRecord), 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, selectKey1: "option", selectedItem: { option: String(pageLimit) }, tableBodyCols: constants_1.tableBodyCols, tableBodyRows: invoices, tableDescription: t('subTitle'), tableHeadItems: tableHeadItems, tableHeading: t('title'), totalPages: totalPagePerRecord }),
75
- react_1.default.createElement(drawer_1.Drawer, { translationMap: translationMap }),
76
- react_1.default.createElement(generate_toast_1.VistaToaster, null)));
63
+ var totalPages = (0, util_functions_1.calculatePages)(count, pageLimit);
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 }),
66
+ react_1.default.createElement(drawer_1.Drawer, { isRTL: isRTL }),
67
+ react_1.default.createElement(sonner_1.Toaster, null)));
77
68
  };
78
69
  exports.InvoicePage = InvoicePage;
@@ -1,2 +1,12 @@
1
- import React from 'react';
2
- export declare const PricingSection: () => React.JSX.Element;
1
+ /**
2
+ * Pricing Form Section Component
3
+ *
4
+ * Totals calculation section for invoice pricing including tax and discount.
5
+ * Uses Shadcn UI components with RTL support and i18n.
6
+ */
7
+ import { FC } from "react";
8
+ interface Props {
9
+ isRTL?: boolean;
10
+ }
11
+ export declare const PricingSection: FC<Props>;
12
+ export {};
@@ -1,20 +1,76 @@
1
1
  "use strict";
2
+ /**
3
+ * Pricing Form Section Component
4
+ *
5
+ * Totals calculation section for invoice pricing including tax and discount.
6
+ * Uses Shadcn UI components with RTL support and i18n.
7
+ */
2
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
10
  };
5
11
  Object.defineProperty(exports, "__esModule", { value: true });
6
12
  exports.PricingSection = void 0;
7
13
  var react_1 = __importDefault(require("react"));
8
- var vista_vertical_divider_v4_1 = require("@appcorp/app-corp-vista/molecules/vista-vertical-divider-v4");
14
+ var next_intl_1 = require("next-intl");
15
+ var combobox_1 = require("@appcorp/shadcn/components/combobox");
16
+ var input_1 = require("@appcorp/shadcn/components/input");
17
+ var label_1 = require("@appcorp/shadcn/components/label");
18
+ var button_1 = require("@appcorp/shadcn/components/button");
9
19
  var context_1 = require("./context");
10
- var pricing_form_elements_1 = require("./pricing-form-elements");
20
+ var types_1 = require("./types");
11
21
  var PricingSection = function () {
12
- var dynamicPricingFormElements = (0, context_1.useInvoiceStateContext)().dynamicPricingFormElements;
13
- return (react_1.default.createElement(react_1.default.Fragment, null,
14
- react_1.default.createElement(vista_vertical_divider_v4_1.VistaVerticalDividerV4, { label: "Totals" }),
15
- react_1.default.createElement("div", { className: "grid grid-cols-3 justify-end" },
16
- react_1.default.createElement("div", null),
17
- react_1.default.createElement("div", null),
18
- (0, pricing_form_elements_1.renderPricingFormElements)(dynamicPricingFormElements))));
22
+ var t = (0, next_intl_1.useTranslations)("invoicePage");
23
+ var _a = (0, context_1.useInvoiceStateContext)(), afterDiscount = _a.afterDiscount, discount = _a.discount, discountUnit = _a.discountUnit, errors = _a.errors, handleChange = _a.handleChange, subTotal = _a.subTotal, tax = _a.tax, taxes = _a.taxes, total = _a.total;
24
+ var handleTaxChange = function (selectedTaxId) {
25
+ var selectedTax = taxes === null || taxes === void 0 ? void 0 : taxes.find(function (t) { return t.id === selectedTaxId; });
26
+ if (selectedTax) {
27
+ handleChange("taxRate", selectedTax.taxRate);
28
+ }
29
+ };
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
+ var handleTaxSearch = function (_searchQuery) {
32
+ // Tax search functionality placeholder
33
+ };
34
+ var handleDiscountUnitChange = function (unit) {
35
+ handleChange("discountUnit", unit);
36
+ };
37
+ // Map taxes to have consistent structure for CompanyCombobox
38
+ var taxOptions = (taxes || []).map(function (tax) { return ({
39
+ id: tax.id,
40
+ name: "".concat(tax.taxName, " (").concat(tax.taxRate, "%)"),
41
+ }); });
42
+ var currentTax = taxes === null || taxes === void 0 ? void 0 : taxes.find(function (t) { return String(t.taxRate) === String(tax); });
43
+ return (react_1.default.createElement("div", { className: "flex flex-col gap-6" },
44
+ react_1.default.createElement("h3", { className: "text-lg font-semibold border-b pb-2" }, t("pricingSectionTitle")),
45
+ react_1.default.createElement("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6" },
46
+ react_1.default.createElement("div", { className: "hidden lg:block" }),
47
+ react_1.default.createElement("div", { className: "hidden lg:block" }),
48
+ react_1.default.createElement("div", { className: "flex flex-col gap-4" },
49
+ react_1.default.createElement("div", { className: "space-y-2" },
50
+ 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" })),
51
+ react_1.default.createElement("div", { className: "space-y-3" },
52
+ react_1.default.createElement(label_1.Label, null, t("formLabelDiscountUnit")),
53
+ react_1.default.createElement("p", { className: "text-sm text-muted-foreground" }, t("discountUnitDescription")),
54
+ react_1.default.createElement("div", { className: "flex gap-2" },
55
+ react_1.default.createElement(button_1.Button, { onClick: function () {
56
+ return handleDiscountUnitChange(types_1.DISCOUNT_UNIT.FIXED_VALUE);
57
+ }, size: "sm", type: "button", variant: discountUnit === types_1.DISCOUNT_UNIT.FIXED_VALUE
58
+ ? "default"
59
+ : "outline" }, t("discountUnitFixedValue")),
60
+ react_1.default.createElement(button_1.Button, { onClick: function () {
61
+ return handleDiscountUnitChange(types_1.DISCOUNT_UNIT.PERCENTAGE_VALUE);
62
+ }, size: "sm", type: "button", variant: discountUnit === types_1.DISCOUNT_UNIT.PERCENTAGE_VALUE
63
+ ? "default"
64
+ : "outline" }, t("discountUnitPercentageValue")))),
65
+ react_1.default.createElement("div", { className: "space-y-2" },
66
+ 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" })),
67
+ react_1.default.createElement("div", { className: "space-y-2" },
68
+ 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" })),
69
+ react_1.default.createElement("div", { className: "space-y-2" },
70
+ react_1.default.createElement(combobox_1.CompanyCombobox, { companies: taxOptions, id: "taxRate", label: t("formLabelTax"), onSearchChange: handleTaxSearch, onValueChange: handleTaxChange, placeholder: t("formPlaceholderTax"), value: (currentTax === null || currentTax === void 0 ? void 0 : currentTax.id) || "" })),
71
+ react_1.default.createElement("div", { className: "space-y-2" },
72
+ 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" })),
73
+ react_1.default.createElement("div", { className: "space-y-2" },
74
+ 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") }))))));
19
75
  };
20
76
  exports.PricingSection = PricingSection;
@@ -1,2 +1,12 @@
1
- import React from 'react';
2
- export declare const ProductsSection: () => React.JSX.Element;
1
+ /**
2
+ * Products Form Section Component
3
+ *
4
+ * Dynamic list of product rows for invoice creation/editing.
5
+ * Uses Shadcn UI components with RTL support and i18n.
6
+ */
7
+ import { FC } from "react";
8
+ interface Props {
9
+ isRTL?: boolean;
10
+ }
11
+ export declare const ProductsSection: FC<Props>;
12
+ export {};
@@ -1,46 +1,71 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
2
+ /**
3
+ * Products Form Section Component
4
+ *
5
+ * Dynamic list of product rows for invoice creation/editing.
6
+ * Uses Shadcn UI components with RTL support and i18n.
7
+ */
13
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
10
  };
16
11
  Object.defineProperty(exports, "__esModule", { value: true });
17
12
  exports.ProductsSection = void 0;
18
13
  var react_1 = __importDefault(require("react"));
19
- var vista_vertical_divider_v4_1 = require("@appcorp/app-corp-vista/molecules/vista-vertical-divider-v4");
14
+ var next_intl_1 = require("next-intl");
15
+ var lucide_react_1 = require("lucide-react");
16
+ var button_1 = require("@appcorp/shadcn/components/button");
17
+ var combobox_1 = require("@appcorp/shadcn/components/combobox");
18
+ var input_1 = require("@appcorp/shadcn/components/input");
20
19
  var context_1 = require("./context");
21
- var vista_text_input_v1_1 = require("@appcorp/app-corp-vista/molecules/vista-text-input-v1");
22
- var vista_button_v1_1 = require("@appcorp/app-corp-vista/molecules/vista-button-v1/vista-button-v1");
23
- var solid_1 = require("@heroicons/react/24/solid");
24
- var vista_button_type_1 = require("@appcorp/app-corp-vista/type/vista-button-type");
25
- var vista_combobox_v1_1 = require("@appcorp/app-corp-vista/molecules/vista-combobox-v1/vista-combobox-v1");
26
20
  var ProductsSection = function () {
27
- var _a = (0, context_1.useInvoiceStateContext)(), errors = _a.errors, getProducts = _a.getProducts, handleChange = _a.handleChange, handleDeleteServiceRow = _a.handleDeleteServiceRow, handleItemChangeProducts = _a.handleItemChangeProducts, productsList = _a.productsList;
21
+ var t = (0, next_intl_1.useTranslations)("invoicePage");
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) {
24
+ return null;
25
+ }
26
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
27
+ var handleProductSearch = function (_searchQuery) {
28
+ // Product search is handled by getProducts filter in context
29
+ // This is a placeholder to satisfy CompanyCombobox props
30
+ };
28
31
  return (react_1.default.createElement("div", { className: "flex flex-col gap-4" },
29
- react_1.default.createElement(vista_vertical_divider_v4_1.VistaVerticalDividerV4, { label: "Products" }),
30
- productsList.length > 0 && (productsList === null || productsList === void 0 ? void 0 : productsList.map(function (row, index) { return (react_1.default.createElement("div", { key: index, className: 'grid grid-cols-[17.5%_17.5%_17.5%_17.5%_17.5%_auto] items-start justify-between gap-4' },
31
- react_1.default.createElement("div", { className: 'col-span-2' },
32
- react_1.default.createElement(vista_combobox_v1_1.VistaComboboxV1, { handleOnChange: function (k, v) {
33
- var val = __assign({}, v);
34
- handleItemChangeProducts({
32
+ react_1.default.createElement("h3", { className: "text-lg font-semibold border-b pb-2" }, t("productsSectionTitle")),
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
+ 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) {
36
+ return handleItemChangeProducts({
37
+ index: index,
38
+ key: "id",
39
+ value: selectedProductId,
40
+ });
41
+ }, placeholder: t("formPlaceholderProduct"), required: true, value: productsList[index].id || "" })),
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) {
44
+ return handleItemChangeProducts({
45
+ index: index,
46
+ key: "quantity",
47
+ value: e.target.value,
48
+ });
49
+ }, placeholder: "1", required: true, type: "number", value: String(productsList[index].quantity || "") })),
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) {
52
+ return handleItemChangeProducts({
53
+ index: index,
54
+ key: "price",
55
+ value: e.target.value,
56
+ });
57
+ }, placeholder: "0.00", required: true, type: "number", value: productsList[index].price || "" })),
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) {
60
+ return handleItemChangeProducts({
35
61
  index: index,
36
- key: k,
37
- value: val.id,
62
+ key: "rowTotal",
63
+ value: e.target.value,
38
64
  });
39
- }, handleOnBlur: handleChange, handleInputOnChange: handleChange, label: "Product", listItems: getProducts, nodeQueryKey: 'productQuery', nodeSelectKey: 'id', query: '', selectKey1: 'name', selectedItem: { id: productsList[index].id }, error: errors["productsList-".concat(index, "-id")] })),
40
- react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeProducts({ index: index, key: k, value: v }); }, id: 'quantity', label: 'Quantity', placeholder: '1', value: String(productsList[index].quantity), type: 'number', error: errors["productsList-".concat(index, "-quantity")] }),
41
- react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeProducts({ index: index, key: k, value: v }); }, id: 'price', label: 'Price', placeholder: '0.00', value: productsList[index].price, type: 'number', error: errors["productsList-".concat(index, "-price")] }),
42
- react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeProducts({ index: index, key: k, value: v }); }, id: 'rowTotal', label: 'Row Total', placeholder: '0.00', value: productsList[index].rowTotal, type: 'number', readOnly: true, error: errors["productsList-".concat(index, "-rowTotal")] }),
43
- react_1.default.createElement("div", { className: 'h-full flex flex-col justify-center' },
44
- react_1.default.createElement(vista_button_v1_1.VistaButtonV1, { className: 'flex justify-center items-end', handleOnClick: function () { return handleDeleteServiceRow(index); }, icon: react_1.default.createElement(solid_1.TrashIcon, { className: "size-6" }), variant: vista_button_type_1.VISTA_BUTTON_VARIANT.ICON })))); }))));
65
+ }, placeholder: "0.00", readOnly: true, required: true, type: "number", value: productsList[index].rowTotal || "" })),
66
+ react_1.default.createElement("div", { className: "flex items-end h-full" },
67
+ react_1.default.createElement(button_1.Button, { onClick: function () { return handleDeleteProductRow(index); }, size: "icon", type: "button", variant: "ghost" },
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")))))); }))));
45
70
  };
46
71
  exports.ProductsSection = ProductsSection;
@@ -1,4 +1,4 @@
1
- import { InvoiceActions } from './actions';
2
- import { InvoiceState } from './types';
1
+ import { InvoiceActions } from "./actions";
2
+ import { InvoiceState } from "./types";
3
3
  export declare const initialInvoiceState: InvoiceState;
4
4
  export declare function invoiceReducer(state: InvoiceState, action: InvoiceActions): InvoiceState;