Refactored useApi usage.

This commit is contained in:
Mike Cao 2022-12-27 20:20:44 -08:00
parent 561cde6e7e
commit cad0b73e42
26 changed files with 67 additions and 85 deletions

View file

@ -1,8 +1,8 @@
import { useQuery } from '@tanstack/react-query';
import EmptyPlaceholder from 'components/common/EmptyPlaceholder';
import { formatDistance } from 'date-fns';
import { getAuthToken } from 'lib/client';
import { useApi } from 'next-basics';
import { getClientAuthToken } from 'lib/client';
import useApi from 'hooks/useApi';
import Link from 'next/link';
import { useEffect, useState } from 'react';
import {
@ -26,7 +26,7 @@ const defaultColumns = [
export default function UsersTable({ columns = defaultColumns, onLoading, onAddKeyClick }) {
const [values, setValues] = useState(null);
const { get } = useApi(getAuthToken());
const { get } = useApi(getClientAuthToken());
const { data, isLoading, error } = useQuery(['user'], () => get(`/users`));
const hasData = data && data.length !== 0;