Add onEnter search
This commit is contained in:
@@ -9,11 +9,14 @@ const Result = ({result, term}) => {
|
||||
let sentences
|
||||
|
||||
const checkForMatches = (props) => {
|
||||
if(props.length !== 1) return sentences.map((sentence) => {
|
||||
sentence.toLowerCase().includes(term.toLowerCase()) ? setTitle(sentence) : null
|
||||
|
||||
if(props.length === 1) return setTitle(props)
|
||||
if(props.length > 1 ){
|
||||
return sentences.map((sentence) => {
|
||||
if(sentence.toLowerCase().includes(term.toLowerCase())) setTitle(sentence)
|
||||
else setTitle(props[0])
|
||||
})
|
||||
|
||||
return setTitle(text)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +29,7 @@ const Result = ({result, term}) => {
|
||||
useEffect(() => {
|
||||
sentences = splitText()
|
||||
checkForMatches(sentences)
|
||||
})
|
||||
}, [])
|
||||
// ako term nije pronadjen u textu onda
|
||||
// treba provjeriti duzinu niza, ako niz ima jednu recenicu, recenica treba biti title, ako ne, naci medju recenicama onu koja ima term u sebi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user