This commit is contained in:
@@ -1,29 +1,29 @@
|
||||
type BuildListQueryOptions = {
|
||||
q?: string;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
sort?: string;
|
||||
defaultSort: string;
|
||||
q?: string;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
sort?: string;
|
||||
defaultSort: string;
|
||||
};
|
||||
|
||||
export function buildListQuery({
|
||||
q,
|
||||
page = 1,
|
||||
pageSize = 10,
|
||||
sort,
|
||||
defaultSort,
|
||||
q,
|
||||
page = 1,
|
||||
pageSize = 10,
|
||||
sort,
|
||||
defaultSort,
|
||||
}: BuildListQueryOptions): string {
|
||||
const query = new URLSearchParams();
|
||||
const normalizedQuery = q?.trim();
|
||||
const normalizedSort = sort?.trim();
|
||||
const query = new URLSearchParams();
|
||||
const normalizedQuery = q?.trim();
|
||||
const normalizedSort = sort?.trim();
|
||||
|
||||
if (normalizedQuery) {
|
||||
query.set('q', normalizedQuery);
|
||||
}
|
||||
if (normalizedQuery) {
|
||||
query.set('q', normalizedQuery);
|
||||
}
|
||||
|
||||
query.set('page', String(page));
|
||||
query.set('pageSize', String(pageSize));
|
||||
query.set('sort', normalizedSort || defaultSort);
|
||||
query.set('page', String(page));
|
||||
query.set('pageSize', String(pageSize));
|
||||
query.set('sort', normalizedSort || defaultSort);
|
||||
|
||||
return query.toString();
|
||||
return query.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user