feat: Centralized navigation system with HandleNavigate hook
BREAKING CHANGE: Replaced all direct useNavigate() usage with HandleNavigate hook
## Summary
- Complete frontend navigation refactoring
- Centralized route management with routes.js
- Converted 18+ components to use HandleNavigate
- Enhanced navigation with 20+ type-safe functions
## New Files
- src/utils/routes.js - Central route constants and helpers
- Documentations/FRONTEND_CODING_GUIDELINES.md - Frontend best practices (300+ lines)
- Documentations/NAVIGATION_REFACTORING_REPORT.md - Detailed refactoring report (400+ lines)
## Modified Components (18+)
### Pages
- Home.jsx, LoginForm.jsx, RegisterForm.jsx
- ResetPassword.jsx, VerifyEmailPage.jsx
- DeckCreator.jsx, Card_display.jsx
- Lobby.jsx, GameTest.jsx, ChooseDeck.jsx, PlayerSetup.jsx
- Landingpage.jsx
### Components
- Userdetails.jsx, DeckInfoPopUp.jsx
- PlayMenu.jsx, LandingPage.jsx, DeckManager.jsx
### Hooks
- useRequireAuth.jsx
### Core
- App.jsx - Route constants integration
- HandleNavigate.jsx - Enhanced with 20+ navigation functions
## Key Improvements
Type-safe navigation (goDeckDetails(id) vs navigate('/deck/'+id))
Automatic scroll management
Centralized state passing
Single source of truth for routes
Backwards compatibility aliases
Zero compile errors
Production ready
## Validation
- useNavigate: Only in HandleNavigate.jsx
- navigate() calls: 0 direct usage
- Compile errors: 0
- Documentation: Complete
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, { useState, useEffect } from "react"
|
||||
import { useNavigate } from "react-router-dom"
|
||||
import HandleNavigate from "../../utils/HandleNavigate/HandleNavigate"
|
||||
import {
|
||||
FaCommentDots,
|
||||
FaUserFriends,
|
||||
@@ -19,7 +19,7 @@ import { getUserProfile, updateUserProfile, deleteUserProfile } from "../../api/
|
||||
import { notifySuccess, notifyError, notifyWarning } from "../Toastify/toastifyServices"
|
||||
|
||||
const ProfileCard = () => {
|
||||
const navigate = useNavigate()
|
||||
const { goLanding } = HandleNavigate()
|
||||
|
||||
// State
|
||||
const [user, setUser] = useState(null)
|
||||
@@ -120,7 +120,7 @@ const ProfileCard = () => {
|
||||
notifySuccess("Profil sikeresen törölve!")
|
||||
localStorage.removeItem("authLevel")
|
||||
localStorage.removeItem("username")
|
||||
navigate("/")
|
||||
goLanding()
|
||||
} catch (err) {
|
||||
console.error("Profil törlési hiba:", err)
|
||||
notifyError(err.response?.data?.message || "Hiba a profil törlésekor!")
|
||||
|
||||
Reference in New Issue
Block a user