diff --git a/routes/main_routes.py b/routes/main_routes.py index 5cb3459..281cd51 100644 --- a/routes/main_routes.py +++ b/routes/main_routes.py @@ -10,6 +10,19 @@ from utils.file_server import read_starter_code, resolve_starter_file, get_starter_code_dir import os +# Interest categories that currently have no project recommendations available +NO_PROJECT_INTERESTS = { + "machine learning/ai", + "devops", + "mobile", + "artificial intelligence", + "cloud computing", + "mobile app development", +} + +def interest_has_no_projects(interest): + return interest and interest.strip().lower() in NO_PROJECT_INTERESTS + # Create the Blueprint that app.py will register main = Blueprint("main", __name__) @@ -58,6 +71,12 @@ def recommend(): # Return only the first error to keep the UI message clean return jsonify({"error": errors[0]}), 400 + if interest_has_no_projects(interest): + return jsonify({ + "projects": [], + "message": "No projects are currently available for this interest area. Please check back later." + }), 200 + results = get_recommendations(skills, level, interest, time_availability) if not results: diff --git a/static/script.js b/static/script.js index 9d96ab9..bb0f30e 100644 --- a/static/script.js +++ b/static/script.js @@ -615,9 +615,19 @@ if (clearFiltersBtn) { resultsEmptyEl.style.display = "block"; if (message && emptyMessageEl) emptyMessageEl.textContent = message; if (!projects || projects.length === 0) { //if no projects returned from api, show the "no results" message and hide the grid - resultsGrid.style.display = "none"; - resultsEmptyEl.style.display = "block"; - if (message && emptyMessageEl) emptyMessageEl.textContent = message; //if api sent back a message (e.g. "no projects found matching your criteria"), show that + resultsGrid.style.display = "none"; + resultsEmptyEl.style.display = "block"; + + // Show a friendly custom message when the user selected an interest + var selectedInterest = document.getElementById("interest")?.value; + if (selectedInterest) { + emptyMessageEl.textContent = "No projects are currently available for this interest. Please check back later or try a different area."; + } else if (message) { + emptyMessageEl.textContent = message; + } else { + emptyMessageEl.textContent = "Try adjusting your skills or choosing a different interest area."; + } + resultsSection.scrollIntoView({ behavior: "smooth" }); return; } @@ -654,8 +664,8 @@ if (clearFiltersBtn) { var tagsRow = document.createElement("div"); tagsRow.className = "project-card-tags"; - // Show the first two skills as tags - (project.skills || []).slice(0, 2).forEach(function (skill) { + // Show all project skills as tags so users can see the full match + (project.skills || []).forEach(function (skill) { tagsRow.appendChild(createTag(skill, "skill")); }); diff --git a/templates/index.html b/templates/index.html index 18537b9..959c697 100644 --- a/templates/index.html +++ b/templates/index.html @@ -413,7 +413,6 @@