Skip to content

Commit

Permalink
feat: add loading spinner for updated current job on career chart page (
Browse files Browse the repository at this point in the history
  • Loading branch information
jajjibhai008 authored Jul 7, 2023
1 parent 0bfb8a7 commit 11d2acb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/my-career/VisualizeCareer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const VisualizeCareer = ({ jobId, submitClickHandler }) => {
const [showInstructions, , , toggleShowInstructions] = useToggle(false);
const [isEditable, setIsEditable] = useState(false);

const [learnerSkillLevels, learnerSkillLevelsFetchError] = useLearnerSkillLevels(jobId);
const [learnerSkillLevels, learnerSkillLevelsFetchError, isLoading] = useLearnerSkillLevels(jobId);

const editOnClickHandler = () => {
setIsEditable(true);
Expand All @@ -44,7 +44,7 @@ const VisualizeCareer = ({ jobId, submitClickHandler }) => {
return <ErrorPage status={learnerSkillLevelsFetchError.status} />;
}

if (!learnerSkillLevels) {
if (!learnerSkillLevels || isLoading) {
return (
<div className="py-5">
<LoadingSpinner data-testid="loading-spinner" screenReaderText="Visualize Career Tab" />
Expand Down
5 changes: 4 additions & 1 deletion src/components/my-career/data/hooks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ export function useLearnerProfileData(username) {
export function useLearnerSkillLevels(jobId) {
const [learnerSkillLevels, setLearnerSkillLevels] = useState();
const [fetchError, setFetchError] = useState();
const [isLoading, setIsLoading] = useState(false);

useEffect(() => {
const fetchData = async () => {
setIsLoading(true);
if (jobId) {
try {
const response = await getLearnerSkillLevels(jobId);
Expand All @@ -45,11 +47,12 @@ export function useLearnerSkillLevels(jobId) {
setFetchError(error);
}
}
setIsLoading(false);
return undefined;
};
fetchData();
}, [jobId]);
return [camelCaseObject(learnerSkillLevels), fetchError];
return [camelCaseObject(learnerSkillLevels), fetchError, isLoading];
}

export function usePlotlySpiderChart(categories) {
Expand Down

0 comments on commit 11d2acb

Please sign in to comment.