Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide KASP Advance Filter #6687

Merged
merged 5 commits into from
Nov 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions src/Components/Facility/FacilityFilter/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { navigate } from "raviger";
import { FACILITY_TYPES } from "../../../Common/constants";
import useMergeState from "../../../Common/hooks/useMergeState";
import useConfig from "../../../Common/hooks/useConfig";
import FiltersSlideover from "../../../CAREUI/interactive/FiltersSlideover";
import { useTranslation } from "react-i18next";
import StateAutocompleteFormField from "../../Common/StateAutocompleteFormField";
import { FieldChangeEvent } from "../../Form/FormFields/Utils";
import DistrictAutocompleteFormField from "../../Common/DistrictAutocompleteFormField";
import LocalBodyAutocompleteFormField from "../../Common/LocalBodyAutocompleteFormField";
import { SelectFormField } from "../../Form/FormFields/SelectFormField";
import AccordionV2 from "../../Common/components/AccordionV2";

const clearFilterState = {
state: "",
Expand All @@ -21,7 +21,7 @@ const clearFilterState = {
function FacilityFilter(props: any) {
const { t } = useTranslation();
const { filter, onChange, closeFilter } = props;
const { kasp_string } = useConfig();

const [filterState, setFilterState] = useMergeState({
state: filter.state || "",
district: filter.district || "",
Expand Down Expand Up @@ -58,9 +58,9 @@ function FacilityFilter(props: any) {
setFilterState(filterData);
};

const field = (name: string) => ({
const field = (name: string, showLabel = true) => ({
name,
label: t(name),
label: showLabel ? t(name) : undefined,
value: filterState[name],
onChange: handleChange,
});
Expand Down Expand Up @@ -92,17 +92,23 @@ function FacilityFilter(props: any) {
optionValue={(option) => option.id}
placeholder={t("show_all")}
/>
<SelectFormField
{...field("kasp_empanelled")}
label={`${kasp_string} Empanelled`}
options={[
{ id: "true", text: t("yes") },
{ id: "false", text: t("no") },
]}
optionLabel={(option) => option.text}
optionValue={(option) => option.id}
placeholder={t("show_all")}
/>
<AccordionV2
title={"KASP Empanelled"}
expanded={false}
className="w-full rounded-md"
>
<SelectFormField
{...field("kasp_empanelled", false)}
options={[
{ id: "true", text: t("yes") },
{ id: "false", text: t("no") },
]}
optionLabel={(option) => option.text}
optionValue={(option) => option.id}
placeholder={t("show_all")}
className="mt-2"
/>
</AccordionV2>
</div>
</FiltersSlideover>
);
Expand Down
Loading