From 34346b1fd4fffd2571374f86b16084066dc4aa2d Mon Sep 17 00:00:00 2001 From: realtradam Date: Thu, 6 Jun 2024 19:24:45 -0400 Subject: add seperate uploading page and update match backend functionality --- src/components/Games.jsx | 95 ------------------------------------------------ 1 file changed, 95 deletions(-) delete mode 100644 src/components/Games.jsx (limited to 'src/components/Games.jsx') diff --git a/src/components/Games.jsx b/src/components/Games.jsx deleted file mode 100644 index 173b3b7..0000000 --- a/src/components/Games.jsx +++ /dev/null @@ -1,95 +0,0 @@ -import React, { useState, useEffect } from "react"; -//import { Link } from "react-router-dom"; -import GameCard from "./GameCard"; -import Button from "./Button"; - -//export default () => ( -export default function Games () { - const [games, setGames] = useState([]); - useEffect(() => { - const url = `${import.meta.env.VITE_API_TITLE}/api/v1/games`; - fetch(url).then((response) => { - if (response.ok) { - return response.json(); - } - throw new Error("Network response was not ok."); - }).then((response) => setGames(response))//.catch(() => navigate("/")); - }, []); - const allGames = games.map((game) => ( - - )); - var handleSubmit = (e) => { - e.preventDefault() //stops submit from happening - const form = e.target; - const formData = new FormData() - formData.append('game[title]', form.title.value) - formData.append('game[img_rendering]', form.img_rendering.value) - for(let i =0; i < form.game_files.files.length; i++) - { - formData.append('game[game_files][]', form.game_files.files[i], form.game_files.files[i].value); - } - formData.append('game[card_img]', form.card_img.files[0], form.card_img.value); - formData.append('game[char_img]', form.char_img.files[0], form.char_img.value); - formData.append('game[title_img]', form.title_img.files[0], form.title_img.value); - - for (var pair of formData.entries()) { - console.log(pair[0] + ', ' + pair[1]) - }; - - fetch(`${import.meta.env.VITE_API_TITLE}/api/v1/games`, { - method: 'post', - body: formData, - }); - } - return( - <> -
-
-
Games
-
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- }/> -
- -
-
-
-
-
- { allGames } -
-
-
- - ); -}; -- cgit v1.2.3