diff --git a/src/app/search/_components/Result/Result.type.ts b/src/app/search/_components/Result/Result.type.ts index 5434582..f48361a 100644 --- a/src/app/search/_components/Result/Result.type.ts +++ b/src/app/search/_components/Result/Result.type.ts @@ -1,8 +1,4 @@ -import { SwapType } from 'src/types'; - export interface PropsType { - data: SwapType[]; query: string; - total: number; page: number; } diff --git a/src/app/search/_components/Result/index.tsx b/src/app/search/_components/Result/index.tsx index bd0bc8d..e397c74 100644 --- a/src/app/search/_components/Result/index.tsx +++ b/src/app/search/_components/Result/index.tsx @@ -1,9 +1,24 @@ import { PropsType } from './Result.type'; import Pagination from '../Pagination'; import Table from 'src/components/common/Table'; +import { getWalletSwaps } from 'src/services'; +import { notFound } from 'next/navigation'; + +async function Result(props: PropsType) { + const { query, page } = props; + + await new Promise((res) => + setTimeout(() => { + res(5); + }, 5000), + ); + const data = await getWalletSwaps(query, page); + const { transactions, total } = data || {}; + + if (!data || !transactions?.length) { + notFound(); + } -function Result(props: PropsType) { - const { data, query, total, page } = props; return (
@@ -16,7 +31,7 @@ function Result(props: PropsType) {

- +
diff --git a/src/app/search/page.tsx b/src/app/search/page.tsx index 663d954..547b210 100644 --- a/src/app/search/page.tsx +++ b/src/app/search/page.tsx @@ -1,7 +1,9 @@ import { MATCH_TYPE } from 'src/constant'; import { notFound, redirect } from 'next/navigation'; -import { getSearchResult, getWalletSwaps } from 'src/services'; +import { getSearchResult } from 'src/services'; import Result from './_components/Result'; +import TableLoading from 'src/components/common/Table/TableLoading'; +import { Suspense } from 'react'; export async function generateMetadata({ searchParams, @@ -38,21 +40,11 @@ const Page = async ({ if (requestId) redirect(`/swap/${requestId}`); } - const data = await getWalletSwaps(query, page); - const { transactions, total } = data || {}; - - if (!data || !transactions?.length) { - notFound(); - } - return (
- + }> + +
); }; diff --git a/src/components/common/Skeleton/Skeleton.types.ts b/src/components/common/Skeleton/Skeleton.types.ts new file mode 100644 index 0000000..09c472e --- /dev/null +++ b/src/components/common/Skeleton/Skeleton.types.ts @@ -0,0 +1,6 @@ +export type PropTypes = { + width?: number; + height?: number; + variant?: 'circular' | 'rectangular'; + className?: string; +}; diff --git a/src/components/common/Skeleton/index.tsx b/src/components/common/Skeleton/index.tsx new file mode 100644 index 0000000..6eaef89 --- /dev/null +++ b/src/components/common/Skeleton/index.tsx @@ -0,0 +1,18 @@ +import type { PropTypes } from './Skeleton.types'; + +export function Skeleton(props: PropTypes) { + const { height, width, variant = 'rectangular', className = '' } = props; + return ( +
+ ); +} diff --git a/src/components/common/Table/TableLoading.tsx b/src/components/common/Table/TableLoading.tsx new file mode 100644 index 0000000..332184b --- /dev/null +++ b/src/components/common/Table/TableLoading.tsx @@ -0,0 +1,135 @@ +import { useId } from 'react'; +import TableHead from './TableHead'; +import { Skeleton } from '../Skeleton'; +import Link from 'next/link'; + +function TableLoading() { + const id = useId(); + return ( +
+
+
+

+ Search Results +

+
+ +
+
+
+
+ +
+ {Array.from({ length: 14 }, () => { + return ( +
+
+
+ Request ID +
+ + +
+
+
+ + +
+
+ + +
+
+
+
+
+ + +
+
+ + +
+
+
+
+ Amount +
+ + +
+
+
+ Status +
+ + +
+ + Detail + +
+ ); + })} +
+
+
+
+
+ + + + + + + +
+
+
+
+ ); +} + +export default TableLoading; diff --git a/src/services/index.ts b/src/services/index.ts index 12bb0d9..4eb8edb 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -33,7 +33,7 @@ export const getSearchResult = async (query: string) => .then(async (res) => await res.json()) .then((data) => data?.searchResult || data); -export const getWalletSwaps = async (address: string, page?: string) => +export const getWalletSwaps = async (address: string, page?: number) => await fetch( `${API_URL}/scanner/tx/wallet?walletAddress=${address}&offset=${SEARCH_RESULT_OFFSET}&page=${ page || 0