add enter functionality

This commit is contained in:
ismailsosic
2023-03-08 19:52:30 +01:00
parent f09648dd67
commit 992967e24e
19 changed files with 33 additions and 24 deletions

View File

@@ -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
})
return setTitle(text)
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])
})
}
}
@@ -26,9 +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
}, [])
return (