generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #820 from ita-social-projects/#800AdminFrontendAdm…
…inRegistrationPage [Admin][Frontend] Admin Registration Page
- Loading branch information
Showing
7 changed files
with
155 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div className={css['admin_registration-section']}> | ||
<h3>Реєстрація Адміністратора</h3> | ||
<div className={css['admin_registration-outer-wrapper']}> | ||
<label className={css['admin_registration-label']} htmlFor="newAdminEmail"> | ||
<span className={css['admin_registration-asterisk']} >*</span> | ||
Електронна адреса | ||
</label> | ||
<div className={css['admin_registration-input-wrapper']}> | ||
<Tooltip | ||
title={'Введіть тут електронну пошту особи, яку потрібно зареєструвати в якості адміністратора'} | ||
placement="top"> | ||
<input className={css['admin_registration-input']} | ||
id="newAdminEmail" | ||
onChange={handleInputChange} | ||
type="text" | ||
placeholder="Введіть електронну пошту" | ||
autoComplete="off" /> | ||
</Tooltip> | ||
<button className={css['admin_registration-button']} onClick={handleSubmit}> | ||
Згенерувати та надіслати пароль | ||
</button> | ||
</div> | ||
{error && <p className={css['admin_registration-error']} >{error}</p>} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AdminRegistration; |
71 changes: 71 additions & 0 deletions
71
FrontEnd/src/pages/AdminPage/AdminRegistration/AdminRegistration.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters