This commit is contained in:
Lukian LEIZOUR 2024-06-04 15:14:31 +02:00
parent 4bb31eb679
commit fbf07e772d
4 changed files with 10 additions and 6 deletions

View file

@ -7,13 +7,13 @@ export default function HelpButton({ gameid, helpingprop, token }) {
console.log("helpingprop:", helpingprop) console.log("helpingprop:", helpingprop)
function addHelper() { function addHelper() {
axios.post("http://leizour.fr:3000/api/v1/games/addHelper", { token, gameid }) axios.post("https://leizour.fr/api/v1/games/addHelper", { token, gameid })
.then(() => setHelping(true)) .then(() => setHelping(true))
.catch((error) => console.error("Error adding helper")); .catch((error) => console.error("Error adding helper"));
} }
function removeHelper() { function removeHelper() {
axios.post("http://leizour.fr:3000/api/v1/games/removeHelper", { token, gameid }) axios.post("https://leizour.fr/api/v1/games/removeHelper", { token, gameid })
.then(() => setHelping(false)) .then(() => setHelping(false))
.catch((error) => console.error("Error removing helper")); .catch((error) => console.error("Error removing helper"));
} }
@ -27,6 +27,10 @@ export default function HelpButton({ gameid, helpingprop, token }) {
} }
} }
useEffect(() => {
setHelping(helpingprop);
}, [helpingprop]);
useEffect(() => { useEffect(() => {
if (helping) { if (helping) {
document.getElementById(`helpbutton-${gameid}`).classList.add("helpButton-enabled"); document.getElementById(`helpbutton-${gameid}`).classList.add("helpButton-enabled");

View file

@ -31,7 +31,7 @@ export default function Home() {
async function fetchGames() { async function fetchGames() {
setLoading(true); setLoading(true);
try { try {
const response = await axios.post("https://leizour.fr:3000/api/v1/games/getall", { token: tokenLocal }); const response = await axios.post("https://leizour.fr/api/v1/games/getall", { token: tokenLocal });
setGames(response.data); setGames(response.data);
} catch (error) { } catch (error) {
console.error("Error fetching games:", error); console.error("Error fetching games:", error);

View file

@ -23,7 +23,7 @@ export default function Login() {
} }
try { try {
const response = await axios.post("https://leizour.fr:3000/api/v1/auth/login", { const response = await axios.post("https://leizour.fr/api/v1/auth/login", {
username: username, username: username,
password: password password: password
}) })

View file

@ -24,14 +24,14 @@ export default function Register() {
} }
try { try {
const response = await axios.post("https://leizour.fr:3000/api/v1/auth/register", { const response = await axios.post("https://leizour.fr/api/v1/auth/register", {
username: username, username: username,
name: name, name: name,
lastname: lastname, lastname: lastname,
password: password password: password
}) })
const loginResponse = await axios.post("https://leizour.fr:3000/api/v1/auth/login", { const loginResponse = await axios.post("https://leizour.fr/api/v1/auth/login", {
username: username, username: username,
password: password password: password
}) })