-
navigate("/created/tournaments/view/0")} className="badge badge-info gap-2 font-bold">
+
navigate("/created/tournaments/view/"+user?.login+"/0")} className="badge badge-info gap-2 font-bold">
{"See more >>"}
@@ -203,7 +203,7 @@ export const ProfilePage= () => {
aria-label="Coordinated tournaments"/>
-
navigate("/coordinated/tournaments/view/0")} className="badge badge-info gap-2 font-bold">
+
navigate("/coordinated/tournaments/view/"+user?.login+"/0")} className="badge badge-info gap-2 font-bold">
{"See more >>"}
@@ -211,7 +211,7 @@ export const ProfilePage= () => {
-
navigate("/joined/tournaments/view/0")} className="badge badge-info gap-2 font-bold">
+
navigate("/joined/tournaments/view/"+user?.login+"/0")} className="badge badge-info gap-2 font-bold">
{"See more >>"}
diff --git a/IT/codekatabattle-frontend/src/components/VisualizeCoordinatedTournaments.tsx b/IT/codekatabattle-frontend/src/components/VisualizeCoordinatedTournaments.tsx
index 87bae26..d5951f7 100644
--- a/IT/codekatabattle-frontend/src/components/VisualizeCoordinatedTournaments.tsx
+++ b/IT/codekatabattle-frontend/src/components/VisualizeCoordinatedTournaments.tsx
@@ -1,4 +1,4 @@
-import { PageTournament, Tournament, TournamentService} from "../services/openapi";
+import {AuthService, PageTournament, Tournament, TournamentService} from "../services/openapi";
import {useContext, useEffect, useState} from "react";
import {NavBar} from "./NavBar.tsx";
import five from "../assets/high-five.png"
@@ -16,12 +16,17 @@ export const VisualizeCoordinatedTournaments= () => {
useEffect(() => {
fetchTournaments();
- }, [params,user]);
+ }, []);
async function fetchTournaments() {
try {
- if(user?.login) {
- const tournaments = await TournamentService.findAllCoordinatedByUser(user.login, +params.page!, 5);
+ let tuser;
+ if(!params.username) tuser=user;
+ else {
+ tuser = await AuthService.getUserInfo(params.username);
+ }
+ if(tuser?.login) {
+ const tournaments = await TournamentService.findAllCoordinatedByUser(tuser.login, +params.page!, 5);
setTournaments(tournaments);
}
@@ -33,7 +38,7 @@ export const VisualizeCoordinatedTournaments= () => {
function to(id: string | undefined) {
if (id != undefined) {
- const s = "/coordinated/tournaments/" + id;
+ const s = "/coordinated/tournaments/view/"+params.username+"/"+id;
navigate(s);
location.reload();
}
@@ -54,7 +59,7 @@ export const VisualizeCoordinatedTournaments= () => {
(to("view/1"))}/>
+ onClick={() => (to("1"))}/>
)
}
@@ -62,7 +67,7 @@ export const VisualizeCoordinatedTournaments= () => {
return (
(to("view/0"))}/>
+ onClick={() => (to("0"))}/>
@@ -75,13 +80,13 @@ export const VisualizeCoordinatedTournaments= () => {
aria-label={"Page " + (+params.page! + 1).toString()}
checked/>
(to("view/" + (+params.page! + 1).toString()))}/>
+ onClick={() => (to((+params.page! + 1).toString()))}/>
(to("view/" + ((tournaments?.totalPages ?? 2) - 2).toString()))}/>
+ onClick={() => (to(((tournaments?.totalPages ?? 2) - 2).toString()))}/>
(to("view/" + ((tournaments?.totalPages ?? 1) - 1).toString()))}/>
+ onClick={() => (to(((tournaments?.totalPages ?? 1) - 1).toString()))}/>
)
}
@@ -89,12 +94,12 @@ export const VisualizeCoordinatedTournaments= () => {
return (
(to("view/0"))}
+ onClick={() => (to("0"))}
/>
(to("view/1"))}/>
+ onClick={() => (to("1"))}/>
(to("view/" + (+params.page! - 1).toString()))}
+ onClick={() => (to( (+params.page! - 1).toString()))}
/>
{
}
return (
(to("view/0"))}
+ onClick={() => (to("0"))}
/>
(to("view/1"))}/>
+ onClick={() => (to("1"))}/>
(to("view/" + (+params.page! - 1).toString()))}
+ onClick={() => (to( (+params.page! - 1).toString()))}
/>
(to("view/" + (+params.page! + 1).toString()))}
+ onClick={() => (to( (+params.page! + 1).toString()))}
/>
(to("view/" + ((tournaments?.totalPages ?? 2) - 2).toString()))}/>
+ onClick={() => (to( ((tournaments?.totalPages ?? 2) - 2).toString()))}/>
(to("view/" + ((tournaments?.totalPages ?? 1) - 1).toString()))}/>
+ onClick={() => (to( ((tournaments?.totalPages ?? 1) - 1).toString()))}/>
)
}
diff --git a/IT/codekatabattle-frontend/src/components/VisualizeCreatedTournaments.tsx b/IT/codekatabattle-frontend/src/components/VisualizeCreatedTournaments.tsx
index 89166b7..1a05354 100644
--- a/IT/codekatabattle-frontend/src/components/VisualizeCreatedTournaments.tsx
+++ b/IT/codekatabattle-frontend/src/components/VisualizeCreatedTournaments.tsx
@@ -1,4 +1,4 @@
-import { PageTournament, Tournament, TournamentService} from "../services/openapi";
+import {AuthService, PageTournament, Tournament, TournamentService} from "../services/openapi";
import {useContext, useEffect, useState} from "react";
import {NavBar} from "./NavBar.tsx";
import fight from "../assets/fight.png"
@@ -15,12 +15,17 @@ export const VisualizeCreatedTournaments= () => {
const {user}=useContext(AuthContext);
useEffect(() => {
fetchTournaments();
- }, [params,user]);
+ }, []);
async function fetchTournaments() {
try {
- if(user?.login){
- const tournaments = await TournamentService.findAllCreatedByUser(user.login,+params.page!, 5);
+ let tuser;
+ if(!params.username) tuser=user;
+ else {
+ tuser = await AuthService.getUserInfo(params.username);
+ }
+ if(tuser?.login){
+ const tournaments = await TournamentService.findAllCreatedByUser(tuser.login,+params.page!, 5);
setTournaments(tournaments);
}
@@ -32,7 +37,7 @@ export const VisualizeCreatedTournaments= () => {
function to(id: string | undefined) {
if (id != undefined) {
- const s = "/created/tournaments/" + id;
+ const s = "/created/tournaments/view/"+params.username+"/"+id;
navigate(s);
location.reload();
}
@@ -53,7 +58,7 @@ export const VisualizeCreatedTournaments= () => {
(to("view/1"))}/>
+ onClick={() => (to("1"))}/>
)
}
@@ -61,7 +66,7 @@ export const VisualizeCreatedTournaments= () => {
return (
(to("view/0"))}/>
+ onClick={() => (to("0"))}/>
@@ -74,13 +79,13 @@ export const VisualizeCreatedTournaments= () => {
aria-label={"Page " + (+params.page! + 1).toString()}
checked/>
(to("view/" + (+params.page! + 1).toString()))}/>
+ onClick={() => (to( (+params.page! + 1).toString()))}/>
(to("view/" + ((tournaments?.totalPages ?? 2) - 2).toString()))}/>
+ onClick={() => (to( ((tournaments?.totalPages ?? 2) - 2).toString()))}/>
(to("view/" + ((tournaments?.totalPages ?? 1) - 1).toString()))}/>
+ onClick={() => (to( ((tournaments?.totalPages ?? 1) - 1).toString()))}/>
)
}
@@ -88,12 +93,12 @@ export const VisualizeCreatedTournaments= () => {
return (
(to("view/0"))}
+ onClick={() => (to("0"))}
/>
(to("view/1"))}/>
+ onClick={() => (to("1"))}/>
(to("view/" + (+params.page! - 1).toString()))}
+ onClick={() => (to( (+params.page! - 1).toString()))}
/>
{
}
return (
(to("view/0"))}
+ onClick={() => (to("0"))}
/>
(to("view/1"))}/>
+ onClick={() => (to("1"))}/>
(to("view/" + (+params.page! - 1).toString()))}
+ onClick={() => (to( (+params.page! - 1).toString()))}
/>
(to("view/" + (+params.page! + 1).toString()))}
+ onClick={() => (to((+params.page! + 1).toString()))}
/>
(to("view/" + ((tournaments?.totalPages ?? 2) - 2).toString()))}/>
+ onClick={() => (to( ((tournaments?.totalPages ?? 2) - 2).toString()))}/>
(to("view/" + ((tournaments?.totalPages ?? 1) - 1).toString()))}/>
+ onClick={() => (to( ((tournaments?.totalPages ?? 1) - 1).toString()))}/>
)
}
diff --git a/IT/codekatabattle-frontend/src/components/VisualizeJoinedTournaments.tsx b/IT/codekatabattle-frontend/src/components/VisualizeJoinedTournaments.tsx
index 8dfdc72..1eb9b05 100644
--- a/IT/codekatabattle-frontend/src/components/VisualizeJoinedTournaments.tsx
+++ b/IT/codekatabattle-frontend/src/components/VisualizeJoinedTournaments.tsx
@@ -1,4 +1,4 @@
-import { PageTournament, Tournament, TournamentService} from "../services/openapi";
+import {AuthService, PageTournament, Tournament, TournamentService} from "../services/openapi";
import {useContext, useEffect, useState} from "react";
import {NavBar} from "./NavBar.tsx";
import join from "../assets/join.png"
@@ -15,12 +15,17 @@ export const VisualizeJoinedTournaments= () => {
const {user}=useContext(AuthContext);
useEffect(() => {
fetchTournaments();
- }, [params,user]);
+ }, []);
async function fetchTournaments() {
try {
- if(user?.login){
- const tournaments = await TournamentService.findAllJoinedByUser(user.login,+params.page!, 5);
+ let tuser;
+ if(!params.username) tuser=user;
+ else {
+ tuser = await AuthService.getUserInfo(params.username);
+ }
+ if(tuser?.login){
+ const tournaments = await TournamentService.findAllJoinedByUser(tuser.login,+params.page!, 5);
setTournaments(tournaments);
}
@@ -32,7 +37,7 @@ export const VisualizeJoinedTournaments= () => {
function to(id: string | undefined) {
if (id != undefined) {
- const s = "/joined/tournaments/" + id;
+ const s = "/joined/tournaments/view/" +params.username+"/"+ id;
navigate(s);
location.reload();
}
@@ -53,7 +58,7 @@ export const VisualizeJoinedTournaments= () => {
(to("view/1"))}/>
+ onClick={() => (to("1"))}/>
)
}
@@ -61,7 +66,7 @@ export const VisualizeJoinedTournaments= () => {
return (
(to("view/0"))}/>
+ onClick={() => (to("0"))}/>
@@ -74,13 +79,13 @@ export const VisualizeJoinedTournaments= () => {
aria-label={"Page " + (+params.page! + 1).toString()}
checked/>
(to("view/" + (+params.page! + 1).toString()))}/>
+ onClick={() => (to( (+params.page! + 1).toString()))}/>
(to("view/" + ((tournaments?.totalPages ?? 2) - 2).toString()))}/>
+ onClick={() => (to(((tournaments?.totalPages ?? 2) - 2).toString()))}/>
(to("view/" + ((tournaments?.totalPages ?? 1) - 1).toString()))}/>
+ onClick={() => (to(((tournaments?.totalPages ?? 1) - 1).toString()))}/>
)
}
@@ -88,12 +93,12 @@ export const VisualizeJoinedTournaments= () => {
return (
(to("view/0"))}
+ onClick={() => (to("0"))}
/>
(to("view/1"))}/>
+ onClick={() => (to("1"))}/>
(to("view/" + (+params.page! - 1).toString()))}
+ onClick={() => (to( (+params.page! - 1).toString()))}
/>
{
}
return (
(to("view/0"))}
+ onClick={() => (to("0"))}
/>
(to("view/1"))}/>
+ onClick={() => (to("1"))}/>
(to("view/" + (+params.page! - 1).toString()))}
+ onClick={() => (to( (+params.page! - 1).toString()))}
/>
(to("view/" + (+params.page! + 1).toString()))}
+ onClick={() => (to( (+params.page! + 1).toString()))}
/>
(to("view/" + ((tournaments?.totalPages ?? 2) - 2).toString()))}/>
+ onClick={() => (to( ((tournaments?.totalPages ?? 2) - 2).toString()))}/>
(to("view/" + ((tournaments?.totalPages ?? 1) - 1).toString()))}/>
+ onClick={() => (to( ((tournaments?.totalPages ?? 1) - 1).toString()))}/>
)
}
diff --git a/IT/codekatabattle-frontend/src/main.tsx b/IT/codekatabattle-frontend/src/main.tsx
index 3ad0445..eb8d55c 100644
--- a/IT/codekatabattle-frontend/src/main.tsx
+++ b/IT/codekatabattle-frontend/src/main.tsx
@@ -43,17 +43,17 @@ const router = createBrowserRouter([
},
{
- path: "/created/tournaments/view/:page",
+ path: "/created/tournaments/view/:username/:page",
element:
,
},
{
- path: "/joined/tournaments/view/:page",
+ path: "/joined/tournaments/view/:username/:page",
element:
,
},
{
- path: "/coordinated/tournaments/view/:page",
+ path: "/coordinated/tournaments/view/:username/:page",
element:
,
},