Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

fix issue#123 #570

Merged
merged 1 commit into from
Jul 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions client/src/components/SuggestionBox/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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);
}
Expand Down