diff --git a/src/assets/styles/adminPanel.module.scss b/src/assets/styles/adminPanel.module.scss
index f2b25cf..1e1d26e 100644
--- a/src/assets/styles/adminPanel.module.scss
+++ b/src/assets/styles/adminPanel.module.scss
@@ -33,6 +33,8 @@
}
}
&__wrapper {
+ width: 100%;
+ height: 100%;
&__header {
width: 100%;
height: 15%;
@@ -53,9 +55,13 @@
width: 100%;
height: 20%;
border-bottom: 1px solid rgb(200, 200, 200);
- display: flex;
- justify-content: space-between;
- align-items: center;
+ &__wrapper {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ width: 95%;
+ height: 100%;
+ }
&__item {
font-size: 15px;
font-family: "Montserrat", sans-serif;
@@ -67,19 +73,30 @@
&__users {
width: 100%;
height: 80%;
- margin-top: 10px;
+ overflow-y: auto;
+ &::-webkit-scrollbar {
+ width: 7px;
+ }
+ &::-webkit-scrollbar-thumb {
+ background-color: rgb(200, 200, 200);
+ }
&__item {
width: 100%;
height: 20%;
- display: flex;
- justify-content: space-between;
- align-items: center;
border-bottom: 1px solid rgb(200, 200, 200);
+ position: relative;
+ &__wrapper {
+ width: 95%;
+ height: 100%;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ }
&__link {
font-size: 15px;
font-family: "Montserrat", sans-serif;
color: rgb(70, 70, 70);
- width: 33.3%;
+ width: 20%;
text-align: center;
cursor: pointer;
&:hover {
@@ -91,9 +108,19 @@
font-size: 15px;
font-family: "Montserrat", sans-serif;
color: rgb(100, 100, 100);
- width: 33.3%;
+ width: 20%;
text-align: center;
}
+ &__remove {
+ position: absolute;
+ right: 2%;
+ cursor: pointer;
+ i {
+ &:hover {
+ color: rgb(199, 73, 73);
+ }
+ }
+ }
}
}
&__item {
diff --git a/src/components/NavBar.jsx b/src/components/NavBar.jsx
index 53947b5..48f9df4 100644
--- a/src/components/NavBar.jsx
+++ b/src/components/NavBar.jsx
@@ -10,9 +10,14 @@ const NavBar = ({navigate, auth, setAuth}) => {
diff --git a/src/hooks/api/adminApi.js b/src/hooks/api/adminApi.js
index 09afd91..d73ee2d 100644
--- a/src/hooks/api/adminApi.js
+++ b/src/hooks/api/adminApi.js
@@ -1,42 +1,42 @@
-import axios from "axios";
+// import axios from "axios";
-async function listUsersApi(token) {
- try {
- const response = await axios.get(`https://api.minerva.krbl.ru/auth/manage/users`,
- {
- headers: {
- "Authorization": `Token ${token}`
- }
- })
- return response
- }
- catch (e) {
- return e
- }
-};
+// async function listUsersApi(token) {
+// try {
+// const response = await axios.get(`https://api.minerva.krbl.ru/auth/manage/users`,
+// {
+// headers: {
+// "Authorization": `Token ${token}`
+// }
+// })
+// return response
+// }
+// catch (e) {
+// return e
+// }
+// };
-async function editUserApi(token, data) {
- try {
- const response = await axios.post(`https://api.minerva.krbl.ru/auth/manage/edit`,
- {
- "email": data.email,
- "first_name": data.first_name,
- "id": data.id,
- "is_admin": data.is_admin,
- "last_name": data.last_name,
- "login": data.login,
- "phone": data.phone
- },
- {
- headers: {
- "Authorization": `Token ${token}`
- }
- })
- return response
- }
- catch (e) {
- return e
- }
-};
+// async function editUserApi(token, data) {
+// try {
+// const response = await axios.post(`https://api.minerva.krbl.ru/auth/manage/edit`,
+// {
+// "email": data.email,
+// "first_name": data.first_name,
+// "id": data.id,
+// "is_admin": data.is_admin,
+// "last_name": data.last_name,
+// "login": data.login,
+// "phone": data.phone
+// },
+// {
+// headers: {
+// "Authorization": `Token ${token}`
+// }
+// })
+// return response
+// }
+// catch (e) {
+// return e
+// }
+// };
-export {listUsersApi, editUserApi}
\ No newline at end of file
+// export {listUsersApi, editUserApi}
\ No newline at end of file
diff --git a/src/hooks/api/formApi.js b/src/hooks/api/formApi.js
index 54b0819..fec21a0 100644
--- a/src/hooks/api/formApi.js
+++ b/src/hooks/api/formApi.js
@@ -131,6 +131,7 @@ async function saveAnswersApi(token, formToken, data) {
"Authorization": `Token ${token}`
}
})
+ console.log("saveAnswersApi", response)
return response
}
catch (e) {
diff --git a/src/hooks/api/listFormsApi.js b/src/hooks/api/listFormsApi.js
index 0695eda..9c1ae49 100644
--- a/src/hooks/api/listFormsApi.js
+++ b/src/hooks/api/listFormsApi.js
@@ -26,6 +26,7 @@ async function createFormApi(token) {
"Authorization": `Token ${token}`,
}
})
+ console.log("createFormApi", response)
return response
}
catch (e) {
@@ -67,7 +68,10 @@ async function updateTitleFormApi(token, formId, title) {
async function newFormTokenApi(token, formId) {
try {
- const response = await axios.post(`https://api.minerva.krbl.ru/formBuilder/edit/${formId}/access/new`, {},
+ const response = await axios.post(`https://api.minerva.krbl.ru/formBuilder/edit/${formId}/access/new`,
+ {
+ "name": "test"
+ },
{
headers: {
"Authorization": `Token ${token}`
diff --git a/src/hooks/api/profileApi.js b/src/hooks/api/profileApi.js
index e63408b..10532a1 100644
--- a/src/hooks/api/profileApi.js
+++ b/src/hooks/api/profileApi.js
@@ -18,8 +18,6 @@ async function editUserApi(token, data) {
"Authorization": `Token ${token}`,
},
})
-
- console.log(response)
return response
}
catch(e) {
@@ -29,22 +27,6 @@ async function editUserApi(token, data) {
};
-// async function getListUserApi(token) {
-// try {
-// const response = await axios.get(`https://api.minerva.krbl.ru/auth/manage/users`,
-// {
-// headers: {
-// "Authorization": `Token ${token}`
-// }
-// })
-// return response
-// }
-// catch (e) {
-// return e
-// }
-// };
-
-
async function getListUserApi(token) {
try {
const response = await axios.get(`https://api.minerva.krbl.ru/auth/manage/users`,
@@ -83,10 +65,31 @@ async function addUserApi(token, data) {
catch (e) {
return e
}
+};
+
+
+async function removeUserApi(token, login) {
+ try {
+ const response = await axios.post("https://api.minerva.krbl.ru/auth/manage/delete",
+ {
+ "login": login
+ },
+ {
+ headers: {
+ "Authorization": `Token ${token}`,
+ },
+ })
+ return response
+ }
+ catch(e) {
+ console.log(e)
+ return e
+ }
}
export {
editUserApi,
getListUserApi,
- addUserApi
+ addUserApi,
+ removeUserApi
}
\ No newline at end of file
diff --git a/src/pages/AdminPanel.jsx b/src/pages/AdminPanel.jsx
index a5eeea6..d2f9891 100644
--- a/src/pages/AdminPanel.jsx
+++ b/src/pages/AdminPanel.jsx
@@ -3,11 +3,12 @@ import { useCookies } from "react-cookie";
import { useNavigate } from "react-router-dom";
import classes from "../assets/styles/adminPanel.module.scss";
import { UserData } from "../context";
-import { getListUserApi, editUserApi, addUserApi } from "../hooks/api/profileApi.js";
+import { getListUserApi, editUserApi, addUserApi, removeUserApi } from "../hooks/api/profileApi.js";
import { verifyUser } from "../hooks/services/profile.js";
import DefaultModal from "../components/DefaultModal.jsx";
import EditUserAdminPanel from "../components/bodyModal/EditUserAdminPanel.jsx";
import MyButton from "../components/MyButton.jsx";
+import CheckModal from "../components/CheckModal.jsx";
const AdminPanel = () => {
@@ -106,13 +107,21 @@ const AdminPanel = () => {
setPhone(user.phone)
}
+ async function removeUser(login) {
+ const response = await removeUserApi(cookies.token, login)
+
+ if (response.status === 200) {
+ setListUser(listUser.filter(item => item.login !== login))
+ }
+ }
+
return (
-
+ {/*
navigate("/profile")}>Профиль
-
+
*/}
Пользователи
@@ -125,34 +134,56 @@ const AdminPanel = () => {
-
Логин
-
Фамилия
-
Email
-
Учитель
-
Администратор
+
+
Логин
+
Фамилия
+
Email
+
Учитель
+
Администратор
+
{listUser.map(item =>
-
openUser(item)}
- >
- {item.login}
-
-
- {item.last_name ? item.last_name : '-'}
-
-
- {item.email ? item.email : '-'}
-
-
- {item.is_teacher ? 'Да' : 'Нет'}
-
-
- {item.admin ? 'Да' : 'Нет'}
-
+
+
openUser(item)}
+ >
+ {item.login}
+
+
+ {item.last_name ? item.last_name : '-'}
+
+
+ {item.email ? item.email : '-'}
+
+
+ {
+ item.is_teacher ?
+ :
+
+ }
+
+
+ {
+ item.admin ?
+ :
+ }
+
+
+
+
+
?`}
+ action={{
+ execute: () => removeUser(item.login),
+ cancel: () => {}
+ }}
+ />
+
)}
{
- {user.is_admin ?
+ {/* {user.is_admin ?
navigate("/admin")}>Админ панель
-
:
}
+
:
} */}
Ваши данные
diff --git a/src/pages/TokensForm.jsx b/src/pages/TokensForm.jsx
index 9831786..98b0073 100644
--- a/src/pages/TokensForm.jsx
+++ b/src/pages/TokensForm.jsx
@@ -18,6 +18,7 @@ const TokensForm = () => {
useEffect(() => {
async function listFormsByToken() {
const response = await listFormsByTokenApi(cookies.token, formId)
+ console.log(response)
if (response.data.tokens) {
setTokens(response.data.tokens.filter(item => item.is_active === true))
@@ -78,7 +79,7 @@ const TokensForm = () => {
По умолчанию
- {item.form_id}
+ {item.id}
diff --git a/src/router/protectedRouting.js b/src/router/protectedRouting.js
index 7afca10..0d3b37e 100644
--- a/src/router/protectedRouting.js
+++ b/src/router/protectedRouting.js
@@ -5,6 +5,7 @@ const protectedUrl = {
new RegExp("/profile"),
new RegExp("/forms/\\w+/answers"),
new RegExp("/tokens/\\w+"),
+ new RegExp("/admin"),
],
Authorized: [
"/enter"
@@ -14,6 +15,7 @@ const protectedUrl = {
new RegExp("/forms/\\w+/edit"),
new RegExp("/forms/\\w+/answers"),
new RegExp("/tokens/\\w+"),
+ new RegExp("/admin"),
]
}