Skip to content

Commit

Permalink
feat: update logic for navigation from account screen using back brea…
Browse files Browse the repository at this point in the history
…dcrumb
  • Loading branch information
akhlopiachyi committed Jan 18, 2024
1 parent 6c77f95 commit e0d7954
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion apps/web-coreum/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web-coreum",
"version": "2.19.3-70",
"version": "2.19.3-71",
"license": "Apache-2.0",
"private": true,
"scripts": {
Expand Down
36 changes: 28 additions & 8 deletions packages/ui/src/screens/account_details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,33 @@ import Staking from '@/screens/account_details/components/staking';
import Transactions from '@/screens/account_details/components/transactions';
import { useAccountDetails } from '@/screens/account_details/hooks';
import useStyles from '@/screens/account_details/styles';
import Link from 'next/link';
import { useRouter } from 'next/router';
import { useCallback, useEffect, useState } from 'react';

const AccountDetails = () => {
export default function AccountDetails() {
const { t } = useTranslation('accounts');
const { classes } = useStyles();
const { state } = useAccountDetails();
const router = useRouter();
const [previousRouteDefined, setPreviousRouteDefined] = useState<boolean>(false);

useEffect(() => {
Object.keys((router as any).components).forEach((key) => {
const parsedKey = key.replace('_', '');

if (parsedKey !== router.pathname && parsedKey !== '/app') {
setPreviousRouteDefined(true);
}
});
}, []);

const goBack = useCallback(() => {
if (previousRouteDefined) {
router.back();
} else {
router.push('/');
}
}, [router, previousRouteDefined]);

return (
<>
Expand All @@ -39,7 +60,8 @@ const AccountDetails = () => {
/>
)}
<div className={classes.block}>
<Link href="/transactions" className={classes.breadcrumb}>
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
<div onClick={goBack} className={classes.breadcrumb}>
<svg
width="16"
height="17"
Expand All @@ -49,8 +71,8 @@ const AccountDetails = () => {
>
<path d="M10.5 13.5L5.5 8.5L10.5 3.5" stroke="#25D695" strokeWidth="1.5" />
</svg>
Back to all transactions
</Link>
Back
</div>
<div className={classes.title}>{t('accountDetails')}</div>
</div>
<Overview
Expand All @@ -75,6 +97,4 @@ const AccountDetails = () => {
</Layout>
</>
);
};

export default AccountDetails;
}

0 comments on commit e0d7954

Please sign in to comment.