diff --git a/src/components/Auth/index.tsx b/src/components/Auth/index.tsx index 2abf984..46aa64d 100644 --- a/src/components/Auth/index.tsx +++ b/src/components/Auth/index.tsx @@ -30,7 +30,6 @@ export const login = async (credentials: Credentials) => { return firebaseClient.auth().currentUser; } catch (err) { console.log('Login ERROR', err); - alert('Usuário ou senha incorreta.'); } }; @@ -52,7 +51,6 @@ export const signup = async (credentials: Credentials) => { }); } catch (err) { console.log('SIGNUP ERROR', err); - alert('E-mail já cadastrado no sistema.'); } }; diff --git a/src/pages/[username].tsx b/src/pages/[username].tsx index 0f9c751..ce7da2e 100644 --- a/src/pages/[username].tsx +++ b/src/pages/[username].tsx @@ -25,6 +25,10 @@ interface getScheduleInterface { const getSchedule = async (data: getScheduleInterface) => { const { when, username } = data; + if (!username) { + return null; + } + return axios({ method: 'get', url: '/api/schedule', @@ -61,13 +65,13 @@ const Schedule = () => { }) .then(res => { setLoading(false); - setData(res.data); + setData(res?.data); }) - .catch(() => router.push('/')); + .catch(err => console.log(err)); useEffect(() => { refresh(); - }, [when, router.query.username, router]); + }, [when, router.query.username]); return ( @@ -110,7 +114,7 @@ const Schedule = () => { )} - {data.map(({ time, isBlocked }: any) => ( + {data?.map(({ time, isBlocked }: any) => ( { return res.status(200).json(result); } catch (err) { console.log(`Error: ${err}`); - return res.status(401); } };