Some checks failed
CI / Frontend Lint & Type Check (push) Has been cancelled
CI / Frontend Build (push) Has been cancelled
CI / Backend Lint (push) Has been cancelled
CI / Backend Tests (push) Has been cancelled
CI / Docker Build (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
Deploy / Build & Push Images (push) Has been cancelled
Deploy / Deploy to Server (push) Has been cancelled
Deploy / Notify (push) Has been cancelled
- Renamed /command/* routes to /terminal/* - Renamed CommandCenterLayout to TerminalLayout - Updated all internal links - Added permanent redirects from /command/* to /terminal/* - Updated Sidebar navigation - Added concept docs (pounce_*.md)
68 lines
2.0 KiB
TypeScript
68 lines
2.0 KiB
TypeScript
'use client'
|
|
|
|
import { useEffect, Suspense } from 'react'
|
|
import { useRouter, useSearchParams } from 'next/navigation'
|
|
import { useStore } from '@/lib/store'
|
|
import { Loader2, CheckCircle } from 'lucide-react'
|
|
|
|
function OAuthCallbackContent() {
|
|
const router = useRouter()
|
|
const searchParams = useSearchParams()
|
|
const { checkAuth } = useStore()
|
|
|
|
useEffect(() => {
|
|
const token = searchParams.get('token')
|
|
const redirect = searchParams.get('redirect') || '/terminal/dashboard'
|
|
const isNew = searchParams.get('new') === 'true'
|
|
const error = searchParams.get('error')
|
|
|
|
if (error) {
|
|
router.push(`/login?error=${error}`)
|
|
return
|
|
}
|
|
|
|
if (token) {
|
|
// Store the token (using 'token' key to match api.ts)
|
|
localStorage.setItem('token', token)
|
|
|
|
// Update auth state
|
|
checkAuth().then(() => {
|
|
// Redirect with welcome message for new users
|
|
if (isNew) {
|
|
router.push(`${redirect}?welcome=true`)
|
|
} else {
|
|
router.push(redirect)
|
|
}
|
|
})
|
|
} else {
|
|
router.push('/login?error=no_token')
|
|
}
|
|
}, [searchParams, router, checkAuth])
|
|
|
|
return (
|
|
<div className="min-h-screen bg-background flex items-center justify-center">
|
|
<div className="text-center">
|
|
<div className="relative mb-6">
|
|
<Loader2 className="w-12 h-12 text-accent animate-spin mx-auto" />
|
|
<div className="absolute inset-0 bg-accent/20 blur-xl rounded-full" />
|
|
</div>
|
|
<h2 className="text-xl font-display text-foreground mb-2">Signing you in...</h2>
|
|
<p className="text-sm text-foreground-muted">Please wait while we complete authentication</p>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default function OAuthCallbackPage() {
|
|
return (
|
|
<Suspense fallback={
|
|
<div className="min-h-screen flex items-center justify-center bg-background">
|
|
<Loader2 className="w-6 h-6 animate-spin text-accent" />
|
|
</div>
|
|
}>
|
|
<OAuthCallbackContent />
|
|
</Suspense>
|
|
)
|
|
}
|
|
|