Skip to content

Commit

Permalink
fix benefit question scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
wbglaeser committed Dec 4, 2024
1 parent 0327340 commit 36886a1
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const App = () => {
<Route path="/onboarding-welcome/:benefitMode" element={<OnboardingWelcomeOverview/>}/>
<Route path="/eligibility-overview" element={<EligibilityOverviewScreen/>}/>
<Route path="/profile-section" element={<ProfileSectionScreen/>}/>
<Route path="/profile-section/:benefitId" element={<ProfileSectionScreen/>}/>
<Route path="/profile-section/:benefitMode" element={<ProfileSectionScreen/>}/>
<Route path="/benefit-page/:id" element={<BenefitPageScreen/>}/>
<Route path="/profile-overview" element={<ProfileScreen/>}/>
<Route path="/activity-log" element={<ActivityLogScreen/>}/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import HStack from "../../../shared-components/HStack";
import {Link} from "react-router-dom";
import globalStyles from "../../../styles/styles";
import useTranslation from "../../../language/useTranslation";
import {useSelectedBenefitStore} from "../../../storage/zustand";
import {useSelectedBenefitStore, useSelectedTopicsStore} from "../../../storage/zustand";

const EligibilityOverviewItemDetails = ({item, eligible}) => {
const { t } = useTranslation();
const {t} = useTranslation();
const setSelectedBenefit = useSelectedBenefitStore((state) => state.setSelectedBenefit);
const clearSelectedTopics = useSelectedTopicsStore((state) => state.clear);

return (
<VStack alignItems={'flex-start'}>
Expand All @@ -22,7 +23,10 @@ const EligibilityOverviewItemDetails = ({item, eligible}) => {
sx={styles.checkEligibilityButton}
variant="text"
component={Link}
onClick={setSelectedBenefit(item.id)}
onClick={() => {
setSelectedBenefit(item.id);
clearSelectedTopics()
}}
to={`/onboarding-welcome/${true}`}>
{t('app.browseAll.checkElBtn')}
</Button>
Expand Down
4 changes: 3 additions & 1 deletion src/ui/screens/onboarding-welcome/OnboardingWelcomeTopics.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useContext, useEffect, useState} from 'react';
import {Button, Checkbox, FormControlLabel, Typography} from '@mui/material';
import {useSelectedTopicsStore} from "../../storage/zustand";
import {useSelectedBenefitStore, useSelectedTopicsStore} from "../../storage/zustand";
import OnboardingWelcomeScreen from "./components/OnboardingWelcomeScreen";
import VStack from "../../shared-components/VStack";
import globalStyles from "../../styles/styles";
Expand All @@ -17,8 +17,10 @@ const OnboardingWelcomeTopics = () => {
const [topicsData, setTopicsData] = useState([]);
const [selectedTopicsBoolean, setSelectedTopicsBoolean] = useState([]);
const selectedTopics = useSelectedTopicsStore((state) => state.selectedTopics);
const clearSelectedBenefit = useSelectedBenefitStore((state) => state.clear);

useSetDataObject('assets/data/topics/topics-list.json', setTopicsData);
clearSelectedBenefit()

useEffect(() => {
if (topicsData.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback } from 'react';
import { useSelectedTopicsStore } from "../../../storage/zustand";
import {useSelectedTopicsStore} from "../../../storage/zustand";
import { questionsStackStore } from "../../../storage/zustand";

const useTopicSelectionHandlers = (topicsData, selectedTopicsBoolean, setSelectedTopicsBoolean) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {useCallback} from 'react';
import {UserManager} from '../../../../core/managers/userManager';
import userManager from '../../../../core/managers/userManager';
import {useUserStore} from '../../../storage/zustand';

function useRemoveProfileObject(currentField, entityData) {
Expand All @@ -8,7 +8,7 @@ function useRemoveProfileObject(currentField, entityData) {
return new Promise((resolve, reject) => {
if (currentField.datatype === 'class') {
try {
UserModel.removeObjectFromField(activeUserId, id, currentField.datafield, entityData);
userManager.removeObjectFromField(activeUserId, id, currentField.datafield, entityData);
resolve();
} catch (error) {
console.log('Error removing profile field')
Expand Down
14 changes: 7 additions & 7 deletions src/ui/shared-hooks/useRunPrioritizedQuestions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useContext, useEffect} from "react";
import {
useQuestionsStore,
useQuestionsStore, useSelectedBenefitStore,
useSelectedTopicsStore,
useUserStore,
useValidationReportStore
Expand All @@ -12,22 +12,22 @@ import {useQuestionsUpdate, useValidationUpdate} from "../storage/updates";
const useRunPrioritizedQuestions = (benefitId = null) => {
const userId = useUserStore((state) => state.activeUserId);
const selectedTopics = useSelectedTopicsStore((state) => state.selectedTopics);
const selectedBenefit = useSelectedBenefitStore((state) => state.selectedBenefit);
const updateCounter = useQuestionsUpdate((state) => state.updateCounter);
const setValidationIsLoading = useValidationUpdate((state) => state.setValidationIsLoading);
const {language} = useContext(LanguageContext);

useEffect(() => {
if (!userId || (!selectedTopics && !benefitId)) return;
const fetchPrioritizedQuestions = async (benefitId) => {
if (!userId || (!selectedTopics && !selectedBenefit)) return;
const fetchPrioritizedQuestions = async () => {
setValidationIsLoading(true);
const questionsResponse = await questionsManager.fetchPrioritizedQuestions(userId, benefitId ? [] : selectedTopics.map((topic) => topic.id), benefitId, language);
const questionsResponse = await questionsManager.fetchPrioritizedQuestions(userId, selectedBenefit ? [] : selectedTopics.map((topic) => topic.id), selectedBenefit, language);
useValidationReportStore.getState().updateValidationReport(questionsResponse.validationReport);
useQuestionsStore.getState().updateQuestions(questionsResponse.prioritizedMissingDataFields);
setValidationIsLoading(false);
}
fetchPrioritizedQuestions(benefitId);
}, [userId, selectedTopics, benefitId, language, updateCounter, setValidationIsLoading]);

fetchPrioritizedQuestions();
}, [userId, selectedTopics, selectedBenefit, language, updateCounter, setValidationIsLoading]);
};

export default useRunPrioritizedQuestions;

0 comments on commit 36886a1

Please sign in to comment.