Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 96487fb065 | |||
| 9ef83f7963 | |||
| 27fc028bad |
+4
-9
@@ -107,9 +107,9 @@ const DeckManager = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full flex flex-col bg-[color:var(--color-background)]">
|
<div className="w-full flex flex-col bg-[color:var(--color-background)]">
|
||||||
<div className="w-full max-w-6xl mx-auto px-4 py-10">
|
<div className="w-full max-w-[1200px] mx-auto px-4 py-10">
|
||||||
{/* Filters */}
|
{/* Filters */}
|
||||||
<div className="flex flex-col md:flex-row gap-4 justify-between items-center mb-10 bg-[color:var(--color-surface)]/80 backdrop-blur-lg rounded-2xl px-6 py-4 shadow-lg">
|
<div className="flex flex-col md:flex-row gap-3 justify-between items-center mb-10 bg-[color:var(--color-surface)]/80 backdrop-blur-lg rounded-2xl px-6 py-4 shadow-lg">
|
||||||
<div className="flex gap-2 items-center w-full md:w-auto">
|
<div className="flex gap-2 items-center w-full md:w-auto">
|
||||||
<SearchBox
|
<SearchBox
|
||||||
value={search}
|
value={search}
|
||||||
@@ -249,7 +249,7 @@ const DeckManager = () => {
|
|||||||
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-8 mt-8">
|
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-8 mt-8">
|
||||||
{/* Create New Deck (Mockup) */}
|
{/* Create New Deck (Mockup) */}
|
||||||
<div
|
<div
|
||||||
onClick={() => navigate('/deck-creator')}
|
onClick={() => navigate("/deck-creator")}
|
||||||
className="flex flex-col items-center justify-center h-48 bg-[color:var(--color-card)] border-2 border-dashed border-[color:var(--color-success)] rounded-2xl cursor-pointer hover:bg-[color:var(--color-success)]/20 transition-all duration-200 shadow-lg"
|
className="flex flex-col items-center justify-center h-48 bg-[color:var(--color-card)] border-2 border-dashed border-[color:var(--color-success)] rounded-2xl cursor-pointer hover:bg-[color:var(--color-success)]/20 transition-all duration-200 shadow-lg"
|
||||||
>
|
>
|
||||||
<FaPlus style={{ color: "var(--color-success)" }} className="text-5xl mb-2" />
|
<FaPlus style={{ color: "var(--color-success)" }} className="text-5xl mb-2" />
|
||||||
@@ -296,12 +296,7 @@ const DeckManager = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Deck Info Popup */}
|
{/* Deck Info Popup */}
|
||||||
{selectedDeck && (
|
{selectedDeck && <DeckInfoPopUp deck={selectedDeck} onClose={() => setSelectedDeck(null)} />}
|
||||||
<DeckInfoPopUp
|
|
||||||
deck={selectedDeck}
|
|
||||||
onClose={() => setSelectedDeck(null)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,9 @@ const PlayMenu = ({ onJoinGame, onCreateGame, user }) => {
|
|||||||
const [joinCode, setJoinCode] = useState("")
|
const [joinCode, setJoinCode] = useState("")
|
||||||
const [error, setError] = useState("")
|
const [error, setError] = useState("")
|
||||||
|
|
||||||
|
// gyors username kiolvasás (ha a parent objektum user={ { name: ... } } küldi)
|
||||||
|
const username = user?.name ?? null
|
||||||
|
|
||||||
const handleJoin = () => {
|
const handleJoin = () => {
|
||||||
if (!joinCode.trim()) {
|
if (!joinCode.trim()) {
|
||||||
setError("Add meg a játék kódját!")
|
setError("Add meg a játék kódját!")
|
||||||
@@ -21,9 +24,19 @@ const PlayMenu = ({ onJoinGame, onCreateGame, user }) => {
|
|||||||
onCreateGame()
|
onCreateGame()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// egyszerű segéd az inicialishez
|
||||||
|
const initials = username
|
||||||
|
? username
|
||||||
|
.split(" ")
|
||||||
|
.map((s) => s[0])
|
||||||
|
.join("")
|
||||||
|
.slice(0, 2)
|
||||||
|
.toUpperCase()
|
||||||
|
: ""
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
className="w-[95%] max-w-6xl mx-auto my-16 flex flex-col md:flex-row items-center justify-center rounded-3xl shadow-2xl min-h-[60vh] overflow-hidden"
|
className="w-[95%] max-w-6xl mx-auto my-16 flex flex-col md:flex-row items-center justify-center rounded-3xl shadow-2xl overflow-hidden"
|
||||||
style={{
|
style={{
|
||||||
background: "linear-gradient(90deg, var(--color-surface) 30%, var(--color-mint) 100%)",
|
background: "linear-gradient(90deg, var(--color-surface) 30%, var(--color-mint) 100%)",
|
||||||
}}
|
}}
|
||||||
@@ -32,10 +45,10 @@ const PlayMenu = ({ onJoinGame, onCreateGame, user }) => {
|
|||||||
<div className="flex-1 flex items-center justify-center w-full h-full py-10 md:py-0 md:pl-10">
|
<div className="flex-1 flex items-center justify-center w-full h-full py-10 md:py-0 md:pl-10">
|
||||||
<LogoCard
|
<LogoCard
|
||||||
imageSrc={logoImg}
|
imageSrc={logoImg}
|
||||||
containerHeight="450px"
|
containerHeight="420px"
|
||||||
containerWidth="450px"
|
containerWidth="420px"
|
||||||
imageHeight="450px"
|
imageHeight="420px"
|
||||||
imageWidth="450px"
|
imageWidth="420px"
|
||||||
rotateAmplitude={7}
|
rotateAmplitude={7}
|
||||||
scaleOnHover={1.03}
|
scaleOnHover={1.03}
|
||||||
showMobileWarning={false}
|
showMobileWarning={false}
|
||||||
@@ -43,12 +56,41 @@ const PlayMenu = ({ onJoinGame, onCreateGame, user }) => {
|
|||||||
displayOverlayContent={false}
|
displayOverlayContent={false}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Jobb oldali panel */}
|
{/* Jobb oldali panel */}
|
||||||
<div className="flex-1 w-full flex flex-col items-center justify-center px-4 md:px-12 py-10">
|
<div className="flex-1 w-full flex items-center justify-center px-6 md:px-12 py-8">
|
||||||
<div className="w-full max-w-md rounded-2xl p-8 flex flex-col gap-8">
|
<div
|
||||||
|
className="w-full max-w-md rounded-2xl p-6 md:p-8 flex flex-col gap-6"
|
||||||
|
style={{ background: "rgba(0,0,0,0.15)", backdropFilter: "blur(6px)" }}
|
||||||
|
>
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
{username ? (
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
{/* opcionális kis info ikon helye, ha később kell */}
|
||||||
|
<div
|
||||||
|
className="w-10 h-10 rounded-full flex items-center justify-center text-sm font-semibold"
|
||||||
|
style={{ background: "rgba(34,197,94,0.12)", color: "var(--color-mint)" }}
|
||||||
|
>
|
||||||
|
{initials}
|
||||||
|
</div>
|
||||||
|
<div className="text-[32px]" style={{ color: "var(--color-muted, #cbd5e1)" }}>
|
||||||
|
{" "}
|
||||||
|
<span className="font-medium" style={{ color: "var(--color-text, #fff)" }}>
|
||||||
|
{username}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="text-sm text-gray-300">Nincs bejelentkezve</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{/* opcionális kis info ikon helye, ha később kell */}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-lg font-semibold mb-2 text-text">Csatlakozás játékhoz</h2>
|
<h2 className="text-xl font-semibold mb-3 text-text">Csatlakozás játékhoz</h2>
|
||||||
<div className={`${error ? "border border-error rounded-lg" : ""}`}>
|
<div className={`${error ? "border border-error rounded-lg p-2" : ""}`}>
|
||||||
<InputBoxDark
|
<InputBoxDark
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Játék kódja"
|
placeholder="Játék kódja"
|
||||||
@@ -57,17 +99,20 @@ const PlayMenu = ({ onJoinGame, onCreateGame, user }) => {
|
|||||||
width="w-full"
|
width="w-full"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="text-xs mt-1 text-error">{error}</div>}
|
{error && <div className="text-xs mt-2 text-error">{error}</div>}
|
||||||
<div className="mt-4">
|
<div className="mt-4">
|
||||||
<ButtonDark text="Csatlakozás" type="button" onClick={handleJoin} width="w-full" />
|
<ButtonDark text="Csatlakozás" type="button" onClick={handleJoin} width="w-full" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{user && (
|
|
||||||
<div>
|
<div className="border-t border-white/10 pt-4">
|
||||||
<h2 className="text-lg font-semibold mb-2 text-text">Új játék létrehozása</h2>
|
{username && (
|
||||||
<ButtonDark text="Játék létrehozása" type="button" onClick={handleCreate} width="w-full" />
|
<div>
|
||||||
</div>
|
<h3 className="text-lg font-semibold mb-3 text-text">Új játék létrehozása</h3>
|
||||||
)}
|
<ButtonDark text="Játék létrehozása" type="button" onClick={handleCreate} width="w-full" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -32,15 +32,23 @@ const Navbar = () => {
|
|||||||
</div>
|
</div>
|
||||||
{/* Desktop Menu */}
|
{/* Desktop Menu */}
|
||||||
<div className="hidden md:flex space-x-8 items-center">
|
<div className="hidden md:flex space-x-8 items-center">
|
||||||
<Link to="/home" className={navLinkClass}>
|
{isLoggedIn ? (
|
||||||
Home
|
<>
|
||||||
</Link>
|
<Link to="/home" className={navLinkClass}>
|
||||||
<Link to="/decks" className={navLinkClass}>
|
Home
|
||||||
Decks
|
</Link>
|
||||||
</Link>
|
<Link to="/decks" className={navLinkClass}>
|
||||||
<Link to="/report" className={navLinkClass}>
|
Decks
|
||||||
Stats
|
</Link>
|
||||||
</Link>
|
<Link to="/report" className={navLinkClass}>
|
||||||
|
Stats
|
||||||
|
</Link>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<Link to="/" className={navLinkClass}>
|
||||||
|
Home
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
<Link to="/about" className={navLinkClass}>
|
<Link to="/about" className={navLinkClass}>
|
||||||
About
|
About
|
||||||
</Link>
|
</Link>
|
||||||
@@ -103,9 +111,15 @@ const Navbar = () => {
|
|||||||
{/* Mobile Menu */}
|
{/* Mobile Menu */}
|
||||||
{menuOpen && (
|
{menuOpen && (
|
||||||
<div className="md:hidden bg-emerald-600 px-2 pt-2 pb-3 space-y-1">
|
<div className="md:hidden bg-emerald-600 px-2 pt-2 pb-3 space-y-1">
|
||||||
<Link to="/home" className={navLinkClass}>
|
{isLoggedIn ? (
|
||||||
Home
|
<Link to="/home" className={navLinkClass}>
|
||||||
</Link>
|
Home
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<Link to="/" className={navLinkClass}>
|
||||||
|
Home
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
<Link to="/leaderboard" className={navLinkClass}>
|
<Link to="/leaderboard" className={navLinkClass}>
|
||||||
Leaderboard
|
Leaderboard
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import { useState, useEffect } from "react"
|
||||||
|
import { useNavigate } from "react-router-dom"
|
||||||
|
|
||||||
|
export function requireAuthSync({ key = "username", redirectTo = "/login", replace = true } = {}) {
|
||||||
|
const value = localStorage.getItem(key)
|
||||||
|
if (!value) {
|
||||||
|
if (replace) window.location.replace(redirectTo)
|
||||||
|
else window.location.assign(redirectTo)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default hook: ad vissza egy [value, setValue] párt, szinkronizálja localStorage-t és átirányít, ha nincs érték
|
||||||
|
export default function useRequireAuth({ key = "username", redirectTo = "/login" } = {}) {
|
||||||
|
const navigate = useNavigate()
|
||||||
|
const [value, setValue] = useState(() => {
|
||||||
|
try {
|
||||||
|
return localStorage.getItem(key)
|
||||||
|
} catch {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Ha nincs érték, átirányítjuk (komponens mount-oláskor)
|
||||||
|
useEffect(() => {
|
||||||
|
if (!value) {
|
||||||
|
navigate(redirectTo)
|
||||||
|
}
|
||||||
|
}, [navigate, value, redirectTo])
|
||||||
|
|
||||||
|
// Szinkronizáljuk a localStorage-t amikor a state változik
|
||||||
|
useEffect(() => {
|
||||||
|
try {
|
||||||
|
if (value == null) localStorage.removeItem(key)
|
||||||
|
else localStorage.setItem(key, value)
|
||||||
|
} catch {
|
||||||
|
// fail silently
|
||||||
|
}
|
||||||
|
}, [key, value])
|
||||||
|
|
||||||
|
return [value, setValue]
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
// src/pages/Decks/DeckManagerPage.jsx
|
// src/pages/Decks/DeckManagerPage.jsx
|
||||||
// Deck Management Page (with Navbar, no Footer)
|
// Deck Management Page (with Navbar, no Footer)
|
||||||
|
|
||||||
import DeckManager from "../../components/Landingpage/DeckManager.jsx"
|
import DeckManager from "../../components/DeckCreator/DeckManager.jsx"
|
||||||
import Navbar from "../../components/Navbar/Navbar.jsx"
|
import Navbar from "../../components/Navbar/Navbar.jsx"
|
||||||
|
|
||||||
export default function DeckManagerPage() {
|
export default function DeckManagerPage() {
|
||||||
|
|||||||
@@ -1,19 +1,16 @@
|
|||||||
// src/pages/Home/Home.jsx
|
// src/pages/Home/Home.jsx
|
||||||
// Régi PlayMenu-s oldal, "Home" néven
|
// Régi PlayMenu-s oldal, "Home" néven
|
||||||
|
|
||||||
import { useState, useEffect } from "react"
|
import { useEffect } from "react"
|
||||||
import { useNavigate } from "react-router-dom"
|
import useRequireAuth from "../../hooks/useRequireAuth"
|
||||||
import Navbar from "../../components/Navbar/Navbar"
|
import Navbar from "../../components/Navbar/Navbar"
|
||||||
import Footer from "../../components/Footer/Footer.jsx"
|
import Footer from "../../components/Footer/Footer.jsx"
|
||||||
import Background from "../../assets/backgrounds/Background.jsx"
|
import Background from "../../assets/backgrounds/Background.jsx"
|
||||||
import PlayMenu from "../../components/Landingpage/PlayMenu.jsx"
|
import PlayMenu from "../../components/Landingpage/PlayMenu.jsx"
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const navigate = useNavigate()
|
// a hook inicializálja a user-t a localStorage-ból és visszaadja a state-et + settert
|
||||||
const user = localStorage.getItem("username")
|
const [user, setUser] = useRequireAuth()
|
||||||
|
|
||||||
// Logoljuk ki a user-t minden renderkor
|
|
||||||
console.log("Home user:", user)
|
|
||||||
|
|
||||||
// Dummy callbackok és user példa
|
// Dummy callbackok és user példa
|
||||||
const handleJoinGame = (code) => {
|
const handleJoinGame = (code) => {
|
||||||
@@ -24,12 +21,7 @@ export default function Home() {
|
|||||||
}
|
}
|
||||||
const userObj = { name: user }
|
const userObj = { name: user }
|
||||||
|
|
||||||
// Ha nincs bejelentkezett felhasználó a localStorage-ben, átirányítjuk a /login oldalra
|
// ha szükséges a user módosítása máshol: setUser("újnév") automatikusan menti localStorage-be
|
||||||
useEffect(() => {
|
|
||||||
if (!user) {
|
|
||||||
navigate("/login")
|
|
||||||
}
|
|
||||||
}, [navigate, user])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full min-h-screen flex flex-col relative overflow-x-hidden">
|
<div className="w-full min-h-screen flex flex-col relative overflow-x-hidden">
|
||||||
|
|||||||
@@ -4,8 +4,11 @@ import Navbar from "../../components/Navbar/Navbar.jsx"
|
|||||||
import Footer from "../../components/Footer/Footer.jsx"
|
import Footer from "../../components/Footer/Footer.jsx"
|
||||||
import Background from "../../assets/backgrounds/Background.jsx"
|
import Background from "../../assets/backgrounds/Background.jsx"
|
||||||
import { getUserStats } from "../../api/userApi.js"
|
import { getUserStats } from "../../api/userApi.js"
|
||||||
|
import useRequireAuth from "../../hooks/useRequireAuth.jsx"
|
||||||
|
|
||||||
export default function Reports() {
|
export default function Reports() {
|
||||||
|
const [username] = useRequireAuth({ key: "username", redirectTo: "/login" })
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full min-h-screen flex flex-col relative overflow-x-hidden">
|
<div className="w-full min-h-screen flex flex-col relative overflow-x-hidden">
|
||||||
{/* Háttér */}
|
{/* Háttér */}
|
||||||
@@ -24,9 +27,8 @@ export default function Reports() {
|
|||||||
{/* Fejléc */}
|
{/* Fejléc */}
|
||||||
<div className="text-center mb-8">
|
<div className="text-center mb-8">
|
||||||
<h2 className="text-3xl font-bold text-white">Játék Riportok</h2>
|
<h2 className="text-3xl font-bold text-white">Játék Riportok</h2>
|
||||||
<p className="text-gray-300 mt-2">
|
<p className="text-gray-300 mt-2">Áttekintés a legutóbbi játékokról és statisztikákról</p>
|
||||||
Áttekintés a legutóbbi játékokról és statisztikákról
|
{username && <p className="text-sm text-gray-400 mt-1">Bejelentkezett: {username}</p>}
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Statisztikai kártyák */}
|
{/* Statisztikai kártyák */}
|
||||||
|
|||||||
Reference in New Issue
Block a user