mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-18 07:37:27 +00:00
fix: normalize search pagination params to avoid [object Object]
This commit is contained in:
@@ -47,7 +47,7 @@ const TokensFilters = ({
|
||||
setFormApi(api);
|
||||
formApiRef.current = api;
|
||||
}}
|
||||
onSubmit={searchTokens}
|
||||
onSubmit={() => searchTokens(1)}
|
||||
allowEmpty={true}
|
||||
autoComplete='off'
|
||||
layout='horizontal'
|
||||
|
||||
@@ -191,6 +191,10 @@ export const useTokensData = (openFluentNotification) => {
|
||||
|
||||
// Search tokens function
|
||||
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();
|
||||
if (searchKeyword === '' && searchToken === '') {
|
||||
setSearchMode(false);
|
||||
@@ -199,7 +203,7 @@ export const useTokensData = (openFluentNotification) => {
|
||||
}
|
||||
setSearching(true);
|
||||
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;
|
||||
if (success) {
|
||||
|
||||
Reference in New Issue
Block a user