diff --git a/client/src/App.jsx b/client/src/App.jsx index 5ff8da69ff..c0d9133549 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -1,10 +1,12 @@ +import NewVideoForm from "./NewVideoForm.jsx"; import VideoList from "./VideoRecommendations"; const App = () => { return ( <>

Video Recommendations

- + + ); }; diff --git a/client/src/NewVideoForm.css b/client/src/NewVideoForm.css new file mode 100644 index 0000000000..f4143c99f9 --- /dev/null +++ b/client/src/NewVideoForm.css @@ -0,0 +1,55 @@ +/* CSS for NewVideoForm component */ +div { + max-width: 500px; + margin: 0 auto; + padding: 20px; + border: 1px solid #ccc; + border-radius: 10px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + background-color: #f9f9f9; +} + +h2 { + text-align: center; + color: #333; + margin-bottom: 20px; +} + +form { + display: flex; + flex-direction: column; + gap: 15px; +} + +div > div { + display: flex; + flex-direction: column; +} + +label { + font-weight: bold; + margin-bottom: 5px; + color: #555; +} + +input { + padding: 10px; + border: 1px solid #ccc; + border-radius: 5px; + font-size: 16px; +} + +button { + padding: 10px 20px; + border: none; + border-radius: 5px; + background-color: #007bff; + color: #fff; + font-size: 16px; + cursor: pointer; + transition: background-color 0.3s; +} + +button:hover { + background-color: #0056b3; +} diff --git a/client/src/NewVideoForm.jsx b/client/src/NewVideoForm.jsx new file mode 100644 index 0000000000..2400f3ef7b --- /dev/null +++ b/client/src/NewVideoForm.jsx @@ -0,0 +1,58 @@ +import React, { useState } from "react"; + +import "./NewVideoForm.css"; +const NewVideoForm = () => { + const [title, setTitle] = useState(""); + const [src, setSrc] = useState(""); + + const handleSubmit = (e) => { + e.preventDefault(); + + fetch("/api/videos", { + method: "POST", + headers: { + Accept: "application/json", + "Content-Type": "application/json", + }, + body: JSON.stringify({ title, src }), + }) + .then((response) => response.json()) + .then((data) => { + console.log(JSON.stringify(data)); + }) + .catch((error) => { + console.error(error); + }); + }; + + return ( +
+

Add New Video

+
+
+ + setTitle(e.target.value)} + required + /> +
+
+ + setSrc(e.target.value)} + required + /> +
+ +
+
+ ); +}; + +export default NewVideoForm;