Added localstorage to make onboarding easier.

This commit is contained in:
Josh 2025-06-09 18:52:44 +00:00
parent 8166a1119c
commit 7c29439ac3
4 changed files with 32 additions and 9 deletions

View File

@ -670,7 +670,7 @@ function CareerExplorer() {
`Are you sure you want to move on to Educational Programs for ${career.title}?` `Are you sure you want to move on to Educational Programs for ${career.title}?`
); );
if (!confirmed) return; if (!confirmed) return;
localStorage.setItem("selectedCareer", JSON.stringify(career));
// 2) Look up CIP codes from masterCareerRatings by SOC code // 2) Look up CIP codes from masterCareerRatings by SOC code
const matching = masterCareerRatings.find((r) => r.soc_code === career.code); const matching = masterCareerRatings.find((r) => r.soc_code === career.code);
if (!matching) { if (!matching) {

View File

@ -116,6 +116,10 @@ function EducationalProgramsPage() {
'Youre about to move to the financial planning portion of the app, which is reserved for premium subscribers. Do you want to continue?' 'Youre about to move to the financial planning portion of the app, which is reserved for premium subscribers. Do you want to continue?'
); );
if (proceed) { if (proceed) {
const storedOnboarding = JSON.parse(localStorage.getItem('premiumOnboardingState') || '{}');
storedOnboarding.collegeData = storedOnboarding.collegeData || {};
storedOnboarding.collegeData.selectedSchool = school; // or any property name
localStorage.setItem('premiumOnboardingState', JSON.stringify(storedOnboarding));
navigate('/career-roadmap', { state: { selectedSchool: school } }); navigate('/career-roadmap', { state: { selectedSchool: school } });
} }
}; };
@ -221,9 +225,10 @@ useEffect(() => {
setCareerTitle(parsed.title || ''); setCareerTitle(parsed.title || '');
// Re-set CIP code logic (like in handleCareerSelected) // Re-set CIP code logic (like in handleCareerSelected)
let rawCips = Array.isArray(parsed.cip_code) let rawCips = parsed.cip_code || [];
? parsed.cip_code if (!Array.isArray(rawCips)) rawCips = [rawCips].filter(Boolean);
: [parsed.cip_code];
const cleanedCips = rawCips.map((code) => code.toString().replace('.', '').slice(0, 4)); const cleanedCips = rawCips.map((code) => code.toString().replace('.', '').slice(0, 4));
setCipCodes(cleanedCips); setCipCodes(cleanedCips);

View File

@ -1,5 +1,6 @@
// CareerOnboarding.js // CareerOnboarding.js
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import axios from 'axios'; import axios from 'axios';
import { Input } from '../ui/input.js'; // Ensure path matches your structure import { Input } from '../ui/input.js'; // Ensure path matches your structure
import authFetch from '../../utils/authFetch.js'; import authFetch from '../../utils/authFetch.js';
@ -15,12 +16,27 @@ const CareerOnboarding = ({ nextStep, prevStep, data, setData }) => {
const [selectedCareer, setSelectedCareer] = useState(''); const [selectedCareer, setSelectedCareer] = useState('');
const [collegeEnrollmentStatus, setCollegeEnrollmentStatus] = useState(''); const [collegeEnrollmentStatus, setCollegeEnrollmentStatus] = useState('');
// On mount, if data already has these fields, set them // 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(() => { useEffect(() => {
if (data.currently_working) setCurrentlyWorking(data.currently_working); if (careerTitle) {
if (data.career_name) setSelectedCareer(data.career_name); setSelectedCareer(careerTitle);
if (data.college_enrollment_status) setCollegeEnrollmentStatus(data.college_enrollment_status); setData((prev) => ({
}, [data]); ...prev,
career_name: careerTitle,
soc_code: socCode || ''
}));
}
}, [careerTitle, socCode, setData]);
// Called whenever other <inputs> change // Called whenever other <inputs> change
const handleChange = (e) => { const handleChange = (e) => {

View File

@ -53,6 +53,8 @@ function CollegeOnboarding({ nextStep, prevStep, data, setData }) {
const [manualProgramLength, setManualProgramLength] = useState(''); const [manualProgramLength, setManualProgramLength] = useState('');
const [autoProgramLength, setAutoProgramLength] = useState('0.00'); const [autoProgramLength, setAutoProgramLength] = useState('0.00');
/** /**
* handleParentFieldChange * handleParentFieldChange
* If user leaves numeric fields blank, store '' in local state, not 0. * If user leaves numeric fields blank, store '' in local state, not 0.