otterscan/src/App.tsx

83 lines
2.5 KiB
TypeScript
Raw Normal View History

2021-11-25 09:28:45 +00:00
import React, { Suspense } from "react";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import WarningHeader from "./WarningHeader";
2021-07-01 18:21:40 +00:00
import Home from "./Home";
2021-11-25 09:28:45 +00:00
import Main from "./Main";
import ConnectionErrorPanel from "./ConnectionErrorPanel";
2021-07-10 06:17:07 +00:00
import Footer from "./Footer";
import { ConnectionStatus } from "./types";
2021-07-09 05:07:20 +00:00
import { RuntimeContext, useRuntime } from "./useRuntime";
2021-07-01 18:21:40 +00:00
2021-10-24 04:21:20 +00:00
const Block = React.lazy(
() => import(/* webpackChunkName: "block", webpackPrefetch: true */ "./Block")
);
const BlockTransactions = React.lazy(
() =>
import(
/* webpackChunkName: "blocktxs", webpackPrefetch: true */ "./BlockTransactions"
)
);
const Address = React.lazy(
2021-10-24 04:21:20 +00:00
() =>
import(/* webpackChunkName: "address", webpackPrefetch: true */ "./Address")
2021-10-24 04:21:20 +00:00
);
const Transaction = React.lazy(
() =>
import(/* webpackChunkName: "tx", webpackPrefetch: true */ "./Transaction")
);
const London = React.lazy(
() =>
import(
/* webpackChunkName: "london", webpackPrefetch: true */ "./special/london/London"
)
);
2022-01-31 18:53:25 +00:00
const PageNotFound = React.lazy(
() =>
import(
/* webpackChunkName: "notfound", webpackPrefetch: true */ "./PageNotFound"
)
);
2021-07-01 18:21:40 +00:00
2021-07-08 19:02:42 +00:00
const App = () => {
2021-07-09 05:07:20 +00:00
const runtime = useRuntime();
2021-07-08 19:02:42 +00:00
return (
2021-10-24 04:12:05 +00:00
<Suspense fallback={null}>
{runtime.connStatus !== ConnectionStatus.CONNECTED ? (
<ConnectionErrorPanel
connStatus={runtime.connStatus}
config={runtime.config}
/>
) : (
<RuntimeContext.Provider value={runtime}>
<div className="h-screen flex flex-col">
<WarningHeader />
<Router>
2021-11-25 09:28:45 +00:00
<Routes>
<Route index element={<Home />} />
<Route path="/special/london" element={<London />} />
<Route path="*" element={<Main />}>
<Route path="block/:blockNumberOrHash" element={<Block />} />
<Route
path="block/:blockNumber/txs"
element={<BlockTransactions />}
/>
<Route path="tx/:txhash/*" element={<Transaction />} />
<Route
2021-11-26 06:38:24 +00:00
path="address/:addressOrName/*"
element={<Address />}
2021-11-25 09:28:45 +00:00
/>
2022-01-31 18:53:25 +00:00
<Route path="*" element={<PageNotFound />} />
</Route>
2021-11-25 09:28:45 +00:00
</Routes>
</Router>
<Footer />
</div>
</RuntimeContext.Provider>
)}
2021-07-08 19:02:42 +00:00
</Suspense>
);
};
2021-07-01 18:21:40 +00:00
2021-11-25 09:28:45 +00:00
export default App;