From ada6b504ba8c9ef5ec2d5905228085d241631180 Mon Sep 17 00:00:00 2001 From: Yan Zhylavy Date: Fri, 11 Oct 2024 15:54:13 +0300 Subject: [PATCH 01/15] Implement front-end part of the Admin registration functionality --- .../AdminRegistration/AdminRegistration.jsx | 57 ++++++++++++++++ .../AdminRegistration.module.css | 68 +++++++++++++++++++ FrontEnd/src/pages/AdminPage/Menu/Menu.jsx | 5 ++ FrontEnd/src/routes/AdminRouter.jsx | 2 + 4 files changed, 132 insertions(+) create mode 100644 FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx create mode 100644 FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.module.css diff --git a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx new file mode 100644 index 00000000..a1572569 --- /dev/null +++ b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx @@ -0,0 +1,57 @@ +import axios from 'axios'; +import { toast } from 'react-toastify'; +import { useState } from 'react'; +import { EMAIL_PATTERN } from '../../../constants/constants'; +import css from './AdminRegistration.module.css'; + +const AdminRegistration = () => { + const [email, setEmail] = useState(''); + const [error, setError] = useState(null); + + const handleInputChange = (e) => { + setEmail(e.target.value); + }; + + const url = `${process.env.REACT_APP_BASE_API_URL}/api/admin/admin_create/`; + + const handleSubmit = () => { + EMAIL_PATTERN.test(email) ? + axios.post(url, { email: email }) + .then(() => { + toast.success('Пароль надіслано на електронну адресу'); + }) + .catch(() => { + toast.error('Виникла помилка'); + }) + .finally(() => { + setError(null); + }) + : + setError('Будь ласка, введіть дійсну електронну адресу'); + }; + + return ( +
+

Реєстрація Адміністратора

+
+ +
+ + +
+ {error &&

{error}

} +
+
+ ); +}; + +export default AdminRegistration; \ No newline at end of file diff --git a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.module.css b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.module.css new file mode 100644 index 00000000..44b6077e --- /dev/null +++ b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.module.css @@ -0,0 +1,68 @@ +.admin_registration-section { + display: flex; + flex-direction: column; + padding-left: 35px; + padding-top: 20px; +} + +.admin_registration-outer-wrapper { + display: flex; + flex-direction: column; + gap: 2px; + margin-top: 40px; +} +.admin_registration-asterisk { + font-family: var(--font-main); + font-size: 14px; + padding-right: 3px; + color: #FF4D4F; +} + +.admin_registration-label { + flex: 1 0; + color: var(--main-black-90, #292E32); + font-feature-settings: 'calt' off; + font-style: normal; + font-family: var(--font-main); + font-size: 14px; + font-weight: 400; + line-height: 20px; + letter-spacing: -0.01em; + text-align: left; + color: #292E32; +} + +.admin_registration-input-wrapper { + display: flex; + flex-direction: row; + gap: 10px; +} + +.admin_registration-input { + width: 320px; + height: 25px; + padding: 0 2px; + margin: auto; +} + +.admin_registration-button { + padding: 5px 15px; + width: auto; + border-radius: 4px; + border: 1px solid #1F9A7C; + background: #1F9A7C; + box-shadow: 0px 2px 0px 0px rgba(0, 0, 0, 0.04); + color: #FFF; + font-family: var(--font-main); + font-size: 16px; + font-weight: 600; + line-height: 20px; + letter-spacing: -0.16px; + cursor: pointer; +} + +.admin_registration-error { + color: rgb(212, 21, 21); + font-family: var(--font-main); + font-size: 14px; +} diff --git a/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx b/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx index 59cd7d2f..a1995dc1 100644 --- a/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx +++ b/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx @@ -29,6 +29,11 @@ const MENU = [ id: 'am5', title: 'Пошта адміністратора', link: '/customadmin/email/' + }, + { + id: 'am6', + title: 'Реєстрація адміністратора', + link: '/customadmin/admin_create/' } ]; diff --git a/FrontEnd/src/routes/AdminRouter.jsx b/FrontEnd/src/routes/AdminRouter.jsx index 1237273c..25e8b3c2 100644 --- a/FrontEnd/src/routes/AdminRouter.jsx +++ b/FrontEnd/src/routes/AdminRouter.jsx @@ -14,6 +14,7 @@ import Loader from '../components/Loader/Loader'; import AutoApproveDelay from '../pages/AdminPage/AutoApproveDelay/AutoApproveDelay'; import ModerationEmail from '../pages/AdminPage/DetailView/ModerationEmail'; import Contacts from '../pages/AdminPage/DetailView/Contacts'; +import AdminRegistration from '../pages/AdminPage/AdminRegistration/AdminRegistration'; function AdminRouter() { @@ -29,6 +30,7 @@ function AdminRouter() { } /> } /> } /> + } /> ) : ( From d3c04cc734fd62c946bc8f04fe8025b6fcf9c000 Mon Sep 17 00:00:00 2001 From: Yan Zhylavy Date: Fri, 11 Oct 2024 16:02:17 +0300 Subject: [PATCH 02/15] Add tooltip for admin registration input --- .../AdminRegistration/AdminRegistration.jsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx index a1572569..f8f22193 100644 --- a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx +++ b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx @@ -1,5 +1,6 @@ import axios from 'axios'; import { toast } from 'react-toastify'; +import { Tooltip } from 'antd'; import { useState } from 'react'; import { EMAIL_PATTERN } from '../../../constants/constants'; import css from './AdminRegistration.module.css'; @@ -39,11 +40,15 @@ const AdminRegistration = () => { Електронна адреса
- + + + From 6816d8e6df4ba37f7b76424cceb5cd77a1193652 Mon Sep 17 00:00:00 2001 From: Yan Zhylavy Date: Fri, 11 Oct 2024 16:10:40 +0300 Subject: [PATCH 03/15] Change tooltip placement to top --- .../src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx index f8f22193..8b2b9e7d 100644 --- a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx +++ b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx @@ -42,7 +42,7 @@ const AdminRegistration = () => {
+ placement="top"> Date: Fri, 11 Oct 2024 16:34:21 +0300 Subject: [PATCH 04/15] css adjustments --- FrontEnd/src/pages/AdminPage/AdminGlobal.css | 3 +++ .../AdminRegistration.module.css | 22 +++++++------------ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/FrontEnd/src/pages/AdminPage/AdminGlobal.css b/FrontEnd/src/pages/AdminPage/AdminGlobal.css index ec7e4538..cf7c6997 100644 --- a/FrontEnd/src/pages/AdminPage/AdminGlobal.css +++ b/FrontEnd/src/pages/AdminPage/AdminGlobal.css @@ -10,4 +10,7 @@ --border-input__admin-panel: #d9d9d9; --background-butons__admin-panel: #1F9A7C; --button-color__admin-panel: #1F9A7C; + --button-text-color__admin-panel: #FFF; + --error-notification-text-color__admin-panel: #f4282b; + --box-shadow-color__admin-panel: rgba(0, 0, 0, 0.04); } diff --git a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.module.css b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.module.css index 44b6077e..fc4e55da 100644 --- a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.module.css +++ b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.module.css @@ -1,8 +1,8 @@ .admin_registration-section { display: flex; flex-direction: column; - padding-left: 35px; - padding-top: 20px; + padding-left: 25px; + padding-top: 30px; } .admin_registration-outer-wrapper { @@ -15,21 +15,15 @@ font-family: var(--font-main); font-size: 14px; padding-right: 3px; - color: #FF4D4F; + color: var(--notification-text-color__admin-panel); } .admin_registration-label { - flex: 1 0; color: var(--main-black-90, #292E32); - font-feature-settings: 'calt' off; - font-style: normal; font-family: var(--font-main); font-size: 14px; - font-weight: 400; line-height: 20px; letter-spacing: -0.01em; - text-align: left; - color: #292E32; } .admin_registration-input-wrapper { @@ -49,10 +43,10 @@ padding: 5px 15px; width: auto; border-radius: 4px; - border: 1px solid #1F9A7C; - background: #1F9A7C; - box-shadow: 0px 2px 0px 0px rgba(0, 0, 0, 0.04); - color: #FFF; + border: 1px solid var(--button-color__admin-panel); + background: var(--button-color__admin-panel); + box-shadow: 0px 2px 0px 0px var(--box-shadow-color__admin-panel); + color: var(--button-text-color__admin-panel); font-family: var(--font-main); font-size: 16px; font-weight: 600; @@ -62,7 +56,7 @@ } .admin_registration-error { - color: rgb(212, 21, 21); + color: var(--error-notification-text-color__admin-panel); font-family: var(--font-main); font-size: 14px; } From fe3214596331b19abbc535efd7ee782b39113702 Mon Sep 17 00:00:00 2001 From: Yan Zhylavy Date: Fri, 11 Oct 2024 16:51:54 +0300 Subject: [PATCH 05/15] Adjust input attributes in AdminRegistration --- .../pages/AdminPage/AdminRegistration/AdminRegistration.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx index 8b2b9e7d..544d0461 100644 --- a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx +++ b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx @@ -44,7 +44,8 @@ const AdminRegistration = () => { title={'Введіть тут електронну пошту особи, яку потрібно зареєструвати в якості адміністратора'} placement="top"> From a336148e0625634605eb8ef76e18f54a38014b64 Mon Sep 17 00:00:00 2001 From: Yan Zhylavy Date: Fri, 11 Oct 2024 16:54:58 +0300 Subject: [PATCH 06/15] Delete trailing spaces --- .../src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx index 544d0461..f98fbf5e 100644 --- a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx +++ b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx @@ -44,7 +44,7 @@ const AdminRegistration = () => { title={'Введіть тут електронну пошту особи, яку потрібно зареєструвати в якості адміністратора'} placement="top"> Date: Fri, 11 Oct 2024 17:47:59 +0300 Subject: [PATCH 07/15] admin_create -> admin-create --- .../src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx | 2 +- FrontEnd/src/pages/AdminPage/Menu/Menu.jsx | 2 +- FrontEnd/src/routes/AdminRouter.jsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx index f98fbf5e..413743bc 100644 --- a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx +++ b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx @@ -13,7 +13,7 @@ const AdminRegistration = () => { setEmail(e.target.value); }; - const url = `${process.env.REACT_APP_BASE_API_URL}/api/admin/admin_create/`; + const url = `${process.env.REACT_APP_BASE_API_URL}/api/admin/admin-create/`; const handleSubmit = () => { EMAIL_PATTERN.test(email) ? diff --git a/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx b/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx index 93544cea..cf1fb505 100644 --- a/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx +++ b/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx @@ -31,7 +31,7 @@ const MENU = [ { id: 'am6', title: 'Реєстрація адміністратора', - link: '/customadmin/admin_create/' + link: '/customadmin/admin-create/' } ]; diff --git a/FrontEnd/src/routes/AdminRouter.jsx b/FrontEnd/src/routes/AdminRouter.jsx index a9fc3c41..45973352 100644 --- a/FrontEnd/src/routes/AdminRouter.jsx +++ b/FrontEnd/src/routes/AdminRouter.jsx @@ -36,7 +36,7 @@ function AdminRouter() { } /> } /> } /> - } /> + } /> ) : ( From 24cec9f53748010cbd300cbd0471f4a599211dc4 Mon Sep 17 00:00:00 2001 From: Yan Zhylavy Date: Fri, 11 Oct 2024 17:50:01 +0300 Subject: [PATCH 08/15] Fix url --- .../src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx index 413743bc..f98fbf5e 100644 --- a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx +++ b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx @@ -13,7 +13,7 @@ const AdminRegistration = () => { setEmail(e.target.value); }; - const url = `${process.env.REACT_APP_BASE_API_URL}/api/admin/admin-create/`; + const url = `${process.env.REACT_APP_BASE_API_URL}/api/admin/admin_create/`; const handleSubmit = () => { EMAIL_PATTERN.test(email) ? From f8dd37e46a9c2f023c2622ef7d796f0a04e0b03c Mon Sep 17 00:00:00 2001 From: Yan Zhylavy Date: Sat, 12 Oct 2024 10:49:31 +0300 Subject: [PATCH 09/15] Add isSuperUser state in useAuth for confitional rendering of specific elements, set this conditional rendering, fix bad code with controled/uncontroled inputs in adminpanel --- FrontEnd/src/context/AuthContextProvider.js | 5 ++++- .../AutoApproveDelay/AutoApproveDelay.jsx | 2 +- .../pages/AdminPage/DetailView/ModerationEmail.jsx | 4 ++-- FrontEnd/src/pages/AdminPage/Menu/Menu.jsx | 14 ++++++++++++-- FrontEnd/src/routes/AdminRouter.jsx | 10 +++++++--- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/FrontEnd/src/context/AuthContextProvider.js b/FrontEnd/src/context/AuthContextProvider.js index 4771e741..b56d77d9 100644 --- a/FrontEnd/src/context/AuthContextProvider.js +++ b/FrontEnd/src/context/AuthContextProvider.js @@ -10,6 +10,7 @@ export function AuthProvider({ children }) { const [isLoading, setLoading] = useState(true); const [authToken, setAuthToken] = useState(localStorage.getItem('Token')); const [isStaff, setIsStaff] = useState(false); + const [isSuperUser, setIsSuperUser] = useState(false); const { data, error, mutate } = useSWR( authToken ? [`${process.env.REACT_APP_BASE_API_URL}/api/auth/users/me/`, authToken] @@ -45,6 +46,7 @@ export function AuthProvider({ children }) { delete axios.defaults.headers.common['Authorization']; setIsAuth(false); setIsStaff(false); + setIsSuperUser(false); setUser(null); }; @@ -70,6 +72,7 @@ export function AuthProvider({ children }) { if (data) { setUser(data); setIsStaff(data.is_staff); + setIsSuperUser(data?.is_superuser ?? false); } if (error) { setUser(null); @@ -93,7 +96,7 @@ export function AuthProvider({ children }) { }); }); - const value = { login, logout, isAuth, authToken, isLoading, isStaff, user, error, mutate }; + const value = { login, logout, isAuth, authToken, isLoading, isStaff, isSuperUser, user, error, mutate }; return {children}; } \ No newline at end of file diff --git a/FrontEnd/src/pages/AdminPage/AutoApproveDelay/AutoApproveDelay.jsx b/FrontEnd/src/pages/AdminPage/AutoApproveDelay/AutoApproveDelay.jsx index 19bae05f..ab7239bf 100644 --- a/FrontEnd/src/pages/AdminPage/AutoApproveDelay/AutoApproveDelay.jsx +++ b/FrontEnd/src/pages/AdminPage/AutoApproveDelay/AutoApproveDelay.jsx @@ -13,7 +13,7 @@ const AutoApproveDelay = () => { }); const url = `${process.env.REACT_APP_BASE_API_URL}/api/admin/automoderation/`; const { data, mutate } = useSWR(url, fetcher); - const [delay, setDelay] = useState(null); + const [delay, setDelay] = useState(''); const [error, setError] = useState(null); useEffect(() => { diff --git a/FrontEnd/src/pages/AdminPage/DetailView/ModerationEmail.jsx b/FrontEnd/src/pages/AdminPage/DetailView/ModerationEmail.jsx index 038d5231..2b56d8ad 100644 --- a/FrontEnd/src/pages/AdminPage/DetailView/ModerationEmail.jsx +++ b/FrontEnd/src/pages/AdminPage/DetailView/ModerationEmail.jsx @@ -11,7 +11,7 @@ const ModerationEmail = () => { const { data, mutate } = useSWR(url, fetcher); // Define email and setEmail using useState - const [email, setEmail] = useState(null); + const [email, setEmail] = useState(''); // Update email state when data is fetched useEffect(() => { @@ -39,7 +39,7 @@ const ModerationEmail = () => { title={'Введіть Email'} placement="top" pointAtCenter={true}> - +
diff --git a/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx b/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx index cf1fb505..f76def3d 100644 --- a/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx +++ b/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx @@ -1,5 +1,5 @@ import { NavLink } from 'react-router-dom'; - +import { useAuth } from '../../../hooks'; import css from './Menu.module.css'; const MENU = [ @@ -23,6 +23,10 @@ const MENU = [ title: 'Зміна часу автомодерації', link: '/customadmin/automoderation/' }, + +]; + +const superUserMenu = [ { id: 'am5', title: 'Пошта адміністратора', @@ -36,7 +40,7 @@ const MENU = [ ]; function Menu() { - + const { isSuperUser } = useAuth(); return (
{MENU.map((element) => ( @@ -45,6 +49,12 @@ function Menu() { key={element.id} to={element.link}>{element.title} ))} + {isSuperUser && + superUserMenu.map((element) => ( + (`${css['menu-section-element']} ${isActive && css['menu-section-element__active']}`)} + key={element.id} to={element.link}>{element.title} + ))}
); } diff --git a/FrontEnd/src/routes/AdminRouter.jsx b/FrontEnd/src/routes/AdminRouter.jsx index 45973352..a2217f75 100644 --- a/FrontEnd/src/routes/AdminRouter.jsx +++ b/FrontEnd/src/routes/AdminRouter.jsx @@ -21,7 +21,7 @@ import '../pages/AdminPage/AdminGlobal.css'; import css from '../pages/AdminPage/AdminPage.module.css'; function AdminRouter() { - const { isLoading, isAuth, isStaff, user } = useAuth(); + const { isLoading, isAuth, isStaff, isSuperUser, user } = useAuth(); const { pathname } = useLocation(); const hideMenu = pathname.includes('/admin-profile/'); const renderMenu = isStaff && isAuth && !hideMenu ? : null; @@ -33,10 +33,14 @@ function AdminRouter() { } /> } /> } /> - } /> } /> } /> - } /> + {isSuperUser ? + <> + } /> + } /> + + : null} ) : ( From da6c0a4ce5bcfd92f2c0395a2193ac9bcccfd8e1 Mon Sep 17 00:00:00 2001 From: Yan Zhylavy Date: Sat, 12 Oct 2024 11:29:44 +0300 Subject: [PATCH 10/15] Undo last changes, they are to be made by other contributor. Bug fix remains untouched --- FrontEnd/src/context/AuthContextProvider.js | 5 +---- FrontEnd/src/pages/AdminPage/Menu/Menu.jsx | 15 +++------------ FrontEnd/src/routes/AdminRouter.jsx | 10 +++------- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/FrontEnd/src/context/AuthContextProvider.js b/FrontEnd/src/context/AuthContextProvider.js index b56d77d9..4771e741 100644 --- a/FrontEnd/src/context/AuthContextProvider.js +++ b/FrontEnd/src/context/AuthContextProvider.js @@ -10,7 +10,6 @@ export function AuthProvider({ children }) { const [isLoading, setLoading] = useState(true); const [authToken, setAuthToken] = useState(localStorage.getItem('Token')); const [isStaff, setIsStaff] = useState(false); - const [isSuperUser, setIsSuperUser] = useState(false); const { data, error, mutate } = useSWR( authToken ? [`${process.env.REACT_APP_BASE_API_URL}/api/auth/users/me/`, authToken] @@ -46,7 +45,6 @@ export function AuthProvider({ children }) { delete axios.defaults.headers.common['Authorization']; setIsAuth(false); setIsStaff(false); - setIsSuperUser(false); setUser(null); }; @@ -72,7 +70,6 @@ export function AuthProvider({ children }) { if (data) { setUser(data); setIsStaff(data.is_staff); - setIsSuperUser(data?.is_superuser ?? false); } if (error) { setUser(null); @@ -96,7 +93,7 @@ export function AuthProvider({ children }) { }); }); - const value = { login, logout, isAuth, authToken, isLoading, isStaff, isSuperUser, user, error, mutate }; + const value = { login, logout, isAuth, authToken, isLoading, isStaff, user, error, mutate }; return {children}; } \ No newline at end of file diff --git a/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx b/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx index f76def3d..7aa988af 100644 --- a/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx +++ b/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx @@ -1,5 +1,5 @@ import { NavLink } from 'react-router-dom'; -import { useAuth } from '../../../hooks'; + import css from './Menu.module.css'; const MENU = [ @@ -23,10 +23,6 @@ const MENU = [ title: 'Зміна часу автомодерації', link: '/customadmin/automoderation/' }, - -]; - -const superUserMenu = [ { id: 'am5', title: 'Пошта адміністратора', @@ -37,10 +33,11 @@ const superUserMenu = [ title: 'Реєстрація адміністратора', link: '/customadmin/admin-create/' } + ]; function Menu() { - const { isSuperUser } = useAuth(); + return (
{MENU.map((element) => ( @@ -49,12 +46,6 @@ function Menu() { key={element.id} to={element.link}>{element.title} ))} - {isSuperUser && - superUserMenu.map((element) => ( - (`${css['menu-section-element']} ${isActive && css['menu-section-element__active']}`)} - key={element.id} to={element.link}>{element.title} - ))}
); } diff --git a/FrontEnd/src/routes/AdminRouter.jsx b/FrontEnd/src/routes/AdminRouter.jsx index a2217f75..45973352 100644 --- a/FrontEnd/src/routes/AdminRouter.jsx +++ b/FrontEnd/src/routes/AdminRouter.jsx @@ -21,7 +21,7 @@ import '../pages/AdminPage/AdminGlobal.css'; import css from '../pages/AdminPage/AdminPage.module.css'; function AdminRouter() { - const { isLoading, isAuth, isStaff, isSuperUser, user } = useAuth(); + const { isLoading, isAuth, isStaff, user } = useAuth(); const { pathname } = useLocation(); const hideMenu = pathname.includes('/admin-profile/'); const renderMenu = isStaff && isAuth && !hideMenu ? : null; @@ -33,14 +33,10 @@ function AdminRouter() { } /> } /> } /> + } /> } /> } /> - {isSuperUser ? - <> - } /> - } /> - - : null} + } /> ) : ( From c209131d6b62fa6c3269c3749d386d34c78824b5 Mon Sep 17 00:00:00 2001 From: Yan Zhylavy Date: Mon, 14 Oct 2024 09:05:21 +0300 Subject: [PATCH 11/15] Add message for already used email for AdminRegistration --- .../AdminPage/AdminRegistration/AdminRegistration.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx index f98fbf5e..2fd0d0b8 100644 --- a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx +++ b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx @@ -21,8 +21,12 @@ const AdminRegistration = () => { .then(() => { toast.success('Пароль надіслано на електронну адресу'); }) - .catch(() => { - toast.error('Виникла помилка'); + .catch((err) => { + if (err.response.data.email) { + toast.error('Ця електронна пошта вже використовується'); + } else { + toast.error('Виникла помилка'); + } }) .finally(() => { setError(null); From 404cc90a5913ce0564e1ad264b40b9f01d7352fa Mon Sep 17 00:00:00 2001 From: Yan Zhylavy Date: Mon, 14 Oct 2024 09:39:11 +0300 Subject: [PATCH 12/15] css adjustments --- .../AdminPage/AdminRegistration/AdminRegistration.module.css | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.module.css b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.module.css index fc4e55da..af6aa79b 100644 --- a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.module.css +++ b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.module.css @@ -35,8 +35,10 @@ .admin_registration-input { width: 320px; height: 25px; - padding: 0 2px; margin: auto; + padding: 3px 12px; + border: 1px solid var(--border-input__admin-panel); + font-size: 14px; } .admin_registration-button { From 7e7bbeb54e7fd80b7075ff5f3264e8809e43890b Mon Sep 17 00:00:00 2001 From: Yan Zhylavy Date: Mon, 14 Oct 2024 10:28:04 +0300 Subject: [PATCH 13/15] Change flex-direction, turn off input autocomplete --- .../AdminPage/AdminRegistration/AdminRegistration.jsx | 2 +- .../AdminRegistration/AdminRegistration.module.css | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx index 2fd0d0b8..bca65242 100644 --- a/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx +++ b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx @@ -52,7 +52,7 @@ const AdminRegistration = () => { onChange={handleInputChange} type="text" placeholder="Введіть текст" - autoComplete="email" /> + autoComplete="off" />