Skip to content

Commit

Permalink
fix: add status filter for prevalence
Browse files Browse the repository at this point in the history
  • Loading branch information
9sneha-n committed May 23, 2024
1 parent d634b0f commit 2f06fbe
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 27 deletions.
4 changes: 4 additions & 0 deletions src/webapp/components/survey-list/SurveyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ export const SurveyList: React.FC<SurveyListProps> = ({ surveyFormType }) => {
/>
)}

{surveyFormType === "PrevalenceSurveyForm" && (
<SurveyListFilters status={statusFilter} setStatus={setStatusFilter} />
)}

{isPaginatedSurveyList(surveyFormType) ? (
<PaginatedSurveyListTable
surveys={searchResultSurveys}
Expand Down
54 changes: 28 additions & 26 deletions src/webapp/components/survey-list/SurveyListFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { SURVEY_STATUSES, SURVEY_TYPES } from "../../../domain/entities/Survey";
interface SurveyListFilterProps {
status: SURVEY_STATUSES | undefined;
setStatus: Dispatch<SetStateAction<SURVEY_STATUSES | undefined>>;
surveyType: SURVEY_TYPES | undefined;
setSurveyType: Dispatch<SetStateAction<SURVEY_TYPES | undefined>>;
surveyType?: SURVEY_TYPES | undefined;
setSurveyType?: Dispatch<SetStateAction<SURVEY_TYPES | undefined>>;
}
export const SurveyListFilters: React.FC<SurveyListFilterProps> = ({
status,
Expand All @@ -18,7 +18,7 @@ export const SurveyListFilters: React.FC<SurveyListFilterProps> = ({
}) => {
return (
<FilterContainer>
<FormControl fullWidth>
<FormControl style={{ width: "50%" }}>
<InputLabel id="status-label">{i18n.t("Filter by Status")}</InputLabel>
<Select
labelId="status-label"
Expand All @@ -44,29 +44,31 @@ export const SurveyListFilters: React.FC<SurveyListFilterProps> = ({
</Select>
</FormControl>

<FormControl fullWidth>
<InputLabel id="status-label">{i18n.t("Filter by Survey Type")}</InputLabel>
<Select
value={surveyType}
onChange={e => {
if (e.target.value === "ALL") setSurveyType(undefined);
else setSurveyType(e.target.value as SURVEY_TYPES);
}}
>
<MenuItem key="SUPRANATIONAL" value="SUPRANATIONAL">
{i18n.t("SUPRANATIONAL")}
</MenuItem>
<MenuItem key="NATIONAL" value="NATIONAL">
{i18n.t("NATIONAL")}
</MenuItem>
<MenuItem key="HOSP" value="HOSP">
{i18n.t("HOSP")}
</MenuItem>
<MenuItem key="ALL-SurveyType" value="ALL">
{i18n.t("ALL")}
</MenuItem>
</Select>
</FormControl>
{setSurveyType && (
<FormControl style={{ width: "50%" }}>
<InputLabel id="status-label">{i18n.t("Filter by Survey Type")}</InputLabel>
<Select
value={surveyType}
onChange={e => {
if (e.target.value === "ALL") setSurveyType(undefined);
else setSurveyType(e.target.value as SURVEY_TYPES);
}}
>
<MenuItem key="SUPRANATIONAL" value="SUPRANATIONAL">
{i18n.t("SUPRANATIONAL")}
</MenuItem>
<MenuItem key="NATIONAL" value="NATIONAL">
{i18n.t("NATIONAL")}
</MenuItem>
<MenuItem key="HOSP" value="HOSP">
{i18n.t("HOSP")}
</MenuItem>
<MenuItem key="ALL-SurveyType" value="ALL">
{i18n.t("ALL")}
</MenuItem>
</Select>
</FormControl>
)}
</FilterContainer>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function useFilteredSurveys(

useEffect(() => {
//filters apply only to PPSSurveyForm
if (surveyFormType !== "PPSSurveyForm") {
if (surveyFormType !== "PPSSurveyForm" && surveyFormType !== "PrevalenceSurveyForm") {
setStatusFilter(undefined);
setSurveyTypeFilter(undefined);
}
Expand Down

0 comments on commit 2f06fbe

Please sign in to comment.