import * as React from "react"; import { Modal, Button } from "@wordpress/components"; import { useState, useRef, useEffect, useContext } from "@wordpress/element"; import type { TitleSelection } from "../../types"; import { TitleControls } from "../title-controls/TitleControls"; import { __, sprintf } from "@wordpress/i18n"; import JustWatchContext from "../../context/context"; import config from "../../context/config"; export type TitleDialogProps = { isOpen: boolean; onClose: () => void; onConfirm: (selection: TitleSelection | undefined) => void; titleSelection?: TitleSelection; }; export const TitleDialog = ({ isOpen, onClose, onConfirm }: TitleDialogProps): JSX.Element => { const [titleSelection, setTitleSelection] = useState(); const inputRef = useRef(null); const settings = useContext(JustWatchContext); useEffect(() => { if (isOpen) { // Reset the title selection state setTitleSelection(undefined); // Focus the input field if the ref is available if (inputRef.current) { inputRef.current.focus(); inputRef.current.value = ""; // Clear the input value } } }, [isOpen]); return isOpen ? (
{!settings.apiKey && (

plugin settings` ) }} /> )}

Enter a movie or TV show title to search for it on Justwatch.

) : <>; }; export default TitleDialog;