@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
@@ -1,6 +0,0 @@
1
- import { FC } from "react";
2
- interface Props {
3
- isRTL: boolean;
4
- }
5
- export declare const Drawer: FC<Props>;
6
- export {};
@@ -1,44 +1,89 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Drawer = void 0;
7
- var react_1 = __importDefault(require("react"));
8
- var lucide_react_1 = require("lucide-react");
9
- var button_1 = require("@appcorp/shadcn/components/ui/button");
10
- var drawer_1 = require("@appcorp/shadcn/components/ui/drawer");
11
- var context_1 = require("./context");
12
- var form_1 = require("./form");
13
- var types_1 = require("./types");
14
- var next_intl_1 = require("next-intl");
15
- var view_1 = require("./view");
16
- var Drawer = function (_a) {
17
- var isRTL = _a.isRTL;
18
- var t = (0, next_intl_1.useTranslations)("payment");
19
- var _b = (0, context_1.usePaymentStateContext)(), closeDrawer = _b.closeDrawer, disableSaveButton = _b.disableSaveButton, drawer = _b.drawer, handleSubmit = _b.handleSubmit;
20
- var isFormDrawer = drawer === types_1.PAYMENT_DRAWER.PAYMENT_FORM_DRAWER;
21
- var isFilterDrawer = drawer === types_1.PAYMENT_DRAWER.PAYMENT_FILTER_DRAWER;
22
- var isViewDrawer = drawer === types_1.PAYMENT_DRAWER.PAYMENT_VIEW_DRAWER;
23
- var drawerWidth = "w-[400px] sm:w-[540px]";
24
- var drawerDirection = isRTL ? "left" : "right";
25
- return (react_1.default.createElement(drawer_1.Drawer, { open: !!drawer, onOpenChange: function (open) { return !open && closeDrawer(); }, direction: drawerDirection },
26
- react_1.default.createElement(drawer_1.DrawerContent, { className: "h-full ".concat(drawerWidth, " ").concat(isRTL ? "rtl" : "ltr"), dir: isRTL ? "rtl" : "ltr", "aria-describedby": "drawer-description", "aria-description": "drawer-description" },
27
- react_1.default.createElement(drawer_1.DrawerHeader, { className: "flex flex-row items-center justify-between border-b pb-4 ".concat(isRTL ? "flex-row-reverse" : "") },
28
- react_1.default.createElement(drawer_1.DrawerTitle, { className: "text-xl font-semibold flex items-center ".concat(isRTL ? "flex-row-reverse gap-2" : "gap-2") },
29
- isFormDrawer && t("drawerTitlePayment"),
30
- isFilterDrawer && t("drawerTitleFilter"),
31
- isViewDrawer && t("drawerTitleView")),
32
- react_1.default.createElement(drawer_1.DrawerClose, { asChild: true },
33
- react_1.default.createElement(button_1.Button, { variant: "ghost", size: "icon", className: "h-8 w-8" },
34
- react_1.default.createElement(lucide_react_1.X, { className: "h-4 w-4" }),
35
- react_1.default.createElement("span", { className: "sr-only" }, t("drawerButtonClose"))))),
36
- react_1.default.createElement("div", { className: "flex-1 overflow-y-auto px-4 py-6 ".concat(isRTL ? "text-right" : "text-left") },
37
- isFormDrawer && react_1.default.createElement(form_1.PaymentForm, { isRTL: isRTL }),
38
- isViewDrawer && react_1.default.createElement(view_1.PaymentView, { isRTL: isRTL })),
39
- react_1.default.createElement(drawer_1.DrawerFooter, { className: "border-t pt-4" },
40
- react_1.default.createElement("div", { className: "flex gap-2 ".concat(isRTL ? "flex-row-reverse" : "") },
41
- react_1.default.createElement(button_1.Button, { variant: "outline", onClick: closeDrawer, className: "flex-1" }, t("drawerButtonCancel")),
42
- isFormDrawer && (react_1.default.createElement(button_1.Button, { onClick: handleSubmit, disabled: disableSaveButton, className: "flex-1" }, t("drawerButtonSave"))))))));
43
- };
44
- exports.Drawer = Drawer;
1
+ // import React, { FC } from "react";
2
+ // import { X } from "lucide-react";
3
+ // import { Button } from "@appcorp/shadcn/components/ui/button";
4
+ // import {
5
+ // Drawer as ShadcnDrawer,
6
+ // DrawerClose,
7
+ // DrawerContent,
8
+ // DrawerFooter,
9
+ // DrawerHeader,
10
+ // DrawerTitle,
11
+ // } from "@appcorp/shadcn/components/ui/drawer";
12
+ // import { usePaymentStateContext } from "./context";
13
+ // import { PaymentForm } from "./form";
14
+ // import { PAYMENT_DRAWER } from "./types";
15
+ // import { useTranslations } from "next-intl";
16
+ // import { PaymentView } from "./view";
17
+ // interface Props {
18
+ // isRTL: boolean;
19
+ // }
20
+ // export const Drawer: FC<Props> = ({ isRTL }) => {
21
+ // const t = useTranslations("payment");
22
+ // const { closeDrawer, disableSaveButton, drawer, handleSubmit } =
23
+ // usePaymentStateContext();
24
+ // const isFormDrawer = drawer === PAYMENT_DRAWER.PAYMENT_FORM_DRAWER;
25
+ // const isFilterDrawer = drawer === PAYMENT_DRAWER.PAYMENT_FILTER_DRAWER;
26
+ // const isViewDrawer = drawer === PAYMENT_DRAWER.PAYMENT_VIEW_DRAWER;
27
+ // const drawerWidth = "w-[400px] sm:w-[540px]";
28
+ // const drawerDirection = isRTL ? "left" : "right";
29
+ // return (
30
+ // <ShadcnDrawer
31
+ // open={!!drawer}
32
+ // onOpenChange={(open: boolean) => !open && closeDrawer()}
33
+ // direction={drawerDirection}
34
+ // >
35
+ // <DrawerContent
36
+ // className={`h-full ${drawerWidth} ${isRTL ? "rtl" : "ltr"}`}
37
+ // dir={isRTL ? "rtl" : "ltr"}
38
+ // aria-describedby="drawer-description"
39
+ // aria-description="drawer-description"
40
+ // >
41
+ // <DrawerHeader
42
+ // className={`flex flex-row items-center justify-between border-b pb-4 ${
43
+ // isRTL ? "flex-row-reverse" : ""
44
+ // }`}
45
+ // >
46
+ // <DrawerTitle
47
+ // className={`text-xl font-semibold flex items-center ${
48
+ // isRTL ? "flex-row-reverse gap-2" : "gap-2"
49
+ // }`}
50
+ // >
51
+ // {isFormDrawer && t("drawerTitlePayment")}
52
+ // {isFilterDrawer && t("drawerTitleFilter")}
53
+ // {isViewDrawer && t("drawerTitleView")}
54
+ // </DrawerTitle>
55
+ // <DrawerClose asChild>
56
+ // <Button variant="ghost" size="icon" className="h-8 w-8">
57
+ // <X className="h-4 w-4" />
58
+ // <span className="sr-only">{t("drawerButtonClose")}</span>
59
+ // </Button>
60
+ // </DrawerClose>
61
+ // </DrawerHeader>
62
+ // <div
63
+ // className={`flex-1 overflow-y-auto px-4 py-6 ${
64
+ // isRTL ? "text-right" : "text-left"
65
+ // }`}
66
+ // >
67
+ // {isFormDrawer && <PaymentForm isRTL={isRTL} />}
68
+ // {isViewDrawer && <PaymentView isRTL={isRTL} />}
69
+ // </div>
70
+ // <DrawerFooter className="border-t pt-4">
71
+ // <div className={`flex gap-2 ${isRTL ? "flex-row-reverse" : ""}`}>
72
+ // <Button variant="outline" onClick={closeDrawer} className="flex-1">
73
+ // {t("drawerButtonCancel")}
74
+ // </Button>
75
+ // {isFormDrawer && (
76
+ // <Button
77
+ // onClick={handleSubmit}
78
+ // disabled={disableSaveButton}
79
+ // className="flex-1"
80
+ // >
81
+ // {t("drawerButtonSave")}
82
+ // </Button>
83
+ // )}
84
+ // </div>
85
+ // </DrawerFooter>
86
+ // </DrawerContent>
87
+ // </ShadcnDrawer>
88
+ // );
89
+ // };
@@ -27,8 +27,9 @@ var context_2 = require("@appcorp/stellar-solutions-modules/global-modules/payme
27
27
  var PaymentForm = function (_a) {
28
28
  var isRTL = _a.isRTL;
29
29
  var t = (0, next_intl_1.useTranslations)("payment");
30
- var _b = (0, context_1.usePaymentStateContext)(), amount = _b.amount, attachment = _b.attachment, balance = _b.balance, currency = _b.currency, date = _b.date, description = _b.description, errors = _b.errors, handleChange = _b.handleChange, paymentModeId = _b.paymentModeId, paymentType = _b.paymentType, ref = _b.ref;
31
- var _c = (0, context_2.usePaymentModeStateContext)(), paymentModes = _c.paymentModes, paymentModesLoading = _c.listLoading;
30
+ var _b = (0, context_1.usePaymentModule)(), amount = _b.amount, attachment = _b.attachment, balance = _b.balance, currency = _b.currency, date = _b.date, description = _b.description, errors = _b.errors, handleChange = _b.handleChange, paymentModeId = _b.paymentModeId, paymentType = _b.paymentType, ref = _b.ref;
31
+ var _c = (0, context_2.usePaymentModeModule)(), paymentModesLoading = _c.listLoading, paymentModeState = _c.state;
32
+ var paymentModes = paymentModeState.items;
32
33
  // Helper function to translate validation error keys
33
34
  var getTranslatedError = function (key) {
34
35
  if (!errors[key])
@@ -8,16 +8,14 @@ exports.PaymentPage = 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 use_rtl_1 = require("@appcorp/stellar-solutions-modules/hooks/use-rtl");
12
11
  var enhanced_table_1 = require("@appcorp/shadcn/components/enhanced-table");
13
12
  var sonner_1 = require("@appcorp/shadcn/components/ui/sonner");
14
13
  var constants_1 = require("./constants");
15
14
  var context_1 = require("./context");
16
- var drawer_1 = require("./drawer");
17
15
  var PaymentPage = function () {
18
- var _a = (0, context_1.usePaymentStateContext)(), count = _a.count, currentPage = _a.currentPage, handleNextClick = _a.handleNextClick, handlePageLimit = _a.handlePageLimit, handlePreviousClick = _a.handlePreviousClick, headerActions = _a.headerActions, listLoading = _a.listLoading, pageLimit = _a.pageLimit, payments = _a.payments, rowActions = _a.rowActions, searchOnChange = _a.searchOnChange, searchQuery = _a.searchQuery;
16
+ var _a = (0, context_1.usePaymentModule)(), count = _a.count, currentPage = _a.currentPage, handleNextClick = _a.handleNextClick, handlePageLimit = _a.handlePageLimit, handlePreviousClick = _a.handlePreviousClick, headerActions = _a.headerActions, listLoading = _a.listLoading, pageLimit = _a.pageLimit, payments = _a.payments, rowActions = _a.rowActions, searchOnChange = _a.searchOnChange, searchQuery = _a.searchQuery;
19
17
  var t = (0, next_intl_1.useTranslations)("payment");
20
- var isRTL = (0, use_rtl_1.useRTL)();
18
+ var isRTL = (0, util_functions_1.useRTL)();
21
19
  var tableHeadItems = [
22
20
  { label: t("tableColumnHeaderId"), width: "5%" },
23
21
  { label: t("tableColumnHeaderQuoteInvoice"), width: "15%" },
@@ -33,7 +31,6 @@ var PaymentPage = function () {
33
31
  var totalPages = (0, util_functions_1.calculatePages)(count, pageLimit);
34
32
  return (react_1.default.createElement("div", { className: "space-y-4 ".concat(isRTL ? "rtl" : "ltr"), dir: isRTL ? "rtl" : "ltr" },
35
33
  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: "payment-search", searchPlaceholder: t("tableSearchPlaceholder"), searchValue: searchQuery, tableBodyCols: constants_1.tableBodyCols, tableBodyRows: payments, tableDescription: t("tableDescription"), tableHeadItems: tableHeadItems, tableHeading: t("tableTitle"), totalPages: Number(totalPages) }),
36
- react_1.default.createElement(drawer_1.Drawer, { isRTL: isRTL }),
37
34
  react_1.default.createElement(sonner_1.Toaster, null)));
38
35
  };
39
36
  exports.PaymentPage = PaymentPage;
@@ -1,85 +0,0 @@
1
- import { Dispatch } from "react";
2
- import { PaymentModeTypeBE } from "@appcorp/stellar-solutions-modules/global-modules/payment-mode/types";
3
- import { QuoteInvoiceTypeBE } from "../invoice/types";
4
- import { PaymentActions } from "./actions";
5
- import { HeaderAction, RowAction } from "@appcorp/shadcn/components/enhanced-table";
6
- export declare enum PAYMENT_TYPE {
7
- FULL_AMOUNT = "FULL_AMOUNT",
8
- PARTIAL_AMOUNT = "PARTIAL_AMOUNT"
9
- }
10
- export declare enum PAYMENT_DRAWER {
11
- PAYMENT_FILTER_DRAWER = "PAYMENT_FILTER_DRAWER",
12
- PAYMENT_FORM_DRAWER = "PAYMENT_FORM_DRAWER",
13
- PAYMENT_VIEW_DRAWER = "PAYMENT_VIEW_DRAWER"
14
- }
15
- export declare enum PAYMENT_MODAL {
16
- DUMMY = "DUMMY"
17
- }
18
- /**
19
- * Payment Backend Entity
20
- */
21
- export interface PaymentTypeBE {
22
- amount: string;
23
- attachment?: string;
24
- balance: string;
25
- createdAt: string;
26
- currency: string;
27
- date: string;
28
- description?: string;
29
- id: string;
30
- paymentMode?: PaymentModeTypeBE;
31
- paymentModeId: string;
32
- paymentType: PAYMENT_TYPE;
33
- quoteInvoice?: QuoteInvoiceTypeBE;
34
- quoteInvoiceId: string;
35
- ref?: string;
36
- updatedAt: string;
37
- }
38
- export type { PaymentModeTypeBE };
39
- export interface PaymentContextType {
40
- byIdError?: Error;
41
- byIdLoading: boolean;
42
- clearSearch: () => void;
43
- closeDrawer: () => void;
44
- deleteError?: Error;
45
- deleteLoading: boolean;
46
- dispatch: Dispatch<PaymentActions>;
47
- handleChange: (field: string, value: string | number | number[]) => void;
48
- handleNextClick: () => void;
49
- handlePageLimit: (node: string, value: object) => void;
50
- handlePreviousClick: () => void;
51
- handleSubmit: () => void;
52
- headerActions: HeaderAction[];
53
- listError?: Error;
54
- listFetchNow: () => void;
55
- listLoading: boolean;
56
- rowActions: RowAction[];
57
- searchOnChange: (k: string, v: string) => void;
58
- updateError?: Error;
59
- updateLoading: boolean;
60
- }
61
- export interface PaymentState extends Omit<PaymentTypeBE, "createdAt" | "updatedAt" | "paymentMode" | "quoteInvoice"> {
62
- count: number;
63
- currentPage: number;
64
- disableSaveButton: boolean;
65
- drawer: null | PAYMENT_DRAWER;
66
- errors: {
67
- [key: string]: string;
68
- };
69
- mode: "Create" | "Edit";
70
- pageLimit: number;
71
- paymentMode?: PaymentModeTypeBE;
72
- paymentModeQuery: string;
73
- paymentModes: PaymentModeTypeBE[];
74
- payments: PaymentTypeBE[];
75
- quoteInvoice?: QuoteInvoiceTypeBE;
76
- quoteInvoiceQuery: string;
77
- quoteInvoices: QuoteInvoiceTypeBE[];
78
- searchQuery: string;
79
- invoice: QuoteInvoiceTypeBE | null;
80
- }
81
- export interface FetchPaymentsArgs {
82
- currentPage: number;
83
- pageLimit: number;
84
- searchQuery?: string;
85
- }
@@ -1,21 +1,74 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PAYMENT_MODAL = exports.PAYMENT_DRAWER = exports.PAYMENT_TYPE = void 0;
4
- // ============================================================================
5
- // ENUMS
6
- // ============================================================================
7
- var PAYMENT_TYPE;
8
- (function (PAYMENT_TYPE) {
9
- PAYMENT_TYPE["FULL_AMOUNT"] = "FULL_AMOUNT";
10
- PAYMENT_TYPE["PARTIAL_AMOUNT"] = "PARTIAL_AMOUNT";
11
- })(PAYMENT_TYPE || (exports.PAYMENT_TYPE = PAYMENT_TYPE = {}));
12
- var PAYMENT_DRAWER;
13
- (function (PAYMENT_DRAWER) {
14
- PAYMENT_DRAWER["PAYMENT_FILTER_DRAWER"] = "PAYMENT_FILTER_DRAWER";
15
- PAYMENT_DRAWER["PAYMENT_FORM_DRAWER"] = "PAYMENT_FORM_DRAWER";
16
- PAYMENT_DRAWER["PAYMENT_VIEW_DRAWER"] = "PAYMENT_VIEW_DRAWER";
17
- })(PAYMENT_DRAWER || (exports.PAYMENT_DRAWER = PAYMENT_DRAWER = {}));
18
- var PAYMENT_MODAL;
19
- (function (PAYMENT_MODAL) {
20
- PAYMENT_MODAL["DUMMY"] = "DUMMY";
21
- })(PAYMENT_MODAL || (exports.PAYMENT_MODAL = PAYMENT_MODAL = {}));
1
+ // import { PaymentModeBE } from '@react-pakistan/util-functions/api/stellar-solutions/type';
2
+ // import { QuoteInvoiceTypeBE } from "@appcorp/stellar-solutions-modules/global-modules/quote-invoice/types";
3
+ // // import { PaymentModeTypeBE } from "@appcorp/stellar-solutions-modules/global-modules/payment-mode/types";
4
+ // // import { PaymentModeBE } from "@appcorp/stellar-solutions-modules/global-modules/payment-mode/types";
5
+ // // import { QuoteInvoiceTypeBE } from "../invoice/types";
6
+ // // ============================================================================
7
+ // // ENUMS
8
+ // // ============================================================================
9
+ // export enum PAYMENT_TYPE {
10
+ // FULL_AMOUNT = "FULL_AMOUNT",
11
+ // PARTIAL_AMOUNT = "PARTIAL_AMOUNT",
12
+ // }
13
+ // export enum PAYMENT_DRAWER {
14
+ // PAYMENT_FILTER_DRAWER = "PAYMENT_FILTER_DRAWER",
15
+ // PAYMENT_FORM_DRAWER = "PAYMENT_FORM_DRAWER",
16
+ // PAYMENT_VIEW_DRAWER = "PAYMENT_VIEW_DRAWER",
17
+ // }
18
+ // export enum PAYMENT_MODAL {
19
+ // DUMMY = "DUMMY",
20
+ // }
21
+ // // ============================================================================
22
+ // // ENTITY TYPES (Backend Data Structures)
23
+ // // ============================================================================
24
+ // /**
25
+ // * Payment Backend Entity
26
+ // */
27
+ // export interface PaymentTypeBE {
28
+ // amount: string;
29
+ // attachment?: string;
30
+ // balance: string;
31
+ // createdAt: string;
32
+ // currency: string;
33
+ // date: string;
34
+ // description?: string;
35
+ // id: string;
36
+ // paymentMode?: PaymentModeTypeBE;
37
+ // paymentModeId: string;
38
+ // paymentType: PAYMENT_TYPE;
39
+ // quoteInvoice?: QuoteInvoiceTypeBE;
40
+ // quoteInvoiceId: string;
41
+ // ref?: string;
42
+ // updatedAt: string;
43
+ // }
44
+ // // Re-export PaymentModeTypeBE for convenience
45
+ // export type { PaymentModeTypeBE };
46
+ // // ============================================================================
47
+ // // STATE TYPES (Frontend Component State)
48
+ // // ============================================================================
49
+ // export interface PaymentState extends Omit<
50
+ // PaymentTypeBE,
51
+ // "createdAt" | "updatedAt" | "paymentMode" | "quoteInvoice"
52
+ // > {
53
+ // count: number;
54
+ // currentPage: number;
55
+ // disableSaveButton: boolean;
56
+ // drawer: null | PAYMENT_DRAWER;
57
+ // errors: { [key: string]: string };
58
+ // mode: "Create" | "Edit";
59
+ // pageLimit: number;
60
+ // paymentMode?: PaymentModeTypeBE;
61
+ // paymentModeQuery: string;
62
+ // paymentModes: PaymentModeTypeBE[];
63
+ // payments: PaymentTypeBE[];
64
+ // quoteInvoice?: QuoteInvoiceTypeBE;
65
+ // quoteInvoiceQuery: string;
66
+ // quoteInvoices: QuoteInvoiceTypeBE[];
67
+ // searchQuery: string;
68
+ // invoice: QuoteInvoiceTypeBE | null;
69
+ // }
70
+ // export interface FetchPaymentsArgs {
71
+ // currentPage: number;
72
+ // pageLimit: number;
73
+ // searchQuery?: string;
74
+ // }
@@ -1,4 +1,16 @@
1
1
  import { z } from "zod";
2
+ export declare const VALIDATION_KEYS: {
3
+ amount: string;
4
+ attachment: string;
5
+ balance: string;
6
+ currency: string;
7
+ date: string;
8
+ description: string;
9
+ paymentMode: string;
10
+ paymentType: string;
11
+ quoteInvoice: string;
12
+ ref: string;
13
+ };
2
14
  /**
3
15
  * Validation schema for payment form
4
16
  */
@@ -1,8 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formValidation = void 0;
3
+ exports.formValidation = exports.VALIDATION_KEYS = void 0;
4
4
  var zod_1 = require("zod");
5
- var constants_1 = require("./constants");
5
+ exports.VALIDATION_KEYS = {
6
+ amount: "validationAmountRequired",
7
+ attachment: "validationAttachmentInvalid",
8
+ balance: "validationBalanceInvalid",
9
+ currency: "validationCurrencyRequired",
10
+ date: "validationDateRequired",
11
+ description: "validationDescriptionInvalid",
12
+ paymentMode: "validationPaymentModeRequired",
13
+ paymentType: "validationPaymentTypeRequired",
14
+ quoteInvoice: "validationQuoteInvoiceRequired",
15
+ ref: "validationRefInvalid",
16
+ };
6
17
  // ============================================================================
7
18
  // FORM VALIDATION SCHEMA
8
19
  // ============================================================================
@@ -10,14 +21,14 @@ var constants_1 = require("./constants");
10
21
  * Validation schema for payment form
11
22
  */
12
23
  exports.formValidation = zod_1.z.object({
13
- amount: zod_1.z.string().nonempty(constants_1.VALIDATION_KEYS.amount),
24
+ amount: zod_1.z.string().nonempty(exports.VALIDATION_KEYS.amount),
14
25
  attachment: zod_1.z.string().optional(),
15
26
  balance: zod_1.z.string().optional(),
16
- currency: zod_1.z.string().nonempty(constants_1.VALIDATION_KEYS.currency),
17
- date: zod_1.z.string().nonempty(constants_1.VALIDATION_KEYS.date),
27
+ currency: zod_1.z.string().nonempty(exports.VALIDATION_KEYS.currency),
28
+ date: zod_1.z.string().nonempty(exports.VALIDATION_KEYS.date),
18
29
  description: zod_1.z.string().optional(),
19
- paymentModeId: zod_1.z.string().nonempty(constants_1.VALIDATION_KEYS.paymentMode),
20
- paymentType: zod_1.z.string().nonempty(constants_1.VALIDATION_KEYS.paymentType),
21
- quoteInvoiceId: zod_1.z.string().nonempty(constants_1.VALIDATION_KEYS.quoteInvoice),
30
+ paymentModeId: zod_1.z.string().nonempty(exports.VALIDATION_KEYS.paymentMode),
31
+ paymentType: zod_1.z.string().nonempty(exports.VALIDATION_KEYS.paymentType),
32
+ quoteInvoiceId: zod_1.z.string().nonempty(exports.VALIDATION_KEYS.quoteInvoice),
22
33
  ref: zod_1.z.string().optional(),
23
34
  });
@@ -1,6 +1,2 @@
1
1
  import { FC } from "react";
2
- interface Props {
3
- isRTL: boolean;
4
- }
5
- export declare const PaymentView: FC<Props>;
6
- export {};
2
+ export declare const PaymentView: FC;
@@ -9,15 +9,16 @@ var context_1 = require("./context");
9
9
  var card_1 = require("@appcorp/shadcn/components/ui/card");
10
10
  var separator_1 = require("@appcorp/shadcn/components/ui/separator");
11
11
  var badge_1 = require("@appcorp/shadcn/components/ui/badge");
12
+ var util_functions_1 = require("@react-pakistan/util-functions");
12
13
  var Row = function (_a) {
13
14
  var label = _a.label, value = _a.value;
14
15
  return (react_1.default.createElement("div", { className: "flex w-full items-start justify-between py-2" },
15
16
  react_1.default.createElement("div", { className: "text-sm text-muted-foreground" }, label),
16
17
  react_1.default.createElement("div", { className: "text-sm text-foreground ml-4" }, value !== null && value !== void 0 ? value : "—")));
17
18
  };
18
- var PaymentView = function (_a) {
19
- var isRTL = _a.isRTL;
20
- var _b = (0, context_1.usePaymentStateContext)(), amount = _b.amount, attachment = _b.attachment, balance = _b.balance, currency = _b.currency, date = _b.date, description = _b.description, id = _b.id, paymentMode = _b.paymentMode, paymentType = _b.paymentType, quoteInvoice = _b.quoteInvoice, ref = _b.ref;
19
+ var PaymentView = function () {
20
+ var isRTL = (0, util_functions_1.useRTL)();
21
+ var _a = (0, context_1.usePaymentModule)(), amount = _a.amount, attachment = _a.attachment, balance = _a.balance, currency = _a.currency, date = _a.date, description = _a.description, id = _a.id, paymentMode = _a.paymentMode, paymentType = _a.paymentType, quoteInvoice = _a.quoteInvoice, ref = _a.ref;
21
22
  return (react_1.default.createElement(card_1.Card, { className: "w-full" },
22
23
  react_1.default.createElement(card_1.CardHeader, { className: "flex ".concat(isRTL ? "flex-row-reverse" : "flex-row", " items-center justify-between") },
23
24
  react_1.default.createElement(card_1.CardTitle, null, "Payment"),
@@ -17,7 +17,7 @@ var button_1 = require("@appcorp/shadcn/components/ui/button");
17
17
  var context_1 = require("./context");
18
18
  var AddServiceProductSection = function () {
19
19
  var t = (0, next_intl_1.useTranslations)("quote");
20
- var _a = (0, context_1.useQuoteStateContext)(), handleAddItemProduct = _a.handleAddItemProduct, handleAddItemService = _a.handleAddItemService;
20
+ var _a = (0, context_1.useQuoteModule)(), handleAddItemProduct = _a.handleAddItemProduct, handleAddItemService = _a.handleAddItemService;
21
21
  return (react_1.default.createElement("div", { className: "flex items-center justify-center gap-3 rounded-lg border-2 border-dashed border-muted-foreground/25 p-6 hover:border-muted-foreground/50 transition-colors" },
22
22
  react_1.default.createElement("span", { className: "text-sm text-muted-foreground" }, t("addItem")),
23
23
  react_1.default.createElement(button_1.Button, { onClick: handleAddItemService, size: "sm", type: "button", variant: "outline" },
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Quote Cache
3
+ *
4
+ * Client-side caching utilities for quote data.
5
+ * Uses localStorage-backed cache to reduce redundant API calls.
6
+ */
7
+ import { QuoteInvoiceBE, type ListResponse } from "@react-pakistan/util-functions";
8
+ export declare const getCachedQuotesSync: () => ListResponse<QuoteInvoiceBE> | null;
9
+ export declare const getCachedQuotes: ({ params, }?: {
10
+ params?: Record<string, unknown>;
11
+ }) => Promise<ListResponse<QuoteInvoiceBE>>;
12
+ export declare const getCachedQuoteById: (quoteId: string) => QuoteInvoiceBE | null;
13
+ export declare const invalidateQuotesCache: () => void;
14
+ export declare const preloadQuotes: () => Promise<ListResponse<QuoteInvoiceBE>>;
15
+ export declare const isQuotesCacheStale: () => boolean;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /**
3
+ * Quote Cache
4
+ *
5
+ * Client-side caching utilities for quote data.
6
+ * Uses localStorage-backed cache to reduce redundant API calls.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.isQuotesCacheStale = exports.preloadQuotes = exports.invalidateQuotesCache = exports.getCachedQuoteById = exports.getCachedQuotes = exports.getCachedQuotesSync = void 0;
10
+ var util_functions_1 = require("@react-pakistan/util-functions");
11
+ var constants_1 = require("./constants");
12
+ // ============================================================================
13
+ // CACHE CONFIG
14
+ // ============================================================================
15
+ var QUOTES_CACHE_KEY = "stellar_quotes_cache";
16
+ var QUOTE_CACHE_CONFIG = {
17
+ apiUrl: constants_1.QUOTE_API_ROUTES.QUOTE,
18
+ cacheKey: QUOTES_CACHE_KEY,
19
+ };
20
+ // ============================================================================
21
+ // CACHE UTILITIES
22
+ // ============================================================================
23
+ var getCachedQuotesSync = function () {
24
+ return (0, util_functions_1.getCachedDataSync)(QUOTES_CACHE_KEY);
25
+ };
26
+ exports.getCachedQuotesSync = getCachedQuotesSync;
27
+ var getCachedQuotes = function (_a) {
28
+ var _b = _a === void 0 ? {} : _a, params = _b.params;
29
+ return (0, util_functions_1.getCachedData)({
30
+ config: QUOTE_CACHE_CONFIG,
31
+ params: params,
32
+ headers: {
33
+ "Content-Type": "application/json",
34
+ "x-api-token": process.env.NEXT_PUBLIC_API_KEY,
35
+ },
36
+ });
37
+ };
38
+ exports.getCachedQuotes = getCachedQuotes;
39
+ var getCachedQuoteById = function (quoteId) {
40
+ return (0, util_functions_1.getCachedItemById)(QUOTES_CACHE_KEY, quoteId);
41
+ };
42
+ exports.getCachedQuoteById = getCachedQuoteById;
43
+ var invalidateQuotesCache = function () { return (0, util_functions_1.invalidateCache)(QUOTES_CACHE_KEY); };
44
+ exports.invalidateQuotesCache = invalidateQuotesCache;
45
+ var preloadQuotes = function () {
46
+ return (0, util_functions_1.preloadCache)(QUOTE_CACHE_CONFIG);
47
+ };
48
+ exports.preloadQuotes = preloadQuotes;
49
+ var isQuotesCacheStale = function () { return (0, util_functions_1.isCacheStale)(QUOTES_CACHE_KEY); };
50
+ exports.isQuotesCacheStale = isQuotesCacheStale;
@@ -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 CompanySection: FC<Props>;
12
12
  export {};
@@ -47,41 +47,42 @@ var enhanced_combobox_1 = require("@appcorp/shadcn/components/enhanced-combobox"
47
47
  var enhanced_input_1 = require("@appcorp/shadcn/components/enhanced-input");
48
48
  var enhanced_textarea_1 = require("@appcorp/shadcn/components/enhanced-textarea");
49
49
  var context_1 = require("@appcorp/stellar-solutions-modules/global-modules/preferences/context");
50
- var actions_1 = require("./actions");
51
50
  var context_2 = require("./context");
52
51
  var CompanySection = function () {
53
52
  var t = (0, next_intl_1.useTranslations)("quote");
54
53
  var currencies = (0, context_1.usePreferenceStateContext)().currencies;
55
- var _a = (0, context_2.useQuoteStateContext)(), companiesList = _a.companiesList, companyId = _a.companyId, currency = _a.currency, date = _a.date, dispatch = _a.dispatch, errors = _a.errors, expiryDate = _a.expiryDate, note = _a.note, ref = _a.ref;
54
+ var _a = (0, context_2.useQuoteModule)(), companiesList = _a.companiesList, companyId = _a.companyId, currency = _a.currency, date = _a.date, dispatch = _a.dispatch, errors = _a.errors, expiryDate = _a.expiryDate, note = _a.note, ref = _a.ref;
56
55
  var handleInputChange = (0, react_1.useCallback)(function (key, value) {
57
56
  dispatch({
58
- type: actions_1.QUOTE_ACTION_TYPES.SET_INPUT_FIELD,
57
+ type: context_2.QUOTE_ACTION_TYPES.SET_INPUT_FIELD,
59
58
  payload: { key: key, value: value },
60
59
  });
61
60
  dispatch({
62
- type: actions_1.QUOTE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
61
+ type: context_2.QUOTE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
63
62
  payload: { disableSaveButton: false },
64
63
  });
65
64
  dispatch({
66
- type: actions_1.QUOTE_ACTION_TYPES.RESET_ERRORS,
65
+ type: context_2.QUOTE_ACTION_TYPES.SET_ERRORS,
66
+ payload: { errors: {} },
67
67
  });
68
68
  }, [dispatch]);
69
69
  var handleCompanyChange = function (selectedCompanyId) {
70
70
  dispatch({
71
- type: actions_1.QUOTE_ACTION_TYPES.SET_INPUT_FIELD,
71
+ type: context_2.QUOTE_ACTION_TYPES.SET_INPUT_FIELD,
72
72
  payload: { key: "companyId", value: selectedCompanyId },
73
73
  });
74
74
  dispatch({
75
- type: actions_1.QUOTE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
75
+ type: context_2.QUOTE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
76
76
  payload: { disableSaveButton: false },
77
77
  });
78
78
  dispatch({
79
- type: actions_1.QUOTE_ACTION_TYPES.RESET_ERRORS,
79
+ type: context_2.QUOTE_ACTION_TYPES.SET_ERRORS,
80
+ payload: { errors: {} },
80
81
  });
81
82
  };
82
83
  var handleCompanySearch = function (searchQuery) {
83
84
  dispatch({
84
- type: actions_1.QUOTE_ACTION_TYPES.SET_INPUT_FIELD,
85
+ type: context_2.QUOTE_ACTION_TYPES.SET_INPUT_FIELD,
85
86
  payload: {
86
87
  key: "companyQuery",
87
88
  value: searchQuery,
@@ -90,15 +91,16 @@ var CompanySection = function () {
90
91
  };
91
92
  var handleCurrencyChange = function (currencyCode) {
92
93
  dispatch({
93
- type: actions_1.QUOTE_ACTION_TYPES.SET_INPUT_FIELD,
94
+ type: context_2.QUOTE_ACTION_TYPES.SET_INPUT_FIELD,
94
95
  payload: { key: "currency", value: currencyCode },
95
96
  });
96
97
  dispatch({
97
- type: actions_1.QUOTE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
98
+ type: context_2.QUOTE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
98
99
  payload: { disableSaveButton: false },
99
100
  });
100
101
  dispatch({
101
- type: actions_1.QUOTE_ACTION_TYPES.RESET_ERRORS,
102
+ type: context_2.QUOTE_ACTION_TYPES.SET_ERRORS,
103
+ payload: { errors: {} },
102
104
  });
103
105
  };
104
106
  // Map currencies to have consistent structure for CompanyCombobox
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validationErrors = exports.tableBodyCols = exports.QUOTE_API_ROUTES = exports.changeActionsMap = exports.handleSplitId = exports.pageLimit = void 0;
4
4
  var util_functions_1 = require("@react-pakistan/util-functions");
5
5
  var enhanced_table_1 = require("@appcorp/shadcn/components/enhanced-table");
6
+ // import { QuoteInvoiceTypeBE } from "../invoice/types";
6
7
  exports.pageLimit = Number(process.env.NEXT_PUBLIC_PAGE_LIMIT);
7
8
  var handleSplitId = function (value) {
8
9
  return value === null || value === void 0 ? void 0 : value.split(util_functions_1.VALUE_DELIMITER.COLON);