Skip to content

Commit

Permalink
feat: simultaneous logins modal has been added
Browse files Browse the repository at this point in the history
  • Loading branch information
borkopetrovicc committed Jun 5, 2023
1 parent b28d0a2 commit 06f3679
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/containers/AccountModal/AccountModal.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@
max-width: 50%;
}
}

.title {
margin: 28px 0 28px 0;
font-weight: var(--body-font-weight-bold);
font-size: 19px;
}
5 changes: 4 additions & 1 deletion src/containers/AccountModal/AccountModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ResetPassword from './forms/ResetPassword';
import CancelSubscription from './forms/CancelSubscription';
import RenewSubscription from './forms/RenewSubscription';
import EditPassword from './forms/EditPassword';
import Simultaneouslogins from './forms/Simultaneouslogins';

import { useConfigStore } from '#src/stores/ConfigStore';
import { useAccountStore } from '#src/stores/AccountStore';
Expand All @@ -23,7 +24,7 @@ import Dialog from '#components/Dialog/Dialog';
import { addQueryParam, removeQueryParam } from '#src/utils/location';
import WaitingForPayment from '#src/components/WaitingForPayment/WaitingForPayment';

const PUBLIC_VIEWS = ['login', 'create-account', 'forgot-password', 'reset-password', 'send-confirmation', 'edit-password'];
const PUBLIC_VIEWS = ['login', 'create-account', 'forgot-password', 'reset-password', 'send-confirmation', 'edit-password', 'simultaneous-logins'];

const AccountModal = () => {
const navigate = useNavigate();
Expand Down Expand Up @@ -63,6 +64,8 @@ const AccountModal = () => {
);
}
switch (view) {
case 'simultaneous-logins':
return <Simultaneouslogins />;
case 'login':
return <Login />;
case 'create-account':
Expand Down
23 changes: 23 additions & 0 deletions src/containers/AccountModal/forms/Simultaneouslogins.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { useLocation, useNavigate } from 'react-router';

import styles from '../AccountModal.module.scss';

import Button from '#src/components/Button/Button';
import { addQueryParam } from '#src/utils/location';

const Simultaneouslogins = () => {
const navigate = useNavigate();
const location = useLocation();
function loginClickHandler() {
navigate(addQueryParam(location, 'u', 'login'));
}

return (
<React.Fragment>
<h1 className={styles.title}>You have been logged out beacuse the simultaneous logins limit has been reached.</h1>
<Button type="submit" onClick={loginClickHandler} label="Ok" variant="contained" color="primary" size="large" fullWidth />
</React.Fragment>
);
};
export default Simultaneouslogins;
2 changes: 1 addition & 1 deletion src/stores/NotificationsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const subscribeToNotifications = async (uuid: string = '') => {
break;
case NotificationsTypes.ACCOUNT_LOGOUT:
await getAccount(auth);
// redirect to login page with message
window.location.href = addQueryParams(window.location.href, { u: 'simultaneous-logins' });
break;
case NotificationsTypes.ACCESS_GRANTED:
await reloadActiveSubscription();
Expand Down

0 comments on commit 06f3679

Please sign in to comment.