google sign in page done

This commit is contained in:
2026-02-19 11:15:25 +05:30
parent ad6ae63d33
commit 555c03a91c
16 changed files with 1745 additions and 104 deletions

View File

@@ -0,0 +1,27 @@
import { useEffect, type ReactNode } from 'react'
import { Navigate, useLocation } from 'react-router-dom'
import { useAuth } from '../contexts/AuthContext'
type Props = {
children: ReactNode
}
export function ProtectedRoute({ children }: Props) {
const { user, loading } = useAuth()
const location = useLocation()
if (loading) {
return (
<div className="protected-route__loading" aria-live="polite">
<span className="protected-route__spinner" aria-hidden />
<p>Loading</p>
</div>
)
}
if (!user) {
return <Navigate to="/login" state={{ from: location }} replace />
}
return <>{children}</>
}