import React, { useEffect } from "react" import { useNavigate } from "react-router-dom" import { FaUser, FaLock, FaGlobe, FaTags, FaCalendarAlt, FaQuestionCircle, FaComment, FaTimes, FaEdit } from "react-icons/fa" export default function DeckInfoPopUp({ deck, onClose }) { const navigate = useNavigate() if (!deck) return null // Debug: Log the deck structure to see what we're working with console.log('Deck in popup:', deck) console.log('Raw deck data:', deck.raw) // Scroll blokkolás amikor a popup nyitva van useEffect(() => { // Scroll letiltása document.body.style.overflow = 'hidden' // Cleanup function - scroll visszaállítása amikor a komponens unmount-ol return () => { document.body.style.overflow = 'unset' } }, []) // Backend enum mapping const deckTypeMapping = { 0: { label: "Szerencse", color: "var(--color-luck)" }, // LUCK 1: { label: "Joker", color: "var(--color-fun)" }, // JOKER 2: { label: "Kérdés", color: "var(--color-question)" } // QUESTION } const ctypeMapping = { 0: "Publikus", // PUBLIC 1: "Privát", // PRIVATE 2: "Vállalati" // ORGANIZATION } const stateMapping = { 0: "Aktív", // ACTIVE 1: "Törölt" // SOFT_DELETE } // Get data from raw (backend data) const rawData = deck.raw || deck // Type info const deckTypeInfo = deckTypeMapping[rawData.type] || { label: "Ismeretlen", color: "var(--color-success)" } // Privacy/CType const privacy = ctypeMapping[rawData.ctype] || "Ismeretlen" // State const state = stateMapping[rawData.state] || "Ismeretlen" // Creator const creator = rawData.user?.name || rawData.creatorName || rawData.creator || "Ismeretlen" // Card count const cardCount = rawData.cardCount || 0 // Played count const playedNumber = rawData.playedNumber || 0 console.log('Mapped data:', { type: rawData.type, deckTypeInfo, ctype: rawData.ctype, privacy, state, cardCount, playedNumber }) const mockData = { name: rawData.name || deck.name || "Névtelen pakli", creator, privacy, state, questionsCount: cardCount, answersCount: playedNumber, created: rawData.creationdate || rawData.created || deck.created || new Date().toISOString(), description: rawData.description || "" } const formatDate = (dateString) => { try { const date = new Date(dateString) return date.toLocaleDateString('hu-HU', { year: 'numeric', month: 'long', day: 'numeric' }) } catch (e) { return dateString } } const handleOpenDeck = () => { // TODO: Megnyitás funkció - később implementálható alert("⚠️ A pakli megnyitás funkció még fejlesztés alatt áll!") } const handleEditDeck = () => { // Get the deck ID from raw data const deckId = rawData.id || deck.id if (!deckId) { alert("⚠️ Hiba: A pakli azonosítója nem található!") return } // Navigate to deck creator with the deck ID navigate(`/deck-creator/${deckId}`) // Close the popup onClose() } return (
{/* Header with deck type color */}
{/* Close button */}
{/* Deck name and type */}

{mockData.name}

{deckTypeInfo.label}
{mockData.description && (

{mockData.description}

)}
{/* Data grid */}
{/* Creator */}
Létrehozó
{mockData.creator}
{/* Privacy */}
{mockData.privacy === "Privát" ? ( ) : ( )}
Láthatóság
{mockData.privacy}
{/* Type */}
Típus
{deckTypeInfo.label}
{/* Date */}
Létrehozás dátuma
{formatDate(mockData.created)}
{/* Questions and Answers in one row */}
{/* Card Count (Kártyák) */}
Kártyák
{mockData.questionsCount}
{/* Played Count (Játszva) */}
Játszva
{mockData.answersCount}×
{/* Action buttons */}
{/* Open button */} {/* Edit button */}
) }