enzostvs HF Staff commited on
Commit
be213e2
·
1 Parent(s): 63fef5b

check the error in prod

Browse files
Files changed (2) hide show
  1. components/login/index.tsx +4 -1
  2. utils/useUser.ts +4 -1
components/login/index.tsx CHANGED
@@ -10,7 +10,7 @@ import classNames from "classnames";
10
  import { HiCheckBadge } from "react-icons/hi2";
11
 
12
  export const Login = ({ code }: { code?: string }) => {
13
- const { getAuthorization, user } = useUser();
14
 
15
  useMount(() => getAuthorization(code as string));
16
 
@@ -52,6 +52,9 @@ export const Login = ({ code }: { code?: string }) => {
52
  <FaUserAstronaut className="w-full h-full text-indigo-500" />
53
  </div>
54
  </div>
 
 
 
55
  </div>
56
  </div>
57
  );
 
10
  import { HiCheckBadge } from "react-icons/hi2";
11
 
12
  export const Login = ({ code }: { code?: string }) => {
13
+ const { getAuthorization, user, error } = useUser();
14
 
15
  useMount(() => getAuthorization(code as string));
16
 
 
52
  <FaUserAstronaut className="w-full h-full text-indigo-500" />
53
  </div>
54
  </div>
55
+ {error && (
56
+ <p className="text-black text-sm">{JSON.stringify(error, null, 2)}</p>
57
+ )}
58
  </div>
59
  </div>
60
  );
utils/useUser.ts CHANGED
@@ -2,9 +2,11 @@
2
 
3
  import { useCookie, useUpdateEffect } from "react-use";
4
  import { useQuery } from "@tanstack/react-query";
 
5
 
6
  export const useUser = () => {
7
  const [value, setValue, remove] = useCookie("auth_hf_token");
 
8
 
9
  const {
10
  data: user,
@@ -63,7 +65,7 @@ export const useUser = () => {
63
  });
64
  const res = await request.clone().json().catch(() => ({}));
65
  if (!res.ok) {
66
- console.log(res);
67
  return null;
68
  }
69
  setValue(res.access_token, {
@@ -82,6 +84,7 @@ export const useUser = () => {
82
  refetch,
83
  loading,
84
  token: `Bearer ${value}`,
 
85
  getAuthorization
86
  }
87
  }
 
2
 
3
  import { useCookie, useUpdateEffect } from "react-use";
4
  import { useQuery } from "@tanstack/react-query";
5
+ import { useState } from "react";
6
 
7
  export const useUser = () => {
8
  const [value, setValue, remove] = useCookie("auth_hf_token");
9
+ const [error, setError] = useState(null);
10
 
11
  const {
12
  data: user,
 
65
  });
66
  const res = await request.clone().json().catch(() => ({}));
67
  if (!res.ok) {
68
+ setError(res);
69
  return null;
70
  }
71
  setValue(res.access_token, {
 
84
  refetch,
85
  loading,
86
  token: `Bearer ${value}`,
87
+ error,
88
  getAuthorization
89
  }
90
  }