ADD navigation refresh after Google login and logout
This commit is contained in:
@@ -8,6 +8,7 @@ import type { CredentialResponse } from '@react-oauth/google';
|
|||||||
|
|
||||||
import MenuButton from "./buttons/MenuButton.tsx";
|
import MenuButton from "./buttons/MenuButton.tsx";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
|
import {useNavigate} from "react-router-dom";
|
||||||
|
|
||||||
|
|
||||||
type props = {
|
type props = {
|
||||||
@@ -25,6 +26,8 @@ const Topbar = ({
|
|||||||
fetchUser,
|
fetchUser,
|
||||||
className}: props) => {
|
className}: props) => {
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const handleLogin = (response: CredentialResponse) => {
|
const handleLogin = (response: CredentialResponse) => {
|
||||||
if (!response.credential) {
|
if (!response.credential) {
|
||||||
console.error("No credential received from Google login.");
|
console.error("No credential received from Google login.");
|
||||||
@@ -34,6 +37,7 @@ const Topbar = ({
|
|||||||
login(response.credential)
|
login(response.credential)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
fetchUser();
|
fetchUser();
|
||||||
|
navigate(0);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("Login failed:", error);
|
console.error("Login failed:", error);
|
||||||
@@ -44,6 +48,7 @@ const Topbar = ({
|
|||||||
logout()
|
logout()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
fetchUser();
|
fetchUser();
|
||||||
|
navigate(0);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("Logout failed:", error);
|
console.error("Logout failed:", error);
|
||||||
|
|||||||
Reference in New Issue
Block a user