-
-
Notifications
You must be signed in to change notification settings - Fork 12
Root: ui|v2.5|src|components|Movies|MovieDetails: MovieScrapeDialog.tsx
This file contains the MovieScrapeDialog
component, which is responsible for displaying a dialog for scraping movie information. Below is an overview of its structure and functionality:
The MovieScrapeDialog
component is a functional component used to display a dialog for scraping movie information from external sources. Here's a breakdown of its functionality:
-
Props:
-
movie
: Partial data of typeGQL.MovieUpdateInput
representing the movie for which information is being scraped. -
movieStudio
: Data of typeStudio
representing the studio associated with the movie. -
scraped
: Data of typeGQL.ScrapedMovie
containing scraped information about the movie. -
onClose
: Callback function triggered when the dialog is closed, optionally passing the scraped movie data.
-
-
State:
- State variables are used to manage the scraped information for various fields such as name, aliases, duration, date, director, synopsis, studio, URL, front image, and back image.
-
Create New Studio:
- Utilizes a hook (
useCreateScrapedStudio
) to create a new scraped studio object if necessary.
- Utilizes a hook (
-
Rendering:
- Renders a
ScrapeDialog
component, passing the render function for scraping rows and the onClose callback function as props.
- Renders a
The MovieScrapeDialog
component provides a user-friendly interface for scraping movie information from external sources. It displays fields for various movie attributes and allows users to modify the scraped data before applying it to the movie entity.
import React, { useState } from "react";
import { MovieScrapeDialog } from "./MovieScrapeDialog";
const MovieDetailsPage = ({ movie }) => {
const [isScrapeDialogOpen, setIsScrapeDialogOpen] = useState(false);
const handleScrapeDialogClose = (scrapedMovie) => {
// Handle scraped movie data
console.log("Scraped Movie Data:", scrapedMovie);
setIsScrapeDialogOpen(false);
};
return (
<div>
<h1>{movie.name} Details</h1>
<button onClick={() => setIsScrapeDialogOpen(true)}>
Open Scrape Dialog
</button>
{isScrapeDialogOpen && (
<MovieScrapeDialog
movie={movie}
movieStudio={movie.studio}
scraped={/* scraped movie data */}
onClose={handleScrapeDialogClose}
/>
)}
</div>
);
};
export default MovieDetailsPage;
In the example above, the MovieScrapeDialog component is used within a movie details page. When the user clicks a button to open the scrape dialog, the dialog appears, allowing the user to modify scraped movie information. When the dialog is closed, the handleScrapeDialogClose function is called to handle the scraped movie data.