// CareerOnboarding.js import React, { useState, useEffect } from 'react'; import { useLocation } from 'react-router-dom'; import axios from 'axios'; import { Input } from '../ui/input.js'; // Ensure path matches your structure import authFetch from '../../utils/authFetch.js'; // 1) Import your CareerSearch component import CareerSearch from '../CareerSearch.js'; // adjust path as necessary const apiURL = process.env.REACT_APP_API_URL; const CareerOnboarding = ({ nextStep, prevStep, data, setData }) => { // We store local state for “are you working,” “selectedCareer,” etc. const [currentlyWorking, setCurrentlyWorking] = useState(''); const [selectedCareer, setSelectedCareer] = useState(''); const [collegeEnrollmentStatus, setCollegeEnrollmentStatus] = useState(''); const [showFinPrompt, setShowFinPrompt] = useState(false); const [financialReady, setFinancialReady] = useState(false); // persisted later if you wish const Req = () => *; const ready = selectedCareer && currentlyWorking && collegeEnrollmentStatus; // 1) Grab the location state values, if any const location = useLocation(); const { socCode, cipCodes, careerTitle, // <--- we passed this from handleSelectForEducation userZip, userState, } = location.state || {}; // 2) On mount, see if location.state has a careerTitle and update local states if needed useEffect(() => { if (careerTitle) { setSelectedCareer(careerTitle); setData((prev) => ({ ...prev, career_name: careerTitle, soc_code: socCode || '' })); } }, [careerTitle, socCode, setData]); // Called whenever other change const handleChange = (e) => { setData(prev => ({ ...prev, [e.target.name]: e.target.value })); }; // Called when user picks a career from CareerSearch and confirms it const handleCareerSelected = (careerObj) => { // e.g. { title, soc_code, cip_code, ... } setSelectedCareer(careerObj.title); setData(prev => ({ ...prev, career_name: careerObj.title, soc_code: careerObj.soc_code || '' // store SOC if needed })); }; const handleSubmit = () => { if (!selectedCareer || !currentlyWorking || !collegeEnrollmentStatus) { alert('Please complete all required fields before continuing.'); return; } const isInCollege = collegeEnrollmentStatus === 'currently_enrolled' || collegeEnrollmentStatus === 'prospective_student'; // Merge local state into parent data setData(prevData => ({ ...prevData, career_name: selectedCareer, college_enrollment_status: collegeEnrollmentStatus, currently_working: currentlyWorking, inCollege: isInCollege, // fallback defaults, or use user-provided status: prevData.status || 'planned', start_date: prevData.start_date || new Date().toISOString().slice(0, 10).slice(0, 10), projected_end_date: prevData.projected_end_date || null })); nextStep(); }; return (

Career Details

(We ask this to understand your financial picture. This won’t affect how we track your progress toward your target career.)

{/* 2) Replace old local “Search for Career” with */}

What career are you planning to pursue?

This should be your target career path — whether it’s a new goal or the one you're already in.

{selectedCareer && (

Selected Career: {selectedCareer}

)}
{showFinPrompt && !financialReady && (

We can give you step-by-step milestones right away.
If you’d also like a personal cash-flow & tuition projection,
add a few financial details now—or skip and do it later.

)}