add useeffect app for return
This commit is contained in:
parent
4151350162
commit
152d0541d4
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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)
|
||||
@Post('/quit')
|
||||
async setOffline(@Request() req) {
|
||||
|
||||
console.log("cc quit here");
|
||||
const user = await this.userService.findOne(req.user.username);
|
||||
|
||||
user.status = 0;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
@ -19,20 +19,20 @@ import DoubleAuth from "../pages/2fa.tsx";
|
||||
import Game from "../pages/Game.tsx";
|
||||
import Social from "./Social/Social.tsx";
|
||||
import Logout from "./Profile/Logout.tsx";
|
||||
|
||||
import api from "../script/axiosApi.tsx"
|
||||
|
||||
|
||||
function AnimatedRoute () {
|
||||
// const location = useLocation();
|
||||
|
||||
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.returnValue = ''; // Chrome requires a return value to display a custom message
|
||||
if (!localStorage.getItem('token'))
|
||||
return ;
|
||||
try {
|
||||
|
||||
await api.post("/quit");
|
||||
} catch(err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user