@asaleh37/ui-base 25.6.25 → 25.7.26-1
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/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/administration/admin/ChangePasswordPanel.tsx +128 -0
- package/src/components/administration/admin/PersonGrid.tsx +27 -0
- package/src/layout/TopBar.tsx +67 -7
package/package.json
CHANGED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Box, Button, Divider, Paper } from "@mui/material";
|
|
2
|
+
import { TemplateTextField } from "../../templates";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { toast } from "react-toastify";
|
|
5
|
+
import { useAxios } from "../../../hooks";
|
|
6
|
+
|
|
7
|
+
interface ChangePasswordPanelProps {
|
|
8
|
+
selectedPerson: any;
|
|
9
|
+
isSelfService: boolean;
|
|
10
|
+
onSuccessCallBk: () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const ChangePasswordPanel: React.FC<ChangePasswordPanelProps> = (props) => {
|
|
14
|
+
const [currentPassword, setCurrentPassword] = useState("");
|
|
15
|
+
const [password1, setPassword1] = useState("");
|
|
16
|
+
const [password2, setPassword2] = useState("");
|
|
17
|
+
const { handlePostRequest } = useAxios();
|
|
18
|
+
const handleChangePasswordRequest = async () => {
|
|
19
|
+
if (props.isSelfService) {
|
|
20
|
+
if (currentPassword === null || currentPassword.trim() === "") {
|
|
21
|
+
toast.error(
|
|
22
|
+
"You must enter your current password to process your request"
|
|
23
|
+
);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (
|
|
28
|
+
password1 === null ||
|
|
29
|
+
password1 === "" ||
|
|
30
|
+
password2 === null ||
|
|
31
|
+
password2 === "" ||
|
|
32
|
+
password1 != password2
|
|
33
|
+
) {
|
|
34
|
+
toast.error(
|
|
35
|
+
"You must enter new password in required fields and must be identical"
|
|
36
|
+
);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
await handlePostRequest({
|
|
40
|
+
endPointURI: props.isSelfService
|
|
41
|
+
? "api/v1/ss/changeMyPassword"
|
|
42
|
+
: "api/v1/admin/changeUserPassword",
|
|
43
|
+
data: {
|
|
44
|
+
personId: props?.selectedPerson?.id,
|
|
45
|
+
currentPassword,
|
|
46
|
+
newPassword: password1,
|
|
47
|
+
},
|
|
48
|
+
successCallBkFn: () => {
|
|
49
|
+
props.onSuccessCallBk();
|
|
50
|
+
toast.success("Your request has been processed successfully");
|
|
51
|
+
},
|
|
52
|
+
showMask: true,
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
return (
|
|
56
|
+
<Paper
|
|
57
|
+
sx={{
|
|
58
|
+
display: "flex",
|
|
59
|
+
flexDirection: "column",
|
|
60
|
+
alignItems: "center",
|
|
61
|
+
justifyContent: "center",
|
|
62
|
+
width: 400,
|
|
63
|
+
padding: 1,
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
<Box
|
|
67
|
+
sx={{
|
|
68
|
+
m: 1,
|
|
69
|
+
display: "flex",
|
|
70
|
+
alignItems: "center",
|
|
71
|
+
justifyContent: "flex-start",
|
|
72
|
+
width: "100%",
|
|
73
|
+
fontWeight: "bold",
|
|
74
|
+
fontSize: 16,
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
Changing Password For : {props?.selectedPerson?.employeeEnName}
|
|
78
|
+
</Box>
|
|
79
|
+
<Divider variant="fullWidth" sx={{ width: "100%", marginBottom: 2 }} />
|
|
80
|
+
{props.isSelfService ? (
|
|
81
|
+
<TemplateTextField
|
|
82
|
+
label="Current Password"
|
|
83
|
+
value={currentPassword}
|
|
84
|
+
onChange={(e) => {
|
|
85
|
+
setCurrentPassword(e.target.value);
|
|
86
|
+
}}
|
|
87
|
+
sx={{ m: 1 }}
|
|
88
|
+
fullWidth
|
|
89
|
+
type="password"
|
|
90
|
+
/>
|
|
91
|
+
) : (
|
|
92
|
+
<></>
|
|
93
|
+
)}
|
|
94
|
+
|
|
95
|
+
<TemplateTextField
|
|
96
|
+
label="New Password"
|
|
97
|
+
value={password1}
|
|
98
|
+
onChange={(e) => {
|
|
99
|
+
setPassword1(e.target.value);
|
|
100
|
+
}}
|
|
101
|
+
sx={{ m: 1 }}
|
|
102
|
+
fullWidth
|
|
103
|
+
type="password"
|
|
104
|
+
/>
|
|
105
|
+
<TemplateTextField
|
|
106
|
+
label="Confirm New Password"
|
|
107
|
+
value={password2}
|
|
108
|
+
onChange={(e) => {
|
|
109
|
+
setPassword2(e.target.value);
|
|
110
|
+
}}
|
|
111
|
+
sx={{ m: 1 }}
|
|
112
|
+
fullWidth
|
|
113
|
+
type="password"
|
|
114
|
+
/>
|
|
115
|
+
<Button
|
|
116
|
+
sx={{ m: 1 }}
|
|
117
|
+
variant="contained"
|
|
118
|
+
onClick={() => {
|
|
119
|
+
handleChangePasswordRequest();
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
Change Password
|
|
123
|
+
</Button>
|
|
124
|
+
</Paper>
|
|
125
|
+
);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export default ChangePasswordPanel;
|
|
@@ -9,6 +9,7 @@ import { Box } from "@mui/material";
|
|
|
9
9
|
import AttachmentImageViewer from "../../templates/attachment/AttachmentImageViewer";
|
|
10
10
|
import { useSelector } from "react-redux";
|
|
11
11
|
import OrgMemberRoleForm from "./OrgMemberRoleForm";
|
|
12
|
+
import ChangePasswordPanel from "./ChangePasswordPanel";
|
|
12
13
|
|
|
13
14
|
const PersonGrid: React.FC = () => {
|
|
14
15
|
const { t } = useTranslation();
|
|
@@ -44,6 +45,15 @@ const PersonGrid: React.FC = () => {
|
|
|
44
45
|
windowTitle: "Organization Member Roles",
|
|
45
46
|
width: "50%",
|
|
46
47
|
});
|
|
48
|
+
const {
|
|
49
|
+
Window: ChangePasswordWindow,
|
|
50
|
+
setWindowState: setChangePasswordWindow,
|
|
51
|
+
} = useWindow({
|
|
52
|
+
windowIcon: "key",
|
|
53
|
+
windowTitle: "Change Password",
|
|
54
|
+
width: "fit-content",
|
|
55
|
+
height: "fit-content",
|
|
56
|
+
});
|
|
47
57
|
|
|
48
58
|
const formElements: Array<FormElementProps> = [
|
|
49
59
|
{
|
|
@@ -251,6 +261,15 @@ const PersonGrid: React.FC = () => {
|
|
|
251
261
|
<OrganizationMembersWindow>
|
|
252
262
|
<OrganizationMemberGrid selectedPerson={selectedPerson} />
|
|
253
263
|
</OrganizationMembersWindow>
|
|
264
|
+
<ChangePasswordWindow>
|
|
265
|
+
<ChangePasswordPanel
|
|
266
|
+
selectedPerson={selectedPerson}
|
|
267
|
+
isSelfService={false}
|
|
268
|
+
onSuccessCallBk={() => {
|
|
269
|
+
setChangePasswordWindow(false);
|
|
270
|
+
}}
|
|
271
|
+
/>
|
|
272
|
+
</ChangePasswordWindow>
|
|
254
273
|
<TemplateGrid
|
|
255
274
|
attachment={{ attachmentCode: "EMPLOYEE_PHOTOS" }}
|
|
256
275
|
apiActions={apiActions}
|
|
@@ -268,6 +287,14 @@ const PersonGrid: React.FC = () => {
|
|
|
268
287
|
keyColumnName={"id"}
|
|
269
288
|
gridTitle="PERSON_PLURAL"
|
|
270
289
|
rowActions={[
|
|
290
|
+
{
|
|
291
|
+
icon: "key",
|
|
292
|
+
label: "Change User Password",
|
|
293
|
+
actionFn: async (data) => {
|
|
294
|
+
setSelectedPerson(data);
|
|
295
|
+
setChangePasswordWindow(true);
|
|
296
|
+
},
|
|
297
|
+
},
|
|
271
298
|
{
|
|
272
299
|
icon: "tags",
|
|
273
300
|
label: "Current Organization User Roles",
|
package/src/layout/TopBar.tsx
CHANGED
|
@@ -2,6 +2,8 @@ import {
|
|
|
2
2
|
Avatar,
|
|
3
3
|
Box,
|
|
4
4
|
IconButton,
|
|
5
|
+
Menu,
|
|
6
|
+
MenuItem,
|
|
5
7
|
styled,
|
|
6
8
|
Tooltip,
|
|
7
9
|
Typography,
|
|
@@ -23,6 +25,8 @@ import ChangeOrgForm from "../components/common/ChangeOrgForm";
|
|
|
23
25
|
import { toggleSideBarState } from "../redux/features/common/SideBarSlice";
|
|
24
26
|
import AttachmentImageViewer from "../components/templates/attachment/AttachmentImageViewer";
|
|
25
27
|
import NotificationButton from "./NotificationButton";
|
|
28
|
+
import { useState } from "react";
|
|
29
|
+
import ChangePasswordPanel from "../components/administration/admin/ChangePasswordPanel";
|
|
26
30
|
|
|
27
31
|
interface AppBarProps extends MuiAppBarProps {
|
|
28
32
|
open?: boolean;
|
|
@@ -70,10 +74,26 @@ const TopBar: React.FC = () => {
|
|
|
70
74
|
height: "fit-content",
|
|
71
75
|
});
|
|
72
76
|
const AppInfo = useSelector((state: any) => state.AppInfo.value);
|
|
77
|
+
const [anchorElUser, setAnchorElUser] = useState<null | HTMLElement>(null);
|
|
78
|
+
const handleCloseUserMenu = () => {
|
|
79
|
+
setAnchorElUser(null);
|
|
80
|
+
};
|
|
81
|
+
const handleOpenUserMenu = (event: React.MouseEvent<HTMLElement>) => {
|
|
82
|
+
setAnchorElUser(event.currentTarget);
|
|
83
|
+
};
|
|
73
84
|
const AppLayout = useSelector((state: any) => state.AppLayout);
|
|
74
85
|
const SideBarState = useSelector((state: any) => state.SideBar);
|
|
75
86
|
const { UserSession } = useSession();
|
|
76
87
|
const currentOrganization = UserSession.value.currentOrganization;
|
|
88
|
+
const {
|
|
89
|
+
Window: ChangePasswordWindow,
|
|
90
|
+
setWindowState: setChangePasswordWindow,
|
|
91
|
+
} = useWindow({
|
|
92
|
+
windowIcon: "key",
|
|
93
|
+
windowTitle: "Change Password",
|
|
94
|
+
width: "fit-content",
|
|
95
|
+
height: "fit-content",
|
|
96
|
+
});
|
|
77
97
|
const { handleGetRequest } = useAxios();
|
|
78
98
|
const isMobile = useIsMobile();
|
|
79
99
|
const dispatch = useDispatch();
|
|
@@ -88,6 +108,40 @@ const TopBar: React.FC = () => {
|
|
|
88
108
|
};
|
|
89
109
|
return (
|
|
90
110
|
<>
|
|
111
|
+
<ChangePasswordWindow>
|
|
112
|
+
<ChangePasswordPanel
|
|
113
|
+
selectedPerson={UserSession.value}
|
|
114
|
+
isSelfService={true}
|
|
115
|
+
onSuccessCallBk={() => {
|
|
116
|
+
setChangePasswordWindow(false);
|
|
117
|
+
}}
|
|
118
|
+
/>
|
|
119
|
+
</ChangePasswordWindow>
|
|
120
|
+
<Menu
|
|
121
|
+
sx={{ mt: "45px" }}
|
|
122
|
+
id="menu-appbar"
|
|
123
|
+
anchorEl={anchorElUser}
|
|
124
|
+
anchorOrigin={{
|
|
125
|
+
vertical: "top",
|
|
126
|
+
horizontal: "right",
|
|
127
|
+
}}
|
|
128
|
+
keepMounted
|
|
129
|
+
transformOrigin={{
|
|
130
|
+
vertical: "top",
|
|
131
|
+
horizontal: "right",
|
|
132
|
+
}}
|
|
133
|
+
open={Boolean(anchorElUser)}
|
|
134
|
+
onClose={handleCloseUserMenu}
|
|
135
|
+
>
|
|
136
|
+
<MenuItem
|
|
137
|
+
onClick={() => {
|
|
138
|
+
setChangePasswordWindow(true);
|
|
139
|
+
handleCloseUserMenu();
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
<Typography sx={{ textAlign: "center" }}>Change Password</Typography>
|
|
143
|
+
</MenuItem>
|
|
144
|
+
</Menu>
|
|
91
145
|
<ChangeOrgWindow>
|
|
92
146
|
<ChangeOrgForm
|
|
93
147
|
successChangeCallBackFn={() => {
|
|
@@ -205,13 +259,19 @@ const TopBar: React.FC = () => {
|
|
|
205
259
|
) : (
|
|
206
260
|
<></>
|
|
207
261
|
)}
|
|
208
|
-
<
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
262
|
+
<div onClick={handleOpenUserMenu} style={{ cursor: "pointer" }}>
|
|
263
|
+
<AttachmentImageViewer
|
|
264
|
+
showAsAvatar={true}
|
|
265
|
+
onErrorImage="/no_user.png"
|
|
266
|
+
attachmentCode="EMPLOYEE_PHOTOS"
|
|
267
|
+
refKey={UserSession.value?.id + ""}
|
|
268
|
+
/>
|
|
269
|
+
</div>
|
|
270
|
+
|
|
271
|
+
<div
|
|
272
|
+
style={{ marginLeft: 5, marginRight: 5, cursor: "pointer" }}
|
|
273
|
+
onClick={handleOpenUserMenu}
|
|
274
|
+
>
|
|
215
275
|
{isMobile ? "" : UserSession.value?.username}
|
|
216
276
|
</div>
|
|
217
277
|
<IconButton color="inherit" onClick={handleLogout}>
|