Skip to content

Commit

Permalink
remove bunch of useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Jan 24, 2024
1 parent 5d1466d commit 6ee76f1
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 142 deletions.
16 changes: 4 additions & 12 deletions src/Components/Assets/AssetFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect, useCallback } from "react";
import { useState, useEffect } from "react";
import { useQueryParams } from "raviger";
import { FacilitySelect } from "../Common/FacilitySelect";
import { FacilityModel } from "../Facility/models";
Expand Down Expand Up @@ -53,18 +53,10 @@ function AssetFilter(props: any) {
);
}, [facility?.id, qParams.facility, qParams.location]);

const clearFilter = useCallback(() => {
removeFilters([
"facility",
"asset_type",
"asset_class",
"status",
"location",
"warranty_amc_end_of_validity_before",
"warranty_amc_end_of_validity_after",
]);
const clearFilter = () => {
removeFilters();
closeFilter();
}, [qParams]);
};

const applyFilter = () => {
const data = {
Expand Down
16 changes: 1 addition & 15 deletions src/Components/ExternalResult/ListFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ import routes from "../../Redux/api";
import Loading from "../Common/Loading";
import { LocalBodyModel, WardModel } from "../Facility/models";

const clearFilterState = {
created_date_before: "",
created_date_after: "",
result_date_before: "",
result_date_after: "",
sample_collection_date_before: "",
sample_collection_date_after: "",
srf_id: "",
};

const getDate = (value: any) =>
value && dayjs(value).isValid() && dayjs(value).toDate();

Expand Down Expand Up @@ -185,11 +175,7 @@ export default function ListFilter(props: any) {
advancedFilter={props}
onApply={applyFilter}
onClear={() => {
removeFilters([
...Object.keys(clearFilterState),
"wards",
"local_bodies",
]);
removeFilters();
closeFilter();
}}
>
Expand Down
9 changes: 1 addition & 8 deletions src/Components/Facility/FacilityFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ import DistrictAutocompleteFormField from "../../Common/DistrictAutocompleteForm
import LocalBodyAutocompleteFormField from "../../Common/LocalBodyAutocompleteFormField";
import { SelectFormField } from "../../Form/FormFields/SelectFormField";

const clearFilterState = {
state: "",
district: "",
local_body: "",
facility_type: "",
};

function FacilityFilter(props: any) {
const { t } = useTranslation();
const { filter, onChange, closeFilter, removeFilters } = props;
Expand Down Expand Up @@ -65,7 +58,7 @@ function FacilityFilter(props: any) {
advancedFilter={props}
onApply={applyFilter}
onClear={() => {
removeFilters(Object.keys(clearFilterState));
removeFilters();
closeFilter();
}}
>
Expand Down
46 changes: 1 addition & 45 deletions src/Components/Patient/PatientFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,50 +101,6 @@ export default function PatientFilter(props: any) {
});
const dispatch: any = useDispatch();

const clearFilterState = {
district: "",
facility: "",
facility_type: "",
lsgBody: "",
facility_ref: null,
lsgBody_ref: null,
district_ref: null,
date_declared_positive_before: "",
date_declared_positive_after: "",
date_of_result_before: "",
date_of_result_after: "",
created_date_before: "",
created_date_after: "",
modified_date_before: "",
modified_date_after: "",
category: null,
gender: null,
disease_status: null,
age_min: "",
age_max: "",
date_of_result: null,
date_declared_positive: null,
last_consultation_medico_legal_case: null,
last_consultation_encounter_date_before: "",
last_consultation_encounter_date_after: "",
last_consultation_discharge_date_before: "",
last_consultation_discharge_date_after: "",
last_consultation_admitted_to_list: [],
last_consultation_current_bed__location: "",
srf_id: "",
number_of_doses: null,
covin_id: "",
is_kasp: null,
is_declared_positive: null,
last_consultation_symptoms_onset_date_before: "",
last_consultation_symptoms_onset_date_after: "",
last_vaccinated_date_before: "",
last_vaccinated_date_after: "",
last_consultation_is_telemedicine: null,
is_antenatal: null,
ventilator_interface: null,
};

useEffect(() => {
async function fetchData() {
if (filter.facility) {
Expand Down Expand Up @@ -336,7 +292,7 @@ export default function PatientFilter(props: any) {
advancedFilter={props}
onApply={applyFilter}
onClear={() => {
removeFilters(Object.keys(clearFilterState));
removeFilters();
closeFilter();
}}
>
Expand Down
10 changes: 1 addition & 9 deletions src/Components/Patient/SampleFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ import { FieldLabel } from "../Form/FormFields/FormField";
import { SelectFormField } from "../Form/FormFields/SelectFormField";
import { FieldChangeEvent } from "../Form/FormFields/Utils";

const clearFilterState = {
status: "",
result: "",
facility: "",
facility_ref: null,
sample_type: "",
};

export default function UserFilter(props: any) {
const { filter, onChange, closeFilter, removeFilters } = props;

Expand Down Expand Up @@ -73,7 +65,7 @@ export default function UserFilter(props: any) {
advancedFilter={props}
onApply={applyFilter}
onClear={() => {
removeFilters(Object.keys(clearFilterState));
removeFilters();
closeFilter();
}}
>
Expand Down
18 changes: 1 addition & 17 deletions src/Components/Resource/ListFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,6 @@ import { dateQueryString } from "../../Utils/utils";
import useQuery from "../../Utils/request/useQuery";
import routes from "../../Redux/api";

const clearFilterState = {
origin_facility: "",
origin_facility_ref: "",
approving_facility: "",
approving_facility_ref: "",
assigned_facility: "",
assigned_facility_ref: "",
emergency: "",
created_date_before: "",
created_date_after: "",
modified_date_before: "",
modified_date_after: "",
ordering: "",
status: "",
};

const getDate = (value: any) =>
value && dayjs(value).isValid() && dayjs(value).toDate();

Expand Down Expand Up @@ -139,7 +123,7 @@ export default function ListFilter(props: any) {
advancedFilter={props}
onApply={applyFilter}
onClear={() => {
removeFilters(Object.keys(clearFilterState));
removeFilters();
closeFilter();
}}
>
Expand Down
26 changes: 1 addition & 25 deletions src/Components/Shifting/ListFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,6 @@ import dayjs from "dayjs";
import useQuery from "../../Utils/request/useQuery";
import routes from "../../Redux/api";

const clearFilterState = {
origin_facility: "",
origin_facility_ref: "",
shifting_approving_facility: "",
shifting_approving_facility_ref: "",
assigned_facility: "",
assigned_facility_ref: "",
emergency: "",
is_up_shift: "",
created_date_before: "",
created_date_after: "",
modified_date_before: "",
modified_date_after: "",
patient_phone_number: "",
ordering: "",
is_kasp: "",
status: "",
assigned_user_ref: "",
assigned_to: "",
disease_status: "",
is_antenatal: "",
breathlessness_level: "",
};

const getDate = (value: any) =>
value && dayjs(value).isValid() && dayjs(value).toDate();

Expand Down Expand Up @@ -220,7 +196,7 @@ export default function ListFilter(props: any) {
advancedFilter={props}
onApply={applyFilter}
onClear={() => {
removeFilters(Object.keys(clearFilterState));
removeFilters();
closeFilter();
}}
>
Expand Down
12 changes: 1 addition & 11 deletions src/Components/Users/UserFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ export default function UserFilter(props: any) {
district_ref: null,
});

const clearFilterState = {
first_name: "",
last_name: "",
phone_number: undefined,
alt_phone_number: undefined,
user_type: "",
district_id: "",
district_ref: null,
};

const setDistrict = (selected: any) => {
const filterData: any = { ...filterState };
filterData["district_ref"] = selected;
Expand Down Expand Up @@ -83,7 +73,7 @@ export default function UserFilter(props: any) {
advancedFilter={props}
onApply={applyFilter}
onClear={() => {
removeFilters(Object.keys(clearFilterState));
removeFilters();
closeFilter();
}}
>
Expand Down

0 comments on commit 6ee76f1

Please sign in to comment.