|
1 | 1 | import AccountLayout from "@layouts/account"; |
2 | 2 | import { getLayout } from "@layouts/main"; |
3 | | -import { getAccount, getGateways, getSortedOrchestrators } from "@lib/api/ssr"; |
4 | | -import { EnsIdentity } from "@lib/api/types/get-ens"; |
5 | | -import { |
6 | | - AccountQueryResult, |
7 | | - getApollo, |
8 | | - OrchestratorsSortedQueryResult, |
9 | | -} from "apollo"; |
10 | 3 |
|
11 | | -type PageProps = { |
12 | | - account: AccountQueryResult["data"]; |
13 | | - sortedOrchestrators: OrchestratorsSortedQueryResult["data"]; |
14 | | - fallback: { [key: string]: EnsIdentity }; |
15 | | -}; |
16 | | - |
17 | | -const BroadcastingPage = ({ account, sortedOrchestrators }: PageProps) => { |
18 | | - return ( |
19 | | - <AccountLayout |
20 | | - sortedOrchestrators={sortedOrchestrators} |
21 | | - account={account} |
22 | | - /> |
23 | | - ); |
24 | | -}; |
| 4 | +const BroadcastingPage = () => <AccountLayout />; |
25 | 5 |
|
26 | 6 | BroadcastingPage.getLayout = getLayout; |
27 | 7 |
|
28 | | -export const getStaticPaths = async () => { |
29 | | - const { gateways } = await getGateways(); |
30 | | - |
31 | | - const paths = |
32 | | - gateways?.data?.gateways?.map((g) => ({ |
33 | | - params: { account: g.id }, |
34 | | - })) ?? []; |
35 | | - |
36 | | - return { |
37 | | - paths, |
38 | | - fallback: "blocking", |
39 | | - }; |
40 | | -}; |
41 | | - |
42 | | -export const getStaticProps = async (context) => { |
43 | | - try { |
44 | | - const client = getApollo(); |
45 | | - const accountId = context.params?.account?.toString().toLowerCase(); |
46 | | - |
47 | | - if (!accountId) { |
48 | | - return { notFound: true }; |
49 | | - } |
50 | | - |
51 | | - const { account, fallback } = await getAccount(client, accountId); |
52 | | - const { sortedOrchestrators, fallback: sortedOrchestratorsFallback } = |
53 | | - await getSortedOrchestrators(client); |
54 | | - |
55 | | - if (!account.data?.gateway || !sortedOrchestrators.data) { |
56 | | - return { notFound: true, revalidate: 300 }; |
57 | | - } |
58 | | - |
59 | | - const props: PageProps = { |
60 | | - account: account.data, |
61 | | - sortedOrchestrators: sortedOrchestrators.data, |
62 | | - fallback: { |
63 | | - ...sortedOrchestratorsFallback, |
64 | | - ...fallback, |
65 | | - }, |
66 | | - }; |
67 | | - |
68 | | - return { |
69 | | - props, |
70 | | - revalidate: 600, |
71 | | - }; |
72 | | - } catch (e) { |
73 | | - console.error(e); |
74 | | - } |
75 | | - |
76 | | - return { |
77 | | - notFound: true, |
78 | | - }; |
79 | | -}; |
80 | | - |
81 | 8 | export default BroadcastingPage; |
0 commit comments