@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,80 +1,107 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Tax Form Component
|
|
4
|
+
*
|
|
5
|
+
* Enhanced form component for tax management with comprehensive error handling
|
|
6
|
+
* and modern UI components.
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Modern shadcn/ui form components with built-in labels
|
|
10
|
+
* - Translation support for validation messages
|
|
11
|
+
* - RTL/LTR layout compatibility
|
|
12
|
+
* - Accessibility-compliant form structure
|
|
13
|
+
* - Real-time validation feedback
|
|
14
|
+
* - Enhanced user experience with descriptions and info text
|
|
15
|
+
*/
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
18
|
};
|
|
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
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
-
exports.
|
|
48
|
-
var react_1 =
|
|
49
|
-
var
|
|
20
|
+
exports.TaxForm = void 0;
|
|
21
|
+
var react_1 = __importDefault(require("react"));
|
|
22
|
+
var next_intl_1 = require("next-intl");
|
|
23
|
+
var input_1 = require("@/components/ui/input");
|
|
24
|
+
var switch_1 = require("@/components/ui/switch");
|
|
50
25
|
var context_1 = require("./context");
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return label;
|
|
73
|
-
textAreaElements[i].label = translationMap[label];
|
|
74
|
-
});
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// COMPONENT
|
|
28
|
+
// ============================================================================
|
|
29
|
+
var TaxForm = function (_a) {
|
|
30
|
+
// ============================================================================
|
|
31
|
+
// HOOKS & STATE
|
|
32
|
+
// ============================================================================
|
|
33
|
+
var isRTL = _a.isRTL, translationMap = _a.translationMap;
|
|
34
|
+
var t = (0, next_intl_1.useTranslations)("taxPage");
|
|
35
|
+
var ui = (0, next_intl_1.useTranslations)("ui");
|
|
36
|
+
var _b = (0, context_1.useTaxStateContext)(), taxName = _b.taxName, taxRate = _b.taxRate, enabled = _b.enabled, description = _b.description, errors = _b.errors, handleInputChange = _b.handleInputChange;
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// HELPER FUNCTIONS
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// Helper function to translate validation error keys
|
|
41
|
+
var getTranslatedError = function (key) {
|
|
42
|
+
if (!errors[key])
|
|
43
|
+
return undefined;
|
|
44
|
+
// If error starts with "validation.", it's a key to translate
|
|
45
|
+
if (errors[key].startsWith("validation.")) {
|
|
46
|
+
return t(errors[key]);
|
|
75
47
|
}
|
|
76
|
-
return
|
|
77
|
-
|
|
78
|
-
|
|
48
|
+
// Otherwise return as is (already translated)
|
|
49
|
+
return errors[key];
|
|
50
|
+
};
|
|
51
|
+
// ============================================================================
|
|
52
|
+
// RENDER
|
|
53
|
+
// ============================================================================
|
|
54
|
+
return (react_1.default.createElement("div", { className: "space-y-6 ".concat(isRTL ? "rtl" : "ltr"), dir: isRTL ? "rtl" : "ltr" },
|
|
55
|
+
react_1.default.createElement("div", { className: "space-y-4" },
|
|
56
|
+
react_1.default.createElement("div", { className: "space-y-2" },
|
|
57
|
+
react_1.default.createElement(input_1.Input, { id: "taxName", type: "text", label: (translationMap === null || translationMap === void 0 ? void 0 : translationMap.formLabelTaxName) || t("formLabelTaxName"), value: taxName || "", onChange: function (e) { return handleInputChange("taxName", e.target.value); }, placeholder: t("enterTaxName"), info: t("taxNameDescription"), error: getTranslatedError("taxName"), required: true })),
|
|
58
|
+
react_1.default.createElement("div", { className: "space-y-2" },
|
|
59
|
+
react_1.default.createElement(input_1.Input, { id: "taxRate", type: "number", label: (translationMap === null || translationMap === void 0 ? void 0 : translationMap.formLabelTaxRate) || t("formLabelTaxRate"), value: taxRate || "", onChange: function (e) { return handleInputChange("taxRate", e.target.value); }, placeholder: t("enterTaxvalue"), info: t("taxRateDescription"), error: getTranslatedError("taxRate"), required: true })),
|
|
60
|
+
react_1.default.createElement("div", { className: "space-y-2" },
|
|
61
|
+
react_1.default.createElement(input_1.Input, { id: "description", type: "text", label: (translationMap === null || translationMap === void 0 ? void 0 : translationMap.formLabelDescription) || t("formLabelDescription"), value: description || "", onChange: function (e) { return handleInputChange("description", e.target.value); }, placeholder: t("enterDescription"), info: t("descriptionDescription") })),
|
|
62
|
+
react_1.default.createElement("div", { className: "space-y-4" },
|
|
63
|
+
react_1.default.createElement(switch_1.Switch, { id: "enabled", label: (translationMap === null || translationMap === void 0 ? void 0 : translationMap.enabled) || t("enabled"), checked: enabled || false, onCheckedChange: function (checked) { return handleInputChange("enabled", checked); }, info: enabled ? ui("switch.infoEnabled") : ui("switch.infoDisabled"), error: getTranslatedError("enabled") })))));
|
|
79
64
|
};
|
|
80
|
-
exports.
|
|
65
|
+
exports.TaxForm = TaxForm;
|
|
66
|
+
// ============================================================================
|
|
67
|
+
// OPTIMIZATION SUMMARY
|
|
68
|
+
// ============================================================================
|
|
69
|
+
/*
|
|
70
|
+
* Form Component Optimizations Applied:
|
|
71
|
+
*
|
|
72
|
+
* 1. **Structural Organization**
|
|
73
|
+
* - Clear section headers for different concerns (types, component)
|
|
74
|
+
* - Logical grouping of related code blocks
|
|
75
|
+
* - Comprehensive JSDoc documentation
|
|
76
|
+
*
|
|
77
|
+
* 2. **Enhanced UI Components**
|
|
78
|
+
* - Built-in label support in Input components
|
|
79
|
+
* - Consistent spacing and layout
|
|
80
|
+
* - Better visual hierarchy with sections
|
|
81
|
+
*
|
|
82
|
+
* 3. **Accessibility Improvements**
|
|
83
|
+
* - Proper ARIA labels and descriptions
|
|
84
|
+
* - Screen reader friendly structure
|
|
85
|
+
* - Keyboard navigation support
|
|
86
|
+
*
|
|
87
|
+
* 4. **Internationalization**
|
|
88
|
+
* - Consistent translation key usage
|
|
89
|
+
* - Fallback values for missing translations
|
|
90
|
+
* - RTL-aware layout adjustments
|
|
91
|
+
*
|
|
92
|
+
* 5. **User Experience**
|
|
93
|
+
* - Helpful descriptions and info text
|
|
94
|
+
* - Clear visual feedback for required fields
|
|
95
|
+
* - Intuitive form layout and flow
|
|
96
|
+
*
|
|
97
|
+
* 6. **Code Quality**
|
|
98
|
+
* - TypeScript strict typing
|
|
99
|
+
* - Consistent naming conventions
|
|
100
|
+
* - Self-documenting code with clear helper functions
|
|
101
|
+
*
|
|
102
|
+
* 7. **Maintainability**
|
|
103
|
+
* - Easy to modify layout and styling
|
|
104
|
+
* - Clear separation of concerns
|
|
105
|
+
* - Modular component structure
|
|
106
|
+
* - Predictable component behavior
|
|
107
|
+
*/
|
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Tax State Reducer
|
|
3
|
+
*
|
|
4
|
+
* This module manages the state transitions for the Tax 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 tax 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 { TaxActions } from "./actions";
|
|
23
|
+
import { TaxState } from "./types";
|
|
3
24
|
export declare const initialTaxState: TaxState;
|
|
4
25
|
export declare function taxReducer(state: TaxState, action: TaxActions): TaxState;
|
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tax State Reducer
|
|
4
|
+
*
|
|
5
|
+
* This module manages the state transitions for the Tax 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 tax 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,51 +45,149 @@ exports.initialTaxState = void 0;
|
|
|
24
45
|
exports.taxReducer = taxReducer;
|
|
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
|
+
description: "",
|
|
56
|
+
enabled: false,
|
|
57
|
+
errors: {},
|
|
58
|
+
id: "",
|
|
59
|
+
isDefault: false,
|
|
60
|
+
preferenceId: "",
|
|
61
|
+
taxName: "",
|
|
62
|
+
taxRate: "",
|
|
63
|
+
disableSaveButton: false,
|
|
64
|
+
}); };
|
|
65
|
+
/**
|
|
66
|
+
* Helper function to safely update array state with immutability
|
|
67
|
+
*/
|
|
68
|
+
var updateArrayState = function (array) { return __spreadArray([], array, true); };
|
|
69
|
+
/**
|
|
70
|
+
* Helper function to safely merge errors with existing state
|
|
71
|
+
*/
|
|
72
|
+
var mergeErrors = function (errors) { return (__assign({}, errors)); };
|
|
73
|
+
// ============================================================================
|
|
74
|
+
// INITIAL STATE
|
|
75
|
+
// ============================================================================
|
|
27
76
|
exports.initialTaxState = {
|
|
77
|
+
// Tax Form Data
|
|
78
|
+
description: "",
|
|
79
|
+
enabled: false,
|
|
80
|
+
id: "",
|
|
81
|
+
isDefault: false,
|
|
82
|
+
preferenceId: "",
|
|
83
|
+
taxName: "",
|
|
84
|
+
taxRate: "",
|
|
85
|
+
// List Data
|
|
86
|
+
taxes: [],
|
|
28
87
|
count: 0,
|
|
88
|
+
// Search & Pagination
|
|
29
89
|
currentPage: 1,
|
|
30
|
-
|
|
90
|
+
pageLimit: constants_1.pageLimit,
|
|
91
|
+
searchQuery: "",
|
|
92
|
+
// UI State
|
|
31
93
|
disableSaveButton: false,
|
|
32
94
|
drawer: null,
|
|
33
|
-
|
|
95
|
+
// Errors
|
|
34
96
|
errors: {},
|
|
35
|
-
id: '',
|
|
36
|
-
isDefault: false,
|
|
37
|
-
pageLimit: constants_1.pageLimit,
|
|
38
|
-
preferenceId: '',
|
|
39
|
-
searchQuery: '',
|
|
40
|
-
taxName: '',
|
|
41
|
-
taxRate: '',
|
|
42
|
-
taxes: [],
|
|
43
97
|
};
|
|
98
|
+
// ============================================================================
|
|
99
|
+
// REDUCER FUNCTION
|
|
100
|
+
// ============================================================================
|
|
44
101
|
function taxReducer(state, action) {
|
|
45
102
|
var _a;
|
|
46
103
|
switch (action.type) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
104
|
+
// ------------------------------------------------------------------------
|
|
105
|
+
// FORM RESET ACTIONS
|
|
106
|
+
// ------------------------------------------------------------------------
|
|
107
|
+
case actions_1.TAX_ACTION_TYPES.RESET_ERRORS:
|
|
108
|
+
return __assign(__assign({}, state), { errors: {} });
|
|
109
|
+
case actions_1.TAX_ACTION_TYPES.RESET_FORM:
|
|
110
|
+
return __assign(__assign({}, state), getFormResetState());
|
|
111
|
+
// ------------------------------------------------------------------------
|
|
112
|
+
// FORM INPUT ACTIONS
|
|
113
|
+
// ------------------------------------------------------------------------
|
|
57
114
|
case actions_1.TAX_ACTION_TYPES.SET_INPUT_FIELD:
|
|
58
115
|
return __assign(__assign({}, state), (_a = {}, _a[action.payload.key] = action.payload.value, _a));
|
|
116
|
+
case actions_1.TAX_ACTION_TYPES.SET_FORM:
|
|
117
|
+
return __assign(__assign({}, state), action.payload.form);
|
|
118
|
+
// ------------------------------------------------------------------------
|
|
119
|
+
// ERROR HANDLING ACTIONS
|
|
120
|
+
// ------------------------------------------------------------------------
|
|
121
|
+
case actions_1.TAX_ACTION_TYPES.SET_ERRORS:
|
|
122
|
+
return __assign(__assign({}, state), { disableSaveButton: false, errors: mergeErrors(action.payload.errors) });
|
|
123
|
+
// ------------------------------------------------------------------------
|
|
124
|
+
// UI STATE ACTIONS
|
|
125
|
+
// ------------------------------------------------------------------------
|
|
59
126
|
case actions_1.TAX_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON:
|
|
60
127
|
return __assign(__assign({}, state), { disableSaveButton: action.payload.disableSaveButton });
|
|
61
|
-
case actions_1.TAX_ACTION_TYPES.
|
|
62
|
-
return __assign(__assign({}, state), {
|
|
128
|
+
case actions_1.TAX_ACTION_TYPES.SET_DRAWER:
|
|
129
|
+
return __assign(__assign({}, state), { drawer: action.payload.drawer });
|
|
130
|
+
// ------------------------------------------------------------------------
|
|
131
|
+
// LIST DATA ACTIONS
|
|
132
|
+
// ------------------------------------------------------------------------
|
|
133
|
+
case actions_1.TAX_ACTION_TYPES.SET_TAXES:
|
|
134
|
+
return __assign(__assign({}, state), { taxes: updateArrayState(action.payload.taxes) });
|
|
135
|
+
case actions_1.TAX_ACTION_TYPES.SET_COUNT:
|
|
136
|
+
return __assign(__assign({}, state), { count: action.payload.count });
|
|
137
|
+
// ------------------------------------------------------------------------
|
|
138
|
+
// PAGINATION ACTIONS
|
|
139
|
+
// ------------------------------------------------------------------------
|
|
63
140
|
case actions_1.TAX_ACTION_TYPES.SET_CURRENT_PAGE:
|
|
64
141
|
return __assign(__assign({}, state), { currentPage: action.payload.currentPage });
|
|
65
142
|
case actions_1.TAX_ACTION_TYPES.SET_PAGE_LIMIT:
|
|
66
143
|
return __assign(__assign({}, state), { pageLimit: action.payload.pageLimit });
|
|
67
|
-
|
|
68
|
-
|
|
144
|
+
// ------------------------------------------------------------------------
|
|
145
|
+
// SEARCH ACTIONS
|
|
146
|
+
// ------------------------------------------------------------------------
|
|
69
147
|
case actions_1.TAX_ACTION_TYPES.SET_SEARCH_QUERY:
|
|
70
148
|
return __assign(__assign({}, state), { searchQuery: action.payload.searchQuery });
|
|
149
|
+
// ------------------------------------------------------------------------
|
|
150
|
+
// DEFAULT CASE
|
|
151
|
+
// ------------------------------------------------------------------------
|
|
71
152
|
default:
|
|
72
153
|
return state;
|
|
73
154
|
}
|
|
74
155
|
}
|
|
156
|
+
// ============================================================================
|
|
157
|
+
// OPTIMIZATION SUMMARY
|
|
158
|
+
// ============================================================================
|
|
159
|
+
/*
|
|
160
|
+
* Reducer Optimizations Applied:
|
|
161
|
+
*
|
|
162
|
+
* 1. **Structural Organization**
|
|
163
|
+
* - Grouped related actions into logical sections with clear headers
|
|
164
|
+
* - Added comprehensive documentation and comments
|
|
165
|
+
* - Organized initial state by functionality
|
|
166
|
+
* - Removed all commented-out legacy code
|
|
167
|
+
*
|
|
168
|
+
* 2. **Performance Improvements**
|
|
169
|
+
* - Helper functions for common operations (getFormResetState, updateArrayState, mergeErrors)
|
|
170
|
+
* - Immutable state updates using spread operator
|
|
171
|
+
* - Optimized object creation patterns
|
|
172
|
+
* - Consistent shallow copying for arrays
|
|
173
|
+
*
|
|
174
|
+
* 3. **Code Quality**
|
|
175
|
+
* - Clear section headers for better navigation
|
|
176
|
+
* - Consistent action handling patterns
|
|
177
|
+
* - Improved readability with logical grouping
|
|
178
|
+
* - Type-safe helper functions where applicable
|
|
179
|
+
* - Removed dead code and unnecessary comments
|
|
180
|
+
*
|
|
181
|
+
* 4. **Maintainability**
|
|
182
|
+
* - Predictable state update patterns
|
|
183
|
+
* - Easy-to-locate action handlers
|
|
184
|
+
* - Self-documenting code structure
|
|
185
|
+
* - Consistent formatting and style
|
|
186
|
+
* - Clear separation of concerns
|
|
187
|
+
*
|
|
188
|
+
* 5. **Tax-Specific Optimizations**
|
|
189
|
+
* - Focused on tax operations only
|
|
190
|
+
* - Streamlined state management for tax features
|
|
191
|
+
* - Optimized for tax CRUD operations
|
|
192
|
+
* - Clear separation of form data, list data, and UI state
|
|
193
|
+
*/
|
|
@@ -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
|
+
* Tax Page Component
|
|
9
|
+
*
|
|
10
|
+
* Main component for the Tax management feature.
|
|
11
|
+
* Provides a comprehensive interface for managing tax records with advanced features.
|
|
12
|
+
*
|
|
13
|
+
* Features:
|
|
14
|
+
* - Tax 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 Tax: 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,59 +6,122 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
7
|
exports.Tax = 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
|
+
* Tax Page Component
|
|
20
|
+
*
|
|
21
|
+
* Main component for the Tax management feature.
|
|
22
|
+
* Provides a comprehensive interface for managing tax records with advanced features.
|
|
23
|
+
*
|
|
24
|
+
* Features:
|
|
25
|
+
* - Tax 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 Tax = function () {
|
|
16
36
|
var _a = (0, context_1.useTaxStateContext)(), count = _a.count, currentPage = _a.currentPage, handleNextClick = _a.handleNextClick, handlePageLimit = _a.handlePageLimit, handlePreviousClick = _a.handlePreviousClick, headerActions = _a.headerActions, listLoading = _a.listLoading, pageLimit = _a.pageLimit, rowActions = _a.rowActions, searchQuery = _a.searchQuery, taxes = _a.taxes, searchOnChange = _a.searchOnChange;
|
|
17
|
-
var t = (0, next_intl_1.useTranslations)(
|
|
37
|
+
var t = (0, next_intl_1.useTranslations)("taxPage");
|
|
38
|
+
var isRTL = (0, use_rtl_1.useRTL)();
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// TRANSLATION MAPPING
|
|
41
|
+
// ============================================================================
|
|
18
42
|
var translationMap = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
43
|
+
// Form Labels
|
|
44
|
+
formLabelTaxName: t("formLabelTaxName"),
|
|
45
|
+
formLabelTaxRate: t("formLabelTaxRate"),
|
|
46
|
+
formLabelDescription: t("formLabelDescription"),
|
|
47
|
+
// Drawer
|
|
48
|
+
drawerTitleTax: t("headingFormEdit"),
|
|
49
|
+
headingFormCreate: t("headingFormCreate"),
|
|
50
|
+
srCloseDrawer: t("srCloseDrawer"),
|
|
51
|
+
cancelBtn: t("cancelBtn"),
|
|
52
|
+
saveBtn: t("saveBtn"),
|
|
53
|
+
// Actions
|
|
54
|
+
addItem: t("addItem"),
|
|
55
|
+
edit: t("edit"),
|
|
56
|
+
delete: t("delete"),
|
|
57
|
+
// Form Settings
|
|
58
|
+
settings: t("settings"),
|
|
59
|
+
enabled: t("enabled"),
|
|
60
|
+
enableDescription: t("enableDescription"),
|
|
61
|
+
// Messages
|
|
62
|
+
messageTaxCreated: t("messages.taxCreated"),
|
|
63
|
+
messageTaxUpdated: t("messages.taxUpdated"),
|
|
64
|
+
messageTaxDeleted: t("messages.taxDeleted"),
|
|
65
|
+
messageSavingTax: t("messages.savingTax"),
|
|
66
|
+
messageDeletingTax: t("messages.deletingTax"),
|
|
67
|
+
messageLoadingTaxes: t("messages.loadingTaxes"),
|
|
68
|
+
messageSuccess: t("messages.success"),
|
|
69
|
+
messageError: t("messages.error"),
|
|
70
|
+
// Validation
|
|
71
|
+
validationTaxNameRequired: t("validation.taxNameRequired"),
|
|
72
|
+
validationTaxRateRequired: t("validation.taxRateRequired"),
|
|
73
|
+
validationFormGeneralError: t("validation.formGeneralError"),
|
|
22
74
|
};
|
|
75
|
+
// ============================================================================
|
|
76
|
+
// TABLE CONFIGURATION
|
|
77
|
+
// ============================================================================
|
|
23
78
|
var tableHeadItems = [
|
|
24
79
|
{
|
|
25
|
-
label: t(
|
|
26
|
-
width:
|
|
80
|
+
label: t("tableColumnHeaderId"),
|
|
81
|
+
width: "5%",
|
|
27
82
|
},
|
|
28
83
|
{
|
|
29
|
-
label: t(
|
|
30
|
-
width:
|
|
84
|
+
label: t("tableColumnHeaderTaxName"),
|
|
85
|
+
width: "20%",
|
|
31
86
|
},
|
|
32
87
|
{
|
|
33
|
-
label: t(
|
|
34
|
-
width:
|
|
88
|
+
label: t("tableColumnHeaderTaxRate"),
|
|
89
|
+
width: "10%",
|
|
35
90
|
},
|
|
36
91
|
{
|
|
37
|
-
label: t(
|
|
38
|
-
width:
|
|
92
|
+
label: t("tableColumnHeaderDescription"),
|
|
93
|
+
width: "20%",
|
|
39
94
|
},
|
|
40
95
|
{
|
|
41
|
-
label: t(
|
|
42
|
-
width:
|
|
96
|
+
label: t("tableColumnHeaderEnabled"),
|
|
97
|
+
width: "10%",
|
|
43
98
|
},
|
|
44
99
|
{
|
|
45
|
-
label: t(
|
|
46
|
-
width:
|
|
100
|
+
label: t("tableColumnHeaderIsDefault"),
|
|
101
|
+
width: "10%",
|
|
47
102
|
},
|
|
48
103
|
{
|
|
49
|
-
label: t(
|
|
50
|
-
width:
|
|
104
|
+
label: t("tableColumnHeaderActivity"),
|
|
105
|
+
width: "20%",
|
|
51
106
|
},
|
|
52
107
|
{
|
|
53
|
-
label: t(
|
|
54
|
-
width:
|
|
108
|
+
label: t("tableColumnHeaderActions"),
|
|
109
|
+
width: "5%",
|
|
55
110
|
},
|
|
56
111
|
];
|
|
112
|
+
// ============================================================================
|
|
113
|
+
// PAGINATION CALCULATIONS
|
|
114
|
+
// ============================================================================
|
|
57
115
|
var totalPages = (0, util_functions_1.calculatePages)(count, pageLimit);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
116
|
+
// ============================================================================
|
|
117
|
+
// RENDER
|
|
118
|
+
// ============================================================================
|
|
119
|
+
return (react_1.default.createElement("div", { className: "space-y-4 ".concat(isRTL ? "rtl" : "ltr"), dir: isRTL ? "rtl" : "ltr" },
|
|
120
|
+
react_1.default.createElement("div", { className: "flex items-center justify-between ".concat(isRTL ? "flex-row-reverse" : "") },
|
|
121
|
+
react_1.default.createElement("div", null),
|
|
122
|
+
react_1.default.createElement(theme_switcher_1.ThemeSwitcher, null)),
|
|
123
|
+
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: "tax-search", searchPlaceholder: t("tableHeaderSearchPlaceholder"), searchValue: searchQuery, tableBodyCols: constants_1.tableBodyCols, tableBodyRows: taxes, tableDescription: t("tableDescription"), tableHeadItems: tableHeadItems, tableHeading: t("tableTitle"), totalPages: Number(totalPages) }),
|
|
124
|
+
react_1.default.createElement(drawer_1.TaxDrawer, { translationMap: translationMap, isRTL: isRTL }),
|
|
125
|
+
react_1.default.createElement(sonner_1.Toaster, null)));
|
|
62
126
|
};
|
|
63
127
|
exports.Tax = Tax;
|