Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/app/(auth)/auth/callback/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use client"

import { useEffect } from "react"
import { useRouter } from "next/navigation"
import { LoaderCircle } from "lucide-react"
import { authClient } from "@/infrastructure/auth/client"

export default function AuthCallbackPage() {
const router = useRouter()
const { data: session, isPending } = authClient.useSession()

useEffect(() => {
if (isPending || !session) return
router.push(session.user.role === "admin" ? "/admin" : "/dashboard")
}, [session, isPending, router])
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

return (
<div className="flex flex-col items-center justify-center gap-4 pt-40">
<LoaderCircle className="size-8 animate-spin text-ma-admin-primary" />
<p className="text-2xl font-semibold text-primary">Signing you in...</p>
</div>
)
}
25 changes: 25 additions & 0 deletions src/app/(auth)/auth/signout/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use client"

import { useEffect } from "react"
import { useRouter } from "next/navigation"
import { LoaderCircle } from "lucide-react"
import { authClient } from "@/infrastructure/auth/client"

export default function SignOutPage() {
const router = useRouter()

useEffect(() => {
const signOut = async () => {
await authClient.signOut()
router.push("/login")
}
signOut()
}, [router])
Comment thread
coderabbitai[bot] marked this conversation as resolved.

return (
<div className="flex flex-col items-center justify-center gap-4 pt-40">
<LoaderCircle className="size-8 animate-spin text-ma-admin-primary" />
<p className="text-2xl font-semibold text-primary">Logging out...</p>
</div>
)
}
27 changes: 27 additions & 0 deletions src/app/(auth)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Image from "next/image"
import Link from "next/link"

export default function AuthLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<div className="min-h-screen bg-white">
<header className="bg-white">
<div className="mx-auto px-4 py-5 lg:max-w-7xl lg:px-25 2xl:max-w-360 2xl:px-50">
<Link href="/" className="flex w-[157px] flex-col gap-1">
<Image
src="/figma-home/logo.svg"
alt="ModernAdvocates Inc."
width={58}
height={44}
priority
/>
</Link>
</div>
</header>
{children}
</div>
)
}
2 changes: 1 addition & 1 deletion src/features/auth/components/auth-google-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function AuthGoogleButton({ label }: { label: string }) {
const handleSignIn = async () => {
setPending(true)
try {
await authClient.signIn.social({ provider: "google", callbackURL: "/dashboard" })
await authClient.signIn.social({ provider: "google", callbackURL: "/auth/callback" })
} catch {
toast.error("Failed to sign in with Google. Please try again.")
} finally {
Expand Down
12 changes: 6 additions & 6 deletions src/features/platform/components/sidebar-navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client"

import Link from "next/link"
import { usePathname } from "next/navigation"
import { usePathname, useRouter } from "next/navigation"
import {
LayoutGrid,
PlayCircle,
Expand All @@ -13,7 +13,6 @@ import {
LogOut,
} from "lucide-react"
import { cn } from "@/shared/utils"
import { authClient } from "@/infrastructure/auth/client"
import {
Sidebar,
SidebarContent,
Expand Down Expand Up @@ -45,14 +44,15 @@ export function SidebarNavigation({
...props
}: React.ComponentProps<typeof Sidebar>) {
const pathname = usePathname()
const router = useRouter()

const isActive = (url: string) => {
if (url === "/admin") return pathname === "/admin"
return pathname === url || pathname.startsWith(url + "/")
}

const handleLogout = async () => {
await authClient.signOut()
const handleLogout = () => {
router.push("/auth/signout")
}

return (
Expand Down Expand Up @@ -142,13 +142,13 @@ export function SidebarNavigation({
</SidebarGroup>
</SidebarContent>

<SidebarFooter>
<SidebarFooter className='px-4'>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton
asChild
tooltip="Log out"
className="text-red-500 hover:bg-red-50 hover:text-red-500!"
className="text-red-500 hover:bg-red-50 h-10 text-lg hover:text-red-500!"
>
<button onClick={handleLogout} type="button">
<LogOut className="size-4" />
Expand Down