@appcorp/stellar-solutions-modules 0.1.56 → 0.1.59

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 (40) hide show
  1. package/global-modules/bank/constants.d.ts +2 -2
  2. package/global-modules/bank/constants.js +11 -11
  3. package/global-modules/bank/drawer.js +1 -1
  4. package/global-modules/bank/types.d.ts +2 -22
  5. package/global-modules/branch/constants.d.ts +2 -2
  6. package/global-modules/branch/constants.js +11 -11
  7. package/global-modules/branch/types.d.ts +9 -106
  8. package/global-modules/currency/actions.d.ts +203 -0
  9. package/global-modules/currency/actions.js +153 -0
  10. package/global-modules/currency/constants.d.ts +33 -0
  11. package/global-modules/currency/constants.js +71 -0
  12. package/global-modules/currency/context.d.ts +41 -0
  13. package/global-modules/currency/context.js +422 -0
  14. package/global-modules/currency/currency.d.ts +8 -0
  15. package/global-modules/currency/currency.js +57 -0
  16. package/global-modules/currency/drawer.d.ts +27 -0
  17. package/global-modules/currency/drawer.js +76 -0
  18. package/global-modules/currency/form.d.ts +19 -0
  19. package/global-modules/currency/form.js +52 -0
  20. package/global-modules/currency/reducer.d.ts +25 -0
  21. package/global-modules/currency/reducer.js +153 -0
  22. package/global-modules/currency/types.d.ts +163 -0
  23. package/global-modules/currency/types.js +44 -0
  24. package/global-modules/currency/validate.d.ts +9 -0
  25. package/global-modules/currency/validate.js +18 -0
  26. package/global-modules/payment-mode/constants.d.ts +2 -2
  27. package/global-modules/payment-mode/constants.js +7 -7
  28. package/global-modules/payment-mode/types.d.ts +12 -223
  29. package/global-modules/payment-mode/types.js +1 -9
  30. package/global-modules/preferences/context.js +27 -27
  31. package/global-modules/preferences/preferences.js +2 -3
  32. package/global-modules/preferences/types.d.ts +14 -240
  33. package/global-modules/preferences/types.js +3 -6
  34. package/global-modules/tax/constants.d.ts +2 -2
  35. package/global-modules/tax/constants.js +9 -9
  36. package/global-modules/tax/context.js +3 -2
  37. package/global-modules/tax/types.d.ts +9 -254
  38. package/global-modules/tax/types.js +1 -9
  39. package/i18n/routing.d.ts +1 -1
  40. package/package.json +2 -2
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Currency State Reducer
3
+ *
4
+ * This module manages the state transitions for the Currency 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 currency 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 { CurrencyActions } from "./actions";
23
+ import { CurrencyState } from "./types";
24
+ export declare const initialCurrencyState: CurrencyState;
25
+ export declare function currencyReducer(state: CurrencyState, action: CurrencyActions): CurrencyState;
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ /**
3
+ * Currency State Reducer
4
+ *
5
+ * This module manages the state transitions for the Currency 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 currency 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.initialCurrencyState = void 0;
45
+ exports.currencyReducer = currencyReducer;
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
+ code: "",
56
+ enabled: false,
57
+ errors: {},
58
+ id: "",
59
+ isDefault: false,
60
+ label: "",
61
+ preferenceId: "",
62
+ disableSaveButton: false,
63
+ }); };
64
+ /**
65
+ * Helper function to safely update array state with immutability
66
+ */
67
+ var updateArrayState = function (array) { return __spreadArray([], array, true); };
68
+ /**
69
+ * Helper function to safely merge errors with existing state
70
+ */
71
+ var mergeErrors = function (errors) { return (__assign({}, errors)); };
72
+ // ============================================================================
73
+ // INITIAL STATE
74
+ // ============================================================================
75
+ exports.initialCurrencyState = {
76
+ // Currency Form Data
77
+ code: "",
78
+ enabled: false,
79
+ id: "",
80
+ isDefault: false,
81
+ label: "",
82
+ preferenceId: "",
83
+ // List Data
84
+ currencies: [],
85
+ count: 0,
86
+ // Search & Pagination
87
+ currentPage: 1,
88
+ pageLimit: constants_1.pageLimit,
89
+ searchQuery: "",
90
+ // UI State
91
+ disableSaveButton: false,
92
+ drawer: null,
93
+ // Errors
94
+ errors: {},
95
+ };
96
+ // ============================================================================
97
+ // REDUCER FUNCTION
98
+ // ============================================================================
99
+ function currencyReducer(state, action) {
100
+ var _a;
101
+ switch (action.type) {
102
+ // ------------------------------------------------------------------------
103
+ // FORM RESET ACTIONS
104
+ // ------------------------------------------------------------------------
105
+ case actions_1.CURRENCY_ACTION_TYPES.RESET_ERRORS:
106
+ return __assign(__assign({}, state), { errors: {} });
107
+ case actions_1.CURRENCY_ACTION_TYPES.RESET_FORM:
108
+ return __assign(__assign({}, state), getFormResetState());
109
+ // ------------------------------------------------------------------------
110
+ // FORM INPUT ACTIONS
111
+ // ------------------------------------------------------------------------
112
+ case actions_1.CURRENCY_ACTION_TYPES.SET_INPUT_FIELD:
113
+ return __assign(__assign({}, state), (_a = {}, _a[action.payload.key] = action.payload.value, _a));
114
+ case actions_1.CURRENCY_ACTION_TYPES.SET_FORM:
115
+ return __assign(__assign({}, state), action.payload.form);
116
+ // ------------------------------------------------------------------------
117
+ // ERROR HANDLING ACTIONS
118
+ // ------------------------------------------------------------------------
119
+ case actions_1.CURRENCY_ACTION_TYPES.SET_ERRORS:
120
+ return __assign(__assign({}, state), { disableSaveButton: false, errors: mergeErrors(action.payload.errors) });
121
+ // ------------------------------------------------------------------------
122
+ // UI STATE ACTIONS
123
+ // ------------------------------------------------------------------------
124
+ case actions_1.CURRENCY_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON:
125
+ return __assign(__assign({}, state), { disableSaveButton: action.payload.disableSaveButton });
126
+ case actions_1.CURRENCY_ACTION_TYPES.SET_DRAWER:
127
+ return __assign(__assign({}, state), { drawer: action.payload.drawer });
128
+ // ------------------------------------------------------------------------
129
+ // LIST DATA ACTIONS
130
+ // ------------------------------------------------------------------------
131
+ case actions_1.CURRENCY_ACTION_TYPES.SET_CURRENCIES:
132
+ return __assign(__assign({}, state), { currencies: updateArrayState(action.payload.currencies) });
133
+ case actions_1.CURRENCY_ACTION_TYPES.SET_COUNT:
134
+ return __assign(__assign({}, state), { count: action.payload.count });
135
+ // ------------------------------------------------------------------------
136
+ // PAGINATION ACTIONS
137
+ // ------------------------------------------------------------------------
138
+ case actions_1.CURRENCY_ACTION_TYPES.SET_CURRENT_PAGE:
139
+ return __assign(__assign({}, state), { currentPage: action.payload.currentPage });
140
+ case actions_1.CURRENCY_ACTION_TYPES.SET_PAGE_LIMIT:
141
+ return __assign(__assign({}, state), { pageLimit: action.payload.pageLimit });
142
+ // ------------------------------------------------------------------------
143
+ // SEARCH ACTIONS
144
+ // ------------------------------------------------------------------------
145
+ case actions_1.CURRENCY_ACTION_TYPES.SET_SEARCH_QUERY:
146
+ return __assign(__assign({}, state), { searchQuery: action.payload.searchQuery });
147
+ // ------------------------------------------------------------------------
148
+ // DEFAULT CASE
149
+ // ------------------------------------------------------------------------
150
+ default:
151
+ return state;
152
+ }
153
+ }
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Currency Module Types
3
+ *
4
+ * This module defines all TypeScript interfaces, types, and enums for the Currency feature.
5
+ * Provides type safety and clear contracts for all currency-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
+ * - Currency management with code and symbol
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 "@appcorp/shadcn/components/enhanced-table";
27
+ import { CurrencyActions } from "./actions";
28
+ import { CurrencyBE as CurrencyTypeBE } from "@react-pakistan/util-functions/api/stellar-solutions/type";
29
+ /**
30
+ * Currency Context Interface
31
+ *
32
+ * Defines the complete context API for currency state management.
33
+ * Includes all handlers, state getters, and utility functions.
34
+ */
35
+ export interface CurrencyContextType {
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<CurrencyActions>;
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
+ export type { CurrencyTypeBE };
57
+ /**
58
+ * Currency Component State
59
+ *
60
+ * Complete state interface for the currency module components.
61
+ * Extends entity data with UI state, form state, and search capabilities.
62
+ */
63
+ export interface CurrencyState extends Omit<CurrencyTypeBE, "preference" | "createdAt" | "updatedAt"> {
64
+ currencies: CurrencyTypeBE[];
65
+ count: number;
66
+ currentPage: number;
67
+ pageLimit: number;
68
+ searchQuery: string;
69
+ disableSaveButton: boolean;
70
+ drawer: null | CURRENCY_DRAWER;
71
+ preferenceId: string;
72
+ errors: Record<string, string>;
73
+ }
74
+ /**
75
+ * Fetch Currencies API Arguments
76
+ *
77
+ * Parameters for currency list API requests.
78
+ * Supports pagination and search functionality.
79
+ */
80
+ export interface FetchCurrenciesArgs {
81
+ currentPage: number;
82
+ pageLimit: number;
83
+ searchQuery?: string;
84
+ }
85
+ /**
86
+ * Currency API Response
87
+ *
88
+ * Standard API response format for currency operations.
89
+ */
90
+ export interface CurrencyApiResponse {
91
+ data?: CurrencyTypeBE[];
92
+ count?: number;
93
+ error?: string;
94
+ success: boolean;
95
+ }
96
+ /**
97
+ * Update Currency Arguments
98
+ *
99
+ * Parameters for currency update operations.
100
+ */
101
+ export interface UpdateCurrencyArgs {
102
+ id: string;
103
+ code: string;
104
+ enabled: boolean;
105
+ isDefault: boolean;
106
+ name: string;
107
+ symbol: string;
108
+ }
109
+ /**
110
+ * Currency Drawer Types
111
+ *
112
+ * Enumeration of available drawer states for currency operations.
113
+ */
114
+ export declare enum CURRENCY_DRAWER {
115
+ FILTER_DRAWER = "FILTER_DRAWER",
116
+ FORM_DRAWER = "FORM_DRAWER"
117
+ }
118
+ export declare enum CURRENCY_MODAL {
119
+ DUMMY = "DUMMY"
120
+ }
121
+ /**
122
+ * Currency Form Fields
123
+ *
124
+ * Utility type for currency form field keys.
125
+ * Useful for form validation and dynamic field handling.
126
+ */
127
+ export type CurrencyFormFields = keyof Omit<CurrencyTypeBE, "id" | "createdAt" | "updatedAt" | "preference">;
128
+ /**
129
+ * Currency Required Fields
130
+ *
131
+ * Fields that are mandatory for currency creation.
132
+ */
133
+ export type CurrencyRequiredFields = "code" | "name" | "symbol" | "preferenceId";
134
+ /**
135
+ * Currency Optional Fields
136
+ *
137
+ * Fields that are optional for currency creation.
138
+ */
139
+ export type CurrencyOptionalFields = "enabled" | "isDefault";
140
+ /**
141
+ * Currency Form Type
142
+ *
143
+ * Complete form interface for currency operations.
144
+ * Combines required and optional fields.
145
+ */
146
+ export interface CurrencyForm extends Record<CurrencyRequiredFields, string>, Partial<Record<CurrencyOptionalFields, boolean>> {
147
+ }
148
+ /**
149
+ * Currency Sort Fields
150
+ *
151
+ * Fields available for sorting currency lists.
152
+ */
153
+ export type CurrencySortField = "name" | "code" | "symbol" | "createdAt" | "updatedAt";
154
+ /**
155
+ * Currency Filter Options
156
+ *
157
+ * Available filter options for currency lists.
158
+ */
159
+ export interface CurrencyFilterOptions {
160
+ enabled?: boolean;
161
+ isDefault?: boolean;
162
+ searchQuery?: string;
163
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /**
3
+ * Currency Module Types
4
+ *
5
+ * This module defines all TypeScript interfaces, types, and enums for the Currency feature.
6
+ * Provides type safety and clear contracts for all currency-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
+ * - Currency management with code and symbol
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.CURRENCY_MODAL = exports.CURRENCY_DRAWER = void 0;
28
+ // ============================================================================
29
+ // UI ENUMS (Component State Definitions)
30
+ // ============================================================================
31
+ /**
32
+ * Currency Drawer Types
33
+ *
34
+ * Enumeration of available drawer states for currency operations.
35
+ */
36
+ var CURRENCY_DRAWER;
37
+ (function (CURRENCY_DRAWER) {
38
+ CURRENCY_DRAWER["FILTER_DRAWER"] = "FILTER_DRAWER";
39
+ CURRENCY_DRAWER["FORM_DRAWER"] = "FORM_DRAWER";
40
+ })(CURRENCY_DRAWER || (exports.CURRENCY_DRAWER = CURRENCY_DRAWER = {}));
41
+ var CURRENCY_MODAL;
42
+ (function (CURRENCY_MODAL) {
43
+ CURRENCY_MODAL["DUMMY"] = "DUMMY";
44
+ })(CURRENCY_MODAL || (exports.CURRENCY_MODAL = CURRENCY_MODAL = {}));
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ export declare const formValidation: z.ZodObject<{
3
+ code: z.ZodString;
4
+ enabled: z.ZodBoolean;
5
+ isDefault: z.ZodBoolean;
6
+ label: z.ZodString;
7
+ preferenceId: z.ZodString;
8
+ }, z.core.$strip>;
9
+ export type FormValidate = z.infer<typeof formValidation>;
@@ -0,0 +1,18 @@
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
+ codeRequired: "validationCodeRequired",
8
+ nameRequired: "validationNameRequired",
9
+ preferenceIdRequired: "validationCurrencyPreferenceIdRequired",
10
+ symbolRequired: "validationSymbolRequired",
11
+ };
12
+ exports.formValidation = zod_1.z.object({
13
+ code: zod_1.z.string().nonempty(VALIDATION_KEYS.codeRequired),
14
+ enabled: zod_1.z.boolean(),
15
+ isDefault: zod_1.z.boolean(),
16
+ label: zod_1.z.string().nonempty(VALIDATION_KEYS.nameRequired),
17
+ preferenceId: zod_1.z.string().nonempty(VALIDATION_KEYS.preferenceIdRequired),
18
+ });
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * Naming Convention: Descriptive names with clear purpose
14
14
  */
15
- import { VISTA_TABLE_CELL_TYPE } from "@appcorp/app-corp-vista/type/vista-table-type";
15
+ import { COMPONENT_TYPE } from "@appcorp/shadcn/components/enhanced-table";
16
16
  /**
17
17
  * Default page limit for pagination
18
18
  */
@@ -29,7 +29,7 @@ export declare const PAYMENT_MODE_API_ROUTES: {
29
29
  * Table column definitions for payment mode listing
30
30
  */
31
31
  export declare const tableBodyCols: {
32
- componentType: VISTA_TABLE_CELL_TYPE;
32
+ componentType: COMPONENT_TYPE;
33
33
  key: string;
34
34
  }[];
35
35
  /**
@@ -15,7 +15,7 @@
15
15
  */
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.toastErrors = exports.tableBodyCols = exports.PAYMENT_MODE_API_ROUTES = exports.pageLimit = void 0;
18
- var vista_table_type_1 = require("@appcorp/app-corp-vista/type/vista-table-type");
18
+ var enhanced_table_1 = require("@appcorp/shadcn/components/enhanced-table");
19
19
  // ============================================================================
20
20
  // PAGE CONFIGURATION
21
21
  // ============================================================================
@@ -42,27 +42,27 @@ exports.PAYMENT_MODE_API_ROUTES = {
42
42
  */
43
43
  exports.tableBodyCols = [
44
44
  {
45
- componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.ID,
45
+ componentType: enhanced_table_1.COMPONENT_TYPE.ID,
46
46
  key: "id",
47
47
  },
48
48
  {
49
- componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.BOLD_TEXT,
49
+ componentType: enhanced_table_1.COMPONENT_TYPE.BOLD_TEXT,
50
50
  key: "label",
51
51
  },
52
52
  {
53
- componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.BOOLEAN,
53
+ componentType: enhanced_table_1.COMPONENT_TYPE.BOOLEAN,
54
54
  key: "enabled",
55
55
  },
56
56
  {
57
- componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.BOOLEAN,
57
+ componentType: enhanced_table_1.COMPONENT_TYPE.BOOLEAN,
58
58
  key: "isDefault",
59
59
  },
60
60
  {
61
- componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.CREATED_UPDATED_AT,
61
+ componentType: enhanced_table_1.COMPONENT_TYPE.CREATED_UPDATED_AT,
62
62
  key: "createdAt",
63
63
  },
64
64
  {
65
- componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.ACTIONS,
65
+ componentType: enhanced_table_1.COMPONENT_TYPE.ACTIONS,
66
66
  key: "action",
67
67
  },
68
68
  ];