Update the Search Logic
Approach:
Search within atoms (local search) first.
If no matches are found, make a request to the
global-searchendpoint in the API Client.Only display suggestions if there are actual results to avoid showing an empty suggestion box.
Implement API Search (Global Search)
If no local matches are found, call the
global-searchAPI.Debounce API calls to avoid unnecessary requests on every keystroke.
Handle API responses properly and update suggestions if results exist.
🔹 Example (API Search with Debounce)
4️⃣ Update UI to Show Suggestions Only When Available
If suggestions exist, display them.
Otherwise, do not show the suggestion box.
🔹 Example (React Code for Conditional Rendering)
Final Steps
✅ Modify the search function to follow the correct priority (Atoms → Global Search).
✅ Ensure UI updates dynamically based on available suggestions.
✅ Optimize API calls with debouncing and avoid unnecessary renders.
Would you like help implementing this in your project? 🚀