fixed chatbot careerSuggestions undefined

This commit is contained in:
Josh 2025-03-18 13:02:25 +00:00
parent 88842b5946
commit ea78794196
2 changed files with 40 additions and 21 deletions

View File

@ -3,6 +3,7 @@ import axios from "axios";
import "./Chatbot.css";
const Chatbot = ({ context }) => {
const [messages, setMessages] = useState([
{
role: "assistant",
@ -22,11 +23,11 @@ const Chatbot = ({ context }) => {
Your role is to not only provide career suggestions but to analyze them based on salary potential, job stability, education costs, and market trends.
Use the following user-specific data:
- Career Suggestions: ${context.data.careerSuggestions?.map((c) => c.title).join(", ") || "No suggestions available."}
- Selected Career: ${context.data.selectedCareer?.title || "None"}
- Schools: ${context.data.schools?.map((s) => s["INSTNM"]).join(", ") || "No schools available."}
- Career Suggestions: ${context.careerSuggestions?.map((c) => c.title).join(", ") || "No suggestions available."}
- Selected Career: ${context.selectedCareer?.title || "None"}
- Schools: ${context.schools?.map((s) => s["INSTNM"]).join(", ") || "No schools available."}
- Median Salary: ${
context.data.salaryData?.find((s) => s.percentile === "Median")?.value || "Unavailable"
context.salaryData?.find((s) => s.percentile === "Median")?.value || "Unavailable"
}
- ROI (Return on Investment): If available, use education costs vs. salary potential to guide users.

View File

@ -272,6 +272,20 @@ async (career) => {
],
};
console.log("Passing context to Chatbot:", {
careerSuggestions,
riaSecScores,
selectedCareer,
schools,
salaryData,
economicProjections,
tuitionData,
userState,
areaTitle,
userZipcode,
results,
});
return (
<div className="dashboard">
<div className="dashboard-content">
@ -345,24 +359,28 @@ async (career) => {
{memoizedPopoutPanel}
{/* Pass context to Chatbot */}
<div className="chatbot-widget">
<Chatbot
context={{
careerSuggestions,
riaSecScores,
selectedCareer,
schools,
salaryData,
economicProjections,
tuitionData,
userState,
areaTitle,
userZipcode,
results, // Pass results to Chatbot
{/* Pass context to Chatbot */}
<div className="chatbot-widget">
{careerSuggestions.length > 0 ? (
<Chatbot
context={{
careerSuggestions: careersWithJobZone || [],
riaSecScores: riaSecScores || [],
selectedCareer: selectedCareer || null,
schools: schools || [],
salaryData: salaryData || [],
economicProjections: economicProjections || null,
tuitionData: tuitionData || [],
userState: userState || "",
areaTitle: areaTitle || "",
userZipcode: userZipcode || "",
results: results || [],
}}
/>
</div>
/>
) : (
<p>Loading Chatbot...</p>
)}
</div>
{/* Acknowledgment Section */}