@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
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formValidation = void 0;
|
|
4
4
|
var zod_1 = require("zod");
|
|
5
|
-
|
|
5
|
+
// Validation error keys for i18n translation
|
|
6
|
+
var VALIDATION_KEYS = {
|
|
7
|
+
labelRequired: "paymentModePage.validation.labelRequired",
|
|
8
|
+
preferenceIdRequired: "paymentModePage.validation.preferenceIdRequired",
|
|
9
|
+
};
|
|
6
10
|
exports.formValidation = zod_1.z.object({
|
|
7
|
-
label: zod_1.z
|
|
8
|
-
.string()
|
|
9
|
-
.nonempty(constants_1.validationError.label),
|
|
11
|
+
label: zod_1.z.string().nonempty(VALIDATION_KEYS.labelRequired),
|
|
10
12
|
enabled: zod_1.z.boolean(),
|
|
11
13
|
isDefault: zod_1.z.boolean(),
|
|
12
|
-
preferenceId: zod_1.z.string().nonempty(
|
|
14
|
+
preferenceId: zod_1.z.string().nonempty(VALIDATION_KEYS.preferenceIdRequired),
|
|
13
15
|
});
|
|
@@ -1,61 +1,160 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Preferences Actions
|
|
3
|
+
*
|
|
4
|
+
* This module defines all action types and interfaces for the Preferences state management.
|
|
5
|
+
* Actions are organized by functionality and follow consistent naming patterns.
|
|
6
|
+
*
|
|
7
|
+
* Organization:
|
|
8
|
+
* - Action Types Enum (grouped by functionality)
|
|
9
|
+
* - Reset Actions (form/error reset)
|
|
10
|
+
* - Data Management Actions (preferences, currencies)
|
|
11
|
+
* - UI State Actions (tabs, loading states)
|
|
12
|
+
* - Union Type Export
|
|
13
|
+
* - Action Creators (helper functions)
|
|
14
|
+
* - Type Utilities (guards and helpers)
|
|
15
|
+
*
|
|
16
|
+
* Naming Convention: Preference{Operation}{Target}Action
|
|
17
|
+
* Examples: PreferenceSetCurrenciesAction, PreferenceResetFormAction
|
|
18
|
+
*/
|
|
19
|
+
import { CurrencyTypeBE, PreferenceState, PreferenceTypeBE } from "./types";
|
|
2
20
|
export declare enum PREFERENCE_ACTION_TYPES {
|
|
3
21
|
CLEAR_ERRORS = "CLEAR_ERRORS",
|
|
4
22
|
RESET_FORM = "RESET_FORM",
|
|
5
|
-
SET_ACTIVE_TAB = "SET_ACTIVE_TAB",
|
|
6
23
|
SET_CURRENCIES = "SET_CURRENCIES",
|
|
24
|
+
SET_PREFERENCES = "SET_PREFERENCES",
|
|
25
|
+
SET_COUNT = "SET_COUNT",
|
|
26
|
+
SET_ACTIVE_TAB = "SET_ACTIVE_TAB",
|
|
7
27
|
SET_CURRENCY_UPDATE_ID = "SET_CURRENCY_UPDATE_ID",
|
|
8
28
|
SET_ERRORS = "SET_ERRORS",
|
|
9
|
-
SET_PREFERENCE = "SET_PREFERENCE"
|
|
10
|
-
SET_PREFERENCES = "SET_PREFERENCES",
|
|
11
|
-
SET_COUNT = "SET_COUNT"
|
|
29
|
+
SET_PREFERENCE = "SET_PREFERENCE"
|
|
12
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Clear form validation errors
|
|
33
|
+
*/
|
|
34
|
+
export type PreferenceClearErrorsAction = {
|
|
35
|
+
type: PREFERENCE_ACTION_TYPES.CLEAR_ERRORS;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Reset entire form to initial state
|
|
39
|
+
*/
|
|
40
|
+
export type PreferenceResetFormAction = {
|
|
41
|
+
type: PREFERENCE_ACTION_TYPES.RESET_FORM;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Set currencies list data
|
|
45
|
+
*/
|
|
46
|
+
export type PreferenceSetCurrenciesAction = {
|
|
47
|
+
type: PREFERENCE_ACTION_TYPES.SET_CURRENCIES;
|
|
48
|
+
payload: {
|
|
49
|
+
currencies: CurrencyTypeBE[];
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Set preferences list data
|
|
54
|
+
*/
|
|
13
55
|
export type PreferenceSetPreferencesAction = {
|
|
14
56
|
type: PREFERENCE_ACTION_TYPES.SET_PREFERENCES;
|
|
15
57
|
payload: {
|
|
16
58
|
preferences: PreferenceTypeBE[];
|
|
17
59
|
};
|
|
18
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Set total count of preferences (for pagination)
|
|
63
|
+
*/
|
|
19
64
|
export type PreferenceSetCountAction = {
|
|
20
65
|
type: PREFERENCE_ACTION_TYPES.SET_COUNT;
|
|
21
66
|
payload: {
|
|
22
67
|
count: number;
|
|
23
68
|
};
|
|
24
69
|
};
|
|
25
|
-
|
|
26
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Set active tab in preferences interface
|
|
72
|
+
*/
|
|
73
|
+
export type PreferenceSetActiveTabAction = {
|
|
74
|
+
type: PREFERENCE_ACTION_TYPES.SET_ACTIVE_TAB;
|
|
27
75
|
payload: {
|
|
28
|
-
|
|
76
|
+
activeTab: string;
|
|
29
77
|
};
|
|
30
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* Set currency update loading ID (for UI feedback)
|
|
81
|
+
*/
|
|
82
|
+
export type PreferenceSetCurrencyUpdateIdAction = {
|
|
83
|
+
type: PREFERENCE_ACTION_TYPES.SET_CURRENCY_UPDATE_ID;
|
|
84
|
+
payload: {
|
|
85
|
+
currencyUpdateId: string;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Set form validation errors
|
|
90
|
+
*/
|
|
31
91
|
export type PreferenceSetErrorsAction = {
|
|
32
92
|
type: PREFERENCE_ACTION_TYPES.SET_ERRORS;
|
|
33
93
|
payload: {
|
|
34
94
|
errors: Record<string, string>;
|
|
35
95
|
};
|
|
36
96
|
};
|
|
37
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Set preference data (used when editing existing preference)
|
|
99
|
+
*/
|
|
100
|
+
export type PreferenceSetPreferenceAction = {
|
|
38
101
|
type: PREFERENCE_ACTION_TYPES.SET_PREFERENCE;
|
|
39
102
|
payload: {
|
|
40
103
|
preference: PreferenceState;
|
|
41
104
|
};
|
|
42
105
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
export type
|
|
59
|
-
|
|
106
|
+
/**
|
|
107
|
+
* All preference-related actions grouped by functionality
|
|
108
|
+
*/
|
|
109
|
+
export type PreferenceActions = PreferenceClearErrorsAction | PreferenceResetFormAction | PreferenceSetCurrenciesAction | PreferenceSetPreferencesAction | PreferenceSetCountAction | PreferenceSetActiveTabAction | PreferenceSetCurrencyUpdateIdAction | PreferenceSetErrorsAction | PreferenceSetPreferenceAction;
|
|
110
|
+
/**
|
|
111
|
+
* Type guard for reset actions
|
|
112
|
+
*/
|
|
113
|
+
export type PreferenceResetActions = PreferenceClearErrorsAction | PreferenceResetFormAction;
|
|
114
|
+
/**
|
|
115
|
+
* Type guard for data management actions
|
|
116
|
+
*/
|
|
117
|
+
export type PreferenceDataActions = PreferenceSetCurrenciesAction | PreferenceSetPreferencesAction | PreferenceSetCountAction;
|
|
118
|
+
/**
|
|
119
|
+
* Type guard for UI state actions
|
|
120
|
+
*/
|
|
121
|
+
export type PreferenceUIActions = PreferenceSetActiveTabAction | PreferenceSetCurrencyUpdateIdAction | PreferenceSetErrorsAction | PreferenceSetPreferenceAction;
|
|
122
|
+
/**
|
|
123
|
+
* Action creators for common preference operations
|
|
124
|
+
* These provide type-safe action creation with better developer experience
|
|
125
|
+
*/
|
|
126
|
+
export declare const preferenceActionCreators: {
|
|
127
|
+
readonly clearErrors: () => PreferenceClearErrorsAction;
|
|
128
|
+
readonly resetForm: () => PreferenceResetFormAction;
|
|
129
|
+
readonly setCurrencies: (currencies: CurrencyTypeBE[]) => PreferenceSetCurrenciesAction;
|
|
130
|
+
readonly setPreferences: (preferences: PreferenceTypeBE[]) => PreferenceSetPreferencesAction;
|
|
131
|
+
readonly setCount: (count: number) => PreferenceSetCountAction;
|
|
132
|
+
readonly setActiveTab: (activeTab: string) => PreferenceSetActiveTabAction;
|
|
133
|
+
readonly setCurrencyUpdateId: (currencyUpdateId: string) => PreferenceSetCurrencyUpdateIdAction;
|
|
134
|
+
readonly setErrors: (errors: Record<string, string>) => PreferenceSetErrorsAction;
|
|
135
|
+
readonly setPreference: (preference: PreferenceState) => PreferenceSetPreferenceAction;
|
|
60
136
|
};
|
|
61
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Extract action type from action object
|
|
139
|
+
*/
|
|
140
|
+
export type ActionType<T extends PreferenceActions> = T["type"];
|
|
141
|
+
/**
|
|
142
|
+
* Extract payload type from action object
|
|
143
|
+
*/
|
|
144
|
+
export type ActionPayload<T extends PreferenceActions> = T extends {
|
|
145
|
+
payload: infer P;
|
|
146
|
+
} ? P : never;
|
|
147
|
+
/**
|
|
148
|
+
* Utility type to check if action has payload
|
|
149
|
+
*/
|
|
150
|
+
export type HasPayload<T extends PreferenceActions> = T extends {
|
|
151
|
+
payload: unknown;
|
|
152
|
+
} ? true : false;
|
|
153
|
+
/**
|
|
154
|
+
* Runtime type guards for action validation
|
|
155
|
+
*/
|
|
156
|
+
export declare const isPreferenceAction: (action: unknown) => action is PreferenceActions;
|
|
157
|
+
/**
|
|
158
|
+
* Type guard for reset actions
|
|
159
|
+
*/
|
|
160
|
+
export declare const isResetAction: (action: PreferenceActions) => action is PreferenceResetActions;
|
|
@@ -1,15 +1,139 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Preferences Actions
|
|
4
|
+
*
|
|
5
|
+
* This module defines all action types and interfaces for the Preferences state management.
|
|
6
|
+
* Actions are organized by functionality and follow consistent naming patterns.
|
|
7
|
+
*
|
|
8
|
+
* Organization:
|
|
9
|
+
* - Action Types Enum (grouped by functionality)
|
|
10
|
+
* - Reset Actions (form/error reset)
|
|
11
|
+
* - Data Management Actions (preferences, currencies)
|
|
12
|
+
* - UI State Actions (tabs, loading states)
|
|
13
|
+
* - Union Type Export
|
|
14
|
+
* - Action Creators (helper functions)
|
|
15
|
+
* - Type Utilities (guards and helpers)
|
|
16
|
+
*
|
|
17
|
+
* Naming Convention: Preference{Operation}{Target}Action
|
|
18
|
+
* Examples: PreferenceSetCurrenciesAction, PreferenceResetFormAction
|
|
19
|
+
*/
|
|
2
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PREFERENCE_ACTION_TYPES = void 0;
|
|
21
|
+
exports.isResetAction = exports.isPreferenceAction = exports.preferenceActionCreators = exports.PREFERENCE_ACTION_TYPES = void 0;
|
|
22
|
+
// ============================================================================
|
|
23
|
+
// ACTION TYPES ENUM
|
|
24
|
+
// ============================================================================
|
|
4
25
|
var PREFERENCE_ACTION_TYPES;
|
|
5
26
|
(function (PREFERENCE_ACTION_TYPES) {
|
|
27
|
+
// Reset Actions
|
|
6
28
|
PREFERENCE_ACTION_TYPES["CLEAR_ERRORS"] = "CLEAR_ERRORS";
|
|
7
29
|
PREFERENCE_ACTION_TYPES["RESET_FORM"] = "RESET_FORM";
|
|
8
|
-
|
|
30
|
+
// Data Management Actions
|
|
9
31
|
PREFERENCE_ACTION_TYPES["SET_CURRENCIES"] = "SET_CURRENCIES";
|
|
32
|
+
PREFERENCE_ACTION_TYPES["SET_PREFERENCES"] = "SET_PREFERENCES";
|
|
33
|
+
PREFERENCE_ACTION_TYPES["SET_COUNT"] = "SET_COUNT";
|
|
34
|
+
// UI State Actions
|
|
35
|
+
PREFERENCE_ACTION_TYPES["SET_ACTIVE_TAB"] = "SET_ACTIVE_TAB";
|
|
10
36
|
PREFERENCE_ACTION_TYPES["SET_CURRENCY_UPDATE_ID"] = "SET_CURRENCY_UPDATE_ID";
|
|
11
37
|
PREFERENCE_ACTION_TYPES["SET_ERRORS"] = "SET_ERRORS";
|
|
12
38
|
PREFERENCE_ACTION_TYPES["SET_PREFERENCE"] = "SET_PREFERENCE";
|
|
13
|
-
PREFERENCE_ACTION_TYPES["SET_PREFERENCES"] = "SET_PREFERENCES";
|
|
14
|
-
PREFERENCE_ACTION_TYPES["SET_COUNT"] = "SET_COUNT";
|
|
15
39
|
})(PREFERENCE_ACTION_TYPES || (exports.PREFERENCE_ACTION_TYPES = PREFERENCE_ACTION_TYPES = {}));
|
|
40
|
+
// ============================================================================
|
|
41
|
+
// ACTION CREATORS (Optional Helper Functions)
|
|
42
|
+
// ============================================================================
|
|
43
|
+
/**
|
|
44
|
+
* Action creators for common preference operations
|
|
45
|
+
* These provide type-safe action creation with better developer experience
|
|
46
|
+
*/
|
|
47
|
+
exports.preferenceActionCreators = {
|
|
48
|
+
// Reset Actions
|
|
49
|
+
clearErrors: function () { return ({
|
|
50
|
+
type: PREFERENCE_ACTION_TYPES.CLEAR_ERRORS,
|
|
51
|
+
}); },
|
|
52
|
+
resetForm: function () { return ({
|
|
53
|
+
type: PREFERENCE_ACTION_TYPES.RESET_FORM,
|
|
54
|
+
}); },
|
|
55
|
+
// Data Actions
|
|
56
|
+
setCurrencies: function (currencies) { return ({
|
|
57
|
+
type: PREFERENCE_ACTION_TYPES.SET_CURRENCIES,
|
|
58
|
+
payload: { currencies: currencies },
|
|
59
|
+
}); },
|
|
60
|
+
setPreferences: function (preferences) { return ({
|
|
61
|
+
type: PREFERENCE_ACTION_TYPES.SET_PREFERENCES,
|
|
62
|
+
payload: { preferences: preferences },
|
|
63
|
+
}); },
|
|
64
|
+
setCount: function (count) { return ({
|
|
65
|
+
type: PREFERENCE_ACTION_TYPES.SET_COUNT,
|
|
66
|
+
payload: { count: count },
|
|
67
|
+
}); },
|
|
68
|
+
// UI Actions
|
|
69
|
+
setActiveTab: function (activeTab) { return ({
|
|
70
|
+
type: PREFERENCE_ACTION_TYPES.SET_ACTIVE_TAB,
|
|
71
|
+
payload: { activeTab: activeTab },
|
|
72
|
+
}); },
|
|
73
|
+
setCurrencyUpdateId: function (currencyUpdateId) { return ({
|
|
74
|
+
type: PREFERENCE_ACTION_TYPES.SET_CURRENCY_UPDATE_ID,
|
|
75
|
+
payload: { currencyUpdateId: currencyUpdateId },
|
|
76
|
+
}); },
|
|
77
|
+
setErrors: function (errors) { return ({
|
|
78
|
+
type: PREFERENCE_ACTION_TYPES.SET_ERRORS,
|
|
79
|
+
payload: { errors: errors },
|
|
80
|
+
}); },
|
|
81
|
+
setPreference: function (preference) { return ({
|
|
82
|
+
type: PREFERENCE_ACTION_TYPES.SET_PREFERENCE,
|
|
83
|
+
payload: { preference: preference },
|
|
84
|
+
}); },
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Runtime type guards for action validation
|
|
88
|
+
*/
|
|
89
|
+
var isPreferenceAction = function (action) {
|
|
90
|
+
return (typeof action === "object" &&
|
|
91
|
+
action !== null &&
|
|
92
|
+
"type" in action &&
|
|
93
|
+
Object.values(PREFERENCE_ACTION_TYPES).includes(action.type));
|
|
94
|
+
};
|
|
95
|
+
exports.isPreferenceAction = isPreferenceAction;
|
|
96
|
+
/**
|
|
97
|
+
* Type guard for reset actions
|
|
98
|
+
*/
|
|
99
|
+
var isResetAction = function (action) {
|
|
100
|
+
return (action.type === PREFERENCE_ACTION_TYPES.CLEAR_ERRORS ||
|
|
101
|
+
action.type === PREFERENCE_ACTION_TYPES.RESET_FORM);
|
|
102
|
+
};
|
|
103
|
+
exports.isResetAction = isResetAction;
|
|
104
|
+
// ============================================================================
|
|
105
|
+
// OPTIMIZATION SUMMARY
|
|
106
|
+
// ============================================================================
|
|
107
|
+
/*
|
|
108
|
+
* Actions File Optimizations Applied:
|
|
109
|
+
*
|
|
110
|
+
* 1. **Structural Organization**
|
|
111
|
+
* - Grouped action types by functionality in enum
|
|
112
|
+
* - Organized action interfaces into logical sections with clear headers
|
|
113
|
+
* - Added comprehensive JSDoc documentation for each action
|
|
114
|
+
*
|
|
115
|
+
* 2. **Type Safety Improvements**
|
|
116
|
+
* - Used Record<string, string> instead of generic object for errors
|
|
117
|
+
* - Added helper type guards for different action categories
|
|
118
|
+
* - Improved union type organization with comments
|
|
119
|
+
*
|
|
120
|
+
* 3. **Developer Experience**
|
|
121
|
+
* - Added action creator functions for type-safe action creation
|
|
122
|
+
* - Comprehensive JSDoc comments for all actions and sections
|
|
123
|
+
* - Clear naming conventions following Preference{Operation}{Target}Action pattern
|
|
124
|
+
*
|
|
125
|
+
* 4. **Code Quality**
|
|
126
|
+
* - Logical grouping of related actions by functionality
|
|
127
|
+
* - Consistent formatting and structure
|
|
128
|
+
* - Self-documenting code with clear purpose and organization
|
|
129
|
+
*
|
|
130
|
+
* 5. **Maintainability**
|
|
131
|
+
* - Easy to locate specific action types by section
|
|
132
|
+
* - Clear relationship between actions and their purposes
|
|
133
|
+
* - Modular structure for future extensions
|
|
134
|
+
*
|
|
135
|
+
* 6. **Performance Benefits**
|
|
136
|
+
* - Enum-based action types for better bundling
|
|
137
|
+
* - Type-safe action creators prevent runtime errors
|
|
138
|
+
* - Clear type relationships for better IDE support and intellisense
|
|
139
|
+
*/
|
|
@@ -1,41 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Preferences Constants
|
|
3
|
+
*
|
|
4
|
+
* This module defines all constants used throughout the Preferences module.
|
|
5
|
+
* Constants are organized by functionality and follow consistent naming patterns.
|
|
6
|
+
*
|
|
7
|
+
* Organization:
|
|
8
|
+
* - Page Configuration (pagination, limits)
|
|
9
|
+
* - API Routes (backend endpoints)
|
|
10
|
+
* - Dashboard Configuration (tabs, menu items)
|
|
11
|
+
* - Component Mapping (dashboard tabs map)
|
|
12
|
+
*
|
|
13
|
+
* Naming Convention: Descriptive names with clear purpose
|
|
14
|
+
*/
|
|
15
|
+
import { ReactNode } from "react";
|
|
16
|
+
/**
|
|
17
|
+
* Default page limit for pagination
|
|
18
|
+
*/
|
|
2
19
|
export declare const pageLimit: number;
|
|
20
|
+
/**
|
|
21
|
+
* API endpoints for preferences and related module operations
|
|
22
|
+
*/
|
|
23
|
+
export declare const PREFERENCE_API_ROUTES: {
|
|
24
|
+
readonly BRANCH: "/api/branch";
|
|
25
|
+
readonly BRANCHES: "/api/branches";
|
|
26
|
+
readonly BRANCH_BY_ID: "/api/branch/branch-by-id";
|
|
27
|
+
readonly CURRENCIES: "/api/currencies";
|
|
28
|
+
readonly CURRENCY: "/api/currency";
|
|
29
|
+
readonly CURRENCY_BY_ID: "/api/currency/currency-by-id";
|
|
30
|
+
readonly PAYMENT_MODE: "/api/payment-mode";
|
|
31
|
+
readonly PAYMENT_MODES: "/api/payment-modes";
|
|
32
|
+
readonly PAYMENT_MODE_BY_ID: "/api/payment-mode/payment-mode-by-id";
|
|
33
|
+
readonly PREFERENCE: "/api/preference";
|
|
34
|
+
readonly PREFERENCES: "/api/preferences";
|
|
35
|
+
readonly PREFERENCE_BY_ID: "/api/preference/preference-by-id";
|
|
36
|
+
readonly TAX: "/api/tax";
|
|
37
|
+
readonly TAXES: "/api/taxes";
|
|
38
|
+
readonly TAX_BY_ID: "/api/tax/tax-by-id";
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Initial menu items for dashboard navigation
|
|
42
|
+
* These represent the default menu structure for the application
|
|
43
|
+
*/
|
|
3
44
|
export declare const initialMenuItems: {
|
|
4
45
|
id: string;
|
|
5
46
|
label: string;
|
|
6
47
|
order: number;
|
|
7
48
|
preferenceId: string;
|
|
8
49
|
}[];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
CURRENCIES: string;
|
|
14
|
-
CURRENCY: string;
|
|
15
|
-
CURRENCY_BY_ID: string;
|
|
16
|
-
PAYMENT_MODE: string;
|
|
17
|
-
PAYMENT_MODES: string;
|
|
18
|
-
PAYMENT_MODE_BY_ID: string;
|
|
19
|
-
PREFERENCE: string;
|
|
20
|
-
PREFERENCES: string;
|
|
21
|
-
PREFERENCE_BY_ID: string;
|
|
22
|
-
TAX: string;
|
|
23
|
-
TAXES: string;
|
|
24
|
-
TAX_BY_ID: string;
|
|
25
|
-
};
|
|
26
|
-
export declare const toastErrors: {
|
|
27
|
-
fetchInvoiceError: string;
|
|
28
|
-
formSubmittedSuccess: string;
|
|
29
|
-
genericError: string;
|
|
30
|
-
networkError: string;
|
|
31
|
-
submitFormError: string;
|
|
32
|
-
validationError: string;
|
|
33
|
-
};
|
|
50
|
+
/**
|
|
51
|
+
* Mapping of dashboard tab names to their corresponding React components
|
|
52
|
+
* Used for dynamic rendering of preference management sections
|
|
53
|
+
*/
|
|
34
54
|
export declare const dashboardTabsMap: {
|
|
35
55
|
[key: string]: ReactNode;
|
|
36
56
|
};
|
|
37
|
-
export declare const taxValidationError: {
|
|
38
|
-
taxName: string;
|
|
39
|
-
taxRate: string;
|
|
40
|
-
description: string;
|
|
41
|
-
};
|