@appcorp/stellar-solutions-modules 0.1.34 → 0.1.35
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.
- package/README.md +128 -19
- package/components/theme-switcher.d.ts +4 -0
- package/components/theme-switcher.js +60 -0
- package/components/ui/badge.d.ts +9 -0
- package/components/ui/badge.js +82 -0
- package/components/ui/button.d.ts +10 -0
- package/components/ui/button.js +91 -0
- package/components/ui/checkbox.d.ts +9 -0
- package/components/ui/checkbox.js +87 -0
- package/components/ui/drawer.d.ts +13 -0
- package/components/ui/drawer.js +115 -0
- package/components/ui/dropdown-menu.d.ts +25 -0
- package/components/ui/dropdown-menu.js +148 -0
- package/components/ui/enhanced-table-footer-action.d.ts +34 -0
- package/components/ui/enhanced-table-footer-action.js +117 -0
- package/components/ui/enhanced-table-footer-page.d.ts +32 -0
- package/components/ui/enhanced-table-footer-page.js +140 -0
- package/components/ui/enhanced-table-footer-pagination.d.ts +38 -0
- package/components/ui/enhanced-table-footer-pagination.js +122 -0
- package/components/ui/enhanced-table-header-action.d.ts +7 -0
- package/components/ui/enhanced-table-header-action.js +21 -0
- package/components/ui/enhanced-table-header-search.d.ts +12 -0
- package/components/ui/enhanced-table-header-search.js +17 -0
- package/components/ui/enhanced-table.d.ts +65 -0
- package/components/ui/enhanced-table.js +87 -0
- package/components/ui/input.d.ts +8 -0
- package/components/ui/input.js +86 -0
- package/components/ui/label.d.ts +7 -0
- package/components/ui/label.js +68 -0
- package/components/ui/popover.d.ts +7 -0
- package/components/ui/popover.js +82 -0
- package/components/ui/select.d.ts +15 -0
- package/components/ui/select.js +127 -0
- package/components/ui/sonner.d.ts +4 -0
- package/components/ui/sonner.js +54 -0
- package/components/ui/switch.d.ts +9 -0
- package/components/ui/switch.js +89 -0
- package/components/ui/table.d.ts +10 -0
- package/components/ui/table.js +101 -0
- package/global-modules/bank/actions.d.ts +200 -0
- package/global-modules/bank/actions.js +124 -0
- package/global-modules/bank/bank.d.ts +2 -0
- package/global-modules/bank/bank.js +87 -0
- package/global-modules/bank/constants.d.ts +45 -0
- package/global-modules/bank/constants.js +98 -0
- package/global-modules/bank/context.d.ts +41 -0
- package/global-modules/bank/context.js +419 -0
- package/global-modules/bank/drawer.d.ts +31 -0
- package/global-modules/bank/drawer.js +114 -0
- package/global-modules/bank/form.d.ts +22 -0
- package/global-modules/bank/form.js +68 -0
- package/global-modules/bank/reducer.d.ts +25 -0
- package/global-modules/bank/reducer.js +161 -0
- package/global-modules/bank/types.d.ts +217 -0
- package/global-modules/bank/types.js +81 -0
- package/global-modules/bank/validate.d.ts +13 -0
- package/global-modules/bank/validate.js +22 -0
- package/global-modules/branch/actions.d.ts +154 -37
- package/global-modules/branch/actions.js +148 -6
- package/global-modules/branch/branch.d.ts +2 -2
- package/global-modules/branch/branch.js +46 -32
- package/global-modules/branch/constants.d.ts +34 -24
- package/global-modules/branch/constants.js +101 -122
- package/global-modules/branch/context.d.ts +33 -2
- package/global-modules/branch/context.js +195 -164
- package/global-modules/branch/drawer.d.ts +26 -3
- package/global-modules/branch/drawer.js +101 -6
- package/global-modules/branch/form.d.ts +15 -1
- package/global-modules/branch/form.js +54 -71
- package/global-modules/branch/reducer.d.ts +23 -2
- package/global-modules/branch/reducer.js +148 -118
- package/global-modules/branch/types.d.ts +196 -69
- package/global-modules/branch/types.js +66 -7
- package/global-modules/branch/validate.d.ts +1 -1
- package/global-modules/branch/validate.js +15 -11
- package/global-modules/payment-mode/actions.d.ts +154 -37
- package/global-modules/payment-mode/actions.js +148 -6
- package/global-modules/payment-mode/constants.d.ts +34 -17
- package/global-modules/payment-mode/constants.js +90 -66
- package/global-modules/payment-mode/context.d.ts +33 -2
- package/global-modules/payment-mode/context.js +185 -163
- package/global-modules/payment-mode/drawer.d.ts +26 -3
- package/global-modules/payment-mode/drawer.js +104 -9
- package/global-modules/payment-mode/form.d.ts +16 -2
- package/global-modules/payment-mode/form.js +45 -74
- package/global-modules/payment-mode/payment-mode.d.ts +25 -2
- package/global-modules/payment-mode/payment-mode.js +90 -23
- package/global-modules/payment-mode/reducer.d.ts +23 -2
- package/global-modules/payment-mode/reducer.js +140 -114
- package/global-modules/payment-mode/types.d.ts +327 -112
- package/global-modules/payment-mode/types.js +162 -11
- package/global-modules/payment-mode/validate.d.ts +1 -1
- package/global-modules/payment-mode/validate.js +7 -5
- package/global-modules/preferences/actions.d.ts +126 -27
- package/global-modules/preferences/actions.js +128 -4
- package/global-modules/preferences/constants.d.ts +46 -31
- package/global-modules/preferences/constants.js +129 -66
- package/global-modules/preferences/context.d.ts +2 -2
- package/global-modules/preferences/context.js +43 -43
- package/global-modules/preferences/currency.js +15 -10
- package/global-modules/preferences/preferences.d.ts +2 -2
- package/global-modules/preferences/preferences.js +3 -5
- package/global-modules/preferences/validate.d.ts +1 -1
- package/global-modules/preferences/validate.js +7 -7
- package/global-modules/tax/actions.d.ts +155 -38
- package/global-modules/tax/actions.js +149 -7
- package/global-modules/tax/constants.d.ts +31 -39
- package/global-modules/tax/constants.js +83 -114
- package/global-modules/tax/context.d.ts +33 -2
- package/global-modules/tax/context.js +146 -132
- package/global-modules/tax/drawer.d.ts +26 -3
- package/global-modules/tax/drawer.js +101 -6
- package/global-modules/tax/form.d.ts +20 -3
- package/global-modules/tax/form.js +101 -74
- package/global-modules/tax/reducer.d.ts +23 -2
- package/global-modules/tax/reducer.js +143 -24
- package/global-modules/tax/tax.d.ts +25 -2
- package/global-modules/tax/tax.js +92 -28
- package/global-modules/tax/types.d.ts +332 -102
- package/global-modules/tax/types.js +179 -11
- package/global-modules/tax/validate.d.ts +1 -1
- package/global-modules/tax/validate.js +9 -8
- package/hooks/use-rtl.d.ts +44 -0
- package/hooks/use-rtl.js +75 -0
- package/lib/themes.d.ts +147 -0
- package/lib/themes.js +150 -0
- package/lib/toast-utils.d.ts +44 -0
- package/lib/toast-utils.js +212 -0
- package/lib/utils.d.ts +2 -0
- package/lib/utils.js +12 -0
- package/package.json +21 -4
- package/supabase/supabase.d.ts +80 -1
- package/supabase/supabase.js +281 -6
- package/global-modules/branch/form-elements.d.ts +0 -3
- package/global-modules/branch/form-elements.js +0 -41
- package/global-modules/payment-mode/form-elements.d.ts +0 -3
- package/global-modules/payment-mode/form-elements.js +0 -41
- package/global-modules/preferences/bank.d.ts +0 -2
- package/global-modules/preferences/bank.js +0 -11
- package/global-modules/preferences/branch-drawer.js +0 -36
- package/global-modules/preferences/branch-form-elements.js +0 -30
- package/global-modules/preferences/branch-form.d.ts +0 -0
- package/global-modules/preferences/branch-form.js +0 -33
- package/global-modules/preferences/branch.d.ts +0 -0
- package/global-modules/preferences/branch.js +0 -106
- package/global-modules/preferences/payment-mode-drawer.d.ts +0 -0
- package/global-modules/preferences/payment-mode-drawer.js +0 -36
- package/global-modules/preferences/payment-mode-form-elements.d.ts +0 -0
- package/global-modules/preferences/payment-mode-form-elements.js +0 -30
- package/global-modules/preferences/payment-mode-form.d.ts +0 -0
- package/global-modules/preferences/payment-mode-form.js +0 -33
- package/global-modules/preferences/payment-mode.d.ts +0 -0
- package/global-modules/preferences/payment-mode.js +0 -94
- package/global-modules/tax/form-elements.d.ts +0 -3
- package/global-modules/tax/form-elements.js +0 -41
- /package/{global-modules/preferences/branch-drawer.d.ts → constants.d.ts} +0 -0
- /package/{global-modules/preferences/branch-form-elements.d.ts → constants.js} +0 -0
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Payment Mode Form Component
|
|
3
|
+
*
|
|
4
|
+
* Enhanced form component for payment mode management with comprehensive error handling
|
|
5
|
+
* and modern UI components.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Modern shadcn/ui form components
|
|
9
|
+
* - Translation support for validation messages
|
|
10
|
+
* - RTL/LTR layout compatibility
|
|
11
|
+
* - Accessibility-compliant form structure
|
|
12
|
+
* - Real-time validation feedback
|
|
13
|
+
*/
|
|
14
|
+
import { FC } from "react";
|
|
2
15
|
interface Props {
|
|
16
|
+
isRTL: boolean;
|
|
3
17
|
translationMap: {
|
|
4
18
|
[key: string]: string;
|
|
5
19
|
};
|
|
6
20
|
}
|
|
7
|
-
export declare const
|
|
21
|
+
export declare const PaymentModeForm: FC<Props>;
|
|
8
22
|
export {};
|
|
@@ -1,80 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Payment Mode Form Component
|
|
4
|
+
*
|
|
5
|
+
* Enhanced form component for payment mode management with comprehensive error handling
|
|
6
|
+
* and modern UI components.
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Modern shadcn/ui form components
|
|
10
|
+
* - Translation support for validation messages
|
|
11
|
+
* - RTL/LTR layout compatibility
|
|
12
|
+
* - Accessibility-compliant form structure
|
|
13
|
+
* - Real-time validation feedback
|
|
14
|
+
*/
|
|
15
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
17
|
};
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
-
var ownKeys = function(o) {
|
|
31
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
-
var ar = [];
|
|
33
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
-
return ar;
|
|
35
|
-
};
|
|
36
|
-
return ownKeys(o);
|
|
37
|
-
};
|
|
38
|
-
return function (mod) {
|
|
39
|
-
if (mod && mod.__esModule) return mod;
|
|
40
|
-
var result = {};
|
|
41
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
-
__setModuleDefault(result, mod);
|
|
43
|
-
return result;
|
|
44
|
-
};
|
|
45
|
-
})();
|
|
46
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
-
exports.
|
|
48
|
-
var react_1 =
|
|
49
|
-
var
|
|
19
|
+
exports.PaymentModeForm = void 0;
|
|
20
|
+
var react_1 = __importDefault(require("react"));
|
|
21
|
+
var next_intl_1 = require("next-intl");
|
|
22
|
+
var input_1 = require("@/components/ui/input");
|
|
23
|
+
var switch_1 = require("@/components/ui/switch");
|
|
50
24
|
var context_1 = require("./context");
|
|
51
|
-
var
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
-
var
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return label;
|
|
64
|
-
textInputElements[i].label = translationMap[label];
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
var textAreaElements = (_b = elements[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_AREA_V1]) === null || _b === void 0 ? void 0 : _b.sort(function (a, b) { return a.order - b.order; });
|
|
68
|
-
if (textAreaElements) {
|
|
69
|
-
textAreaElements === null || textAreaElements === void 0 ? void 0 : textAreaElements.forEach(function (_a, i) {
|
|
70
|
-
var label = _a.label;
|
|
71
|
-
if (translationMap[label] === undefined)
|
|
72
|
-
return label;
|
|
73
|
-
textAreaElements[i].label = translationMap[label];
|
|
74
|
-
});
|
|
25
|
+
var PaymentModeForm = function (_a) {
|
|
26
|
+
var isRTL = _a.isRTL, translationMap = _a.translationMap;
|
|
27
|
+
var t = (0, next_intl_1.useTranslations)("paymentModePage");
|
|
28
|
+
var ui = (0, next_intl_1.useTranslations)("ui");
|
|
29
|
+
var _b = (0, context_1.usePaymentModeStateContext)(), enabled = _b.enabled, errors = _b.errors, handleInputChange = _b.handleInputChange, isDefault = _b.isDefault, label = _b.label;
|
|
30
|
+
// Helper function to translate validation error keys
|
|
31
|
+
var getTranslatedError = function (key) {
|
|
32
|
+
if (!errors[key])
|
|
33
|
+
return undefined;
|
|
34
|
+
// If error starts with "validation.", it's a key to translate
|
|
35
|
+
if (errors[key].startsWith("validation.")) {
|
|
36
|
+
return t(errors[key]);
|
|
75
37
|
}
|
|
76
|
-
return
|
|
77
|
-
|
|
78
|
-
|
|
38
|
+
// Otherwise return as is (already translated)
|
|
39
|
+
return errors[key];
|
|
40
|
+
};
|
|
41
|
+
return (react_1.default.createElement("div", { className: "space-y-6 ".concat(isRTL ? "rtl" : "ltr"), dir: isRTL ? "rtl" : "ltr" },
|
|
42
|
+
react_1.default.createElement("div", { className: "space-y-4" },
|
|
43
|
+
react_1.default.createElement("div", { className: "space-y-2" },
|
|
44
|
+
react_1.default.createElement(input_1.Input, { id: "label", type: "text", label: (translationMap === null || translationMap === void 0 ? void 0 : translationMap.formLabelLabel) || "Payment Mode Name", value: label || "", onChange: function (e) { return handleInputChange("label", e.target.value); }, placeholder: "Enter payment mode name", info: "Enter a descriptive name for this payment method", error: getTranslatedError("label"), required: true })),
|
|
45
|
+
react_1.default.createElement("div", { className: "space-y-4" },
|
|
46
|
+
react_1.default.createElement(switch_1.Switch, { id: "enabled", label: (translationMap === null || translationMap === void 0 ? void 0 : translationMap.enabled) || "Enabled", checked: enabled || false, onCheckedChange: function (checked) { return handleInputChange("enabled", checked); }, info: enabled ? ui("switch.infoEnabled") : ui("switch.infoDisabled"), error: getTranslatedError("enabled") }),
|
|
47
|
+
react_1.default.createElement(switch_1.Switch, { id: "isDefault", label: (translationMap === null || translationMap === void 0 ? void 0 : translationMap.setAsDefault) || "Set as Default", checked: isDefault || false, onCheckedChange: function (checked) {
|
|
48
|
+
return handleInputChange("isDefault", checked);
|
|
49
|
+
}, info: isDefault ? ui("switch.infoEnabled") : ui("switch.infoDisabled"), error: getTranslatedError("isDefault") })))));
|
|
79
50
|
};
|
|
80
|
-
exports.
|
|
51
|
+
exports.PaymentModeForm = PaymentModeForm;
|
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
params?: Promise<{
|
|
4
|
+
locale: "en" | "ur";
|
|
5
|
+
}>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Payment Mode Page Component
|
|
9
|
+
*
|
|
10
|
+
* Main component for the Payment Mode management feature.
|
|
11
|
+
* Provides a comprehensive interface for managing payment methods with advanced features.
|
|
12
|
+
*
|
|
13
|
+
* Features:
|
|
14
|
+
* - Payment mode listing with search and pagination
|
|
15
|
+
* - CRUD operations (Create, Read, Update, Delete)
|
|
16
|
+
* - Advanced table with sorting and filtering
|
|
17
|
+
* - Responsive design with RTL support
|
|
18
|
+
* - Internationalization support
|
|
19
|
+
* - Theme switching capability
|
|
20
|
+
* - Toast notifications for user feedback
|
|
21
|
+
*
|
|
22
|
+
* @param params - Route parameters containing locale information
|
|
23
|
+
*/
|
|
24
|
+
export declare const PaymentMode: FC<Props>;
|
|
25
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
"use strict";
|
|
2
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -5,49 +6,115 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
7
|
exports.PaymentMode = void 0;
|
|
7
8
|
var react_1 = __importDefault(require("react"));
|
|
8
|
-
var vista_table_v1_1 = require("@appcorp/app-corp-vista/organisms/vista-table-v1/vista-table-v1");
|
|
9
|
-
var drawer_1 = require("./drawer");
|
|
10
|
-
var generate_toast_1 = require("@appcorp/app-corp-vista/utils/generate-toast");
|
|
11
9
|
var next_intl_1 = require("next-intl");
|
|
12
|
-
var context_1 = require("./context");
|
|
13
10
|
var util_functions_1 = require("@react-pakistan/util-functions");
|
|
11
|
+
var use_rtl_1 = require("@/hooks/use-rtl");
|
|
12
|
+
var enhanced_table_1 = require("@/components/ui/enhanced-table");
|
|
13
|
+
var sonner_1 = require("@/components/ui/sonner");
|
|
14
|
+
var theme_switcher_1 = require("@/components/theme-switcher");
|
|
14
15
|
var constants_1 = require("./constants");
|
|
16
|
+
var context_1 = require("./context");
|
|
17
|
+
var drawer_1 = require("./drawer");
|
|
18
|
+
/**
|
|
19
|
+
* Payment Mode Page Component
|
|
20
|
+
*
|
|
21
|
+
* Main component for the Payment Mode management feature.
|
|
22
|
+
* Provides a comprehensive interface for managing payment methods with advanced features.
|
|
23
|
+
*
|
|
24
|
+
* Features:
|
|
25
|
+
* - Payment mode listing with search and pagination
|
|
26
|
+
* - CRUD operations (Create, Read, Update, Delete)
|
|
27
|
+
* - Advanced table with sorting and filtering
|
|
28
|
+
* - Responsive design with RTL support
|
|
29
|
+
* - Internationalization support
|
|
30
|
+
* - Theme switching capability
|
|
31
|
+
* - Toast notifications for user feedback
|
|
32
|
+
*
|
|
33
|
+
* @param params - Route parameters containing locale information
|
|
34
|
+
*/
|
|
15
35
|
var PaymentMode = function () {
|
|
16
|
-
var _a = (0, context_1.usePaymentModeStateContext)(),
|
|
17
|
-
var t = (0, next_intl_1.useTranslations)(
|
|
36
|
+
var _a = (0, context_1.usePaymentModeStateContext)(), count = _a.count, currentPage = _a.currentPage, handleNextClick = _a.handleNextClick, handlePageLimit = _a.handlePageLimit, handlePreviousClick = _a.handlePreviousClick, headerActions = _a.headerActions, listLoading = _a.listLoading, pageLimit = _a.pageLimit, paymentModes = _a.paymentModes, rowActions = _a.rowActions, searchOnChange = _a.searchOnChange, searchQuery = _a.searchQuery;
|
|
37
|
+
var t = (0, next_intl_1.useTranslations)("paymentModePage");
|
|
38
|
+
var isRTL = (0, use_rtl_1.useRTL)();
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// TRANSLATION MAPPING
|
|
41
|
+
// ============================================================================
|
|
18
42
|
var translationMap = {
|
|
19
|
-
|
|
43
|
+
// Form Labels
|
|
44
|
+
formLabelLabel: t("formLabelLabel"),
|
|
45
|
+
// Drawer
|
|
46
|
+
drawerTitlePaymentMode: t("headingFormEdit"),
|
|
47
|
+
headingFormCreate: t("headingFormCreate"),
|
|
48
|
+
srCloseDrawer: t("srCloseDrawer"),
|
|
49
|
+
cancelBtn: t("cancelBtn"),
|
|
50
|
+
saveBtn: t("saveBtn"),
|
|
51
|
+
// Actions
|
|
52
|
+
addItem: t("addItem"),
|
|
53
|
+
edit: t("edit"),
|
|
54
|
+
delete: t("delete"),
|
|
55
|
+
// Form Settings
|
|
56
|
+
settings: t("settings"),
|
|
57
|
+
enabled: t("enabled"),
|
|
58
|
+
isDefault: t("isDefault"),
|
|
59
|
+
setAsDefault: t("setAsDefault"),
|
|
60
|
+
enableDescription: t("enableDescription"),
|
|
61
|
+
defaultDescription: t("defaultDescription"),
|
|
62
|
+
// Messages
|
|
63
|
+
messagePaymentModeCreated: t("messages.paymentModeCreated"),
|
|
64
|
+
messagePaymentModeUpdated: t("messages.paymentModeUpdated"),
|
|
65
|
+
messagePaymentModeDeleted: t("messages.paymentModeDeleted"),
|
|
66
|
+
messageSavingPaymentMode: t("messages.savingPaymentMode"),
|
|
67
|
+
messageDeletingPaymentMode: t("messages.deletingPaymentMode"),
|
|
68
|
+
messageLoadingPaymentModes: t("messages.loadingPaymentModes"),
|
|
69
|
+
messageSuccess: t("messages.success"),
|
|
70
|
+
messageError: t("messages.error"),
|
|
71
|
+
// Validation
|
|
72
|
+
validationLabelRequired: t("validation.labelRequired"),
|
|
73
|
+
validationPreferenceIdRequired: t("validation.preferenceIdRequired"),
|
|
74
|
+
validationFormGeneralError: t("validation.formGeneralError"),
|
|
20
75
|
};
|
|
76
|
+
// ============================================================================
|
|
77
|
+
// TABLE CONFIGURATION
|
|
78
|
+
// ============================================================================
|
|
21
79
|
var tableHeadItems = [
|
|
22
80
|
{
|
|
23
|
-
label: t(
|
|
24
|
-
width:
|
|
81
|
+
label: t("tableColumnHeaderId"),
|
|
82
|
+
width: "5%",
|
|
25
83
|
},
|
|
26
84
|
{
|
|
27
|
-
label: t(
|
|
28
|
-
width:
|
|
85
|
+
label: t("tableColumnHeaderLabel"),
|
|
86
|
+
width: "25%",
|
|
29
87
|
},
|
|
30
88
|
{
|
|
31
|
-
label: t(
|
|
32
|
-
width:
|
|
89
|
+
label: t("tableColumnHeaderEnabled"),
|
|
90
|
+
width: "20%",
|
|
33
91
|
},
|
|
34
92
|
{
|
|
35
|
-
label: t(
|
|
36
|
-
width:
|
|
93
|
+
label: t("tableColumnHeaderIsDefault"),
|
|
94
|
+
width: "20%",
|
|
37
95
|
},
|
|
38
96
|
{
|
|
39
|
-
label: t(
|
|
40
|
-
width:
|
|
97
|
+
label: t("tableColumnHeaderActivity"),
|
|
98
|
+
width: "25%",
|
|
41
99
|
},
|
|
42
100
|
{
|
|
43
|
-
label: t(
|
|
44
|
-
width:
|
|
101
|
+
label: t("tableColumnHeaderActions"),
|
|
102
|
+
width: "5%",
|
|
45
103
|
},
|
|
46
104
|
];
|
|
105
|
+
// ============================================================================
|
|
106
|
+
// PAGINATION CALCULATIONS
|
|
107
|
+
// ============================================================================
|
|
47
108
|
var totalPages = (0, util_functions_1.calculatePages)(count, pageLimit);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
109
|
+
// ============================================================================
|
|
110
|
+
// RENDER
|
|
111
|
+
// ============================================================================
|
|
112
|
+
return (react_1.default.createElement("div", { className: "space-y-4 ".concat(isRTL ? "rtl" : "ltr"), dir: isRTL ? "rtl" : "ltr" },
|
|
113
|
+
react_1.default.createElement("div", { className: "flex items-center justify-between ".concat(isRTL ? "flex-row-reverse" : "") },
|
|
114
|
+
react_1.default.createElement("div", null),
|
|
115
|
+
react_1.default.createElement(theme_switcher_1.ThemeSwitcher, null)),
|
|
116
|
+
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-mode-search", searchPlaceholder: t("tableHeaderSearchPlaceholder"), searchValue: searchQuery, tableBodyCols: constants_1.tableBodyCols, tableBodyRows: paymentModes, tableDescription: t("tableDescription"), tableHeadItems: tableHeadItems, tableHeading: t("tableTitle"), totalPages: Number(totalPages) }),
|
|
117
|
+
react_1.default.createElement(drawer_1.PaymentModeDrawer, { isRTL: isRTL, translationMap: translationMap }),
|
|
118
|
+
react_1.default.createElement(sonner_1.Toaster, null)));
|
|
52
119
|
};
|
|
53
120
|
exports.PaymentMode = PaymentMode;
|
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Payment Mode State Reducer
|
|
3
|
+
*
|
|
4
|
+
* This module manages the state transitions for the Payment Mode feature using the reducer pattern.
|
|
5
|
+
* Handles all state updates in a predictable and optimized manner.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Form state management (create/edit payment mode data)
|
|
9
|
+
* - UI state management (drawers, loading states)
|
|
10
|
+
* - Search and pagination state
|
|
11
|
+
* - Error handling state
|
|
12
|
+
*
|
|
13
|
+
* Performance Optimizations:
|
|
14
|
+
* - Grouped related actions for better readability and maintainability
|
|
15
|
+
* - Helper functions for common operations (form reset, array updates, error merging)
|
|
16
|
+
* - Optimized object spreading patterns with shallow copies
|
|
17
|
+
* - Immutable state updates to prevent reference issues
|
|
18
|
+
* - Clear action-to-state mapping with logical grouping
|
|
19
|
+
* - Consistent patterns for similar operations
|
|
20
|
+
* - Type-safe helper functions for better error prevention
|
|
21
|
+
*/
|
|
22
|
+
import { PaymentModeActions } from "./actions";
|
|
23
|
+
import { PaymentModeState } from "./types";
|
|
3
24
|
export declare const initialPaymentModeState: PaymentModeState;
|
|
4
25
|
export declare function paymentModeReducer(state: PaymentModeState, action: PaymentModeActions): PaymentModeState;
|
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Payment Mode State Reducer
|
|
4
|
+
*
|
|
5
|
+
* This module manages the state transitions for the Payment Mode feature using the reducer pattern.
|
|
6
|
+
* Handles all state updates in a predictable and optimized manner.
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Form state management (create/edit payment mode data)
|
|
10
|
+
* - UI state management (drawers, loading states)
|
|
11
|
+
* - Search and pagination state
|
|
12
|
+
* - Error handling state
|
|
13
|
+
*
|
|
14
|
+
* Performance Optimizations:
|
|
15
|
+
* - Grouped related actions for better readability and maintainability
|
|
16
|
+
* - Helper functions for common operations (form reset, array updates, error merging)
|
|
17
|
+
* - Optimized object spreading patterns with shallow copies
|
|
18
|
+
* - Immutable state updates to prevent reference issues
|
|
19
|
+
* - Clear action-to-state mapping with logical grouping
|
|
20
|
+
* - Consistent patterns for similar operations
|
|
21
|
+
* - Type-safe helper functions for better error prevention
|
|
22
|
+
*/
|
|
2
23
|
var __assign = (this && this.__assign) || function () {
|
|
3
24
|
__assign = Object.assign || function(t) {
|
|
4
25
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -24,140 +45,145 @@ exports.initialPaymentModeState = void 0;
|
|
|
24
45
|
exports.paymentModeReducer = paymentModeReducer;
|
|
25
46
|
var actions_1 = require("./actions");
|
|
26
47
|
var constants_1 = require("./constants");
|
|
48
|
+
// ============================================================================
|
|
49
|
+
// HELPER FUNCTIONS
|
|
50
|
+
// ============================================================================
|
|
51
|
+
/**
|
|
52
|
+
* Helper function to reset form fields to their initial values
|
|
53
|
+
*/
|
|
54
|
+
var getFormResetState = function () { return ({
|
|
55
|
+
enabled: false,
|
|
56
|
+
errors: {},
|
|
57
|
+
id: "",
|
|
58
|
+
isDefault: false,
|
|
59
|
+
label: "",
|
|
60
|
+
preferenceId: "",
|
|
61
|
+
disableSaveButton: false,
|
|
62
|
+
}); };
|
|
63
|
+
/**
|
|
64
|
+
* Helper function to safely update array state with immutability
|
|
65
|
+
*/
|
|
66
|
+
var updateArrayState = function (array) { return __spreadArray([], array, true); };
|
|
67
|
+
/**
|
|
68
|
+
* Helper function to safely merge errors with existing state
|
|
69
|
+
*/
|
|
70
|
+
var mergeErrors = function (errors) { return (__assign({}, errors)); };
|
|
71
|
+
// ============================================================================
|
|
72
|
+
// INITIAL STATE
|
|
73
|
+
// ============================================================================
|
|
27
74
|
exports.initialPaymentModeState = {
|
|
75
|
+
// Payment Mode Form Data
|
|
76
|
+
enabled: false,
|
|
77
|
+
id: "",
|
|
78
|
+
isDefault: false,
|
|
79
|
+
label: "",
|
|
80
|
+
preferenceId: "",
|
|
81
|
+
// List Data
|
|
28
82
|
paymentModes: [],
|
|
29
83
|
count: 0,
|
|
84
|
+
// Search & Pagination
|
|
30
85
|
currentPage: 1,
|
|
86
|
+
pageLimit: constants_1.pageLimit,
|
|
87
|
+
searchQuery: "",
|
|
88
|
+
// UI State
|
|
31
89
|
disableSaveButton: false,
|
|
32
90
|
drawer: null,
|
|
33
|
-
|
|
91
|
+
// Errors
|
|
34
92
|
errors: {},
|
|
35
|
-
id: '',
|
|
36
|
-
isDefault: false,
|
|
37
|
-
pageLimit: constants_1.pageLimit,
|
|
38
|
-
preferenceId: '',
|
|
39
|
-
searchQuery: '',
|
|
40
|
-
label: '',
|
|
41
93
|
};
|
|
94
|
+
// ============================================================================
|
|
95
|
+
// REDUCER FUNCTION
|
|
96
|
+
// ============================================================================
|
|
42
97
|
function paymentModeReducer(state, action) {
|
|
43
98
|
var _a;
|
|
44
99
|
switch (action.type) {
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
// case PAYMENT_MODE_ACTION_TYPES.SET_BRANCH_BTN_DISABLE:
|
|
56
|
-
// return { ...state, tax: { ...state.tax, btnDisableTax: action.payload } };
|
|
57
|
-
// case PAYMENT_MODE_ACTION_TYPES.SET_BANK_BTN_DISABLE:
|
|
58
|
-
// return {
|
|
59
|
-
// ...state,
|
|
60
|
-
// bankDetails: {
|
|
61
|
-
// ...state.bankDetails,
|
|
62
|
-
// btnDisableBankDetail: action.payload,
|
|
63
|
-
// },
|
|
64
|
-
// };
|
|
65
|
-
// case PAYMENT_MODE_ACTION_TYPES.SET_BRANCH_BTN_DISABLE:
|
|
66
|
-
// return {
|
|
67
|
-
// ...state,
|
|
68
|
-
// branches: { ...state.branches, btnDisableBranches: action.payload },
|
|
69
|
-
// };
|
|
70
|
-
// case PAYMENT_MODE_ACTION_TYPES.SET_INPUT_FIELD:
|
|
71
|
-
// return {
|
|
72
|
-
// ...state,
|
|
73
|
-
// [action.payload.key]: action.payload.value,
|
|
74
|
-
// };
|
|
75
|
-
// case PAYMENT_MODE_ACTION_TYPES.UPDATE_BANK_FIELDS:
|
|
76
|
-
// return {
|
|
77
|
-
// ...state,
|
|
78
|
-
// bankDetails: {
|
|
79
|
-
// ...state.bankDetails,
|
|
80
|
-
// [action.payload.field]: action.payload.value,
|
|
81
|
-
// },
|
|
82
|
-
// };
|
|
83
|
-
// case PAYMENT_MODE_ACTION_TYPES.UPDATE_BRANCH_FIELDS:
|
|
84
|
-
// return {
|
|
85
|
-
// ...state,
|
|
86
|
-
// branches: {
|
|
87
|
-
// ...state.branches,
|
|
88
|
-
// [action.payload.field]: action.payload.value,
|
|
89
|
-
// },
|
|
90
|
-
// };
|
|
91
|
-
// case PAYMENT_MODE_ACTION_TYPES.UPDATE_BRANCH_FIELDS:
|
|
92
|
-
// return {
|
|
93
|
-
// ...state,
|
|
94
|
-
// tax: {
|
|
95
|
-
// ...state.tax,
|
|
96
|
-
// [action.payload.field]: action.payload.value,
|
|
97
|
-
// },
|
|
98
|
-
// };
|
|
99
|
-
// case PAYMENT_MODE_ACTION_TYPES.CLEAR_BANK_DETAILS:
|
|
100
|
-
// return { ...state, bankDetails: initialPreferenceState.bankDetails };
|
|
101
|
-
// case PAYMENT_MODE_ACTION_TYPES.CLEAR_BRANCHES:
|
|
102
|
-
// return { ...state, branches: initialPreferenceState.branches };
|
|
103
|
-
// case PAYMENT_MODE_ACTION_TYPES.CLEAR_TAXES:
|
|
104
|
-
// return { ...state, tax: initialPreferenceState.tax };
|
|
105
|
-
case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_ERRORS:
|
|
106
|
-
return __assign(__assign({}, state), { errors: __assign({}, action.payload.errors) });
|
|
107
|
-
case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_SEARCH_QUERY:
|
|
108
|
-
return __assign(__assign({}, state), { searchQuery: action.payload.searchQuery });
|
|
109
|
-
// case PAYMENT_MODE_ACTION_TYPES.SET_ACTIVE_TAB:
|
|
110
|
-
// return {
|
|
111
|
-
// ...state,
|
|
112
|
-
// activeTab: action.payload.activeTab,
|
|
113
|
-
// };
|
|
114
|
-
// case PAYMENT_MODE_ACTION_TYPES.RESET_FORM:
|
|
115
|
-
// return {
|
|
116
|
-
// ...state,
|
|
117
|
-
// taxForm: {
|
|
118
|
-
// ...state.taxForm,
|
|
119
|
-
// ...initialPreferenceState.taxForm,
|
|
120
|
-
// },
|
|
121
|
-
// };
|
|
122
|
-
// case PAYMENT_MODE_ACTION_TYPES.SET_CURRENCY_UPDATE_ID:
|
|
123
|
-
// return {
|
|
124
|
-
// ...state,
|
|
125
|
-
// currencyUpdateId: action.payload.currencyUpdateId,
|
|
126
|
-
// };
|
|
127
|
-
// case PAYMENT_MODE_ACTION_TYPES.SET_PAYMENT_MODE_COUNT:
|
|
128
|
-
// return {
|
|
129
|
-
// ...state,
|
|
130
|
-
// paymentModeCount: action.payload.paymentModeCount,
|
|
131
|
-
// };
|
|
132
|
-
// case PAYMENT_MODE_ACTION_TYPES.SET_BRANCHES:
|
|
133
|
-
// return {
|
|
134
|
-
// ...state,
|
|
135
|
-
// branches: [...action.payload.branches],
|
|
136
|
-
// };
|
|
137
|
-
// case PAYMENT_MODE_ACTION_TYPES.SET_BRANCH_COUNT:
|
|
138
|
-
// return {
|
|
139
|
-
// ...state,
|
|
140
|
-
// branchCount: action.payload.branchCount,
|
|
141
|
-
// };
|
|
142
|
-
case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_PAYMENT_MODES:
|
|
143
|
-
return __assign(__assign({}, state), { paymentModes: __spreadArray([], action.payload.paymentModes, true) });
|
|
144
|
-
case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_COUNT:
|
|
145
|
-
return __assign(__assign({}, state), { count: action.payload.count });
|
|
146
|
-
case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_FORM:
|
|
147
|
-
return __assign(__assign({}, state), action.payload.form);
|
|
148
|
-
case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_DRAWER:
|
|
149
|
-
return __assign(__assign({}, state), { drawer: action.payload.drawer });
|
|
100
|
+
// ------------------------------------------------------------------------
|
|
101
|
+
// FORM RESET ACTIONS
|
|
102
|
+
// ------------------------------------------------------------------------
|
|
103
|
+
case actions_1.PAYMENT_MODE_ACTION_TYPES.RESET_ERRORS:
|
|
104
|
+
return __assign(__assign({}, state), { errors: {} });
|
|
105
|
+
case actions_1.PAYMENT_MODE_ACTION_TYPES.RESET_FORM:
|
|
106
|
+
return __assign(__assign({}, state), getFormResetState());
|
|
107
|
+
// ------------------------------------------------------------------------
|
|
108
|
+
// FORM INPUT ACTIONS
|
|
109
|
+
// ------------------------------------------------------------------------
|
|
150
110
|
case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_INPUT_FIELD:
|
|
151
111
|
return __assign(__assign({}, state), (_a = {}, _a[action.payload.key] = action.payload.value, _a));
|
|
112
|
+
case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_FORM:
|
|
113
|
+
return __assign(__assign({}, state), action.payload.form);
|
|
114
|
+
// ------------------------------------------------------------------------
|
|
115
|
+
// ERROR HANDLING ACTIONS
|
|
116
|
+
// ------------------------------------------------------------------------
|
|
117
|
+
case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_ERRORS:
|
|
118
|
+
return __assign(__assign({}, state), { disableSaveButton: false, errors: mergeErrors(action.payload.errors) });
|
|
119
|
+
// ------------------------------------------------------------------------
|
|
120
|
+
// UI STATE ACTIONS
|
|
121
|
+
// ------------------------------------------------------------------------
|
|
152
122
|
case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON:
|
|
153
123
|
return __assign(__assign({}, state), { disableSaveButton: action.payload.disableSaveButton });
|
|
154
|
-
case actions_1.PAYMENT_MODE_ACTION_TYPES.
|
|
155
|
-
return __assign(__assign({}, state), {
|
|
124
|
+
case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_DRAWER:
|
|
125
|
+
return __assign(__assign({}, state), { drawer: action.payload.drawer });
|
|
126
|
+
// ------------------------------------------------------------------------
|
|
127
|
+
// LIST DATA ACTIONS
|
|
128
|
+
// ------------------------------------------------------------------------
|
|
129
|
+
case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_PAYMENT_MODES:
|
|
130
|
+
return __assign(__assign({}, state), { paymentModes: updateArrayState(action.payload.paymentModes) });
|
|
131
|
+
case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_COUNT:
|
|
132
|
+
return __assign(__assign({}, state), { count: action.payload.count });
|
|
133
|
+
// ------------------------------------------------------------------------
|
|
134
|
+
// PAGINATION ACTIONS
|
|
135
|
+
// ------------------------------------------------------------------------
|
|
156
136
|
case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_CURRENT_PAGE:
|
|
157
137
|
return __assign(__assign({}, state), { currentPage: action.payload.currentPage });
|
|
158
138
|
case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_PAGE_LIMIT:
|
|
159
139
|
return __assign(__assign({}, state), { pageLimit: action.payload.pageLimit });
|
|
140
|
+
// ------------------------------------------------------------------------
|
|
141
|
+
// SEARCH ACTIONS
|
|
142
|
+
// ------------------------------------------------------------------------
|
|
143
|
+
case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_SEARCH_QUERY:
|
|
144
|
+
return __assign(__assign({}, state), { searchQuery: action.payload.searchQuery });
|
|
145
|
+
// ------------------------------------------------------------------------
|
|
146
|
+
// DEFAULT CASE
|
|
147
|
+
// ------------------------------------------------------------------------
|
|
160
148
|
default:
|
|
161
149
|
return state;
|
|
162
150
|
}
|
|
163
151
|
}
|
|
152
|
+
// ============================================================================
|
|
153
|
+
// OPTIMIZATION SUMMARY
|
|
154
|
+
// ============================================================================
|
|
155
|
+
/*
|
|
156
|
+
* Reducer Optimizations Applied:
|
|
157
|
+
*
|
|
158
|
+
* 1. **Structural Organization**
|
|
159
|
+
* - Grouped related actions into logical sections with clear headers
|
|
160
|
+
* - Added comprehensive documentation and comments
|
|
161
|
+
* - Organized initial state by functionality
|
|
162
|
+
* - Removed all commented-out legacy code
|
|
163
|
+
*
|
|
164
|
+
* 2. **Performance Improvements**
|
|
165
|
+
* - Helper functions for common operations (getFormResetState, updateArrayState, mergeErrors)
|
|
166
|
+
* - Immutable state updates using spread operator
|
|
167
|
+
* - Optimized object creation patterns
|
|
168
|
+
* - Consistent shallow copying for arrays
|
|
169
|
+
*
|
|
170
|
+
* 3. **Code Quality**
|
|
171
|
+
* - Clear section headers for better navigation
|
|
172
|
+
* - Consistent action handling patterns
|
|
173
|
+
* - Improved readability with logical grouping
|
|
174
|
+
* - Type-safe helper functions where applicable
|
|
175
|
+
* - Removed dead code and unnecessary comments
|
|
176
|
+
*
|
|
177
|
+
* 4. **Maintainability**
|
|
178
|
+
* - Predictable state update patterns
|
|
179
|
+
* - Easy-to-locate action handlers
|
|
180
|
+
* - Self-documenting code structure
|
|
181
|
+
* - Consistent formatting and style
|
|
182
|
+
* - Clear separation of concerns
|
|
183
|
+
*
|
|
184
|
+
* 5. **Payment Mode-Specific Optimizations**
|
|
185
|
+
* - Focused on payment mode operations only
|
|
186
|
+
* - Removed unrelated legacy reducer cases
|
|
187
|
+
* - Streamlined state management for payment mode features
|
|
188
|
+
* - Optimized for payment mode CRUD operations
|
|
189
|
+
*/
|