display current chain
This commit is contained in:
parent
ec92000f2d
commit
1d9666e8e4
|
|
@ -1,22 +1,32 @@
|
||||||
import { redirect } from "@tanstack/react-router";
|
import { redirect } from "@tanstack/react-router";
|
||||||
|
import { useParams } from "@tanstack/react-router";
|
||||||
import { requireChains } from "@/entities/chain/lib";
|
import { requireChains } from "@/entities/chain/lib";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
|
||||||
import { useChainState } from "@/entities/chain/model";
|
import { useChainState } from "@/entities/chain/model";
|
||||||
import { Typography } from "@mui/material";
|
import { Typography } from "@mui/material";
|
||||||
|
import { ChainButtons } from "@/widgets/chain-buttons";
|
||||||
|
|
||||||
function ChainPage() {
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<div key={chain._id} className="flex items-center justify-between">
|
||||||
<Typography
|
<Typography
|
||||||
variant="h4"
|
variant="h4"
|
||||||
sx={{ color: "#4C4E64DE" }}
|
sx={{ color: "#4C4E64DE" }}
|
||||||
className="select-none"
|
className="select-none"
|
||||||
>
|
>
|
||||||
{selectedChain!.name}
|
{chain.name}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
|
<ChainButtons chain={chain} />
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -33,6 +43,5 @@ export const Route = createFileRoute("/$namespace/$chainId")({
|
||||||
|
|
||||||
const selectedChain = chainState.getChain(params.chainId);
|
const selectedChain = chainState.getChain(params.chainId);
|
||||||
if (!selectedChain) throw redirect({ to: "/$namespace", params });
|
if (!selectedChain) throw redirect({ to: "/$namespace", params });
|
||||||
return { selectedChain };
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user