import { useRouter } from 'next/router' import { useGlobal } from '@/lib/global' import { useState } from 'react' const SearchInput = ({ currentTag, currentSearch }) => { const { locale } = useGlobal() const [searchKey, setSearchKey] = useState(currentSearch) const router = useRouter() const handleSearch = () => { if (searchKey && searchKey !== '') { router.push({ pathname: '/search', query: { s: searchKey } }).then(r => { }) } else { router.push({ pathname: '/' }).then(r => { }) } } const handleKeyUp = (e) => { if (e.keyCode === 13) { handleSearch() } } return