Skip to content

Commit

Permalink
Merge pull request #319 from zstenger93/api_new
Browse files Browse the repository at this point in the history
Api new
  • Loading branch information
Lacusch authored Apr 21, 2024
2 parents 40705ca + c2d9423 commit a909ecc
Show file tree
Hide file tree
Showing 15 changed files with 91 additions and 101 deletions.
2 changes: 1 addition & 1 deletion frontend/public/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
counter--;
setTimeout(updateCounter, 1150);
} else {
window.location.href = '/Transcendence/';
window.location.href = '/';
}
}

Expand Down
12 changes: 1 addition & 11 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { I18nextProvider, useTranslation } from "react-i18next";
import Translation from "./components/Translation";
import Home from "./pages/Home";
import Chat from "./pages/Chat";
import Games from "./pages/Games/Games";
import About from "./pages/About";
import NotFound from "./components/404";
import Sidebar from "./components/hamburger_menu/Hamburger";
Expand Down Expand Up @@ -47,7 +46,6 @@ const PageWrapper = ({ children, image, showSidebar = true, redirectUri }) => {
function App() {
const { i18n } = useTranslation();
const basename = "";
// process.env.NODE_ENV === "production" ? "/Transcendence" : "";
let REDIRECT_URI;

if (process.env.NODE_ENV === "development") {
Expand Down Expand Up @@ -107,14 +105,6 @@ function App() {
</PageWrapper>
}
/>
<Route
path="games"
element={
<PageWrapper image={Background} redirectUri={REDIRECT_URI}>
<Games />
</PageWrapper>
}
/>
<Route
path="profile"
element={
Expand Down Expand Up @@ -173,7 +163,7 @@ function App() {
</PageWrapper>
}
/>
<Route
<Route
path="tournament"
element={
<PageWrapper image={Background} redirectUri={REDIRECT_URI}>
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/components/game/HowToPlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ const HowToPlay = ({ isOpen, setIsOpen, background, backgroundimage }) => {
{t("If the blackhole swallows your planets, you lose.")}
</p>
</div>
<div className="text-center">
<h1 className="text-4xl mb-10">{t("Tournament")}</h1>
<p>
{t("Play a Tournament against other players.")}
<br />
{t("This mode is played in multiple rounds.")}
<br />
{t("You need to provide the nicknames for the participants")}
<br />
{t("Choose if they are real players or an AI.")}
</p>
</div>
<div className="text-center">
<h1 className="text-4xl mb-10">{t("Keybinds")}</h1>
<div className="flex justify-between">
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/hamburger_menu/HamburgerMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const HamburgerMenu = ({
<SidebarIcon
icon={<SiGameandwatch size="32" />}
text={t("Play or Watch Games")}
to="/games"
to="/choosepongmode"
/>
<SidebarIcon
icon={<FaUser size="32" />}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/sidebar/Sidebar_Monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const SidebarContent = ({ t, changeLanguage, redirectUri }) => {
<SidebarIcon
icon={<SiGameandwatch size="32" />}
text={t("Play or Watch Games")}
to="/games"
to="/choosepongmode"
/>
<SidebarIcon
icon={<FaUser size="32" />}
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"The Project": "Das Projekt",
"16 Major & 11 Minor modules": "16 Haupt- und 11 Nebenmodule",
"Web": "Web",
"Play a Tournament against other players.": "Spielen Sie ein Turnier gegen andere Spieler.",
"This mode is played in multiple rounds.": "Dieser Modus wird in mehreren Runden gespielt.",
"You need to provide the nicknames for the participants": "Sie müssen die Nicknamen der Teilnehmer angeben.",
"Choose if they are real players or an AI.": "Wählen Sie aus, ob es sich um echte Spieler oder eine KI handelt.",
"Use a framework as backend": "Verwenden Sie ein Framework als Backend",
"Use a front-end framework or toolkit": "Verwenden Sie ein Front-End-Framework oder -Toolkit",
"Use a database for the backend": "Verwenden Sie eine Datenbank für das Backend",
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/locales/en/translation.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
{
"Delete Account": "Delete Account",
"Are you sure you want to delete your account?" : "Are you sure you want to delete your account?",
"Are you sure you want to delete your account?": "Are you sure you want to delete your account?",
"Submit": "Submit",
"New Password ": "New Password ",
"Confirm New Password ": "Confirm New Password ",
"2 Factor Authentication": "2 Factor Authentication",
"Settings": "Settings",
"Passwords do not match": "Passwords do not match",
"Tournament": "Tournament",

"Private": "Private",
"Expanding browser compatibility": "Expanding browser compatibility",
"Play a Tournament against other players.": "Play a Tournament against other players.",
"This mode is played in multiple rounds.": "This mode is played in multiple rounds.",
"You need to provide the nicknames for the participants": "You need to provide the nicknames for the participants",
"Choose if they are real players or an AI.": "Choose if they are real players or an AI.",

"The Project": "The Project",
"16 Major & 11 Minor modules": "16 Major & 11 Minor modules",
Expand Down Expand Up @@ -69,10 +73,6 @@
"Can you navigate thru the asteroid fields?": "Can you navigate thru the asteroid fields?",
"Contributors": "Contributors",





"How to play": "How to play",
"The classic game of Pong.": "The classic game of Pong.",
"Hit the ball back and forth": "Hit the ball back and forth",
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"The Project": "Le Projet",
"16 Major & 11 Minor modules": "16 Modules Majeurs & 11 Modules Mineurs",
"Web": "Web",
"Play a Tournament against other players.": "Jouez un tournoi contre d'autres joueurs.",
"This mode is played in multiple rounds.": "Ce mode se joue en plusieurs rounds.",
"You need to provide the nicknames for the participants": "Vous devez fournir les surnoms des participants.",
"Choose if they are real players or an AI.": "Choisissez s'ils sont de vrais joueurs ou une IA.",
"Use a framework as backend": "Utiliser un framework en tant que backend",
"Use a front-end framework or toolkit": "Utiliser un framework ou une boîte à outils en front-end",
"Use a database for the backend": "Utiliser une base de données pour le backend",
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/hu/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"The Project": "A Projekt",
"16 Major & 11 Minor modules": "16 fő és 11 kisebb modul",
"Web": "Web",
"Play a Tournament against other players.": "Játsszon egy versenyt más játékosok ellen.",
"This mode is played in multiple rounds.": "Ez a mód több fordulóban játszható.",
"You need to provide the nicknames for the participants": "Meg kell adnia a résztvevők becenevét.",
"Choose if they are real players or an AI.": "Válasszon valódi játékos vagy mesterséges intelligencia ellenfelet.",
"Use a framework as backend": "Használjon egy keretrendszert a háttérben",
"Use a front-end framework or toolkit": "Használjon egy front-end keretrendszert vagy eszköztárat",
"Use a database for the backend": "Használjon adatbázist a háttérben",
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/locales/jp/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"The Project": "プロジェクト",
"16 Major & 11 Minor modules": "16のメジャーモジュールと11のマイナーモジュール",
"Web": "ウェブ",
"Play a Tournament against other players.": "他のプレイヤーとトーナメントをプレイします。",
"This mode is played in multiple rounds.": "このモードは複数のラウンドでプレイされます。",
"You need to provide the nicknames for the participants": "参加者のニックネームを提供する必要があります。",
"Choose if they are real players or an AI.": "彼らが実際のプレイヤーかAIかを選択してください。",
"Use a framework as backend": "バックエンドとしてフレームワークを使用する",
"Use a front-end framework or toolkit": "フロントエンドのフレームワークやツールキットを使用する",
"Use a database for the backend": "バックエンドにデータベースを使用する",
Expand Down
20 changes: 16 additions & 4 deletions frontend/src/pages/About.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,20 @@ import zsolt from "../images/about/zsolt.jpeg";
import jamshidbek from "../images/about/jamshidbek.jpg";
import karlis from "../images/about/karlis.png";
import laszlo from "../images/about/laszlo.png";
import Cookies from "js-cookie";

function About() {
useEffect(() => {
setTimeout(() => {
const accessToken = Cookies.get("access");
console.log(accessToken);

if (!accessToken) {
window.location.href = "/404.html";
}
}, 1000);
}, []);

const [selectedCard, setSelectedCard] = React.useState(null);
const { t } = useTranslation();
const teamMembers = [
Expand Down Expand Up @@ -121,10 +133,10 @@ function About() {
flex flex-col items-center justify-start transition-all duration-800
ease-in-out transform-gpu shadow-2xl
${
selectedCard === index
? "w-96 absolute top-1/2 transform -translate-y-1/2"
: ""
}`}
selectedCard === index
? "w-96 absolute top-1/2 transform -translate-y-1/2"
: ""
}`}
style={{
backgroundImage: `url(${backgroundImage})`,
transition: "transform 0.0s ease-in-out",
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/pages/Chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,20 @@ import {
unblockUser,
getBlockedUsers,
} from "../components/API";
import Cookies from "js-cookie";

function Chat({ redirectUri }) {
useEffect(() => {
setTimeout(() => {
const accessToken = Cookies.get("access");
console.log(accessToken);

if (!accessToken) {
window.location.href = "/404.html";
}
}, 1000);
}, []);

const { t } = useTranslation();
const navigate = useNavigate();
const [currentChannel, setCurrentChannel] = useState("General");
Expand Down
75 changes: 0 additions & 75 deletions frontend/src/pages/Games/Games.js

This file was deleted.

14 changes: 13 additions & 1 deletion frontend/src/pages/Home.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* disable eslint */

import React from "react";
import React, { useEffect} from "react";
import WelcomeMessage from "../components/home/WelcomeMessage";
import Readme from "../components/home/Readme";
import Sidebar from "../components/hamburger_menu/Hamburger";
import Cookies from "js-cookie";

function ScrollDownIndicator() {
return (
Expand All @@ -16,6 +17,17 @@ function ScrollDownIndicator() {
}

function Home({ redirectUri }) {
useEffect(() => {
setTimeout(() => {
const accessToken = Cookies.get("access");
console.log(accessToken);

if (!accessToken) {
window.location.href = "/404.html";
}
}, 1000);
}, []);

return (
<>
<div className="relative h-screen flex items-center justify-center">
Expand Down
13 changes: 12 additions & 1 deletion frontend/src/pages/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,17 @@ const defaultUserDetails = {
};

function Profile({ redirectUri }) {
useEffect(() => {
setTimeout(() => {
const accessToken = Cookies.get("access");
console.log(accessToken);

if (!accessToken) {
window.location.href = "/404.html";
}
}, 1000);
}, []);

const [userDetails, setUserDetails] = useState(null);
const [imageUrl, setImageUrl] = useState(defaultUserDetails.profile_picture);
const [username, setUsername] = useState(
Expand All @@ -241,7 +252,7 @@ function Profile({ redirectUri }) {
.replace("('", "")
.replace("',)", "")
.replace("v2/", "")
.replace("api", "profile"),
.replace("api", "profile"),
};
});

Expand Down

0 comments on commit a909ecc

Please sign in to comment.