@appcorp/stellar-solutions-modules 0.1.34 → 0.1.36

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 (181) hide show
  1. package/README.md +128 -19
  2. package/components/theme-provider.d.ts +9 -0
  3. package/components/theme-provider.js +122 -0
  4. package/components/theme-switcher.d.ts +4 -0
  5. package/components/theme-switcher.js +60 -0
  6. package/components/ui/badge.d.ts +9 -0
  7. package/components/ui/badge.js +82 -0
  8. package/components/ui/button.d.ts +10 -0
  9. package/components/ui/button.js +91 -0
  10. package/components/ui/card.d.ts +9 -0
  11. package/components/ui/card.js +94 -0
  12. package/components/ui/checkbox.d.ts +9 -0
  13. package/components/ui/checkbox.js +87 -0
  14. package/components/ui/combobox.d.ts +70 -0
  15. package/components/ui/combobox.js +315 -0
  16. package/components/ui/command.d.ts +18 -0
  17. package/components/ui/command.js +115 -0
  18. package/components/ui/dialog.d.ts +15 -0
  19. package/components/ui/dialog.js +118 -0
  20. package/components/ui/drawer.d.ts +13 -0
  21. package/components/ui/drawer.js +115 -0
  22. package/components/ui/dropdown-menu.d.ts +25 -0
  23. package/components/ui/dropdown-menu.js +148 -0
  24. package/components/ui/enhanced-table-footer-action.d.ts +34 -0
  25. package/components/ui/enhanced-table-footer-action.js +117 -0
  26. package/components/ui/enhanced-table-footer-page.d.ts +32 -0
  27. package/components/ui/enhanced-table-footer-page.js +140 -0
  28. package/components/ui/enhanced-table-footer-pagination.d.ts +36 -0
  29. package/components/ui/enhanced-table-footer-pagination.js +122 -0
  30. package/components/ui/enhanced-table-header-action.d.ts +7 -0
  31. package/components/ui/enhanced-table-header-action.js +21 -0
  32. package/components/ui/enhanced-table-header-search.d.ts +12 -0
  33. package/components/ui/enhanced-table-header-search.js +17 -0
  34. package/components/ui/enhanced-table.d.ts +65 -0
  35. package/components/ui/enhanced-table.js +87 -0
  36. package/components/ui/form.d.ts +24 -0
  37. package/components/ui/form.js +125 -0
  38. package/components/ui/input.d.ts +8 -0
  39. package/components/ui/input.js +86 -0
  40. package/components/ui/label.d.ts +7 -0
  41. package/components/ui/label.js +68 -0
  42. package/components/ui/popover.d.ts +7 -0
  43. package/components/ui/popover.js +82 -0
  44. package/components/ui/select.d.ts +15 -0
  45. package/components/ui/select.js +127 -0
  46. package/components/ui/separator.d.ts +4 -0
  47. package/components/ui/separator.js +66 -0
  48. package/components/ui/sonner.d.ts +4 -0
  49. package/components/ui/sonner.js +54 -0
  50. package/components/ui/switch.d.ts +9 -0
  51. package/components/ui/switch.js +89 -0
  52. package/components/ui/table.d.ts +10 -0
  53. package/components/ui/table.js +101 -0
  54. package/components/ui/textarea.d.ts +8 -0
  55. package/components/ui/textarea.js +86 -0
  56. package/global-modules/bank/actions.d.ts +200 -0
  57. package/global-modules/bank/actions.js +124 -0
  58. package/global-modules/bank/bank.d.ts +2 -0
  59. package/global-modules/bank/bank.js +87 -0
  60. package/global-modules/bank/constants.d.ts +45 -0
  61. package/global-modules/bank/constants.js +98 -0
  62. package/global-modules/bank/context.d.ts +41 -0
  63. package/global-modules/bank/context.js +419 -0
  64. package/global-modules/bank/drawer.d.ts +31 -0
  65. package/global-modules/bank/drawer.js +114 -0
  66. package/global-modules/bank/form.d.ts +22 -0
  67. package/global-modules/bank/form.js +68 -0
  68. package/global-modules/bank/reducer.d.ts +25 -0
  69. package/global-modules/bank/reducer.js +161 -0
  70. package/global-modules/bank/types.d.ts +217 -0
  71. package/global-modules/bank/types.js +81 -0
  72. package/global-modules/bank/validate.d.ts +13 -0
  73. package/global-modules/bank/validate.js +22 -0
  74. package/global-modules/branch/actions.d.ts +154 -37
  75. package/global-modules/branch/actions.js +148 -6
  76. package/global-modules/branch/branch.d.ts +2 -2
  77. package/global-modules/branch/branch.js +46 -32
  78. package/global-modules/branch/constants.d.ts +34 -24
  79. package/global-modules/branch/constants.js +101 -122
  80. package/global-modules/branch/context.d.ts +33 -2
  81. package/global-modules/branch/context.js +195 -164
  82. package/global-modules/branch/drawer.d.ts +26 -3
  83. package/global-modules/branch/drawer.js +101 -6
  84. package/global-modules/branch/form.d.ts +15 -1
  85. package/global-modules/branch/form.js +54 -71
  86. package/global-modules/branch/reducer.d.ts +23 -2
  87. package/global-modules/branch/reducer.js +148 -118
  88. package/global-modules/branch/types.d.ts +196 -69
  89. package/global-modules/branch/types.js +66 -7
  90. package/global-modules/branch/validate.d.ts +1 -1
  91. package/global-modules/branch/validate.js +15 -11
  92. package/global-modules/payment-mode/actions.d.ts +154 -37
  93. package/global-modules/payment-mode/actions.js +148 -6
  94. package/global-modules/payment-mode/constants.d.ts +34 -17
  95. package/global-modules/payment-mode/constants.js +90 -66
  96. package/global-modules/payment-mode/context.d.ts +33 -2
  97. package/global-modules/payment-mode/context.js +185 -163
  98. package/global-modules/payment-mode/drawer.d.ts +26 -3
  99. package/global-modules/payment-mode/drawer.js +104 -9
  100. package/global-modules/payment-mode/form.d.ts +16 -2
  101. package/global-modules/payment-mode/form.js +45 -74
  102. package/global-modules/payment-mode/payment-mode.d.ts +25 -2
  103. package/global-modules/payment-mode/payment-mode.js +90 -23
  104. package/global-modules/payment-mode/reducer.d.ts +23 -2
  105. package/global-modules/payment-mode/reducer.js +140 -114
  106. package/global-modules/payment-mode/types.d.ts +327 -112
  107. package/global-modules/payment-mode/types.js +162 -11
  108. package/global-modules/payment-mode/validate.d.ts +1 -1
  109. package/global-modules/payment-mode/validate.js +7 -5
  110. package/global-modules/preferences/actions.d.ts +126 -27
  111. package/global-modules/preferences/actions.js +128 -4
  112. package/global-modules/preferences/constants.d.ts +46 -31
  113. package/global-modules/preferences/constants.js +129 -66
  114. package/global-modules/preferences/context.d.ts +2 -2
  115. package/global-modules/preferences/context.js +43 -43
  116. package/global-modules/preferences/currency.js +15 -10
  117. package/global-modules/preferences/preferences.d.ts +2 -2
  118. package/global-modules/preferences/preferences.js +3 -5
  119. package/global-modules/preferences/validate.d.ts +1 -1
  120. package/global-modules/preferences/validate.js +7 -7
  121. package/global-modules/tax/actions.d.ts +155 -38
  122. package/global-modules/tax/actions.js +149 -7
  123. package/global-modules/tax/constants.d.ts +31 -39
  124. package/global-modules/tax/constants.js +83 -114
  125. package/global-modules/tax/context.d.ts +33 -2
  126. package/global-modules/tax/context.js +146 -132
  127. package/global-modules/tax/drawer.d.ts +26 -3
  128. package/global-modules/tax/drawer.js +101 -6
  129. package/global-modules/tax/form.d.ts +20 -3
  130. package/global-modules/tax/form.js +101 -74
  131. package/global-modules/tax/reducer.d.ts +23 -2
  132. package/global-modules/tax/reducer.js +143 -24
  133. package/global-modules/tax/tax.d.ts +25 -2
  134. package/global-modules/tax/tax.js +92 -28
  135. package/global-modules/tax/types.d.ts +332 -102
  136. package/global-modules/tax/types.js +179 -11
  137. package/global-modules/tax/validate.d.ts +1 -1
  138. package/global-modules/tax/validate.js +9 -8
  139. package/hooks/use-rtl.d.ts +44 -0
  140. package/hooks/use-rtl.js +75 -0
  141. package/i18n/navigation.d.ts +340 -0
  142. package/i18n/navigation.js +9 -0
  143. package/i18n/request.d.ts +2 -0
  144. package/i18n/request.js +95 -0
  145. package/i18n/routing.d.ts +18 -0
  146. package/i18n/routing.js +9 -0
  147. package/index.d.ts +26 -0
  148. package/index.js +42 -0
  149. package/lib/themes.d.ts +147 -0
  150. package/lib/themes.js +150 -0
  151. package/lib/toast-utils.d.ts +44 -0
  152. package/lib/toast-utils.js +212 -0
  153. package/lib/utils.d.ts +2 -0
  154. package/lib/utils.js +12 -0
  155. package/package.json +21 -3
  156. package/supabase/supabase.d.ts +80 -1
  157. package/supabase/supabase.js +281 -6
  158. package/global-modules/branch/form-elements.d.ts +0 -3
  159. package/global-modules/branch/form-elements.js +0 -41
  160. package/global-modules/payment-mode/form-elements.d.ts +0 -3
  161. package/global-modules/payment-mode/form-elements.js +0 -41
  162. package/global-modules/preferences/bank.d.ts +0 -2
  163. package/global-modules/preferences/bank.js +0 -11
  164. package/global-modules/preferences/branch-drawer.js +0 -36
  165. package/global-modules/preferences/branch-form-elements.js +0 -30
  166. package/global-modules/preferences/branch-form.d.ts +0 -0
  167. package/global-modules/preferences/branch-form.js +0 -33
  168. package/global-modules/preferences/branch.d.ts +0 -0
  169. package/global-modules/preferences/branch.js +0 -106
  170. package/global-modules/preferences/payment-mode-drawer.d.ts +0 -0
  171. package/global-modules/preferences/payment-mode-drawer.js +0 -36
  172. package/global-modules/preferences/payment-mode-form-elements.d.ts +0 -0
  173. package/global-modules/preferences/payment-mode-form-elements.js +0 -30
  174. package/global-modules/preferences/payment-mode-form.d.ts +0 -0
  175. package/global-modules/preferences/payment-mode-form.js +0 -33
  176. package/global-modules/preferences/payment-mode.d.ts +0 -0
  177. package/global-modules/preferences/payment-mode.js +0 -94
  178. package/global-modules/tax/form-elements.d.ts +0 -3
  179. package/global-modules/tax/form-elements.js +0 -41
  180. /package/{global-modules/preferences/branch-drawer.d.ts → constants.d.ts} +0 -0
  181. /package/{global-modules/preferences/branch-form-elements.d.ts → constants.js} +0 -0
@@ -1,52 +1,62 @@
1
- import { VistaTableHeaderActionItem } from '@appcorp/app-corp-vista/type/vista-table-type';
2
- import { RowActionItem } from '@appcorp/app-corp-vista/type/vista-dropdown-menu-type';
3
- import { BranchActions } from './actions';
4
- import { Dispatch } from 'react';
5
- import { VistaFormElements } from '@appcorp/app-corp-vista/type/vista-form-elements';
6
- export interface MenuItem {
7
- preferenceId: string;
8
- label: string;
9
- order: number;
10
- id: string;
11
- }
12
- export interface Tax {
13
- taxName: string;
14
- taxValue: string;
15
- id: string;
16
- description: string;
17
- preferenceId: string;
18
- enabled: boolean;
19
- errors: {
20
- [key: string]: string;
21
- };
22
- createdAt?: string;
23
- updatedAt?: string;
24
- loading: boolean;
25
- isDefault: boolean;
26
- btnDisableTax: boolean;
27
- }
28
- export type BranchForm = Omit<BranchTypeBE, 'createdAt' | 'updatedAt' | 'preference'>;
29
- export interface BranchState {
30
- branchAddress: string;
31
- branchName: string;
32
- branches: BranchTypeBE[];
33
- count: number;
34
- currentPage: number;
35
- disableSaveButton: boolean;
36
- drawer: null | BRANCH_DRAWER;
37
- enabled: boolean;
38
- errors: {
39
- [key: string]: string;
40
- };
41
- id: string;
42
- isDefault: boolean;
43
- pageLimit: number;
44
- personEmail: string;
45
- personName: string;
46
- personPhone: string;
47
- preferenceId: string;
48
- searchQuery: string;
1
+ /**
2
+ * Branch Module Types
3
+ *
4
+ * This module defines all TypeScript interfaces, types, and enums for the Branch feature.
5
+ * Provides type safety and clear contracts for all branch-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
+ * - Branch management with contact person 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 { BranchActions } from "./actions";
28
+ /**
29
+ * Branch Context Interface
30
+ *
31
+ * Defines the complete context API for branch state management.
32
+ * Includes all handlers, state getters, and utility functions.
33
+ */
34
+ export interface BranchContextType {
35
+ byIdError?: Error;
36
+ byIdLoading: boolean;
37
+ deleteError?: Error;
38
+ deleteLoading: boolean;
39
+ listError?: Error;
40
+ listLoading: boolean;
41
+ updateError?: Error;
42
+ updateLoading: boolean;
43
+ dispatch: Dispatch<BranchActions>;
44
+ handleInputChange: (key: string, value: string | boolean) => void;
45
+ handleNextClick: () => void;
46
+ handlePageLimit: (k: string, v: object) => void;
47
+ handlePreviousClick: () => void;
48
+ handleSubmit: () => void;
49
+ clearSearch: () => void;
50
+ closeDrawer: () => void;
51
+ searchOnChange: (k: string, v: string) => void;
52
+ headerActions: HeaderAction[];
53
+ rowActions: RowAction[];
49
54
  }
55
+ /**
56
+ * Banking Detail Backend Entity
57
+ *
58
+ * Represents banking detail data structure with branch relationship.
59
+ */
50
60
  export interface BankingDetailTypeBE {
51
61
  accountNumber: string;
52
62
  accountTitle: string;
@@ -62,6 +72,12 @@ export interface BankingDetailTypeBE {
62
72
  swiftCode?: string;
63
73
  updatedAt: string;
64
74
  }
75
+ /**
76
+ * Branch Backend Entity
77
+ *
78
+ * Represents the complete branch data structure as received from the API.
79
+ * Includes all branch-specific fields, contact person details, and relationships.
80
+ */
65
81
  export interface BranchTypeBE {
66
82
  branchAddress: string;
67
83
  branchName: string;
@@ -76,6 +92,31 @@ export interface BranchTypeBE {
76
92
  preferenceId: string;
77
93
  updatedAt: string;
78
94
  }
95
+ /**
96
+ * Branch Component State
97
+ *
98
+ * Complete state interface for the branch module components.
99
+ * Extends entity data with UI state, form state, and search capabilities.
100
+ */
101
+ export interface BranchState {
102
+ branches: BranchTypeBE[];
103
+ count: number;
104
+ currentPage: number;
105
+ pageLimit: number;
106
+ searchQuery: string;
107
+ disableSaveButton: boolean;
108
+ drawer: null | BRANCH_DRAWER;
109
+ branchAddress: string;
110
+ branchName: string;
111
+ enabled: boolean;
112
+ errors: Record<string, string>;
113
+ id: string;
114
+ isDefault: boolean;
115
+ personEmail: string;
116
+ personName: string;
117
+ personPhone: string;
118
+ preferenceId: string;
119
+ }
79
120
  export interface CurrencyTypeBE {
80
121
  code: string;
81
122
  createdAt: string;
@@ -96,6 +137,58 @@ export interface MenuOrderTypeBE {
96
137
  preferenceId: string;
97
138
  updatedAt: string;
98
139
  }
140
+ /**
141
+ * Fetch Branches API Arguments
142
+ *
143
+ * Parameters for branch list API requests.
144
+ * Supports pagination and search functionality.
145
+ */
146
+ export interface FetchBranchesArgs {
147
+ currentPage: number;
148
+ pageLimit: number;
149
+ searchQuery?: string;
150
+ }
151
+ /**
152
+ * Branch API Response
153
+ *
154
+ * Standard API response format for branch operations.
155
+ */
156
+ export interface BranchApiResponse {
157
+ data?: BranchTypeBE[];
158
+ count?: number;
159
+ error?: string;
160
+ success: boolean;
161
+ }
162
+ /**
163
+ * Single Branch API Response
164
+ *
165
+ * API response format for individual branch operations.
166
+ */
167
+ export interface SingleBranchApiResponse {
168
+ data?: BranchTypeBE;
169
+ error?: string;
170
+ success: boolean;
171
+ }
172
+ /**
173
+ * Update Branch Arguments
174
+ *
175
+ * Parameters for branch update operations.
176
+ */
177
+ export interface UpdateBranchArgs {
178
+ id: string;
179
+ branchAddress: string;
180
+ branchName: string;
181
+ enabled: boolean;
182
+ isDefault: boolean;
183
+ personEmail: string;
184
+ personName: string;
185
+ personPhone: string;
186
+ }
187
+ /**
188
+ * Payment Types
189
+ *
190
+ * Enumeration of payment type classifications.
191
+ */
99
192
  export declare enum PAYMENT_TYPE {
100
193
  FULL_PAYMENT = "FULL_PAYMENT",
101
194
  PARTIAL_PAYMENT = "PARTIAL_PAYMENT"
@@ -152,27 +245,6 @@ export interface PreferenceTypeBE {
152
245
  taxes: TaxTypeBE[];
153
246
  updatedAt: string;
154
247
  }
155
- export interface BranchContextType {
156
- byIdError?: Error;
157
- byIdLoading: boolean;
158
- clearSearch: () => void;
159
- closeDrawer: () => void;
160
- deleteError?: Error;
161
- deleteLoading: boolean;
162
- dispatch: Dispatch<BranchActions>;
163
- dynamicFormElements: VistaFormElements;
164
- handleNextClick: () => void;
165
- handlePageLimit: (k: string, v: object) => void;
166
- handlePreviousClick: () => void;
167
- handleSubmit: () => void;
168
- headerActions: VistaTableHeaderActionItem[];
169
- listError?: Error;
170
- listLoading: boolean;
171
- rowActions: RowActionItem[];
172
- searchOnChange: (k: string, v: string) => void;
173
- updateError?: Error;
174
- updateLoading: boolean;
175
- }
176
248
  export interface CreateBankDetailArg {
177
249
  id: string;
178
250
  accountNumber: string;
@@ -253,3 +325,58 @@ export declare enum BRANCH_DRAWER {
253
325
  export declare enum BRANCH_MODAL {
254
326
  DUMMY = "DUMMY"
255
327
  }
328
+ /**
329
+ * Branch Form Fields
330
+ *
331
+ * Utility type for branch form field keys.
332
+ * Useful for form validation and dynamic field handling.
333
+ */
334
+ export type BranchFormFields = keyof Omit<BranchTypeBE, "id" | "createdAt" | "updatedAt" | "preference">;
335
+ /**
336
+ * Branch Required Fields
337
+ *
338
+ * Fields that are mandatory for branch creation.
339
+ */
340
+ export type BranchRequiredFields = "branchName" | "branchAddress" | "personName" | "personEmail" | "personPhone" | "preferenceId";
341
+ /**
342
+ * Branch Optional Fields
343
+ *
344
+ * Fields that are optional for branch creation.
345
+ */
346
+ export type BranchOptionalFields = "enabled" | "isDefault";
347
+ /**
348
+ * Branch Search Fields
349
+ *
350
+ * Fields that can be used for searching branches.
351
+ */
352
+ export type BranchSearchFields = "branchName" | "personName" | "personEmail";
353
+ /**
354
+ * Branch Sort Fields
355
+ *
356
+ * Fields that can be used for sorting branch lists.
357
+ */
358
+ export type BranchSortFields = "branchName" | "personName" | "createdAt" | "enabled" | "isDefault";
359
+ /**
360
+ * Partial Branch Update
361
+ *
362
+ * Type for partial branch updates (PATCH operations).
363
+ */
364
+ export type PartialBranchUpdate = Partial<Omit<BranchTypeBE, "id" | "createdAt" | "updatedAt">>;
365
+ /**
366
+ * Branch Form Data
367
+ *
368
+ * Type for branch form data (excludes backend-only fields).
369
+ */
370
+ export type BranchForm = Omit<BranchTypeBE, "createdAt" | "updatedAt" | "preference">;
371
+ /**
372
+ * Type guard to check if object is a valid BranchTypeBE
373
+ */
374
+ export declare const isBranchTypeBE: (obj: unknown) => obj is BranchTypeBE;
375
+ /**
376
+ * Type guard to check if string is a valid branch drawer type
377
+ */
378
+ export declare const isBranchDrawer: (value: string) => value is BRANCH_DRAWER;
379
+ /**
380
+ * Type guard to check if object has valid branch filter structure
381
+ */
382
+ export declare const isFetchBranchesArgs: (obj: unknown) => obj is FetchBranchesArgs;
@@ -1,12 +1,38 @@
1
1
  "use strict";
2
+ /**
3
+ * Branch Module Types
4
+ *
5
+ * This module defines all TypeScript interfaces, types, and enums for the Branch feature.
6
+ * Provides type safety and clear contracts for all branch-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
+ * - Branch management with contact person 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
+ */
2
26
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BRANCH_MODAL = exports.BRANCH_DRAWER = exports.PAYMENT_TYPE = void 0;
4
- // export enum PAYMENT_MODE {
5
- // BANK_TRANSFER = 'BANK_TRANSFER',
6
- // CASH = 'CASH',
7
- // CHEQUE = 'CHEQUE',
8
- // OTHER = 'OTHER',
9
- // }
27
+ exports.isFetchBranchesArgs = exports.isBranchDrawer = exports.isBranchTypeBE = exports.BRANCH_MODAL = exports.BRANCH_DRAWER = exports.PAYMENT_TYPE = void 0;
28
+ // ============================================================================
29
+ // UI ENUMS (Component State Definitions)
30
+ // ============================================================================
31
+ /**
32
+ * Payment Types
33
+ *
34
+ * Enumeration of payment type classifications.
35
+ */
10
36
  var PAYMENT_TYPE;
11
37
  (function (PAYMENT_TYPE) {
12
38
  PAYMENT_TYPE["FULL_PAYMENT"] = "FULL_PAYMENT";
@@ -20,3 +46,36 @@ var BRANCH_MODAL;
20
46
  (function (BRANCH_MODAL) {
21
47
  BRANCH_MODAL["DUMMY"] = "DUMMY";
22
48
  })(BRANCH_MODAL || (exports.BRANCH_MODAL = BRANCH_MODAL = {}));
49
+ // ============================================================================
50
+ // TYPE GUARDS (Runtime Type Checking)
51
+ // ============================================================================
52
+ /**
53
+ * Type guard to check if object is a valid BranchTypeBE
54
+ */
55
+ var isBranchTypeBE = function (obj) {
56
+ return (typeof obj === "object" &&
57
+ obj !== null &&
58
+ "id" in obj &&
59
+ "branchName" in obj &&
60
+ "branchAddress" in obj &&
61
+ typeof obj.enabled === "boolean" &&
62
+ typeof obj.isDefault === "boolean");
63
+ };
64
+ exports.isBranchTypeBE = isBranchTypeBE;
65
+ /**
66
+ * Type guard to check if string is a valid branch drawer type
67
+ */
68
+ var isBranchDrawer = function (value) {
69
+ return Object.values(BRANCH_DRAWER).includes(value);
70
+ };
71
+ exports.isBranchDrawer = isBranchDrawer;
72
+ /**
73
+ * Type guard to check if object has valid branch filter structure
74
+ */
75
+ var isFetchBranchesArgs = function (obj) {
76
+ return (typeof obj === "object" &&
77
+ obj !== null &&
78
+ typeof obj.currentPage === "number" &&
79
+ typeof obj.pageLimit === "number");
80
+ };
81
+ exports.isFetchBranchesArgs = isFetchBranchesArgs;
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import { z } from "zod";
2
2
  export declare const formValidation: z.ZodObject<{
3
3
  branchAddress: z.ZodString;
4
4
  branchName: z.ZodString;
@@ -2,18 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formValidation = void 0;
4
4
  var zod_1 = require("zod");
5
- var constants_1 = require("./constants");
5
+ // Validation error keys for i18n translation
6
+ var VALIDATION_KEYS = {
7
+ branchNameRequired: "branchPage.validation.branchNameRequired",
8
+ branchAddressRequired: "branchPage.validation.branchAddressRequired",
9
+ personNameRequired: "branchPage.validation.personNameRequired",
10
+ personEmailRequired: "branchPage.validation.personEmailRequired",
11
+ personPhoneRequired: "branchPage.validation.personPhoneRequired",
12
+ preferenceIdRequired: "branchPage.validation.preferenceIdRequired",
13
+ };
6
14
  exports.formValidation = zod_1.z.object({
7
- branchAddress: zod_1.z
8
- .string()
9
- .nonempty(constants_1.validationError.branchAddress),
10
- branchName: zod_1.z
11
- .string()
12
- .nonempty(constants_1.validationError.branchName),
15
+ branchAddress: zod_1.z.string().nonempty(VALIDATION_KEYS.branchAddressRequired),
16
+ branchName: zod_1.z.string().nonempty(VALIDATION_KEYS.branchNameRequired),
13
17
  enabled: zod_1.z.boolean(),
14
18
  isDefault: zod_1.z.boolean(),
15
- personEmail: zod_1.z.string().nonempty(constants_1.validationError.personEmail),
16
- personPhone: zod_1.z.string().nonempty(constants_1.validationError.personPhone),
17
- personName: zod_1.z.string().nonempty(constants_1.validationError.personName),
18
- preferenceId: zod_1.z.string().nonempty(constants_1.validationError.preferenceId),
19
+ personEmail: zod_1.z.string().nonempty(VALIDATION_KEYS.personEmailRequired),
20
+ personPhone: zod_1.z.string().nonempty(VALIDATION_KEYS.personPhoneRequired),
21
+ personName: zod_1.z.string().nonempty(VALIDATION_KEYS.personNameRequired),
22
+ preferenceId: zod_1.z.string().nonempty(VALIDATION_KEYS.preferenceIdRequired),
19
23
  });
@@ -1,83 +1,200 @@
1
- import { BranchTypeBE, PAYMENT_MODE_DRAWER, PaymentModeTypeBE } from './types';
1
+ /**
2
+ * Payment Mode Actions
3
+ *
4
+ * This module defines all action types and interfaces for the Payment Mode 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 (payment modes, pagination)
13
+ * - Search Actions (queries)
14
+ * - Union Type Export
15
+ * - Action Creators (helper functions)
16
+ * - Type Utilities (guards and helpers)
17
+ *
18
+ * Naming Convention: PaymentMode{Operation}{Target}Action
19
+ * Examples: PaymentModeSetInputFieldAction, PaymentModeResetFormAction
20
+ */
21
+ import { PAYMENT_MODE_DRAWER, PaymentModeForm, PaymentModeTypeBE } from "./types";
2
22
  export declare enum PAYMENT_MODE_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_PAYMENT_MODES = "SET_PAYMENT_MODES",
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
- export type PaymentModeSetErrorsAction = {
17
- type: PAYMENT_MODE_ACTION_TYPES.SET_ERRORS;
18
- payload: {
19
- errors: Record<string, string>;
20
- };
21
- };
22
- export type PaymentModeSetSearchQueryAction = {
23
- type: PAYMENT_MODE_ACTION_TYPES.SET_SEARCH_QUERY;
24
- payload: {
25
- searchQuery: string;
26
- };
36
+ /**
37
+ * Reset form validation errors
38
+ */
39
+ export type PaymentModeResetErrorsAction = {
40
+ type: PAYMENT_MODE_ACTION_TYPES.RESET_ERRORS;
27
41
  };
42
+ /**
43
+ * Reset entire form to initial state
44
+ */
28
45
  export type PaymentModeResetFormAction = {
29
46
  type: PAYMENT_MODE_ACTION_TYPES.RESET_FORM;
30
47
  };
31
- export type PaymentModeSetCountAction = {
32
- type: PAYMENT_MODE_ACTION_TYPES.SET_COUNT;
33
- payload: {
34
- count: number;
35
- };
36
- };
37
- export type PaymentModeSetPaymentModesAction = {
38
- type: PAYMENT_MODE_ACTION_TYPES.SET_PAYMENT_MODES;
48
+ /**
49
+ * Update individual form field dynamically
50
+ */
51
+ export type PaymentModeSetInputFieldAction = {
52
+ type: PAYMENT_MODE_ACTION_TYPES.SET_INPUT_FIELD;
39
53
  payload: {
40
- paymentModes: PaymentModeTypeBE[];
54
+ key: keyof PaymentModeForm;
55
+ value: string | string[] | boolean | number | number[];
41
56
  };
42
57
  };
58
+ /**
59
+ * Set entire form data (used when editing existing payment mode)
60
+ */
43
61
  export type PaymentModeSetFormAction = {
44
62
  type: PAYMENT_MODE_ACTION_TYPES.SET_FORM;
45
63
  payload: {
46
64
  form: PaymentModeTypeBE;
47
65
  };
48
66
  };
67
+ /**
68
+ * Set form validation errors
69
+ */
70
+ export type PaymentModeSetErrorsAction = {
71
+ type: PAYMENT_MODE_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 PaymentModeSetDisableSaveButtonAction = {
80
+ type: PAYMENT_MODE_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 PaymentModeSetDrawerAction = {
50
89
  type: PAYMENT_MODE_ACTION_TYPES.SET_DRAWER;
51
90
  payload: {
52
91
  drawer: null | PAYMENT_MODE_DRAWER;
53
92
  };
54
93
  };
55
- export type PaymentModeSetInputFieldAction = {
56
- type: PAYMENT_MODE_ACTION_TYPES.SET_INPUT_FIELD;
94
+ /**
95
+ * Set payment modes list data
96
+ */
97
+ export type PaymentModeSetPaymentModesAction = {
98
+ type: PAYMENT_MODE_ACTION_TYPES.SET_PAYMENT_MODES;
57
99
  payload: {
58
- key: keyof BranchTypeBE;
59
- value: string | string[] | boolean | number | number[];
100
+ paymentModes: PaymentModeTypeBE[];
60
101
  };
61
102
  };
62
- export type PaymentModeSetDisableSaveButtonAction = {
63
- type: PAYMENT_MODE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON;
103
+ /**
104
+ * Set total count of payment modes (for pagination)
105
+ */
106
+ export type PaymentModeSetCountAction = {
107
+ type: PAYMENT_MODE_ACTION_TYPES.SET_COUNT;
64
108
  payload: {
65
- disableSaveButton: boolean;
109
+ count: number;
66
110
  };
67
111
  };
68
- export type PaymentModeResetErrorsAction = {
69
- type: PAYMENT_MODE_ACTION_TYPES.RESET_ERRORS;
70
- };
112
+ /**
113
+ * Update current page number
114
+ */
71
115
  export type PaymentModeSetCurrentPageAction = {
72
116
  type: PAYMENT_MODE_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 PaymentModeSetPageLimitAction = {
78
125
  type: PAYMENT_MODE_ACTION_TYPES.SET_PAGE_LIMIT;
79
126
  payload: {
80
127
  pageLimit: number;
81
128
  };
82
129
  };
83
- export type PaymentModeActions = PaymentModeSetErrorsAction | PaymentModeSetCountAction | PaymentModeSetPaymentModesAction | PaymentModeSetFormAction | PaymentModeSetDrawerAction | PaymentModeSetInputFieldAction | PaymentModeSetDisableSaveButtonAction | PaymentModeResetErrorsAction | PaymentModeSetCurrentPageAction | PaymentModeSetPageLimitAction | PaymentModeResetFormAction | PaymentModeSetSearchQueryAction;
130
+ /**
131
+ * Update search query for payment modes
132
+ */
133
+ export type PaymentModeSetSearchQueryAction = {
134
+ type: PAYMENT_MODE_ACTION_TYPES.SET_SEARCH_QUERY;
135
+ payload: {
136
+ searchQuery: string;
137
+ };
138
+ };
139
+ /**
140
+ * All payment mode-related actions grouped by functionality
141
+ */
142
+ export type PaymentModeActions = PaymentModeResetErrorsAction | PaymentModeResetFormAction | PaymentModeSetInputFieldAction | PaymentModeSetFormAction | PaymentModeSetErrorsAction | PaymentModeSetDisableSaveButtonAction | PaymentModeSetDrawerAction | PaymentModeSetPaymentModesAction | PaymentModeSetCountAction | PaymentModeSetCurrentPageAction | PaymentModeSetPageLimitAction | PaymentModeSetSearchQueryAction;
143
+ /**
144
+ * Type guard for reset actions
145
+ */
146
+ export type PaymentModeResetActions = PaymentModeResetErrorsAction | PaymentModeResetFormAction;
147
+ /**
148
+ * Type guard for form-related actions
149
+ */
150
+ export type PaymentModeFormActions = PaymentModeSetInputFieldAction | PaymentModeSetFormAction | PaymentModeSetErrorsAction;
151
+ /**
152
+ * Type guard for UI state actions
153
+ */
154
+ export type PaymentModeUIActions = PaymentModeSetDisableSaveButtonAction | PaymentModeSetDrawerAction;
155
+ /**
156
+ * Type guard for list management actions
157
+ */
158
+ export type PaymentModeListActions = PaymentModeSetPaymentModesAction | PaymentModeSetCountAction | PaymentModeSetCurrentPageAction | PaymentModeSetPageLimitAction;
159
+ /**
160
+ * Action creators for common payment mode operations
161
+ * These provide type-safe action creation with better developer experience
162
+ */
163
+ export declare const paymentModeActionCreators: {
164
+ readonly resetErrors: () => PaymentModeResetErrorsAction;
165
+ readonly resetForm: () => PaymentModeResetFormAction;
166
+ readonly setInputField: (key: keyof PaymentModeForm, value: string | string[] | boolean | number | number[]) => PaymentModeSetInputFieldAction;
167
+ readonly setForm: (form: PaymentModeTypeBE) => PaymentModeSetFormAction;
168
+ readonly setErrors: (errors: Record<string, string>) => PaymentModeSetErrorsAction;
169
+ readonly setDisableSaveButton: (disableSaveButton: boolean) => PaymentModeSetDisableSaveButtonAction;
170
+ readonly setDrawer: (drawer: null | PAYMENT_MODE_DRAWER) => PaymentModeSetDrawerAction;
171
+ readonly setPaymentModes: (paymentModes: PaymentModeTypeBE[]) => PaymentModeSetPaymentModesAction;
172
+ readonly setCount: (count: number) => PaymentModeSetCountAction;
173
+ readonly setCurrentPage: (currentPage: number) => PaymentModeSetCurrentPageAction;
174
+ readonly setPageLimit: (pageLimit: number) => PaymentModeSetPageLimitAction;
175
+ readonly setSearchQuery: (searchQuery: string) => PaymentModeSetSearchQueryAction;
176
+ };
177
+ /**
178
+ * Extract action type from action object
179
+ */
180
+ export type ActionType<T extends PaymentModeActions> = T["type"];
181
+ /**
182
+ * Extract payload type from action object
183
+ */
184
+ export type ActionPayload<T extends PaymentModeActions> = 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 PaymentModeActions> = T extends {
191
+ payload: unknown;
192
+ } ? true : false;
193
+ /**
194
+ * Runtime type guards for action validation
195
+ */
196
+ export declare const isPaymentModeAction: (action: unknown) => action is PaymentModeActions;
197
+ /**
198
+ * Type guard for reset actions
199
+ */
200
+ export declare const isResetAction: (action: PaymentModeActions) => action is PaymentModeResetActions;