diff --git a/src/CAREUI/misc/PaginatedList.tsx b/src/CAREUI/misc/PaginatedList.tsx index ec270bf8134..db68c6f042c 100644 --- a/src/CAREUI/misc/PaginatedList.tsx +++ b/src/CAREUI/misc/PaginatedList.tsx @@ -1,4 +1,4 @@ -import { createContext, useContext, useEffect, useState } from "react"; +import { createContext, useContext, useState } from "react"; import { PaginatedResponse, QueryRoute } from "../../Utils/request/types"; import useQuery, { QueryOptions } from "../../Utils/request/useQuery"; import ButtonV2, { @@ -33,9 +33,6 @@ function useContextualized() { interface Props extends QueryOptions> { route: QueryRoute>; perPage?: number; - queryCB?: ( - query: ReturnType>>, - ) => void; children: ( ctx: PaginatedListContext, query: ReturnType>>, @@ -46,7 +43,6 @@ export default function PaginatedList({ children, route, perPage = DEFAULT_PER_PAGE_LIMIT, - queryCB, ...queryOptions }: Props) { const [currentPage, setPage] = useState(1); @@ -61,12 +57,6 @@ export default function PaginatedList({ const items = query.data?.results ?? []; - useEffect(() => { - if (queryCB) { - queryCB(query); - } - }, [query]); - return ( (name: string, defaultValue?: T) => { - return { - name, - value: qParams[name] || defaultValue, - onChange: (e: FieldChangeEvent) => updateQuery({ [e.name]: e.value }), - className: "grow w-full mb-2", - }; - }; - - const [phone_number, setPhoneNumber] = useState(""); - const [phoneNumberError, setPhoneNumberError] = useState(""); - const [emergency_phone_number, setEmergencyPhoneNumber] = useState(""); - const [emergencyPhoneNumberError, setEmergencyPhoneNumberError] = - useState(""); - const [count, setCount] = useState(0); - - const setPhoneNum = (phone_number: string) => { - setPhoneNumber(phone_number); - if (phone_number.length >= 13) { - setPhoneNumberError(""); - updateQuery({ phone_number }); - return; - } - - if (phone_number === "+91" || phone_number === "") { - setPhoneNumberError(""); - qParams.phone_number && updateQuery({ phone_number: null }); - return; - } - - setPhoneNumberError("Enter a valid number"); - }; - - const setEmergencyPhoneNum = (emergency_phone_number: string) => { - setEmergencyPhoneNumber(emergency_phone_number); - if (emergency_phone_number.length >= 13) { - setEmergencyPhoneNumberError(""); - updateQuery({ emergency_phone_number }); - return; - } - - if (emergency_phone_number === "+91" || emergency_phone_number === "") { - setEmergencyPhoneNumberError(""); - qParams.emergency_phone_number && - updateQuery({ emergency_phone_number: null }); - return; - } - - setEmergencyPhoneNumberError("Enter a valid number"); - }; + const { qParams, updateQuery, FilterBadges } = useFilters({}); return ( -
+ updateQuery({ name: e.value }))} + /> +
navigate("/patients")} isTab2Active /> - advancedFilter.setShow(true)} - /> } > -
-
-
- -
-
-
-
-
- - -
-
- setPhoneNum(e.value)} - error={phoneNumberError} - types={["mobile", "landline"]} - /> - setEmergencyPhoneNum(e.value)} - error={emergencyPhoneNumberError} - types={["mobile", "landline"]} - /> -
-
-
-
- [ - phoneNumber("Primary number", "phone_number"), - phoneNumber("Emergency number", "emergency_phone_number"), - badge("Patient name", "name"), - badge("IP/OP number", "patient_no"), - ...dateRange("Modified", "modified_date"), - ...dateRange("Created", "created_date"), - badge("No. of vaccination doses", "number_of_doses"), - kasp(), - badge("COWIN ID", "covin_id"), - badge("Is Antenatal", "is_antenatal"), - badge("Review Missed", "review_missed"), - badge("Facility Type", "facility_type"), - ordering(), - badge("Disease Status", "disease_status"), - value( - "Respiratory Support", - "ventilator_interface", - qParams.ventilator_interface && - t(`RESPIRATORY_SUPPORT_${qParams.ventilator_interface}`), - ), - value( - "Gender", - "gender", - parseOptionId(GENDER_TYPES, qParams.gender) || "", - ), - ...range("Age", "age"), - badge("SRF ID", "srf_id"), - badge("Declared Status", "is_declared_positive"), - ...dateRange("Result", "date_of_result"), - ...dateRange("Declared positive", "date_declared_positive"), - ...dateRange("Last vaccinated", "last_vaccinated_date"), - ]} - /> + [ordering()]} />
{ - setCount(query.data?.count || 0); - }} > {() => ( -
+
{t("discharged_patients_empty")} @@ -254,11 +99,6 @@ const DischargedPatientsList = ({
)} - ); }; diff --git a/src/Components/Patient/PatientFilter.tsx b/src/Components/Patient/PatientFilter.tsx index 5ded9678f7d..7c68dce8fbc 100644 --- a/src/Components/Patient/PatientFilter.tsx +++ b/src/Components/Patient/PatientFilter.tsx @@ -379,10 +379,9 @@ export default function PatientFilter(props: any) { } />
- {(props.dischargePage || - ["StateAdmin", "StateReadOnlyAdmin"].includes( - authUser.user_type, - )) && ( + {["StateAdmin", "StateReadOnlyAdmin"].includes( + authUser.user_type, + ) && (
Discharge Reason
- {!props.dischargePage && ( -
- Facility - setFilterWithRef("facility", obj)} - /> -
- )} +
+ Facility + setFilterWithRef("facility", obj)} + /> +
{filterState.facility && (
Location @@ -616,24 +613,22 @@ export default function PatientFilter(props: any) { />
)} - {!props.dischargePage && ( -
- Facility type - o.text} - optionValue={(o) => o.text} - value={filterState.facility_type} - onChange={(v) => - setFilterState({ ...filterState, facility_type: v }) - } - optionIcon={() => ( - - )} - /> -
- )} +
+ Facility type + o.text} + optionValue={(o) => o.text} + value={filterState.facility_type} + onChange={(v) => + setFilterState({ ...filterState, facility_type: v }) + } + optionIcon={() => ( + + )} + /> +
LSG Body