Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bfe977d35b | |||
| 5194308f7c | |||
| 8d24e8ffa6 | |||
| 1bf3253128 |
@@ -15,6 +15,7 @@ import About from "./pages/About/About"
|
|||||||
import ScrollToTop from "./components/ScrollToTop"
|
import ScrollToTop from "./components/ScrollToTop"
|
||||||
import GameScreen from "./pages/Game/GameScreen"
|
import GameScreen from "./pages/Game/GameScreen"
|
||||||
import Reports from "./pages/Report/Reports"
|
import Reports from "./pages/Report/Reports"
|
||||||
|
import Lobby from "./pages/Lobby/Lobby"
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [isMobile, setIsMobile] = useState(false)
|
const [isMobile, setIsMobile] = useState(false)
|
||||||
@@ -46,6 +47,7 @@ function App() {
|
|||||||
<Router>
|
<Router>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/about" element={<About />} />
|
<Route path="/about" element={<About />} />
|
||||||
|
<Route path="/lobby" element={<Lobby />} />
|
||||||
<Route path="/register" element={<AuthRegister />} />
|
<Route path="/register" element={<AuthRegister />} />
|
||||||
<Route path="/login" element={<AuthLogin />} />
|
<Route path="/login" element={<AuthLogin />} />
|
||||||
<Route path="/verify-email" element={<EmailVerification />} />
|
<Route path="/verify-email" element={<EmailVerification />} />
|
||||||
|
|||||||
@@ -10,6 +10,16 @@ export const createDeck = async (deck) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get paginated decks (authenticated)
|
||||||
|
export const getDecksPage = async (from = 0, to = 49) => {
|
||||||
|
try {
|
||||||
|
const response = await apiClient.get(`/decks/page/${from}/${to}`)
|
||||||
|
return response.data
|
||||||
|
} catch (err) {
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
createDeck
|
createDeck
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from "react"
|
import React, { useState, useEffect } from "react"
|
||||||
import { useNavigate } from "react-router-dom"
|
import { useNavigate } from "react-router-dom"
|
||||||
import {
|
import {
|
||||||
FaPlus,
|
FaPlus,
|
||||||
@@ -20,19 +20,7 @@ const deckTypes = [
|
|||||||
{ label: "Fun", color: "var(--color-fun)" },
|
{ label: "Fun", color: "var(--color-fun)" },
|
||||||
]
|
]
|
||||||
|
|
||||||
const mockDecks = [
|
// initial state will be fetched from backend
|
||||||
// Just for visual mockup
|
|
||||||
{ id: 1, name: "Party Luck", type: "Luck", created: "2025-07-01", origin: "Vállalati" },
|
|
||||||
{ id: 2, name: "Quiz Night", type: "Question", created: "2025-07-02", origin: "Saját" },
|
|
||||||
{ id: 3, name: "Fun Times", type: "Fun", created: "2025-07-03", origin: "Vállalati" },
|
|
||||||
{ id: 4, name: "Corporate Challenge", type: "Question", created: "2025-07-04", origin: "Vállalati" },
|
|
||||||
{ id: 5, name: "Randomizer", type: "Luck", created: "2025-07-05", origin: "Saját" },
|
|
||||||
{ id: 6, name: "Afterwork luck", type: "Luck", created: "2025-07-06", origin: "Saját" },
|
|
||||||
{ id: 7, name: "Serpent Quiz", type: "Question", created: "2025-07-07", origin: "Vállalati" },
|
|
||||||
{ id: 8, name: "Green Fortune", type: "Luck", created: "2025-07-08", origin: "Vállalati" },
|
|
||||||
{ id: 9, name: "Team Builder", type: "Fun", created: "2025-07-09", origin: "Saját" },
|
|
||||||
{ id: 10, name: "Knowledge Race", type: "Question", created: "2025-07-10", origin: "Saját" },
|
|
||||||
]
|
|
||||||
|
|
||||||
const origins = ["Mind", "Vállalati", "Saját"]
|
const origins = ["Mind", "Vállalati", "Saját"]
|
||||||
|
|
||||||
@@ -82,9 +70,39 @@ const DeckManager = () => {
|
|||||||
const [search, setSearch] = useState("")
|
const [search, setSearch] = useState("")
|
||||||
const [showSortHelp, setShowSortHelp] = useState(false)
|
const [showSortHelp, setShowSortHelp] = useState(false)
|
||||||
const [selectedDeck, setSelectedDeck] = useState(null)
|
const [selectedDeck, setSelectedDeck] = useState(null)
|
||||||
|
const [decks, setDecks] = useState([])
|
||||||
|
const [loading, setLoading] = useState(false)
|
||||||
|
|
||||||
// Filter logic (mock)
|
useEffect(() => {
|
||||||
let filteredDecks = mockDecks.filter((deck) => {
|
let mounted = true
|
||||||
|
const load = async () => {
|
||||||
|
setLoading(true)
|
||||||
|
try {
|
||||||
|
const result = await import('../../api/deckApi').then(m => m.getDecksPage(0, 49))
|
||||||
|
if (!mounted) return
|
||||||
|
// map backend deck shape to UI shape
|
||||||
|
const mapped = result.decks.map(d => ({
|
||||||
|
id: d.id,
|
||||||
|
name: d.name,
|
||||||
|
type: d.type === 2 ? 'Question' : d.type === 1 ? 'Joker' : 'Luck',
|
||||||
|
created: d.creationdate ? new Date(d.creationdate).toLocaleDateString() : '',
|
||||||
|
origin: d.ctype === 2 ? 'Vállalati' : d.ctype === 0 ? 'Mind' : 'Saját',
|
||||||
|
raw: d
|
||||||
|
}))
|
||||||
|
setDecks(mapped)
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to load decks', err)
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
load()
|
||||||
|
return () => { mounted = false }
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
// Filter logic
|
||||||
|
const sourceDecks = decks
|
||||||
|
let filteredDecks = sourceDecks.filter((deck) => {
|
||||||
const typeMatch = selectedType === "All" || deck.type === selectedType
|
const typeMatch = selectedType === "All" || deck.type === selectedType
|
||||||
const originMatch = selectedOrigin === "Mind" || deck.origin === selectedOrigin
|
const originMatch = selectedOrigin === "Mind" || deck.origin === selectedOrigin
|
||||||
const searchMatch = !search || deck.name.toLowerCase().includes(search.toLowerCase())
|
const searchMatch = !search || deck.name.toLowerCase().includes(search.toLowerCase())
|
||||||
@@ -255,8 +273,14 @@ const DeckManager = () => {
|
|||||||
<FaPlus style={{ color: "var(--color-success)" }} className="text-5xl mb-2" />
|
<FaPlus style={{ color: "var(--color-success)" }} className="text-5xl mb-2" />
|
||||||
<span className="text-[color:var(--color-text)] font-semibold">Új pakli létrehozása</span>
|
<span className="text-[color:var(--color-text)] font-semibold">Új pakli létrehozása</span>
|
||||||
</div>
|
</div>
|
||||||
{/* Existing Decks (Mockup) */}
|
{/* Existing Decks (from backend) */}
|
||||||
{filteredDecks.map((deck) => {
|
{loading && (
|
||||||
|
<div className="col-span-full text-center text-[color:var(--color-text-muted)]">Betöltés...</div>
|
||||||
|
)}
|
||||||
|
{!loading && filteredDecks.length === 0 && (
|
||||||
|
<div className="col-span-full text-center text-[color:var(--color-text-muted)]">Nincsenek mentett paklik.</div>
|
||||||
|
)}
|
||||||
|
{!loading && filteredDecks.map((deck) => {
|
||||||
const deckType = deckTypes.find((t) => t.label === deck.type)
|
const deckType = deckTypes.find((t) => t.label === deck.type)
|
||||||
const borderColor = deckType ? deckType.color : "var(--color-success)"
|
const borderColor = deckType ? deckType.color : "var(--color-success)"
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ const PlayMenu = ({ onJoinGame, onCreateGame, user }) => {
|
|||||||
<div className="text-sm text-gray-300">Nincs bejelentkezve</div>
|
<div className="text-sm text-gray-300">Nincs bejelentkezve</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{/* opcionális kis info ikon helye, ha később kell */}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ import {
|
|||||||
export default function DeckInfoPopUp({ deck, onClose }) {
|
export default function DeckInfoPopUp({ deck, onClose }) {
|
||||||
if (!deck) return null
|
if (!deck) return null
|
||||||
|
|
||||||
|
// Debug: Log the deck structure to see what we're working with
|
||||||
|
console.log('Deck in popup:', deck)
|
||||||
|
console.log('Cards:', deck.cards)
|
||||||
|
|
||||||
// Scroll blokkolás amikor a popup nyitva van
|
// Scroll blokkolás amikor a popup nyitva van
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Scroll letiltása
|
// Scroll letiltása
|
||||||
@@ -33,13 +37,25 @@ export default function DeckInfoPopUp({ deck, onClose }) {
|
|||||||
|
|
||||||
const currentDeckType = deckTypes[deck.type] || { label: deck.type, color: "var(--color-success)" }
|
const currentDeckType = deckTypes[deck.type] || { label: deck.type, color: "var(--color-success)" }
|
||||||
|
|
||||||
// Mock data - ezeket majd a backend adatokra cseréljük
|
// Use real deck data with safe fallbacks
|
||||||
|
const creator = deck.creatorName || deck.creator || (deck.user && deck.user.name) || "Ismeretlen"
|
||||||
|
const privacy = deck.origin === "Vállalati" || deck.ctype === 1 || deck.privacy === 'public' ? "Publikus" : "Privát"
|
||||||
|
|
||||||
|
// Get data from raw if available
|
||||||
|
const rawData = deck.raw || deck
|
||||||
|
|
||||||
|
// Use played number from raw data for answers count
|
||||||
|
const questionsCount = rawData.cardCount || 0
|
||||||
|
const answersCount = rawData.playedNumber || 0
|
||||||
|
|
||||||
|
console.log('Calculated counts:', { questionsCount, answersCount, rawData })
|
||||||
|
|
||||||
const mockData = {
|
const mockData = {
|
||||||
creator: "John Doe",
|
...deck,
|
||||||
privacy: deck.origin === "Vállalati" ? "Publikus" : "Privát",
|
creator,
|
||||||
questionsCount: Math.floor(Math.random() * 50) + 10,
|
privacy,
|
||||||
answersCount: Math.floor(Math.random() * 200) + 50,
|
questionsCount,
|
||||||
...deck
|
answersCount
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatDate = (dateString) => {
|
const formatDate = (dateString) => {
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
import React, { useEffect, useRef, useState } from "react"
|
||||||
|
import { useNavigate, useLocation } from "react-router-dom"
|
||||||
|
import Navbar from "../../components/Navbar/Navbar"
|
||||||
|
import Background from "../../assets/backgrounds/Background.jsx"
|
||||||
|
import useRequireAuth from "../../hooks/useRequireAuth"
|
||||||
|
|
||||||
|
const Lobby = () => {
|
||||||
|
const [visible, setVisible] = useState(false)
|
||||||
|
const sectionRef = useRef(null)
|
||||||
|
const navigate = useNavigate()
|
||||||
|
const location = useLocation()
|
||||||
|
|
||||||
|
|
||||||
|
const [user, setUser] = useRequireAuth()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const observer = new IntersectionObserver(
|
||||||
|
([entry]) => {
|
||||||
|
if (entry.isIntersecting) setVisible(true)
|
||||||
|
},
|
||||||
|
{ threshold: 0.3 }
|
||||||
|
)
|
||||||
|
if (sectionRef.current) observer.observe(sectionRef.current)
|
||||||
|
return () => observer.disconnect()
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const handleExit = () => {
|
||||||
|
if (window.confirm("Biztosan ki szeretnél lépni a lobbyból?")) {
|
||||||
|
navigate("/home")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getInitials = (name) => {
|
||||||
|
return name
|
||||||
|
.split(" ")
|
||||||
|
.map((n) => n[0])
|
||||||
|
.join("")
|
||||||
|
.slice(0, 2)
|
||||||
|
.toUpperCase()
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col min-h-screen overflow-y-auto relative">
|
||||||
|
<div className="fixed top-0 left-0 w-full h-full -z-10">
|
||||||
|
<Background />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="fixed top-0 left-0 right-0 z-30">
|
||||||
|
<Navbar />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<main className="flex-grow text-white px-6 pt-16 mt-0 mb-20 flex items-center justify-center">
|
||||||
|
<section
|
||||||
|
ref={sectionRef}
|
||||||
|
className={`w-full max-w-3xl rounded-2xl p-8 md:p-10 transition-all duration-1000 ease-out backdrop-blur-md shadow-2xl ${
|
||||||
|
visible ? "opacity-100 translate-y-0" : "opacity-0 translate-y-10"
|
||||||
|
}`}
|
||||||
|
style={{ background: "rgba(0,0,0,0.25)" }}
|
||||||
|
>
|
||||||
|
<h1 className="text-4xl md:text-5xl font-extrabold text-green-300 mb-4 text-center tracking-wide drop-shadow-lg">
|
||||||
|
{user} Lobby-ja
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<p className="text-lg text-zinc-300 mb-8 text-center">
|
||||||
|
Játékosok, akik csatlakoztak ehhez a szobához:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div className="bg-zinc-800/90 rounded-xl shadow-lg p-6 mb-8">
|
||||||
|
<ul className="flex flex-col gap-4">
|
||||||
|
<li className="bg-zinc-700 py-3 px-4 rounded-xl text-green-400 font-semibold flex items-center gap-4 shadow hover:shadow-green-500/20 transition">
|
||||||
|
<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)" }}
|
||||||
|
>
|
||||||
|
{getInitials(user)}
|
||||||
|
</div>
|
||||||
|
<span className="text-white text-lg">{user}</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex justify-center">
|
||||||
|
<button
|
||||||
|
onClick={handleExit}
|
||||||
|
className="bg-gradient-to-r from-green-700 to-green-500 hover:from-green-600 hover:to-green-400 text-white px-8 py-3 rounded-xl font-semibold shadow-lg hover:shadow-green-400/30 transition-transform transform hover:scale-105"
|
||||||
|
>
|
||||||
|
Kilépés
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Lobby
|
||||||
Reference in New Issue
Block a user