Files
solana/explorer/src/App.tsx

84 lines
2.6 KiB
TypeScript
Raw Normal View History

2020-03-13 18:23:46 +08:00
import React from "react";
import { Switch, Route, Redirect } from "react-router-dom";
2020-03-19 20:43:53 +08:00
2020-05-12 18:32:14 +08:00
import AccountDetails from "./components/AccountDetails";
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";
2020-04-29 20:48:38 +08:00
import { TX_ALIASES } from "./providers/transactions";
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 MessageBanner from "components/MessageBanner";
import Navbar from "components/Navbar";
import { ClusterStatusBanner } from "components/ClusterStatusButton";
2020-08-02 01:46:22 +08:00
import { SearchBar } from "components/SearchBar";
2020-03-13 17:07:58 +08:00
const ACCOUNT_ALIASES = ["account", "accounts", "addresses"];
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">
<Navbar />
<MessageBanner />
<ClusterStatusBanner />
2020-08-02 01:46:22 +08:00
<SearchBar />
2020-04-29 20:48:38 +08:00
<Switch>
<Route exact path={["/supply", "/accounts", "accounts/top"]}>
<div className="container mt-4">
2020-05-23 03:09:28 +08:00
<SupplyCard />
2020-05-23 15:17:07 +08:00
<TopAccountsCard />
</div>
2020-05-23 15:17:07 +08:00
</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-05-12 18:32:14 +08:00
<Route
exact
path={ACCOUNT_ALIASES.flatMap((account) => [
`/${account}/:address`,
`/${account}/:address/:tab`,
])}
render={({ match, location }) => {
let pathname = `/address/${match.params.address}`;
if (match.params.tab) {
pathname += `/${match.params.tab}`;
}
return <Redirect to={{ ...location, pathname }} />;
}}
/>
<Route
exact
path={["/address/:address", "/address/:address/:tab"]}
2020-05-12 18:32:14 +08:00
render={({ match }) => (
<AccountDetails
address={match.params.address}
tab={match.params.tab}
/>
2020-05-12 18:32:14 +08:00
)}
/>
<Route exact path="/">
<div className="container mt-4">
<StatsCard />
</div>
</Route>
<Route
render={({ location }) => (
<Redirect to={{ ...location, pathname: "/" }} />
)}
/>
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;