Skip to content

Commit

Permalink
fix(front): quando o usuário faz logout e tem grades no cloud essas n…
Browse files Browse the repository at this point in the history
…ão ficam mais no buffer (#170)

* fix(front): clean cloud schedules when logout

* web(front): change loading screen source
  • Loading branch information
mateusvrs authored Dec 12, 2023
1 parent 2f2a895 commit 21b2dbf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
9 changes: 9 additions & 0 deletions web/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
'use client';

import Link from 'next/link';

import SignInSection from './components/SignInSection';
import LogoImageHandler from './components/LogoImageHandler';
import { LoadingScreen } from './components/LoadingScreen';

import useUser from './hooks/useUser';

export default function Welcome() {
const { isLoading } = useUser();

if (isLoading) return <LoadingScreen />;

return (
<main className='flex flex-col flat:flex-row justify-center items-center gap-8 text-white p-8 h-screen w-screen bg-primary'>
<LogoImageHandler />
Expand Down
4 changes: 0 additions & 4 deletions web/app/schedules/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Image from 'next/image';

import AsideButton from '../components/AsideButton';
import Protected from '../components/Protected';
import { LoadingScreen } from '../components/LoadingScreen';
import InfoHeader from '../components/InfoHeader';

import homeIcon from '@/public/icons/home.jpg';
Expand Down Expand Up @@ -100,9 +99,6 @@ function AsideButtonsJSX() {

function LayoutJSX({ children }: { children: React.ReactNode }) {
const { breakHeighPoint } = useWindowDimensions();
const { isLoading } = useUser();

if (isLoading) return <LoadingScreen />;

return (
<>
Expand Down
3 changes: 2 additions & 1 deletion web/app/schedules/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function Profile() {

const { setClassesToShow } = useClassesToShow();
const { setSelectedClasses } = useSelectedClasses();
const { localSchedules, setLocalSchedules } = useSchedules();
const { localSchedules, setLocalSchedules, setCloudSchedules } = useSchedules();

const userContext = useUser();
const { user } = userContext;
Expand All @@ -33,6 +33,7 @@ export default function Profile() {
setClassesToShow(new Array());
setSelectedClasses(new Map());
setLocalSchedules(new Array(), false);
setCloudSchedules(new Array());
handleLogout({ userContext, router });
}

Expand Down
5 changes: 3 additions & 2 deletions web/app/utils/api/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ export default function handleLogout({
request.post('/users/logout/', {}, settings).then(response => {
if (response.status == 200) {
setUser(defaultUser);
router.replace('/');
router.push('/');
}
}).catch(error => toast.error('Não foi possível sair!'));
}
else router.replace('/');
else router.push('/');
router.refresh();
}

0 comments on commit 21b2dbf

Please sign in to comment.