@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.
Files changed (157) hide show
  1. package/README.md +128 -19
  2. package/components/theme-switcher.d.ts +4 -0
  3. package/components/theme-switcher.js +60 -0
  4. package/components/ui/badge.d.ts +9 -0
  5. package/components/ui/badge.js +82 -0
  6. package/components/ui/button.d.ts +10 -0
  7. package/components/ui/button.js +91 -0
  8. package/components/ui/checkbox.d.ts +9 -0
  9. package/components/ui/checkbox.js +87 -0
  10. package/components/ui/drawer.d.ts +13 -0
  11. package/components/ui/drawer.js +115 -0
  12. package/components/ui/dropdown-menu.d.ts +25 -0
  13. package/components/ui/dropdown-menu.js +148 -0
  14. package/components/ui/enhanced-table-footer-action.d.ts +34 -0
  15. package/components/ui/enhanced-table-footer-action.js +117 -0
  16. package/components/ui/enhanced-table-footer-page.d.ts +32 -0
  17. package/components/ui/enhanced-table-footer-page.js +140 -0
  18. package/components/ui/enhanced-table-footer-pagination.d.ts +38 -0
  19. package/components/ui/enhanced-table-footer-pagination.js +122 -0
  20. package/components/ui/enhanced-table-header-action.d.ts +7 -0
  21. package/components/ui/enhanced-table-header-action.js +21 -0
  22. package/components/ui/enhanced-table-header-search.d.ts +12 -0
  23. package/components/ui/enhanced-table-header-search.js +17 -0
  24. package/components/ui/enhanced-table.d.ts +65 -0
  25. package/components/ui/enhanced-table.js +87 -0
  26. package/components/ui/input.d.ts +8 -0
  27. package/components/ui/input.js +86 -0
  28. package/components/ui/label.d.ts +7 -0
  29. package/components/ui/label.js +68 -0
  30. package/components/ui/popover.d.ts +7 -0
  31. package/components/ui/popover.js +82 -0
  32. package/components/ui/select.d.ts +15 -0
  33. package/components/ui/select.js +127 -0
  34. package/components/ui/sonner.d.ts +4 -0
  35. package/components/ui/sonner.js +54 -0
  36. package/components/ui/switch.d.ts +9 -0
  37. package/components/ui/switch.js +89 -0
  38. package/components/ui/table.d.ts +10 -0
  39. package/components/ui/table.js +101 -0
  40. package/global-modules/bank/actions.d.ts +200 -0
  41. package/global-modules/bank/actions.js +124 -0
  42. package/global-modules/bank/bank.d.ts +2 -0
  43. package/global-modules/bank/bank.js +87 -0
  44. package/global-modules/bank/constants.d.ts +45 -0
  45. package/global-modules/bank/constants.js +98 -0
  46. package/global-modules/bank/context.d.ts +41 -0
  47. package/global-modules/bank/context.js +419 -0
  48. package/global-modules/bank/drawer.d.ts +31 -0
  49. package/global-modules/bank/drawer.js +114 -0
  50. package/global-modules/bank/form.d.ts +22 -0
  51. package/global-modules/bank/form.js +68 -0
  52. package/global-modules/bank/reducer.d.ts +25 -0
  53. package/global-modules/bank/reducer.js +161 -0
  54. package/global-modules/bank/types.d.ts +217 -0
  55. package/global-modules/bank/types.js +81 -0
  56. package/global-modules/bank/validate.d.ts +13 -0
  57. package/global-modules/bank/validate.js +22 -0
  58. package/global-modules/branch/actions.d.ts +154 -37
  59. package/global-modules/branch/actions.js +148 -6
  60. package/global-modules/branch/branch.d.ts +2 -2
  61. package/global-modules/branch/branch.js +46 -32
  62. package/global-modules/branch/constants.d.ts +34 -24
  63. package/global-modules/branch/constants.js +101 -122
  64. package/global-modules/branch/context.d.ts +33 -2
  65. package/global-modules/branch/context.js +195 -164
  66. package/global-modules/branch/drawer.d.ts +26 -3
  67. package/global-modules/branch/drawer.js +101 -6
  68. package/global-modules/branch/form.d.ts +15 -1
  69. package/global-modules/branch/form.js +54 -71
  70. package/global-modules/branch/reducer.d.ts +23 -2
  71. package/global-modules/branch/reducer.js +148 -118
  72. package/global-modules/branch/types.d.ts +196 -69
  73. package/global-modules/branch/types.js +66 -7
  74. package/global-modules/branch/validate.d.ts +1 -1
  75. package/global-modules/branch/validate.js +15 -11
  76. package/global-modules/payment-mode/actions.d.ts +154 -37
  77. package/global-modules/payment-mode/actions.js +148 -6
  78. package/global-modules/payment-mode/constants.d.ts +34 -17
  79. package/global-modules/payment-mode/constants.js +90 -66
  80. package/global-modules/payment-mode/context.d.ts +33 -2
  81. package/global-modules/payment-mode/context.js +185 -163
  82. package/global-modules/payment-mode/drawer.d.ts +26 -3
  83. package/global-modules/payment-mode/drawer.js +104 -9
  84. package/global-modules/payment-mode/form.d.ts +16 -2
  85. package/global-modules/payment-mode/form.js +45 -74
  86. package/global-modules/payment-mode/payment-mode.d.ts +25 -2
  87. package/global-modules/payment-mode/payment-mode.js +90 -23
  88. package/global-modules/payment-mode/reducer.d.ts +23 -2
  89. package/global-modules/payment-mode/reducer.js +140 -114
  90. package/global-modules/payment-mode/types.d.ts +327 -112
  91. package/global-modules/payment-mode/types.js +162 -11
  92. package/global-modules/payment-mode/validate.d.ts +1 -1
  93. package/global-modules/payment-mode/validate.js +7 -5
  94. package/global-modules/preferences/actions.d.ts +126 -27
  95. package/global-modules/preferences/actions.js +128 -4
  96. package/global-modules/preferences/constants.d.ts +46 -31
  97. package/global-modules/preferences/constants.js +129 -66
  98. package/global-modules/preferences/context.d.ts +2 -2
  99. package/global-modules/preferences/context.js +43 -43
  100. package/global-modules/preferences/currency.js +15 -10
  101. package/global-modules/preferences/preferences.d.ts +2 -2
  102. package/global-modules/preferences/preferences.js +3 -5
  103. package/global-modules/preferences/validate.d.ts +1 -1
  104. package/global-modules/preferences/validate.js +7 -7
  105. package/global-modules/tax/actions.d.ts +155 -38
  106. package/global-modules/tax/actions.js +149 -7
  107. package/global-modules/tax/constants.d.ts +31 -39
  108. package/global-modules/tax/constants.js +83 -114
  109. package/global-modules/tax/context.d.ts +33 -2
  110. package/global-modules/tax/context.js +146 -132
  111. package/global-modules/tax/drawer.d.ts +26 -3
  112. package/global-modules/tax/drawer.js +101 -6
  113. package/global-modules/tax/form.d.ts +20 -3
  114. package/global-modules/tax/form.js +101 -74
  115. package/global-modules/tax/reducer.d.ts +23 -2
  116. package/global-modules/tax/reducer.js +143 -24
  117. package/global-modules/tax/tax.d.ts +25 -2
  118. package/global-modules/tax/tax.js +92 -28
  119. package/global-modules/tax/types.d.ts +332 -102
  120. package/global-modules/tax/types.js +179 -11
  121. package/global-modules/tax/validate.d.ts +1 -1
  122. package/global-modules/tax/validate.js +9 -8
  123. package/hooks/use-rtl.d.ts +44 -0
  124. package/hooks/use-rtl.js +75 -0
  125. package/lib/themes.d.ts +147 -0
  126. package/lib/themes.js +150 -0
  127. package/lib/toast-utils.d.ts +44 -0
  128. package/lib/toast-utils.js +212 -0
  129. package/lib/utils.d.ts +2 -0
  130. package/lib/utils.js +12 -0
  131. package/package.json +21 -4
  132. package/supabase/supabase.d.ts +80 -1
  133. package/supabase/supabase.js +281 -6
  134. package/global-modules/branch/form-elements.d.ts +0 -3
  135. package/global-modules/branch/form-elements.js +0 -41
  136. package/global-modules/payment-mode/form-elements.d.ts +0 -3
  137. package/global-modules/payment-mode/form-elements.js +0 -41
  138. package/global-modules/preferences/bank.d.ts +0 -2
  139. package/global-modules/preferences/bank.js +0 -11
  140. package/global-modules/preferences/branch-drawer.js +0 -36
  141. package/global-modules/preferences/branch-form-elements.js +0 -30
  142. package/global-modules/preferences/branch-form.d.ts +0 -0
  143. package/global-modules/preferences/branch-form.js +0 -33
  144. package/global-modules/preferences/branch.d.ts +0 -0
  145. package/global-modules/preferences/branch.js +0 -106
  146. package/global-modules/preferences/payment-mode-drawer.d.ts +0 -0
  147. package/global-modules/preferences/payment-mode-drawer.js +0 -36
  148. package/global-modules/preferences/payment-mode-form-elements.d.ts +0 -0
  149. package/global-modules/preferences/payment-mode-form-elements.js +0 -30
  150. package/global-modules/preferences/payment-mode-form.d.ts +0 -0
  151. package/global-modules/preferences/payment-mode-form.js +0 -33
  152. package/global-modules/preferences/payment-mode.d.ts +0 -0
  153. package/global-modules/preferences/payment-mode.js +0 -94
  154. package/global-modules/tax/form-elements.d.ts +0 -3
  155. package/global-modules/tax/form-elements.js +0 -41
  156. /package/{global-modules/preferences/branch-drawer.d.ts → constants.d.ts} +0 -0
  157. /package/{global-modules/preferences/branch-form-elements.d.ts → constants.js} +0 -0
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Bank State Reducer
3
+ *
4
+ * This module manages the state transitions for the Bank 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 bank 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 { BankActions } from "./actions";
23
+ import { BankState } from "./types";
24
+ export declare const initialBankState: BankState;
25
+ export declare function bankReducer(state: BankState, action: BankActions): BankState;
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ /**
3
+ * Bank State Reducer
4
+ *
5
+ * This module manages the state transitions for the Bank 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 bank 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
+ */
23
+ var __assign = (this && this.__assign) || function () {
24
+ __assign = Object.assign || function(t) {
25
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
26
+ s = arguments[i];
27
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
28
+ t[p] = s[p];
29
+ }
30
+ return t;
31
+ };
32
+ return __assign.apply(this, arguments);
33
+ };
34
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
35
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
36
+ if (ar || !(i in from)) {
37
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
38
+ ar[i] = from[i];
39
+ }
40
+ }
41
+ return to.concat(ar || Array.prototype.slice.call(from));
42
+ };
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.initialBankState = void 0;
45
+ exports.bankReducer = bankReducer;
46
+ var actions_1 = require("./actions");
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
+ accountNumber: "",
56
+ accountTitle: "",
57
+ bankAddress: "",
58
+ bankName: "",
59
+ enabled: false,
60
+ errors: {},
61
+ iban: "",
62
+ id: "",
63
+ isDefault: false,
64
+ swiftCode: "",
65
+ preferenceId: "",
66
+ disableSaveButton: false,
67
+ }); };
68
+ /**
69
+ * Helper function to safely update array state with immutability
70
+ */
71
+ var updateArrayState = function (array) { return __spreadArray([], array, true); };
72
+ /**
73
+ * Helper function to safely merge errors with existing state
74
+ */
75
+ var mergeErrors = function (errors) { return (__assign({}, errors)); };
76
+ // ============================================================================
77
+ // INITIAL STATE
78
+ // ============================================================================
79
+ exports.initialBankState = {
80
+ // Bank Form Data
81
+ accountNumber: "",
82
+ accountTitle: "",
83
+ bankAddress: "",
84
+ bankName: "",
85
+ enabled: false,
86
+ iban: "",
87
+ id: "",
88
+ isDefault: false,
89
+ swiftCode: "",
90
+ preferenceId: "",
91
+ // List Data
92
+ banks: [],
93
+ count: 0,
94
+ // Search & Pagination
95
+ currentPage: 1,
96
+ pageLimit: constants_1.pageLimit,
97
+ searchQuery: "",
98
+ // UI State
99
+ disableSaveButton: false,
100
+ drawer: null,
101
+ // Errors
102
+ errors: {},
103
+ };
104
+ // ============================================================================
105
+ // REDUCER FUNCTION
106
+ // ============================================================================
107
+ function bankReducer(state, action) {
108
+ var _a;
109
+ switch (action.type) {
110
+ // ------------------------------------------------------------------------
111
+ // FORM RESET ACTIONS
112
+ // ------------------------------------------------------------------------
113
+ case actions_1.BANK_ACTION_TYPES.RESET_ERRORS:
114
+ return __assign(__assign({}, state), { errors: {} });
115
+ case actions_1.BANK_ACTION_TYPES.RESET_FORM:
116
+ return __assign(__assign({}, state), getFormResetState());
117
+ // ------------------------------------------------------------------------
118
+ // FORM INPUT ACTIONS
119
+ // ------------------------------------------------------------------------
120
+ case actions_1.BANK_ACTION_TYPES.SET_INPUT_FIELD:
121
+ return __assign(__assign({}, state), (_a = {}, _a[action.payload.key] = action.payload.value, _a));
122
+ case actions_1.BANK_ACTION_TYPES.SET_FORM:
123
+ return __assign(__assign({}, state), action.payload.form);
124
+ // ------------------------------------------------------------------------
125
+ // ERROR HANDLING ACTIONS
126
+ // ------------------------------------------------------------------------
127
+ case actions_1.BANK_ACTION_TYPES.SET_ERRORS:
128
+ return __assign(__assign({}, state), { disableSaveButton: false, errors: mergeErrors(action.payload.errors) });
129
+ // ------------------------------------------------------------------------
130
+ // UI STATE ACTIONS
131
+ // ------------------------------------------------------------------------
132
+ case actions_1.BANK_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON:
133
+ return __assign(__assign({}, state), { disableSaveButton: action.payload.disableSaveButton });
134
+ case actions_1.BANK_ACTION_TYPES.SET_DRAWER:
135
+ return __assign(__assign({}, state), { drawer: action.payload.drawer });
136
+ // ------------------------------------------------------------------------
137
+ // LIST DATA ACTIONS
138
+ // ------------------------------------------------------------------------
139
+ case actions_1.BANK_ACTION_TYPES.SET_BANKS:
140
+ return __assign(__assign({}, state), { banks: updateArrayState(action.payload.banks) });
141
+ case actions_1.BANK_ACTION_TYPES.SET_COUNT:
142
+ return __assign(__assign({}, state), { count: action.payload.count });
143
+ // ------------------------------------------------------------------------
144
+ // PAGINATION ACTIONS
145
+ // ------------------------------------------------------------------------
146
+ case actions_1.BANK_ACTION_TYPES.SET_CURRENT_PAGE:
147
+ return __assign(__assign({}, state), { currentPage: action.payload.currentPage });
148
+ case actions_1.BANK_ACTION_TYPES.SET_PAGE_LIMIT:
149
+ return __assign(__assign({}, state), { pageLimit: action.payload.pageLimit });
150
+ // ------------------------------------------------------------------------
151
+ // SEARCH ACTIONS
152
+ // ------------------------------------------------------------------------
153
+ case actions_1.BANK_ACTION_TYPES.SET_SEARCH_QUERY:
154
+ return __assign(__assign({}, state), { searchQuery: action.payload.searchQuery });
155
+ // ------------------------------------------------------------------------
156
+ // DEFAULT CASE
157
+ // ------------------------------------------------------------------------
158
+ default:
159
+ return state;
160
+ }
161
+ }
@@ -0,0 +1,217 @@
1
+ /**
2
+ * Bank Module Types
3
+ *
4
+ * This module defines all TypeScript interfaces, types, and enums for the Bank feature.
5
+ * Provides type safety and clear contracts for all bank-related operations.
6
+ *
7
+ * Type Categories:
8
+ * - Context Types (React context and state management)
9
+ * - Entity Types (Backend data structures)
10
+ * - State Types (Frontend component state)
11
+ * - API Types (Request/response interfaces)
12
+ * - UI Types (Drawer and component enums)
13
+ * - Utility Types (Helper and computed types)
14
+ *
15
+ * Advanced Features:
16
+ * - Bank management with account details
17
+ * - CRUD operations support
18
+ * - Enhanced search and pagination
19
+ *
20
+ * Naming Conventions:
21
+ * - Interfaces: PascalCase with descriptive suffixes (Type, State, Args)
22
+ * - Enums: UPPER_SNAKE_CASE for values, PascalCase for enum names
23
+ * - Types: PascalCase following interface conventions
24
+ */
25
+ import { Dispatch } from "react";
26
+ import { RowAction, HeaderAction } from "@/components/ui/enhanced-table";
27
+ import { BankActions } from "./actions";
28
+ import { PreferenceBE as PreferenceTypeBE } from "@react-pakistan/util-functions/api/stellar-solutions/type";
29
+ /**
30
+ * Bank Context Interface
31
+ *
32
+ * Defines the complete context API for bank state management.
33
+ * Includes all handlers, state getters, and utility functions.
34
+ */
35
+ export interface BankContextType {
36
+ byIdError?: Error;
37
+ byIdLoading: boolean;
38
+ deleteError?: Error;
39
+ deleteLoading: boolean;
40
+ listError?: Error;
41
+ listLoading: boolean;
42
+ updateError?: Error;
43
+ updateLoading: boolean;
44
+ dispatch: Dispatch<BankActions>;
45
+ handleInputChange: (key: string, value: string | boolean) => void;
46
+ handleNextClick: () => void;
47
+ handlePageLimit: (k: string, v: object) => void;
48
+ handlePreviousClick: () => void;
49
+ handleSubmit: () => void;
50
+ clearSearch: () => void;
51
+ closeDrawer: () => void;
52
+ searchOnChange: (k: string, v: string) => void;
53
+ headerActions: HeaderAction[];
54
+ rowActions: RowAction[];
55
+ }
56
+ /**
57
+ * Bank Backend Entity
58
+ *
59
+ * Represents the complete bank data structure as received from the API.
60
+ * Includes all bank-specific fields and account details.
61
+ */
62
+ export interface BankTypeBE {
63
+ accountNumber: string;
64
+ accountTitle: string;
65
+ bankAddress?: string;
66
+ bankName: string;
67
+ createdAt: string;
68
+ enabled: boolean;
69
+ iban?: string;
70
+ id: string;
71
+ isDefault: boolean;
72
+ swiftCode?: string;
73
+ updatedAt: string;
74
+ preference: PreferenceTypeBE;
75
+ preferenceId: string;
76
+ }
77
+ /**
78
+ * Bank Component State
79
+ *
80
+ * Complete state interface for the bank module components.
81
+ * Extends entity data with UI state, form state, and search capabilities.
82
+ */
83
+ export interface BankState {
84
+ banks: BankTypeBE[];
85
+ count: number;
86
+ currentPage: number;
87
+ pageLimit: number;
88
+ searchQuery: string;
89
+ disableSaveButton: boolean;
90
+ drawer: null | BANK_DRAWER;
91
+ accountNumber: string;
92
+ accountTitle: string;
93
+ bankAddress: string;
94
+ bankName: string;
95
+ enabled: boolean;
96
+ errors: Record<string, string>;
97
+ iban: string;
98
+ id: string;
99
+ isDefault: boolean;
100
+ swiftCode: string;
101
+ preferenceId: string;
102
+ }
103
+ /**
104
+ * Fetch Banks API Arguments
105
+ *
106
+ * Parameters for bank list API requests.
107
+ * Supports pagination and search functionality.
108
+ */
109
+ export interface FetchBanksArgs {
110
+ currentPage: number;
111
+ pageLimit: number;
112
+ searchQuery?: string;
113
+ }
114
+ /**
115
+ * Bank API Response
116
+ *
117
+ * Standard API response format for bank operations.
118
+ */
119
+ export interface BankApiResponse {
120
+ data?: BankTypeBE[];
121
+ count?: number;
122
+ error?: string;
123
+ success: boolean;
124
+ }
125
+ /**
126
+ * Single Bank API Response
127
+ *
128
+ * API response format for individual bank operations.
129
+ */
130
+ export interface SingleBankApiResponse {
131
+ data?: BankTypeBE;
132
+ error?: string;
133
+ success: boolean;
134
+ }
135
+ /**
136
+ * Update Bank Arguments
137
+ *
138
+ * Parameters for bank update operations.
139
+ */
140
+ export interface UpdateBankArgs {
141
+ id: string;
142
+ accountNumber: string;
143
+ accountTitle: string;
144
+ bankAddress: string;
145
+ bankName: string;
146
+ enabled: boolean;
147
+ iban: string;
148
+ swiftCode: string;
149
+ isDefault: boolean;
150
+ }
151
+ /**
152
+ * Bank Drawer Types
153
+ *
154
+ * Enumeration of available drawer states for bank operations.
155
+ */
156
+ export declare enum BANK_DRAWER {
157
+ FILTER_DRAWER = "FILTER_DRAWER",
158
+ FORM_DRAWER = "FORM_DRAWER"
159
+ }
160
+ export declare enum BANK_MODAL {
161
+ DUMMY = "DUMMY"
162
+ }
163
+ /**
164
+ * Bank Form Fields
165
+ *
166
+ * Utility type for bank form field keys.
167
+ * Useful for form validation and dynamic field handling.
168
+ */
169
+ export type BankFormFields = keyof Omit<BankTypeBE, "id" | "createdAt" | "updatedAt" | "preference">;
170
+ /**
171
+ * Bank Required Fields
172
+ *
173
+ * Fields that are mandatory for bank creation.
174
+ */
175
+ export type BankRequiredFields = "accountNumber" | "accountTitle" | "bankName" | "preferenceId";
176
+ /**
177
+ * Bank Optional Fields
178
+ *
179
+ * Fields that are optional for bank creation.
180
+ */
181
+ export type BankOptionalFields = "bankAddress" | "iban" | "swiftCode" | "enabled" | "isDefault";
182
+ /**
183
+ * Bank Search Fields
184
+ *
185
+ * Fields that can be used for searching banks.
186
+ */
187
+ export type BankSearchFields = "bankName" | "accountTitle" | "accountNumber";
188
+ /**
189
+ * Bank Sort Fields
190
+ *
191
+ * Fields that can be used for sorting bank lists.
192
+ */
193
+ export type BankSortFields = "bankName" | "accountTitle" | "accountNumber" | "createdAt" | "enabled" | "isDefault";
194
+ /**
195
+ * Partial Bank Update
196
+ *
197
+ * Type for partial bank updates (PATCH operations).
198
+ */
199
+ export type PartialBankUpdate = Partial<Omit<BankTypeBE, "id" | "createdAt" | "updatedAt">>;
200
+ /**
201
+ * Bank Form Data
202
+ *
203
+ * Type for bank form data (excludes backend-only fields).
204
+ */
205
+ export type BankForm = Omit<BankTypeBE, "createdAt" | "updatedAt" | "preference">;
206
+ /**
207
+ * Type guard to check if object is a valid BankTypeBE
208
+ */
209
+ export declare const isBankTypeBE: (obj: unknown) => obj is BankTypeBE;
210
+ /**
211
+ * Type guard to check if string is a valid bank drawer type
212
+ */
213
+ export declare const isBankDrawer: (value: string) => value is BANK_DRAWER;
214
+ /**
215
+ * Type guard to check if object has valid bank filter structure
216
+ */
217
+ export declare const isFetchBanksArgs: (obj: unknown) => obj is FetchBanksArgs;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ /**
3
+ * Bank Module Types
4
+ *
5
+ * This module defines all TypeScript interfaces, types, and enums for the Bank feature.
6
+ * Provides type safety and clear contracts for all bank-related operations.
7
+ *
8
+ * Type Categories:
9
+ * - Context Types (React context and state management)
10
+ * - Entity Types (Backend data structures)
11
+ * - State Types (Frontend component state)
12
+ * - API Types (Request/response interfaces)
13
+ * - UI Types (Drawer and component enums)
14
+ * - Utility Types (Helper and computed types)
15
+ *
16
+ * Advanced Features:
17
+ * - Bank management with account details
18
+ * - CRUD operations support
19
+ * - Enhanced search and pagination
20
+ *
21
+ * Naming Conventions:
22
+ * - Interfaces: PascalCase with descriptive suffixes (Type, State, Args)
23
+ * - Enums: UPPER_SNAKE_CASE for values, PascalCase for enum names
24
+ * - Types: PascalCase following interface conventions
25
+ */
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.isFetchBanksArgs = exports.isBankDrawer = exports.isBankTypeBE = exports.BANK_MODAL = exports.BANK_DRAWER = void 0;
28
+ // ============================================================================
29
+ // UI ENUMS (Component State Definitions)
30
+ // ============================================================================
31
+ /**
32
+ * Bank Drawer Types
33
+ *
34
+ * Enumeration of available drawer states for bank operations.
35
+ */
36
+ var BANK_DRAWER;
37
+ (function (BANK_DRAWER) {
38
+ BANK_DRAWER["FILTER_DRAWER"] = "FILTER_DRAWER";
39
+ BANK_DRAWER["FORM_DRAWER"] = "FORM_DRAWER";
40
+ })(BANK_DRAWER || (exports.BANK_DRAWER = BANK_DRAWER = {}));
41
+ var BANK_MODAL;
42
+ (function (BANK_MODAL) {
43
+ BANK_MODAL["DUMMY"] = "DUMMY";
44
+ })(BANK_MODAL || (exports.BANK_MODAL = BANK_MODAL = {}));
45
+ // ============================================================================
46
+ // TYPE GUARDS (Runtime Type Checking)
47
+ // ============================================================================
48
+ /**
49
+ * Type guard to check if object is a valid BankTypeBE
50
+ */
51
+ var isBankTypeBE = function (obj) {
52
+ return (typeof obj === "object" &&
53
+ obj !== null &&
54
+ "id" in obj &&
55
+ "bankName" in obj &&
56
+ "accountNumber" in obj &&
57
+ typeof obj.enabled === "boolean" &&
58
+ typeof obj.isDefault === "boolean");
59
+ };
60
+ exports.isBankTypeBE = isBankTypeBE;
61
+ /**
62
+ * Type guard to check if string is a valid bank drawer type
63
+ */
64
+ var isBankDrawer = function (value) {
65
+ return Object.values(BANK_DRAWER).includes(value);
66
+ };
67
+ exports.isBankDrawer = isBankDrawer;
68
+ /**
69
+ * Type guard to check if object has valid bank filter structure
70
+ */
71
+ var isFetchBanksArgs = function (obj) {
72
+ return (typeof obj === "object" &&
73
+ obj !== null &&
74
+ typeof obj.currentPage === "number" &&
75
+ typeof obj.pageLimit === "number");
76
+ };
77
+ exports.isFetchBanksArgs = isFetchBanksArgs;
78
+ // ============================================================================
79
+ // SHARED TYPES (From other modules)
80
+ // ============================================================================
81
+ // All shared types are now imported from @react-pakistan/util-functions/api/stellar-solutions/type
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ export declare const formValidation: z.ZodObject<{
3
+ accountNumber: z.ZodString;
4
+ accountTitle: z.ZodString;
5
+ bankAddress: z.ZodOptional<z.ZodString>;
6
+ bankName: z.ZodString;
7
+ enabled: z.ZodBoolean;
8
+ iban: z.ZodOptional<z.ZodString>;
9
+ isDefault: z.ZodBoolean;
10
+ preferenceId: z.ZodString;
11
+ swiftCode: z.ZodOptional<z.ZodString>;
12
+ }, z.core.$strip>;
13
+ export type FormValidate = z.infer<typeof formValidation>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formValidation = void 0;
4
+ var zod_1 = require("zod");
5
+ // Validation error keys for i18n translation
6
+ var VALIDATION_KEYS = {
7
+ accountNumberRequired: "validation.accountNumberRequired",
8
+ accountTitleRequired: "validation.accountTitleRequired",
9
+ bankNameRequired: "validation.bankNameRequired",
10
+ preferenceIdRequired: "validation.preferenceIdRequired",
11
+ };
12
+ exports.formValidation = zod_1.z.object({
13
+ accountNumber: zod_1.z.string().nonempty(VALIDATION_KEYS.accountNumberRequired),
14
+ accountTitle: zod_1.z.string().nonempty(VALIDATION_KEYS.accountTitleRequired),
15
+ bankAddress: zod_1.z.string().optional(),
16
+ bankName: zod_1.z.string().nonempty(VALIDATION_KEYS.bankNameRequired),
17
+ enabled: zod_1.z.boolean(),
18
+ iban: zod_1.z.string().optional(),
19
+ isDefault: zod_1.z.boolean(),
20
+ preferenceId: zod_1.z.string().nonempty(VALIDATION_KEYS.preferenceIdRequired),
21
+ swiftCode: zod_1.z.string().optional(),
22
+ });