From b78963f906dc02c409c6885fc73a5f559a8a9b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Poizat?= Date: Fri, 20 Dec 2024 11:54:38 +0100 Subject: [PATCH] feat: Display message if no enough char in query and no assistant --- .../src/components/ResultMenu/NotEnoughItem.jsx | 17 +++++++++++++++++ .../components/ResultMenu/ResultMenuContent.jsx | 7 ++++++- packages/cozy-dataproxy-lib/src/locales/en.json | 3 ++- packages/cozy-dataproxy-lib/src/locales/fr.json | 3 ++- 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 packages/cozy-dataproxy-lib/src/components/ResultMenu/NotEnoughItem.jsx diff --git a/packages/cozy-dataproxy-lib/src/components/ResultMenu/NotEnoughItem.jsx b/packages/cozy-dataproxy-lib/src/components/ResultMenu/NotEnoughItem.jsx new file mode 100644 index 0000000000..3ca0a455f3 --- /dev/null +++ b/packages/cozy-dataproxy-lib/src/components/ResultMenu/NotEnoughItem.jsx @@ -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 ( + + + + ) +} + +export default NotEnoughItem diff --git a/packages/cozy-dataproxy-lib/src/components/ResultMenu/ResultMenuContent.jsx b/packages/cozy-dataproxy-lib/src/components/ResultMenu/ResultMenuContent.jsx index 8d620990ec..6130d04b53 100644 --- a/packages/cozy-dataproxy-lib/src/components/ResultMenu/ResultMenuContent.jsx +++ b/packages/cozy-dataproxy-lib/src/components/ResultMenu/ResultMenuContent.jsx @@ -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' @@ -28,7 +29,11 @@ const SearchResult = () => { } if (!isLoading && !results?.length && !isAssistantEnabled()) { - return + if (searchValue.length >= 3) { + return + } else { + return + } } return results.map((result, idx) => ( diff --git a/packages/cozy-dataproxy-lib/src/locales/en.json b/packages/cozy-dataproxy-lib/src/locales/en.json index d0d0a9d532..23705c969d 100644 --- a/packages/cozy-dataproxy-lib/src/locales/en.json +++ b/packages/cozy-dataproxy-lib/src/locales/en.json @@ -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" diff --git a/packages/cozy-dataproxy-lib/src/locales/fr.json b/packages/cozy-dataproxy-lib/src/locales/fr.json index 5006643f24..40d676d433 100644 --- a/packages/cozy-dataproxy-lib/src/locales/fr.json +++ b/packages/cozy-dataproxy-lib/src/locales/fr.json @@ -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"