ui-soxo-bootstrap-core 2.6.3 → 2.6.4
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/core/components/menu-template-api/menu-template-api.js +2 -2
- package/core/lib/components/sidemenu/sidemenu.js +19 -13
- package/core/lib/pages/login/login.js +29 -4
- package/core/lib/utils/api/api.utils.js +71 -48
- package/core/lib/utils/common/common.utils.js +24 -0
- package/core/lib/utils/index.js +22 -28
- package/core/models/base/base.js +7 -3
- package/core/models/menus/components/menu-lists/menu-lists.js +2 -2
- package/core/models/menus/menus.js +21 -2
- package/core/models/users/components/assign-role/assign-role.js +138 -50
- package/core/models/users/components/assign-role/assign-role.scss +209 -45
- package/core/models/users/components/assign-role/avatar-props.js +45 -0
- package/core/models/users/components/user-add/user-add.js +13 -10
- package/core/models/users/components/user-add/user-edit.js +19 -2
- package/core/models/users/users.js +24 -8
- package/core/modules/reporting/components/reporting-dashboard/reporting-dashboard.js +4 -2
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import { Skeleton, Typography, message, Switch, Form, Input, Select, Checkbox, R
|
|
|
6
6
|
|
|
7
7
|
import AsyncSelect from 'react-select/async';
|
|
8
8
|
|
|
9
|
-
import { Table, Card, Button, JSONInput, GlobalContext } from './../../../../lib/';
|
|
9
|
+
import { Table, Card, Button, JSONInput, GlobalContext, safeJSON } from './../../../../lib/';
|
|
10
10
|
|
|
11
11
|
import { ModelsAPI, PagesAPI, RolesAPI } from '../../..';
|
|
12
12
|
|
|
@@ -30,7 +30,7 @@ const UserAdd = ({ model, callback, edit, history, formContent, match, additiona
|
|
|
30
30
|
const [selectedBranches, setSelectedBranches] = useState([]);
|
|
31
31
|
|
|
32
32
|
// for default branch
|
|
33
|
-
const [defaultBranch, setDefaultBranch] = useState(null);
|
|
33
|
+
// const [defaultBranch, setDefaultBranch] = useState(null);
|
|
34
34
|
//Need to check this condition
|
|
35
35
|
const [authentication, setAuthentication] = useState(false);
|
|
36
36
|
|
|
@@ -42,7 +42,7 @@ const UserAdd = ({ model, callback, edit, history, formContent, match, additiona
|
|
|
42
42
|
const [selectedStaff, setSelectedStaff] = useState(null);
|
|
43
43
|
const [staffList, setStaffList] = useState([]);
|
|
44
44
|
/**Converting to JSON */
|
|
45
|
-
|
|
45
|
+
const firmDetails = safeJSON(user?.firm?.f_otherdetails1) ?? {};
|
|
46
46
|
|
|
47
47
|
/**Variable for cheaking mandatory condition of mobile*/
|
|
48
48
|
let mobileRequired;
|
|
@@ -270,8 +270,6 @@ const UserAdd = ({ model, callback, edit, history, formContent, match, additiona
|
|
|
270
270
|
const getStaff = () => {
|
|
271
271
|
UsersAPI.getAllStaff()
|
|
272
272
|
.then((res) => {
|
|
273
|
-
console.log('Staff List Response:', res);
|
|
274
|
-
|
|
275
273
|
if (Array.isArray(res)) {
|
|
276
274
|
const list = res.map((staff) => ({
|
|
277
275
|
label: `${staff.shortName || 'No Name'} (${staff.id})`,
|
|
@@ -325,20 +323,25 @@ const UserAdd = ({ model, callback, edit, history, formContent, match, additiona
|
|
|
325
323
|
}
|
|
326
324
|
if (!formContent) return;
|
|
327
325
|
|
|
328
|
-
// normalize branch ids to NUMBER
|
|
329
326
|
const org =
|
|
330
327
|
typeof formContent.organization_details === 'string' ? JSON.parse(formContent.organization_details) : formContent.organization_details;
|
|
331
328
|
|
|
329
|
+
// normalize branch ids to NUMBER
|
|
332
330
|
const branchIds = (org?.branch_ids || []).map(Number);
|
|
333
|
-
|
|
331
|
+
|
|
332
|
+
// find default branch pointer
|
|
333
|
+
const defaultBranchObj = org?.branch?.find((br) => br.defaultBranch);
|
|
334
|
+
|
|
335
|
+
// extract dbPtr (branch code)
|
|
336
|
+
const defaultBranchCode = defaultBranchObj?.branch_id ? Number(defaultBranchObj.branch_id) : undefined;
|
|
334
337
|
|
|
335
338
|
// state (for filtering)
|
|
336
339
|
setSelectedBranches(branchIds);
|
|
337
340
|
|
|
338
|
-
// form
|
|
341
|
+
// form values
|
|
339
342
|
form.setFieldsValue({
|
|
340
343
|
selectedBranches: branchIds,
|
|
341
|
-
defaultBranch:
|
|
344
|
+
defaultBranch: defaultBranchCode,
|
|
342
345
|
});
|
|
343
346
|
}, [formContent, form]);
|
|
344
347
|
// Generate branch options for Select component
|
|
@@ -669,7 +672,7 @@ const UserAdd = ({ model, callback, edit, history, formContent, match, additiona
|
|
|
669
672
|
<Col span={8}>
|
|
670
673
|
{/* Default Branch */}
|
|
671
674
|
<Form.Item label="Default Branch" name="defaultBranch" rules={[{ required: true, message: 'Please select default branch' }]}>
|
|
672
|
-
<Select placeholder="Select Default Branch"
|
|
675
|
+
<Select placeholder="Select Default Branch">
|
|
673
676
|
{branchOptions
|
|
674
677
|
.filter((opt) => selectedBranches.includes(Number(opt.value)))
|
|
675
678
|
.map((opt) => (
|
|
@@ -37,6 +37,13 @@ export default function UserEdit(record) {
|
|
|
37
37
|
} catch (e) {
|
|
38
38
|
orgDetails = {};
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
// find default branch pointer
|
|
42
|
+
const defaultBranchObj = orgDetails?.branch?.find((br) => br.defaultBranch);
|
|
43
|
+
|
|
44
|
+
// extract dbPtr (branch code)
|
|
45
|
+
const defaultBranchCode = defaultBranchObj?.branch_id ? Number(defaultBranchObj.branch_id) : undefined;
|
|
46
|
+
|
|
40
47
|
// Construct mapped data object
|
|
41
48
|
const mappedData = {
|
|
42
49
|
id: apiData.id,
|
|
@@ -49,7 +56,7 @@ export default function UserEdit(record) {
|
|
|
49
56
|
// Handle selected branches and default branch
|
|
50
57
|
organization_details: orgDetails,
|
|
51
58
|
selectedBranches: orgDetails.branch_ids || [],
|
|
52
|
-
defaultBranch:
|
|
59
|
+
defaultBranch: defaultBranchCode || null,
|
|
53
60
|
role_id: apiData.role_id,
|
|
54
61
|
password: apiData.password,
|
|
55
62
|
user_group: apiData.user_group,
|
|
@@ -81,7 +88,17 @@ export default function UserEdit(record) {
|
|
|
81
88
|
<Skeleton active />
|
|
82
89
|
</div>
|
|
83
90
|
) : (
|
|
84
|
-
<UserAdd
|
|
91
|
+
<UserAdd
|
|
92
|
+
mode="Edit"
|
|
93
|
+
formContent={userData}
|
|
94
|
+
callback={() => {
|
|
95
|
+
setVisible(false);
|
|
96
|
+
if (record.callback) {
|
|
97
|
+
record.callback();
|
|
98
|
+
}
|
|
99
|
+
}}
|
|
100
|
+
edit={true}
|
|
101
|
+
/>
|
|
85
102
|
)}
|
|
86
103
|
</Modal>
|
|
87
104
|
</div>
|
|
@@ -149,7 +149,13 @@ class Users extends Base {
|
|
|
149
149
|
* @returns
|
|
150
150
|
*/
|
|
151
151
|
create = (formBody) => {
|
|
152
|
-
return ApiUtils.post({
|
|
152
|
+
return ApiUtils.post({
|
|
153
|
+
url: `users/create-user`,
|
|
154
|
+
formBody,
|
|
155
|
+
headers: {
|
|
156
|
+
db_ptr: 'nuraho',
|
|
157
|
+
},
|
|
158
|
+
});
|
|
153
159
|
};
|
|
154
160
|
|
|
155
161
|
/**
|
|
@@ -161,7 +167,7 @@ class Users extends Base {
|
|
|
161
167
|
return ApiUtils.get({
|
|
162
168
|
url: `branch-master/get-records`,
|
|
163
169
|
headers: {
|
|
164
|
-
db_ptr:
|
|
170
|
+
db_ptr: 'nuraho',
|
|
165
171
|
},
|
|
166
172
|
});
|
|
167
173
|
};
|
|
@@ -271,25 +277,35 @@ class Users extends Base {
|
|
|
271
277
|
* @returns
|
|
272
278
|
*/
|
|
273
279
|
updateUser = ({ id, formBody }) => {
|
|
274
|
-
return ApiUtils.put({
|
|
280
|
+
return ApiUtils.put({
|
|
281
|
+
url: `users/update-user/${id}`,
|
|
282
|
+
formBody,
|
|
283
|
+
headers: {
|
|
284
|
+
db_ptr: 'nuraho',
|
|
285
|
+
},
|
|
286
|
+
});
|
|
275
287
|
};
|
|
276
|
-
|
|
288
|
+
|
|
277
289
|
/* The `getUser` method is a function that takes an object with an `id` property as a parameter. It
|
|
278
290
|
then uses the `ApiUtils.get` function to make a GET request to the endpoint `users/` to fetch
|
|
279
291
|
user data based on the provided `id`. This method is used to retrieve a specific user's
|
|
280
292
|
information from the API. */
|
|
281
293
|
|
|
282
294
|
getUser = ({ id }) => {
|
|
283
|
-
return ApiUtils.get({
|
|
295
|
+
return ApiUtils.get({
|
|
296
|
+
url: `users/${id}`,
|
|
297
|
+
headers: {
|
|
298
|
+
db_ptr: 'nuraho',
|
|
299
|
+
},
|
|
300
|
+
});
|
|
284
301
|
};
|
|
285
|
-
|
|
302
|
+
/* The `getUserRole` method is a function that takes an object with an `id` property as a parameter.
|
|
286
303
|
It then uses the `ApiUtils.get` function to make a GET request to the endpoint `core-user-roles`
|
|
287
304
|
with the `user_id` parameter set to the provided `id`. This method is used to fetch the role or
|
|
288
305
|
roles associated with a specific user from the API. */
|
|
289
|
-
|
|
306
|
+
|
|
290
307
|
getUserRole = ({ id }) => {
|
|
291
308
|
return ApiUtils.get({ url: `core-user-roles?user_id=${id}&active=Y` });
|
|
292
|
-
|
|
293
309
|
};
|
|
294
310
|
|
|
295
311
|
/**
|
|
@@ -292,8 +292,11 @@ export default function ReportingDashboard({
|
|
|
292
292
|
}
|
|
293
293
|
// Fetch result
|
|
294
294
|
const result = await CoreScripts.getReportingLisitng(coreScriptId, formBody, dbPtr);
|
|
295
|
+
|
|
296
|
+
const apiData = Array.isArray(result) ? result : Array.isArray(result?.result) ? result.result : [];
|
|
297
|
+
|
|
295
298
|
// Handle both result formats
|
|
296
|
-
let resultDetails =
|
|
299
|
+
let resultDetails = apiData[0] || [];
|
|
297
300
|
if (result?.result && result?.result[0]) {
|
|
298
301
|
resultDetails = result.result[0];
|
|
299
302
|
}
|
|
@@ -324,7 +327,6 @@ export default function ReportingDashboard({
|
|
|
324
327
|
}
|
|
325
328
|
} catch (error) {
|
|
326
329
|
console.error('Error fetching report data:', error);
|
|
327
|
-
message.warn('Please try again');
|
|
328
330
|
} finally {
|
|
329
331
|
// Always runs, success or error
|
|
330
332
|
setLoading(false);
|