Skip to content

Commit

Permalink
feat: #282 - 검색 모달에서 키워드가 1글자일 경우 토스트 알림 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
dudwns committed Dec 29, 2023
1 parent c18f05e commit 88f798a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/common/SearchModal/hooks/useSearchModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from 'react-hook-form'
import { mock_trendData } from '@/data'
import { useRouter } from 'next/navigation'
import { notify } from '../../Toast/Toast'
import { SearchFormValues } from '../SearchModal'

export interface useSearchModalProps {
Expand Down Expand Up @@ -43,7 +44,11 @@ const useSearchModal = ({
}

const onSubmit: SubmitHandler<SearchFormValues> = (data) => {
if (data.search.length === 1) return
if (data.search.length === 1) {
notify('info', '검색어는 최대 2글자여야 합니다.')
return
}

router.push(`/search?target=${data.target}&keyword=${data.search}`)
}

Expand Down

0 comments on commit 88f798a

Please sign in to comment.