Refactored to use app folder.

This commit is contained in:
Mike Cao 2023-09-29 05:29:22 -07:00
parent 40cfcd41e9
commit 9a52cdd2e1
258 changed files with 2025 additions and 2258 deletions

View file

@ -1,4 +1,3 @@
import { useRouter } from 'next/router';
import * as reactQuery from '@tanstack/react-query';
import { useApi as nextUseApi } from 'next-basics';
import { getClientAuthToken } from 'lib/client';
@ -8,12 +7,11 @@ import useStore from 'store/app';
const selector = state => state.shareToken;
export function useApi() {
const { basePath } = useRouter();
const shareToken = useStore(selector);
const { get, post, put, del } = nextUseApi(
{ authorization: `Bearer ${getClientAuthToken()}`, [SHARE_TOKEN_HEADER]: shareToken?.token },
basePath,
process.env.basePath,
);
return { get, post, put, del, ...reactQuery };