deckcreate-oldal-javitas #62
@@ -16,6 +16,9 @@ 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"
|
import Lobby from "./pages/Lobby/Lobby"
|
||||||
|
import { ToastConfig } from "./components/Toastify/toastifyServices" // ✅ fontos: named import, nem default!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [isMobile, setIsMobile] = useState(false)
|
const [isMobile, setIsMobile] = useState(false)
|
||||||
@@ -44,28 +47,31 @@ function App() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Router>
|
<>
|
||||||
<Routes>
|
<Router>
|
||||||
<Route path="/about" element={<About />} />
|
<Routes>
|
||||||
<Route path="/lobby" element={<Lobby />} />
|
<Route path="/about" element={<About />} />
|
||||||
<Route path="/register" element={<AuthRegister />} />
|
<Route path="/lobby" element={<Lobby />} />
|
||||||
<Route path="/login" element={<AuthLogin />} />
|
<Route path="/register" element={<AuthRegister />} />
|
||||||
<Route path="/verify-email" element={<EmailVerification />} />
|
<Route path="/login" element={<AuthLogin />} />
|
||||||
<Route path="/forgot-password" element={<ForgotPassword />} />
|
<Route path="/verify-email" element={<EmailVerification />} />
|
||||||
<Route path="/reset-password" element={<ResetPassword />} />
|
<Route path="/forgot-password" element={<ForgotPassword />} />
|
||||||
<Route path="/test" element={<Test />} />
|
<Route path="/reset-password" element={<ResetPassword />} />
|
||||||
<Route path="/" element={<Landingpage />} />
|
<Route path="/test" element={<Test />} />
|
||||||
<Route path="/home" element={<Home />} />
|
<Route path="/" element={<Landingpage />} />
|
||||||
<Route path="/decks" element={<DeckManagerPage />} />
|
<Route path="/home" element={<Home />} />
|
||||||
<Route path="/deck-creator" element={<DeckCreator />} />
|
<Route path="/decks" element={<DeckManagerPage />} />
|
||||||
<Route path="/deck-creator/:deckId" element={<DeckCreator />} />
|
<Route path="/deck-creator" element={<DeckCreator />} />
|
||||||
<Route path="/game" element={<GameScreen />} />
|
<Route path="/deck-creator/:deckId" element={<DeckCreator />} />
|
||||||
<Route path="/companies" element={<CompanyHub />} />
|
<Route path="/game" element={<GameScreen />} />
|
||||||
<Route path="/report" element={<Reports />} />
|
<Route path="/companies" element={<CompanyHub />} />
|
||||||
|
<Route path="/report" element={<Reports />} />
|
||||||
|
</Routes>
|
||||||
|
</Router>
|
||||||
|
|
||||||
{/* Add more routes as needed */}
|
{/* ✅ Toastify Container */}
|
||||||
</Routes>
|
<ToastConfig />
|
||||||
</Router>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import TaskCardEditor from "./TaskCardEditor.jsx"
|
|||||||
import JokerCardEditor from "./JokerCardEditor.jsx"
|
import JokerCardEditor from "./JokerCardEditor.jsx"
|
||||||
import LuckCardEditor from "./LuckCardEditor.jsx"
|
import LuckCardEditor from "./LuckCardEditor.jsx"
|
||||||
import CardPreview from "./CardPreview.jsx"
|
import CardPreview from "./CardPreview.jsx"
|
||||||
|
import { notifySuccess, notifyError,notifyWarning } from "../../components/Toastify/toastifyServices"
|
||||||
|
|
||||||
|
|
||||||
export default function CardEditor({ card, isCreating, cardType, onSave, onCancel }) {
|
export default function CardEditor({ card, isCreating, cardType, onSave, onCancel }) {
|
||||||
const [cardData, setCardData] = useState(null)
|
const [cardData, setCardData] = useState(null)
|
||||||
@@ -65,33 +67,24 @@ export default function CardEditor({ card, isCreating, cardType, onSave, onCance
|
|||||||
}
|
}
|
||||||
}, [card, isCreating, cardType])
|
}, [card, isCreating, cardType])
|
||||||
|
|
||||||
const handleSave = () => {
|
|
||||||
if (!cardData) return
|
|
||||||
|
|
||||||
// Validáció
|
|
||||||
if (!validateCard(cardData)) return
|
|
||||||
|
|
||||||
onSave(cardData)
|
|
||||||
}
|
|
||||||
|
|
||||||
const validateCard = (data) => {
|
const validateCard = (data) => {
|
||||||
if (data.type === 'QUESTION') {
|
if (data.type === 'QUESTION') {
|
||||||
if (!data.question && !data.statement) {
|
if (!data.question && !data.statement) {
|
||||||
alert("❌ Kérdés vagy állítás megadása kötelező!")
|
notifyError("Kérdés vagy állítás megadása kötelező!")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (data.subType === 'quiz' && data.options.some(opt => !opt.trim())) {
|
if (data.subType === 'quiz' && data.options.some(opt => !opt.trim())) {
|
||||||
alert("❌ Minden válaszlehetőséget ki kell tölteni!")
|
notifyError("Minden válaszlehetőséget ki kell tölteni!")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
} else if (data.type === 'JOKER') {
|
} else if (data.type === 'JOKER') {
|
||||||
if (!data.text || !data.text.trim()) {
|
if (!data.text || !data.text.trim()) {
|
||||||
alert("❌ Joker kártya szövege nem lehet üres!")
|
notifyError("Joker kártya szövege nem lehet üres!")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
} else if (data.type === 'LUCK') {
|
} else if (data.type === 'LUCK') {
|
||||||
if (!data.text || !data.text.trim()) {
|
if (!data.text || !data.text.trim()) {
|
||||||
alert("❌ Szerencse kártya szövege nem lehet üres!")
|
notifyError("Szerencse kártya szövege nem lehet üres!")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,6 +96,19 @@ export default function CardEditor({ card, isCreating, cardType, onSave, onCance
|
|||||||
setCardData(prev => prev ? { ...prev, ...updates } : null)
|
setCardData(prev => prev ? { ...prev, ...updates } : null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleSave = () => {
|
||||||
|
if (!cardData) return
|
||||||
|
|
||||||
|
if (!validateCard(cardData)) return
|
||||||
|
|
||||||
|
try {
|
||||||
|
onSave(cardData)
|
||||||
|
notifySuccess('Kártya sikeresen mentve!')
|
||||||
|
} catch (error) {
|
||||||
|
notifyError('Hiba történt a kártya mentése során: ' + (error?.message || String(error)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ha nincs kiválasztott kártya vagy új kártya létrehozás
|
// Ha nincs kiválasztott kártya vagy új kártya létrehozás
|
||||||
if (!cardData) {
|
if (!cardData) {
|
||||||
return (
|
return (
|
||||||
@@ -134,10 +140,17 @@ export default function CardEditor({ card, isCreating, cardType, onSave, onCance
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-xl font-bold text-[color:var(--color-text)]">
|
<h2 className="text-xl font-bold text-[color:var(--color-text)]">
|
||||||
|
<<<<<<< HEAD
|
||||||
{isCreating ? 'Új' : 'Szerkesztés'} {' '}
|
{isCreating ? 'Új' : 'Szerkesztés'} {' '}
|
||||||
{cardData.type === 'QUESTION' && 'Feladat kártya'}
|
{cardData.type === 'QUESTION' && 'Feladat kártya'}
|
||||||
{cardData.type === 'JOKER' && 'Joker kártya'}
|
{cardData.type === 'JOKER' && 'Joker kártya'}
|
||||||
{cardData.type === 'LUCK' && 'Szerencse kártya'}
|
{cardData.type === 'LUCK' && 'Szerencse kártya'}
|
||||||
|
=======
|
||||||
|
{isCreating ? 'Új' : 'Szerkesztés'} {' '}
|
||||||
|
{cardData.type === 'QUESTION' && 'Feladat kártya'}
|
||||||
|
{cardData.type === 'JOKER' && 'Joker kártya'}
|
||||||
|
{cardData.type === 'LUCK' && 'Szerencse kártya'}
|
||||||
|
>>>>>>> main
|
||||||
</h2>
|
</h2>
|
||||||
<div className="text-[color:var(--color-text-muted)] text-sm">
|
<div className="text-[color:var(--color-text-muted)] text-sm">
|
||||||
{cardData.type === 'QUESTION' && cardData.subType && (
|
{cardData.type === 'QUESTION' && cardData.subType && (
|
||||||
@@ -168,12 +181,15 @@ export default function CardEditor({ card, isCreating, cardType, onSave, onCance
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={onCancel}
|
onClick={() => {
|
||||||
className="flex items-center gap-2 px-4 py-2 rounded-xl bg-[color:var(--color-background)] hover:bg-[color:var(--color-surface-selected)] text-[color:var(--color-text)] transition-all duration-200"
|
notifyWarning('Kártya készítés megszakítva')
|
||||||
>
|
onCancel()
|
||||||
<FaTimes />
|
}}
|
||||||
Mégse
|
className="flex items-center gap-2 px-4 py-2 rounded-xl bg-[color:var(--color-background)] hover:bg-[color:var(--color-surface-selected)] text-[color:var(--color-text)] transition-all duration-200"
|
||||||
</button>
|
>
|
||||||
|
<FaTimes />
|
||||||
|
Mégse
|
||||||
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={handleSave}
|
onClick={handleSave}
|
||||||
@@ -189,12 +205,10 @@ export default function CardEditor({ card, isCreating, cardType, onSave, onCance
|
|||||||
{/* Content */}
|
{/* Content */}
|
||||||
<div className="flex-1 overflow-hidden">
|
<div className="flex-1 overflow-hidden">
|
||||||
{showPreview ? (
|
{showPreview ? (
|
||||||
/* Preview Mode */
|
|
||||||
<div className="h-full bg-[color:var(--color-background)] flex items-center justify-center p-6">
|
<div className="h-full bg-[color:var(--color-background)] flex items-center justify-center p-6">
|
||||||
<CardPreview card={cardData} />
|
<CardPreview card={cardData} />
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
/* Edit Mode */
|
|
||||||
<div className="h-full overflow-y-auto p-6">
|
<div className="h-full overflow-y-auto p-6">
|
||||||
{cardData.type === 'QUESTION' && (
|
{cardData.type === 'QUESTION' && (
|
||||||
<TaskCardEditor
|
<TaskCardEditor
|
||||||
|
|||||||
@@ -1,8 +1,18 @@
|
|||||||
// src/components/DeckCreator/CardsList.jsx
|
// src/components/DeckCreator/CardsList.jsx
|
||||||
// Bal oldali kártyák listája és új kártya létrehozás
|
// Bal oldali kártyák listája és új kártya létrehozás
|
||||||
|
|
||||||
import React from "react"
|
import React, { useState } from "react"
|
||||||
import { FaPlus, FaEdit, FaTrash, FaQuestionCircle, FaCheck, FaTimes, FaDice, FaTheaterMasks } from "react-icons/fa"
|
import {
|
||||||
|
FaPlus,
|
||||||
|
FaEdit,
|
||||||
|
FaTrash,
|
||||||
|
FaQuestionCircle,
|
||||||
|
FaCheck,
|
||||||
|
FaTimes,
|
||||||
|
FaDice,
|
||||||
|
FaTheaterMasks
|
||||||
|
} from "react-icons/fa"
|
||||||
|
import { notifySuccess, notifyError } from "../../components/Toastify/toastifyServices"
|
||||||
|
|
||||||
const cardTypeIcons = {
|
const cardTypeIcons = {
|
||||||
QUESTION: { icon: FaQuestionCircle, color: "var(--color-question)" },
|
QUESTION: { icon: FaQuestionCircle, color: "var(--color-question)" },
|
||||||
@@ -17,18 +27,28 @@ const cardSubTypeLabels = {
|
|||||||
text: "Szöveges válasz"
|
text: "Szöveges válasz"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
export default function CardsList({
|
export default function CardsList({
|
||||||
cards,
|
cards,
|
||||||
selectedCard,
|
selectedCard,
|
||||||
deckType,
|
deckType,
|
||||||
onSelectCard,
|
onSelectCard,
|
||||||
onCreateCard,
|
onCreateCard,
|
||||||
|
=======
|
||||||
|
export default function CardsList({
|
||||||
|
cards,
|
||||||
|
selectedCard,
|
||||||
|
onSelectCard,
|
||||||
|
onCreateCard,
|
||||||
|
>>>>>>> main
|
||||||
onDeleteCard,
|
onDeleteCard,
|
||||||
isCreatingCard,
|
isCreatingCard,
|
||||||
newCardType
|
newCardType
|
||||||
}) {
|
}) {
|
||||||
|
const [confirmingDelete, setConfirmingDelete] = useState(null)
|
||||||
|
|
||||||
const getCardPreview = (card) => {
|
const getCardPreview = (card) => {
|
||||||
|
<<<<<<< HEAD
|
||||||
if (card.type === 'QUESTION') {
|
if (card.type === 'QUESTION') {
|
||||||
return card.question || card.statement || 'Új feladat kártya'
|
return card.question || card.statement || 'Új feladat kártya'
|
||||||
}
|
}
|
||||||
@@ -37,34 +57,69 @@ export default function CardsList({
|
|||||||
}
|
}
|
||||||
if (card.type === 'LUCK') {
|
if (card.type === 'LUCK') {
|
||||||
return card.text || 'Új szerencse kártya'
|
return card.text || 'Új szerencse kártya'
|
||||||
|
=======
|
||||||
|
if (card.type === 'QUESTION') {
|
||||||
|
return card.question || card.statement || 'Új feladat kártya'
|
||||||
}
|
}
|
||||||
return 'Ismeretlen kártya'
|
if (card.type === 'JOKER') {
|
||||||
|
return card.text || 'Új joker kártya'
|
||||||
|
}
|
||||||
|
if (card.type === 'LUCK') {
|
||||||
|
return card.text || 'Új szerencse kártya'
|
||||||
|
>>>>>>> main
|
||||||
|
}
|
||||||
|
return "Ismeretlen kártya"
|
||||||
}
|
}
|
||||||
|
|
||||||
const getCardTypeLabel = (card) => {
|
const getCardTypeLabel = (card) => {
|
||||||
|
<<<<<<< HEAD
|
||||||
if (card.type === 'QUESTION') {
|
if (card.type === 'QUESTION') {
|
||||||
|
=======
|
||||||
|
if (card.type === "task") {
|
||||||
|
>>>>>>> main
|
||||||
if (card.subType) {
|
if (card.subType) {
|
||||||
return cardSubTypeLabels[card.subType] || 'Feladat'
|
return cardSubTypeLabels[card.subType] || "Feladat"
|
||||||
}
|
}
|
||||||
return 'Feladat'
|
return "Feladat"
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
if (card.type === 'JOKER') {
|
if (card.type === 'JOKER') {
|
||||||
return 'Joker'
|
return 'Joker'
|
||||||
}
|
}
|
||||||
if (card.type === 'LUCK') {
|
if (card.type === 'LUCK') {
|
||||||
return 'Szerencse'
|
return 'Szerencse'
|
||||||
|
=======
|
||||||
|
if (card.type === "joker") {
|
||||||
|
return "Joker"
|
||||||
}
|
}
|
||||||
return 'Ismeretlen'
|
if (card.type === "luck") {
|
||||||
|
return "Szerencse"
|
||||||
|
>>>>>>> main
|
||||||
|
}
|
||||||
|
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 (
|
return (
|
||||||
<div className="flex flex-col h-full">
|
<div className="flex flex-col h-full relative">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="p-4 border-b border-[color:var(--color-surface-selected)]">
|
<div className="p-4 border-b border-[color:var(--color-surface-selected)]">
|
||||||
<h2 className="text-lg font-bold text-[color:var(--color-text)] mb-4 flex items-center gap-2">
|
<h2 className="text-lg font-bold text-[color:var(--color-text)] mb-4 flex items-center gap-2">
|
||||||
🃏 Kártyák
|
🃏 Kártyák
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
{/* New Card Button */}
|
{/* New Card Button */}
|
||||||
<button
|
<button
|
||||||
onClick={() => onCreateCard(deckType)}
|
onClick={() => onCreateCard(deckType)}
|
||||||
@@ -77,6 +132,42 @@ export default function CardsList({
|
|||||||
{deckType === 'LUCK' && '🎲 Új szerencse kártya'}
|
{deckType === 'LUCK' && '🎲 Új szerencse kártya'}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
|
=======
|
||||||
|
{/* New Card Dropdown */}
|
||||||
|
<div className="relative group">
|
||||||
|
<button className="w-full flex items-center justify-center gap-2 px-4 py-3 rounded-xl bg-[color:var(--color-success)] hover:bg-[color:var(--color-success)]/80 text-[color:var(--color-text-inverse)] font-semibold transition-all duration-200 hover:scale-105 shadow-lg">
|
||||||
|
<FaPlus />
|
||||||
|
Új kártya
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{/* Dropdown Menu */}
|
||||||
|
<div className="absolute top-full left-0 right-0 mt-2 bg-[color:var(--color-card)] rounded-xl shadow-lg border border-[color:var(--color-surface-selected)] opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 z-10">
|
||||||
|
<button
|
||||||
|
onClick={() => onCreateCard("task")}
|
||||||
|
className="w-full flex items-center gap-3 px-4 py-3 hover:bg-[color:var(--color-surface-selected)] text-[color:var(--color-text)] transition-colors duration-200 rounded-t-xl"
|
||||||
|
>
|
||||||
|
<FaQuestionCircle className="text-[color:var(--color-question)]" />
|
||||||
|
📋 Feladat kártya
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
onClick={() => onCreateCard("joker")}
|
||||||
|
className="w-full flex items-center gap-3 px-4 py-3 hover:bg-[color:var(--color-surface-selected)] text-[color:var(--color-text)] transition-colors duration-200"
|
||||||
|
>
|
||||||
|
<FaTheaterMasks className="text-[color:var(--color-fun)]" />
|
||||||
|
🃏 Joker kártya
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
onClick={() => onCreateCard("luck")}
|
||||||
|
className="w-full flex items-center gap-3 px-4 py-3 hover:bg-[color:var(--color-surface-selected)] text-[color:var(--color-text)] transition-colors duration-200 rounded-b-xl"
|
||||||
|
>
|
||||||
|
<FaDice className="text-[color:var(--color-luck)]" />
|
||||||
|
🎲 Szerencse kártya
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
>>>>>>> main
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Cards List */}
|
{/* Cards List */}
|
||||||
@@ -94,7 +185,7 @@ export default function CardsList({
|
|||||||
)}
|
)}
|
||||||
<div>
|
<div>
|
||||||
<div className="text-[color:var(--color-text)] font-medium">
|
<div className="text-[color:var(--color-text)] font-medium">
|
||||||
Új {newCardType === 'task' ? 'feladat' : newCardType === 'joker' ? 'joker' : 'szerencse'} kártya
|
Új {newCardType === "task" ? "feladat" : newCardType === "joker" ? "joker" : "szerencse"} kártya
|
||||||
</div>
|
</div>
|
||||||
<div className="text-[color:var(--color-text-muted)] text-sm">
|
<div className="text-[color:var(--color-text-muted)] text-sm">
|
||||||
Szerkesztés folyamatban...
|
Szerkesztés folyamatban...
|
||||||
@@ -115,16 +206,20 @@ export default function CardsList({
|
|||||||
onClick={() => onSelectCard(card)}
|
onClick={() => onSelectCard(card)}
|
||||||
className={`
|
className={`
|
||||||
p-4 rounded-xl border cursor-pointer transition-all duration-200 hover:scale-105 group
|
p-4 rounded-xl border cursor-pointer transition-all duration-200 hover:scale-105 group
|
||||||
${isSelected
|
${
|
||||||
? 'bg-[color:var(--color-success)]/10 border-[color:var(--color-success)] shadow-lg'
|
isSelected
|
||||||
: 'bg-[color:var(--color-background)]/50 border-[color:var(--color-surface-selected)] hover:bg-[color:var(--color-background)]/80'
|
? "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 Header */}
|
{/* Card Header */}
|
||||||
<div className="flex items-start justify-between gap-2 mb-3">
|
<div className="flex items-start justify-between gap-2 mb-3">
|
||||||
<div className="flex items-center gap-3 flex-1 min-w-0">
|
<div className="flex items-center gap-3 flex-1 min-w-0">
|
||||||
<div className="flex items-center justify-center w-10 h-10 rounded-full border-2" style={{ borderColor: cardIcon.color }}>
|
<div
|
||||||
|
className="flex items-center justify-center w-10 h-10 rounded-full border-2"
|
||||||
|
style={{ borderColor: cardIcon.color }}
|
||||||
|
>
|
||||||
{React.createElement(cardIcon.icon, {
|
{React.createElement(cardIcon.icon, {
|
||||||
style: { color: cardIcon.color },
|
style: { color: cardIcon.color },
|
||||||
className: "text-lg"
|
className: "text-lg"
|
||||||
@@ -148,7 +243,7 @@ export default function CardsList({
|
|||||||
<button
|
<button
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
onDeleteCard(card.id)
|
setConfirmingDelete(card.id)
|
||||||
}}
|
}}
|
||||||
className="p-1.5 rounded-lg bg-[color:var(--color-error)]/10 hover:bg-[color:var(--color-error)]/20 text-[color:var(--color-error)] transition-colors duration-200"
|
className="p-1.5 rounded-lg bg-[color:var(--color-error)]/10 hover:bg-[color:var(--color-error)]/20 text-[color:var(--color-error)] transition-colors duration-200"
|
||||||
>
|
>
|
||||||
@@ -162,10 +257,10 @@ export default function CardsList({
|
|||||||
<div
|
<div
|
||||||
className="text-[color:var(--color-text)] text-sm leading-relaxed"
|
className="text-[color:var(--color-text)] text-sm leading-relaxed"
|
||||||
style={{
|
style={{
|
||||||
display: '-webkit-box',
|
display: "-webkit-box",
|
||||||
WebkitLineClamp: 2,
|
WebkitLineClamp: 2,
|
||||||
WebkitBoxOrient: 'vertical',
|
WebkitBoxOrient: "vertical",
|
||||||
overflow: 'hidden'
|
overflow: "hidden"
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{getCardPreview(card)}
|
{getCardPreview(card)}
|
||||||
@@ -188,6 +283,34 @@ export default function CardsList({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Confirm Delete Popup */}
|
||||||
|
{confirmingDelete && (
|
||||||
|
<div className="fixed inset-0 bg-black/40 flex items-center justify-center z-50">
|
||||||
|
<div className="bg-white rounded-xl shadow-xl p-6 w-80 text-center animate-fadeIn">
|
||||||
|
<h3 className="text-lg font-semibold mb-4 text-gray-800">
|
||||||
|
Biztosan törölni szeretnéd?
|
||||||
|
</h3>
|
||||||
|
<p className="text-sm text-gray-600 mb-6">
|
||||||
|
Ez a művelet nem visszavonható.
|
||||||
|
</p>
|
||||||
|
<div className="flex justify-center gap-4">
|
||||||
|
<button
|
||||||
|
onClick={handleConfirmDelete}
|
||||||
|
className="bg-[color:var(--color-error)] text-white px-4 py-2 rounded-lg hover:bg-red-600 transition"
|
||||||
|
>
|
||||||
|
Igen
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={handleCancelDelete}
|
||||||
|
className="bg-gray-200 px-4 py-2 rounded-lg hover:bg-gray-300 transition"
|
||||||
|
>
|
||||||
|
Mégse
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Footer Stats */}
|
{/* Footer Stats */}
|
||||||
<div className="p-4 border-t border-[color:var(--color-surface-selected)] bg-[color:var(--color-background)]/30">
|
<div className="p-4 border-t border-[color:var(--color-surface-selected)] bg-[color:var(--color-background)]/30">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
@@ -197,9 +320,15 @@ export default function CardsList({
|
|||||||
|
|
||||||
{cards.length > 0 && (
|
{cards.length > 0 && (
|
||||||
<div className="flex justify-center gap-4 mt-2 text-xs text-[color:var(--color-text-muted)]">
|
<div className="flex justify-center gap-4 mt-2 text-xs text-[color:var(--color-text-muted)]">
|
||||||
|
<<<<<<< HEAD
|
||||||
<span>📋 {cards.filter(c => c.type === 'QUESTION').length}</span>
|
<span>📋 {cards.filter(c => c.type === 'QUESTION').length}</span>
|
||||||
<span>🃏 {cards.filter(c => c.type === 'JOKER').length}</span>
|
<span>🃏 {cards.filter(c => c.type === 'JOKER').length}</span>
|
||||||
<span>🎲 {cards.filter(c => c.type === 'LUCK').length}</span>
|
<span>🎲 {cards.filter(c => c.type === 'LUCK').length}</span>
|
||||||
|
=======
|
||||||
|
<span>📋 {cards.filter(c => c.type === 'QUESTION').length}</span>
|
||||||
|
<span>🃏 {cards.filter(c => c.type === 'JOKER').length}</span>
|
||||||
|
<span>🎲 {cards.filter(c => c.type === 'LUCK').length}</span>
|
||||||
|
>>>>>>> main
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ const LandingPage = ({ onNavigateToPlay, onNavigateToAuth, onNavigateToGame }) =
|
|||||||
{/* If not authenticated show Login/Register; if authenticated show Home button */}
|
{/* If not authenticated show Login/Register; if authenticated show Home button */}
|
||||||
{!auth ? (
|
{!auth ? (
|
||||||
<>
|
<>
|
||||||
<ButtonGreen text="Bejelntekezés" onClick={onNavigateToPlay} width="w-60" />
|
<ButtonGreen text="Bejelentkezés" onClick={onNavigateToPlay} width="w-60" />
|
||||||
<ButtonGreen text="Regisztráció" onClick={onNavigateToAuth} width="w-60" />
|
<ButtonGreen text="Regisztráció" onClick={onNavigateToAuth} width="w-60" />
|
||||||
<ButtonGreen text="Játék" onClick={onNavigateToGame} width="w-60" />
|
<ButtonGreen text="Játék" onClick={onNavigateToGame} width="w-60" />
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -0,0 +1,165 @@
|
|||||||
|
import { toast, ToastContainer, Bounce } from "react-toastify";
|
||||||
|
import "react-toastify/dist/ReactToastify.css";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 🔧 Ezt csak egyszer kell betenni az App.jsx-be!
|
||||||
|
* <ToastConfig /> = az a komponens, ami kirendereli a toastokat
|
||||||
|
*/
|
||||||
|
export const ToastConfig = () => (
|
||||||
|
<ToastContainer
|
||||||
|
position="bottom-right"
|
||||||
|
autoClose={5000}
|
||||||
|
hideProgressBar={false}
|
||||||
|
newestOnTop={false}
|
||||||
|
closeOnClick={false}
|
||||||
|
rtl={false}
|
||||||
|
pauseOnFocusLoss
|
||||||
|
draggable
|
||||||
|
pauseOnHover
|
||||||
|
theme="light"
|
||||||
|
transition={Bounce}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 🦄 Alapértelmezett toast üzenet (semleges)
|
||||||
|
* notify("Üzenet szövege")
|
||||||
|
*/
|
||||||
|
export const notify = (message) => {
|
||||||
|
toast(message, {
|
||||||
|
position: "bottom-right",
|
||||||
|
autoClose: 5000,
|
||||||
|
hideProgressBar: false,
|
||||||
|
closeOnClick: false,
|
||||||
|
pauseOnHover: true,
|
||||||
|
draggable: true,
|
||||||
|
theme: "light",
|
||||||
|
transition: Bounce,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ✅ Sikeres művelethez
|
||||||
|
* notifySuccess("Sikeres mentés!")
|
||||||
|
*/
|
||||||
|
export const notifySuccess = (message) => {
|
||||||
|
toast.success(message, {
|
||||||
|
position: "bottom-right",
|
||||||
|
autoClose: 4000,
|
||||||
|
theme: "light",
|
||||||
|
transition: Bounce,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ❌ Hibás művelethez
|
||||||
|
* notifyError("Hiba történt a mentés során!")
|
||||||
|
*/
|
||||||
|
export const notifyError = (message) => {
|
||||||
|
toast.error(message, {
|
||||||
|
position: "bottom-right",
|
||||||
|
autoClose: 5000,
|
||||||
|
theme: "light",
|
||||||
|
transition: Bounce,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ℹ️ Információs üzenethez
|
||||||
|
* notifyInfo("Friss adatok betöltve!")
|
||||||
|
*/
|
||||||
|
export const notifyInfo = (message) => {
|
||||||
|
toast.info(message, {
|
||||||
|
position: "bottom-right",
|
||||||
|
autoClose: 4000,
|
||||||
|
theme: "light",
|
||||||
|
transition: Bounce,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ⚠️ Figyelmeztetéshez
|
||||||
|
* notifyWarning("Figyelem! Nem mentett módosítások vannak!")
|
||||||
|
*/
|
||||||
|
export const notifyWarning = (message) => {
|
||||||
|
toast.warn(message, {
|
||||||
|
position: "bottom-right",
|
||||||
|
autoClose: 4000,
|
||||||
|
theme: "light",
|
||||||
|
transition: Bounce,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// import React, { useState } from "react";
|
||||||
|
// import { notifyWarning } from "../../components/Toastify/toastifyServices";
|
||||||
|
|
||||||
|
// function AuthLogin() {
|
||||||
|
// const [email, setEmail] = useState("");
|
||||||
|
// const [password, setPassword] = useState("");
|
||||||
|
|
||||||
|
// const handleLogin = async (e) => {
|
||||||
|
// e.preventDefault();
|
||||||
|
|
||||||
|
// // Példa jelszó ellenőrzés logikára:
|
||||||
|
// if (password !== "titkosjelszo123") {
|
||||||
|
// notifyWarning("⚠️ Hibás jelszó! Kérlek próbáld újra.");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Ha jó a jelszó:
|
||||||
|
// notifySuccess("✅ Sikeres bejelentkezés!");
|
||||||
|
// };
|
||||||
|
|
||||||
|
// return (
|
||||||
|
// <form onSubmit={handleLogin} className="login-form">
|
||||||
|
// <input
|
||||||
|
// type="email"
|
||||||
|
// placeholder="Email cím"
|
||||||
|
// value={email}
|
||||||
|
// onChange={(e) => setEmail(e.target.value)}
|
||||||
|
// />
|
||||||
|
// <input
|
||||||
|
// type="password"
|
||||||
|
// placeholder="Jelszó"
|
||||||
|
// value={password}
|
||||||
|
// onChange={(e) => setPassword(e.target.value)}
|
||||||
|
// />
|
||||||
|
// <button type="submit">Bejelentkezés</button>
|
||||||
|
// </form>
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// export default AuthLogin;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// meghivas
|
||||||
|
// import { toast } from "react-toastify";
|
||||||
|
|
||||||
|
// // 🔔 Alap toast
|
||||||
|
// export const notify = (msg) => toast(msg);
|
||||||
|
|
||||||
|
// // ✅ Sikeres üzenet
|
||||||
|
// export const notifySuccess = (msg) => toast.success(msg);
|
||||||
|
|
||||||
|
// // ⚠️ Figyelmeztetés
|
||||||
|
// export const notifyWarning = (msg) => toast.warning(msg);
|
||||||
|
|
||||||
|
// // ❌ Hiba
|
||||||
|
// export const notifyError = (msg) => toast.error(msg);
|
||||||
|
|
||||||
|
// // ℹ️ Információ
|
||||||
|
// export const notifyInfo = (msg) => toast.info(msg);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// hasznalat
|
||||||
|
// import { notifyWarning } from "../../components/Toastify/toastifyServices";
|
||||||
|
|
||||||
|
// if (password !== "titkos") {
|
||||||
|
// notifyWarning("⚠️ Hibás jelszó!");
|
||||||
|
// }
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
// src/pages/Auth/LoginForm.jsx
|
// src/pages/Auth/LoginForm.jsx
|
||||||
// Bejelentkezési űrlap
|
|
||||||
|
|
||||||
import InputBox from "../../components/Inputs/InputBox"
|
import InputBox from "../../components/Inputs/InputBox"
|
||||||
import Button from "../../components/Buttons/Button"
|
import Button from "../../components/Buttons/Button"
|
||||||
import { motion } from "framer-motion"
|
import { motion } from "framer-motion"
|
||||||
import { useState, useEffect } from "react"
|
import { useState, useEffect } from "react"
|
||||||
import { useLocation, useNavigate } from "react-router-dom"
|
import { useLocation, useNavigate } from "react-router-dom"
|
||||||
import { login } from "../../api/userApi"
|
import { login } from "../../api/userApi"
|
||||||
|
import { FaArrowLeft } from "react-icons/fa"
|
||||||
|
|
||||||
export default function LoginForm() {
|
export default function LoginForm() {
|
||||||
const [email, setEmail] = useState("")
|
const [email, setEmail] = useState("")
|
||||||
@@ -32,23 +31,23 @@ export default function LoginForm() {
|
|||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
setError("")
|
setError("")
|
||||||
setShowErrorPopup(false)
|
setShowErrorPopup(false)
|
||||||
|
|
||||||
if (!email || !password) {
|
if (!email || !password) {
|
||||||
setError("Minden mező kitöltése kötelező.")
|
setError("Minden mező kitöltése kötelező.")
|
||||||
setShowErrorPopup(true)
|
setShowErrorPopup(true)
|
||||||
setTimeout(() => setShowErrorPopup(false), 2000)
|
setTimeout(() => setShowErrorPopup(false), 2000)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validateEmail(email)) {
|
if (!validateEmail(email)) {
|
||||||
setError("Hibás email formátum.")
|
setError("Hibás email formátum.")
|
||||||
setShowErrorPopup(true)
|
setShowErrorPopup(true)
|
||||||
setTimeout(() => setShowErrorPopup(false), 2000)
|
setTimeout(() => setShowErrorPopup(false), 2000)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Backend API
|
|
||||||
login(email, password)
|
login(email, password)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log(response)
|
|
||||||
// Csak a response.status-t ellenőrizd!
|
|
||||||
if (response && response.status === 200) {
|
if (response && response.status === 200) {
|
||||||
if (response.data && response.data.user) {
|
if (response.data && response.data.user) {
|
||||||
localStorage.setItem("username", response.data.user.username)
|
localStorage.setItem("username", response.data.user.username)
|
||||||
@@ -61,7 +60,7 @@ export default function LoginForm() {
|
|||||||
setTimeout(() => setShowErrorPopup(false), 2000)
|
setTimeout(() => setShowErrorPopup(false), 2000)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(() => {
|
||||||
setError("Hibás bejelentkezési adatok.")
|
setError("Hibás bejelentkezési adatok.")
|
||||||
setShowErrorPopup(true)
|
setShowErrorPopup(true)
|
||||||
setTimeout(() => setShowErrorPopup(false), 2000)
|
setTimeout(() => setShowErrorPopup(false), 2000)
|
||||||
@@ -75,18 +74,35 @@ export default function LoginForm() {
|
|||||||
animate={{ opacity: 1 }}
|
animate={{ opacity: 1 }}
|
||||||
exit={{ opacity: 0 }}
|
exit={{ opacity: 0 }}
|
||||||
transition={{ duration: 0.25 }}
|
transition={{ duration: 0.25 }}
|
||||||
|
className="relative flex flex-col items-center"
|
||||||
>
|
>
|
||||||
<h2 className="text-4xl font-extrabold text-center mb-6 text-gray-800 tracking-wide">Bejelentkezés</h2>
|
{/* 🔙 Vissza nyíl gomb — most pontosan a fehér box bal felső sarkában */}
|
||||||
|
<div
|
||||||
|
className="absolute -top-6 -left-6 flex items-center group cursor-pointer select-none"
|
||||||
|
onClick={() => navigate("/")}
|
||||||
|
>
|
||||||
|
<FaArrowLeft className="text-gray-700 text-xl transition-transform duration-300 group-hover:-translate-x-1" />
|
||||||
|
<span className="ml-2 text-gray-700 font-medium opacity-0 -translate-x-2 group-hover:opacity-100 group-hover:translate-x-0 transition-all duration-300">
|
||||||
|
Vissza a főoldalra
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h2 className="text-4xl font-extrabold text-center mb-6 text-gray-800 tracking-wide">
|
||||||
|
Bejelentkezés
|
||||||
|
</h2>
|
||||||
|
|
||||||
{showSuccess && (
|
{showSuccess && (
|
||||||
<div className="fixed top-6 left-1/2 -translate-x-1/2 bg-green-500 text-white px-6 py-2 rounded shadow-lg z-50 text-center font-semibold transition-opacity duration-300">
|
<div className="fixed top-6 left-1/2 -translate-x-1/2 bg-green-500 text-white px-6 py-2 rounded shadow-lg z-50 text-center font-semibold transition-opacity duration-300">
|
||||||
Sikeres regisztráció! Az email ellenőrzése után be tudsz lépni.
|
Sikeres regisztráció! Az email ellenőrzése után be tudsz lépni.
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{showErrorPopup && error && (
|
{showErrorPopup && error && (
|
||||||
<div className="fixed top-6 left-1/2 -translate-x-1/2 bg-red-500 text-white px-6 py-2 rounded shadow-lg z-50 text-center font-semibold transition-opacity duration-300">
|
<div className="fixed top-6 left-1/2 -translate-x-1/2 bg-red-500 text-white px-6 py-2 rounded shadow-lg z-50 text-center font-semibold transition-opacity duration-300">
|
||||||
{error}
|
{error}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<form onSubmit={handleSubmit} className="space-y-6">
|
<form onSubmit={handleSubmit} className="space-y-6">
|
||||||
<InputBox
|
<InputBox
|
||||||
type="email"
|
type="email"
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
// src/pages/Auth/RegisterForm.jsx
|
// src/pages/Auth/RegisterForm.jsx
|
||||||
// Regisztrációs űrlap
|
|
||||||
|
|
||||||
import InputBox from "../../components/Inputs/InputBox"
|
import InputBox from "../../components/Inputs/InputBox"
|
||||||
import Button from "../../components/Buttons/Button"
|
import Button from "../../components/Buttons/Button"
|
||||||
import { motion } from "framer-motion"
|
import { motion } from "framer-motion"
|
||||||
import { useState } from "react"
|
import { useState } from "react"
|
||||||
import { register } from "../../api/userApi"
|
import { register } from "../../api/userApi"
|
||||||
import { useNavigate, useLocation } from "react-router-dom"
|
import { useNavigate, useLocation } from "react-router-dom"
|
||||||
|
import { ToastConfig } from "../../components/Toastify/toastifyServices"
|
||||||
|
import { FaArrowLeft } from "react-icons/fa"
|
||||||
|
|
||||||
export default function RegisterForm() {
|
export default function RegisterForm() {
|
||||||
const [lastname, setLastname] = useState("")
|
const [lastname, setLastname] = useState("")
|
||||||
@@ -46,36 +46,26 @@ export default function RegisterForm() {
|
|||||||
setError("A jelszavak nem egyeznek.")
|
setError("A jelszavak nem egyeznek.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Backend API
|
|
||||||
try {
|
try {
|
||||||
const response = await register(username, email, password, firstname, lastname, phone)
|
const response = await register(username, email, password, firstname, lastname, phone)
|
||||||
// Check for 201 Created status
|
|
||||||
if (response && response.status === 201) {
|
if (response && response.status === 201) {
|
||||||
// Ha már a /login útvonalon van a user, a sima navigate nem biztos, hogy újraindítja a komponenst.
|
ToastConfig("✅ Sikeres regisztráció!")
|
||||||
// Ilyenkor előbb beállítjuk a state-et, majd kényszerítünk egy teljes oldalletöltést.
|
|
||||||
if (location.pathname === "/login") {
|
if (location.pathname === "/login") {
|
||||||
navigate("/login", { state: { success: true } })
|
navigate("/login", { state: { success: true } })
|
||||||
// teljes újratöltés, hogy a login oldal újra feldolgozza a state-et
|
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
} else {
|
} else {
|
||||||
navigate("/login", { state: { success: true } })
|
navigate("/login", { state: { success: true } })
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let msg = "Sikertelen regisztráció."
|
let msg = "Sikertelen regisztráció."
|
||||||
if (response && response.data && response.data.error) {
|
if (response?.data?.error) msg = response.data.error
|
||||||
msg = response.data.error
|
|
||||||
}
|
|
||||||
setError(msg)
|
setError(msg)
|
||||||
setShowErrorPopup(true)
|
setShowErrorPopup(true)
|
||||||
setTimeout(() => setShowErrorPopup(false), 2000)
|
setTimeout(() => setShowErrorPopup(false), 2000)
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
let msg = "Ismeretlen hiba történt."
|
let msg = err?.response?.data?.error || err.message || "Ismeretlen hiba történt."
|
||||||
if (err.response && err.response.data && err.response.data.error) {
|
|
||||||
msg = err.response.data.error
|
|
||||||
} else if (err.message) {
|
|
||||||
msg = err.message
|
|
||||||
}
|
|
||||||
setError(msg)
|
setError(msg)
|
||||||
setShowErrorPopup(true)
|
setShowErrorPopup(true)
|
||||||
setTimeout(() => setShowErrorPopup(false), 2000)
|
setTimeout(() => setShowErrorPopup(false), 2000)
|
||||||
@@ -89,56 +79,37 @@ export default function RegisterForm() {
|
|||||||
animate={{ opacity: 1 }}
|
animate={{ opacity: 1 }}
|
||||||
exit={{ opacity: 0 }}
|
exit={{ opacity: 0 }}
|
||||||
transition={{ duration: 0.25 }}
|
transition={{ duration: 0.25 }}
|
||||||
|
className="relative flex flex-col items-center"
|
||||||
>
|
>
|
||||||
<h2 className="text-4xl font-extrabold text-center mb-6 text-gray-800 tracking-wide">Regisztráció</h2>
|
{/* 🔙 Vissza nyíl gomb – ugyanott, mint a login oldalon */}
|
||||||
|
<div
|
||||||
|
className="absolute -top-2 -left-1 flex items-center group cursor-pointer select-none"
|
||||||
|
onClick={() => navigate("/")}
|
||||||
|
>
|
||||||
|
<FaArrowLeft className="text-gray-700 text-xl transition-transform duration-300 group-hover:-translate-x-1" />
|
||||||
|
<span className="ml-2 text-gray-700 font-medium opacity-0 -translate-x-2 group-hover:opacity-100 group-hover:translate-x-0 transition-all duration-300">
|
||||||
|
Vissza a főoldalra
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h2 className="text-4xl font-extrabold text-center mb-6 text-gray-800 tracking-wide">
|
||||||
|
Regisztráció
|
||||||
|
</h2>
|
||||||
|
|
||||||
{showErrorPopup && error && (
|
{showErrorPopup && error && (
|
||||||
<div className="fixed top-6 left-1/2 -translate-x-1/2 bg-red-500 text-white px-6 py-2 rounded shadow-lg z-50 text-center font-semibold transition-opacity duration-300">
|
<div className="fixed top-6 left-1/2 -translate-x-1/2 bg-red-500 text-white px-6 py-2 rounded shadow-lg z-50 text-center font-semibold transition-opacity duration-300">
|
||||||
{error}
|
{error}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<form onSubmit={handleSubmit} className="space-y-6">
|
<form onSubmit={handleSubmit} className="space-y-6">
|
||||||
<InputBox
|
<InputBox type="text" placeholder="Vezetéknév" value={lastname} onChange={(e) => setLastname(e.target.value)} />
|
||||||
type="text"
|
<InputBox type="text" placeholder="Keresztnév" value={firstname} onChange={(e) => setFirstname(e.target.value)} />
|
||||||
placeholder="Vezetéknév"
|
<InputBox type="text" placeholder="Felhasználónév" value={username} onChange={(e) => setUsername(e.target.value)} />
|
||||||
value={lastname}
|
<InputBox type="email" placeholder="Email cím" value={email} onChange={(e) => setEmail(e.target.value)} />
|
||||||
onChange={(e) => setLastname(e.target.value)}
|
<InputBox type="phone" placeholder="Telefonszám" value={phone} onChange={(e) => setPhone(e.target.value)} />
|
||||||
/>
|
<InputBox type="password" placeholder="Jelszó" value={password} onChange={(e) => setPassword(e.target.value)} />
|
||||||
<InputBox
|
<InputBox type="password" placeholder="Jelszó megerősítése" value={confirmPassword} onChange={(e) => setConfirmPassword(e.target.value)} />
|
||||||
type="text"
|
|
||||||
placeholder="Keresztnév"
|
|
||||||
value={firstname}
|
|
||||||
onChange={(e) => setFirstname(e.target.value)}
|
|
||||||
/>
|
|
||||||
<InputBox
|
|
||||||
type="text"
|
|
||||||
placeholder="Felhasználónév"
|
|
||||||
value={username}
|
|
||||||
onChange={(e) => setUsername(e.target.value)}
|
|
||||||
/>
|
|
||||||
<InputBox
|
|
||||||
type="email"
|
|
||||||
placeholder="Email cím"
|
|
||||||
value={email}
|
|
||||||
onChange={(e) => setEmail(e.target.value)}
|
|
||||||
/>
|
|
||||||
<InputBox
|
|
||||||
type="phone"
|
|
||||||
placeholder="Telefonszám"
|
|
||||||
value={phone}
|
|
||||||
onChange={(e) => setPhone(e.target.value)}
|
|
||||||
/>
|
|
||||||
<InputBox
|
|
||||||
type="password"
|
|
||||||
placeholder="Jelszó"
|
|
||||||
value={password}
|
|
||||||
onChange={(e) => setPassword(e.target.value)}
|
|
||||||
/>
|
|
||||||
<InputBox
|
|
||||||
type="password"
|
|
||||||
placeholder="Jelszó megerősítése"
|
|
||||||
value={confirmPassword}
|
|
||||||
onChange={(e) => setConfirmPassword(e.target.value)}
|
|
||||||
/>
|
|
||||||
<Button text="Regisztráció" type="submit" />
|
<Button text="Regisztráció" type="submit" />
|
||||||
</form>
|
</form>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import DeckHeader from "../../components/DeckCreator/DeckHeader.jsx"
|
|||||||
import CardsList from "../../components/DeckCreator/CardsList.jsx"
|
import CardsList from "../../components/DeckCreator/CardsList.jsx"
|
||||||
import CardEditor from "../../components/DeckCreator/CardEditor.jsx"
|
import CardEditor from "../../components/DeckCreator/CardEditor.jsx"
|
||||||
import { createDeck } from '../../api/deckApi'
|
import { createDeck } from '../../api/deckApi'
|
||||||
|
import { notifySuccess, notifyError } from "../../components/Toastify/toastifyServices"
|
||||||
|
|
||||||
export default function DeckCreator() {
|
export default function DeckCreator() {
|
||||||
const { deckId } = useParams() // URL-ből deck ID (új deck esetén undefined)
|
const { deckId } = useParams() // URL-ből deck ID (új deck esetén undefined)
|
||||||
@@ -31,9 +32,12 @@ export default function DeckCreator() {
|
|||||||
// Betöltés API-ból
|
// Betöltés API-ból
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (deckId) {
|
if (deckId) {
|
||||||
|
<<<<<<< HEAD
|
||||||
// TODO: Betöltés API-ból
|
// TODO: Betöltés API-ból
|
||||||
|
=======
|
||||||
|
loadDeck(deckId)
|
||||||
|
>>>>>>> main
|
||||||
} else {
|
} else {
|
||||||
// Új deck
|
|
||||||
setDeck({
|
setDeck({
|
||||||
id: null,
|
id: null,
|
||||||
name: "Új Pakli",
|
name: "Új Pakli",
|
||||||
@@ -60,6 +64,7 @@ export default function DeckCreator() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const saved = await createDeck(payload)
|
const saved = await createDeck(payload)
|
||||||
|
<<<<<<< HEAD
|
||||||
setDeck(prev => ({
|
setDeck(prev => ({
|
||||||
...prev,
|
...prev,
|
||||||
id: saved.id ?? prev.id,
|
id: saved.id ?? prev.id,
|
||||||
@@ -67,16 +72,27 @@ export default function DeckCreator() {
|
|||||||
updatedate: saved.updatedate ?? prev.updatedate
|
updatedate: saved.updatedate ?? prev.updatedate
|
||||||
}))
|
}))
|
||||||
alert('✅ Deck sikeresen mentve!')
|
alert('✅ Deck sikeresen mentve!')
|
||||||
|
=======
|
||||||
|
setDeck(prev => ({
|
||||||
|
...prev,
|
||||||
|
id: saved.id ?? prev.id,
|
||||||
|
creationdate: saved.creationdate ?? prev.creationdate,
|
||||||
|
updatedate: saved.updatedate ?? prev.updatedate
|
||||||
|
}))
|
||||||
|
|
||||||
|
console.log('Deck saved (backend):', saved)
|
||||||
|
notifySuccess('Deck sikeresen mentve!')
|
||||||
|
>>>>>>> main
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Mentési hiba:', error)
|
console.error('Mentési hiba:', error)
|
||||||
alert('❌ Hiba történt a mentés során: ' + (error?.response?.data?.error || error.message || String(error)))
|
notifyError('Hiba történt a mentés során: ' + (error?.response?.data?.error || error.message || String(error)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 🔧 Itt korábban volt confirm(), de most eltávolítottuk
|
||||||
const handleBack = () => {
|
const handleBack = () => {
|
||||||
if (confirm("Biztosan visszamész? A nem mentett változtatások elvesznek.")) {
|
// Egyszerű visszalépés — ha akarsz, később adhatunk hozzá saját modalt
|
||||||
navigate("/decks")
|
navigate("/decks")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleCreateCard = (cardType) => {
|
const handleCreateCard = (cardType) => {
|
||||||
@@ -92,9 +108,34 @@ export default function DeckCreator() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleSaveCard = (cardData) => {
|
const handleSaveCard = (cardData) => {
|
||||||
|
<<<<<<< HEAD
|
||||||
const updatedCard = {
|
const updatedCard = {
|
||||||
...cardData,
|
...cardData,
|
||||||
id: isCreatingCard ? Date.now() : cardData.id
|
id: isCreatingCard ? Date.now() : cardData.id
|
||||||
|
=======
|
||||||
|
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)
|
||||||
|
>>>>>>> main
|
||||||
}
|
}
|
||||||
|
|
||||||
setDeck(prev => ({
|
setDeck(prev => ({
|
||||||
@@ -109,16 +150,15 @@ export default function DeckCreator() {
|
|||||||
setNewCardType(null)
|
setNewCardType(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 🔧 Itt is confirm() volt — most a CardsList popupja kezeli a megerősítést
|
||||||
const handleDeleteCard = (cardId) => {
|
const handleDeleteCard = (cardId) => {
|
||||||
if (confirm("Biztosan törlöd ezt a kártyát?")) {
|
setDeck(prev => ({
|
||||||
setDeck(prev => ({
|
...prev,
|
||||||
...prev,
|
cards: prev.cards.filter(card => card.id !== cardId)
|
||||||
cards: prev.cards.filter(card => card.id !== cardId)
|
}))
|
||||||
}))
|
|
||||||
|
|
||||||
if (selectedCard?.id === cardId) {
|
if (selectedCard?.id === cardId) {
|
||||||
setSelectedCard(null)
|
setSelectedCard(null)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user