mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
enforce default value on sortBy filter
This commit is contained in:
@@ -2,14 +2,14 @@ import { parseAsString, useQueryState } from 'nuqs';
|
|||||||
|
|
||||||
import { FILTER_KEYS } from '/@/renderer/features/shared/utils';
|
import { FILTER_KEYS } from '/@/renderer/features/shared/utils';
|
||||||
|
|
||||||
export const useSortByFilter = <TSortBy>(defaultValue?: string) => {
|
export const useSortByFilter = <TSortBy>(defaultValue: string) => {
|
||||||
const [sortBy, setSortBy] = useQueryState(
|
const [sortBy, setSortBy] = useQueryState(
|
||||||
FILTER_KEYS.SHARED.SORT_BY,
|
FILTER_KEYS.SHARED.SORT_BY,
|
||||||
defaultValue ? parseAsString.withDefault(defaultValue) : parseAsString,
|
defaultValue ? parseAsString.withDefault(defaultValue) : parseAsString,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
[FILTER_KEYS.SHARED.SORT_BY]: (sortBy as TSortBy) ?? undefined,
|
[FILTER_KEYS.SHARED.SORT_BY]: sortBy as TSortBy,
|
||||||
setSortBy,
|
setSortBy,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user