- {cardData.type === 'task' && '📋'}
- {cardData.type === 'joker' && '🃏'}
- {cardData.type === 'luck' && '🎲'}
+ {cardData.type === 'QUESTION' && '📋'}
+ {cardData.type === 'JOKER' && '🃏'}
+ {cardData.type === 'LUCK' && '🎲'}
{isCreating ? 'Új' : 'Szerkesztés'} {' '}
- {cardData.type === 'task' && 'Feladat kártya'}
- {cardData.type === 'joker' && 'Joker kártya'}
- {cardData.type === 'luck' && 'Szerencse kártya'}
+ {cardData.type === 'QUESTION' && 'Feladat kártya'}
+ {cardData.type === 'JOKER' && 'Joker kártya'}
+ {cardData.type === 'LUCK' && 'Szerencse kártya'}
- {cardData.type === 'task' && cardData.subType && (
+ {cardData.type === 'QUESTION' && cardData.subType && (
<>
{cardData.subType === 'quiz' && 'Quiz (A/B/C/D)'}
{cardData.subType === 'truefalse' && 'Igaz/Hamis'}
@@ -196,21 +196,21 @@ export default function CardEditor({ card, isCreating, cardType, onSave, onCance
) : (
/* Edit Mode */
- {cardData.type === 'task' && (
+ {cardData.type === 'QUESTION' && (
)}
- {cardData.type === 'joker' && (
+ {cardData.type === 'JOKER' && (
)}
- {cardData.type === 'luck' && (
+ {cardData.type === 'LUCK' && (
{
- if (card.type === 'task') {
+ if (card.type === 'QUESTION') {
return card.question || card.statement || 'Új feladat kártya'
}
- if (card.type === 'joker') {
+ if (card.type === 'JOKER') {
return card.text || 'Új joker kártya'
}
- if (card.type === 'luck') {
+ if (card.type === 'LUCK') {
return card.text || 'Új szerencse kártya'
}
return 'Ismeretlen kártya'
}
const getCardTypeLabel = (card) => {
- if (card.type === 'task') {
+ if (card.type === 'QUESTION') {
if (card.subType) {
return cardSubTypeLabels[card.subType] || 'Feladat'
}
return 'Feladat'
}
- if (card.type === 'joker') {
+ if (card.type === 'JOKER') {
return 'Joker'
}
- if (card.type === 'luck') {
+ if (card.type === 'LUCK') {
return 'Szerencse'
}
return 'Ismeretlen'
@@ -64,40 +65,18 @@ export default function CardsList({
🃏 Kártyák
- {/* New Card Dropdown */}
-
-
-
- {/* Dropdown Menu */}
-
-
-
-
-
-
-
-
+ {/* New Card Button */}
+
{/* Cards List */}
@@ -218,9 +197,9 @@ export default function CardsList({
{cards.length > 0 && (
- 📋 {cards.filter(c => c.type === 'task').length}
- 🃏 {cards.filter(c => c.type === 'joker').length}
- 🎲 {cards.filter(c => c.type === 'luck').length}
+ 📋 {cards.filter(c => c.type === 'QUESTION').length}
+ 🃏 {cards.filter(c => c.type === 'JOKER').length}
+ 🎲 {cards.filter(c => c.type === 'LUCK').length}
)}
diff --git a/SerpentRace_Frontend/src/components/DeckCreator/DeckHeader.jsx b/SerpentRace_Frontend/src/components/DeckCreator/DeckHeader.jsx
index a0f65d2a..79dda370 100644
--- a/SerpentRace_Frontend/src/components/DeckCreator/DeckHeader.jsx
+++ b/SerpentRace_Frontend/src/components/DeckCreator/DeckHeader.jsx
@@ -5,9 +5,9 @@ import React, { useState, useRef, useEffect } from "react"
import { FaSave, FaArrowLeft, FaGlobe, FaLock, FaQuestionCircle, FaDice, FaLaughBeam } from "react-icons/fa"
const deckTypes = [
- { value: "Question", label: "Kérdés", icon: FaQuestionCircle, color: "var(--color-question)" },
- { value: "Luck", label: "Szerencse", icon: FaDice, color: "var(--color-luck)" },
- { value: "Fun", label: "Szórakozás", icon: FaLaughBeam, color: "var(--color-fun)" }
+ { value: "QUESTION", label: "Kérdés", icon: FaQuestionCircle, color: "var(--color-question)" },
+ { value: "LUCK", label: "Szerencse", icon: FaDice, color: "var(--color-luck)" },
+ { value: "JOKER", label: "Szórakozás", icon: FaLaughBeam, color: "var(--color-fun)" }
]
const privacyOptions = [
diff --git a/SerpentRace_Frontend/src/components/DeckCreator/JokerCardEditor.jsx b/SerpentRace_Frontend/src/components/DeckCreator/JokerCardEditor.jsx
index c902cade..3d23a1af 100644
--- a/SerpentRace_Frontend/src/components/DeckCreator/JokerCardEditor.jsx
+++ b/SerpentRace_Frontend/src/components/DeckCreator/JokerCardEditor.jsx
@@ -6,14 +6,14 @@ import { FaTheaterMasks, FaInfoCircle, FaUsers } from 'react-icons/fa'
export default function JokerCardEditor({ card, onChange }) {
const [cardData, setCardData] = useState({
- type: 'joker',
+ type: 'JOKER',
text: ''
})
useEffect(() => {
if (card) {
setCardData({
- type: 'joker',
+ type: 'JOKER',
text: card.text || ''
})
}
diff --git a/SerpentRace_Frontend/src/components/DeckCreator/LuckCardEditor.jsx b/SerpentRace_Frontend/src/components/DeckCreator/LuckCardEditor.jsx
index e1edd2b6..f0dbb093 100644
--- a/SerpentRace_Frontend/src/components/DeckCreator/LuckCardEditor.jsx
+++ b/SerpentRace_Frontend/src/components/DeckCreator/LuckCardEditor.jsx
@@ -6,14 +6,14 @@ import { FaDice, FaInfoCircle } from 'react-icons/fa'
export default function LuckCardEditor({ card, onChange }) {
const [cardData, setCardData] = useState({
- type: 'luck',
+ type: 'LUCK',
text: ''
})
useEffect(() => {
if (card) {
setCardData({
- type: 'luck',
+ type: 'LUCK',
text: card.text || ''
})
}
diff --git a/SerpentRace_Frontend/src/pages/DeckCreator/DeckCreator.jsx b/SerpentRace_Frontend/src/pages/DeckCreator/DeckCreator.jsx
index 60c13986..396c1dd7 100644
--- a/SerpentRace_Frontend/src/pages/DeckCreator/DeckCreator.jsx
+++ b/SerpentRace_Frontend/src/pages/DeckCreator/DeckCreator.jsx
@@ -17,7 +17,7 @@ export default function DeckCreator() {
const [deck, setDeck] = useState({
id: null,
name: "Új Pakli",
- type: "Question", // Question, Luck, Fun
+ type: "QUESTION", // QUESTION, LUCK, JOKER - backend formátum
privacy: "private", // private, public
description: "",
cards: []
@@ -26,19 +26,18 @@ export default function DeckCreator() {
// UI állapotok
const [selectedCard, setSelectedCard] = useState(null)
const [isCreatingCard, setIsCreatingCard] = useState(false)
- const [newCardType, setNewCardType] = useState(null) // task, joker, luck
+ const [newCardType, setNewCardType] = useState(null)
- // Betöltés (később API-ból)
+ // Betöltés API-ból
useEffect(() => {
if (deckId) {
// TODO: Betöltés API-ból
- loadDeck(deckId)
} else {
// Új deck
setDeck({
id: null,
name: "Új Pakli",
- type: "Question",
+ type: "QUESTION",
privacy: "private",
description: "",
cards: []
@@ -46,60 +45,27 @@ export default function DeckCreator() {
}
}, [deckId])
- const loadDeck = async (id) => {
- // Mock deck betöltés
- const mockDeck = {
- id: id,
- name: "Quiz Night",
- type: "Question",
- privacy: "public",
- description: "Szórakoztató kvíz este",
- cards: [
- {
- id: 1,
- type: "task",
- subType: "quiz",
- question: "Mi Magyarország fővárosa?",
- options: ["Budapest", "Debrecen", "Szeged", "Pécs"],
- correctAnswer: 0,
- points: 10,
- timeLimit: 30,
- explanation: "Budapest 1873 óta Magyarország fővárosa."
- },
- {
- id: 2,
- type: "task",
- subType: "truefalse",
- statement: "A Duna Magyarország leghosszabb folyója.",
- isTrue: false,
- points: 5,
- timeLimit: 15,
- explanation: "A Tisza a leghosszabb folyó Magyarországon."
- }
- ]
- }
- setDeck(mockDeck)
- }
-
const handleDeckUpdate = (updates) => {
setDeck(prev => ({ ...prev, ...updates }))
}
const handleSaveDeck = async () => {
try {
- console.log("Deck mentése:", deck)
-
const payload = {
name: deck.name,
- type: (deck.type || 'Question').toString().toUpperCase(),
+ type: deck.type,
ctype: deck.privacy === 'public' ? 'PUBLIC' : 'PRIVATE',
description: deck.description || '',
- cards: deck.cards.map(c => ({ ...c, text: c.question || c.statement || c.text || '' }))
+ cards: deck.cards
}
const saved = await createDeck(payload)
- setDeck(prev => ({ ...prev, id: saved.id ?? prev.id, creationdate: saved.creationdate ?? prev.creationdate, updatedate: saved.updatedate ?? prev.updatedate }))
- console.log('Deck saved (backend):', saved)
+ setDeck(prev => ({
+ ...prev,
+ id: saved.id ?? prev.id,
+ creationdate: saved.creationdate ?? prev.creationdate,
+ updatedate: saved.updatedate ?? prev.updatedate
+ }))
alert('✅ Deck sikeresen mentve!')
} catch (error) {
console.error('Mentési hiba:', error)
@@ -126,29 +92,21 @@ export default function DeckCreator() {
}
const handleSaveCard = (cardData) => {
- if (isCreatingCard) {
- // Új kártya hozzáadása
- const newCard = {
- ...cardData,
- id: Date.now(), // Temporary ID
- }
- setDeck(prev => ({
- ...prev,
- cards: [...prev.cards, newCard]
- }))
- setIsCreatingCard(false)
- setNewCardType(null)
- setSelectedCard(newCard)
- } else {
- // Meglévő kártya frissítése
- setDeck(prev => ({
- ...prev,
- cards: prev.cards.map(card =>
- card.id === cardData.id ? cardData : card
- )
- }))
- setSelectedCard(cardData)
+ const updatedCard = {
+ ...cardData,
+ id: isCreatingCard ? Date.now() : cardData.id
}
+
+ setDeck(prev => ({
+ ...prev,
+ cards: isCreatingCard
+ ? [...prev.cards, updatedCard]
+ : prev.cards.map(card => card.id === updatedCard.id ? updatedCard : card)
+ }))
+
+ setSelectedCard(updatedCard)
+ setIsCreatingCard(false)
+ setNewCardType(null)
}
const handleDeleteCard = (cardId) => {
@@ -184,6 +142,7 @@ export default function DeckCreator() {