From d58d734bb9227507b5fd4cced0531f4b1ab99097 Mon Sep 17 00:00:00 2001 From: Krishna Mahato Date: Sun, 14 Aug 2022 13:52:29 +0530 Subject: [PATCH] feature(ui): ui and styling for the edit user page Signed-off-by: Krishna Mahato --- src/Routes.jsx | 6 + src/api/auth.js | 4 +- src/api/users.js | 37 ++ src/components/Header/index.jsx | 8 + .../Upload/CommonFields/AccessLevel/index.jsx | 2 +- src/components/Widgets/Input/index.jsx | 2 +- src/components/Widgets/Modal/index.css | 40 ++ src/components/Widgets/Modal/index.jsx | 51 +++ src/constants/constants.js | 18 +- src/constants/endpoints.js | 3 + src/constants/routes.js | 1 + src/pages/Admin/Users/Edit/index.css | 26 ++ src/pages/Admin/Users/Edit/index.jsx | 427 ++++++++++++++++++ src/pages/Admin/Users/Edit/token_space.jsx | 390 ++++++++++++++++ src/services/users.js | 36 ++ src/utils/index.js | 29 ++ 16 files changed, 1075 insertions(+), 5 deletions(-) create mode 100644 src/components/Widgets/Modal/index.css create mode 100644 src/components/Widgets/Modal/index.jsx create mode 100644 src/pages/Admin/Users/Edit/index.css create mode 100644 src/pages/Admin/Users/Edit/index.jsx create mode 100644 src/pages/Admin/Users/Edit/token_space.jsx create mode 100644 src/utils/index.js diff --git a/src/Routes.jsx b/src/Routes.jsx index e5661a031..2705f4105 100644 --- a/src/Routes.jsx +++ b/src/Routes.jsx @@ -93,6 +93,7 @@ const GroupCreate = React.lazy(() => import("pages/Admin/Group/Create")); const DeleteGroup = React.lazy(() => import("pages/Admin/Group/Delete")); const DeleteUser = React.lazy(() => import("pages/Admin/Users/Delete")); const AddUser = React.lazy(() => import("pages/Admin/Users/Add")); +const EditUser = React.lazy(() => import("pages/Admin/Users/Edit")); const AddLicense = React.lazy(() => import("pages/Admin/License/Create")); const SelectLicense = React.lazy(() => import("pages/Admin/License/SelectLicense") @@ -311,6 +312,11 @@ const Routes = () => { path={routes.admin.users.add} component={AddUser} /> + { +const fetchTokenApi = (username, password, tokenDetails = null) => { const url = endpoints.auth.tokens(); return sendRequest({ url, method: "POST", - body: { + body: tokenDetails || { username, password, token_name: randomString(tokenNameLength), diff --git a/src/api/users.js b/src/api/users.js index ecc25ee83..b3c41d404 100644 --- a/src/api/users.js +++ b/src/api/users.js @@ -73,3 +73,40 @@ export const deleteUserApi = (id) => { }, }); }; + +// Modifying user PUT request +export const editUserByIdApi = (id, editedUserDetails) => { + const url = endpoints.users.edit(id); + return sendRequest({ + url, + method: "PUT", + body: editedUserDetails, + headers: { + Authorization: getToken(), + }, + }); +}; + +// Getting user by id +export const getUserByIdAapi = (id) => { + const url = endpoints.users.getSingle(id); + return sendRequest({ + url, + method: "GET", + headers: { + Authorization: getToken(), + }, + }); +}; + +// Getting REST API Tokens based on token type (active | expired) +export const getTokensApi = (type) => { + const url = endpoints.users.getTokens(type); + return sendRequest({ + url, + method: "GET", + headers: { + Authorization: getToken(), + }, + }); +}; diff --git a/src/components/Header/index.jsx b/src/components/Header/index.jsx index d35360447..bc6b0f47c 100644 --- a/src/components/Header/index.jsx +++ b/src/components/Header/index.jsx @@ -275,6 +275,14 @@ const Header = () => { Add User +
+ + Edit User Account + +
+
+
{children && (