From 2cd0cb48c2a91b42c034857e475d05eddd44e56e Mon Sep 17 00:00:00 2001
From: Abhishek Kumar <anonims.ak@gmail.com>
Date: Fri, 24 Jul 2020 15:32:00 +0530
Subject: [PATCH] show no results found on empty suggestion

---
 client/src/components/SuggestionBox/index.jsx | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/client/src/components/SuggestionBox/index.jsx b/client/src/components/SuggestionBox/index.jsx
index dd1f7e4..9e90c9d 100644
--- a/client/src/components/SuggestionBox/index.jsx
+++ b/client/src/components/SuggestionBox/index.jsx
@@ -4,6 +4,8 @@ import config from "../../config";
 import api from "../../services/api";
 import style from "./style.module.scss";
 
+const NO_RESULTS_FOUND = "no results found";
+
 /**
  * Decides what is displayed after the user selects a suggestion
  * @param {Object} suggestion The selected suggestion
@@ -88,7 +90,8 @@ export default function SuggestionBox({
 
   const onSuggestionsFetchRequested = async ({ value }) => {
     if (purpose === "skills") {
-      const data = await getSkillsSuggestions(apiClient, value);
+      let data = await getSkillsSuggestions(apiClient, value);
+      if (data.length < 1) data = [{ name: NO_RESULTS_FOUND }];
       setSuggestions(data);
     } else {
       const data = await getCompanyAttributesSuggestions(
@@ -104,7 +107,7 @@ export default function SuggestionBox({
 
   const onSuggestionSelected = (event, { suggestion }) => {
     if (purpose === "skills") {
-      onSelect(suggestion);
+      if (suggestion.name !== NO_RESULTS_FOUND) onSelect(suggestion);
     } else {
       onSelect(companyAttrId, suggestion);
     }