display current chain

This commit is contained in:
Robert 2024-03-08 21:35:52 +07:00
parent ec92000f2d
commit 1d9666e8e4
No known key found for this signature in database
GPG Key ID: F631C7FD957D5F22

View File

@ -1,22 +1,32 @@
import { redirect } from "@tanstack/react-router";
import { useParams } from "@tanstack/react-router";
import { requireChains } from "@/entities/chain/lib";
import { createFileRoute } from "@tanstack/react-router";
import { useNavigate } from "@tanstack/react-router";
import { useChainState } from "@/entities/chain/model";
import { Typography } from "@mui/material";
import { ChainButtons } from "@/widgets/chain-buttons";
function ChainPage() {
const { selectedChain } = Route.useLoaderData();
const navigate = useNavigate({ from: "/$namespace/$chainId" });
const { chainId } = useParams({ from: "/$namespace/$chainId" });
const chain = useChainState((state) => state.getChain(chainId));
if (!chain) return navigate({ to: "/$namespace" });
return (
<>
<Typography
variant="h4"
sx={{ color: "#4C4E64DE" }}
className="select-none"
>
{selectedChain!.name}
</Typography>
<div key={chain._id} className="flex items-center justify-between">
<Typography
variant="h4"
sx={{ color: "#4C4E64DE" }}
className="select-none"
>
{chain.name}
</Typography>
<ChainButtons chain={chain} />
</div>
</>
);
}
@ -33,6 +43,5 @@ export const Route = createFileRoute("/$namespace/$chainId")({
const selectedChain = chainState.getChain(params.chainId);
if (!selectedChain) throw redirect({ to: "/$namespace", params });
return { selectedChain };
},
});