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

@@ -9,9 +9,9 @@ import {
Icon,
} from 'react-basics';
import { useRouter } from 'next/router';
import { useApi } from 'next-basics';
import useApi from 'hooks/useApi';
import { setUser } from 'store/app';
import { setAuthToken } from 'lib/client';
import { setClientAuthToken } from 'lib/client';
import Logo from 'assets/logo.svg';
import styles from './Form.module.css';
@@ -23,7 +23,7 @@ export default function LoginForm() {
const handleSubmit = async data => {
mutate(data, {
onSuccess: async ({ token, user }) => {
setAuthToken(token);
setClientAuthToken(token);
setUser(user);
await router.push('/websites');