This commit is contained in:
Donat Magda
2025-11-26 20:23:35 +01:00
parent 9ba8c95142
commit f82bd6d304
5 changed files with 14 additions and 2 deletions
+11 -1
View File
@@ -2,7 +2,7 @@ import axios from "axios"
export const API_CONFIG = {
baseURL: (import.meta.env.VITE_API_URL ? import.meta.env.VITE_API_URL : "") + "/api",
wsURL: "http://localhost:3000",
wsURL: (import.meta.env.VITE_API_URL ? import.meta.env.VITE_API_URL : ""),
timeout: 10000,
retryAttempts: 3,
}
@@ -26,6 +26,16 @@ export const login = async (username, password) => {
}
}
//logout
export const logout = async () => {
try {
const response = await apiClient.post("/users/logout")
return response
} catch (error) {
throw error
}
}
//register
export const register = async (username, email, password, fname, lname, phone) => {
try {
@@ -3,6 +3,7 @@ import Logo from "../../assets/pictures/Logo"
import { Link } from "react-router-dom"
import HandleNavigate from "../../utils/HandleNavigate/HandleNavigate" // ✅ importáld a navigációs hookot
import { FaSignOutAlt, FaChartBar, FaUser, FaBars } from "react-icons/fa"
import { logout } from "../../api/userApi" // ✅ importáld a logout API hívást
const navLinkClass = "px-3 py-2 rounded-lg text-white transition-all duration-200 hover:bg-white/10"
const navLinkClassPlay =
@@ -17,8 +18,9 @@ const Navbar = () => {
const { goLanding, goAbout, goHome, goLogin, goContacts } = HandleNavigate()
// ✅ Logout logika
const handleLogout = () => {
const handleLogout = async () => {
localStorage.clear()
await logout()
goLanding()
}