feat : logout callback use current path instead of root
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useState, useMemo } from "react";
|
import { useState, useMemo } from "react";
|
||||||
|
import { usePathname } from "next/navigation";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { LogOut } from "lucide-react";
|
import { LogOut } from "lucide-react";
|
||||||
import { signOut } from "next-auth/react";
|
import { signOut } from "next-auth/react";
|
||||||
@@ -53,6 +54,7 @@ export function DropdownMenuAvatar({
|
|||||||
showName?: boolean;
|
showName?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const [imgError, setImgError] = useState(false);
|
const [imgError, setImgError] = useState(false);
|
||||||
|
const pathname = usePathname();
|
||||||
|
|
||||||
const displayAvatar = profile?.avatarUrl || userImage;
|
const displayAvatar = profile?.avatarUrl || userImage;
|
||||||
const displayName = profile?.globalName || userName;
|
const displayName = profile?.globalName || userName;
|
||||||
@@ -151,7 +153,7 @@ export function DropdownMenuAvatar({
|
|||||||
{/* Footer / Sign Out */}
|
{/* Footer / Sign Out */}
|
||||||
<div className="p-2 border-t">
|
<div className="p-2 border-t">
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={() => signOut({ callbackUrl: "/" })}
|
onClick={() => signOut({ callbackUrl: pathname })}
|
||||||
className="text-destructive"
|
className="text-destructive"
|
||||||
>
|
>
|
||||||
<LogOut className="w-4 h-4 mr-2" />
|
<LogOut className="w-4 h-4 mr-2" />
|
||||||
|
|||||||
Reference in New Issue
Block a user