Files
solana/explorer/src/App.tsx

100 lines
3.1 KiB
TypeScript
Raw Normal View History

2020-03-13 18:23:46 +08:00
import React from "react";
import { Link, Switch, Route, Redirect } from "react-router-dom";
2020-03-19 20:43:53 +08:00
2020-03-31 21:58:48 +08:00
import AccountsCard from "./components/AccountsCard";
2020-05-12 18:32:14 +08:00
import AccountDetails from "./components/AccountDetails";
import TransactionsCard from "./components/TransactionsCard";
2020-04-29 20:48:38 +08:00
import TransactionDetails from "./components/TransactionDetails";
2020-03-31 14:36:40 +08:00
import ClusterModal from "./components/ClusterModal";
import Logo from "./img/logos-solana/light-explorer-logo.svg";
2020-04-29 20:48:38 +08:00
import { TX_ALIASES } from "./providers/transactions";
2020-05-12 18:32:14 +08:00
import { ACCOUNT_ALIASES, ACCOUNT_ALIASES_PLURAL } from "./providers/accounts";
2020-04-29 20:48:38 +08:00
import TabbedPage from "components/TabbedPage";
2020-05-23 15:17:07 +08:00
import TopAccountsCard from "components/TopAccountsCard";
2020-05-23 03:09:28 +08:00
import SupplyCard from "components/SupplyCard";
import StatsCard from "components/StatsCard";
import { pickCluster } from "utils/url";
import Banner from "components/Banner";
2020-03-13 17:07:58 +08:00
function App() {
return (
2020-04-24 20:11:30 +08:00
<>
2020-04-29 20:48:38 +08:00
<ClusterModal />
2020-04-24 20:11:30 +08:00
<div className="main-content">
<nav className="navbar navbar-expand-xl navbar-light">
<div className="container">
<div className="row align-items-end">
<div className="col">
<Link
2020-06-24 16:07:47 +08:00
to={(location) => ({
...pickCluster(location),
pathname: "/",
})}
>
2020-04-29 20:48:38 +08:00
<img src={Logo} width="250" alt="Solana Explorer" />
</Link>
2020-04-24 20:11:30 +08:00
</div>
</div>
</div>
</nav>
<Banner />
2020-04-29 20:48:38 +08:00
<Switch>
2020-05-23 03:09:28 +08:00
<Route exact path="/supply">
<TabbedPage tab="Supply">
<SupplyCard />
2020-05-23 15:17:07 +08:00
<TopAccountsCard />
</TabbedPage>
</Route>
<Route
exact
path="/accounts/top"
render={({ location }) => (
<Redirect to={{ ...location, pathname: "/supply" }} />
)}
></Route>
2020-04-29 20:48:38 +08:00
<Route
exact
2020-06-24 16:07:47 +08:00
path={TX_ALIASES.flatMap((tx) => [tx, tx + "s"]).map(
(tx) => `/${tx}/:signature`
2020-05-03 12:07:51 +08:00
)}
2020-04-29 20:48:38 +08:00
render={({ match }) => (
<TransactionDetails signature={match.params.signature} />
)}
/>
2020-06-24 16:07:47 +08:00
<Route exact path={TX_ALIASES.map((tx) => `/${tx}s`)}>
2020-04-29 20:48:38 +08:00
<TabbedPage tab="Transactions">
<TransactionsCard />
2020-04-29 20:48:38 +08:00
</TabbedPage>
</Route>
2020-05-12 18:32:14 +08:00
<Route
exact
path={ACCOUNT_ALIASES.concat(ACCOUNT_ALIASES_PLURAL).map(
2020-06-24 16:07:47 +08:00
(account) => `/${account}/:address`
2020-05-12 18:32:14 +08:00
)}
render={({ match }) => (
<AccountDetails address={match.params.address} />
)}
/>
2020-06-24 16:07:47 +08:00
<Route
exact
path={ACCOUNT_ALIASES_PLURAL.map((alias) => "/" + alias)}
>
2020-04-29 20:48:38 +08:00
<TabbedPage tab="Accounts">
<AccountsCard />
2020-04-29 20:48:38 +08:00
</TabbedPage>
</Route>
<Route>
<TabbedPage tab="Stats">
<StatsCard />
</TabbedPage>
</Route>
2020-04-29 20:48:38 +08:00
</Switch>
2020-04-24 20:11:30 +08:00
</div>
</>
2020-03-13 17:07:58 +08:00
);
}
export default App;