diff --git a/client/src/routes/login.tsx b/client/src/routes/login.tsx index 1cdafb4..4344b20 100644 --- a/client/src/routes/login.tsx +++ b/client/src/routes/login.tsx @@ -1,16 +1,13 @@ import { Link, Navigate } from 'react-router-dom'; import logo from '@assets/images/logo.svg'; -import { useQuery, useQueryClient } from '@tanstack/react-query'; +import { useQuery } from '@tanstack/react-query'; import { useState } from 'react'; import { useCookies } from 'react-cookie'; -import ms from 'ms'; const Login = () => { + const [cookie, setCookie] = useCookies(['token']); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); - const [cookie, setCookie] = useCookies(['token']); - - const queryClient = useQueryClient(); const { refetch } = useQuery( ['login'], @@ -27,7 +24,8 @@ const Login = () => { }, { onSuccess: (data) => { - setCookie('token', data.token, { path: '/', expires: new Date(Date.now() + ms('1d')) }); + setCookie('token', data.token, { path: '/', expires: new Date(data.expiresAt) }); + return ; }, onError: (error) => { console.error(error); @@ -44,7 +42,7 @@ const Login = () => { return ( <> - {cookie.token ? : null} + {cookie.token && }
Groupomania diff --git a/client/src/types/index.d.ts b/client/src/types/index.d.ts new file mode 100644 index 0000000..e69de29