@appcorp/stellar-solutions-modules 0.1.56 → 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/types.d.ts +2 -22
- package/global-modules/branch/types.d.ts +9 -106
- 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/types.d.ts +12 -223
- package/global-modules/payment-mode/types.js +1 -9
- package/global-modules/preferences/context.js +2 -1
- package/global-modules/preferences/types.d.ts +14 -240
- package/global-modules/preferences/types.js +3 -6
- package/global-modules/tax/context.js +3 -2
- 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 +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
|
+
});
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
import { Dispatch } from "react";
|
|
26
26
|
import { RowAction, HeaderAction } from "@appcorp/shadcn/components/enhanced-table";
|
|
27
27
|
import { PaymentModeActions } from "./actions";
|
|
28
|
+
import { BankBE as BankTypeBE, BranchBE as BranchTypeBE, CurrencyBE as CurrencyTypeBE, MenuOrderBE as MenuOrderTypeBE, PaymentBE as PaymentTypeBE, PaymentModeBE as PaymentModeTypeBE, PreferenceBE as PreferenceTypeBE, TaxBE as TaxTypeBE } from "@react-pakistan/util-functions/api/stellar-solutions/type";
|
|
28
29
|
/**
|
|
29
30
|
* Payment Mode Context Interface
|
|
30
31
|
*
|
|
@@ -58,56 +59,19 @@ export interface PaymentModeContextType {
|
|
|
58
59
|
* Represents the complete payment mode data structure as received from the API.
|
|
59
60
|
* Includes all payment mode-specific fields and relationships.
|
|
60
61
|
*/
|
|
61
|
-
export
|
|
62
|
-
createdAt: string;
|
|
63
|
-
enabled: boolean;
|
|
64
|
-
id: string;
|
|
65
|
-
isDefault: boolean;
|
|
66
|
-
label: string;
|
|
67
|
-
payments?: PaymentTypeBE[];
|
|
68
|
-
preference?: PreferenceTypeBE;
|
|
69
|
-
preferenceId: string;
|
|
70
|
-
updatedAt: string;
|
|
71
|
-
}
|
|
62
|
+
export type { PaymentModeTypeBE };
|
|
72
63
|
/**
|
|
73
64
|
* Payment Backend Entity
|
|
74
65
|
*
|
|
75
66
|
* Represents payment data structure with payment mode relationship.
|
|
76
67
|
*/
|
|
77
|
-
export
|
|
78
|
-
amount: string;
|
|
79
|
-
attachment?: string;
|
|
80
|
-
balance: string;
|
|
81
|
-
createdAt: string;
|
|
82
|
-
currency: string;
|
|
83
|
-
date: string;
|
|
84
|
-
description?: string;
|
|
85
|
-
id: string;
|
|
86
|
-
paymentMode?: PaymentModeTypeBE;
|
|
87
|
-
paymentModeId: string;
|
|
88
|
-
paymentType: PAYMENT_TYPE;
|
|
89
|
-
quoteInvoice?: undefined;
|
|
90
|
-
quoteInvoiceId: string;
|
|
91
|
-
ref: string;
|
|
92
|
-
updatedAt: string;
|
|
93
|
-
}
|
|
68
|
+
export type { PaymentTypeBE };
|
|
94
69
|
/**
|
|
95
70
|
* Preference Backend Entity
|
|
96
71
|
*
|
|
97
72
|
* Represents preference data structure containing payment modes.
|
|
98
73
|
*/
|
|
99
|
-
export
|
|
100
|
-
bankingDetails: BankingDetailTypeBE[];
|
|
101
|
-
branches: BranchTypeBE[];
|
|
102
|
-
createdAt: string;
|
|
103
|
-
currencies: CurrencyTypeBE[];
|
|
104
|
-
id: string;
|
|
105
|
-
menuOrder: MenuOrderTypeBE[];
|
|
106
|
-
onboarding: boolean;
|
|
107
|
-
paymentModes: PaymentModeTypeBE[];
|
|
108
|
-
taxes: TaxTypeBE[];
|
|
109
|
-
updatedAt: string;
|
|
110
|
-
}
|
|
74
|
+
export type { PreferenceTypeBE };
|
|
111
75
|
/**
|
|
112
76
|
* Payment Mode Component State
|
|
113
77
|
*
|
|
@@ -261,206 +225,31 @@ export declare const getPaymentModeDisplayLabel: (paymentMode: PaymentModeTypeBE
|
|
|
261
225
|
/**
|
|
262
226
|
* Check if payment mode has payments associated
|
|
263
227
|
*/
|
|
264
|
-
export declare const hasPayments: (paymentMode: PaymentModeTypeBE
|
|
228
|
+
export declare const hasPayments: (paymentMode: PaymentModeTypeBE & {
|
|
229
|
+
payments?: PaymentTypeBE[];
|
|
230
|
+
}) => boolean;
|
|
265
231
|
/**
|
|
266
232
|
* Legacy Banking Detail Type
|
|
267
233
|
* TODO: Move to banking-details module
|
|
268
234
|
*/
|
|
269
|
-
export
|
|
270
|
-
accountNumber: string;
|
|
271
|
-
accountTitle: string;
|
|
272
|
-
bankAddress?: string;
|
|
273
|
-
bankName: string;
|
|
274
|
-
createdAt: string;
|
|
275
|
-
enabled: boolean;
|
|
276
|
-
iban?: string;
|
|
277
|
-
id: string;
|
|
278
|
-
isDefault: boolean;
|
|
279
|
-
preference: PreferenceTypeBE;
|
|
280
|
-
preferenceId: string;
|
|
281
|
-
swiftCode?: string;
|
|
282
|
-
updatedAt: string;
|
|
283
|
-
}
|
|
235
|
+
export type { BankTypeBE };
|
|
284
236
|
/**
|
|
285
237
|
* Legacy Branch Type
|
|
286
238
|
* TODO: Move to branches module
|
|
287
239
|
*/
|
|
288
|
-
export
|
|
289
|
-
branchAddress: string;
|
|
290
|
-
branchName: string;
|
|
291
|
-
createdAt: string;
|
|
292
|
-
enabled: boolean;
|
|
293
|
-
id: string;
|
|
294
|
-
isDefault: boolean;
|
|
295
|
-
personEmail: string;
|
|
296
|
-
personName: string;
|
|
297
|
-
personPhone: string;
|
|
298
|
-
preference: PreferenceTypeBE;
|
|
299
|
-
preferenceId: string;
|
|
300
|
-
updatedAt: string;
|
|
301
|
-
}
|
|
240
|
+
export type { BranchTypeBE };
|
|
302
241
|
/**
|
|
303
242
|
* Legacy Currency Type
|
|
304
243
|
* TODO: Move to currencies module
|
|
305
244
|
*/
|
|
306
|
-
export
|
|
307
|
-
code: string;
|
|
308
|
-
createdAt: string;
|
|
309
|
-
enabled: boolean;
|
|
310
|
-
id: string;
|
|
311
|
-
isDefault: boolean;
|
|
312
|
-
label: string;
|
|
313
|
-
preference?: PreferenceTypeBE;
|
|
314
|
-
preferenceId: string;
|
|
315
|
-
updatedAt: string;
|
|
316
|
-
}
|
|
245
|
+
export type { CurrencyTypeBE };
|
|
317
246
|
/**
|
|
318
247
|
* Legacy Menu Order Type
|
|
319
248
|
* TODO: Move to preferences module
|
|
320
249
|
*/
|
|
321
|
-
export
|
|
322
|
-
createdAt: string;
|
|
323
|
-
id: string;
|
|
324
|
-
label: string;
|
|
325
|
-
order: number;
|
|
326
|
-
preference: PreferenceTypeBE;
|
|
327
|
-
preferenceId: string;
|
|
328
|
-
updatedAt: string;
|
|
329
|
-
}
|
|
250
|
+
export type { MenuOrderTypeBE };
|
|
330
251
|
/**
|
|
331
252
|
* Legacy Tax Type
|
|
332
253
|
* TODO: Move to taxes module
|
|
333
254
|
*/
|
|
334
|
-
export
|
|
335
|
-
createdAt: string;
|
|
336
|
-
description?: string;
|
|
337
|
-
enabled: boolean;
|
|
338
|
-
id: string;
|
|
339
|
-
isDefault: boolean;
|
|
340
|
-
preference: PreferenceTypeBE;
|
|
341
|
-
preferenceId: string;
|
|
342
|
-
taxName: string;
|
|
343
|
-
taxRate: string;
|
|
344
|
-
updatedAt: string;
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Legacy Tax Interface
|
|
348
|
-
* TODO: Move to taxes module
|
|
349
|
-
*/
|
|
350
|
-
export interface Tax {
|
|
351
|
-
taxName: string;
|
|
352
|
-
taxValue: string;
|
|
353
|
-
id: string;
|
|
354
|
-
description: string;
|
|
355
|
-
preferenceId: string;
|
|
356
|
-
enabled: boolean;
|
|
357
|
-
errors: {
|
|
358
|
-
[key: string]: string;
|
|
359
|
-
};
|
|
360
|
-
createdAt?: string;
|
|
361
|
-
updatedAt?: string;
|
|
362
|
-
loading: boolean;
|
|
363
|
-
isDefault: boolean;
|
|
364
|
-
btnDisableTax: boolean;
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* Legacy Menu Item Interface
|
|
368
|
-
* TODO: Move to preferences module
|
|
369
|
-
*/
|
|
370
|
-
export interface MenuItem {
|
|
371
|
-
preferenceId: string;
|
|
372
|
-
label: string;
|
|
373
|
-
order: number;
|
|
374
|
-
id: string;
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Legacy Currency Args
|
|
378
|
-
* TODO: Move to currencies module
|
|
379
|
-
*/
|
|
380
|
-
export type CurrencyArgs = {
|
|
381
|
-
id: string;
|
|
382
|
-
label: string;
|
|
383
|
-
enabled: boolean;
|
|
384
|
-
code: string;
|
|
385
|
-
isDefault: boolean;
|
|
386
|
-
preferenceId: string;
|
|
387
|
-
};
|
|
388
|
-
/**
|
|
389
|
-
* Legacy Create Bank Detail Args
|
|
390
|
-
* TODO: Move to banking-details module
|
|
391
|
-
*/
|
|
392
|
-
export interface CreateBankDetailArg {
|
|
393
|
-
id: string;
|
|
394
|
-
accountNumber: string;
|
|
395
|
-
accountTitle: string;
|
|
396
|
-
bankAddress: string;
|
|
397
|
-
bankName: string;
|
|
398
|
-
enabled: boolean;
|
|
399
|
-
iban: string;
|
|
400
|
-
swiftCode: string;
|
|
401
|
-
preferenceId: string;
|
|
402
|
-
errors: {
|
|
403
|
-
[key: string]: string;
|
|
404
|
-
};
|
|
405
|
-
loading: boolean;
|
|
406
|
-
isDefault: boolean;
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* Legacy Create Branches Args
|
|
410
|
-
* TODO: Move to branches module
|
|
411
|
-
*/
|
|
412
|
-
export interface createBranchesArgs {
|
|
413
|
-
personName: string;
|
|
414
|
-
personEmail: string;
|
|
415
|
-
id: string;
|
|
416
|
-
personPhone: string;
|
|
417
|
-
branchAddress: string;
|
|
418
|
-
branchName: string;
|
|
419
|
-
preferenceId: string;
|
|
420
|
-
enabled: boolean;
|
|
421
|
-
errors: {
|
|
422
|
-
[key: string]: string;
|
|
423
|
-
};
|
|
424
|
-
createdAt?: string;
|
|
425
|
-
updatedAt?: string;
|
|
426
|
-
loading: boolean;
|
|
427
|
-
isDefault: boolean;
|
|
428
|
-
}
|
|
429
|
-
/**
|
|
430
|
-
* Legacy Create Taxes Args
|
|
431
|
-
* TODO: Move to taxes module
|
|
432
|
-
*/
|
|
433
|
-
export interface createTaxesArgs {
|
|
434
|
-
taxName: string;
|
|
435
|
-
taxValue: string;
|
|
436
|
-
id: string;
|
|
437
|
-
description: string;
|
|
438
|
-
preferenceId: string;
|
|
439
|
-
enabled: boolean;
|
|
440
|
-
errors: {
|
|
441
|
-
[key: string]: string;
|
|
442
|
-
};
|
|
443
|
-
createdAt?: string;
|
|
444
|
-
updatedAt?: string;
|
|
445
|
-
loading: boolean;
|
|
446
|
-
isDefault: boolean;
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* Legacy Update Currency Args
|
|
450
|
-
* TODO: Move to currencies module
|
|
451
|
-
*/
|
|
452
|
-
export interface updateCurrencyArgs {
|
|
453
|
-
id: string;
|
|
454
|
-
label: string;
|
|
455
|
-
enabled: boolean;
|
|
456
|
-
code: string;
|
|
457
|
-
isDefault: boolean;
|
|
458
|
-
preferenceId: string;
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* Legacy Branch Modal Enum
|
|
462
|
-
* TODO: Move to branches module
|
|
463
|
-
*/
|
|
464
|
-
export declare enum BRANCH_MODAL {
|
|
465
|
-
DUMMY = "DUMMY"
|
|
466
|
-
}
|
|
255
|
+
export type { TaxTypeBE };
|