Skip to content

Commit

Permalink
fix: added placeWork to WorkTime remote source
Browse files Browse the repository at this point in the history
  • Loading branch information
MailineN committed Jul 17, 2024
1 parent 747351b commit 7ac6208
Show file tree
Hide file tree
Showing 4 changed files with 820 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/pages/activity/Activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { getData, getSource, getSurveyRights, getTabsData } from "service/survey

const ActivityPage = () => {
const source = getSource(SourcesEnum.ACTIVITY_SURVEY);
console.log("source ActivityPage", source);
const navigate = useNavigate();

const context: OrchestratorContext = useOutletContext();
Expand Down
9 changes: 2 additions & 7 deletions src/pages/work-time/weekly-planner/WeeklyPlanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ const WeeklyPlannerPage = () => {

// TODO: fix null check & move elsewhere & fix questionnaire model (temp solution)
const initializeCollectedFields = (dataBdd: LunaticData, fieldsToInitialize: FieldNameEnum[]) => {
console.log("initializeCollectedFields");
if (dataBdd.COLLECTED !== undefined) {
fieldsToInitialize.forEach(field => {
if (!dataBdd.COLLECTED?.[field]) {
Expand All @@ -104,10 +103,8 @@ const WeeklyPlannerPage = () => {

const save = (idSurvey: string, data?: [IODataStructure[], string[], string[], any[]]): void => {
const dataBdd = getData(idSurvey);
console.log("data", data);
if (data && data[1].length > 0) {
if (dataBdd.COLLECTED) {
console.log("DataBdd", dataBdd);
initializeCollectedFields(dataBdd, [
FieldNameEnum.WEEKLYPLANNER,
FieldNameEnum.DATES,
Expand Down Expand Up @@ -148,7 +145,7 @@ const WeeklyPlannerPage = () => {
dataCopy.COLLECTED[name].COLLECTED = quartier;
}
});
saveData(idSurveyResponse, dataCopy);
saveDataLocally(idSurveyResponse, dataCopy);
}

if (
Expand All @@ -169,8 +166,7 @@ const WeeklyPlannerPage = () => {
dataCopy.COLLECTED[name].EDITED = quartier;
}
});
console.log("saveData duration");
saveData(idSurveyResponse, dataCopy);
saveDataLocally(idSurveyResponse, dataCopy);
}
};

Expand Down Expand Up @@ -296,7 +292,6 @@ const WeeklyPlannerPage = () => {
const onHelp = useCallback(() => {
setIsHelpMenuOpen(true);
}, []);

return (
<ErrorBoundary FallbackComponent={ErrorProvider}>
<Box
Expand Down
9 changes: 8 additions & 1 deletion src/service/survey-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import {
} from "utils/utils";
import { validate } from "uuid";
import workTimeSource from "work-time-survey.json";
import placeWorkSource from "utils/placeWork.json";
import { EdtUserRightsEnum } from "./../enumerations/EdtUserRightsEnum";
import { LunaticData } from "./../interface/lunatic/Lunatic";
import {
Expand Down Expand Up @@ -1236,8 +1237,14 @@ const getActivitySource = () => {
return sourcesData != null ? sourcesData.edtActivitySurvey : activitySurveySource;
};

//TODO: Temp solution as place work does not exist
const getWorkTimeSource = () => {
return sourcesData != null ? sourcesData.edtWorkTimeSurvey : workTimeSource;
if (sourcesData?.edtWorkTimeSurvey) {
const data = { ...sourcesData.edtWorkTimeSurvey, ...placeWorkSource };
return data;
} else {
return workTimeSource;
}
};

const getSource = (refName: SourcesEnum) => {
Expand Down
Loading

0 comments on commit 7ac6208

Please sign in to comment.