From d2ad5924bce17e3b07ee0af86a8739559dac3b35 Mon Sep 17 00:00:00 2001 From: realtradam Date: Wed, 15 May 2024 00:44:53 -0400 Subject: begin implementing game file upload and also styling --- app/javascript/components/Button.jsx | 15 +++++++++++++ app/javascript/components/Home.jsx | 42 +++++++++++++++++++++++++++--------- app/javascript/components/Layout.jsx | 39 +++++++++++++++++++++++++++------ 3 files changed, 80 insertions(+), 16 deletions(-) create mode 100644 app/javascript/components/Button.jsx (limited to 'app/javascript/components') diff --git a/app/javascript/components/Button.jsx b/app/javascript/components/Button.jsx new file mode 100644 index 0000000..f9505f8 --- /dev/null +++ b/app/javascript/components/Button.jsx @@ -0,0 +1,15 @@ +import React from "react"; +import { Link } from "react-router-dom"; + +export default function Button ({ link }) +{ + return ( + <> +
+
+ { link } +
+
+ + ) +}; diff --git a/app/javascript/components/Home.jsx b/app/javascript/components/Home.jsx index efe3cd5..6ead779 100644 --- a/app/javascript/components/Home.jsx +++ b/app/javascript/components/Home.jsx @@ -1,8 +1,27 @@ -import React from "react"; +import React, { } from "react"; import { Link } from "react-router-dom"; -export default () => ( -
+//export default () => ( +export default function Home () { + var handleSubmit = (e) => { + e.preventDefault() //stops submit from happening + + const formData = new FormData() + formData.append('game[title]', e.target.title.value) + formData.append('game[game_file]', e.target.game_file.files[0], e.target.game_file.value) + +for (var pair of formData.entries()) { + console.log(pair[0] + ', ' + pair[1]) +}; + + fetch('http://127.0.0.1:3000/api/v1/games', { + method: 'post', + body: formData, + }); + } + return( + <> +

Games!

@@ -17,14 +36,17 @@ export default () => ( > View Games - - View Blogs -
+
+ + + + + + +
+ ); +}; diff --git a/app/javascript/components/Layout.jsx b/app/javascript/components/Layout.jsx index 6bf698a..0c5d5b6 100644 --- a/app/javascript/components/Layout.jsx +++ b/app/javascript/components/Layout.jsx @@ -1,15 +1,42 @@ import React from "react"; import { Outlet, Link } from "react-router-dom"; - +import Button from "./Button"; export default function Layout ({userData}) { console.log(userData); //const [userData, setUserData] = useState({ name: "" }); return ( <> -
- +
+
+
+
+
+
+
+
+
+ +
+
-
+
- + ) }; -- cgit v1.2.3