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"; import "./Chatbot.css";
const Chatbot = ({ context }) => { const Chatbot = ({ context }) => {
const [messages, setMessages] = useState([ const [messages, setMessages] = useState([
{ {
role: "assistant", 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. 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: Use the following user-specific data:
- Career Suggestions: ${context.data.careerSuggestions?.map((c) => c.title).join(", ") || "No suggestions available."} - Career Suggestions: ${context.careerSuggestions?.map((c) => c.title).join(", ") || "No suggestions available."}
- Selected Career: ${context.data.selectedCareer?.title || "None"} - Selected Career: ${context.selectedCareer?.title || "None"}
- Schools: ${context.data.schools?.map((s) => s["INSTNM"]).join(", ") || "No schools available."} - Schools: ${context.schools?.map((s) => s["INSTNM"]).join(", ") || "No schools available."}
- Median Salary: ${ - 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. - 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 ( return (
<div className="dashboard"> <div className="dashboard">
<div className="dashboard-content"> <div className="dashboard-content">
@ -345,24 +359,28 @@ async (career) => {
{memoizedPopoutPanel} {memoizedPopoutPanel}
{/* Pass context to Chatbot */} {/* Pass context to Chatbot */}
<div className="chatbot-widget"> <div className="chatbot-widget">
<Chatbot {careerSuggestions.length > 0 ? (
context={{ <Chatbot
careerSuggestions, context={{
riaSecScores, careerSuggestions: careersWithJobZone || [],
selectedCareer, riaSecScores: riaSecScores || [],
schools, selectedCareer: selectedCareer || null,
salaryData, schools: schools || [],
economicProjections, salaryData: salaryData || [],
tuitionData, economicProjections: economicProjections || null,
userState, tuitionData: tuitionData || [],
areaTitle, userState: userState || "",
userZipcode, areaTitle: areaTitle || "",
results, // Pass results to Chatbot userZipcode: userZipcode || "",
results: results || [],
}} }}
/> />
</div> ) : (
<p>Loading Chatbot...</p>
)}
</div>
{/* Acknowledgment Section */} {/* Acknowledgment Section */}