2020-03-13 18:23:46 +08:00
|
|
|
import React from "react";
|
2020-08-01 23:32:25 +08:00
|
|
|
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";
|
2020-08-01 22:05:58 +08:00
|
|
|
import StatsCard from "components/StatsCard";
|
2020-08-01 23:32:25 +08:00
|
|
|
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
|
|
|
|
2020-08-08 00:38:20 +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">
|
2020-08-01 23:32:25 +08:00
|
|
|
<Navbar />
|
|
|
|
<MessageBanner />
|
|
|
|
<ClusterStatusBanner />
|
2020-08-02 01:46:22 +08:00
|
|
|
<SearchBar />
|
2020-04-29 20:48:38 +08:00
|
|
|
<Switch>
|
2020-08-01 23:32:25 +08:00
|
|
|
<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 />
|
2020-08-01 23:32:25 +08:00
|
|
|
</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
|
2020-08-08 00:38:20 +08:00
|
|
|
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 }) => (
|
2020-08-08 00:38:20 +08:00
|
|
|
<AccountDetails
|
|
|
|
address={match.params.address}
|
|
|
|
tab={match.params.tab}
|
|
|
|
/>
|
2020-05-12 18:32:14 +08:00
|
|
|
)}
|
|
|
|
/>
|
2020-08-01 23:32:25 +08:00
|
|
|
<Route exact path="/">
|
|
|
|
<div className="container mt-4">
|
2020-08-01 22:05:58 +08:00
|
|
|
<StatsCard />
|
2020-08-01 23:32:25 +08:00
|
|
|
</div>
|
2020-08-01 22:05:58 +08:00
|
|
|
</Route>
|
2020-08-01 23:32:25 +08:00
|
|
|
<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;
|