diff --git a/src/components/VideoUpload.js b/src/components/VideoUpload.js
index dc2e006..963ea78 100644
--- a/src/components/VideoUpload.js
+++ b/src/components/VideoUpload.js
@@ -1,3 +1,4 @@
+import axios from "axios";
import {
Box,
Button,
@@ -55,44 +56,35 @@ const VideoUpload = () => {
const [moviefile, setMovieFile] = useState(null);
const [movieDetails, setMovieDetails] = useState({
- movieName: "",
- movieCertification: [
- {
- title: "",
- },
- ],
- genre: [
- {
- title: "",
- },
- ],
+ title: "",
+ plot: "",
+ genres: [],
+ runtime: "",
cast: "",
- country: [
- {
- title: "",
+ languages: [],
+ released: "",
+ directors: [],
+ rated: "",
+ imdb: {
+ rating: "",
+ votes: "",
+ },
+ countries: [],
+ type: "movie",
+ tomatoes: {
+ viewer: {
+ rating: "",
+ numReviews: "",
+ meter: "",
},
- ],
- director: "",
- language: [
- {
- title: "",
- },
- ],
- writer: "",
- releasedDate: "",
- imdbRating: "",
- imdbVotes: "",
- awardName: "",
- totalAwards: "",
- description: "",
+ },
});
const handleChange = (e) => {
- console.log("e.target.id : ", e.target.id);
- console.log("e.target.value : ", e.target.value);
+ console.log(e.target.value);
setMovieDetails({
...movieDetails,
- [e.target.id]: e.target.value,
+ [e.target.name]: e.target.value,
});
};
@@ -106,7 +98,7 @@ const VideoUpload = () => {
const handleAutoCompleteChange = (event, value) => {
setMovieDetails({
...movieDetails,
- movieCertification: value.map((item) => item),
+ [event.target.id]: value.map((item) => item.title),
});
};
@@ -115,7 +107,22 @@ const VideoUpload = () => {
console.log(event.target.files[0]);
};
- const handleSubmit = (e) => {};
+ const handleSubmit = async (e) => {
+ e.preventDefault();
+ try {
+ const response = await axios.post("http://localhost:3001/admin/uploadmovie", movieDetails, {
+ headers: {
+ "Content-Type": "application/json",
+ "Authorization": `Bearer ${localStorage.getItem("token")}`,
+ },
+ });
+ console.log(movieDetails);
+ console.log("Movie uploaded successfully:", response.data);
+ // Reset form fields or navigate to another page upon successful upload
+ } catch (error) {
+ console.error("Error uploading movie:", error);
+ }
+ };
return (
@@ -133,14 +140,14 @@ const VideoUpload = () => {
onChange={handleChange}
required
fullWidth
- id="movieName"
+ id="title"
// label="Enter email"
- value={movieDetails.movieName}
- name="movieName"
+ value={movieDetails.title}
+ name="title"
sx={{ mt: 1, mb: 2 }}
/>
-
+ {/*
Movie Certification
@@ -157,7 +164,7 @@ const VideoUpload = () => {
)}
/>
-
+ */}
{
>
- Enter Genre
+ Genres
option.title}
- onChange={handleAutoCompleteChange}
size="small"
sx={{ mt: 1, mb: 2 }}
- renderInput={(params) => }
+ renderInput={(params) => (
+
+ )}
/>
@@ -211,15 +220,16 @@ const VideoUpload = () => {
multiple
limitTags={2}
onOpen={() => countries(dispatch)}
- id="country"
+ id="countries" // Changed id to match schema
options={Countries}
getOptionLabel={(option) => option.title}
onChange={handleAutoCompleteChange}
size="small"
sx={{ mt: 1, mb: 2 }}
- renderInput={(params) => }
+ renderInput={(params) => } // Changed id to match schema
/>
+
Enter Director Name
@@ -232,13 +242,14 @@ const VideoUpload = () => {
marginTop: "0.5rem",
marginBottom: "1rem",
}}
- onChange={(value) => handleTagInputChange(value, "director")}
- value={movieDetails.director}
- id="director"
+ onChange={(value) => handleTagInputChange(value, "directors")} // Changed "director" to "directors" to match schema
+ value={movieDetails.directors} // Changed "director" to "directors" to match schema
+ id="directors" // Changed id to match schema
menuStyle={{ width: "100%" }}
size="lg"
/>
+
{
option.title}
onChange={handleAutoCompleteChange}
size="small"
sx={{ mt: 1, mb: 2 }}
renderInput={(params) => (
-
+ // Changed id to match schema
)}
/>
+
Enter Writer Name
@@ -274,9 +286,9 @@ const VideoUpload = () => {
marginTop: "0.5rem",
marginBottom: "1rem",
}}
- id="writer"
- onChange={(value) => handleTagInputChange(value, "writer")}
- value={movieDetails.writer}
+ id="writers" // Changed id to match schema
+ onChange={(value) => handleTagInputChange(value, "writers")} // Changed "writer" to "writers" to match schema
+ value={movieDetails.writers} // Changed "writer" to "writers" to match schema
menuStyle={{ width: "100%" }}
size="lg"
/>
@@ -293,17 +305,18 @@ const VideoUpload = () => {
option.title}
size="small"
sx={{ mt: 1, mb: 2 }}
renderInput={(params) => (
-
+ // Changed id to match schema
)}
/>
+
Select Released Date
@@ -317,7 +330,7 @@ const VideoUpload = () => {
marginBottom: "1rem",
}}
onChange={(value) => handleTagInputChange(value, "releasedDate")}
- id="released"
+ id="releasedDate" // Changed id to match schema
size="lg"
/>
@@ -368,24 +381,6 @@ const VideoUpload = () => {
sx={{ mt: 1, mb: 2 }}
/>
-
-
- Total Votes
-
-
-
{
>
- Some Information
+ Some Information.
{
- Description
+ plot