variable d'environnement pour le path
continuous-integration/drone/push Build is passing Details

pull/97/head^2
Thomas Chazot 1 year ago
parent a05f07f80c
commit 2c298aca47

@ -1,9 +0,0 @@
<FilesMatch "\.css$">
ForceType text/css
Header set Content-Type "text/css"
</FilesMatch>
<FilesMatch "\.js$">
ForceType application/javascript
Header set Content-Type "application/javascript"
</FilesMatch>

@ -58,9 +58,13 @@ function App() {
setLocale(newLocale); setLocale(newLocale);
}; };
const basePath = process.env.REACT_APP_BASE_PATH || '';
console.log(basePath)
//const location = useLocation(); //const location = useLocation();
const hasNavbarVisible = ["/containers/Crypteam-website/", "/containers/Crypteam-website/login", "/containers/Crypteam-website/signup", "/containers/Crypteam-website/play", "/containers/Crypteam-website/lobby", "/containers/Crypteam-website/endgame", "/containers/Crypteam-website/deduc"]//.includes(window.location.pathname); const hasNavbarVisible = [basePath + "/", basePath + "/login", basePath + "/signup", basePath + "/play", basePath + "/lobby", basePath + "/endgame", basePath + "/deduc"]//.includes(window.location.pathname);
return ( return (
@ -73,17 +77,18 @@ function App() {
<BrowserRouter> <BrowserRouter>
{hasNavbarVisible && <AppNavbar changeLocale={changeLocale} />} {hasNavbarVisible && <AppNavbar changeLocale={changeLocale} />}
<Routes> <Routes>
<Route path="/containers/Crypteam-website/" element={<NewPlay/>} />
<Route path="/containers/Crypteam-website/login" element={<Login />} /> <Route path={`${basePath}/`} element={<NewPlay/>} />
<Route path="/containers/Crypteam-website/signup" element={<SignUp />} /> <Route path={`${basePath}/login`} element={<Login />} />
<Route path="/containers/Crypteam-website/presentation" element={<Home />} /> <Route path={`${basePath}/signup`} element={<SignUp />} />
<Route path="/containers/Crypteam-website/lobby" element={<Lobby/>} /> <Route path={`${basePath}/presentation`} element={<Home />} />
<Route path="/containers/Crypteam-website/endgame" element={<EndGame/>} /> <Route path={`${basePath}/lobby`} element={<Lobby/>} />
<Route path="/containers/Crypteam-website/game" element={<InGame locale={locale} changeLocale={changeLocale}/>}/> <Route path={`${basePath}/endgame`} element={<EndGame/>} />
<Route path="/containers/Crypteam-website/info" element={<InfoPage locale={locale} changeLocale={changeLocale}/>} /> <Route path={`${basePath}/game`} element={<InGame locale={locale} changeLocale={changeLocale}/>}/>
<Route path="/containers/Crypteam-website/deduc" element={<DeducGrid/>} /> <Route path={`${basePath}/info`} element={<InfoPage locale={locale} changeLocale={changeLocale}/>} />
<Route path="/containers/Crypteam-website/profile" element={<Profile/>} /> <Route path={`${basePath}/deduc`} element={<DeducGrid/>} />
<Route path="/containers/Crypteam-website/join" element={<Lobbies/>}/> <Route path={`${basePath}/profile`} element={<Profile/>} />
<Route path={`${basePath}/join`} element={<Lobbies/>}/>
{/* <Route path="/solo" element={<SoloGame locale={locale} changeLocale={changeLocale} />}/> */} {/* <Route path="/solo" element={<SoloGame locale={locale} changeLocale={changeLocale} />}/> */}
<Route path="*" element={<ErrorPage code="404" msg='not found' />} /> {/* page 404 */} <Route path="*" element={<ErrorPage code="404" msg='not found' />} /> {/* page 404 */}

@ -67,6 +67,8 @@ let cptBug = 0
let cptUseEffect = 0 let cptUseEffect = 0
let testPlayers: Player[] = [] let testPlayers: Player[] = []
const basePath = process.env.REACT_APP_BASE_PATH || '';
const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, isEasy, addToHistory, showLast, setNetwork, setNetworkEnigme, setPlayerIndex, askedWrong, setAskedWrong, importToPdf, setImportToPdf}) => { const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleShowTurnBar, handleTurnBarTextChange, playerTouched, setPlayerTouched, changecptTour, solo, isDaily, isEasy, addToHistory, showLast, setNetwork, setNetworkEnigme, setPlayerIndex, askedWrong, setAskedWrong, importToPdf, setImportToPdf}) => {
let cptTour: number = 0 let cptTour: number = 0
@ -809,7 +811,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
socket.off("put imossible grey") socket.off("put imossible grey")
socket.off("who plays") socket.off("who plays")
navigate("/endgame") navigate(`${basePath}/endgame`)
} }
} }
}) })
@ -1018,8 +1020,7 @@ const MyGraphComponent: React.FC<MyGraphComponentProps> = ({onNodeClick, handleS
catch(error){ catch(error){
console.log(error); console.log(error);
} }
navigate(`${basePath}/endgame?solo=true+${isDaily}`)
navigate("/endgame?solo=true&daily=" + isDaily)
} }
} }

@ -20,6 +20,8 @@ interface LobbyContainerProps {
//? mettre un "nbplayermax" si le nombre de joueur max peut etre fixé ? //? mettre un "nbplayermax" si le nombre de joueur max peut etre fixé ?
} }
const basePath = process.env.REACT_APP_BASE_PATH || '';
const LobbyContainer: React.FC<LobbyContainerProps> = ({roomNum, HeadPlayer, nbPlayer, setFirst, started}) => { const LobbyContainer: React.FC<LobbyContainerProps> = ({roomNum, HeadPlayer, nbPlayer, setFirst, started}) => {
const theme=useTheme(); const theme=useTheme();
@ -47,7 +49,7 @@ const LobbyContainer: React.FC<LobbyContainerProps> = ({roomNum, HeadPlayer, nbP
if (nbPlayer < 6 && !started) { if (nbPlayer < 6 && !started) {
socket.off("request lobbies") socket.off("request lobbies")
setFirst(true) setFirst(true)
navigate(dest); navigate(`${basePath}/${dest}`);
} }
else if(started){ else if(started){
handleShowStart() handleShowStart()

@ -25,6 +25,9 @@ import { useTheme } from '../Style/ThemeContext';
import { useAuth } from '../Contexts/AuthContext'; import { useAuth } from '../Contexts/AuthContext';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
const basePath = process.env.REACT_APP_BASE_PATH || '';
// @ts-ignore // @ts-ignore
function AppNavbar({changeLocale}) { function AppNavbar({changeLocale}) {
const theme = useTheme(); const theme = useTheme();
@ -34,11 +37,11 @@ function AppNavbar({changeLocale}) {
function navigateToProfile(){ function navigateToProfile(){
navigate("/profile") navigate(`${basePath}/profile`)
} }
function navigateToHome(){ function navigateToHome(){
navigate("/") navigate(`${basePath}/`)
} }
return ( return (

@ -6,6 +6,7 @@ import './ErrorStyle.css';
import { FormattedMessage } from 'react-intl'; import { FormattedMessage } from 'react-intl';
import { Button } from 'react-bootstrap'; import { Button } from 'react-bootstrap';
const basePath = process.env.REACT_APP_BASE_PATH || '';
//@ts-ignore //@ts-ignore
@ -28,7 +29,7 @@ function ErrorPage({ code = "", msg = "Something is wrong"}) {
</div> </div>
<div className='centerDivH' style={{margin: "20px"}}> <div className='centerDivH' style={{margin: "20px"}}>
<Button href='/' variant='danger'>Retour à l'accueil</Button> <Button href={`${basePath}/join`} variant='danger'>Retour à l'accueil</Button>
</div> </div>
</div> </div>
); );

@ -52,6 +52,8 @@ import Indice from '../model/Indices/Indice';
let cptNavigation = 0 let cptNavigation = 0
const basePath = process.env.REACT_APP_BASE_PATH || '';
//@ts-ignore //@ts-ignore
const InGame = ({locale, changeLocale}) => { const InGame = ({locale, changeLocale}) => {
@ -66,7 +68,7 @@ const InGame = ({locale, changeLocale}) => {
if (cptNavigation % 2 == 0){ if (cptNavigation % 2 == 0){
if (navigationType.toString() == "POP"){ if (navigationType.toString() == "POP"){
socket.emit("player quit") socket.emit("player quit")
navigate("/play") navigate(`${basePath}/play`)
} }
} }

@ -50,6 +50,8 @@ import { DataSet } from 'vis-network';
let gameStarted = false let gameStarted = false
let firstLaunch = true let firstLaunch = true
const basePath = process.env.REACT_APP_BASE_PATH || '';
function Lobby() { function Lobby() {
const theme=useTheme(); const theme=useTheme();
@ -134,7 +136,7 @@ function Lobby() {
gameStarted = true gameStarted = true
//socket.off("player left") //socket.off("player left")
//socket.off("new player") //socket.off("new player")
navigate('/game?solo=false&daily=false'); navigate(`${basePath}/game?solo=false&daily=false`);
}); });
@ -170,7 +172,7 @@ function Lobby() {
setIndicesData(choosenIndices) setIndicesData(choosenIndices)
first = true first = true
gameStarted = true gameStarted = true
navigate('/game?solo=false&daily=false'); navigate(`${basePath}/game?solo=false&daily=false`)
}); });
socket.on("new player", (tab) =>{ socket.on("new player", (tab) =>{
@ -185,17 +187,17 @@ function Lobby() {
socket.on("room full", () => { socket.on("room full", () => {
//TODO POP UP pour quand la room est pleine //TODO POP UP pour quand la room est pleine
navigate("/play") navigate(`${basePath}/play`)
}) })
socket.on("game started", () => { socket.on("game started", () => {
//TODO POP UP pour quand la room est pleine //TODO POP UP pour quand la room est pleine
navigate("/play") navigate(`${basePath}/play`)
}) })
socket.on("game already started", () => { socket.on("game already started", () => {
//TODO POP UP pour quand la room est pleine //TODO POP UP pour quand la room est pleine
navigate("/play") navigate(`${basePath}/play`)
}) })
socket.on("player left", (tab, i) => { socket.on("player left", (tab, i) => {

@ -5,6 +5,8 @@ import { useAuth } from '../Contexts/AuthContext';
import AuthService from '../services/AuthService'; import AuthService from '../services/AuthService';
import '../Style/Global.css'; import '../Style/Global.css';
const basePath = process.env.REACT_APP_BASE_PATH || '';
const SignIn = () => { const SignIn = () => {
const navigate = useNavigate(); const navigate = useNavigate();
const { login } = useAuth(); const { login } = useAuth();
@ -35,7 +37,7 @@ const SignIn = () => {
setShowConfirmation(true); setShowConfirmation(true);
setTimeout(async () => { setTimeout(async () => {
await login(); await login();
navigate('/'); navigate(`${basePath}/`);
}, 1250); }, 1250);
} }
} catch (error: any) { } catch (error: any) {

@ -34,6 +34,9 @@ import Lobbies from './Lobbies';
let cptNavigation = 0 let cptNavigation = 0
const basePath = process.env.REACT_APP_BASE_PATH || '';
function NewPlay() { function NewPlay() {
let first = true let first = true
@ -97,7 +100,7 @@ function NewPlay() {
setPersonNetworkData(networkPerson) setPersonNetworkData(networkPerson)
setIndicesData(choosenIndices) setIndicesData(choosenIndices)
setIndicesData(choosenIndices) setIndicesData(choosenIndices)
navigate('/game?solo=true&daily=false'); navigate(`${basePath}/game?solo=true&daily=false`);
} }
@ -128,12 +131,12 @@ function NewPlay() {
useEffect(() => { useEffect(() => {
if (room !== null) { if (room !== null) {
const nouvelleURL = `/lobby?room=${room}`; const nouvelleURL = `/lobby?room=${room}`;
navigate(nouvelleURL); navigate(`${basePath}${nouvelleURL}`)
} }
}, [room, navigate]); }, [room, navigate]);
const goBack = () => { const goBack = () => {
navigate("/lobby?room=" + goBackRoom) navigate(`${basePath}/lobby?room=${goBackRoom}`)
} }
@ -156,7 +159,7 @@ function NewPlay() {
setIndicesData(choosenIndices) setIndicesData(choosenIndices)
setIndicesData(choosenIndices) setIndicesData(choosenIndices)
navigate('/game?solo=true&daily=true&easy=true'); navigate(`${basePath}/game?solo=true&daily=true&easy=true`);
setShowOverlay(false); setShowOverlay(false);
}; };
@ -174,7 +177,7 @@ function NewPlay() {
const map = EnigmeDuJourCreator.createEnigme(networkPerson, choosenIndices, choosenPerson, Stub.GenerateIndice()) const map = EnigmeDuJourCreator.createEnigme(networkPerson, choosenIndices, choosenPerson, Stub.GenerateIndice())
setDailyEnigmeData(map) setDailyEnigmeData(map)
} }
navigate('/game?solo=true&daily=true&easy=false'); navigate(`${basePath}/game?solo=true&daily=true&easy=false`);
setShowOverlay(false); setShowOverlay(false);
}; };

@ -32,6 +32,8 @@ import Info from '../res/icon/infoGreen.png';
let cptNavigation = 0 let cptNavigation = 0
const basePath = process.env.REACT_APP_BASE_PATH || '';
function Play() { function Play() {
let first = true let first = true
@ -98,7 +100,7 @@ function Play() {
setPersonNetworkData(networkPerson) setPersonNetworkData(networkPerson)
setIndicesData(choosenIndices) setIndicesData(choosenIndices)
setIndicesData(choosenIndices) setIndicesData(choosenIndices)
navigate('/game?solo=true&daily=false'); navigate(`${basePath}/game?solo=true&daily=false`);
} }
@ -129,12 +131,12 @@ function Play() {
useEffect(() => { useEffect(() => {
if (room !== null) { if (room !== null) {
const nouvelleURL = `/lobby?room=${room}`; const nouvelleURL = `/lobby?room=${room}`;
navigate(nouvelleURL); navigate(`${basePath}${nouvelleURL}`);
} }
}, [room, navigate]); }, [room, navigate]);
const goBack = () => { const goBack = () => {
navigate("/lobby?room=" + goBackRoom) navigate(`${basePath}/lobby?room=${goBackRoom}`)
} }
@ -157,7 +159,7 @@ function Play() {
setIndicesData(choosenIndices) setIndicesData(choosenIndices)
setIndicesData(choosenIndices) setIndicesData(choosenIndices)
navigate('/game?solo=true&daily=true&easy=true'); navigate(`${basePath}/game?solo=true&daily=true&easy=true`);
setShowOverlay(false); setShowOverlay(false);
}; };
@ -175,7 +177,7 @@ function Play() {
const map = EnigmeDuJourCreator.createEnigme(networkPerson, choosenIndices, choosenPerson, Stub.GenerateIndice()) const map = EnigmeDuJourCreator.createEnigme(networkPerson, choosenIndices, choosenPerson, Stub.GenerateIndice())
setDailyEnigmeData(map) setDailyEnigmeData(map)
} }
navigate('/game?solo=true&daily=true&easy=false'); navigate(`${basePath}/game?solo=true&daily=true&easy=false`);
setShowOverlay(false); setShowOverlay(false);
}; };
@ -238,7 +240,7 @@ function Play() {
<button onClick={createLobby} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Créer une partie </button> <button onClick={createLobby} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Créer une partie </button>
<button onClick= {() => navigate("/join")} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Rejoindre </button> <button onClick= {() => navigate(`${basePath}/join`)} className="ButtonNav" style={{backgroundColor: theme.colors.primary, borderColor: theme.colors.secondary}}> Rejoindre </button>
</div> </div>
</div> </div>
<div className='rightContainer'> <div className='rightContainer'>

@ -25,6 +25,8 @@ import Form from 'react-bootstrap/Form';
import ProgressBar from 'react-bootstrap/ProgressBar'; import ProgressBar from 'react-bootstrap/ProgressBar';
const basePath = process.env.REACT_APP_BASE_PATH || '';
//@ts-ignore //@ts-ignore
const Profile = () => { const Profile = () => {
@ -184,7 +186,7 @@ const Profile = () => {
} }
handleCloseDeleteModal(); handleCloseDeleteModal();
navigate("/") navigate(`${basePath}/`)
} else { } else {
console.error('Phrase de confirmation incorrecte.'); console.error('Phrase de confirmation incorrecte.');

@ -4,6 +4,9 @@ import { useNavigate } from 'react-router-dom';
import AuthService from '../services/AuthService'; import AuthService from '../services/AuthService';
import '../Style/Global.css'; import '../Style/Global.css';
const basePath = process.env.REACT_APP_BASE_PATH || '';
const SignUp = () => { const SignUp = () => {
const navigate = useNavigate(); const navigate = useNavigate();
@ -32,7 +35,7 @@ const SignUp = () => {
setShowConfirmation(true); setShowConfirmation(true);
setTimeout(() => { setTimeout(() => {
navigate('/login'); // 3 secondes avant de rediriger vers la page de connexion navigate(`${basePath}/login`); // 3 secondes avant de rediriger vers la page de connexion
}, 1250); }, 1250);
} }
} catch (error: any) { } catch (error: any) {

Loading…
Cancel
Save