Skip to content

Commit 30a611b

Browse files
committed
feat: implement login page and dashboard layout with authentication
1 parent 386c568 commit 30a611b

File tree

13 files changed

+169
-29
lines changed

13 files changed

+169
-29
lines changed
Lines changed: 51 additions & 0 deletions
Loading
4.92 KB
Loading

frontend-nextjs/public/file.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

frontend-nextjs/public/globe.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

frontend-nextjs/public/next.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

frontend-nextjs/public/vercel.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

frontend-nextjs/public/window.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

frontend-nextjs/src/app/layout.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ import { Toaster } from "@/components/ui/toaster"
88
const inter = Inter({ subsets: ["latin"] })
99

1010
export const metadata: Metadata = {
11-
title: "FastAPI Dashboard",
12-
description: "Modern admin dashboard for FastAPI applications",
13-
generator: 'v0.dev'
11+
title: "Full Stack FastAPI Project",
12+
description: "A modern full-stack web application built with FastAPI and Next.js",
13+
icons: {
14+
icon: "/assets/images/favicon.png",
15+
shortcut: "/assets/images/favicon.png",
16+
apple: "/assets/images/favicon.png",
17+
},
1418
}
1519

1620
export default function RootLayout({

frontend-nextjs/src/app/login/page.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import type React from "react"
44

5-
import { useState } from "react"
5+
import { useState, useEffect } from "react"
66
import { motion } from "framer-motion"
77
import { Eye, EyeOff, AlertCircle } from "lucide-react"
88
import { Button } from "@/components/ui/button"
@@ -13,6 +13,7 @@ import { Alert, AlertDescription } from "@/components/ui/alert"
1313
import Link from "next/link"
1414
import { useRouter } from "next/navigation"
1515
import { loginLoginAccessToken, type BodyLoginLoginAccessToken } from "@/lib/api-client"
16+
import { isAuthenticated } from "@/lib/auth"
1617

1718
export default function LoginPage() {
1819
const [showPassword, setShowPassword] = useState(false)
@@ -22,6 +23,12 @@ export default function LoginPage() {
2223
const [error, setError] = useState<string | null>(null)
2324
const router = useRouter()
2425

26+
useEffect(() => {
27+
if (isAuthenticated()) {
28+
router.push("/dashboard")
29+
}
30+
}, [router])
31+
2532
const handleSubmit = async (e: React.FormEvent) => {
2633
e.preventDefault()
2734
setIsLoading(true)

frontend-nextjs/src/app/page.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
1-
import { redirect } from "next/navigation"
1+
"use client"
2+
3+
import { useEffect } from "react"
4+
import { useRouter } from "next/navigation"
5+
import { isAuthenticated } from "@/lib/auth"
26

37
export default function HomePage() {
4-
redirect("/login")
8+
const router = useRouter()
9+
10+
useEffect(() => {
11+
if (isAuthenticated()) {
12+
router.push("/dashboard")
13+
} else {
14+
router.push("/login")
15+
}
16+
}, [router])
17+
18+
// Show loading state while redirecting
19+
return (
20+
<div className="flex items-center justify-center min-h-screen">
21+
<div className="text-center">
22+
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 mx-auto"></div>
23+
<p className="mt-2 text-gray-600">Redirecting...</p>
24+
</div>
25+
</div>
26+
)
527
}

0 commit comments

Comments
 (0)