-
-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea8243c
commit 0979b10
Showing
3 changed files
with
74 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters