Skip to content

Commit

Permalink
IPFS hosting adaptation
Browse files Browse the repository at this point in the history
  • Loading branch information
JayJay1024 committed Dec 19, 2023
1 parent 4354ddd commit a090be9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
4 changes: 4 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "export",
images: {
unoptimized: true,
},
webpack: (config) => {
config.externals.push("lokijs", "encoding", "pino-pretty");
return config;
Expand Down
File renamed without changes.
10 changes: 2 additions & 8 deletions src/app/records/[id]/page.tsx → src/app/record/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@ export const metadata: Metadata = {
description: "View Helix Bridge transfer details",
};

interface Props {
params: {
id: string;
};
}

export default function RecordPage({ params }: Props) {
export default function RecordPage() {
return (
<PageWrap>
<RecordDetail id={params.id} />
<RecordDetail />
</PageWrap>
);
}
5 changes: 2 additions & 3 deletions src/components/history-records.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useApp } from "@/hooks";
import { HistoryRecordsReqParams, HistoryRecordsResData, RecordResult, UrlSearchParamKey } from "@/types";
import Tabs, { TabsProps } from "@/ui/tabs";
import { NetworkStatus, useQuery } from "@apollo/client";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useRouter, useSearchParams } from "next/navigation";
import { useDeferredValue, useEffect, useState } from "react";
import RecordsTable from "./records-table";
import Search from "@/ui/search";
Expand All @@ -24,7 +24,6 @@ export default function HistoryRecords() {
const deferredSearchValue = useDeferredValue(recordsSearch);

const searchParams = useSearchParams();
const pathName = usePathname();
const router = useRouter();

const [activeKey, setActiveKey] = useState<TabsProps<TabKey>["activeKey"]>(AllResult.All);
Expand Down Expand Up @@ -86,7 +85,7 @@ export default function HistoryRecords() {
params.set(UrlSearchParamKey.PAGE, (page + 1).toString());
router.push(`?${params.toString()}`);
}}
onRowClick={(_, { id }) => router.push(`${pathName}/${id}`)}
onRowClick={(_, { id }) => router.push(`record?${UrlSearchParamKey.ID}=${id}`)}
/>
);

Expand Down
18 changes: 11 additions & 7 deletions src/components/record-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import { BaseBridge } from "@/bridges";
import { GQL_HISTORY_RECORD_BY_ID } from "@/config";
import { HistoryRecordReqParams, HistoryRecordResData } from "@/types";
import { HistoryRecordReqParams, HistoryRecordResData, UrlSearchParamKey } from "@/types";
import ComponentLoading from "@/ui/component-loading";
import CountdownRefresh from "@/ui/countdown-refresh";
import { bridgeFactory, getChainConfig } from "@/utils";
import { useQuery } from "@apollo/client";
import { PropsWithChildren, useMemo } from "react";
import { PropsWithChildren, useEffect, useMemo, useState } from "react";
import TransferRoute from "./transfer-route";
import TransactionStatus from "./transaction-status";
import { TransactionHash } from "./transaction-hash";
Expand All @@ -19,18 +19,17 @@ import TransactionValue from "./transaction-value";
import TransactionFee from "./transaction-fee";
import { RecordItemTitle } from "@/ui/record-item-title";

interface Props {
id: string;
}
export default function RecordDetail() {
const [id, setId] = useState("");

export default function RecordDetail(props: Props) {
const {
loading,
data: record,
refetch,
} = useQuery<HistoryRecordResData, HistoryRecordReqParams>(GQL_HISTORY_RECORD_BY_ID, {
variables: { id: props.id },
variables: { id },
notifyOnNetworkStatusChange: true,
skip: !id.length,
});

const bridgeInstance = useMemo<BaseBridge | undefined>(() => {
Expand All @@ -46,6 +45,11 @@ export default function RecordDetail(props: Props) {
return undefined;
}, [record?.historyRecordById]);

useEffect(() => {
const id = new URLSearchParams(window.location.search).get(UrlSearchParamKey.ID);
setId((prev) => id ?? prev);
}, []);

return (
<>
<div className="flex items-center justify-between gap-5">
Expand Down
1 change: 1 addition & 0 deletions src/types/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export enum UrlSearchParamKey {
TARGET_CHAIN = "target_chain",
SOURCE_TOKEN = "source_token",
TARGET_TOKEN = "target_token",
ID = "id",
}

0 comments on commit a090be9

Please sign in to comment.