fix: Consequence kezelés és deck szerkesztés javítások
- TaskCardEditor és JokerCardEditor: consequence mezők eltávolítása (csak LuckCardEditor-nél marad) - DeckCreator: kártya type konverzió javítása betöltéskor (szám -> string) - DeckCreator: csak megfelelő típusú kártyák megtartása mentéskor - UpdateDeckCommandHandler: userstate -> authLevel javítás (interface mező helyesen) - sql_schema_only.sql: trigger függvény javítása (NEW.updatedate -> NEW.update_date)
This commit is contained in:
@@ -4,29 +4,17 @@
|
||||
import React, { useState, useEffect } from 'react'
|
||||
import { FaTheaterMasks, FaInfoCircle, FaUsers } from 'react-icons/fa'
|
||||
|
||||
const consequenceTypes = [
|
||||
{ value: 0, label: '⬆️ Előre lépés', description: 'A játékos előre lép X mezőt' },
|
||||
{ value: 1, label: '⬇️ Hátra lépés', description: 'A játékos hátra lép X mezőt' },
|
||||
{ value: 2, label: '⏸️ Kör kihagyás', description: 'A játékos kihagy egy kört' },
|
||||
{ value: 3, label: '⏩ Extra kör', description: 'A játékos kap egy extra kört' },
|
||||
{ value: 5, label: '🏁 Vissza a starthoz', description: 'A játékos visszakerül a starthoz' }
|
||||
]
|
||||
|
||||
export default function JokerCardEditor({ card, onChange }) {
|
||||
const [cardData, setCardData] = useState({
|
||||
type: 'JOKER',
|
||||
text: '',
|
||||
consequence: { type: 0, value: 1 },
|
||||
wrongConsequence: { type: 1, value: 1 }
|
||||
text: ''
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (card) {
|
||||
setCardData({
|
||||
type: 'JOKER',
|
||||
text: card.text || '',
|
||||
consequence: card.consequence || { type: 0, value: 1 },
|
||||
wrongConsequence: card.wrongConsequence || { type: 1, value: 1 }
|
||||
text: card.text || ''
|
||||
})
|
||||
}
|
||||
}, [card])
|
||||
@@ -43,36 +31,6 @@ export default function JokerCardEditor({ card, onChange }) {
|
||||
}
|
||||
}
|
||||
|
||||
const updateConsequence = (field, value) => {
|
||||
const newCardData = {
|
||||
...cardData,
|
||||
consequence: {
|
||||
...cardData.consequence,
|
||||
[field]: value
|
||||
}
|
||||
}
|
||||
setCardData(newCardData)
|
||||
|
||||
if (onChange) {
|
||||
onChange(newCardData)
|
||||
}
|
||||
}
|
||||
|
||||
const updateWrongConsequence = (field, value) => {
|
||||
const newCardData = {
|
||||
...cardData,
|
||||
wrongConsequence: {
|
||||
...cardData.wrongConsequence,
|
||||
[field]: value
|
||||
}
|
||||
}
|
||||
setCardData(newCardData)
|
||||
|
||||
if (onChange) {
|
||||
onChange(newCardData)
|
||||
}
|
||||
}
|
||||
|
||||
// Példa joker kártyák
|
||||
const exampleCards = [
|
||||
"Felelsz vagy mersz? (Az előző játékos kérdez)",
|
||||
@@ -186,100 +144,6 @@ export default function JokerCardEditor({ card, onChange }) {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Következmények (teljesítés esetén) */}
|
||||
<div className="bg-[color:var(--color-surface)] rounded-xl p-6">
|
||||
<h3 className="text-lg font-semibold text-[color:var(--color-text)] mb-4">
|
||||
🎯 Következmények (teljesítés esetén)
|
||||
</h3>
|
||||
|
||||
<div className="space-y-4">
|
||||
{/* Consequence Type */}
|
||||
<div>
|
||||
<label className="block text-[color:var(--color-text-muted)] text-sm font-medium mb-2">
|
||||
Hatás típusa
|
||||
</label>
|
||||
<select
|
||||
value={cardData.consequence?.type ?? 0}
|
||||
onChange={(e) => updateConsequence('type', parseInt(e.target.value))}
|
||||
className="w-full px-4 py-2 rounded-xl bg-[color:var(--color-background)] border border-[color:var(--color-surface-selected)] text-[color:var(--color-text)] focus:ring-2 focus:ring-[color:var(--color-success)] focus:border-transparent outline-none transition-all duration-200"
|
||||
>
|
||||
{consequenceTypes.map(type => (
|
||||
<option key={type.value} value={type.value}>
|
||||
{type.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="text-xs text-[color:var(--color-text-muted)] mt-1">
|
||||
{consequenceTypes.find(t => t.value === (cardData.consequence?.type ?? 0))?.description}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Consequence Value - csak ha előre/hátra lépés */}
|
||||
{(cardData.consequence?.type === 0 || cardData.consequence?.type === 1) && (
|
||||
<div>
|
||||
<label className="block text-[color:var(--color-text-muted)] text-sm font-medium mb-2">
|
||||
Mezők száma
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
value={cardData.consequence?.value ?? 1}
|
||||
onChange={(e) => updateConsequence('value', parseInt(e.target.value) || 1)}
|
||||
className="w-full px-4 py-2 rounded-xl bg-[color:var(--color-background)] border border-[color:var(--color-surface-selected)] text-[color:var(--color-text)] focus:ring-2 focus:ring-[color:var(--color-success)] focus:border-transparent outline-none transition-all duration-200"
|
||||
min="1"
|
||||
max="10"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Következmények (nem teljesítés esetén) */}
|
||||
<div className="bg-[color:var(--color-surface)] rounded-xl p-6">
|
||||
<h3 className="text-lg font-semibold text-[color:var(--color-text)] mb-4">
|
||||
❌ Következmények (nem teljesítés esetén)
|
||||
</h3>
|
||||
|
||||
<div className="space-y-4">
|
||||
{/* Wrong Consequence Type */}
|
||||
<div>
|
||||
<label className="block text-[color:var(--color-text-muted)] text-sm font-medium mb-2">
|
||||
Hatás típusa
|
||||
</label>
|
||||
<select
|
||||
value={cardData.wrongConsequence?.type ?? 1}
|
||||
onChange={(e) => updateWrongConsequence('type', parseInt(e.target.value))}
|
||||
className="w-full px-4 py-2 rounded-xl bg-[color:var(--color-background)] border border-[color:var(--color-surface-selected)] text-[color:var(--color-text)] focus:ring-2 focus:ring-[color:var(--color-danger)] focus:border-transparent outline-none transition-all duration-200"
|
||||
>
|
||||
{consequenceTypes.map(type => (
|
||||
<option key={type.value} value={type.value}>
|
||||
{type.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="text-xs text-[color:var(--color-text-muted)] mt-1">
|
||||
{consequenceTypes.find(t => t.value === (cardData.wrongConsequence?.type ?? 1))?.description}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Wrong Consequence Value - csak ha előre/hátra lépés */}
|
||||
{(cardData.wrongConsequence?.type === 0 || cardData.wrongConsequence?.type === 1) && (
|
||||
<div>
|
||||
<label className="block text-[color:var(--color-text-muted)] text-sm font-medium mb-2">
|
||||
Mezők száma
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
value={cardData.wrongConsequence?.value ?? 1}
|
||||
onChange={(e) => updateWrongConsequence('value', parseInt(e.target.value) || 1)}
|
||||
className="w-full px-4 py-2 rounded-xl bg-[color:var(--color-background)] border border-[color:var(--color-surface-selected)] text-[color:var(--color-text)] focus:ring-2 focus:ring-[color:var(--color-danger)] focus:border-transparent outline-none transition-all duration-200"
|
||||
min="1"
|
||||
max="10"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -20,14 +20,6 @@ const timeLimits = [
|
||||
{ value: 120, label: '2 perc' }
|
||||
]
|
||||
|
||||
const consequenceTypes = [
|
||||
{ value: 0, label: '⬆️ Előre lépés', description: 'A játékos előre lép X mezőt' },
|
||||
{ value: 1, label: '⬇️ Hátra lépés', description: 'A játékos hátra lép X mezőt' },
|
||||
{ value: 2, label: '⏸️ Kör kihagyás', description: 'A játékos kihagy egy kört' },
|
||||
{ value: 3, label: '⏩ Extra kör', description: 'A játékos kap egy extra kört' },
|
||||
{ value: 5, label: '🏁 Vissza a starthoz', description: 'A játékos visszakerül a starthoz' }
|
||||
]
|
||||
|
||||
export default function TaskCardEditor({ card, onChange }) {
|
||||
|
||||
const updateField = (field, value) => {
|
||||
@@ -92,26 +84,6 @@ export default function TaskCardEditor({ card, onChange }) {
|
||||
onChange({ acceptedAnswers: newAnswers })
|
||||
}
|
||||
|
||||
const updateConsequence = (field, value) => {
|
||||
const currentConsequence = card.consequence || { type: 0, value: 1 }
|
||||
onChange({
|
||||
consequence: {
|
||||
...currentConsequence,
|
||||
[field]: value
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const updateWrongConsequence = (field, value) => {
|
||||
const currentWrongConsequence = card.wrongConsequence || { type: 1, value: 1 }
|
||||
onChange({
|
||||
wrongConsequence: {
|
||||
...currentWrongConsequence,
|
||||
[field]: value
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto space-y-6">
|
||||
{/* Feladat típus választó */}
|
||||
@@ -544,100 +516,6 @@ export default function TaskCardEditor({ card, onChange }) {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Következmények (helyes válasz esetén) */}
|
||||
<div className="bg-[color:var(--color-surface)] rounded-xl p-6">
|
||||
<h3 className="text-lg font-semibold text-[color:var(--color-text)] mb-4">
|
||||
🎯 Következmények (helyes válasz esetén)
|
||||
</h3>
|
||||
|
||||
<div className="space-y-4">
|
||||
{/* Consequence Type */}
|
||||
<div>
|
||||
<label className="block text-[color:var(--color-text-muted)] text-sm font-medium mb-2">
|
||||
Hatás típusa
|
||||
</label>
|
||||
<select
|
||||
value={card.consequence?.type ?? 0}
|
||||
onChange={(e) => updateConsequence('type', parseInt(e.target.value))}
|
||||
className="w-full px-4 py-2 rounded-xl bg-[color:var(--color-background)] border border-[color:var(--color-surface-selected)] text-[color:var(--color-text)] focus:ring-2 focus:ring-[color:var(--color-success)] focus:border-transparent outline-none transition-all duration-200"
|
||||
>
|
||||
{consequenceTypes.map(type => (
|
||||
<option key={type.value} value={type.value}>
|
||||
{type.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="text-xs text-[color:var(--color-text-muted)] mt-1">
|
||||
{consequenceTypes.find(t => t.value === (card.consequence?.type ?? 0))?.description}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Consequence Value - csak ha előre/hátra lépés */}
|
||||
{(card.consequence?.type === 0 || card.consequence?.type === 1) && (
|
||||
<div>
|
||||
<label className="block text-[color:var(--color-text-muted)] text-sm font-medium mb-2">
|
||||
Mezők száma
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
value={card.consequence?.value ?? 1}
|
||||
onChange={(e) => updateConsequence('value', parseInt(e.target.value) || 1)}
|
||||
className="w-full px-4 py-2 rounded-xl bg-[color:var(--color-background)] border border-[color:var(--color-surface-selected)] text-[color:var(--color-text)] focus:ring-2 focus:ring-[color:var(--color-success)] focus:border-transparent outline-none transition-all duration-200"
|
||||
min="1"
|
||||
max="10"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Következmények (rossz válasz esetén) */}
|
||||
<div className="bg-[color:var(--color-surface)] rounded-xl p-6">
|
||||
<h3 className="text-lg font-semibold text-[color:var(--color-text)] mb-4">
|
||||
❌ Következmények (rossz válasz esetén)
|
||||
</h3>
|
||||
|
||||
<div className="space-y-4">
|
||||
{/* Wrong Consequence Type */}
|
||||
<div>
|
||||
<label className="block text-[color:var(--color-text-muted)] text-sm font-medium mb-2">
|
||||
Hatás típusa
|
||||
</label>
|
||||
<select
|
||||
value={card.wrongConsequence?.type ?? 1}
|
||||
onChange={(e) => updateWrongConsequence('type', parseInt(e.target.value))}
|
||||
className="w-full px-4 py-2 rounded-xl bg-[color:var(--color-background)] border border-[color:var(--color-surface-selected)] text-[color:var(--color-text)] focus:ring-2 focus:ring-[color:var(--color-danger)] focus:border-transparent outline-none transition-all duration-200"
|
||||
>
|
||||
{consequenceTypes.map(type => (
|
||||
<option key={type.value} value={type.value}>
|
||||
{type.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="text-xs text-[color:var(--color-text-muted)] mt-1">
|
||||
{consequenceTypes.find(t => t.value === (card.wrongConsequence?.type ?? 1))?.description}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Wrong Consequence Value - csak ha előre/hátra lépés */}
|
||||
{(card.wrongConsequence?.type === 0 || card.wrongConsequence?.type === 1) && (
|
||||
<div>
|
||||
<label className="block text-[color:var(--color-text-muted)] text-sm font-medium mb-2">
|
||||
Mezők száma
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
value={card.wrongConsequence?.value ?? 1}
|
||||
onChange={(e) => updateWrongConsequence('value', parseInt(e.target.value) || 1)}
|
||||
className="w-full px-4 py-2 rounded-xl bg-[color:var(--color-background)] border border-[color:var(--color-surface-selected)] text-[color:var(--color-text)] focus:ring-2 focus:ring-[color:var(--color-danger)] focus:border-transparent outline-none transition-all duration-200"
|
||||
min="1"
|
||||
max="10"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user