Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
uphrh-smf-web
Commits
2392edeb
Commit
2392edeb
authored
2 years ago
by
devendra
Browse files
Options
Download
Patches
Plain Diff
Feat: Delete user- api integration
parent
512108e9
master
delete-form
delete-user
1 merge request
!10
Delete user feature for super admin
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/constants/ApiConstants.ts
+1
-0
src/constants/ApiConstants.ts
src/layouts/reviewer/Users.tsx
+23
-4
src/layouts/reviewer/Users.tsx
src/services/user.service.js
+12
-0
src/services/user.service.js
with
36 additions
and
4 deletions
+36
-4
src/constants/ApiConstants.ts
+
1
−
0
View file @
2392edeb
...
...
@@ -32,6 +32,7 @@ export const APIS = {
CREATE_OR_UPDATE_USER
:
"
user/createOrUpdate
"
,
GET_USER_BY_ID
:
"
user/getUserById
"
,
GET_ALL_USERS
:
"
user/v1/getAllUser
"
,
DELETE_USER
:
"
user/admin/deleteUser
"
},
DASHBOARD
:
{
GET_DASHBOARD_CONFIG
:
"
dashboard/getDashboardConfig/SMF/home
"
,
...
...
This diff is collapsed.
Click to expand it.
src/layouts/reviewer/Users.tsx
+
23
−
4
View file @
2392edeb
...
...
@@ -90,12 +90,27 @@ export const Users = ({ data }: userProps) => {
};
const
deleteUser
=
()
=>
{
console
.
log
(
userToDelete
);
//Make api call to soft delete user
setShowConfirmModal
(
false
);
UserService
.
deleteUser
(
userToDelete
?.
id
).
then
(
(
response
)
=>
{
if
(
response
.
statusInfo
&&
response
.
statusInfo
.
statusCode
===
APP
.
CODE
.
SUCCESS
)
{
console
.
log
(
response
.
responseData
);
Notify
.
success
(
'
User deleted successfully!
'
);
getAllUsers
();
}
else
{
Notify
.
error
(
response
.
statusInfo
.
errorMessage
);
}
setShowConfirmModal
(
false
);
},
(
error
)
=>
{
error
.
statusInfo
?
Notify
.
error
(
error
.
statusInfo
.
errorMessage
)
:
Notify
.
error
(
error
.
message
);
setShowConfirmModal
(
false
);
}
);
}
useEffect
(
()
=>
{
const
getAllUsers
=
()
=>
{
// get users
UserService
.
getAllUsers
().
then
(
(
response2
)
=>
{
...
...
@@ -115,6 +130,10 @@ export const Users = ({ data }: userProps) => {
:
Notify
.
error
(
error
.
message
);
}
);
}
useEffect
(()
=>
{
getAllUsers
();
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[]);
...
...
This diff is collapsed.
Click to expand it.
src/services/user.service.js
+
12
−
0
View file @
2392edeb
...
...
@@ -10,6 +10,7 @@ export const UserService = {
createOrUpdateUser
,
getUserByID
,
getAllUsers
,
deleteUser
,
};
function
login
(
username
,
otp
)
{
...
...
@@ -64,6 +65,17 @@ function createOrUpdateUser(user) {
);
}
function
deleteUser
(
userId
)
{
const
requestOptions
=
{
method
:
APP
.
REQUEST
.
POST
,
headers
:
authHeader
(),
body
:
JSON
.
stringify
({
id
:
userId
})
};
return
fetch
(
APIS
.
BASE_URL
+
APIS
.
USER
.
DELETE_USER
,
requestOptions
).
then
(
handleResponse
);
}
function
getUserByID
(
id
)
{
const
requestOptions
=
{
method
:
APP
.
REQUEST
.
GET
,
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets