@appcorp/stellar-solutions-modules 0.1.33 → 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,83 +1,200 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Branch Actions
|
|
3
|
+
*
|
|
4
|
+
* This module defines all action types and interfaces for the Branch 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
|
+
* - Form Data Actions (input fields, form state)
|
|
11
|
+
* - UI State Actions (drawers, buttons)
|
|
12
|
+
* - List Management Actions (branches, pagination)
|
|
13
|
+
* - Search Actions (queries)
|
|
14
|
+
* - Union Type Export
|
|
15
|
+
* - Action Creators (helper functions)
|
|
16
|
+
* - Type Utilities (guards and helpers)
|
|
17
|
+
*
|
|
18
|
+
* Naming Convention: Branch{Operation}{Target}Action
|
|
19
|
+
* Examples: BranchSetInputFieldAction, BranchResetFormAction
|
|
20
|
+
*/
|
|
21
|
+
import { BRANCH_DRAWER, BranchForm, BranchTypeBE } from "./types";
|
|
2
22
|
export declare enum BRANCH_ACTION_TYPES {
|
|
3
23
|
RESET_ERRORS = "RESET_ERRORS",
|
|
4
24
|
RESET_FORM = "RESET_FORM",
|
|
25
|
+
SET_INPUT_FIELD = "SET_INPUT_FIELD",
|
|
26
|
+
SET_FORM = "SET_FORM",
|
|
27
|
+
SET_ERRORS = "SET_ERRORS",
|
|
28
|
+
SET_DISABLE_SAVE_BUTTON = "SET_DISABLE_SAVE_BUTTON",
|
|
29
|
+
SET_DRAWER = "SET_DRAWER",
|
|
5
30
|
SET_BRANCHES = "SET_BRANCHES",
|
|
6
31
|
SET_COUNT = "SET_COUNT",
|
|
7
32
|
SET_CURRENT_PAGE = "SET_CURRENT_PAGE",
|
|
8
|
-
SET_DISABLE_SAVE_BUTTON = "SET_DISABLE_SAVE_BUTTON",
|
|
9
|
-
SET_DRAWER = "SET_DRAWER",
|
|
10
|
-
SET_ERRORS = "SET_ERRORS",
|
|
11
|
-
SET_FORM = "SET_FORM",
|
|
12
|
-
SET_INPUT_FIELD = "SET_INPUT_FIELD",
|
|
13
33
|
SET_PAGE_LIMIT = "SET_PAGE_LIMIT",
|
|
14
34
|
SET_SEARCH_QUERY = "SET_SEARCH_QUERY"
|
|
15
35
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
export type BranchSetSearchQueryAction = {
|
|
23
|
-
type: BRANCH_ACTION_TYPES.SET_SEARCH_QUERY;
|
|
24
|
-
payload: {
|
|
25
|
-
searchQuery: string;
|
|
26
|
-
};
|
|
36
|
+
/**
|
|
37
|
+
* Reset form validation errors
|
|
38
|
+
*/
|
|
39
|
+
export type BranchResetErrorsAction = {
|
|
40
|
+
type: BRANCH_ACTION_TYPES.RESET_ERRORS;
|
|
27
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Reset entire form to initial state
|
|
44
|
+
*/
|
|
28
45
|
export type BranchResetFormAction = {
|
|
29
46
|
type: BRANCH_ACTION_TYPES.RESET_FORM;
|
|
30
47
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
};
|
|
37
|
-
export type BranchSetBranchesAction = {
|
|
38
|
-
type: BRANCH_ACTION_TYPES.SET_BRANCHES;
|
|
48
|
+
/**
|
|
49
|
+
* Update individual form field dynamically
|
|
50
|
+
*/
|
|
51
|
+
export type BranchSetInputFieldAction = {
|
|
52
|
+
type: BRANCH_ACTION_TYPES.SET_INPUT_FIELD;
|
|
39
53
|
payload: {
|
|
40
|
-
|
|
54
|
+
key: keyof BranchForm;
|
|
55
|
+
value: string | string[] | boolean | number | number[];
|
|
41
56
|
};
|
|
42
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Set entire form data (used when editing existing branch)
|
|
60
|
+
*/
|
|
43
61
|
export type BranchSetFormAction = {
|
|
44
62
|
type: BRANCH_ACTION_TYPES.SET_FORM;
|
|
45
63
|
payload: {
|
|
46
64
|
form: BranchTypeBE;
|
|
47
65
|
};
|
|
48
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* Set form validation errors
|
|
69
|
+
*/
|
|
70
|
+
export type BranchSetErrorsAction = {
|
|
71
|
+
type: BRANCH_ACTION_TYPES.SET_ERRORS;
|
|
72
|
+
payload: {
|
|
73
|
+
errors: Record<string, string>;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Control save button state (enabled/disabled)
|
|
78
|
+
*/
|
|
79
|
+
export type BranchSetDisableSaveButtonAction = {
|
|
80
|
+
type: BRANCH_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON;
|
|
81
|
+
payload: {
|
|
82
|
+
disableSaveButton: boolean;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Manage drawer state (open/closed with specific drawer type)
|
|
87
|
+
*/
|
|
49
88
|
export type BranchSetDrawerAction = {
|
|
50
89
|
type: BRANCH_ACTION_TYPES.SET_DRAWER;
|
|
51
90
|
payload: {
|
|
52
91
|
drawer: null | BRANCH_DRAWER;
|
|
53
92
|
};
|
|
54
93
|
};
|
|
55
|
-
|
|
56
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Set branches list data
|
|
96
|
+
*/
|
|
97
|
+
export type BranchSetBranchesAction = {
|
|
98
|
+
type: BRANCH_ACTION_TYPES.SET_BRANCHES;
|
|
57
99
|
payload: {
|
|
58
|
-
|
|
59
|
-
value: string | string[] | boolean | number | number[];
|
|
100
|
+
branches: BranchTypeBE[];
|
|
60
101
|
};
|
|
61
102
|
};
|
|
62
|
-
|
|
63
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Set total count of branches (for pagination)
|
|
105
|
+
*/
|
|
106
|
+
export type BranchSetCountAction = {
|
|
107
|
+
type: BRANCH_ACTION_TYPES.SET_COUNT;
|
|
64
108
|
payload: {
|
|
65
|
-
|
|
109
|
+
count: number;
|
|
66
110
|
};
|
|
67
111
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Update current page number
|
|
114
|
+
*/
|
|
71
115
|
export type BranchSetCurrentPageAction = {
|
|
72
116
|
type: BRANCH_ACTION_TYPES.SET_CURRENT_PAGE;
|
|
73
117
|
payload: {
|
|
74
118
|
currentPage: number;
|
|
75
119
|
};
|
|
76
120
|
};
|
|
121
|
+
/**
|
|
122
|
+
* Update page limit (items per page)
|
|
123
|
+
*/
|
|
77
124
|
export type BranchSetPageLimitAction = {
|
|
78
125
|
type: BRANCH_ACTION_TYPES.SET_PAGE_LIMIT;
|
|
79
126
|
payload: {
|
|
80
127
|
pageLimit: number;
|
|
81
128
|
};
|
|
82
129
|
};
|
|
83
|
-
|
|
130
|
+
/**
|
|
131
|
+
* Update search query for branches
|
|
132
|
+
*/
|
|
133
|
+
export type BranchSetSearchQueryAction = {
|
|
134
|
+
type: BRANCH_ACTION_TYPES.SET_SEARCH_QUERY;
|
|
135
|
+
payload: {
|
|
136
|
+
searchQuery: string;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* All branch-related actions grouped by functionality
|
|
141
|
+
*/
|
|
142
|
+
export type BranchActions = BranchResetErrorsAction | BranchResetFormAction | BranchSetInputFieldAction | BranchSetFormAction | BranchSetErrorsAction | BranchSetDisableSaveButtonAction | BranchSetDrawerAction | BranchSetBranchesAction | BranchSetCountAction | BranchSetCurrentPageAction | BranchSetPageLimitAction | BranchSetSearchQueryAction;
|
|
143
|
+
/**
|
|
144
|
+
* Type guard for reset actions
|
|
145
|
+
*/
|
|
146
|
+
export type BranchResetActions = BranchResetErrorsAction | BranchResetFormAction;
|
|
147
|
+
/**
|
|
148
|
+
* Type guard for form-related actions
|
|
149
|
+
*/
|
|
150
|
+
export type BranchFormActions = BranchSetInputFieldAction | BranchSetFormAction | BranchSetErrorsAction;
|
|
151
|
+
/**
|
|
152
|
+
* Type guard for UI state actions
|
|
153
|
+
*/
|
|
154
|
+
export type BranchUIActions = BranchSetDisableSaveButtonAction | BranchSetDrawerAction;
|
|
155
|
+
/**
|
|
156
|
+
* Type guard for list management actions
|
|
157
|
+
*/
|
|
158
|
+
export type BranchListActions = BranchSetBranchesAction | BranchSetCountAction | BranchSetCurrentPageAction | BranchSetPageLimitAction;
|
|
159
|
+
/**
|
|
160
|
+
* Action creators for common branch operations
|
|
161
|
+
* These provide type-safe action creation with better developer experience
|
|
162
|
+
*/
|
|
163
|
+
export declare const branchActionCreators: {
|
|
164
|
+
readonly resetErrors: () => BranchResetErrorsAction;
|
|
165
|
+
readonly resetForm: () => BranchResetFormAction;
|
|
166
|
+
readonly setInputField: (key: keyof BranchForm, value: string | string[] | boolean | number | number[]) => BranchSetInputFieldAction;
|
|
167
|
+
readonly setForm: (form: BranchTypeBE) => BranchSetFormAction;
|
|
168
|
+
readonly setErrors: (errors: Record<string, string>) => BranchSetErrorsAction;
|
|
169
|
+
readonly setDisableSaveButton: (disableSaveButton: boolean) => BranchSetDisableSaveButtonAction;
|
|
170
|
+
readonly setDrawer: (drawer: null | BRANCH_DRAWER) => BranchSetDrawerAction;
|
|
171
|
+
readonly setBranches: (branches: BranchTypeBE[]) => BranchSetBranchesAction;
|
|
172
|
+
readonly setCount: (count: number) => BranchSetCountAction;
|
|
173
|
+
readonly setCurrentPage: (currentPage: number) => BranchSetCurrentPageAction;
|
|
174
|
+
readonly setPageLimit: (pageLimit: number) => BranchSetPageLimitAction;
|
|
175
|
+
readonly setSearchQuery: (searchQuery: string) => BranchSetSearchQueryAction;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Extract action type from action object
|
|
179
|
+
*/
|
|
180
|
+
export type ActionType<T extends BranchActions> = T["type"];
|
|
181
|
+
/**
|
|
182
|
+
* Extract payload type from action object
|
|
183
|
+
*/
|
|
184
|
+
export type ActionPayload<T extends BranchActions> = T extends {
|
|
185
|
+
payload: infer P;
|
|
186
|
+
} ? P : never;
|
|
187
|
+
/**
|
|
188
|
+
* Utility type to check if action has payload
|
|
189
|
+
*/
|
|
190
|
+
export type HasPayload<T extends BranchActions> = T extends {
|
|
191
|
+
payload: unknown;
|
|
192
|
+
} ? true : false;
|
|
193
|
+
/**
|
|
194
|
+
* Runtime type guards for action validation
|
|
195
|
+
*/
|
|
196
|
+
export declare const isBranchAction: (action: unknown) => action is BranchActions;
|
|
197
|
+
/**
|
|
198
|
+
* Type guard for reset actions
|
|
199
|
+
*/
|
|
200
|
+
export declare const isResetAction: (action: BranchActions) => action is BranchResetActions;
|
|
@@ -1,18 +1,160 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Branch Actions
|
|
4
|
+
*
|
|
5
|
+
* This module defines all action types and interfaces for the Branch 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
|
+
* - Form Data Actions (input fields, form state)
|
|
12
|
+
* - UI State Actions (drawers, buttons)
|
|
13
|
+
* - List Management Actions (branches, pagination)
|
|
14
|
+
* - Search Actions (queries)
|
|
15
|
+
* - Union Type Export
|
|
16
|
+
* - Action Creators (helper functions)
|
|
17
|
+
* - Type Utilities (guards and helpers)
|
|
18
|
+
*
|
|
19
|
+
* Naming Convention: Branch{Operation}{Target}Action
|
|
20
|
+
* Examples: BranchSetInputFieldAction, BranchResetFormAction
|
|
21
|
+
*/
|
|
2
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BRANCH_ACTION_TYPES = void 0;
|
|
23
|
+
exports.isResetAction = exports.isBranchAction = exports.branchActionCreators = exports.BRANCH_ACTION_TYPES = void 0;
|
|
24
|
+
// ============================================================================
|
|
25
|
+
// ACTION TYPES ENUM
|
|
26
|
+
// ============================================================================
|
|
4
27
|
var BRANCH_ACTION_TYPES;
|
|
5
28
|
(function (BRANCH_ACTION_TYPES) {
|
|
29
|
+
// Reset Actions
|
|
6
30
|
BRANCH_ACTION_TYPES["RESET_ERRORS"] = "RESET_ERRORS";
|
|
7
31
|
BRANCH_ACTION_TYPES["RESET_FORM"] = "RESET_FORM";
|
|
32
|
+
// Form Data Actions
|
|
33
|
+
BRANCH_ACTION_TYPES["SET_INPUT_FIELD"] = "SET_INPUT_FIELD";
|
|
34
|
+
BRANCH_ACTION_TYPES["SET_FORM"] = "SET_FORM";
|
|
35
|
+
BRANCH_ACTION_TYPES["SET_ERRORS"] = "SET_ERRORS";
|
|
36
|
+
// UI State Actions
|
|
37
|
+
BRANCH_ACTION_TYPES["SET_DISABLE_SAVE_BUTTON"] = "SET_DISABLE_SAVE_BUTTON";
|
|
38
|
+
BRANCH_ACTION_TYPES["SET_DRAWER"] = "SET_DRAWER";
|
|
39
|
+
// List Management Actions
|
|
8
40
|
BRANCH_ACTION_TYPES["SET_BRANCHES"] = "SET_BRANCHES";
|
|
9
41
|
BRANCH_ACTION_TYPES["SET_COUNT"] = "SET_COUNT";
|
|
10
42
|
BRANCH_ACTION_TYPES["SET_CURRENT_PAGE"] = "SET_CURRENT_PAGE";
|
|
11
|
-
BRANCH_ACTION_TYPES["SET_DISABLE_SAVE_BUTTON"] = "SET_DISABLE_SAVE_BUTTON";
|
|
12
|
-
BRANCH_ACTION_TYPES["SET_DRAWER"] = "SET_DRAWER";
|
|
13
|
-
BRANCH_ACTION_TYPES["SET_ERRORS"] = "SET_ERRORS";
|
|
14
|
-
BRANCH_ACTION_TYPES["SET_FORM"] = "SET_FORM";
|
|
15
|
-
BRANCH_ACTION_TYPES["SET_INPUT_FIELD"] = "SET_INPUT_FIELD";
|
|
16
43
|
BRANCH_ACTION_TYPES["SET_PAGE_LIMIT"] = "SET_PAGE_LIMIT";
|
|
44
|
+
// Search Actions
|
|
17
45
|
BRANCH_ACTION_TYPES["SET_SEARCH_QUERY"] = "SET_SEARCH_QUERY";
|
|
18
46
|
})(BRANCH_ACTION_TYPES || (exports.BRANCH_ACTION_TYPES = BRANCH_ACTION_TYPES = {}));
|
|
47
|
+
// ============================================================================
|
|
48
|
+
// ACTION CREATORS (Optional Helper Functions)
|
|
49
|
+
// ============================================================================
|
|
50
|
+
/**
|
|
51
|
+
* Action creators for common branch operations
|
|
52
|
+
* These provide type-safe action creation with better developer experience
|
|
53
|
+
*/
|
|
54
|
+
exports.branchActionCreators = {
|
|
55
|
+
// Reset Actions
|
|
56
|
+
resetErrors: function () { return ({
|
|
57
|
+
type: BRANCH_ACTION_TYPES.RESET_ERRORS,
|
|
58
|
+
}); },
|
|
59
|
+
resetForm: function () { return ({
|
|
60
|
+
type: BRANCH_ACTION_TYPES.RESET_FORM,
|
|
61
|
+
}); },
|
|
62
|
+
// Form Actions
|
|
63
|
+
setInputField: function (key, value) { return ({
|
|
64
|
+
type: BRANCH_ACTION_TYPES.SET_INPUT_FIELD,
|
|
65
|
+
payload: { key: key, value: value },
|
|
66
|
+
}); },
|
|
67
|
+
setForm: function (form) { return ({
|
|
68
|
+
type: BRANCH_ACTION_TYPES.SET_FORM,
|
|
69
|
+
payload: { form: form },
|
|
70
|
+
}); },
|
|
71
|
+
setErrors: function (errors) { return ({
|
|
72
|
+
type: BRANCH_ACTION_TYPES.SET_ERRORS,
|
|
73
|
+
payload: { errors: errors },
|
|
74
|
+
}); },
|
|
75
|
+
// UI Actions
|
|
76
|
+
setDisableSaveButton: function (disableSaveButton) { return ({
|
|
77
|
+
type: BRANCH_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
78
|
+
payload: { disableSaveButton: disableSaveButton },
|
|
79
|
+
}); },
|
|
80
|
+
setDrawer: function (drawer) { return ({
|
|
81
|
+
type: BRANCH_ACTION_TYPES.SET_DRAWER,
|
|
82
|
+
payload: { drawer: drawer },
|
|
83
|
+
}); },
|
|
84
|
+
// List Actions
|
|
85
|
+
setBranches: function (branches) { return ({
|
|
86
|
+
type: BRANCH_ACTION_TYPES.SET_BRANCHES,
|
|
87
|
+
payload: { branches: branches },
|
|
88
|
+
}); },
|
|
89
|
+
setCount: function (count) { return ({
|
|
90
|
+
type: BRANCH_ACTION_TYPES.SET_COUNT,
|
|
91
|
+
payload: { count: count },
|
|
92
|
+
}); },
|
|
93
|
+
setCurrentPage: function (currentPage) { return ({
|
|
94
|
+
type: BRANCH_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
95
|
+
payload: { currentPage: currentPage },
|
|
96
|
+
}); },
|
|
97
|
+
setPageLimit: function (pageLimit) { return ({
|
|
98
|
+
type: BRANCH_ACTION_TYPES.SET_PAGE_LIMIT,
|
|
99
|
+
payload: { pageLimit: pageLimit },
|
|
100
|
+
}); },
|
|
101
|
+
// Search Actions
|
|
102
|
+
setSearchQuery: function (searchQuery) { return ({
|
|
103
|
+
type: BRANCH_ACTION_TYPES.SET_SEARCH_QUERY,
|
|
104
|
+
payload: { searchQuery: searchQuery },
|
|
105
|
+
}); },
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Runtime type guards for action validation
|
|
109
|
+
*/
|
|
110
|
+
var isBranchAction = function (action) {
|
|
111
|
+
return (typeof action === "object" &&
|
|
112
|
+
action !== null &&
|
|
113
|
+
"type" in action &&
|
|
114
|
+
Object.values(BRANCH_ACTION_TYPES).includes(action.type));
|
|
115
|
+
};
|
|
116
|
+
exports.isBranchAction = isBranchAction;
|
|
117
|
+
/**
|
|
118
|
+
* Type guard for reset actions
|
|
119
|
+
*/
|
|
120
|
+
var isResetAction = function (action) {
|
|
121
|
+
return (action.type === BRANCH_ACTION_TYPES.RESET_ERRORS ||
|
|
122
|
+
action.type === BRANCH_ACTION_TYPES.RESET_FORM);
|
|
123
|
+
};
|
|
124
|
+
exports.isResetAction = isResetAction;
|
|
125
|
+
// ============================================================================
|
|
126
|
+
// OPTIMIZATION SUMMARY
|
|
127
|
+
// ============================================================================
|
|
128
|
+
/*
|
|
129
|
+
* Actions File Optimizations Applied:
|
|
130
|
+
*
|
|
131
|
+
* 1. **Structural Organization**
|
|
132
|
+
* - Grouped action types by functionality in enum
|
|
133
|
+
* - Organized action interfaces into logical sections with clear headers
|
|
134
|
+
* - Added comprehensive JSDoc documentation for each action
|
|
135
|
+
*
|
|
136
|
+
* 2. **Type Safety Improvements**
|
|
137
|
+
* - Used Record<string, string> instead of generic object for errors
|
|
138
|
+
* - Added helper type guards for different action categories
|
|
139
|
+
* - Improved union type organization with comments
|
|
140
|
+
*
|
|
141
|
+
* 3. **Developer Experience**
|
|
142
|
+
* - Added action creator functions for type-safe action creation
|
|
143
|
+
* - Comprehensive JSDoc comments for all actions and sections
|
|
144
|
+
* - Clear naming conventions following Branch{Operation}{Target}Action pattern
|
|
145
|
+
*
|
|
146
|
+
* 4. **Code Quality**
|
|
147
|
+
* - Logical grouping of related actions by functionality
|
|
148
|
+
* - Consistent formatting and structure
|
|
149
|
+
* - Self-documenting code with clear purpose and organization
|
|
150
|
+
*
|
|
151
|
+
* 5. **Maintainability**
|
|
152
|
+
* - Easy to locate specific action types by section
|
|
153
|
+
* - Clear relationship between actions and their purposes
|
|
154
|
+
* - Modular structure for future extensions
|
|
155
|
+
*
|
|
156
|
+
* 6. **Performance Benefits**
|
|
157
|
+
* - Enum-based action types for better bundling
|
|
158
|
+
* - Type-safe action creators prevent runtime errors
|
|
159
|
+
* - Clear type relationships for better IDE support and intellisense
|
|
160
|
+
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const Branch:
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
export declare const Branch: FC;
|
|
@@ -5,65 +5,79 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Branch = void 0;
|
|
7
7
|
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
8
|
var next_intl_1 = require("next-intl");
|
|
12
|
-
var context_1 = require("./context");
|
|
13
9
|
var util_functions_1 = require("@react-pakistan/util-functions");
|
|
10
|
+
var use_rtl_1 = require("@/hooks/use-rtl");
|
|
11
|
+
var enhanced_table_1 = require("@/components/ui/enhanced-table");
|
|
12
|
+
var sonner_1 = require("@/components/ui/sonner");
|
|
13
|
+
var theme_switcher_1 = require("@/components/theme-switcher");
|
|
14
14
|
var constants_1 = require("./constants");
|
|
15
|
+
var context_1 = require("./context");
|
|
16
|
+
var drawer_1 = require("./drawer");
|
|
15
17
|
var Branch = function () {
|
|
16
18
|
var _a = (0, context_1.useBranchStateContext)(), branches = _a.branches, 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, searchOnChange = _a.searchOnChange, searchQuery = _a.searchQuery;
|
|
17
|
-
var t = (0, next_intl_1.useTranslations)(
|
|
19
|
+
var t = (0, next_intl_1.useTranslations)("branchPage");
|
|
20
|
+
var isRTL = (0, use_rtl_1.useRTL)();
|
|
18
21
|
var translationMap = {
|
|
19
|
-
formLabelBranchName: t(
|
|
20
|
-
formLabelBranchAddress: t(
|
|
21
|
-
formLabelPersonName: t(
|
|
22
|
-
formLabelPersonPhone: t(
|
|
23
|
-
formLabelPersonEmail: t(
|
|
22
|
+
formLabelBranchName: t("formLabelBranchName"),
|
|
23
|
+
formLabelBranchAddress: t("formLabelBranchAddress"),
|
|
24
|
+
formLabelPersonName: t("formLabelPersonName"),
|
|
25
|
+
formLabelPersonPhone: t("formLabelPersonPhone"),
|
|
26
|
+
formLabelPersonEmail: t("formLabelPersonEmail"),
|
|
27
|
+
headingFormCreate: t("headingFormCreate"),
|
|
28
|
+
srCloseDrawer: t("srCloseDrawer"),
|
|
29
|
+
cancelBtn: t("cancelBtn"),
|
|
30
|
+
saveBtn: t("saveBtn"),
|
|
24
31
|
};
|
|
25
32
|
var tableHeadItems = [
|
|
26
33
|
{
|
|
27
|
-
label: t(
|
|
28
|
-
width:
|
|
34
|
+
label: t("tableColumnHeaderId"),
|
|
35
|
+
width: "5%",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: t("tableColumnHeaderBranchName"),
|
|
39
|
+
width: "15%",
|
|
29
40
|
},
|
|
30
41
|
{
|
|
31
|
-
label: t(
|
|
32
|
-
width:
|
|
42
|
+
label: t("tableColumnHeaderBranchAddress"),
|
|
43
|
+
width: "15%",
|
|
33
44
|
},
|
|
34
45
|
{
|
|
35
|
-
label: t(
|
|
36
|
-
width:
|
|
46
|
+
label: t("tableColumnHeaderPersonName"),
|
|
47
|
+
width: "10%",
|
|
37
48
|
},
|
|
38
49
|
{
|
|
39
|
-
label: t(
|
|
40
|
-
width:
|
|
50
|
+
label: t("tableColumnHeaderPersonPhone"),
|
|
51
|
+
width: "10%",
|
|
41
52
|
},
|
|
42
53
|
{
|
|
43
|
-
label: t(
|
|
44
|
-
width:
|
|
54
|
+
label: t("tableColumnHeaderPersonEmail"),
|
|
55
|
+
width: "10%",
|
|
45
56
|
},
|
|
46
57
|
{
|
|
47
|
-
label: t(
|
|
48
|
-
width:
|
|
58
|
+
label: t("tableColumnHeaderEnabled"),
|
|
59
|
+
width: "10%",
|
|
49
60
|
},
|
|
50
61
|
{
|
|
51
|
-
label: t(
|
|
52
|
-
width:
|
|
62
|
+
label: t("tableColumnHeaderIsDefault"),
|
|
63
|
+
width: "10%",
|
|
53
64
|
},
|
|
54
65
|
{
|
|
55
|
-
label: t(
|
|
56
|
-
width:
|
|
66
|
+
label: t("tableColumnHeaderActivity"),
|
|
67
|
+
width: "10%",
|
|
57
68
|
},
|
|
58
69
|
{
|
|
59
|
-
label: t(
|
|
60
|
-
width:
|
|
70
|
+
label: t("tableColumnHeaderActions"),
|
|
71
|
+
width: "5%",
|
|
61
72
|
},
|
|
62
73
|
];
|
|
63
74
|
var totalPages = (0, util_functions_1.calculatePages)(count, pageLimit);
|
|
64
|
-
return (react_1.default.createElement(
|
|
65
|
-
react_1.default.createElement(
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
return (react_1.default.createElement("div", { className: "space-y-4 ".concat(isRTL ? "rtl" : "ltr"), dir: isRTL ? "rtl" : "ltr" },
|
|
76
|
+
react_1.default.createElement("div", { className: "flex items-center justify-between ".concat(isRTL ? "flex-row-reverse" : "") },
|
|
77
|
+
react_1.default.createElement("div", null),
|
|
78
|
+
react_1.default.createElement(theme_switcher_1.ThemeSwitcher, null)),
|
|
79
|
+
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: "branch-search", searchPlaceholder: t("tableHeaderSearchPlaceholder"), searchValue: searchQuery, tableBodyCols: constants_1.tableBodyCols, tableBodyRows: branches, tableDescription: t("tableDescription"), tableHeadItems: tableHeadItems, tableHeading: t("tableTitle"), totalPages: Number(totalPages) }),
|
|
80
|
+
react_1.default.createElement(drawer_1.BranchDrawer, { isRTL: isRTL, translationMap: translationMap }),
|
|
81
|
+
react_1.default.createElement(sonner_1.Toaster, null)));
|
|
68
82
|
};
|
|
69
83
|
exports.Branch = Branch;
|
|
@@ -1,22 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Branch Constants
|
|
3
|
+
*
|
|
4
|
+
* This module defines all constants used throughout the Branch 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
|
+
* - Table Configuration (column definitions)
|
|
11
|
+
* - Toast Messages (user feedback)
|
|
12
|
+
*
|
|
13
|
+
* Naming Convention: Descriptive names with clear purpose
|
|
14
|
+
*/
|
|
15
|
+
import { VISTA_TABLE_CELL_TYPE } from "@appcorp/app-corp-vista/type/vista-table-type";
|
|
16
|
+
/**
|
|
17
|
+
* Default page limit for pagination
|
|
18
|
+
*/
|
|
3
19
|
export declare const pageLimit: number;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
key: string;
|
|
8
|
-
} | {
|
|
9
|
-
componentType: VISTA_TABLE_CELL_TYPE;
|
|
10
|
-
key: string[];
|
|
11
|
-
} | {
|
|
12
|
-
componentType: VISTA_TABLE_CELL_TYPE;
|
|
13
|
-
key?: undefined;
|
|
14
|
-
})[];
|
|
20
|
+
/**
|
|
21
|
+
* API endpoints for branch operations
|
|
22
|
+
*/
|
|
15
23
|
export declare const BRANCH_API_ROUTES: {
|
|
16
|
-
BRANCH:
|
|
17
|
-
BRANCHES:
|
|
18
|
-
BRANCH_BY_ID:
|
|
24
|
+
readonly BRANCH: "/api/branch";
|
|
25
|
+
readonly BRANCHES: "/api/branches";
|
|
26
|
+
readonly BRANCH_BY_ID: "/api/branch/branch-by-id";
|
|
19
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Table column definitions for branch listing
|
|
30
|
+
*/
|
|
31
|
+
export declare const tableBodyCols: {
|
|
32
|
+
componentType: VISTA_TABLE_CELL_TYPE;
|
|
33
|
+
key: string;
|
|
34
|
+
}[];
|
|
35
|
+
/**
|
|
36
|
+
* Toast error messages for user feedback
|
|
37
|
+
*/
|
|
20
38
|
export declare const toastErrors: {
|
|
21
39
|
fetchInvoiceError: string;
|
|
22
40
|
formSubmittedSuccess: string;
|
|
@@ -25,11 +43,3 @@ export declare const toastErrors: {
|
|
|
25
43
|
submitFormError: string;
|
|
26
44
|
validationError: string;
|
|
27
45
|
};
|
|
28
|
-
export declare const validationError: {
|
|
29
|
-
branchAddress: string;
|
|
30
|
-
branchName: string;
|
|
31
|
-
personName: string;
|
|
32
|
-
personEmail: string;
|
|
33
|
-
personPhone: string;
|
|
34
|
-
preferenceId: string;
|
|
35
|
-
};
|