Skip to content

Commit

Permalink
added encode decode
Browse files Browse the repository at this point in the history
  • Loading branch information
paur94 committed Sep 6, 2024
1 parent ebc599f commit f463e51
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions app/[searchParam]/SearchData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export default function SearchData({ searchParam }: { searchParam: string }) {
const basePath = process.env.NEXT_PUBLIC_APP_BASE_PATH

const apiClient = new LayerSwapApiClient()
const decodedSearchParam = decodeURIComponent(searchParam)
const { data, error, isLoading } = useSWR<ApiResponse<SwapData[]>>(`/explorer/${decodedSearchParam}?version=${process.env.NEXT_PUBLIC_API_VERSION}`, apiClient.fetcher, { dedupingInterval: 60000 });
const { data, error, isLoading } = useSWR<ApiResponse<SwapData[]>>(`/explorer/${searchParam}?version=${process.env.NEXT_PUBLIC_API_VERSION}`, apiClient.fetcher, { dedupingInterval: 60000 });

const swap = data?.data?.[0]?.swap
const quote = data?.data?.[0]?.quote
Expand Down
3 changes: 2 additions & 1 deletion app/[searchParam]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import SearchData from "./SearchData";

export default async function Page({ params }: { params: { searchParam: string } }) {

console.log(params.searchParam)
return (
<main className="w-full py-5 px-6 xl:px-0">
<SearchData searchParam={params.searchParam} />
<SearchData searchParam={decodeURIComponent(params.searchParam)} />
</main>
)
}
2 changes: 1 addition & 1 deletion components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Search = () => {

const handleSearch = () => {
const url = getLastPart(searchParam)
router.push(`/${url}`)
router.push(`/${encodeURIComponent(String(url))}`)
}

const clearSearch = () => {
Expand Down

0 comments on commit f463e51

Please sign in to comment.