Added localstorage to make onboarding easier.
This commit is contained in:
parent
8166a1119c
commit
7c29439ac3
@ -670,7 +670,7 @@ function CareerExplorer() {
|
||||
`Are you sure you want to move on to Educational Programs for ${career.title}?`
|
||||
);
|
||||
if (!confirmed) return;
|
||||
|
||||
localStorage.setItem("selectedCareer", JSON.stringify(career));
|
||||
// 2) Look up CIP codes from masterCareerRatings by SOC code
|
||||
const matching = masterCareerRatings.find((r) => r.soc_code === career.code);
|
||||
if (!matching) {
|
||||
|
@ -116,6 +116,10 @@ function EducationalProgramsPage() {
|
||||
'You’re about to move to the financial planning portion of the app, which is reserved for premium subscribers. Do you want to continue?'
|
||||
);
|
||||
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 } });
|
||||
}
|
||||
};
|
||||
@ -221,9 +225,10 @@ useEffect(() => {
|
||||
setCareerTitle(parsed.title || '');
|
||||
|
||||
// Re-set CIP code logic (like in handleCareerSelected)
|
||||
let rawCips = Array.isArray(parsed.cip_code)
|
||||
? parsed.cip_code
|
||||
: [parsed.cip_code];
|
||||
let rawCips = parsed.cip_code || [];
|
||||
if (!Array.isArray(rawCips)) rawCips = [rawCips].filter(Boolean);
|
||||
|
||||
|
||||
const cleanedCips = rawCips.map((code) => code.toString().replace('.', '').slice(0, 4));
|
||||
setCipCodes(cleanedCips);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
// 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';
|
||||
@ -15,12 +16,27 @@ const CareerOnboarding = ({ nextStep, prevStep, data, setData }) => {
|
||||
const [selectedCareer, setSelectedCareer] = 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(() => {
|
||||
if (data.currently_working) setCurrentlyWorking(data.currently_working);
|
||||
if (data.career_name) setSelectedCareer(data.career_name);
|
||||
if (data.college_enrollment_status) setCollegeEnrollmentStatus(data.college_enrollment_status);
|
||||
}, [data]);
|
||||
if (careerTitle) {
|
||||
setSelectedCareer(careerTitle);
|
||||
setData((prev) => ({
|
||||
...prev,
|
||||
career_name: careerTitle,
|
||||
soc_code: socCode || ''
|
||||
}));
|
||||
}
|
||||
}, [careerTitle, socCode, setData]);
|
||||
|
||||
// Called whenever other <inputs> change
|
||||
const handleChange = (e) => {
|
||||
|
@ -53,6 +53,8 @@ function CollegeOnboarding({ nextStep, prevStep, data, setData }) {
|
||||
const [manualProgramLength, setManualProgramLength] = useState('');
|
||||
const [autoProgramLength, setAutoProgramLength] = useState('0.00');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* handleParentFieldChange
|
||||
* If user leaves numeric fields blank, store '' in local state, not 0.
|
||||
|
Loading…
Reference in New Issue
Block a user