Minor api fixes, made useId hook login optional

This commit is contained in:
Dmitriy Shishkov 2023-08-07 14:10:52 +03:00
parent d2a3393a11
commit 2b5a917107
Signed by: dm1sh
GPG Key ID: 027994B0AA357688
4 changed files with 5 additions and 5 deletions

View File

@ -17,7 +17,7 @@ const initialUser: User = import.meta.env.DEV ? { // Temporary, until api is rea
}
const composeUserURL = () => (
API_URL + '/user?'
API_URL + '/users/me?'
)
const processUser = (data: UserResponse): User => {

View File

@ -4,7 +4,7 @@ import { UseFetchReturn } from '../useFetch'
const useUser = (): UseFetchReturn<User> => (
// useFetch(
// composeUserUrl(getToken()),
// composeUserURL(),
// 'GET',
// true,
// isUserResponse,

View File

@ -2,12 +2,12 @@ import { useNavigate } from 'react-router-dom'
import { getId } from '../utils/auth'
function useId() {
function useId(require = false) {
const navigate = useNavigate()
const id = getId()
if (id < 0) {
if (require && id < 0) {
navigate('/login')
}

View File

@ -81,7 +81,7 @@ function useSend<R, T extends NonNullable<unknown>>(
}
if (import.meta.env.DEV) {
console.log(url, params, err)
console.error(url, params, err)
}
}