Skip to content

Commit

Permalink
AddVideo Implementation - WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
christina-mifsud committed Aug 13, 2023
1 parent ea8243c commit 0979b10
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 5 deletions.
75 changes: 72 additions & 3 deletions client/src/AddVideo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,75 @@
import React from "react";
import React, { useState } from "react";

function AddVideo() {
return <></>;
// React component that will add a Video.
// It should include fields to add a
// Title
// Url
// When a button is clicked the video should be added to the list

function AddVideo({ filterVideos, setFilterVideos }) {
const [addVideoTitle, setAddVideoTitle] = useState("");
const [addVideoUrl, setAddVideoUrl] = useState("");

function handleSubmitTitle(event) {
//////// HELP! I keep getting 'Uncaught TypeError: Cannot read properties of undefined (reading 'value')'
setAddVideoTitle(event.target.value);
// setAddVideoUrl(event.target.value);
}
function handleSubmitUrl(event) {
// setAddVideoTitle(event.target.value);
setAddVideoUrl(event.target.value);
}

function addVideo() {
const addVideoObject = {};
// addVideoObject.id = addVideoId; //////// HELP! How can I find out highest ID and then add to that?
addVideoObject.title = addVideoTitle;
addVideoObject.url = addVideoUrl;
setFilterVideos((filterVideos) => [...filterVideos, addVideoObject]);
}

return (
<div className="add-video">
<h3>Add Video</h3>
<form
className="add-video-form"
onSubmit={(event) => {
event.preventDefault();
handleSubmitTitle(addVideoTitle);
handleSubmitUrl(addVideoUrl);
}}
>
<div>
<label>Title</label>
<input
id="video-title-input"
name="video-title"
type="text"
required=""
value={addVideoTitle}
onChange={handleSubmitTitle}
></input>
</div>
<div>
<label>URL</label>
<input
id="video-url-input"
name="video-url"
type="text"
required=""
value={addVideoUrl}
onChange={handleSubmitUrl}
></input>
</div>
<div>
<button type="cancel">Cancel</button>
<button type="submit" onClick={addVideo}>
Add
</button>
</div>
</form>
</div>
);
}

export default AddVideo;
2 changes: 1 addition & 1 deletion client/src/BodyContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function BodyContainer() {

return (
<>
<AddVideo />
<AddVideo filterVideos={filterVideos} setFilterVideos={setFilterVideos} />
<VideoCards
filterVideos={filterVideos}
setFilterVideos={setFilterVideos}
Expand Down
2 changes: 1 addition & 1 deletion client/src/SingleVideoCard.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from "react";
import exampleResponse from "./exampleResponse.json";
// import exampleResponse from "./exampleResponse.json";

function SingleVideoCard({
videoId,
Expand Down

0 comments on commit 0979b10

Please sign in to comment.