Skip to content

Commit

Permalink
feat: update career chart to pull interested role not current role (#908
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jajjibhai008 authored Dec 19, 2023
1 parent d6caaea commit 7ddbe4e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/my-career/VisualizeCareer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const VisualizeCareer = ({ jobId, submitClickHandler }) => {
{!isEditable ? (
<div key="edit-job-button">
<ActionRow>
<p>Current Role</p>
<p>Desired Role</p>
<ActionRow.Spacer />
<Button variant="link" iconBefore={editIcon} onClick={editOnClickHandler}>Edit</Button>
</ActionRow>
Expand Down
3 changes: 2 additions & 1 deletion src/components/skills-quiz/SkillsQuizStepper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import TopSkillsOverview from './TopSkillsOverview';
import SkillsQuizHeader from './SkillsQuizHeader';

import headerImage from './images/headerImage.png';
import { saveSkillsGoalsAndJobsUserSelected } from './data/utils';
import { saveDesiredRoleForCareerChart, saveSkillsGoalsAndJobsUserSelected } from './data/utils';
import { fetchCourseEnrollments } from './data/service';

const SkillsQuizStepper = () => {
Expand Down Expand Up @@ -90,6 +90,7 @@ const SkillsQuizStepper = () => {

const flipToRecommendedCourses = () => {
saveSkillsGoalsAndJobsUserSelected(goal, currentJobRole, interestedJobs);
saveDesiredRoleForCareerChart(goal, currentJobRole, interestedJobs);
// show courses if learner has selected skills or jobs.
if (goalExceptImproveAndJobSelected) {
// verify if selectedJob is still checked and within first 3 jobs else
Expand Down
23 changes: 23 additions & 0 deletions src/components/skills-quiz/data/utils.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// get common skills between a course/program and the job selected by the learner
// here content can either be a course or a program

import { logError } from '@edx/frontend-platform/logging';
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
import { postSkillsGoalsAndJobsUserSelected } from './service';
import {
DROPDOWN_OPTION_CHANGE_CAREERS,
Expand All @@ -12,6 +14,8 @@ import {
DROPDOWN_OPTION_OTHER,
DROPDOWN_OPTION_OTHER_LABEL,
} from '../constants';
import { CURRENT_JOB_PROFILE_FIELD_NAME } from '../../my-career/data/constants';
import { patchProfile } from '../../my-career/data/service';

export default function getCommonSkills(content, selectedJobSkills, MAX_VISIBLE_SKILLS) {
const contentSkills = content.skillNames || [];
Expand Down Expand Up @@ -50,3 +54,22 @@ export const saveSkillsGoalsAndJobsUserSelected = async (goal, currentJobRole, i
const goalLabel = goalLabels(goal);
postSkillsGoalsAndJobsUserSelected(goalLabel, interestedJobsId, currentJobRoleId);
};

export const saveDesiredRoleForCareerChart = async (goal, currentJob, interestedJobs) => {
const { username } = getAuthenticatedUser();
const learnerFirstDesiredJobID = (goal === DROPDOWN_OPTION_IMPROVE_CURRENT_ROLE)
? currentJob[0].id
: interestedJobs[0]?.id;

const params = {
extended_profile: [
{ field_name: CURRENT_JOB_PROFILE_FIELD_NAME, field_value: learnerFirstDesiredJobID },
],
};

try {
await patchProfile(username, params);
} catch (error) {
logError(new Error(error));
}
};

0 comments on commit 7ddbe4e

Please sign in to comment.