File tree Expand file tree Collapse file tree 3 files changed +4
-19
lines changed
frontend/issue-tracker-ui/src Expand file tree Collapse file tree 3 files changed +4
-19
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,6 @@ interface AdminDashboardProps {
4747export function AdminDashboard ( { user } : AdminDashboardProps ) {
4848 // Mock data for demo
4949 const [ users , setUsers ] = useState < User [ ] > ( ) ;
50-
5150 const [ successMessage , setSuccessMessage ] = useState ( "" ) ;
5251
5352 async function loadUsers ( ) {
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import { Avatar, AvatarFallback } from "@/components/ui/avatar";
1111import { LogOut , Triangle } from "lucide-react" ;
1212import { useRouter } from "next/navigation" ;
1313import { User } from "@/types/user" ;
14+ import { logoutUser } from "@/lib/api/auth" ;
1415
1516interface HeaderProps {
1617 user : User ;
@@ -20,23 +21,8 @@ export function Header({ user }: HeaderProps) {
2021 const router = useRouter ( ) ;
2122 async function handleLogout ( ) {
2223 try {
23- const res = await fetch (
24- "http://localhost:8080/IssuesandDeploymentTracker/api/auth/logout" ,
25- {
26- method : "POST" ,
27- credentials : "include" , // send cookies
28- }
29- ) ;
30-
31- if ( res . ok ) {
32- // Optional: clear any client state
33- localStorage . clear ( ) ;
34- sessionStorage . clear ( ) ;
35-
36- router . push ( "/auth" ) ;
37- } else {
38- console . error ( "Logout failed" ) ;
39- }
24+ await logoutUser ( ) ;
25+ router . push ( "/auth" ) ;
4026 } catch ( err ) {
4127 console . error ( "Logout error" , err ) ;
4228 }
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ export async function LoginUser(email: string, password: string) {
3030 } ) ;
3131 const data = await res . json ( ) ;
3232 if ( ! res . ok ) {
33- alert ( data . message || "Login failed." ) ;
33+ throw new Error ( data . message || "Login failed." ) ;
3434 }
3535 return data ;
3636}
You can’t perform that action at this time.
0 commit comments