Skip to content

Commit

Permalink
add cant login
Browse files Browse the repository at this point in the history
  • Loading branch information
LWangllix committed Jul 25, 2024
1 parent ba5008e commit 9bbf6cc
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Cookies from 'universal-cookie';
import api from './api';
import DefaultLayout from './components/layouts/DefaultLayout';
import LoaderComponent from './components/other/LoaderComponent';
import { CantLogin } from './pages/CantLogin';
import { Login } from './pages/Login';
import { useAppSelector } from './state/hooks';
import { ProfileId } from './types';
Expand Down Expand Up @@ -92,6 +93,9 @@ function App() {
const { isLoading: tenantInfoLoading } = useTenantInfoMutation();

const eGatesLoginMutation = useMutation((ticket: string) => api.eGatesLogin({ ticket }), {
onError: () => {
navigate(slugs.cantLogin);
},
onSuccess: (data) => {
handleUpdateTokens(data);
},
Expand Down Expand Up @@ -201,6 +205,7 @@ function App() {
<Routes>
<Route element={<PublicRoute profileId={profileId} loggedIn={loggedIn} />}>
<Route path="/login" element={<Login />} />
<Route path={slugs.cantLogin} element={<CantLogin />} />
</Route>
<Route
element={
Expand Down
30 changes: 30 additions & 0 deletions src/components/other/ReturnToLogin.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { useNavigate } from "react-router-dom";
import styled from "styled-components";
import { slugs } from "../../utils/routes";
import { buttonsTitles } from "../../utils/texts";
import Icon from "./Icons";

const ReturnToLogin = () => {
const navigate = useNavigate();

return (
<Row onClick={() => navigate(slugs.login)}>
<Icon name="returnArrow" />
<BackButton> {buttonsTitles.returnToLogin}</BackButton>
</Row>
);
};

const BackButton = styled.div`
font-size: 1.5rem;
color: #121926;
margin-left: 11px;
`;

const Row = styled.div`
margin-top: 16px;
display: flex;
cursor: pointer;
`;

export default ReturnToLogin;
41 changes: 41 additions & 0 deletions src/pages/CantLogin.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import styled from 'styled-components';
import ReturnToLogin from '../components/other/ReturnToLogin';
import { formLabels } from '../utils/texts';

export const CantLogin = () => {
return (
<>
<Notification>
<H1>{formLabels.notGrantedAccess}</H1>
<Description>
Jei jungiatės kaip įmonės vadovas ar atstovas, prašome kreiptis el. paštu{' '}
<Link href="mailto:[email protected]">[email protected]</Link>, kad Jums būtų suteikta prieiga.
</Description>
</Notification>
<ReturnToLogin />
</>
);
};

const Description = styled.div`
font-size: 1.6rem;
color: #666;
`;

const H1 = styled.h2`
font-size: 1.5rem;
margin-bottom: 10px;
color: #333;
`;

const Notification = styled.div`
background-color: #f8fafc;
border-radius: 8px;
padding: 16px;
max-width: 400px;
`;

const Link = styled.a`
text-decoration: none;
color: inherit;
`;
1 change: 1 addition & 0 deletions src/utils/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { handleIsTenantOwner, handleIsTenantUser } from './functions';
import { menuLabels, url } from './texts';

export const slugs = {
cantLogin: '/negalima_jungtis',
profile: '/profilis',
tenant: '/imone',
login: '/login',
Expand Down
2 changes: 2 additions & 0 deletions src/utils/texts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export const menuLabels = {
};
export const buttonsTitles = {
download: 'Atsisiųsti',
returnToLogin: 'Grįžti į prisijungimo langą',
or: 'Arba',
eLogin: 'Prisijungti per el. valdžios vartus',
fillOutRequest: 'Pildyti prašymą',
Expand Down Expand Up @@ -262,6 +263,7 @@ export const buttonsTitles = {
};

export const formLabels = {
notGrantedAccess: 'Nesuteikta prieiga',
infoAboutTenant: 'Informacija apie įmonę',
selectProfile: 'Pasirinkite paskyrą',
history: 'Istorija',
Expand Down

0 comments on commit 9bbf6cc

Please sign in to comment.