fix: replace Firebase signOut with NextAuth signOut in left rail
Firebase is not configured - auth was undefined causing the error 'Cannot read properties of undefined (reading signOut)'. Use next-auth/react signOut with callbackUrl to redirect to /auth. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { usePathname, useRouter } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import {
|
import {
|
||||||
LayoutGrid,
|
LayoutGrid,
|
||||||
@@ -13,9 +13,7 @@ import {
|
|||||||
LogOut,
|
LogOut,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
import { signOut } from "@/lib/firebase/auth";
|
import { signOut } from "next-auth/react";
|
||||||
import { toast } from "sonner";
|
|
||||||
|
|
||||||
interface WorkspaceLeftRailProps {
|
interface WorkspaceLeftRailProps {
|
||||||
activeSection?: string;
|
activeSection?: string;
|
||||||
onSectionChange: (section: string) => void;
|
onSectionChange: (section: string) => void;
|
||||||
@@ -56,19 +54,12 @@ const navItems = [
|
|||||||
|
|
||||||
export function WorkspaceLeftRail({ activeSection = 'projects', onSectionChange }: WorkspaceLeftRailProps) {
|
export function WorkspaceLeftRail({ activeSection = 'projects', onSectionChange }: WorkspaceLeftRailProps) {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
// Extract workspace from pathname (e.g., /marks-account/projects -> marks-account)
|
// Extract workspace from pathname (e.g., /marks-account/projects -> marks-account)
|
||||||
const workspace = pathname?.split('/')[1] || 'marks-account';
|
const workspace = pathname?.split('/')[1] || 'marks-account';
|
||||||
|
|
||||||
const handleSignOut = async () => {
|
const handleSignOut = async () => {
|
||||||
try {
|
await signOut({ callbackUrl: "/auth" });
|
||||||
await signOut();
|
|
||||||
toast.success("Signed out successfully");
|
|
||||||
router.push("/auth");
|
|
||||||
} catch (error: any) {
|
|
||||||
toast.error(error.message);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user