Skip to content

Commit

Permalink
feat: Add User and Admin toggle on login pages
Browse files Browse the repository at this point in the history
  • Loading branch information
meetulr committed Jan 5, 2024
1 parent 3819bd8 commit 3440f7b
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 17 deletions.
5 changes: 3 additions & 2 deletions public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
"notAuthorised": "Sorry! you are not Authorised!",
"notFound": "User not found!",
"successfullyRegistered": "Successfully Registered. Please wait until you will be approved.",
"login_to_admin_portal": "Admin Portal Login",
"OR": "OR"
"OR": "OR",
"admin": "ADMIN",
"user": "USER"
},
"latestEvents": {
"eventCardTitle": "Upcoming Events",
Expand Down
5 changes: 3 additions & 2 deletions public/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
"notAuthorised": "Désolé ! vous n'êtes pas autorisé !",
"notFound": "Utilisateur introuvable !",
"successfullyRegistered": "Enregistré avec succès. Veuillez patienter jusqu'à ce que vous soyez approuvé.",
"login_to_admin_portal": "Connexion à l'administration du portail",
"OR": "OU"
"OR": "OU",
"admin": "ADMIN",
"user": "UTILISATEUR"
},
"latestEvents": {
"eventCardTitle": "Événements à venir",
Expand Down
5 changes: 3 additions & 2 deletions public/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
"notAuthorised": "क्षमा करें! आप अधिकृत नहीं हैं!",
"notFound": "उपयोगकर्ता नहीं मिला!",
"successfullyRegistered": "सफलतापूर्वक पंजीकृत। कृपया स्वीकृत होने तक प्रतीक्षा करें।",
"login_to_admin_portal": "एडमिन पोर्टल लॉगिन",
"OR": "या"
"OR": "या",
"admin": "व्यवस्थापक",
"user": "उपयोगकर्ता"
},
"latestEvents": {
"eventCardTitle": "आगामी घटनाएँ",
Expand Down
5 changes: 3 additions & 2 deletions public/locales/sp.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
"notAuthorised": "¡Lo siento! ¡No estás autorizado!",
"notFound": "¡Usuario no encontrado!",
"successfullyRegistered": "Registrado con éxito. Espere hasta que sea aprobado",
"login_to_admin_portal": "Inicio de sesión en el portal de administración",
"OR": "O"
"OR": "O",
"admin": "ADMINISTRACIÓN",
"user": "USUARIO"
},
"latestEvents": {
"eventCardTitle": "Próximos Eventos",
Expand Down
5 changes: 3 additions & 2 deletions public/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
"notAuthorised": "抱歉!你沒有被授權!",
"notFound": "找不到用戶!",
"successfullyRegistered": "註冊成功,請等待審核通過。",
"login_to_admin_portal": " 管理员门户登录 ",
"OR": "或者"
"OR": "或者",
"admin": "行政",
"user": "用戶"
},
"latestEvents": {
"eventCardTitle": "即将举行的活动",
Expand Down
3 changes: 1 addition & 2 deletions src/components/UserPortal/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ export default function login(props: InterfaceLoginProps): JSX.Element {
/* istanbul ignore next */
window.location.assign('/user/organizations');
} else {
/* istanbul ignore next */
toast.warn(t('notAuthorised'));
}
} catch (error: any) {
/* istanbul ignore next */
errorHandler(t, error);
}
}
Expand Down Expand Up @@ -84,7 +84,6 @@ export default function login(props: InterfaceLoginProps): JSX.Element {
return (
<>
<h3 className="mt-3 font-weight-bold">{t('login')}</h3>
<div className="mt-1">{t('loginIntoYourAccount')}</div>

<div className="my-3">
<h6>{t('emailAddress')}</h6>
Expand Down
25 changes: 25 additions & 0 deletions src/screens/LoginPage/LoginPage.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,31 @@
color: var(--bs-secondary);
}

.navLinkClass {
display: inline-block;
padding: 0.375rem 0.75rem;
font-size: 1rem;
line-height: 1.5;
text-align: center;
vertical-align: middle;
cursor: pointer;
color: #212529;
border-radius: 0.25rem;
width: 100%;
box-sizing: border-box;
font-weight: 500;
transition: font-weight 0.3s ease;
}

.navLinkClass:hover {
font-weight: 700;
}

.activeLink {
border-bottom: 3px solid;
width: 100%;
}

@media (max-width: 992px) {
.row .left_portion {
padding: 0 2rem;
Expand Down
2 changes: 1 addition & 1 deletion src/screens/LoginPage/LoginPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ describe('Testing Login Page Screen', () => {

await wait();

expect(screen.getByText(/Admin Portal/i)).toBeInTheDocument();
expect(screen.getByText(/Admin/i)).toBeInTheDocument();
expect(window.location).toBeAt('/orglist');
});

Expand Down
29 changes: 25 additions & 4 deletions src/screens/LoginPage/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Col from 'react-bootstrap/Col';
import Row from 'react-bootstrap/Row';
import ReCAPTCHA from 'react-google-recaptcha';
import { useTranslation } from 'react-i18next';
import { Link, useHistory } from 'react-router-dom';
import { Link, NavLink, useHistory } from 'react-router-dom';
import { toast } from 'react-toastify';

import {
Expand Down Expand Up @@ -299,16 +299,37 @@ function loginPage(): JSX.Element {
showTab === 'REGISTER' && styles.marginTopForReg
}`}
/>

<Row className="mb-5">
<Col>
<NavLink
className={styles.navLinkClass}
activeClassName={styles.activeLink}
exact
to="/"
>
{t('admin')}
</NavLink>
</Col>
<Col>
<NavLink
className={styles.navLinkClass}
activeClassName={styles.activeLink}
exact
to="/user"
>
{t('user')}
</NavLink>
</Col>
</Row>
{/* LOGIN FORM */}
<div
className={`${
showTab === 'LOGIN' ? styles.active_tab : 'd-none'
}`}
>
<form onSubmit={loginLink}>
<h1 className="fs-2 fw-bold text-dark mb-3">
{t('login_to_admin_portal')}
</h1>
<h1 className="fs-2 fw-bold text-dark mb-3">{t('login')}</h1>
<Form.Label>{t('email')}</Form.Label>
<div className="position-relative">
<Form.Control
Expand Down
25 changes: 25 additions & 0 deletions src/screens/UserPortal/UserLoginPage/UserLoginPage.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@ body::before {
content: none !important;
}

.navLinkClass {
display: inline-block;
padding: 0.375rem 0.75rem;
font-size: 1rem;
line-height: 1.5;
text-align: center;
vertical-align: middle;
cursor: pointer;
color: #212529;
border-radius: 0.25rem;
width: 100%;
box-sizing: border-box;
font-weight: 400;
transition: font-weight 0.3s ease;
}

.navLinkClass:hover {
font-weight: 700;
}

.activeLink {
border-bottom: 3px solid;
width: 100%;
}

.leftPane {
align-items: center;
width: 60%;
Expand Down
24 changes: 24 additions & 0 deletions src/screens/UserPortal/UserLoginPage/UserLoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
TwitterLogo,
YoutubeLogo,
} from 'assets/svgs/social-icons';
import { NavLink } from 'react-router-dom';
import { Col, Row } from 'react-bootstrap';

export default function userLoginPage(): JSX.Element {
const { t } = useTranslation('translation', { keyPrefix: 'loginPage' });
Expand Down Expand Up @@ -96,6 +98,28 @@ export default function userLoginPage(): JSX.Element {
src={TalawaImage}
alt="Talawa Branding"
/>
<Row className="mb-3">
<Col>
<NavLink
className={styles.navLinkClass}
activeClassName={styles.activeLink}
exact
to="/"
>
{t('admin')}
</NavLink>
</Col>
<Col>
<NavLink
className={styles.navLinkClass}
activeClassName={styles.activeLink}
exact
to="/user"
>
{t('user')}
</NavLink>
</Col>
</Row>
{
/* istanbul ignore next */
currentMode === 'login' ? (
Expand Down

0 comments on commit 3440f7b

Please sign in to comment.