diff --git a/FrontEnd/src/pages/AdminPage/AdminGlobal.css b/FrontEnd/src/pages/AdminPage/AdminGlobal.css index ec7e45384..cf7c69970 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.jsx b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx new file mode 100644 index 000000000..a767b1402 --- /dev/null +++ b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx @@ -0,0 +1,67 @@ +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'; + +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((err) => { + if (err.response.data.email) { + toast.error('Ця електронна пошта вже використовується'); + } else { + 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 000000000..e750ca790 --- /dev/null +++ b/FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.module.css @@ -0,0 +1,71 @@ +.admin_registration-section { + display: flex; + flex-direction: column; + padding-left: 25px; + padding-top: 30px; +} + +.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: var(--notification-text-color__admin-panel); +} + +.admin_registration-label { + color: var(--main-black-90, #292E32); + font-family: var(--font-main); + font-size: 14px; + line-height: 20px; + letter-spacing: -0.01em; +} + +.admin_registration-input-wrapper { + display: flex; + flex-direction: column; + gap: 18px; +} + +.admin_registration-input { + width: 320px; + height: 25px; + margin: auto; + padding: 3px 12px; + border: 1px solid var(--border-input__admin-panel); + border-radius: 2px; + font-family: var(--font-messages); + font-size: 14px; +} + +.admin_registration-input:focus { + outline: none; +} + +.admin_registration-button { + padding: 5px 15px; + width: auto; + border-radius: 4px; + 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; + line-height: 20px; + letter-spacing: -0.16px; + cursor: pointer; +} + +.admin_registration-error { + color: var(--error-notification-text-color__admin-panel); + font-family: var(--font-main); + font-size: 14px; + margin-top: 7px; +} diff --git a/FrontEnd/src/pages/AdminPage/AutoApproveDelay/AutoApproveDelay.jsx b/FrontEnd/src/pages/AdminPage/AutoApproveDelay/AutoApproveDelay.jsx index 19bae05fb..ab7239bfc 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 038d52318..2b56d8adc 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 c3a74bd88..00b674dd7 100644 --- a/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx +++ b/FrontEnd/src/pages/AdminPage/Menu/Menu.jsx @@ -31,6 +31,12 @@ const SUPERUSER_MENU = [ title: 'Пошта адміністратора', link: '/customadmin/email/' }, + { + id: 'am6', + title: 'Реєстрація адміністратора', + link: '/customadmin/admin-create/' + } + ]; function Menu() { diff --git a/FrontEnd/src/routes/AdminRouter.jsx b/FrontEnd/src/routes/AdminRouter.jsx index a23d8bfca..ff9247c8f 100644 --- a/FrontEnd/src/routes/AdminRouter.jsx +++ b/FrontEnd/src/routes/AdminRouter.jsx @@ -15,6 +15,7 @@ import AutoApproveDelay from '../pages/AdminPage/AutoApproveDelay/AutoApproveDel import ModerationEmail from '../pages/AdminPage/DetailView/ModerationEmail'; import Contacts from '../pages/AdminPage/DetailView/Contacts'; import AdminProfilePage from '../pages/AdminPage/AdminProfile/AdminProfilePage'; +import AdminRegistration from '../pages/AdminPage/AdminRegistration/AdminRegistration'; import '../pages/AdminPage/AdminGlobal.css'; import css from '../pages/AdminPage/AdminPage.module.css'; @@ -34,7 +35,10 @@ function AdminRouter() { } /> } /> {isSuperUser && ( - } /> + <> + } /> + } /> + )} } /> } />