This commit is contained in:
parent
e4dba30177
commit
caf16c4ea9
@ -41,6 +41,7 @@ const App = () => {
|
||||
|
||||
if (response.status === 200) {
|
||||
setUser(response.data);
|
||||
console.log(response.data)
|
||||
globalRender(window.location.pathname, response.data, navigate);
|
||||
}
|
||||
else {
|
||||
|
@ -8,6 +8,10 @@
|
||||
border-radius: 5px;
|
||||
font-family: "Montserrat", sans-serif;
|
||||
}
|
||||
&__red {
|
||||
color: white;
|
||||
background-color: rgb(235, 130, 130);
|
||||
}
|
||||
&__green {
|
||||
color: white;
|
||||
background-color: rgb(150, 209, 158);
|
||||
|
@ -190,16 +190,16 @@ const NewForm = () => {
|
||||
cleanStates();
|
||||
};
|
||||
|
||||
async function updateTitleForm() {
|
||||
const response = await updateTitleFormApi(cookies.token, formId, newTitleForm);
|
||||
// async function updateTitleForm() {
|
||||
// const response = await updateTitleFormApi(cookies.token, formId, newTitleForm);
|
||||
|
||||
if (response.status === 200) {
|
||||
console.log(response)
|
||||
}
|
||||
else {
|
||||
console.log(response)
|
||||
}
|
||||
};
|
||||
// if (response.status === 200) {
|
||||
// console.log(response)
|
||||
// }
|
||||
// else {
|
||||
// console.log(response)
|
||||
// }
|
||||
// };
|
||||
|
||||
async function updateOrderBlock() {
|
||||
const response = await updateOrderBlockApi(cookies.token, formId, {
|
||||
@ -220,15 +220,13 @@ const NewForm = () => {
|
||||
tListBlock.splice(dragElem, 1);
|
||||
};
|
||||
|
||||
tListBlock.forEach((value, i) => tListBlock[i].order = i)
|
||||
|
||||
setListBlock(tListBlock);
|
||||
setListBlock(numberingBlocks(tListBlock, "order"));
|
||||
}
|
||||
};
|
||||
|
||||
async function saveForm() {
|
||||
if (oldTitleFrom !== newTitleForm) {
|
||||
await updateTitleForm()
|
||||
await updateTitleFormApi(cookies.token, formId, newTitleForm);
|
||||
}
|
||||
|
||||
cleanStates();
|
||||
|
@ -108,19 +108,19 @@ const Profile = () => {
|
||||
<span>Редактировать <i class="fa-solid fa-pen"></i></span> :
|
||||
<span>Сохранить <i class="fa-solid fa-floppy-disk"></i></span>
|
||||
}
|
||||
backgroundColor={edit ? "rgb(200, 200, 200)" : ""}
|
||||
class={edit ? "main__white" : "main__green"}
|
||||
click={() => editUser()}/> : <div>Запросите изменение профиля у администратора</div>}
|
||||
<MyButton
|
||||
text={
|
||||
<span>Выйти</span>
|
||||
}
|
||||
backgroundColor={edit ? "rgb(252, 151, 151)" : ""}
|
||||
class={"main__red"}
|
||||
click={() => exitAccount()}/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div className={classes.profile__wrapper__body}>
|
||||
{Object.keys(user).map(key => key !== "is_admin" ? <div className={classes.profile__wrapper__body__item}>
|
||||
{Object.keys(user).map(key => key !== "is_admin" && key !== "is_teacher" && key !== "id" ? <div className={classes.profile__wrapper__body__item}>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text">{key}</span>
|
||||
<input
|
||||
|
@ -1,25 +1,30 @@
|
||||
const protectedUrl = {
|
||||
notAuthorized: [
|
||||
"/forms",
|
||||
"/forms/edit",
|
||||
"/profile"
|
||||
new RegExp("/forms"),
|
||||
new RegExp("/forms/\\w+/edit"),
|
||||
new RegExp("/profile"),
|
||||
new RegExp("/forms/\\w+/answers"),
|
||||
new RegExp("/tokens/\\w+"),
|
||||
],
|
||||
Authorized: [
|
||||
"/enter"
|
||||
],
|
||||
notRights: [
|
||||
"/forms"
|
||||
new RegExp("/forms"),
|
||||
new RegExp("/forms/\\w+/edit"),
|
||||
new RegExp("/forms/\\w+/answers"),
|
||||
new RegExp("/tokens/\\w+"),
|
||||
]
|
||||
}
|
||||
|
||||
function globalRender(url, user, navigate) {
|
||||
if (!user && protectedUrl.notAuthorized.some(item => item === url)) {
|
||||
if (!user && protectedUrl.notAuthorized.some(item => url.match(item) ? url.match(item)[0] === url : false)) {
|
||||
navigate("/enter")
|
||||
}
|
||||
else if (user && protectedUrl.Authorized.some(item => item === url)) {
|
||||
navigate("/")
|
||||
}
|
||||
else if (user && protectedUrl.notRights.some(item => item === url)) {
|
||||
else if (user && protectedUrl.notRights.some(item => url.match(item) ? url.match(item)[0] === url : false)) {
|
||||
if (!user.is_admin) {
|
||||
navigate("/")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user