// src/components/DeckCreator/CardsList.jsx
// Bal oldali kártyák listája és új kártya létrehozás
import React, { useState } from "react"
import {
FaPlus,
FaEdit,
FaTrash,
FaQuestionCircle,
FaCheck,
FaTimes,
FaDice,
FaTheaterMasks
} from "react-icons/fa"
import { notifySuccess, notifyError } from "../../components/Toastify/toastifyServices"
const cardTypeIcons = {
QUESTION: { icon: FaQuestionCircle, color: "var(--color-question)" },
JOKER: { icon: FaTheaterMasks, color: "var(--color-fun)" },
LUCK: { icon: FaDice, color: "var(--color-luck)" }
}
const cardSubTypeLabels = {
quiz: "Quiz",
truefalse: "Igaz/Hamis",
matching: "Párosítás",
text: "Szöveges válasz"
}
export default function CardsList({
cards,
selectedCard,
deckType,
onSelectCard,
onCreateCard,
onDeleteCard,
isCreatingCard,
newCardType
}) {
const [confirmingDelete, setConfirmingDelete] = useState(null)
const getCardPreview = (card) => {
if (card.type === 'QUESTION') {
return card.question || card.statement || 'Új feladat kártya'
}
if (card.type === 'JOKER') {
return card.text || 'Új joker kártya'
}
if (card.type === 'LUCK') {
return card.text || 'Új szerencse kártya'
}
return "Ismeretlen kártya"
}
const getCardTypeLabel = (card) => {
if (card.type === 'QUESTION') {
if (card.subType) {
return cardSubTypeLabels[card.subType] || "Feladat"
}
return "Feladat"
}
if (card.type === 'JOKER') {
return 'Joker'
}
if (card.type === 'LUCK') {
return 'Szerencse'
}
return "Ismeretlen"
}
const handleConfirmDelete = () => {
if (confirmingDelete) {
onDeleteCard(confirmingDelete)
notifySuccess("Kártya sikeresen törölve a pakliból!")
setConfirmingDelete(null)
}
}
const handleCancelDelete = () => {
setConfirmingDelete(null)
}
return (
{/* Header */}
🃏 Kártyák
{/* New Card Button */}
{/* Cards List */}
{/* Creating Card Indicator */}
{isCreatingCard && (
{newCardType && (
{React.createElement(cardTypeIcons[newCardType]?.icon || FaQuestionCircle, {
className: "text-[color:var(--color-success)] text-sm"
})}
)}
Új {newCardType === "QUESTION" ? "feladat" : newCardType === "JOKER" ? "joker" : "szerencse"} kártya
Szerkesztés folyamatban...
)}
{/* Existing Cards */}
{cards.map((card, index) => {
const cardIcon = cardTypeIcons[card.type] || cardTypeIcons.task
const isSelected = selectedCard?.id === card.id
return (
onSelectCard(card)}
className={`
p-4 rounded-xl border cursor-pointer transition-all duration-200 hover:scale-105 group relative
${
isSelected
? "bg-[color:var(--color-success)]/10 border-[color:var(--color-success)] shadow-lg"
: "bg-[color:var(--color-background)]/50 border-[color:var(--color-surface-selected)] hover:bg-[color:var(--color-background)]/80"
}
${card.type !== deckType ? "opacity-70" : ""}
`}
>
{card.type !== deckType && (
)}
{/* Card Header */}
{React.createElement(cardIcon.icon, {
style: { color: cardIcon.color },
className: "text-lg"
})}
#{index + 1} - {getCardTypeLabel(card)}
{card.timeLimit && (
⏱️ {card.timeLimit} másodperc
)}
{/* Action Buttons */}
{/* Card Content Preview */}
)
})}
{/* Empty State */}
{cards.length === 0 && !isCreatingCard && (
🃏
Még nincsenek kártyák.
Hozz létre az első kártyát!
)}
{/* Confirm Delete Popup */}
{confirmingDelete && (
Biztosan törölni szeretnéd?
Ez a művelet nem visszavonható.
)}
{/* Footer Stats */}
📊 Összesen: {cards.length} kártya
)
}