add useeffect app for return

This commit is contained in:
Alexandre POMMIER 2023-06-26 02:27:43 +02:00
parent 4151350162
commit 152d0541d4
3 changed files with 6 additions and 6 deletions

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/17 01:00:00 by apommier #+# #+# */ /* Created: 2023/06/17 01:00:00 by apommier #+# #+# */
/* Updated: 2023/06/26 00:47:07 by apommier ### ########.fr */ /* Updated: 2023/06/26 02:23:56 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -451,7 +451,7 @@ export class AppController {
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('/quit') @Post('/quit')
async setOffline(@Request() req) { async setOffline(@Request() req) {
console.log("cc quit here");
const user = await this.userService.findOne(req.user.username); const user = await this.userService.findOne(req.user.username);
user.status = 0; user.status = 0;

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/17 01:00:25 by apommier #+# #+# */ /* Created: 2023/06/17 01:00:25 by apommier #+# #+# */
/* Updated: 2023/06/24 18:47:59 by apommier ### ########.fr */ /* Updated: 2023/06/26 02:07:45 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -19,20 +19,20 @@ import DoubleAuth from "../pages/2fa.tsx";
import Game from "../pages/Game.tsx"; import Game from "../pages/Game.tsx";
import Social from "./Social/Social.tsx"; import Social from "./Social/Social.tsx";
import Logout from "./Profile/Logout.tsx"; import Logout from "./Profile/Logout.tsx";
import api from "../script/axiosApi.tsx"
function AnimatedRoute () { function AnimatedRoute () {
// const location = useLocation(); // const location = useLocation();
useEffect(() => { useEffect(() => {
const handleBeforeUnload = (event: { preventDefault: () => void; returnValue: string; }) => { const handleBeforeUnload = async (event: { preventDefault: () => void; returnValue: string; }) => {
event.preventDefault(); // Cancel the default event behavior if needed event.preventDefault(); // Cancel the default event behavior if needed
event.returnValue = ''; // Chrome requires a return value to display a custom message event.returnValue = ''; // Chrome requires a return value to display a custom message
if (!localStorage.getItem('token')) if (!localStorage.getItem('token'))
return ; return ;
try { try {
await api.post("/quit");
} catch(err) { } catch(err) {
console.log(err); console.log(err);
} }