import React, { useState, useRef, useContext } from "react"; import { Link, useNavigate } from "react-router-dom"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faQrcode } from "@fortawesome/free-solid-svg-icons/faQrcode"; import useKeyboardShortcut from "use-keyboard-shortcut"; import PriceBox from "./PriceBox"; import SourcifyMenu from "./SourcifyMenu"; import { RuntimeContext } from "./useRuntime"; import { search } from "./search/search"; import Otter from "./otter.jpg"; const CameraScanner = React.lazy(() => import("./search/CameraScanner")); const Title: React.FC = () => { const { provider } = useContext(RuntimeContext); const [searchString, setSearchString] = useState(""); const [canSubmit, setCanSubmit] = useState(false); const navigate = useNavigate(); const handleChange: React.ChangeEventHandler = (e) => { const searchTerm = e.target.value.trim(); setCanSubmit(searchTerm.length > 0); setSearchString(searchTerm); }; const handleSubmit: React.FormEventHandler = (e) => { e.preventDefault(); if (!canSubmit) { return; } if (searchRef.current) { searchRef.current.value = ""; } search(searchString, navigate); }; const searchRef = useRef(null); useKeyboardShortcut(["/"], () => { searchRef.current?.focus(); }); const [isScanning, setScanning] = useState(false); return ( <> {isScanning && setScanning(false)} />}
An otter scanning Otterscan
{provider?.network.chainId === 1 && }
); }; export default Title;