Skip to content

Commit

Permalink
feat: Display message if no enough char in query and no assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
zatteo committed Dec 20, 2024
1 parent dba11f8 commit b78963f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'

import ListItem from 'cozy-ui/transpiled/react/ListItem'
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'

const NotEnoughItem = () => {
const { t } = useI18n()

return (
<ListItem size="small">
<ListItemText primary={t('assistant.search.notEnough')} />
</ListItem>
)
}

export default NotEnoughItem
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useBreakpoints } from 'cozy-ui/transpiled/react/providers/Breakpoints'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'

import NoResultItem from './NoResultItem'
import NotEnoughItem from './NotEnoughItem'
import ResultMenuItem from './ResultMenuItem'
import { useSearch } from '../Search/SearchProvider'
import { isAssistantEnabled } from '../helpers'
Expand All @@ -28,7 +29,11 @@ const SearchResult = () => {
}

if (!isLoading && !results?.length && !isAssistantEnabled()) {
return <NoResultItem />
if (searchValue.length >= 3) {
return <NoResultItem />
} else {
return <NotEnoughItem />
}
}

return results.map((result, idx) => (
Expand Down
3 changes: 2 additions & 1 deletion packages/cozy-dataproxy-lib/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"placeholder": "Any question?",
"send": "Send",
"result": "Ask the assistant",
"noItem": "No results"
"noItem": "No results",
"notEnough": "Your query must contain at least 3 characters"
},
"dialog": {
"close": "Close"
Expand Down
3 changes: 2 additions & 1 deletion packages/cozy-dataproxy-lib/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"placeholder": "Une question ?",
"send": "Envoyer",
"result": "Demander à l'assistant",
"noItem": "Aucun résultat"
"noItem": "Aucun résultat",
"notEnough": "Votre recherche doit contenir au moins 3 caractères"
},
"dialog": {
"close": "Fermer"
Expand Down

0 comments on commit b78963f

Please sign in to comment.