Merge branch 'main' of https://git.mdnd-it.cc/Donat/SerpentRace into 1024zsola
This commit is contained in:
@@ -199,12 +199,13 @@ deckRouter.patch('/:id', authRequired, async (req, res) => {
|
||||
try {
|
||||
const deckId = req.params.id;
|
||||
const userId = (req as any).user.userId;
|
||||
|
||||
const authLevel = (req as any).user.authLevel;
|
||||
logRequest('Update deck endpoint accessed', req, res, { deckId, userId, updateFields: Object.keys(req.body) });
|
||||
|
||||
// Convert string enum values to integers
|
||||
const updateData = convertEnumValues(req.body);
|
||||
|
||||
const result = await container.updateDeckCommandHandler.execute({ id: deckId, userstate: userState, ...updateData });
|
||||
const result = await container.updateDeckCommandHandler.execute({ userid: userId, authLevel: authLevel, id: deckId, ...updateData });
|
||||
|
||||
logRequest('Deck updated successfully', req, res, { deckId, userId });
|
||||
res.json(result);
|
||||
@@ -244,8 +245,10 @@ deckRouter.delete('/:id', authRequired, async (req, res) => {
|
||||
try {
|
||||
const deckId = req.params.id;
|
||||
const userId = (req as any).user.userId;
|
||||
const authLevel = (req as any).user.authLevel;
|
||||
logRequest('Soft delete deck endpoint accessed', req, res, { deckId, userId });
|
||||
|
||||
const result = await container.deleteDeckCommandHandler.execute({ id: deckId, soft: true });
|
||||
const result = await container.deleteDeckCommandHandler.execute({ userid: userId, authLevel: authLevel, id: deckId, soft: true });
|
||||
|
||||
logRequest('Deck soft delete successful', req, res, { deckId, userId, success: result });
|
||||
res.json({ success: result });
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
export interface DeleteDeckCommand {
|
||||
userid: string;
|
||||
authLevel: number;
|
||||
id: string;
|
||||
soft?: boolean;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
import { IDeckRepository } from '../../../Domain/IRepository/IDeckRepository';
|
||||
import { logAuth, logError } from '../../Services/Logger';
|
||||
import { DeleteDeckCommand } from './DeleteDeckCommand';
|
||||
|
||||
export class DeleteDeckCommandHandler {
|
||||
constructor(private readonly deckRepo: IDeckRepository) {}
|
||||
|
||||
async execute(cmd: DeleteDeckCommand): Promise<boolean> {
|
||||
|
||||
//get decks userid
|
||||
const deck = await this.deckRepo.findById(cmd.id);
|
||||
if (!deck) {
|
||||
logError(`Deck not found with ID: ${cmd.id}`);
|
||||
throw new Error('Deck not found');
|
||||
}
|
||||
|
||||
if(cmd.authLevel !==1 && deck.userid !== cmd.userid) {
|
||||
logAuth(`Unauthorized access attempt to deck with ID: ${cmd.id}, UserID: ${cmd.userid}`);
|
||||
throw new Error('Unauthorized');
|
||||
}
|
||||
|
||||
if (cmd.soft) {
|
||||
await this.deckRepo.softDelete(cmd.id);
|
||||
} else {
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { n } from "framer-motion/dist/types.d-D0HXPxHm";
|
||||
|
||||
export interface UpdateDeckCommand {
|
||||
userid: string;
|
||||
authLevel: number;
|
||||
id: string;
|
||||
userstate?: number;
|
||||
name?: string;
|
||||
type?: number;
|
||||
userid?: string;
|
||||
cards?: any[];
|
||||
ctype?: number;
|
||||
state?: number;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { UpdateDeckCommand } from './UpdateDeckCommand';
|
||||
import { ShortDeckDto } from '../../DTOs/DeckDto';
|
||||
import { DeckMapper } from '../../DTOs/Mappers/DeckMapper';
|
||||
import { DeckAggregate } from '../../../Domain/Deck/DeckAggregate';
|
||||
import { logError } from '../../Services/Logger';
|
||||
import { logAuth, logError } from '../../Services/Logger';
|
||||
|
||||
export class UpdateDeckCommandHandler {
|
||||
constructor(private readonly deckRepo: IDeckRepository) {}
|
||||
@@ -24,6 +24,11 @@ export class UpdateDeckCommandHandler {
|
||||
throw new Error('Deck not found');
|
||||
}
|
||||
|
||||
if(cmd.authLevel !==1 && existingDeck.userid !== cmd.userid) {
|
||||
logAuth(`Unauthorized access attempt to deck with ID: ${cmd.id}, UserID: ${cmd.userid}`);
|
||||
throw new Error('Unauthorized');
|
||||
}
|
||||
|
||||
const for_update: Partial<DeckAggregate> = {};
|
||||
if(cmd.name !== undefined) for_update.name = cmd.name;
|
||||
if(cmd.type !== undefined) for_update.type = cmd.type;
|
||||
|
||||
@@ -76,8 +76,7 @@ services:
|
||||
- NODE_ENV=development
|
||||
- VITE_API_URL=http://localhost:3000
|
||||
volumes:
|
||||
- ../SerpentRace_Frontend:/app
|
||||
- /app/node_modules
|
||||
[]
|
||||
develop:
|
||||
watch:
|
||||
- action: sync
|
||||
|
||||
@@ -10,7 +10,7 @@ import Landingpage from "./pages/Landing/Landingpage"
|
||||
import Home from "./pages/Landing/Home"
|
||||
import DeckManagerPage from "./pages/Decks/DeckManagerPage"
|
||||
import DeckCreator from "./pages/DeckCreator/DeckCreator"
|
||||
import CompanyHub from "./pages/Companies/Companies"
|
||||
import CompanyHub from "./pages/Contacts/Contacts"
|
||||
import About from "./pages/About/About"
|
||||
import ScrollToTop from "./components/ScrollToTop"
|
||||
import GameScreen from "./pages/Game/GameScreen"
|
||||
@@ -64,7 +64,7 @@ function App() {
|
||||
<Route path="/deck-creator" element={<DeckCreator />} />
|
||||
<Route path="/deck-creator/:deckId" element={<DeckCreator />} />
|
||||
<Route path="/game" element={<GameScreen />} />
|
||||
<Route path="/companies" element={<CompanyHub />} />
|
||||
<Route path="/contacts" element={<CompanyHub />} />
|
||||
<Route path="/report" element={<Reports />} />
|
||||
</Routes>
|
||||
</Router>
|
||||
|
||||
@@ -57,7 +57,7 @@ const Footer = () => {
|
||||
<a href="/about" className="hover:underline hover:text-green-500">
|
||||
Rólunk
|
||||
</a>
|
||||
<a href="/contact" className="hover:underline hover:text-green-500">
|
||||
<a href="/contacts" className="hover:underline hover:text-green-500">
|
||||
Kapcsolat
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,7 @@ import { motion } from "framer-motion"
|
||||
import { isAuthenticated } from "../../hooks/useRequireAuth" // <-- added import
|
||||
import { useNavigate } from "react-router-dom" // <-- NEW
|
||||
|
||||
const LandingPage = ({ onNavigateToPlay, onNavigateToAuth, onNavigateToGame }) => {
|
||||
const LandingPage = ({ onNavigateToPlay, onNavigateToAuth, onNavigateToGame, onNavigateToContacts }) => {
|
||||
const auth = isAuthenticated() // <-- check without redirect
|
||||
const navigate = useNavigate() // <-- NEW
|
||||
|
||||
@@ -68,7 +68,7 @@ const LandingPage = ({ onNavigateToPlay, onNavigateToAuth, onNavigateToGame }) =
|
||||
<ButtonGreen text="Játék" onClick={onNavigateToGame} width="w-60" />
|
||||
</>
|
||||
) : (
|
||||
<ButtonGreen text="Játék" onClick={() => navigate("/home")} width="w-60" />
|
||||
<ButtonGreen text="Játék" onClick={onNavigateToGame} width="w-60" />
|
||||
)}
|
||||
</motion.div>
|
||||
</div>
|
||||
@@ -178,7 +178,7 @@ const LandingPage = ({ onNavigateToPlay, onNavigateToAuth, onNavigateToGame }) =
|
||||
|
||||
<ButtonGreen
|
||||
text="Kapcsolatfelvétel"
|
||||
onClick={onNavigateToAuth}
|
||||
onClick={onNavigateToContacts}
|
||||
className="px-12 py-4 text-xl font-bold"
|
||||
/>
|
||||
</motion.div>
|
||||
|
||||
@@ -19,9 +19,9 @@ const Navbar = () => {
|
||||
|
||||
return (
|
||||
<nav className="bg-gradient-to-r from-green-700 to-emerald-500 shadow-lg">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-0">
|
||||
<div className="flex justify-between h-16 items-center">
|
||||
{/* Logo */}
|
||||
{/* Logo + Brand */}
|
||||
<div className="flex-shrink-0 flex items-center gap-2">
|
||||
<Link to="/" className="flex items-center mt-1 h-9">
|
||||
<Logo size={36} />
|
||||
@@ -32,33 +32,47 @@ const Navbar = () => {
|
||||
</div>
|
||||
|
||||
{/* Desktop Menu */}
|
||||
<div className="hidden md:flex space-x-8 items-center">
|
||||
{isLoggedIn ? (
|
||||
<div className="hidden md:flex items-center space-x-6">
|
||||
{/* Bal oldali linkek */}
|
||||
<Link to="/" className={navLinkClass}>Főoldal</Link>
|
||||
<Link to="/about" className={navLinkClass}>Rólunk</Link>
|
||||
<Link to="/contacts" className={navLinkClass}>Kapcsolat</Link>
|
||||
|
||||
{/* Csak bejelentkezve */}
|
||||
{isLoggedIn && (
|
||||
<>
|
||||
<Link to="/home" className={navLinkClass}>Játék</Link>
|
||||
<Link to="/decks" className={navLinkClass}>Paklik</Link>
|
||||
<Link to="/report" className={navLinkClass}>Statisztikák</Link>
|
||||
</>
|
||||
) : (
|
||||
<Link to="/" className={navLinkClass}>Főoldal</Link>
|
||||
)}
|
||||
<Link to="/about" className={navLinkClass}>Rólunk</Link>
|
||||
<Link to="/companies" className={navLinkClass}>Kontakt</Link>
|
||||
{!isLoggedIn && (
|
||||
<>
|
||||
|
||||
{/* Játék gomb */}
|
||||
<Link to="/home" className={navLinkClassPlay}>Játék</Link>
|
||||
|
||||
{/* Jobb oldali akciók */}
|
||||
{!isLoggedIn ? (
|
||||
<div className="flex items-center space-x-4">
|
||||
<Link
|
||||
to="/login"
|
||||
className="px-4 py-2 rounded-lg hover:bg-white/20 text-white font-semibold transition-all"
|
||||
>
|
||||
Bejelentkezés
|
||||
</Link>
|
||||
|
||||
{/* Elválasztó vonal */}
|
||||
<div className="w-px h-10 bg-white/100"></div>
|
||||
|
||||
<Link
|
||||
to="/register"
|
||||
className="px-4 py-2 rounded-lg bg-white/10 hover:bg-white/20 text-white font-semibold transition-all"
|
||||
>
|
||||
Bejelentkezés / Regisztráció
|
||||
Regisztráció
|
||||
</Link>
|
||||
</>
|
||||
)}
|
||||
{isLoggedIn && (
|
||||
</div>
|
||||
) : (
|
||||
<button
|
||||
onClick={handleLogout}
|
||||
className="ml-4 p-2 rounded-full bg-[#166534] hover:bg-[#1f7a45] text-white shadow-lg hover:shadow-green-400/40 transition-all transform hover:scale-105 cursor-pointer"
|
||||
className="ml-2 p-2 rounded-full bg-[#166534] hover:bg-[#1f7a45] text-white shadow-lg hover:shadow-green-400/40 transition-all transform hover:scale-105 cursor-pointer"
|
||||
title="Kijelentkezés"
|
||||
>
|
||||
<svg
|
||||
@@ -107,39 +121,45 @@ const Navbar = () => {
|
||||
{/* Mobile Menu */}
|
||||
{menuOpen && (
|
||||
<div className="md:hidden bg-emerald-600 px-2 pt-2 pb-3 space-y-1">
|
||||
{isLoggedIn ? (
|
||||
<Link to="/home" className={navLinkClass}>Home</Link>
|
||||
) : (
|
||||
<Link to="/" className={navLinkClass}>Főoldal</Link>
|
||||
)}
|
||||
<Link to="/leaderboard" className={navLinkClass}>Leaderboard</Link>
|
||||
<Link to="/about" className={navLinkClass}>Rólunk</Link>
|
||||
<Link to="/companies" className={navLinkClass}>Kontakt</Link>
|
||||
{!isLoggedIn && (
|
||||
<Link to="/" onClick={() => setMenuOpen(false)} className={navLinkClass}>Főoldal</Link>
|
||||
<Link to="/about" onClick={() => setMenuOpen(false)} className={navLinkClass}>Rólunk</Link>
|
||||
<Link to="/contacts" onClick={() => setMenuOpen(false)} className={navLinkClass}>Kapcsolat</Link>
|
||||
{isLoggedIn && (
|
||||
<>
|
||||
<div className="px-2">
|
||||
<button
|
||||
onClick={() => {
|
||||
setMenuOpen(false)
|
||||
navigate("/")
|
||||
}}
|
||||
className="w-full text-left px-3 py-2 rounded-lg bg-white/10 hover:bg-white/20 text-white transition-all"
|
||||
>
|
||||
Játék
|
||||
</button>
|
||||
</div>
|
||||
<Link
|
||||
to="/login"
|
||||
className="block px-3 py-2 rounded-lg bg-white/10 hover:bg-white/20 text-white font-semibold transition-all"
|
||||
>
|
||||
Bejelentkezés / Regisztráció
|
||||
</Link>
|
||||
<Link to="/decks" onClick={() => setMenuOpen(false)} className={navLinkClass}>Paklik</Link>
|
||||
<Link to="/report" onClick={() => setMenuOpen(false)} className={navLinkClass}>Statisztikák</Link>
|
||||
</>
|
||||
)}
|
||||
{isLoggedIn && (
|
||||
<Link to="/home" onClick={() => setMenuOpen(false)} className={navLinkClassPlay}>Játék</Link>
|
||||
|
||||
{!isLoggedIn ? (
|
||||
<div className="flex flex-col space-y-2">
|
||||
<Link
|
||||
to="/login"
|
||||
onClick={() => setMenuOpen(false)}
|
||||
className="block px-3 py-2 rounded-lg hover:bg-white/20 text-white font-semibold transition-all"
|
||||
>
|
||||
Bejelentkezés
|
||||
</Link>
|
||||
|
||||
{/* Elválasztó vonal mobilon */}
|
||||
<div className="w-full h-px bg-white/30"></div>
|
||||
|
||||
<Link
|
||||
to="/register"
|
||||
onClick={() => setMenuOpen(false)}
|
||||
className="block px-3 py-2 rounded-lg bg-white/10 hover:bg-white/20 text-white font-semibold transition-all"
|
||||
>
|
||||
Regisztráció
|
||||
</Link>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex justify-end px-2 pb-2">
|
||||
<button
|
||||
onClick={handleLogout}
|
||||
onClick={() => {
|
||||
handleLogout()
|
||||
setMenuOpen(false)
|
||||
}}
|
||||
className="p-2 rounded-full bg-[#166534] hover:bg-[#1f7a45] text-white shadow-lg hover:shadow-green-400/40 transition-all transform hover:scale-105 cursor-pointer"
|
||||
title="Kijelentkezés"
|
||||
>
|
||||
|
||||
+23
-2
@@ -1,7 +1,7 @@
|
||||
import React from "react"
|
||||
import React, { useEffect, useRef, useState } from "react"
|
||||
import Navbar from "../../components/Navbar/Navbar.jsx"
|
||||
import Footer from "../../components/Footer/Footer.jsx"
|
||||
import Background from "../../assets/backgrounds/Background"
|
||||
import Background from "../../assets/backgrounds/Background.jsx"
|
||||
import {
|
||||
FaBuilding,
|
||||
FaEnvelope,
|
||||
@@ -56,6 +56,20 @@ const SectionContainer = ({ id, title, children }) => {
|
||||
}
|
||||
|
||||
const CompanyHub = () => {
|
||||
|
||||
const [visible, setVisible] = useState(false)
|
||||
const sectionRef = useRef(null)
|
||||
useEffect(() => {
|
||||
const observer = new IntersectionObserver(
|
||||
([entry]) => {
|
||||
if (entry.isIntersecting) setVisible(true)
|
||||
},
|
||||
{ threshold: 0.3 }
|
||||
)
|
||||
if (sectionRef.current) observer.observe(sectionRef.current)
|
||||
return () => observer.disconnect()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className=" relative min-h-screen text-white">
|
||||
{/* Background fixed behind everything */}
|
||||
@@ -67,6 +81,12 @@ const CompanyHub = () => {
|
||||
<Navbar />
|
||||
|
||||
<main className="flex-grow relative px-4 py-8 md:px-12 md:py-16 overflow-y-auto scroll-smooth">
|
||||
<section
|
||||
ref={sectionRef}
|
||||
className={`max-w-5xl mx-auto transition-all duration-1000 ease-out ${
|
||||
visible ? "opacity-100 translate-y-0" : "opacity-0 translate-y-10"
|
||||
}`}
|
||||
>
|
||||
<div className="flex justify-center gap-6 mt-8 flex-wrap">
|
||||
<Card
|
||||
icon={<FaBuilding />}
|
||||
@@ -215,6 +235,7 @@ const CompanyHub = () => {
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<Footer />
|
||||
@@ -2,7 +2,7 @@
|
||||
// Főoldal - Landing Page
|
||||
|
||||
|
||||
import { useNavigate } from "react-router-dom"
|
||||
import { data, useNavigate } from "react-router-dom"
|
||||
import Navbar from "../../components/Navbar/Navbar"
|
||||
import Footer from "../../components/Footer/Footer.jsx"
|
||||
import Background from "../../assets/backgrounds/Background.jsx"
|
||||
@@ -12,15 +12,22 @@ export default function LandingPageMain() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleNavigateToPlay = () => {
|
||||
navigate("/login");
|
||||
navigate("/login", { preventScrollReset: false });
|
||||
window.scrollTo(0, 0);
|
||||
};
|
||||
|
||||
const handleNavigateToAuth = () => {
|
||||
navigate("/register");
|
||||
navigate("/companies", { preventScrollReset: false });
|
||||
window.scrollTo(0, 0);
|
||||
};
|
||||
|
||||
const handleNavigateToGame = () => {
|
||||
navigate("/home");
|
||||
navigate("/home", { preventScrollReset: false });
|
||||
window.scrollTo(0, 0);
|
||||
};
|
||||
|
||||
const handleNavigateToContacts = () => {
|
||||
navigate("/contacts");
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -32,7 +39,7 @@ export default function LandingPageMain() {
|
||||
<Navbar />
|
||||
</div>
|
||||
<main className="flex-1 flex flex-col items-center justify-start py-15 min-h-0 mt-[64px]">
|
||||
<LandingPage onNavigateToPlay={handleNavigateToPlay} onNavigateToAuth={handleNavigateToAuth} onNavigateToGame={handleNavigateToGame} />
|
||||
<LandingPage onNavigateToContacts={handleNavigateToContacts} onNavigateToPlay={handleNavigateToPlay} onNavigateToAuth={handleNavigateToAuth} onNavigateToGame={handleNavigateToGame} />
|
||||
</main>
|
||||
<Footer />
|
||||
</div>
|
||||
|
||||
@@ -6,7 +6,7 @@ import Logo from "../../assets/pictures/Logo.jsx"
|
||||
import Navbar from "../../components/Navbar/Navbar"
|
||||
import Footer from "../../components/Footer/Footer.jsx"
|
||||
import UserProfile from "../../components/Userdetails/Userdetails.jsx"
|
||||
import CompanyHub from "../Companies/Companies.jsx"
|
||||
import CompanyHub from "../Contacts/Contacts.jsx"
|
||||
|
||||
import RatingSet from "../../components/PopUp/RatingSet" // <- statisztikai komponens
|
||||
|
||||
|
||||
Reference in New Issue
Block a user