@appcorp/stellar-solutions-modules 0.1.55 → 0.1.58
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/global-modules/bank/bank.d.ts +7 -1
- package/global-modules/bank/bank.js +5 -19
- package/global-modules/bank/constants.js +5 -5
- package/global-modules/bank/context.js +39 -41
- package/global-modules/bank/drawer.d.ts +0 -4
- package/global-modules/bank/drawer.js +8 -6
- package/global-modules/bank/form.d.ts +0 -3
- package/global-modules/bank/form.js +16 -13
- package/global-modules/bank/types.d.ts +2 -22
- package/global-modules/bank/validate.js +2 -2
- package/global-modules/branch/branch.d.ts +7 -1
- package/global-modules/branch/branch.js +6 -16
- package/global-modules/branch/constants.js +1 -1
- package/global-modules/branch/context.js +35 -21
- package/global-modules/branch/drawer.d.ts +0 -4
- package/global-modules/branch/drawer.js +8 -6
- package/global-modules/branch/form.d.ts +0 -3
- package/global-modules/branch/form.js +11 -12
- package/global-modules/branch/types.d.ts +9 -106
- package/global-modules/branch/validate.js +6 -6
- package/global-modules/currency/actions.d.ts +203 -0
- package/global-modules/currency/actions.js +153 -0
- package/global-modules/currency/constants.d.ts +33 -0
- package/global-modules/currency/constants.js +71 -0
- package/global-modules/currency/context.d.ts +41 -0
- package/global-modules/currency/context.js +422 -0
- package/global-modules/currency/currency.d.ts +8 -0
- package/global-modules/currency/currency.js +57 -0
- package/global-modules/currency/drawer.d.ts +27 -0
- package/global-modules/currency/drawer.js +76 -0
- package/global-modules/currency/form.d.ts +19 -0
- package/global-modules/currency/form.js +52 -0
- package/global-modules/currency/reducer.d.ts +25 -0
- package/global-modules/currency/reducer.js +153 -0
- package/global-modules/currency/types.d.ts +163 -0
- package/global-modules/currency/types.js +44 -0
- package/global-modules/currency/validate.d.ts +9 -0
- package/global-modules/currency/validate.js +18 -0
- package/global-modules/payment-mode/constants.js +1 -1
- package/global-modules/payment-mode/context.js +7 -9
- package/global-modules/payment-mode/drawer.d.ts +0 -4
- package/global-modules/payment-mode/drawer.js +8 -6
- package/global-modules/payment-mode/form.d.ts +0 -3
- package/global-modules/payment-mode/form.js +6 -7
- package/global-modules/payment-mode/payment-mode.d.ts +1 -1
- package/global-modules/payment-mode/payment-mode.js +38 -38
- package/global-modules/payment-mode/types.d.ts +12 -223
- package/global-modules/payment-mode/types.js +1 -9
- package/global-modules/payment-mode/validate.js +2 -2
- package/global-modules/preferences/constants.d.ts +0 -4
- package/global-modules/preferences/constants.js +14 -17
- package/global-modules/preferences/context.js +2 -1
- package/global-modules/preferences/preferences.js +2 -6
- package/global-modules/preferences/types.d.ts +14 -240
- package/global-modules/preferences/types.js +3 -6
- package/global-modules/tax/constants.js +1 -1
- package/global-modules/tax/context.js +8 -4
- package/global-modules/tax/drawer.d.ts +0 -4
- package/global-modules/tax/drawer.js +8 -6
- package/global-modules/tax/form.d.ts +0 -4
- package/global-modules/tax/form.js +6 -7
- package/global-modules/tax/tax.d.ts +1 -1
- package/global-modules/tax/tax.js +37 -37
- package/global-modules/tax/types.d.ts +9 -254
- package/global-modules/tax/types.js +1 -9
- package/i18n/routing.d.ts +1 -1
- package/package.json +3 -3
|
@@ -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
|
+
});
|
|
@@ -96,7 +96,7 @@ var usePaymentModeState = function () {
|
|
|
96
96
|
// STATE & CORE HOOKS
|
|
97
97
|
// ---------------------------------------------------------------------------
|
|
98
98
|
var _a = (0, react_1.useReducer)(reducer_1.paymentModeReducer, reducer_1.initialPaymentModeState), state = _a[0], dispatch = _a[1];
|
|
99
|
-
var
|
|
99
|
+
var preferences = (0, context_1.usePreferenceStateContext)().preferences;
|
|
100
100
|
var theme = (0, next_themes_1.useTheme)().theme;
|
|
101
101
|
var t = (0, next_intl_1.useTranslations)("paymentMode");
|
|
102
102
|
var tCommon = (0, next_intl_1.useTranslations)("common");
|
|
@@ -207,7 +207,7 @@ var usePaymentModeState = function () {
|
|
|
207
207
|
// ---------------------------------------------------------------------------
|
|
208
208
|
// MODULE ENTITY HOOK
|
|
209
209
|
// ---------------------------------------------------------------------------
|
|
210
|
-
var
|
|
210
|
+
var _b = (0, util_functions_1.useModuleEntity)({
|
|
211
211
|
byIdCallback: byIdCallback,
|
|
212
212
|
byIdParams: byIdParams,
|
|
213
213
|
deleteCallback: deleteCallback,
|
|
@@ -215,22 +215,20 @@ var usePaymentModeState = function () {
|
|
|
215
215
|
listCallback: listCallback,
|
|
216
216
|
listParams: listParams,
|
|
217
217
|
listUrl: constants_1.PAYMENT_MODE_API_ROUTES.PAYMENT_MODES,
|
|
218
|
-
searchQuery:
|
|
218
|
+
searchQuery: debouncedQuery,
|
|
219
219
|
unitByIdUrl: constants_1.PAYMENT_MODE_API_ROUTES.PAYMENT_MODE_BY_ID,
|
|
220
220
|
unitUrl: constants_1.PAYMENT_MODE_API_ROUTES.PAYMENT_MODE,
|
|
221
221
|
updateCallback: updateCallback,
|
|
222
222
|
updateDeps: [state],
|
|
223
223
|
updateParams: updateParams,
|
|
224
|
-
}), byIdError =
|
|
224
|
+
}), byIdError = _b.byIdError, byIdFetchNow = _b.byIdFetchNow, byIdLoading = _b.byIdLoading, deleteError = _b.deleteError, deleteFetchNow = _b.deleteFetchNow, deleteLoading = _b.deleteLoading, listError = _b.listError, listFetchNow = _b.listFetchNow, listLoading = _b.listLoading, updateError = _b.updateError, updateFetchNow = _b.updateFetchNow, updateLoading = _b.updateLoading;
|
|
225
225
|
// ---------------------------------------------------------------------------
|
|
226
226
|
// EFFECTS (list refresh)
|
|
227
227
|
// ---------------------------------------------------------------------------
|
|
228
228
|
(0, react_1.useEffect)(function () {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
233
|
-
}, [debouncedQuery, state.currentPage, state.pageLimit, activeTab]);
|
|
229
|
+
listFetchNow();
|
|
230
|
+
// eslint-disable-next-line
|
|
231
|
+
}, [debouncedQuery, state.currentPage, state.pageLimit]);
|
|
234
232
|
// ---------------------------------------------------------------------------
|
|
235
233
|
// DRAWER & MODAL HANDLERS
|
|
236
234
|
// ---------------------------------------------------------------------------
|
|
@@ -22,10 +22,6 @@ import { FC } from "react";
|
|
|
22
22
|
interface PaymentModeDrawerProps {
|
|
23
23
|
/** Whether the interface is in RTL (Right-to-Left) mode */
|
|
24
24
|
isRTL: boolean;
|
|
25
|
-
/** Translation map for internationalization */
|
|
26
|
-
translationMap: {
|
|
27
|
-
[key: string]: string;
|
|
28
|
-
};
|
|
29
25
|
}
|
|
30
26
|
export declare const PaymentModeDrawer: FC<PaymentModeDrawerProps>;
|
|
31
27
|
export {};
|
|
@@ -30,6 +30,7 @@ var button_1 = require("@appcorp/shadcn/components/button");
|
|
|
30
30
|
var drawer_1 = require("@appcorp/shadcn/components/drawer");
|
|
31
31
|
var context_1 = require("./context");
|
|
32
32
|
var form_1 = require("./form");
|
|
33
|
+
var next_intl_1 = require("next-intl");
|
|
33
34
|
// ============================================================================
|
|
34
35
|
// CONSTANTS
|
|
35
36
|
// ============================================================================
|
|
@@ -43,10 +44,11 @@ var getDrawerDirection = function (isRTL) {
|
|
|
43
44
|
// COMPONENT
|
|
44
45
|
// ============================================================================
|
|
45
46
|
var PaymentModeDrawer = function (_a) {
|
|
47
|
+
var isRTL = _a.isRTL;
|
|
48
|
+
var t = (0, next_intl_1.useTranslations)("paymentMode");
|
|
46
49
|
// ============================================================================
|
|
47
50
|
// HOOKS & STATE
|
|
48
51
|
// ============================================================================
|
|
49
|
-
var isRTL = _a.isRTL, translationMap = _a.translationMap;
|
|
50
52
|
var _b = (0, context_1.usePaymentModeStateContext)(), closeDrawer = _b.closeDrawer, disableSaveButton = _b.disableSaveButton, drawer = _b.drawer, handleSubmit = _b.handleSubmit;
|
|
51
53
|
// ============================================================================
|
|
52
54
|
// COMPUTED VALUES
|
|
@@ -59,17 +61,17 @@ var PaymentModeDrawer = function (_a) {
|
|
|
59
61
|
return (react_1.default.createElement(drawer_1.Drawer, { open: isDrawerOpen, onOpenChange: function (open) { return !open && closeDrawer(); }, direction: drawerDirection },
|
|
60
62
|
react_1.default.createElement(drawer_1.DrawerContent, { className: "h-full ".concat(DRAWER_WIDTH, " ").concat(isRTL ? "rtl" : "ltr"), dir: isRTL ? "rtl" : "ltr" },
|
|
61
63
|
react_1.default.createElement(drawer_1.DrawerHeader, { className: "flex-row items-center justify-between border-b pb-4 ".concat(isRTL ? "flex-row-reverse" : "") },
|
|
62
|
-
react_1.default.createElement(drawer_1.DrawerTitle, { className: "text-xl font-semibold flex items-center ".concat(isRTL ? "flex-row-reverse gap-2" : "gap-2") }, (
|
|
64
|
+
react_1.default.createElement(drawer_1.DrawerTitle, { className: "text-xl font-semibold flex items-center ".concat(isRTL ? "flex-row-reverse gap-2" : "gap-2") }, t("drawerTitlePaymentMode")),
|
|
63
65
|
react_1.default.createElement(drawer_1.DrawerClose, { asChild: true },
|
|
64
66
|
react_1.default.createElement(button_1.Button, { variant: "ghost", size: "icon", className: "h-8 w-8" },
|
|
65
67
|
react_1.default.createElement(lucide_react_1.X, { className: "h-4 w-4" }),
|
|
66
|
-
react_1.default.createElement("span", { className: "sr-only" }, (
|
|
68
|
+
react_1.default.createElement("span", { className: "sr-only" }, t("drawerButtonClose"))))),
|
|
67
69
|
react_1.default.createElement("div", { className: "flex-1 overflow-y-auto px-4 py-6 ".concat(isRTL ? "text-right" : "text-left") },
|
|
68
|
-
react_1.default.createElement(form_1.PaymentModeForm, { isRTL: isRTL
|
|
70
|
+
react_1.default.createElement(form_1.PaymentModeForm, { isRTL: isRTL })),
|
|
69
71
|
react_1.default.createElement(drawer_1.DrawerFooter, { className: "border-t pt-4" },
|
|
70
72
|
react_1.default.createElement("div", { className: "flex gap-2 ".concat(isRTL ? "flex-row-reverse" : "") },
|
|
71
|
-
react_1.default.createElement(button_1.Button, { variant: "outline", onClick: closeDrawer, className: "flex-1", type: "button" }, (
|
|
72
|
-
react_1.default.createElement(button_1.Button, { onClick: handleSubmit, disabled: disableSaveButton, className: "flex-1", type: "button" }, (
|
|
73
|
+
react_1.default.createElement(button_1.Button, { variant: "outline", onClick: closeDrawer, className: "flex-1", type: "button" }, t("drawerButtonCancel")),
|
|
74
|
+
react_1.default.createElement(button_1.Button, { onClick: handleSubmit, disabled: disableSaveButton, className: "flex-1", type: "button" }, t("drawerButtonSave")))))));
|
|
73
75
|
};
|
|
74
76
|
exports.PaymentModeDrawer = PaymentModeDrawer;
|
|
75
77
|
// ============================================================================
|
|
@@ -23,9 +23,8 @@ var input_1 = require("@appcorp/shadcn/components/input");
|
|
|
23
23
|
var switch_1 = require("@appcorp/shadcn/components/switch");
|
|
24
24
|
var context_1 = require("./context");
|
|
25
25
|
var PaymentModeForm = function (_a) {
|
|
26
|
-
var isRTL = _a.isRTL
|
|
27
|
-
var t = (0, next_intl_1.useTranslations)("
|
|
28
|
-
var ui = (0, next_intl_1.useTranslations)("ui");
|
|
26
|
+
var isRTL = _a.isRTL;
|
|
27
|
+
var t = (0, next_intl_1.useTranslations)("paymentMode");
|
|
29
28
|
var _b = (0, context_1.usePaymentModeStateContext)(), enabled = _b.enabled, errors = _b.errors, handleInputChange = _b.handleInputChange, isDefault = _b.isDefault, label = _b.label;
|
|
30
29
|
// Helper function to translate validation error keys
|
|
31
30
|
var getTranslatedError = function (key) {
|
|
@@ -40,11 +39,11 @@ var PaymentModeForm = function (_a) {
|
|
|
40
39
|
return (react_1.default.createElement("div", { className: "space-y-6 ".concat(isRTL ? "rtl" : "ltr"), dir: isRTL ? "rtl" : "ltr" },
|
|
41
40
|
react_1.default.createElement("div", { className: "space-y-4" },
|
|
42
41
|
react_1.default.createElement("div", { className: "space-y-2" },
|
|
43
|
-
react_1.default.createElement(input_1.Input, { id: "label", type: "text", label: (
|
|
42
|
+
react_1.default.createElement(input_1.Input, { id: "label", type: "text", label: t("formLabelLabel"), value: label || "", onChange: function (e) { return handleInputChange("label", e.target.value); }, placeholder: t("formPlaceholderLabel"), info: t("formInfoLabel"), error: getTranslatedError("label"), required: true })),
|
|
44
43
|
react_1.default.createElement("div", { className: "space-y-4" },
|
|
45
|
-
react_1.default.createElement(switch_1.Switch, { id: "enabled", label: (
|
|
46
|
-
react_1.default.createElement(switch_1.Switch, { id: "isDefault", label: (
|
|
44
|
+
react_1.default.createElement(switch_1.Switch, { id: "enabled", label: t("formLabelEnabled"), checked: enabled || false, onCheckedChange: function (checked) { return handleInputChange("enabled", checked); }, info: t("formInfoEnabled"), error: getTranslatedError("enabled") }),
|
|
45
|
+
react_1.default.createElement(switch_1.Switch, { id: "isDefault", label: t("formLabelIsDefault"), checked: isDefault || false, onCheckedChange: function (checked) {
|
|
47
46
|
return handleInputChange("isDefault", checked);
|
|
48
|
-
}, info:
|
|
47
|
+
}, info: t("formInfoIsDefault"), error: getTranslatedError("isDefault") })))));
|
|
49
48
|
};
|
|
50
49
|
exports.PaymentModeForm = PaymentModeForm;
|