Skip to content

Commit

Permalink
fixed handle net
Browse files Browse the repository at this point in the history
  • Loading branch information
Monobladegg committed Aug 18, 2024
1 parent 4d7f859 commit 286e83e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 148 deletions.
133 changes: 0 additions & 133 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/pages/Layout/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const PageLayout: FC<Props> = ({ children }) => {
);
}, [accounts, net, setIsAuth]);


const themeLS: string | undefined | null = isWindowDefined
? window.localStorage.getItem("theme")
? window.localStorage.getItem("theme")
Expand Down
3 changes: 1 addition & 2 deletions src/pages/public/account/publicnet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const PublicNet: FC<Props> = ({ id }) => {
* Logic to create an array of strings where item is an accountID
* that is not fake in the home_domain set by the account
*
* example: newAccounts: string[] = ['GCGLKWJX5BPX2BOCOHYA6KUBZ67FR23DAHLG7VD3YRTGEYGZX57KUGFP',
* example: newAccounts: string[] = ['GBR2RQKJY6S5JXKZVJYK6YH5CQXN5KUWQXKQO6G7XK5E5WQ4',
* 'GBEUDKANIFPTFHPWJ5T3R6RIO36RQBFGHYPAQ6STH7KMNDHAT36LHOLD',
* 'GA2T6GR7VXXXBETTERSAFETHANSORRYXXXPROTECTEDBYLOBSTRVAULT']
*/
Expand Down Expand Up @@ -900,7 +900,6 @@ const PublicNet: FC<Props> = ({ id }) => {
</p>
) : (
<span>{errorvalid}</span>

)}
</div>
</div>
Expand Down
29 changes: 16 additions & 13 deletions src/widgets/shared/layouts/Header/ui/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import AccountItem from "./AccountItem";
import { collapseAccount } from "@/pages/public/account/publicnet";

export const Header: FC = () => {

const {
net,
setNet,
Expand Down Expand Up @@ -72,28 +73,30 @@ export const Header: FC = () => {
return () => {
document.removeEventListener("mousedown", handleClickOutside);
};
}, [isOpenAddAccountModal, setIsOpenAddAccountModal]); // Добавляем зависимость
}, [isOpenAddAccountModal, setIsOpenAddAccountModal]);

const toggleDropdownNet = () => setIsOpenNet(!isOpenNet);
const toggleDropdownAccount = () => setIsOpenAccount(!isOpenAccount);

const handleSelectNet = (network: string) => {
setNet(network);
localStorage.setItem("net", network);
localStorage.setItem('net', network);
setIsOpenNet(false);

const currentPath = window.location.pathname;
if (currentPath === "/public" || currentPath === "/testnet") {
const newPath = `/${network}`;
router.push(newPath);
} else if (
currentPath.includes("/public/") ||
currentPath.includes("/testnet/")
) {
// Construct the new path with updated network segment
const newPath = `/${network}`
router.push(newPath);
const currentUrl = new URL(window.location.href);
const pathSegments = currentUrl.pathname.split('/').filter(Boolean);

let newPath: string;

if (pathSegments[0] === 'public' || pathSegments[0] === 'testnet') {
newPath = `/${network}${pathSegments.length > 1 ? '/' + pathSegments.slice(1).join('/') : ''}`;
} else {
newPath = `/${network}${currentUrl.pathname}`;
}

const newUrl = `${newPath}${currentUrl.search}`;

router.push(newUrl);
};

// const handleSelectAccount = (account: IAccount) => {
Expand Down

0 comments on commit 286e83e

Please sign in to comment.