Skip to content

Commit

Permalink
Merge pull request #102 from yauheni-deriv/evgeniy/88400/account_clos…
Browse files Browse the repository at this point in the history
…ed_ts_migration

evgeniy/ 88400/ account_closed ts migration
  • Loading branch information
niloofar-deriv committed Mar 28, 2023
2 parents 923a801 + 7559c04 commit 8543e2e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
1 change: 1 addition & 0 deletions packages/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@deriv/api-types": "^1.0.11",
"@deriv/components": "^1.0.0",
"@deriv/shared": "^1.0.0",
"@deriv/stores": "^1.0.0",
"@deriv/translations": "^1.0.0",
"bowser": "^2.9.0",
"classnames": "^2.2.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import React from 'react';
import { useHistory } from 'react-router-dom';
import { Modal, Text } from '@deriv/components';
import { routes, getStaticUrl, PlatformContext } from '@deriv/shared';
import { Localize } from '@deriv/translations';
import { getStaticUrl, PlatformContext } from '@deriv/shared';
import { connect } from 'Stores/connect';
import type { TRootStore } from '@deriv/stores/types';

const AccountClosed = ({ logout }) => {
type TAccountClosed = {
logout: () => void;
};

const AccountClosed = ({ logout }: TAccountClosed) => {
const [is_modal_open, setModalState] = React.useState(true);
const [timer, setTimer] = React.useState(10);
const { is_appstore } = React.useContext(PlatformContext);

React.useEffect(() => {
window.history.pushState(null, null, '/');
logout();
const handleInterval = setInterval(() => counter(), 1000);
return () => {
if (handleInterval) clearInterval(handleInterval);
};
}, [timer, is_modal_open, logout, counter]);
const history = useHistory();

const counter = React.useCallback(() => {
if (timer > 0) {
Expand All @@ -26,6 +24,15 @@ const AccountClosed = ({ logout }) => {
}
}, [is_appstore, timer]);

React.useEffect(() => {
history.push(routes.root);
logout();
const handleInterval = setInterval(() => counter(), 1000);
return () => {
if (handleInterval) clearInterval(handleInterval);
};
}, [timer, is_modal_open, logout, counter]);

return (
<Modal
is_open={is_modal_open}
Expand All @@ -40,6 +47,6 @@ const AccountClosed = ({ logout }) => {
);
};

export default connect(({ client }) => ({
export default connect(({ client }: TRootStore) => ({
logout: client.logout,
}))(AccountClosed);
3 changes: 0 additions & 3 deletions packages/account/src/Sections/Security/AccountClosed/index.js

This file was deleted.

3 changes: 3 additions & 0 deletions packages/account/src/Sections/Security/AccountClosed/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import AccountClosed from './account-closed';

export default AccountClosed;

0 comments on commit 8543e2e

Please sign in to comment.