import React, { useState, useRef, useCallback } from "react"; import { SearchIcon } from "@/components/icons/SearchIcon"; import { CloseIcon } from "@/components/icons/CloseIcon"; interface SearchBoxProps { close?: () => void; } export const SearchBox: React.FC = ({ close = () => {} }) => { const [inputValue, setInputValue] = useState(""); const inputElement = useRef(null); const search = useCallback((query: string) => { if (query.trim()) { window.location.href = `/song/${query.trim()}/info`; } }, []); const handleInputChange = useCallback((event: React.ChangeEvent) => { setInputValue(event.target.value); }, []); const handleKeyDown = useCallback( (event: React.KeyboardEvent) => { if (event.key === "Enter") { event.preventDefault(); search(inputValue); } }, [inputValue, search] ); const handleClear = useCallback(() => { setInputValue(""); close(); }, [close]); return (
); };