Commit 6ebcb8f7 by Seefs

fix: normalize search pagination params to avoid [object Object]

parent 8dbc5641
...@@ -47,7 +47,7 @@ const TokensFilters = ({ ...@@ -47,7 +47,7 @@ const TokensFilters = ({
setFormApi(api); setFormApi(api);
formApiRef.current = api; formApiRef.current = api;
}} }}
onSubmit={searchTokens} onSubmit={() => searchTokens(1)}
allowEmpty={true} allowEmpty={true}
autoComplete='off' autoComplete='off'
layout='horizontal' layout='horizontal'
......
...@@ -191,6 +191,10 @@ export const useTokensData = (openFluentNotification) => { ...@@ -191,6 +191,10 @@ export const useTokensData = (openFluentNotification) => {
// Search tokens function // Search tokens function
const searchTokens = async (page = 1, size = pageSize) => { const searchTokens = async (page = 1, size = pageSize) => {
const normalizedPage = Number.isInteger(page) && page > 0 ? page : 1;
const normalizedSize =
Number.isInteger(size) && size > 0 ? size : pageSize;
const { searchKeyword, searchToken } = getFormValues(); const { searchKeyword, searchToken } = getFormValues();
if (searchKeyword === '' && searchToken === '') { if (searchKeyword === '' && searchToken === '') {
setSearchMode(false); setSearchMode(false);
...@@ -199,7 +203,7 @@ export const useTokensData = (openFluentNotification) => { ...@@ -199,7 +203,7 @@ export const useTokensData = (openFluentNotification) => {
} }
setSearching(true); setSearching(true);
const res = await API.get( const res = await API.get(
`/api/token/search?keyword=${encodeURIComponent(searchKeyword)}&token=${encodeURIComponent(searchToken)}&p=${page}&size=${size}`, `/api/token/search?keyword=${encodeURIComponent(searchKeyword)}&token=${encodeURIComponent(searchToken)}&p=${normalizedPage}&size=${normalizedSize}`,
); );
const { success, message, data } = res.data; const { success, message, data } = res.data;
if (success) { if (success) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment