Fix bug and optimized code

This commit is contained in:
2023-10-30 20:50:32 +07:00
parent 23a79657b9
commit c775d6e581
3 changed files with 8 additions and 5 deletions
+3 -2
View File
@@ -28,6 +28,7 @@ import Search from '../../components/Search';
import SortBy from '../../components/SortBy';
import OrderBy from '../../components/OrderBy';
import { useSearchParams } from 'react-router-dom';
import { DEFAULT_ORDER_BY, DEFAULT_SORT_BY } from '../../constants/config';
interface IUserRow {
user: TUser;
@@ -113,10 +114,10 @@ const UserTable = ({
const [users, setUsers] = useState<TUser[]>([]);
const sortByValue = searchParams.get('sortBy')
? searchParams.get('sortBy')!
: '';
: DEFAULT_SORT_BY;
const orderByValue = searchParams.get('orderBy')
? searchParams.get('orderBy')!
: '';
: DEFAULT_ORDER_BY;
const { data, isPending, errorMsg } = useFetch(
'users',