Skip to content

Commit

Permalink
feat: remove link when a stage is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
9sneha-n committed Jan 24, 2025
1 parent 3a8385a commit 27262ec
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
12 changes: 3 additions & 9 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2025-01-19T19:00:38.576Z\n"
"PO-Revision-Date: 2025-01-19T19:00:38.576Z\n"
"POT-Creation-Date: 2025-01-24T07:04:36.375Z\n"
"PO-Revision-Date: 2025-01-24T07:04:36.375Z\n"

msgid "There was a problem with \"{{name}}\" - {{prop}} is not set"
msgstr ""
Expand Down Expand Up @@ -62,18 +62,12 @@ msgstr ""
msgid "Stage - Profile"
msgstr ""

msgid "Save Indication"
msgstr ""

msgid "Save Treatment"
msgid "Save"
msgstr ""

msgid "Cancel"
msgstr ""

msgid "Save"
msgstr ""

msgid "PPS Surveys"
msgstr ""

Expand Down
10 changes: 2 additions & 8 deletions i18n/es.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
"POT-Creation-Date: 2025-01-19T19:00:38.576Z\n"
"POT-Creation-Date: 2025-01-24T07:04:36.375Z\n"
"PO-Revision-Date: 2018-10-25T09:02:35.143Z\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -62,18 +62,12 @@ msgstr ""
msgid "Stage - Profile"
msgstr ""

msgid "Save Indication"
msgstr ""

msgid "Save Treatment"
msgid "Save"
msgstr ""

msgid "Cancel"
msgstr ""

msgid "Save"
msgstr ""

msgid "PPS Surveys"
msgstr ""

Expand Down
11 changes: 9 additions & 2 deletions src/webapp/components/survey/SurveyForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const SurveyForm: React.FC<SurveyFormProps> = props => {
props.currentSurveyId
);

const { indicationOptions, treatmentOptions } = useTreatmentIndicationLink(
const { indicationOptions, treatmentOptions, removeLinkedStage } = useTreatmentIndicationLink(
props.formType,
questionnaire
);
Expand Down Expand Up @@ -118,6 +118,11 @@ export const SurveyForm: React.FC<SurveyFormProps> = props => {
}
};

const removeLinksAndStage = (stageId: string, stageCode: string) => {
removeLinkedStage(stageCode);
removeProgramStage(stageId);
};

const onCancel = () => {
props.hideForm();
};
Expand Down Expand Up @@ -236,7 +241,9 @@ export const SurveyForm: React.FC<SurveyFormProps> = props => {
{stage.isAddedByUser && (
<CancelButton
variant="outlined"
onClick={() => removeProgramStage(stage.id)}
onClick={() =>
removeLinksAndStage(stage.id, stage.code)
}
>
{i18n.t(`Remove ${stage.title}`)}
</CancelButton>
Expand Down
17 changes: 15 additions & 2 deletions src/webapp/components/survey/hook/useTreatmentIndicationLink.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from "react";
import { useCallback, useEffect, useState } from "react";
import { QuestionOption } from "../../../../domain/entities/Questionnaire/QuestionnaireQuestion";
import { Questionnaire } from "../../../../domain/entities/Questionnaire/Questionnaire";
import { SURVEY_FORM_TYPES } from "../../../../domain/entities/Survey";
Expand Down Expand Up @@ -55,5 +55,18 @@ export const useTreatmentIndicationLink = (
}
}, [formType, questionnaire]);

return { treatmentOptions, indicationOptions };
const removeLinkedStage = useCallback((stageCode: string) => {
if (stageCode === PPS_PATIENT_TRACKER_TREATMENT_STAGE_ID) {
setTreatmentOptions(prevTreatmeantOptions => {
return prevTreatmeantOptions?.filter(option => option.code !== stageCode);
});

} else if (stageCode === PPS_PATIENT_TRACKER_INDICATION_STAGE_ID) {
setIndicationOptions(prevIndicationOptions => {
return prevIndicationOptions?.filter(option => option.code !== stageCode);
});
}
}, []);

return { treatmentOptions, indicationOptions, removeLinkedStage };
};

0 comments on commit 27262ec

Please sign in to comment.