import { useEffect, useState } from "react"; import { FiSearch } from "react-icons/fi"; import { FcGoogle } from "react-icons/fc"; import { SiDuckduckgo } from "react-icons/si"; import { SiMicrosoftbing } from "react-icons/si"; export default function Search({ options, classN }) { const providers = ["google", "bing", "duckduckgo", "custom"]; const targets = ["_blank", "_parent", "_top"]; const [query, setQuery] = useState(""); function search() { if (!providers.includes(options.provider)) { return; } else { if (options.provider === "custom") { if (targets.includes(options.target)) { window.open(options.customdata.url + query, options.target); } else window.open(options.customdata.url + query, "_self"); } else { if (targets.includes(options.target)) { window.open(`https://www.${options.provider}.com/search?q=` + query, `${options.target}`); } else window.open(`https://www.${options.provider}.com/search?q=` + query, "_self"); } } setQuery(""); } if (!options || (options.provider === "custom" && !options.customdata)) { return <>>; } return (
); }