From caf16c4ea984c4c8b4964d379638dd4c93f6d7cd Mon Sep 17 00:00:00 2001 From: kuwsh1n Date: Wed, 8 May 2024 23:19:32 +0300 Subject: [PATCH] fix profile --- src/App.jsx | 1 + .../styles/components/myButton.module.scss | 4 ++++ src/pages/NewForm.jsx | 24 +++++++++---------- src/pages/Profile.jsx | 6 ++--- src/router/protectedRouting.js | 17 ++++++++----- 5 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index b2659cf..dd57b24 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -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 { diff --git a/src/assets/styles/components/myButton.module.scss b/src/assets/styles/components/myButton.module.scss index e2d45c6..3985573 100644 --- a/src/assets/styles/components/myButton.module.scss +++ b/src/assets/styles/components/myButton.module.scss @@ -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); diff --git a/src/pages/NewForm.jsx b/src/pages/NewForm.jsx index cba1e00..4df511a 100644 --- a/src/pages/NewForm.jsx +++ b/src/pages/NewForm.jsx @@ -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(); diff --git a/src/pages/Profile.jsx b/src/pages/Profile.jsx index 4a08768..b2aad0b 100644 --- a/src/pages/Profile.jsx +++ b/src/pages/Profile.jsx @@ -108,19 +108,19 @@ const Profile = () => { Редактировать : Сохранить } - backgroundColor={edit ? "rgb(200, 200, 200)" : ""} + class={edit ? "main__white" : "main__green"} click={() => editUser()}/> :
Запросите изменение профиля у администратора
} Выйти } - backgroundColor={edit ? "rgb(252, 151, 151)" : ""} + class={"main__red"} click={() => exitAccount()}/>
- {Object.keys(user).map(key => key !== "is_admin" ?
+ {Object.keys(user).map(key => key !== "is_admin" && key !== "is_teacher" && key !== "id" ?
{key} 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("/") }