From 39dcf7c6e123f056e92b6665d2755bd3dc170694 Mon Sep 17 00:00:00 2001 From: sriharsh05 Date: Sat, 14 Oct 2023 17:34:12 +0530 Subject: [PATCH 01/10] replace useDispatch with useQuery/request in facility module --- src/Components/Facility/FacilityCard.tsx | 19 +- src/Components/Facility/FacilityCreate.tsx | 393 ++++++----- src/Components/Facility/FacilityHome.tsx | 229 +++++-- src/Components/Facility/FacilityUsers.tsx | 108 +-- src/Components/Facility/HospitalList.tsx | 220 +++--- src/Components/Facility/InventoryList.tsx | 61 +- src/Components/Facility/InventoryLog.tsx | 98 +-- src/Components/Facility/LegacyFacilityCNS.tsx | 118 +++- src/Components/Facility/MinQuantityList.tsx | 64 +- .../Facility/MinQuantityRequiredModal.tsx | 96 +-- src/Components/Facility/SetInventoryForm.tsx | 130 ++-- .../Facility/TransferPatientDialog.tsx | 29 +- src/Components/Facility/TreatmentSummary.tsx | 133 ++-- src/Components/Facility/TriageForm.tsx | 172 ++--- .../Facility/UpdateFacilityMiddleware.tsx | 85 +-- src/Components/Facility/models.tsx | 648 +++++++++++++++++- src/Redux/actions.tsx | 135 +--- src/Redux/api.tsx | 139 +++- 18 files changed, 1900 insertions(+), 977 deletions(-) diff --git a/src/Components/Facility/FacilityCard.tsx b/src/Components/Facility/FacilityCard.tsx index 43e515cec93..9fc80f7d211 100644 --- a/src/Components/Facility/FacilityCard.tsx +++ b/src/Components/Facility/FacilityCard.tsx @@ -1,9 +1,6 @@ import { useState } from "react"; -import { useDispatch } from "react-redux"; import { Link } from "raviger"; import { useTranslation } from "react-i18next"; - -import { sendNotificationMessages } from "../../Redux/actions"; import { FACILITY_FEATURE_TYPES } from "../../Common/constants"; import ButtonV2, { Cancel, Submit } from "../Common/components/ButtonV2"; import * as Notification from "../../Utils/Notifications.js"; @@ -14,25 +11,27 @@ import DialogModal from "../Common/Dialog"; import TextAreaFormField from "../Form/FormFields/TextAreaFormField"; import useConfig from "../../Common/hooks/useConfig"; import { classNames } from "../../Utils/utils"; +import request from "../../Utils/request/request"; +import routes from "../../Redux/api"; export const FacilityCard = (props: { facility: any; userType: any }) => { const { facility, userType } = props; const { kasp_string } = useConfig(); const { t } = useTranslation(); - const dispatchAction: any = useDispatch(); const [notifyModalFor, setNotifyModalFor] = useState(undefined); const [notifyMessage, setNotifyMessage] = useState(""); const [notifyError, setNotifyError] = useState(""); const handleNotifySubmit = async (id: any) => { - const data = { - facility: id, - message: notifyMessage, - }; - if (data.message.trim().length >= 1) { + if (notifyMessage.trim().length >= 1) { setNotifyError(""); - const res = await dispatchAction(sendNotificationMessages(data)); + const { res } = await request(routes.sendNotificationMessages, { + body: { + facility: id, + message: notifyMessage, + }, + }); if (res && res.status == 204) { Notification.Success({ msg: "Facility Notified", diff --git a/src/Components/Facility/FacilityCreate.tsx b/src/Components/Facility/FacilityCreate.tsx index e742caefb82..88b55debfa7 100644 --- a/src/Components/Facility/FacilityCreate.tsx +++ b/src/Components/Facility/FacilityCreate.tsx @@ -1,7 +1,7 @@ import * as Notification from "../../Utils/Notifications.js"; import ButtonV2, { Cancel, Submit } from "../Common/components/ButtonV2"; -import { CapacityModal, DoctorModal } from "./models"; +import { CapacityModal, DoctorModal, IFacilityRequest } from "./models"; import { DraftSection, useAutoSaveReducer } from "../../Utils/AutoSave.js"; import { FACILITY_FEATURE_TYPES, @@ -13,19 +13,8 @@ import { SelectFormField, } from "../Form/FormFields/SelectFormField"; import { Popover, Transition } from "@headlessui/react"; -import { Fragment, lazy, useCallback, useState } from "react"; +import { Fragment, lazy, useEffect, useState } from "react"; import Steps, { Step } from "../Common/Steps"; -import { - createFacility, - getDistrictByState, - getLocalbodyByDistrict, - getPermittedFacility, - getStates, - getWardByLocalBody, - listCapacity, - listDoctor, - updateFacility, -} from "../../Redux/actions"; import { getPincodeDetails, includesIgnoreCase, @@ -37,7 +26,6 @@ import { validateLongitude, validatePincode, } from "../../Common/validation"; -import { statusType, useAbortableEffect } from "../../Common/utils"; import { BedCapacity } from "./BedCapacity"; import BedTypeCard from "./BedTypeCard"; @@ -57,9 +45,11 @@ import TextFormField from "../Form/FormFields/TextFormField"; import { navigate } from "raviger"; import useAppHistory from "../../Common/hooks/useAppHistory"; import useConfig from "../../Common/hooks/useConfig"; -import { useDispatch } from "react-redux"; import { useTranslation } from "react-i18next"; import { PhoneNumberValidator } from "../Form/FieldValidators.js"; +import request from "../../Utils/request/request.js"; +import routes from "../../Redux/api.js"; +import useQuery from "../../Utils/request/useQuery.js"; const Loading = lazy(() => import("../Common/Loading")); @@ -150,7 +140,6 @@ const facilityCreateReducer = (state = initialState, action: FormAction) => { export const FacilityCreate = (props: FacilityProps) => { const { t } = useTranslation(); const { gov_data_api_key, kasp_string, kasp_enabled } = useConfig(); - const dispatchAction: any = useDispatch(); const { facilityId } = props; const [state, dispatch] = useAutoSaveReducer( @@ -176,37 +165,47 @@ export const FacilityCreate = (props: FacilityProps) => { const { goBack } = useAppHistory(); const headerText = !facilityId ? "Create Facility" : "Update Facility"; const buttonText = !facilityId ? "Save Facility" : "Update Facility"; + const [newId, setNewId] = useState(0); - const fetchDistricts = useCallback( - async (id: number) => { - if (id > 0) { - setIsDistrictLoading(true); - const districtList = await dispatchAction(getDistrictByState({ id })); - if (districtList) { - setDistricts([...districtList.data]); - } - setIsDistrictLoading(false); - return districtList ? [...districtList.data] : []; - } + const { + res: districtRes, + data: districtData, + refetch: districtFetch, + } = useQuery(routes.getDistrictByState, { + pathParams: { + id: String(newId), }, - [dispatchAction] - ); + }); - const fetchLocalBody = useCallback( - async (id: number) => { - if (id > 0) { - setIsLocalbodyLoading(true); - const localBodyList = await dispatchAction( - getLocalbodyByDistrict({ id }) - ); - setIsLocalbodyLoading(false); - if (localBodyList) { - setLocalBodies([...localBodyList.data]); - } + useEffect(() => { + if (newId > 0) { + setIsDistrictLoading(true); + if (districtRes && districtData) { + setDistricts([districtData]); } + setIsDistrictLoading(false); + } + }, [newId, districtData]); + + const { + res: localBodyRes, + data: localBodyData, + refetch: localBodyFetch, + } = useQuery(routes.getLocalbodyByDistrict, { + pathParams: { + id: String(newId), }, - [dispatchAction] - ); + }); + + useEffect(() => { + if (newId > 0) { + setIsLocalbodyLoading(true); + if (localBodyData) { + setLocalBodies([localBodyData]); + } + setIsLocalbodyLoading(false); + } + }, [newId, localBodyRes, localBodyData]); const getSteps = (): Step[] => { return [ @@ -245,90 +244,116 @@ export const FacilityCreate = (props: FacilityProps) => { ]; }; - const fetchWards = useCallback( - async (id: number) => { - if (id > 0) { - setIsWardLoading(true); - const wardList = await dispatchAction(getWardByLocalBody({ id })); - setIsWardLoading(false); - if (wardList) { - setWard([...wardList.data.results]); - } - } + const { + res: wardsRes, + data: wardsData, + refetch: wardsFetch, + } = useQuery(routes.getWardByLocalBody, { + pathParams: { + id: String(newId), }, - [dispatchAction] - ); + }); - const fetchData = useCallback( - async (status: statusType) => { - if (facilityId) { - setIsLoading(true); - const res = await dispatchAction(getPermittedFacility(facilityId)); - if (!status.aborted && res.data) { - const formData = { - facility_type: res.data.facility_type, - name: res.data.name, - state: res.data.state ? res.data.state : 0, - district: res.data.district ? res.data.district : 0, - local_body: res.data.local_body ? res.data.local_body : 0, - features: res.data.features || [], - ward: res.data.ward_object ? res.data.ward_object.id : 0, - kasp_empanelled: res.data.kasp_empanelled - ? String(res.data.kasp_empanelled) - : "false", - address: res.data.address, - pincode: res.data.pincode, - phone_number: - res.data.phone_number.length == 10 - ? "+91" + res.data.phone_number - : res.data.phone_number, - latitude: res.data.latitude || "", - longitude: res.data.longitude || "", - type_b_cylinders: res.data.type_b_cylinders, - type_c_cylinders: res.data.type_c_cylinders, - type_d_cylinders: res.data.type_d_cylinders, - expected_type_b_cylinders: res.data.expected_type_b_cylinders, - expected_type_c_cylinders: res.data.expected_type_c_cylinders, - expected_type_d_cylinders: res.data.expected_type_d_cylinders, - expected_oxygen_requirement: res.data.expected_oxygen_requirement, - oxygen_capacity: res.data.oxygen_capacity, - }; - dispatch({ type: "set_form", form: formData }); - Promise.all([ - fetchDistricts(res.data.state), - fetchLocalBody(res.data.district), - fetchWards(res.data.local_body), - ]); - } else { - navigate(`/facility/${facilityId}`); - } - setIsLoading(false); + useEffect(() => { + if (newId > 0) { + setIsWardLoading(true); + if (wardsData) { + const updatedWards = { + id: wardsData.id, + name: wardsData.name, + number: wardsData.number, + }; + setWard([updatedWards]); } - }, - [dispatchAction, facilityId, fetchDistricts, fetchLocalBody, fetchWards] - ); + setIsWardLoading(false); + } + }, [newId, wardsRes, wardsData]); - const fetchStates = useCallback( - async (status: statusType) => { - setIsStateLoading(true); - const statesRes = await dispatchAction(getStates()); - if (!status.aborted && statesRes.data.results) { - setStates([...statesRes.data.results]); - } - setIsStateLoading(false); + const { + res: facilityRes, + data: facilityData, + refetch: facilityFetch, + } = useQuery(routes.getPermittedFacility, { + pathParams: { + id: facilityId || "", }, - [dispatchAction] - ); + }); - useAbortableEffect( - (status: statusType) => { - if (facilityId) { - fetchData(status); + useEffect(() => { + if (facilityId) { + setIsLoading(true); + if (facilityData) { + const formData = { + facility_type: String(facilityData.facility_type), + name: facilityData.name, + state: facilityData.state ? facilityData.state : 0, + district: facilityData.district ? facilityData.district : 0, + local_body: facilityData.local_body ? facilityData.local_body : 0, + features: facilityData.features || [], + ward: facilityData.ward_object ? facilityData.ward_object.id : 0, + kasp_empanelled: facilityData.kasp_empanelled + ? String(facilityData.kasp_empanelled) + : "false", + address: facilityData.address, + pincode: String(facilityData.pincode), + phone_number: + facilityData.phone_number.length == 10 + ? "+91" + facilityData.phone_number + : facilityData.phone_number, + latitude: facilityData.latitude || "", + longitude: facilityData.longitude || "", + type_b_cylinders: facilityData.type_b_cylinders, + type_c_cylinders: facilityData.type_c_cylinders, + type_d_cylinders: facilityData.type_d_cylinders, + expected_type_b_cylinders: facilityData.expected_type_b_cylinders, + expected_type_c_cylinders: facilityData.expected_type_c_cylinders, + expected_type_d_cylinders: facilityData.expected_type_d_cylinders, + expected_oxygen_requirement: facilityData.expected_oxygen_requirement, + oxygen_capacity: facilityData.oxygen_capacity, + }; + dispatch({ type: "set_form", form: formData }); + Promise.all([ + setNewId(facilityData.state), + districtFetch(), + setNewId(facilityData.district), + localBodyFetch(), + setNewId(facilityData.local_body), + wardsFetch(), + ]); + } else { + navigate(`/facility/${facilityId}`); } - fetchStates(status); - }, - [dispatch, fetchData] - ); + setIsLoading(false); + } + }, [ + facilityId, + facilityRes, + facilityData, + districtFetch, + localBodyFetch, + wardsFetch, + ]); + + const { + res: statesRes, + data: statesData, + refetch: fetchStates, + } = useQuery(routes.statesList, {}); + + useEffect(() => { + setIsStateLoading(true); + if (statesRes && statesData) { + setStates([...statesData.results]); + } + setIsStateLoading(false); + }, [statesRes, statesData]); + + useEffect(() => { + if (facilityId) { + facilityFetch(); + } + fetchStates(); + }, [dispatch, facilityFetch]); const handleChange = (e: FieldChangeEvent) => { dispatch({ @@ -362,13 +387,14 @@ export const FacilityCreate = (props: FacilityProps) => { return includesIgnoreCase(state.name, pincodeDetails.statename); }); if (!matchedState) return; + setNewId(matchedState.id); + if (!districtData) return; - const fetchedDistricts = await fetchDistricts(matchedState.id); - if (!fetchedDistricts) return; - - const matchedDistrict = fetchedDistricts.find((district) => { - return includesIgnoreCase(district.name, pincodeDetails.district); - }); + const matchedDistrict = Object.values(districtData).find( + (district: any) => { + return includesIgnoreCase(district.name, pincodeDetails.district); + } + ); if (!matchedDistrict) return; dispatch({ @@ -376,12 +402,13 @@ export const FacilityCreate = (props: FacilityProps) => { form: { ...state.form, state: matchedState.id, - district: matchedDistrict.id, + district: districtData.id, pincode: e.value, }, }); - fetchLocalBody(matchedDistrict.id); + setNewId(districtData.id); + localBodyFetch(); setShowAutoFilledPincode(true); setTimeout(() => { setShowAutoFilledPincode(false); @@ -479,8 +506,8 @@ export const FacilityCreate = (props: FacilityProps) => { console.log(state.form); if (validated) { setIsLoading(true); - const data = { - facility_type: state.form.facility_type, + const data: IFacilityRequest = { + facility_type: Number(state.form.facility_type) || undefined, name: state.form.name, district: state.form.district, state: state.form.state, @@ -490,8 +517,8 @@ export const FacilityCreate = (props: FacilityProps) => { features: state.form.features, ward: state.form.ward, kasp_empanelled: JSON.parse(state.form.kasp_empanelled), - latitude: state.form.latitude || null, - longitude: state.form.longitude || null, + latitude: state.form.latitude, + longitude: state.form.longitude, phone_number: parsePhoneNumber(state.form.phone_number), oxygen_capacity: state.form.oxygen_capacity ? state.form.oxygen_capacity @@ -520,12 +547,20 @@ export const FacilityCreate = (props: FacilityProps) => { ? state.form.expected_type_d_cylinders : 0, }; - const res = await dispatchAction( - facilityId ? updateFacility(facilityId, data) : createFacility(data) - ); - if (res && (res.status === 200 || res.status === 201) && res.data) { - const id = res.data.id; + const { res, data: requestData } = facilityId + ? await request(routes.updateFacility, { + body: data, + pathParams: { + id: facilityId, + }, + }) + : await request(routes.createFacility, { + body: data, + }); + + if (res && (res.status === 200 || res.status === 201) && requestData) { + const id = requestData.id; dispatch({ type: "set_form", form: initForm }); if (!facilityId) { Notification.Success({ @@ -540,9 +575,9 @@ export const FacilityCreate = (props: FacilityProps) => { navigate(`/facility/${facilityId}`); } } else { - if (res?.data) + if (requestData) Notification.Error({ - msg: "Something went wrong: " + (res.data.detail || ""), + msg: "Something went wrong: ", }); } setIsLoading(false); @@ -603,11 +638,17 @@ export const FacilityCreate = (props: FacilityProps) => { lastUpdated={res.modified_date} removeBedType={removeCurrentBedType} handleUpdate={async () => { - const capacityRes = await dispatchAction( - listCapacity({}, { facilityId: createdFacilityId }) - ); - if (capacityRes && capacityRes.data) { - setCapacityData(capacityRes.data.results); + const { res, data } = await request(routes.getCapacity, { + pathParams: { facilityId: createdFacilityId }, + }); + if (res?.ok && data) { + const convertedResult = data.results.map((result) => { + return { + ...result, + id: Number(result.id), + }; + }); + setCapacityData(convertedResult); } }} /> @@ -640,11 +681,17 @@ export const FacilityCreate = (props: FacilityProps) => { facilityId={createdFacilityId || ""} key={`bed_${data.id}`} handleUpdate={async () => { - const doctorRes = await dispatchAction( - listDoctor({}, { facilityId: createdFacilityId }) - ); - if (doctorRes && doctorRes.data) { - setDoctorData(doctorRes.data.results); + const { res, data } = await request(routes.listDoctor, { + pathParams: { facilityId: createdFacilityId }, + }); + if (res && data) { + const convertedResult = data.results.map((result) => { + return { + ...result, + id: Number(result.id), + }; + }); + setDoctorData(convertedResult); } }} {...data} @@ -686,11 +733,17 @@ export const FacilityCreate = (props: FacilityProps) => { navigate(`/facility/${createdFacilityId}`); }} handleUpdate={async () => { - const doctorRes = await dispatchAction( - listDoctor({}, { facilityId: createdFacilityId }) - ); - if (doctorRes && doctorRes.data) { - setDoctorData(doctorRes.data.results); + const { res, data } = await request(routes.listDoctor, { + pathParams: { facilityId: createdFacilityId }, + }); + if (res && data) { + const convertedResult = data.results.map((result) => { + return { + ...result, + id: Number(result.id), + }; + }); + setDoctorData(convertedResult); } }} /> @@ -721,11 +774,17 @@ export const FacilityCreate = (props: FacilityProps) => { setCurrentStep(3); }} handleUpdate={async () => { - const capacityRes = await dispatchAction( - listCapacity({}, { facilityId: createdFacilityId }) - ); - if (capacityRes && capacityRes.data) { - setCapacityData(capacityRes.data.results); + const { res, data } = await request(routes.getCapacity, { + pathParams: { facilityId: createdFacilityId }, + }); + if (res && data) { + const convertedResult = data.results.map((result) => { + return { + ...result, + id: Number(result.id), + }; + }); + setCapacityData(convertedResult); } }} /> @@ -757,9 +816,12 @@ export const FacilityCreate = (props: FacilityProps) => { handleDraftSelect={(newState: any) => { dispatch({ type: "set_state", state: newState }); Promise.all([ - fetchDistricts(newState.form.state), - fetchLocalBody(newState.form.district), - fetchWards(newState.form.local_body), + setNewId(newState.data.state), + districtFetch(), + setNewId(newState.data.district), + localBodyFetch(), + setNewId(newState.data.local_body), + wardsFetch(), ]); }} formData={state.form} @@ -811,7 +873,8 @@ export const FacilityCreate = (props: FacilityProps) => { onChange={(event) => { handleChange(event); if (!event) return; - fetchDistricts(event.value); + setNewId(event.value); + districtFetch(); }} /> { onChange={(event) => { handleChange(event); if (!event) return; - fetchLocalBody(event.value); + setNewId(event.value); + localBodyFetch(); }} /> { onChange={(event) => { handleChange(event); if (!event) return; - fetchWards(event.value); + setNewId(event.value); + wardsFetch(); }} /> import("../Common/Loading")); @@ -61,7 +55,6 @@ export const getFacilityFeatureIcon = (featureId: number) => { export const FacilityHome = (props: any) => { const { t } = useTranslation(); const { facilityId } = props; - const dispatch: any = useDispatch(); const [facilityData, setFacilityData] = useState({}); const [capacityData, setCapacityData] = useState>([]); const [doctorData, setDoctorData] = useState>([]); @@ -80,32 +73,102 @@ export const FacilityHome = (props: any) => { useMessageListener((data) => console.log(data)); - const fetchData = useCallback( - async (status: statusType) => { + const { + res: permittedFacilityRes, + data: permittedFacilityData, + refetch: permittedFacilityFetch, + } = useQuery(routes.getPermittedFacility, { + pathParams: { + id: facilityId, + }, + }); + + useEffect(() => { + const fetchData = async () => { setIsLoading(true); - const facilityRes = await dispatch(getPermittedFacility(facilityId)); - if (facilityRes) { - const [capacityRes, doctorRes, triageRes] = await Promise.all([ - dispatch(listCapacity({}, { facilityId })), - dispatch(listDoctor({}, { facilityId })), - dispatch(getTriageInfo({ facilityId })), - ]); - if (!status.aborted) { + if (permittedFacilityRes) { + const { res: capacityRes, data: capacityData } = await request( + routes.getCapacity, + { + pathParams: { facilityId: facilityId }, + } + ); + const { res: doctorRes, data: doctorData } = await request( + routes.listDoctor, + { + pathParams: { facilityId: facilityId }, + } + ); + const { res: triageRes, data: triageData } = await request( + routes.getTriage, + { + pathParams: { + facilityId: String(facilityId), + }, + } + ); + + if (permittedFacilityRes) { setIsLoading(false); - if (!facilityRes.data) { + if (!permittedFacilityData) { Notification.Error({ msg: "Something went wrong..!", }); } else { - setFacilityData(facilityRes.data); - if (capacityRes && capacityRes.data) { - setCapacityData(capacityRes.data.results); + const transformedPermittedFacilityData = { + id: Number(permittedFacilityData.id), + name: permittedFacilityData.name, + district: permittedFacilityData.district, + read_cover_image_url: permittedFacilityData.read_cover_image_url, + facility_type: String(permittedFacilityData.facility_type), + address: permittedFacilityData.address, + features: permittedFacilityData.features, + location: { + latitude: Number(permittedFacilityData.latitude), + longitude: Number(permittedFacilityData.longitude), + }, + oxygen_capacity: permittedFacilityData.oxygen_capacity, + phone_number: permittedFacilityData.phone_number, + type_b_cylinders: permittedFacilityData.type_b_cylinders, + type_c_cylinders: permittedFacilityData.type_c_cylinders, + type_d_cylinders: permittedFacilityData.type_d_cylinders, + middleware_address: permittedFacilityData.middleware_address, + expected_type_b_cylinders: + permittedFacilityData.expected_type_b_cylinders, + expected_type_c_cylinders: + permittedFacilityData.expected_type_c_cylinders, + expected_type_d_cylinders: + permittedFacilityData.expected_type_d_cylinders, + expected_oxygen_requirement: + permittedFacilityData.expected_oxygen_requirement, + local_body_object: permittedFacilityData.local_body_object, + district_object: permittedFacilityData.district_object, + state_object: permittedFacilityData.state_object, + ward_object: permittedFacilityData.ward_object, + modified_date: permittedFacilityData.modified_date, + created_date: permittedFacilityData.created_date, + }; + setFacilityData(transformedPermittedFacilityData); + if (capacityRes && capacityData) { + const transformedCapacityData = { + id: Number(capacityData.results[0].id), + room_type: capacityData.results[0].room_type_text, + modified_date: capacityData.results[0].modified_date, + total_capacity: capacityData.results[0].total_capacity, + current_capacity: capacityData.results[0].current_capacity, + }; + setCapacityData([transformedCapacityData]); } - if (doctorRes && doctorRes.data) { - setDoctorData(doctorRes.data.results); + if (doctorRes && doctorData) { + const transformedDoctorData = { + id: Number(doctorData.results[0].id), + area: doctorData.results[0].area, + count: doctorData.results[0].count, + }; + setDoctorData([transformedDoctorData]); // calculating total doctors count let totalCount = 0; - doctorRes.data.results.map((doctor: DoctorModal) => { + [transformedDoctorData].map((doctor: DoctorModal) => { if (doctor.count) { totalCount += doctor.count; } @@ -114,11 +177,26 @@ export const FacilityHome = (props: any) => { } if ( triageRes && - triageRes.data && - triageRes.data.results && - triageRes.data.results.length + triageData && + triageData.results && + triageData.results.length ) { - setPatientStatsData(triageRes.data.results); + const transformedTriageData = { + id: Number(triageData.results[0].id), + entryDate: triageData.results[0].entry_date, + num_patients_visited: + triageData.results[0].num_patients_visited, + num_patients_home_quarantine: + triageData.results[0].num_patients_home_quarantine, + num_patients_isolation: + triageData.results[0].num_patients_isolation, + num_patient_referred: + triageData.results[0].num_patient_referred, + entry_date: Number(triageData.results[0].entry_date), + num_patient_confirmed_positive: + triageData.results[0].num_patient_confirmed_positive, + }; + setPatientStatsData([transformedTriageData]); } } } @@ -126,30 +204,29 @@ export const FacilityHome = (props: any) => { navigate("/not-found"); setIsLoading(false); } - }, - [dispatch, facilityId] - ); + }; + fetchData(); + }, [facilityId, permittedFacilityRes, permittedFacilityData]); - useAbortableEffect( - (status: statusType) => { - fetchData(status); - }, - [dispatch, fetchData] - ); + useEffect(() => { + permittedFacilityFetch(); + }, [permittedFacilityFetch]); const handleDeleteClose = () => { setOpenDeleteDialog(false); }; const handleDeleteSubmit = async () => { - const res = await dispatch(deleteFacility(facilityId)); + const { res, data } = await request(routes.deleteFacility, { + pathParams: { id: facilityId }, + }); if (res?.status === 204) { Notification.Success({ msg: "Facility deleted successfully", }); } else { Notification.Error({ - msg: "Error while deleting Facility: " + (res?.data?.detail || ""), + msg: "Error while deleting Facility: " + (data?.detail || ""), }); } navigate("/facility"); @@ -209,11 +286,17 @@ export const FacilityHome = (props: any) => { lastUpdated={res.modified_date} removeBedType={removeCurrentBedType} handleUpdate={async () => { - const capacityRes = await dispatch( - listCapacity({}, { facilityId }) - ); - if (capacityRes && capacityRes.data) { - setCapacityData(capacityRes.data.results); + const { res, data } = await request(routes.getCapacity, { + pathParams: { facilityId }, + }); + if (res?.ok && data) { + const convertedResult = data.results.map((result) => { + return { + ...result, + id: Number(result.id), + }; + }); + setCapacityData(convertedResult); } }} /> @@ -263,14 +346,20 @@ export const FacilityHome = (props: any) => { facilityId={facilityId} key={`bed_${data.id}`} handleUpdate={async () => { - const doctorRes = await dispatch( - listDoctor({}, { facilityId }) - ); - if (doctorRes && doctorRes.data) { - setDoctorData(doctorRes.data.results); + const { res, data } = await request(routes.listDoctor, { + pathParams: { facilityId: facilityId }, + }); + if (res && data) { + const convertedResult = data.results.map((result) => { + return { + ...result, + id: Number(result.id), + }; + }); + setDoctorData(convertedResult); // update total doctors count let totalCount = 0; - doctorRes.data.results.map((doctor: DoctorModal) => { + convertedResult.map((doctor: DoctorModal) => { if (doctor.count) { totalCount += doctor.count; } @@ -752,11 +841,17 @@ export const FacilityHome = (props: any) => { facilityId={facilityId} handleClose={() => setBedCapacityModalOpen(false)} handleUpdate={async () => { - const capacityRes = await dispatch( - listCapacity({}, { facilityId }) - ); - if (capacityRes && capacityRes.data) { - setCapacityData(capacityRes.data.results); + const { res, data } = await request(routes.getCapacity, { + pathParams: { facilityId }, + }); + if (res && data) { + const convertedResult = data.results.map((result) => { + return { + ...result, + id: Number(result.id), + }; + }); + setCapacityData(convertedResult); } }} /> @@ -773,12 +868,20 @@ export const FacilityHome = (props: any) => { facilityId={facilityId} handleClose={() => setDoctorCapacityModalOpen(false)} handleUpdate={async () => { - const doctorRes = await dispatch(listDoctor({}, { facilityId })); - if (doctorRes && doctorRes.data) { - setDoctorData(doctorRes.data.results); + const { res, data } = await request(routes.listDoctor, { + pathParams: { facilityId: facilityId }, + }); + if (res && data) { + const convertedResult = data.results.map((result) => { + return { + ...result, + id: Number(result.id), + }; + }); + setDoctorData(convertedResult); // update total doctors count setTotalDoctors( - doctorRes.data.results.reduce( + convertedResult.reduce( (acc: number, doctor: DoctorModal) => acc + (doctor.count || 0), 0 diff --git a/src/Components/Facility/FacilityUsers.tsx b/src/Components/Facility/FacilityUsers.tsx index 3008e54f830..46f475c4ff7 100644 --- a/src/Components/Facility/FacilityUsers.tsx +++ b/src/Components/Facility/FacilityUsers.tsx @@ -1,14 +1,4 @@ -import { lazy, useCallback, useEffect, useState } from "react"; -import { useDispatch } from "react-redux"; -import { statusType, useAbortableEffect } from "../../Common/utils"; -import { - addUserFacility, - deleteUserFacility, - getUserListFacility, - deleteUser, - getFacilityUsers, - getAnyFacility, -} from "../../Redux/actions"; +import { lazy, useEffect, useState } from "react"; import Pagination from "../Common/Pagination"; import { USER_TYPES, RESULTS_PER_PAGE_LIMIT } from "../../Common/constants"; import { FacilityModel } from "../Facility/models"; @@ -23,12 +13,14 @@ import CareIcon from "../../CAREUI/icons/CareIcon"; import ButtonV2 from "../Common/components/ButtonV2"; import Page from "../Common/components/Page"; import useAuthUser from "../../Common/hooks/useAuthUser"; +import request from "../../Utils/request/request"; +import routes from "../../Redux/api"; +import useQuery from "../../Utils/request/useQuery"; const Loading = lazy(() => import("../Common/Loading")); export default function FacilityUsers(props: any) { const { facilityId } = props; - const dispatch: any = useDispatch(); const initialData: any[] = []; let manageUsers: any = null; const [users, setUsers] = useState(initialData); @@ -66,11 +58,17 @@ export default function FacilityUsers(props: any) { useEffect(() => { async function fetchFacilityName() { if (facilityId) { - const res = await dispatch(getAnyFacility(facilityId)); - setFacilityData({ - name: res?.data?.name || "", - district_object_id: res?.data?.district_object?.id || 0, + const { res, data } = await request(routes.getAnyFacility, { + pathParams: { + id: facilityId, + }, }); + if (res && data) { + setFacilityData({ + name: data.name || "", + district_object_id: data?.district_object?.id || 0, + }); + } } else { setFacilityData({ name: "", @@ -79,32 +77,25 @@ export default function FacilityUsers(props: any) { } } fetchFacilityName(); - }, [dispatch, facilityId]); + }, [facilityId]); - const fetchData = useCallback( - async (status: statusType) => { - setIsLoading(true); - const res = await dispatch( - getFacilityUsers(facilityId, { offset, limit }) - ); + const { res, data, refetch } = useQuery(routes.getFacilityUsers, { + body: { offset: offset, limit: limit }, + pathParams: { facility_id: facilityId }, + }); - if (!status.aborted) { - if (res && res.data) { - setUsers(res.data.results); - setTotalCount(res.data.count); - } - setIsLoading(false); - } - }, - [dispatch, facilityId, offset, limit] - ); + useEffect(() => { + setIsLoading(true); + if (res && data) { + setUsers(data.results); + setTotalCount(data.count); + } + setIsLoading(false); + }, [facilityId, offset, limit, res, data]); - useAbortableEffect( - (status: statusType) => { - fetchData(status); - }, - [fetchData] - ); + useEffect(() => { + refetch(); + }, [refetch]); const handlePagination = (page: number, limit: number) => { const offset = (page - 1) * limit; @@ -117,13 +108,15 @@ export default function FacilityUsers(props: any) { return; } setIsFacilityLoading(true); - const res = await dispatch(getUserListFacility({ username })); - if (res && res.data) { + const { res, data } = await request(routes.userListFacility, { + pathParams: { username: username }, + }); + if (res && data) { const updated = users.map((user) => { return user.username === username ? { ...user, - facilities: res.data, + facilities: data, } : user; }); @@ -156,12 +149,13 @@ export default function FacilityUsers(props: any) { const handleUnlinkFacilitySubmit = async () => { setIsFacilityLoading(true); - await dispatch( - deleteUserFacility( - unlinkFacilityData.userName, - String(unlinkFacilityData?.facility?.id) - ) - ); + await request(routes.deleteUserFacility, { + // body given in the dispatch call but there is no body in API documentation + body: String(unlinkFacilityData?.facility?.id), + pathParams: { + username: unlinkFacilityData.userName, + }, + }); setIsFacilityLoading(false); loadFacilities(unlinkFacilityData.userName); hideUnlinkFacilityModal(); @@ -173,19 +167,21 @@ export default function FacilityUsers(props: any) { const handleSubmit = async () => { const username = userData.username; - const res = await dispatch(deleteUser(username)); + const { res, data } = await request(routes.deleteUser, { + pathParams: { username: username }, + }); if (res?.status === 204) { Notification.Success({ msg: "User deleted successfully", }); } else { Notification.Error({ - msg: "Error while deleting User: " + (res?.data?.detail || ""), + msg: "Error while deleting User: " + (data?.detail || ""), }); } setUserData({ show: false, username: "", name: "" }); - fetchData({ aborted: false }); + refetch(); }; const handleDelete = (user: any) => { @@ -268,7 +264,15 @@ export default function FacilityUsers(props: any) { const addFacility = async (username: string, facility: any) => { hideLinkFacilityModal(); setIsFacilityLoading(true); - await dispatch(addUserFacility(username, String(facility.id))); + // Remaining props of request are not specified in dispatch request + await request(routes.addUserFacility, { + body: { + username: facility.id, + }, + pathParams: { + username: username, + }, + }); setIsFacilityLoading(false); loadFacilities(username); }; diff --git a/src/Components/Facility/HospitalList.tsx b/src/Components/Facility/HospitalList.tsx index ffdc1f4ed12..b9cadbcfc5f 100644 --- a/src/Components/Facility/HospitalList.tsx +++ b/src/Components/Facility/HospitalList.tsx @@ -3,14 +3,8 @@ import { downloadFacilityCapacity, downloadFacilityDoctors, downloadFacilityTriage, - getDistrict, - getLocalBody, - getPermittedFacilities, - getState, } from "../../Redux/actions"; -import { statusType, useAbortableEffect } from "../../Common/utils"; -import { lazy, useCallback, useState } from "react"; -import { useDispatch } from "react-redux"; +import { lazy, useEffect, useState } from "react"; import { AdvancedFilterButton } from "../../CAREUI/interactive/FiltersSlideover"; import CountBlock from "../../CAREUI/display/Count"; import ExportMenu from "../Common/Export"; @@ -25,6 +19,8 @@ import { navigate } from "raviger"; import useFilters from "../../Common/hooks/useFilters"; import { useTranslation } from "react-i18next"; import useAuthUser from "../../Common/hooks/useAuthUser"; +import useQuery from "../../Utils/request/useQuery"; +import routes from "../../Redux/api"; const Loading = lazy(() => import("../Common/Loading")); @@ -39,7 +35,6 @@ export const HospitalList = () => { } = useFilters({ limit: 14, }); - const dispatchAction: any = useDispatch(); const [data, setData] = useState>([]); let manageFacilities: any = null; const [isLoading, setIsLoading] = useState(false); @@ -50,105 +45,138 @@ export const HospitalList = () => { const { user_type } = useAuthUser(); const { t } = useTranslation(); - const fetchData = useCallback( - async (status: statusType) => { - setIsLoading(true); - const params = { - limit: resultsPerPage, - page: qParams.page || 1, - offset: (qParams.page ? qParams.page - 1 : 0) * resultsPerPage, - search_text: qParams.search || undefined, - state: qParams.state, - district: qParams.district, - local_body: qParams.local_body, - facility_type: qParams.facility_type, - kasp_empanelled: qParams.kasp_empanelled, - }; - - const res = await dispatchAction(getPermittedFacilities(params)); - if (!status.aborted) { - if (res && res.data) { - setData(res.data.results); - setTotalCount(res.data.count); - } - setIsLoading(false); - } + const { + res: permittedDataRes, + data: permittedData, + refetch: permittedFacilitiesFetch, + } = useQuery(routes.getPermittedFacilities, { + body: { + district: qParams.district, + district_name: districtName, + facility_type: qParams.facility_type, + kasp_empanelled: qParams.kasp_empanelled, + limit: resultsPerPage, + local_body: qParams.local_body, + local_body_name: localbodyName, + offset: (qParams.page ? qParams.page - 1 : 0) * resultsPerPage, + search_text: qParams.search || undefined, + state: qParams.state, + state_name: stateName, }, - [ - qParams.page, - qParams.search, - qParams.state, - qParams.district, - qParams.local_body, - qParams.facility_type, - qParams.kasp_empanelled, - dispatchAction, - ] - ); + }); - useAbortableEffect( - (status: statusType) => { - fetchData(status); - }, - [fetchData] - ); + useEffect(() => { + setIsLoading(true); + if (permittedDataRes && permittedData) { + const transformedData = permittedData.results.map((result) => ({ + id: Number(result.id), + name: result.name, + district: result.district, + read_cover_image_url: result.read_cover_image_url, + facility_type: String(result.facility_type), + address: result.address, + features: result.features, + location: { + latitude: Number(result.latitude), + longitude: Number(result.longitude), + }, + oxygen_capacity: result.oxygen_capacity, + phone_number: result.phone_number, + type_b_cylinders: result.type_b_cylinders, + type_c_cylinders: result.type_c_cylinders, + type_d_cylinders: result.type_d_cylinders, + middleware_address: result.middleware_address, + expected_type_b_cylinders: result.expected_type_b_cylinders, + expected_type_c_cylinders: result.expected_type_c_cylinders, + expected_type_d_cylinders: result.expected_type_d_cylinders, + expected_oxygen_requirement: result.expected_oxygen_requirement, + local_body_object: result.local_body_object, + district_object: result.district_object, + state_object: result.state_object, + ward_object: result.ward_object, + modified_date: result.modified_date, + created_date: result.created_date, + })); - const fetchStateName = useCallback( - async (status: statusType) => { - const res = - Number(qParams.state) && - (await dispatchAction(getState(qParams.state))); - if (!status.aborted) { - setStateName(res?.data?.name); - } - }, - [dispatchAction, qParams.state] - ); + setData(transformedData); + setTotalCount(permittedData.count); + } + setIsLoading(false); + }, [ + qParams.page, + qParams.search, + qParams.state, + qParams.district, + qParams.local_body, + qParams.facility_type, + qParams.kasp_empanelled, + permittedDataRes, + permittedData, + ]); - useAbortableEffect( - (status: statusType) => { - fetchStateName(status); - }, - [fetchStateName] - ); + useEffect(() => { + permittedFacilitiesFetch(); + }, [permittedFacilitiesFetch]); - const fetchDistrictName = useCallback( - async (status: statusType) => { - const res = - Number(qParams.district) && - (await dispatchAction(getDistrict(qParams.district))); - if (!status.aborted) { - setDistrictName(res?.data?.name); - } + const { + res: stateNameRes, + data: stateNameData, + refetch: stateNameFetch, + } = useQuery(routes.getState, { + pathParams: { + id: qParams.state, }, - [dispatchAction, qParams.district] - ); + }); - useAbortableEffect( - (status: statusType) => { - fetchDistrictName(status); - }, - [fetchDistrictName] - ); + useEffect(() => { + if (stateNameRes && stateNameData) { + setStateName(stateNameData.name); + } + }, [qParams.state, stateNameRes, stateNameData]); - const fetchLocalbodyName = useCallback( - async (status: statusType) => { - const res = - Number(qParams.local_body) && - (await dispatchAction(getLocalBody({ id: qParams.local_body }))); - if (!status.aborted) { - setLocalbodyName(res?.data?.name); - } + useEffect(() => { + stateNameFetch(); + }, [stateNameFetch]); + + const { + res: DistrictNameRes, + data: DistrictNameData, + refetch: DistrictNameFetch, + } = useQuery(routes.getDistrict, { + pathParams: { + id: qParams.district, }, - [dispatchAction, qParams.local_body] - ); + }); - useAbortableEffect( - (status: statusType) => { - fetchLocalbodyName(status); + useEffect(() => { + if (DistrictNameRes && DistrictNameData) { + setDistrictName(DistrictNameData.name); + } + }, [qParams.district, DistrictNameRes, DistrictNameData]); + + useEffect(() => { + DistrictNameFetch(); + }, [DistrictNameFetch]); + + const { + res: LocalbodyNameRes, + data: LocalbodyNameData, + refetch: LocalbodyNameFetch, + } = useQuery(routes.getLocalBody, { + pathParams: { + id: qParams.local_body, }, - [fetchLocalbodyName] - ); + }); + + useEffect(() => { + if (LocalbodyNameRes && LocalbodyNameData) { + setLocalbodyName(LocalbodyNameData.name); + } + }, [qParams.local_body, LocalbodyNameRes, LocalbodyNameData]); + + useEffect(() => { + LocalbodyNameFetch(); + }, [LocalbodyNameFetch]); const findFacilityTypeById = (id: number) => { const facility_type = FACILITY_TYPES.find((type) => type.id == id); diff --git a/src/Components/Facility/InventoryList.tsx b/src/Components/Facility/InventoryList.tsx index 26f1af87191..2608f1de01e 100644 --- a/src/Components/Facility/InventoryList.tsx +++ b/src/Components/Facility/InventoryList.tsx @@ -1,19 +1,18 @@ -import { useState, useCallback, useEffect, lazy } from "react"; +import { useState, useEffect, lazy } from "react"; import { navigate } from "raviger"; -import { useDispatch } from "react-redux"; -import { statusType, useAbortableEffect } from "../../Common/utils"; -import { getInventorySummary, getAnyFacility } from "../../Redux/actions"; import Pagination from "../Common/Pagination"; import { classNames } from "../../Utils/utils"; import Page from "../Common/components/Page"; import ButtonV2 from "../Common/components/ButtonV2"; import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor"; +import useQuery from "../../Utils/request/useQuery"; +import routes from "../../Redux/api"; +import request from "../../Utils/request/request"; const Loading = lazy(() => import("../Common/Loading")); export default function InventoryList(props: any) { const { facilityId }: any = props; - const dispatchAction: any = useDispatch(); const [isLoading, setIsLoading] = useState(false); const initialInventory: any[] = []; let inventoryItem: any = null; @@ -24,42 +23,44 @@ export default function InventoryList(props: any) { const [facilityName, setFacilityName] = useState(""); const limit = 14; - const fetchData = useCallback( - async (status: statusType) => { - setIsLoading(true); - const res = await dispatchAction( - getInventorySummary(facilityId, { limit, offset }) - ); - if (!status.aborted) { - if (res?.data) { - setInventory(res.data.results); - setTotalCount(res.data.count); - } - setIsLoading(false); - } + const { res, data, refetch } = useQuery(routes.getInventorySummary, { + body: { + limit, + offset, }, - [dispatchAction, offset, facilityId] - ); - - useAbortableEffect( - (status: statusType) => { - fetchData(status); + pathParams: { + id: facilityId, }, - [fetchData] - ); + }); + + useEffect(() => { + setIsLoading(true); + if (data) { + setInventory(data.results); + setTotalCount(data.count); + } + setIsLoading(false); + }, [offset, facilityId, res, data]); + + useEffect(() => { + refetch(); + }, [refetch]); useEffect(() => { async function fetchFacilityName() { if (facilityId) { - const res = await dispatchAction(getAnyFacility(facilityId)); - - setFacilityName(res?.data?.name || ""); + const { res, data } = await request(routes.getAnyFacility, { + pathParams: { + id: facilityId, + }, + }); + if (res && data) setFacilityName(data.name || ""); } else { setFacilityName(""); } } fetchFacilityName(); - }, [dispatchAction, facilityId]); + }, [facilityId]); const handlePagination = (page: number, limit: number) => { const offset = (page - 1) * limit; diff --git a/src/Components/Facility/InventoryLog.tsx b/src/Components/Facility/InventoryLog.tsx index 5518b5e320f..0de667e4373 100644 --- a/src/Components/Facility/InventoryLog.tsx +++ b/src/Components/Facility/InventoryLog.tsx @@ -1,25 +1,19 @@ -import { useState, useCallback, useEffect, lazy } from "react"; +import { useState, useEffect, lazy } from "react"; import * as Notification from "../../Utils/Notifications.js"; -import { useDispatch } from "react-redux"; -import { - getInventoryLog, - flagInventoryItem, - deleteLastInventoryLog, - getAnyFacility, -} from "../../Redux/actions"; -import { statusType, useAbortableEffect } from "../../Common/utils"; import Pagination from "../Common/Pagination"; import { formatDateTime } from "../../Utils/utils"; import Page from "../Common/components/Page.js"; import CareIcon from "../../CAREUI/icons/CareIcon.js"; import ButtonV2 from "../Common/components/ButtonV2.js"; +import useQuery from "../../Utils/request/useQuery.js"; +import routes from "../../Redux/api.js"; +import request from "../../Utils/request/request.js"; const Loading = lazy(() => import("../Common/Loading")); export default function InventoryLog(props: any) { const { facilityId, inventoryId }: any = props; - const dispatchAction: any = useDispatch(); const [isLoading, setIsLoading] = useState(false); const [saving, setSaving] = useState(false); const initialInventory: any[] = []; @@ -34,81 +28,91 @@ export default function InventoryLog(props: any) { const [itemName, setItemName] = useState(" "); const [facilityName, setFacilityName] = useState(""); - const fetchData = useCallback( - async (status: statusType) => { - setIsLoading(true); - const res = await dispatchAction( - getInventoryLog(facilityId, { item, limit, offset }) - ); - if (!status.aborted) { - if (res?.data) { - setInventory(res.data.results); - setCurrentStock(res.data.results[0].current_stock); - setTotalCount(res.data.count); - setItemName(res.data.results[0].item_object.name); - } - setIsLoading(false); - } + const { res, data, refetch } = useQuery(routes.getInventoryLog, { + body: { + item: item, + limit: limit, + name: facilityName, + offset: offset, }, - [dispatchAction, offset, facilityId] - ); + pathParams: { + id: facilityId, + }, + }); + + useEffect(() => { + setIsLoading(true); + if (data) { + setInventory(data.results); + setCurrentStock(data.results[0].current_stock); + setTotalCount(data.count); + setItemName(data.results[0].item_object.name); + } + setIsLoading(false); + }, [offset, facilityId, res, data]); useEffect(() => { async function fetchFacilityName() { if (facilityId) { - const res = await dispatchAction(getAnyFacility(facilityId)); + const { res, data } = await request(routes.getAnyFacility, { + pathParams: { + id: facilityId, + }, + }); - setFacilityName(res?.data?.name || ""); + if (res && data) setFacilityName(data.name || ""); } else { setFacilityName(""); } } fetchFacilityName(); - }, [dispatchAction, facilityId]); + }, [facilityId]); const flagFacility = async (id: string) => { setSaving(true); - const res = await dispatchAction( - flagInventoryItem({ facility_external_id: facilityId, external_id: id }) - ); - + // request body is not given in the dispath call + const { res } = await request(routes.flagInventoryItem, { + body: {}, + pathParams: { + facility_external_id: facilityId, + external_id: id, + }, + }); if (res && res.status === 204) { Notification.Success({ msg: "Updated Successfully", }); - fetchData({ aborted: false }); + refetch(); } setSaving(false); }; const removeLastInventoryLog = async (id: any) => { setSaving(true); - const res = await dispatchAction( - deleteLastInventoryLog({ + // API call not matching with documentation. Extra pathparam given in this file for dispatch call + const { res, data } = await request(routes.deleteLastInventoryLog, { + pathParams: { facility_external_id: facilityId, id: id, - }) - ); + }, + }); if (res?.status === 201) { Notification.Success({ msg: "Last entry deleted Successfully", }); - fetchData({ aborted: false }); + refetch(); } else { Notification.Error({ - msg: "Error while deleting last entry: " + (res?.data?.detail || ""), + msg: "Error while deleting last entry: " + (data?.detail || ""), }); } setSaving(false); }; - useAbortableEffect( - (status: statusType) => { - fetchData(status); - }, - [fetchData] - ); + useEffect(() => { + refetch(); + }, [refetch]); const handlePagination = (page: number, limit: number) => { const offset = (page - 1) * limit; setCurrentPage(page); diff --git a/src/Components/Facility/LegacyFacilityCNS.tsx b/src/Components/Facility/LegacyFacilityCNS.tsx index b3a933b9a9f..ebd68e5e670 100644 --- a/src/Components/Facility/LegacyFacilityCNS.tsx +++ b/src/Components/Facility/LegacyFacilityCNS.tsx @@ -1,12 +1,6 @@ import { navigate } from "raviger"; import { useEffect, useState } from "react"; -import { useDispatch } from "react-redux"; import CareIcon from "../../CAREUI/icons/CareIcon"; -import { - getAllPatient, - getPermittedFacility, - listAssetBeds, -} from "../../Redux/actions"; import { classNames } from "../../Utils/utils"; import { AssetData, AssetLocationObject } from "../Assets/AssetTypes"; import ButtonV2, { Cancel, Submit } from "../Common/components/ButtonV2"; @@ -19,6 +13,8 @@ import AutocompleteFormField from "../Form/FormFields/Autocomplete"; import { uniqBy } from "lodash"; import DialogModal from "../Common/Dialog"; import { LegacyMonitorCard } from "./LegacyMonitorCard"; +import request from "../../Utils/request/request"; +import routes from "../../Redux/api"; interface Monitor { patient: PatientModel; @@ -34,7 +30,6 @@ export default function LegacyFacilityCNS({ }: { facilityId: string; }) { - const dispatch = useDispatch(); const [isFullscreen, setIsFullscreen] = useState(false); const [monitors, setMonitors] = useState(); const [facility, setFacility] = useState(); @@ -61,25 +56,76 @@ export default function LegacyFacilityCNS({ useEffect(() => { async function fetchFacility() { - const res = await dispatch(getPermittedFacility(facilityId || "")); - if (res.status === 200) setFacility(res.data); + const { res, data } = await request(routes.getPermittedFacility, { + pathParams: { facilityId }, + }); + if (res?.status === 200 && data) { + const updateData = { + id: Number(data.id), + name: data.name, + district: data.district_object.id, + read_cover_image_url: data.read_cover_image_url, + facility_type: data.facility_type.toString(), + address: data.address, + features: data.features, + location: { + latitude: Number(data.latitude), + longitude: Number(data.longitude), + }, + oxygen_capacity: data.oxygen_capacity, + phone_number: data.phone_number, + type_b_cylinders: data.type_b_cylinders, + type_c_cylinders: data.type_c_cylinders, + type_d_cylinders: data.type_d_cylinders, + middleware_address: data.middleware_address, + expected_type_b_cylinders: data.expected_type_b_cylinders, + expected_type_c_cylinders: data.expected_type_c_cylinders, + expected_type_d_cylinders: data.expected_type_d_cylinders, + expected_oxygen_requirement: data.expected_oxygen_requirement, + local_body_object: { + name: data.local_body_object.name, + body_type: data.local_body_object.body_type, + localbody_code: data.local_body_object.localbody_code, + district: data.local_body_object.district, + }, + district_object: { + id: data.district_object.id, + name: data.district_object.name, + state: data.district_object.state, + }, + state_object: { + id: data.state_object.id, + name: data.state_object.name, + }, + ward_object: { + id: data.ward_object.id, + name: data.ward_object.name, + number: data.ward_object.number, + local_body: data.ward_object.local_body, + }, + modified_date: data.modified_date, + created_date: data.created_date, + }; + + setFacility(updateData); + } } fetchFacility(); - }, [facilityId, dispatch]); + }, [facilityId]); useEffect(() => { if (!facility) return; const middlewareHostname = facility.middleware_address; async function fetchPatients() { - const res = await dispatch( - getAllPatient( - { facility: facilityId, is_active: "True" }, - "cns-patient-list" - ) - ); - if (res.status === 200) { - const patients = res.data.results as PatientModel[]; + const { res, data } = await request(routes.patientList, { + body: { + facility: facilityId, + is_active: true, + }, + }); + if (res && res.status === 200) { + const patients = data.results as PatientModel[]; return patients.filter( (patient) => !!patient.last_consultation?.current_bed?.bed_object.id ); @@ -87,27 +133,25 @@ export default function LegacyFacilityCNS({ } async function fetchPatientMonitorAsset(patient: PatientModel) { - const res = await dispatch( - listAssetBeds( - { - bed: patient.last_consultation?.current_bed?.bed_object?.id, - }, - `asset-bed-${patient.id}` - ) - ); + // Request body in API documentation is not matching with request body of dispatch call + const { res, data } = await request(routes.listAssetBeds, { + body: `asset-bed-${patient.id}`, + pathParams: { + bed: patient.last_consultation?.current_bed?.bed_object?.id || "", + }, + }); + if (res?.status === 200 && data) { + const asset = data.results.find( + (assetBed: any) => + assetBed.asset_object.meta?.asset_type === "HL7MONITOR" + )?.asset_object as AssetData | undefined; - if (res.status !== 200) return; + if (!asset) return; - const asset = res.data.results.find( - (assetBed: any) => - assetBed.asset_object.meta?.asset_type === "HL7MONITOR" - )?.asset_object as AssetData | undefined; + const socketUrl = `wss://${middlewareHostname}/observations/${asset.meta?.local_ip_address}`; - if (!asset) return; - - const socketUrl = `wss://${middlewareHostname}/observations/${asset.meta?.local_ip_address}`; - - return { patient, asset, socketUrl } as Monitor; + return { patient, asset, socketUrl } as Monitor; + } } async function fetchMonitors() { @@ -130,7 +174,7 @@ export default function LegacyFacilityCNS({ }, CNS_REFRESH_INTERVAL); return () => clearInterval(interval); - }, [dispatch, facility, facilityId]); + }, [facility, facilityId]); if (!monitors) return ; return ( diff --git a/src/Components/Facility/MinQuantityList.tsx b/src/Components/Facility/MinQuantityList.tsx index 631f432a9dc..d091343e041 100644 --- a/src/Components/Facility/MinQuantityList.tsx +++ b/src/Components/Facility/MinQuantityList.tsx @@ -1,18 +1,16 @@ -import { useCallback, useState, useEffect, lazy } from "react"; -import { useDispatch } from "react-redux"; - -import { statusType, useAbortableEffect } from "../../Common/utils"; -import { getMinQuantity, getAnyFacility } from "../../Redux/actions"; +import { useState, useEffect, lazy } from "react"; import Pagination from "../Common/Pagination"; import { MinQuantityRequiredModal } from "./MinQuantityRequiredModal"; import ButtonV2 from "../Common/components/ButtonV2"; import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor"; import Page from "../Common/components/Page"; +import request from "../../Utils/request/request"; +import routes from "../../Redux/api"; +import useQuery from "../../Utils/request/useQuery"; const Loading = lazy(() => import("../Common/Loading")); export default function MinQuantityList(props: any) { const { facilityId }: any = props; - const dispatchAction: any = useDispatch(); const [isLoading, setIsLoading] = useState(false); const initialInventory: any[] = []; let inventoryItem: any = null; @@ -26,42 +24,44 @@ export default function MinQuantityList(props: any) { const [selectedItem, setSelectedItem] = useState({ id: 0, item_id: 0 }); const limit = 14; - const fetchData = useCallback( - async (status: statusType) => { - setIsLoading(true); - const res = await dispatchAction( - getMinQuantity(facilityId, { limit, offset }) - ); - if (!status.aborted) { - if (res && res.data) { - setInventory(res.data.results); - setTotalCount(res.data.count); - } - setIsLoading(false); - } + const { res, data, refetch } = useQuery(routes.getMinQuantity, { + body: { + limit: limit, + offset: offset, }, - [dispatchAction, offset, facilityId] - ); - - useAbortableEffect( - (status: statusType) => { - fetchData(status); + pathParams: { + id: facilityId, }, - [fetchData] - ); + }); + + useEffect(() => { + setIsLoading(true); + if (res && data) { + setInventory(data.results); + setTotalCount(data.count); + } + setIsLoading(false); + }, [offset, facilityId, res, data]); + + useEffect(() => { + refetch(); + }, [refetch]); useEffect(() => { async function fetchFacilityName() { if (facilityId) { - const res = await dispatchAction(getAnyFacility(facilityId)); - - setFacilityName(res?.data?.name || ""); + const { res, data } = await request(routes.getAnyFacility, { + pathParams: { + id: facilityId, + }, + }); + if (res && data) setFacilityName(data.name || ""); } else { setFacilityName(""); } } fetchFacilityName(); - }, [dispatchAction, facilityId]); + }, [facilityId]); const handlePagination = (page: number, limit: number) => { const offset = (page - 1) * limit; @@ -236,7 +236,7 @@ export default function MinQuantityList(props: any) { show={showMinQuantityRequiredModal} handleClose={() => setShowMinQuantityRequiredModal(false)} handleUpdate={() => { - fetchData({ aborted: false }); + refetch(); setShowMinQuantityRequiredModal(false); }} /> diff --git a/src/Components/Facility/MinQuantityRequiredModal.tsx b/src/Components/Facility/MinQuantityRequiredModal.tsx index d076b65f076..b70b873a6d8 100644 --- a/src/Components/Facility/MinQuantityRequiredModal.tsx +++ b/src/Components/Facility/MinQuantityRequiredModal.tsx @@ -1,15 +1,11 @@ -import { useCallback, useReducer, useState } from "react"; -import { useDispatch } from "react-redux"; -import { statusType, useAbortableEffect } from "../../Common/utils"; -import { - updateMinQuantity, - getAnyFacility, - getMinQuantityOfItem, -} from "../../Redux/actions"; +import { useEffect, useReducer, useState } from "react"; import * as Notification from "../../Utils/Notifications.js"; import ButtonV2 from "../Common/components/ButtonV2"; import DialogModal from "../Common/Dialog"; import TextFormField from "../Form/FormFields/TextFormField"; +import request from "../../Utils/request/request"; +import routes from "../../Redux/api"; +import useQuery from "../../Utils/request/useQuery"; const initForm = { id: "", @@ -42,56 +38,66 @@ export const MinQuantityRequiredModal = (props: any) => { const [state, dispatch] = useReducer(inventoryFormReducer, initialState); const { facilityId, inventoryId, itemId, show, handleClose, handleUpdate } = props; - const dispatchAction: any = useDispatch(); const [isLoading, setIsLoading] = useState(false); const [data, setData] = useState(" "); const [facilityName, setFacilityName] = useState(""); - const fetchData = useCallback( - async (status: statusType) => { + const { + res: minQuantityRes, + data: minQuantityData, + refetch: minQuantityFetch, + } = useQuery(routes.getMinQuantityOfItem, { + pathParams: { + id: facilityId, + external_id: inventoryId, + }, + }); + + useEffect(() => { + const fetchData = async () => { setIsLoading(true); - const res = await dispatchAction( - getMinQuantityOfItem(facilityId, inventoryId) - ); - if (!status.aborted) { - if (res && res.data) { - setData(res.data.item_object.name); - const form = { ...state.form, quantity: res.data.min_quantity }; - dispatch({ type: "set_form", form }); - } - if (facilityId) { - const res = await dispatchAction(getAnyFacility(facilityId)); + if (minQuantityRes && minQuantityData) { + setData(minQuantityData.item_object.name); + const form = { ...state.form, quantity: minQuantityData.min_quantity }; + dispatch({ type: "set_form", form }); + } + if (facilityId) { + const { res, data } = await request(routes.getAnyFacility, { + pathParams: { + id: facilityId, + }, + }); + if (res && data) setFacilityName(data.name || ""); + } else { + setFacilityName(""); + } - setFacilityName(res?.data?.name || ""); - } else { - setFacilityName(""); - } + setIsLoading(false); + }; - setIsLoading(false); - } - }, - [dispatchAction, facilityId, inventoryId] - ); - useAbortableEffect( - (status: statusType) => { - fetchData(status); - }, - [fetchData] - ); + fetchData(); + }, [facilityId, inventoryId, minQuantityData, minQuantityRes, state.form]); + + useEffect(() => { + minQuantityFetch(); + }, [minQuantityFetch]); const handleSubmit = async (e: any) => { e.preventDefault(); setIsLoading(true); - const data: any = { - min_quantity: Number(state.form.quantity), - item: Number(itemId), - }; - const res = await dispatchAction( - updateMinQuantity(data, { facilityId, inventoryId }) - ); + const { res, data } = await request(routes.updateMinQuantity, { + body: { + min_quantity: Number(state.form.quantity), + item: Number(itemId), + }, + pathParams: { + facilityId: facilityId, + inventoryId: inventoryId, + }, + }); setIsLoading(false); - if (res && res.data) { + if (res && data) { Notification.Success({ msg: "Minimum quantity updated successfully", }); diff --git a/src/Components/Facility/SetInventoryForm.tsx b/src/Components/Facility/SetInventoryForm.tsx index d0a275e41ba..289a574aa92 100644 --- a/src/Components/Facility/SetInventoryForm.tsx +++ b/src/Components/Facility/SetInventoryForm.tsx @@ -1,13 +1,4 @@ -import { useCallback, useReducer, useState, useEffect, lazy } from "react"; -import { useDispatch } from "react-redux"; - -import { statusType, useAbortableEffect } from "../../Common/utils"; -import { - getItems, - setMinQuantity, - getAnyFacility, - getMinQuantity, -} from "../../Redux/actions"; +import { useReducer, useState, useEffect, lazy } from "react"; import * as Notification from "../../Utils/Notifications.js"; import { InventoryItemsModel } from "./models"; import { Cancel, Submit } from "../Common/components/ButtonV2"; @@ -17,6 +8,9 @@ import Card from "../../CAREUI/display/Card"; import { FieldChangeEvent } from "../Form/FormFields/Utils"; import { SelectFormField } from "../Form/FormFields/SelectFormField"; import TextFormField from "../Form/FormFields/TextFormField"; +import request from "../../Utils/request/request"; +import routes from "../../Redux/api"; +import useQuery from "../../Utils/request/useQuery"; const Loading = lazy(() => import("../Common/Loading")); const initForm = { @@ -50,7 +44,6 @@ export const SetInventoryForm = (props: any) => { const { goBack } = useAppHistory(); const [state, dispatch] = useReducer(inventoryFormReducer, initialState); const { facilityId } = props; - const dispatchAction: any = useDispatch(); const [isLoading, setIsLoading] = useState(false); const [data, setData] = useState>([]); const [currentUnit, setCurrentUnit] = useState(); @@ -59,56 +52,78 @@ export const SetInventoryForm = (props: any) => { const limit = 14; const offset = 0; - const fetchData = useCallback( - async (status: statusType) => { - setIsLoading(true); + const { + res: minQuantityRes, + data: minQuantityData, + refetch: minQuantityFetch, + } = useQuery(routes.getMinQuantity, { + body: {}, + pathParams: { + id: facilityId, + }, + }); + useEffect(() => { + const fetchData = async () => { + setIsLoading(true); const existingItemIDs: number[] = []; - const resMinQuantity = await dispatchAction( - getMinQuantity(facilityId, {}) - ); - - resMinQuantity.data.results.map((item: any) => - existingItemIDs.push(item.item_object.id) - ); - - const res = await dispatchAction(getItems({ limit, offset })); - - if (!status.aborted) { - if (res && res.data) { - const filteredData = res.data.results.filter( - (item: any) => !existingItemIDs.includes(item.id) - ); - setData(filteredData); - dispatch({ - type: "set_form", - form: { ...state.form, id: filteredData[0]?.id }, - }); - } - setIsLoading(false); + if (minQuantityRes && minQuantityData) { + minQuantityData.results.map((item: any) => + existingItemIDs.push(item.item_object.id) + ); } - }, - [dispatchAction] - ); - useAbortableEffect( - (status: statusType) => { - fetchData(status); - }, - [fetchData] - ); + const { res, data } = await request(routes.getItems, { + body: { + limit: limit, + offset: offset, + }, + }); + if (res && data) { + const filteredData = data.results.filter( + (item: any) => !existingItemIDs.includes(item.id) + ); + const transformedData = filteredData.map((item) => { + const allowedUnits = item.allowed_units || []; + return { + id: item.id, + name: item.name, + default_unit: item.default_unit, + allowedUnits, + }; + }); + + setData(transformedData); + + dispatch({ + type: "set_form", + form: { ...state.form, id: filteredData[0]?.id }, + }); + } + setIsLoading(false); + }; + + fetchData(); + }, [minQuantityData, minQuantityRes, state.form]); + + useEffect(() => { + minQuantityFetch(); + }, [minQuantityFetch]); useEffect(() => { async function fetchFacilityName() { if (facilityId) { - const res = await dispatchAction(getAnyFacility(facilityId)); - - setFacilityName(res?.data?.name || ""); + const { res, data } = await request(routes.getAnyFacility, { + pathParams: { + id: facilityId, + }, + }); + if (res && data) setFacilityName(data.name || ""); } else { setFacilityName(""); } } fetchFacilityName(); - }, [dispatchAction, facilityId]); + }, [facilityId]); useEffect(() => { // set the default units according to the item @@ -125,14 +140,17 @@ export const SetInventoryForm = (props: any) => { const handleSubmit = async (e: any) => { e.preventDefault(); setIsLoading(true); - const data: any = { - min_quantity: Number(state.form.quantity), - item: Number(state.form.id), - }; - - const res = await dispatchAction(setMinQuantity(data, { facilityId })); + const { res, data } = await request(routes.setMinQuantity, { + body: { + min_quantity: Number(state.form.quantity), + item: Number(state.form.id), + }, + pathParams: { + facilityId: facilityId, + }, + }); setIsLoading(false); - if (res && res.data && res.data.id) { + if (res && data && data.id) { Notification.Success({ msg: "Minimum quantiy updated successfully", }); diff --git a/src/Components/Facility/TransferPatientDialog.tsx b/src/Components/Facility/TransferPatientDialog.tsx index 632765c2492..993c2ee3a6a 100644 --- a/src/Components/Facility/TransferPatientDialog.tsx +++ b/src/Components/Facility/TransferPatientDialog.tsx @@ -9,10 +9,10 @@ import { FieldLabel } from "../Form/FormFields/FormField"; import { OptionsType } from "../../Common/constants"; import { SelectFormField } from "../Form/FormFields/SelectFormField"; import { navigate } from "raviger"; -import { transferPatient } from "../../Redux/actions"; -import { useDispatch } from "react-redux"; import { dateQueryString } from "../../Utils/utils.js"; import dayjs from "dayjs"; +import request from "../../Utils/request/request.js"; +import routes from "../../Redux/api.js"; interface Props { patientList: Array; @@ -60,7 +60,6 @@ const patientFormReducer = (state = initialState, action: any) => { const TransferPatientDialog = (props: Props) => { const { patientList, handleOk, handleCancel, facilityId } = props; - const dispatchAction: any = useDispatch(); const [isLoading, setIsLoading] = useState(false); const [state, dispatch] = useReducer(patientFormReducer, initialState); const patientOptions: Array = patientList.map((patient) => { @@ -114,25 +113,27 @@ const TransferPatientDialog = (props: Props) => { const validForm = validateForm(); if (validForm) { setIsLoading(true); - const data = { - date_of_birth: dateQueryString(state.form.date_of_birth), - facility: facilityId, - }; - const res = await dispatchAction( - transferPatient(data, { id: state.form.patient }) - ); + const { res, data } = await request(routes.transferPatient, { + body: { + date_of_birth: dateQueryString(state.form.date_of_birth), + facility: facilityId, + }, + pathParams: { + id: state.form.patient, + }, + }); setIsLoading(false); - if (res && res.data && res.status === 200) { + if (res && data && res.status === 200) { dispatch({ type: "set_form", form: initForm }); handleOk(); Notification.Success({ - msg: `Patient ${res.data.patient} transferred successfully`, + msg: `Patient ${data.patient} transferred successfully`, }); const newFacilityId = - res.data && res.data.facility_object && res.data.facility_object.id; + data && data.facility_object && data.facility_object.id; if (newFacilityId) { navigate( - `/facility/${newFacilityId}/patient/${res.data.patient}/consultation` + `/facility/${newFacilityId}/patient/${data.patient}/consultation` ); } else { navigate("/facility"); diff --git a/src/Components/Facility/TreatmentSummary.tsx b/src/Components/Facility/TreatmentSummary.tsx index 3fbd80ac8b2..b70a65b2e60 100644 --- a/src/Components/Facility/TreatmentSummary.tsx +++ b/src/Components/Facility/TreatmentSummary.tsx @@ -1,22 +1,16 @@ -import { lazy, useCallback, useState } from "react"; -import { useDispatch } from "react-redux"; -import { - getPatient, - getInvestigation, - getConsultation, -} from "../../Redux/actions"; +import { lazy, useEffect, useState } from "react"; import { ConsultationModel } from "./models"; -import { statusType, useAbortableEffect } from "../../Common/utils"; import { PatientModel } from "../Patient/models"; import { GENDER_TYPES } from "../../Common/constants"; import { formatAge, formatDate, formatDateTime } from "../../Utils/utils"; +import routes from "../../Redux/api"; +import useQuery from "../../Utils/request/useQuery"; const Loading = lazy(() => import("../Common/Loading")); const TreatmentSummary = (props: any) => { const { consultationId, patientId } = props; const date = new Date(); - const dispatch: any = useDispatch(); const [patientData, setPatientData] = useState({}); const [consultationData, setConsultationData] = useState( {} @@ -25,70 +19,79 @@ const TreatmentSummary = (props: any) => { const [investigations, setInvestigations] = useState>([]); const [dailyRounds, setDailyRounds] = useState({}); - const fetchPatientData = useCallback( - async (status: statusType) => { - setIsLoading(true); - const res = await dispatch(getPatient({ id: patientId })); - if (!status.aborted) { - if (res?.data) { - setPatientData(res.data); - } else { - setPatientData({}); - } - } - setIsLoading(false); + const { + res: patientRes, + data: patientResData, + refetch: patientFetch, + } = useQuery(routes.getPatient, { + pathParams: { + id: patientId, }, - [patientId, dispatch] - ); + }); - const fetchInvestigationData = useCallback( - async (status: statusType) => { - setIsLoading(true); - const res = await dispatch(getInvestigation({}, consultationId)); + useEffect(() => { + setIsLoading(true); + if (patientRes && patientResData) { + setPatientData(patientResData); + } else { + setPatientData({}); + } + setIsLoading(false); + }, [patientId, patientRes, patientResData]); - if (!status.aborted) { - if (res?.data?.results) { - const valueMap = res.data.results.reduce( - (acc: any, cur: { id: any }) => ({ ...acc, [cur.id]: cur }), - {} - ); - setInvestigations(valueMap); - } else { - setInvestigations([]); - } - } - setIsLoading(false); + const { + res: investigationRes, + data: investigationData, + refetch: investigationFetch, + } = useQuery(routes.getInvestigation, { + body: {}, + pathParams: { + consultation_external_id: consultationId, }, - [consultationId, dispatch] - ); + }); - const fetchConsultation = useCallback( - async (status: statusType) => { - setIsLoading(true); - const [res] = await Promise.all([ - dispatch(getConsultation(consultationId)), - ]); - if (!status.aborted) { - if (res?.data) { - setConsultationData(res.data); - if (res.data.last_daily_round) { - setDailyRounds(res.data.last_daily_round); - } - } else { - setConsultationData({}); - } - } - setIsLoading(false); + useEffect(() => { + setIsLoading(true); + if (investigationRes && investigationData?.results) { + const valueMap = investigationData.results.reduce( + (acc: any, cur: { id: any }) => ({ ...acc, [cur.id]: cur }), + {} + ); + setInvestigations(valueMap); + } else { + setInvestigations([]); + } + setIsLoading(false); + }, [consultationId, investigationRes, investigationData]); + + const { + res: consultationRes, + data: consultationfetchData, + refetch: consultationFetch, + } = useQuery(routes.getConsultation, { + pathParams: { + id: consultationId, }, - [consultationId, dispatch] - ); + }); - useAbortableEffect((status: statusType) => { - fetchPatientData(status); - fetchInvestigationData(status); + useEffect(() => { + setIsLoading(true); + if (consultationRes && consultationfetchData) { + setConsultationData(consultationfetchData); + if (consultationfetchData.last_daily_round) { + setDailyRounds(consultationfetchData.last_daily_round); // add last_daily_rounds in model(not specified in documentation) + } + } else { + setConsultationData({}); + } + setIsLoading(false); + }, [consultationId, consultationRes, consultationfetchData]); - fetchConsultation(status); - }, []); + useEffect(() => { + patientFetch(); + investigationFetch(); + consultationFetch(); + }, [patientFetch, investigationFetch, consultationFetch]); return (
diff --git a/src/Components/Facility/TriageForm.tsx b/src/Components/Facility/TriageForm.tsx index 3c8e6b1497b..7dda4039a28 100644 --- a/src/Components/Facility/TriageForm.tsx +++ b/src/Components/Facility/TriageForm.tsx @@ -1,16 +1,7 @@ import ConfirmDialog from "../Common/ConfirmDialog"; import Card from "../../CAREUI/display/Card"; - import CareIcon from "../../CAREUI/icons/CareIcon"; -import { useCallback, useReducer, useState, useEffect, lazy } from "react"; -import { useDispatch } from "react-redux"; -import { statusType, useAbortableEffect } from "../../Common/utils"; -import { - createTriageForm, - getTriageDetails, - getAnyFacility, - getTriageInfo, -} from "../../Redux/actions"; +import { useReducer, useState, useEffect, lazy } from "react"; import * as Notification from "../../Utils/Notifications.js"; import TextFormField from "../Form/FormFields/TextFormField"; import { PatientStatsModel } from "./models"; @@ -22,6 +13,9 @@ const Loading = lazy(() => import("../Common/Loading")); import Page from "../Common/components/Page"; import dayjs from "dayjs"; import { dateQueryString } from "../../Utils/utils"; +import useQuery from "../../Utils/request/useQuery"; +import routes from "../../Redux/api"; +import request from "../../Utils/request/request"; interface triageFormProps extends PatientStatsModel { facilityId: number; @@ -63,8 +57,6 @@ const triageFormReducer = (state = initialState, action: any) => { export const TriageForm = (props: triageFormProps) => { const { goBack } = useAppHistory(); - const dispatchTriageData: any = useDispatch(); - const dispatchAction: any = useDispatch(); const { facilityId, id } = props; const [state, dispatch] = useReducer(triageFormReducer, initialState); const [isLoading, setIsLoading] = useState(false); @@ -77,83 +69,100 @@ export const TriageForm = (props: triageFormProps) => { const headerText = !id ? "Add Triage" : "Edit Triage"; const buttonText = !id ? "Save Triage" : "Update Triage"; - const fetchData = useCallback( - async (status: statusType) => { - setIsLoading(true); - if (id) { - // Edit Form functionality - const res = await dispatchAction( - getTriageDetails({ facilityId: facilityId, id: id }) - ); - if (!status.aborted && res && res.data) { - dispatch({ - type: "set_form", - form: { - entry_date: res.data.entry_date - ? dayjs(res.data.entry_date).toDate() - : null, - num_patients_visited: res.data.num_patients_visited, - num_patients_home_quarantine: - res.data.num_patients_home_quarantine, - num_patients_isolation: res.data.num_patients_isolation, - num_patient_referred: res.data.num_patient_referred, - num_patient_confirmed_positive: - res.data.num_patient_confirmed_positive, - }, - }); - } - } - setIsLoading(false); + const { + res: dataRes, + data: dataFetch, + refetch: fetchData, + } = useQuery(routes.getTriageDetails, { + pathParams: { + facilityId: String(facilityId), + id: String(id), }, - [dispatchAction, facilityId, id] - ); + }); + + useEffect(() => { + setIsLoading(true); + if (id && dataFetch) { + // Edit Form functionality + dispatch({ + type: "set_form", + form: { + entry_date: dataFetch.entry_date + ? dayjs(dataFetch.entry_date).toDate() + : null, + num_patients_visited: dataFetch.num_patients_visited, + num_patients_home_quarantine: dataFetch.num_patients_home_quarantine, + num_patients_isolation: dataFetch.num_patients_isolation, + num_patient_referred: dataFetch.num_patient_referred, + num_patient_confirmed_positive: + dataFetch.num_patient_confirmed_positive, + }, + }); + } + setIsLoading(false); + }, [facilityId, id, dataFetch, dataRes]); - useAbortableEffect( - (status: statusType) => { - fetchData(status); + useEffect(() => { + fetchData(); + }, [fetchData, id]); + + const { + res: triageRes, + data: triageData, + refetch: triageFetch, + } = useQuery(routes.getTriage, { + pathParams: { + facilityId: String(facilityId), }, - [dispatch, fetchData, id] - ); + }); // this will fetch all triage data of the facility - const fetchTriageData = useCallback( - async (status: statusType) => { - const [triageRes] = await Promise.all([ - dispatchTriageData(getTriageInfo({ facilityId })), - ]); - if (!status.aborted) { - if ( - triageRes && - triageRes.data && - triageRes.data.results && - triageRes.data.results.length - ) { - setPatientStatsData(triageRes.data.results); - } - } - }, - [dispatchTriageData, facilityId] - ); + useEffect(() => { + if ( + triageRes && + triageData && + triageData.results && + triageData.results.length > 0 + ) { + const firstResult = triageData.results[0]; + const updatedDataArray: PatientStatsModel[] = [ + { + id: Number(firstResult.id), + entryDate: firstResult.entry_date.toString(), + num_patients_visited: firstResult.num_patients_visited, + num_patients_home_quarantine: + firstResult.num_patients_home_quarantine, + num_patients_isolation: firstResult.num_patients_isolation, + num_patient_referred: firstResult.num_patient_referred, + entry_date: Number(firstResult.entry_date), + num_patient_confirmed_positive: + firstResult.num_patient_confirmed_positive, + }, + ]; - useAbortableEffect( - (status: statusType) => { - fetchTriageData(status); - }, - [dispatch, fetchTriageData] - ); + setPatientStatsData(updatedDataArray); + } + }, [facilityId, triageData, triageRes]); + + useEffect(() => { + triageFetch(); + }, [triageFetch]); useEffect(() => { async function fetchFacilityName() { if (facilityId) { - const res = await dispatchAction(getAnyFacility(facilityId)); - - setFacilityName(res?.data?.name || ""); + const { res, data } = await request(routes.getAnyFacility, { + pathParams: { + id: String(facilityId), + }, + }); + if (res && data) setFacilityName(data.name || ""); } else { setFacilityName(""); } } fetchFacilityName(); - }, [dispatchAction, facilityId]); + }, [facilityId]); const validateForm = () => { const errors = { ...initForm }; @@ -192,7 +201,7 @@ export const TriageForm = (props: triageFormProps) => { setOpenModalForExistingTriage(false); const validForm = validateForm(); if (validForm) { - const data = { + const requestData = { entry_date: dateQueryString(state.form.entry_date), num_patients_visited: Number(state.form.num_patients_visited), num_patients_home_quarantine: Number( @@ -206,17 +215,20 @@ export const TriageForm = (props: triageFormProps) => { }; //proceed if the triage does not exist or proceed has allowed to proceed after seeing the modal or it's a edit feature of the same date if ( - !isTriageExist(data) || + !isTriageExist(requestData) || openModalForExistingTriage || buttonText === "Update Triage" ) { setOpenModalForExistingTriage(false); setIsLoading(true); - const res = await dispatchAction( - createTriageForm(data, { facilityId }) - ); + const { res, data } = await request(routes.createTriage, { + body: requestData, + pathParams: { + facilityId: String(facilityId), + }, + }); setIsLoading(false); - if (res && res.data) { + if (res && data) { dispatch({ type: "set_form", form: initForm }); if (id) { Notification.Success({ diff --git a/src/Components/Facility/UpdateFacilityMiddleware.tsx b/src/Components/Facility/UpdateFacilityMiddleware.tsx index 211d8cf458a..85f5719125a 100644 --- a/src/Components/Facility/UpdateFacilityMiddleware.tsx +++ b/src/Components/Facility/UpdateFacilityMiddleware.tsx @@ -1,17 +1,13 @@ -import { lazy, useCallback, useReducer, useState } from "react"; -import { useDispatch } from "react-redux"; - -import { statusType, useAbortableEffect } from "../../Common/utils"; -import { - getPermittedFacility, - partialUpdateFacility, -} from "../../Redux/actions"; +import { lazy, useEffect, useReducer, useState } from "react"; import * as Notification from "../../Utils/Notifications.js"; import { navigate } from "raviger"; import { Cancel, Submit } from "../Common/components/ButtonV2"; import TextFormField from "../Form/FormFields/TextFormField"; import Page from "../Common/components/Page"; import { ConfigureHealthFacility } from "../ABDM/ConfigureHealthFacility"; +import useQuery from "../../Utils/request/useQuery"; +import routes from "../../Redux/api"; +import request from "../../Utils/request/request"; const Loading = lazy(() => import("../Common/Loading")); const initForm = { @@ -49,39 +45,37 @@ const FormReducer = (state = initialState, action: any) => { export const UpdateFacilityMiddleware = (props: any) => { const [state, dispatch] = useReducer(FormReducer, initialState); const { facilityId } = props; - const dispatchAction: any = useDispatch(); const [isLoading, setIsLoading] = useState(false); - const fetchData = useCallback( - async (status: statusType) => { - if (facilityId) { - setIsLoading(true); - const res = await dispatchAction(getPermittedFacility(facilityId)); - if (!status.aborted && res.data) { - const formData = { - name: res.data.name, - state: res.data.state, - district: res.data.district, - local_body: res.data.local_body, - ward: res.data.ward, - middleware_address: res.data.middleware_address, - }; - dispatch({ type: "set_form", form: formData }); - } else { - navigate(`/facility/${facilityId}`); - } - setIsLoading(false); - } + const { res, data, refetch } = useQuery(routes.getPermittedFacility, { + pathParams: { + id: facilityId, }, - [dispatchAction, facilityId] - ); + }); - useAbortableEffect( - (status: statusType) => { - fetchData(status); - }, - [dispatch, fetchData] - ); + useEffect(() => { + if (facilityId) { + setIsLoading(true); + if (data) { + const formData = { + name: data.name, + state: data.state, + district: data.district, + local_body: data.local_body, + ward: data.ward, + middleware_address: data.middleware_address, + }; + dispatch({ type: "set_form", form: formData }); + } else { + navigate(`/facility/${facilityId}`); + } + setIsLoading(false); + } + }, [facilityId, res, data]); + + useEffect(() => { + refetch(); + }, [dispatch, refetch]); const handleSubmit = async (e: any) => { e.preventDefault(); @@ -113,17 +107,26 @@ export const UpdateFacilityMiddleware = (props: any) => { middleware_address: state.form.middleware_address, }; - const res = await dispatchAction(partialUpdateFacility(facilityId, data)); + // data for request body is not same - keep any + const { res, data: updateData } = await request( + routes.partialUpdateFacility, + { + body: data, + pathParams: { + id: facilityId, + }, + } + ); setIsLoading(false); - if (res && res.data) { + if (res && updateData) { Notification.Success({ msg: "Facility updated successfully", }); navigate(`/facility/${facilityId}`); } else { - if (res?.data) + if (updateData) Notification.Error({ - msg: "Something went wrong: " + (res.data.detail || ""), + msg: "Something went wrong: ", // No detail property in response }); } setIsLoading(false); diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx index de2c6af698a..849bde4c38f 100644 --- a/src/Components/Facility/models.tsx +++ b/src/Components/Facility/models.tsx @@ -25,6 +25,10 @@ export interface WardModel { number: number; local_body: number; } +export interface HomeFacilityModel { + id: string; + name: string; +} export interface FacilityModel { id?: number; name?: string; @@ -81,7 +85,7 @@ export type PatientCategory = | "Abnormal" | "Critical"; -export interface ConsultationModel { +export type ConsultationModel = { admission_date?: string; admitted?: boolean; test_id?: string; @@ -143,7 +147,7 @@ export interface ConsultationModel { death_datetime?: string; death_confirmed_doctor?: string; is_readmission?: boolean; -} +}; export interface PatientStatsModel { id?: number; entryDate?: string; @@ -167,7 +171,7 @@ export interface DupPatientModel { } export interface InventoryItemsModel { - // count?: number; + count?: number; id?: number; name?: string; default_unit?: { @@ -224,3 +228,641 @@ export type ICD11DiagnosisModel = { id: string; label: string; }; + +export type IFacilityNotificationRequest = { + facility?: string; + message?: string; +}; + +export type IStateListResponse = { + count: number; + next: string; + previous: string; + results: { + id: number; + name: string; + }[]; +}; + +export type IStateDitrictResponse = { + id: number; + name: string; +}; + +export type IDistrictLocalBodyResponse = IStateDitrictResponse & { + state: number; +}; + +export type IWardLocalBodyResponse = IStateDitrictResponse & { + number: number; + local_body: number; +}; + +export type IFacilityRequest = Omit< + FacilityModel, + | "id" + | "location" + | "local_body_object" + | "district_object" + | "state_object" + | "ward_object" + | "modified_date" + | "created_date" + | "facility_type" +> & { + facility_type?: number; + district_name?: string; + pincode?: string; + state?: number; + local_body?: number; + ward?: number; + kasp_empanelled?: any; + latitude?: string; + longitude?: string; + phone_number?: string | undefined; +}; + +export type IAllFacilitiesResponse = { + id: string; + name: string; + local_body: number; + district: number; + state: number; + ward_object: WardModel; + local_body_object: { id: number } & LocalBodyModel; + district_object: DistrictModel; + state_object: StateModel; + facility_type: string; + read_cover_image_url: string; + features: number[]; + patient_count: string; + bed_count: string; +}; + +export type IFacilityResponse = Omit< + IAllFacilitiesResponse, + "facility_type" +> & { + ward: number; + facility_type: number; + address: string; + longitude: string; + latitude: string; + pincode: number; + oxygen_capacity: number; + phone_number: string; + modified_date: string; + created_date: string; + kasp_empanelled: boolean; + middleware_address: string; + expected_oxygen_requirement: number; + type_b_cylinders: number; + type_c_cylinders: number; + type_d_cylinders: number; + expected_type_b_cylinders: number; + expected_type_c_cylinders: number; + expected_type_d_cylinders: number; +}; + +export type IListDoctorResponse = { + count: number; + next: string; + previous: string; + results: { + id: string; + area_text: number; + area: number; + count: number; + }[]; +}; + +export type IListCapacityResponse = { + count: number; + next: string; + previous: string; + results: { + id: string; + room_type_text: number; + modified_date: string; + room_type: number; + total_capacity: number; + current_capacity: number; + }[]; +}; + +export type IUserListFacilityResponse = { + id: number; + username: string; + first_name: string; + last_name: string; + email: string; + user_type: number; + doctor_qualification: string; + doctor_experience_commenced_on: string; + doctor_medical_council_registration: string; + created_by: string; + home_facility: string; + weekly_working_hours: number; + local_body: number; + district: number; + state: number; + phone_number: string; + alt_phone_number: string; + gender: number; + age: number; + is_superuser: boolean; + verified: boolean; + home_facility_object: HomeFacilityModel; + local_body_object: { id: number } & LocalBodyModel; + district_object: DistrictModel; + state_object: StateModel; + pf_endpoint: string; + pf_p256dh: string; + pf_auth: string; +}; + +export type IDeleteUserResponse = { + detail?: string; +}; + +export type IDeleteInventoryLog = IDeleteUserResponse; + +export type IUserFacilityRequest = { + username?: string; + first_name?: string; + last_name?: string; + email?: string; + doctor_qualification?: string; + doctor_experience_commenced_on?: string; + doctor_medical_council_registration?: string; + home_facility?: string; + weekly_working_hours?: number; + phone_number?: string; + alt_phone_number?: string; + gender?: number; + age?: number; +}; + +export type IUserFacilityResponse = IUserListFacilityResponse; + +export type IFacilityUserRequest = { + limit?: number; + offset?: number; +}; + +export type IFacilityUserResponse = { + count: number; + next: string | null; + previous: string | null; + results: { + id: number; + first_name: string; + username: string; + email: string; + last_name: string; + alt_phone_number: string; + user_type: number; + last_login: string; + home_facility_object: HomeFacilityModel; + doctor_qualification: string; + doctor_experience_commenced_on: string; + doctor_medical_council_registration: string; + skills: { + id: string; + name: string; + description: string; + }[]; + }[]; +}; + +export type IPermittedFacilityRequest = { + district?: number; + district_name?: string; + facility_type?: number; + kasp_empanelled?: boolean; + limit?: number; + local_body?: number; + local_body_name?: string; + name?: string; + offset?: number; + search_text?: string; + state?: number; + state_name?: string; +}; + +export type IPermittedFacilityResponse = { + count: number; + next: string | null; + previous: string | null; + results: IFacilityResponse[]; +}; + +export type IStateResponse = { + id: number; + name: string; +}; + +export type IStateRequest = { + id?: number; +}; + +export type IDistrictResponse = IStateResponse; + +export type IDistrictRequest = IStateRequest; + +export type ILocalBodyResponse = IStateResponse & { + body_type: number; + localbody_code: string; + district: number; +}; + +export type ILocalBodyRequest = IStateRequest; + +interface InventoryItemObjectModel { + id: number; + default_unit: { + id: number; + name: string; + }; + allowed_units: { + id: number; + name: string; + }[]; + tags: { + id: number; + name: string; + }[]; + name: string; + description: string; + min_quantity: number; +} + +export type IInventorySummaryRequest = { + limit?: number; + offset?: number; +}; + +export type IInventorySummaryResponse = { + count: number; + next: string | null; + previous: string | null; + results: { + id: string; + item_object: InventoryItemObjectModel; + unit_object: { + id: number; + name: string; + }; + created_date: string; + quantity: number; + is_low: boolean; + item: number; + }[]; +}; + +export type IInventoryLogRequest = { + item?: number; + limit?: number; + name?: string; + offset?: number; +}; + +export type IInventoryLogResponse = Omit< + IInventorySummaryResponse, + "results" +> & { + results: { + id: string; + item_object: InventoryItemObjectModel; + unit_object: { + id: number; + name: string; + }; + external_id: string; + current_stock: number; + quantity_in_default_unit: number; + is_incoming: boolean; + probable_accident: boolean; + created_by: number; + }[]; +}; + +export type IFaciclityMinimumQuantityRequest = { + min_quantity?: number; + item?: number; +}; + +export type IFaciclityMinimumQuantityResponse = { + id: string; + item_object: InventoryItemObjectModel; + created_date: string; + min_quantity: number; + item: number; +}; + +export type IPatientTransferRequest = { + facility?: string; + date_of_birth?: string; +}; + +interface FacilityObjectModel { + id: string; + name: string; + local_body: number; + district: number; + state: number; + ward_object: WardModel; + local_body_object: { id: number } & LocalBodyModel; + district_object: DistrictModel; + state_object: StateModel; + facility_type: string; + read_cover_image_url: string; + features: number[]; + patient_count: string; + bed_count: string; +} + +export type IPatientTransferResponse = { + date_of_birth: string; + patient: string; + facility_object: FacilityObjectModel; +}; + +export type IInvestigationRequest = { + created_date_after?: string; + created_date_before?: string; + investigation?: string; + investigations?: string; + modified_date_after?: string; + modified_date_before?: string; + page?: number; + session?: string; + sessions?: string; +}; + +export type IInvestigationResponse = { + count: number; + next: string | null; + previous: string | null; + results: { + id: string; + group_object: { + external_id: string; + name: string; + }; + investigation_object: { + external_id: string; + name: string; + unit: string; + ideal_value: string; + min_value: number; + max_value: number; + investigation_type: string; + choices: string; + }; + session_object: { + session_external_id: string; + session_created_date: string; + created_by: number; + }; + value: number; + notes: string; + investigation: number; + group: number; + consultation: number; + session: number; + }[]; +}; + +interface BedObjectModel { + id: string; + bed_type: number; + location_object: { + id: string; + facility: { + id: string; + name: string; + }; + created_date: string; + modified_date: string; + name: string; + description: string; + location_type: number; + }; + is_occupied: boolean; + created_date: string; + modified_date: string; + name: string; + description: string; + meta: Record; +} + +export type IConsultationBedResponse = { + id: string; + bed_object: BedObjectModel; + assets_objects: Asset[]; + last_daily_round: string; + start_date: string; + created_date: string; + modified_date: string; + end_date: string; + meta: Record; +}; + +type Asset = { + id: string; + status: number; + asset_type: number; + location_object: { + id: string; + facility: { + id: string; + name: string; + }; + created_date: string; + modified_date: string; + name: string; + description: string; + location_type: number; + }; + last_service: { + id: string; + edits: ServiceEdit[]; + external_id: string; + created_date: string; + modified_date: string; + serviced_on: string; + note: string; + }; + created_date: string; + modified_date: string; + name: string; + description: string; + asset_class: string; + is_working: boolean; + not_working_reason: string; + serial_number: string; + warranty_details: string; + meta: Record; + vendor_name: string; + support_name: string; + support_phone: string; + support_email: string; + qr_code_id: string; + manufacturer: string; + warranty_amc_end_of_validity: string; +}; + +type ServiceEdit = { + id: string; + edited_by: { + id: number; + first_name: string; + username: string; + email: string; + last_name: string; + user_type: number; + last_login: string; + }; + edited_on: string; + serviced_on: string; + note: string; +}; + +export type ITriageDetailResponse = { + id: string; + entry_date: string; + facility: string; + created_date: string; + modified_date: string; + num_patients_visited: number; + num_patients_home_quarantine: number; + num_patients_isolation: number; + num_patient_referred: number; + num_patient_confirmed_positive: number; +}; + +// export interface PatientStatsModel { +// id?: number; +// entryDate?: string; +// num_patients_visited?: number; +// num_patients_home_quarantine?: number; +// num_patients_isolation?: number; +// num_patient_referred?: number; +// entry_date?: number; +// num_patient_confirmed_positive?: number; +// } + +export type ITriageRequest = { + entry_date_after?: string; + entry_date_before?: string; + limit?: number; + offset?: number; +}; + +export type ITriageResponse = { + count: number; + next: string; + previous: string; + results: ITriageDetailResponse[]; +}; + +export type IMinQuantityRequest = { + limit?: number; + offset?: number; +}; + +export type IMinQuantityResponse = { + count: number; + next: string; + previous: string; + results: IMinQuantityItemResponse[]; +}; + +export type IMinQuantityItemResponse = { + id: string; + item_object: InventoryItemObjectModel; + created_date: string; + min_quantity: number; + item: number; +}; + +export type IItemRequest = { + limit?: number; + name?: number; + offset?: number; +}; + +export type IItemResponse = { + count: number; + next: string; + previous: string; + results: InventoryItemObjectModel[]; +}; + +export type ISetMinQuantityRequest = { + min_quantity?: number; + item?: number; +}; + +export type ISetMinQuantityResponse = IMinQuantityItemResponse; + +export type IFlagInventoryItemResponse = { + id: string; + item_object: InventoryItemObjectModel; + unit_object: { + id: number; + name: string; + }; + external_id: string; + created_date: string; + current_stock: number; + quantity_in_default_unit: number; + quantity: number; + is_incoming: boolean; + probable_accident: boolean; + item: number; + unit: number; + created_by: number; +}; + +export type IAssetBedResponse = { + count: number; + next: string; + previous: string; + results: { + id: string; + asset_object: Asset; + bed_object: BedObjectModel; + created_date: string; + modified_date: string; + meta: Record; + }[]; +}; + +export type IAllPatientRequest = { + facility?: string; + is_active?: boolean; +}; + +export type ICreateTriageRequest = { + entry_date?: string; + num_patients_visited?: number; + num_patients_home_quarantine?: number; + num_patients_isolation?: number; + num_patient_referred?: number; + num_patient_confirmed_positive?: number; +}; + +export type ICreateTriageResponse = { + id: string; + entry_date: string; + facility: string; + created_date: string; + modified_date: string; + num_patients_visited: number; + num_patients_home_quarantine: number; + num_patients_isolation: number; + num_patient_referred: number; + num_patient_confirmed_positive: number; +}; diff --git a/src/Redux/actions.tsx b/src/Redux/actions.tsx index 1a5bd7e4fb1..fd7c412301a 100644 --- a/src/Redux/actions.tsx +++ b/src/Redux/actions.tsx @@ -24,9 +24,6 @@ export const signupUser = (params: object) => { export const addUser = (params: object) => { return fireRequest("addUser", [], params); }; -export const deleteUser = (username: string) => { - return fireRequest("deleteUser", [username], {}); -}; export const checkResetToken = (params: object) => { return fireRequest("checkResetToken", [], params); @@ -53,18 +50,6 @@ export const updateUserPnconfig = (params: object, pathParams: object) => { }; // Facility -export const createFacility = (params: object) => { - return fireRequest("createFacility", [], params); -}; -export const updateFacility = (id: string, params: object) => { - return fireRequest("updateFacility", [id], params); -}; -export const partialUpdateFacility = (id: string, params: object) => { - return fireRequest("partialUpdateFacility", [id], params); -}; -export const deleteFacility = (id: string) => { - return fireRequest("deleteFacility", [id], {}); -}; export const deleteFacilityCoverImage = (id: string) => { return fireRequest("deleteFacilityCoverImage", [], {}, { id }); }; @@ -79,39 +64,19 @@ export const getUserListSkills = (pathParam: object) => { export const partialUpdateUser = (username: string, data: any) => { return fireRequest("partialUpdateUser", [], data, { username }); }; -export const getUserListFacility = (pathParam: object) => { - return fireRequest("userListFacility", [], {}, pathParam); -}; export const addUserSkill = (username: string, skill: string) => { return fireRequest("addUserSkill", [], { skill }, { username }); }; -export const addUserFacility = (username: string, facility: string) => { - return fireRequest("addUserFacility", [], { facility }, { username }); -}; - export const deleteUserSkill = (username: string, id: string) => { return fireRequest("deleteUserSkill", [], {}, { username, id }); }; -export const deleteUserFacility = (username: string, facility: string) => { - return fireRequest( - "deleteUserFacility", - [], - { data: { facility } }, - { username } - ); -}; - export const clearHomeFacility = (username: string) => { return fireRequest("clearHomeFacility", [], {}, { username }); }; -export const getPermittedFacilities = (params: object) => { - return fireRequest("getPermittedFacilities", [], params); -}; - export const getAllFacilities = (params: object) => { return fireRequest("getAllFacilities", [], params); }; @@ -120,22 +85,6 @@ export const getAllSkills = (params: object) => { return fireRequest("getAllSkills", [], params); }; -export const getPermittedFacility = (id: number | string, key?: string) => { - return fireRequest("getPermittedFacility", [], {}, { id: id }, key); -}; - -export const getAnyFacility = (id: number | string, key?: string) => { - return fireRequest("getAnyFacility", [], {}, { id: id }, key); -}; - -export const getFacilityUsers = (id: string, params?: object) => { - return fireRequest( - "getFacilityUsers", - [], - { ...params }, - { facility_id: id } - ); -}; export const getOnlineDoctors = () => { return fireRequest("getOnlineDoctors", [], {}, {}); }; @@ -371,21 +320,7 @@ export const createDoctor = ( export const deleteDoctor = (id: number, pathParam: object) => { return fireRequest("deleteDoctor", [id], {}, pathParam); }; -export const createTriageForm = (params: object, pathParam: object) => { - return fireRequest("createTriage", [], params, pathParam); -}; -export const getTriageInfo = (pathParam: object) => { - return fireRequest("getTriage", [], {}, pathParam); -}; -export const getTriageDetails = (pathParam: object) => { - return fireRequest("getTriageDetails", [], {}, pathParam); -}; -export const listCapacity = (params: object, pathParam: object) => { - return fireRequest("getCapacity", [], params, pathParam); -}; -export const listDoctor = (params: object, pathParam: object) => { - return fireRequest("listDoctor", [], params, pathParam); -}; + export const getCapacity = (id: number, pathParam: object) => { return fireRequest("getCapacity", [id], {}, pathParam); }; @@ -408,24 +343,15 @@ export const searchPatient = (params: object) => { export const searchUser = (params: object) => { return fireRequest("searchUser", [], params); }; -export const getAllPatient = (params: object, altKey: string) => { - return fireRequest("patientList", [], params, null, altKey); -}; export const createPatient = (params: object) => { return fireRequest("addPatient", [], params); }; -export const getPatient = (pathParam: object) => { - return fireRequest("getPatient", [], {}, pathParam); -}; export const updatePatient = (params: object, pathParam: object) => { return fireRequest("updatePatient", [], params, pathParam); }; export const patchPatient = (params: object, pathParam: object) => { return fireRequest("patchPatient", [], params, pathParam); }; -export const transferPatient = (params: object, pathParam: object) => { - return fireRequest("transferPatient", [], params, pathParam); -}; export const getPatientNotes = ( patientId: string, limit: number, @@ -437,15 +363,9 @@ export const addPatientNote = (patientId: string, params: object) => { return fireRequest("addPatientNote", [], params, { patientId }); }; -export const getStates = () => { - return fireRequest("statesList", []); -}; export const getStatesByText = (params: object) => { return fireRequest("statesList", [], params); }; -export const getState = (id: number) => { - return fireRequest("getState", [], {}, { id: id }); -}; // District/State/Local body/ward export const getDistrictByState = (pathParam: object) => { @@ -454,20 +374,11 @@ export const getDistrictByState = (pathParam: object) => { export const getDistrictByName = (params: object) => { return fireRequest("getDistrictByName", [], params, null); }; -export const getDistrict = (id: number, key?: string) => { - return fireRequest("getDistrict", [], {}, { id: id }, key); -}; -export const getLocalbodyByDistrict = (pathParam: object) => { - return fireRequest("getLocalbodyByDistrict", [], {}, pathParam); -}; export const getLocalbodyByName = (params: object) => { return fireRequest("getLocalbodyByName", [], params, null); }; -export const getWardByLocalBody = (pathParam: object) => { - return fireRequest("getWardByLocalBody", [], {}, pathParam); -}; export const getWards = (params: object) => { return fireRequest("getWards", [], params); }; @@ -477,9 +388,6 @@ export const getAllLocalBodyByDistrict = (pathParam: object) => { }; // Local Body -export const getLocalBody = (pathParam: object) => { - return fireRequest("getLocalBody", [], {}, pathParam); -}; export const getAllLocalBody = (params: object) => { return fireRequest("getAllLocalBody", [], params); }; @@ -543,22 +451,12 @@ export const updateConsultation = (id: number, params: object) => { return fireRequest("updateConsultation", [], params, { id: id }); }; //Inventory -export const getItems = (params: object) => { - return fireRequest("getItems", [], params); -}; export const postInventory = (params: object, pathParams: object) => { return fireRequest("createInventory", [], params, pathParams); }; export const getInventoryLog = (params: object, pathParams: object) => { return fireRequest("getInventoryLog", [params, "inventory"], pathParams); }; -export const setMinQuantity = (params: object, pathParams: object) => { - return fireRequest("setMinQuantity", [], params, pathParams); -}; -export const getMinQuantity = (facilityId: object, params: object) => { - return fireRequest("getMinQuantity", [facilityId, "min_quantity"], params); -}; - export const getMinQuantityOfItem = ( facilityId: object, externalId: object @@ -570,28 +468,10 @@ export const getMinQuantityOfItem = ( ]); }; -export const updateMinQuantity = (pathParams: object, params: object) => { - return fireRequest("updateMinQuantity", [], pathParams, params); -}; -export const getInventorySummary = (facilityId: number, params: object) => { - return fireRequest( - "getInventorySummary", - [facilityId, "inventorysummary"], - params - ); -}; export const getItemName = (id: number) => { return fireRequest("getItemName", [id], {}); }; -export const flagInventoryItem = (params: object) => { - return fireRequest("flagInventoryItem", [], {}, params); -}; - -export const deleteLastInventoryLog = (params: object) => { - return fireRequest("deleteLastInventoryLog", [], {}, params); -}; - export const generateDischargeSummary = (pathParams: object) => { return fireRequest("dischargeSummaryGenerate", [], {}, pathParams); }; @@ -706,10 +586,6 @@ export const getPublicKey = () => { return fireRequest("getPublicKey", [], {}, {}); }; -export const sendNotificationMessages = (params: object) => { - return fireRequest("sendNotificationMessages", [], params, {}); -}; - // FileUpload export const createUpload = (params: object) => { @@ -772,15 +648,6 @@ export const getInvestigationSessions = ( }); }; -export const getInvestigation = ( - params: object, - consultation_external_id: string -) => { - return fireRequest("getInvestigation", [], params, { - consultation_external_id: consultation_external_id, - }); -}; - export const getPatientInvestigation = ( params: object, patient_external_id: string diff --git a/src/Redux/api.tsx b/src/Redux/api.tsx index 1aa06c7e1bc..075f25c880d 100644 --- a/src/Redux/api.tsx +++ b/src/Redux/api.tsx @@ -1,6 +1,59 @@ import { IConfig } from "../Common/hooks/useConfig"; import { AssetData } from "../Components/Assets/AssetTypes"; -import { LocationModel } from "../Components/Facility/models"; +import { + IUserFacilityRequest, + IDeleteUserResponse, + IFacilityNotificationRequest, + IFacilityRequest, + IFacilityResponse, + IListCapacityResponse, + IListDoctorResponse, + IUserListFacilityResponse, + LocationModel, + IUserFacilityResponse, + IAllFacilitiesResponse, + IFacilityUserRequest, + IFacilityUserResponse, + IPermittedFacilityRequest, + IPermittedFacilityResponse, + IStateResponse, + IStateRequest, + IDistrictRequest, + IDistrictResponse, + ILocalBodyRequest, + ILocalBodyResponse, + IInventorySummaryRequest, + IInventorySummaryResponse, + IInventoryLogRequest, + IInventoryLogResponse, + IFaciclityMinimumQuantityResponse, + IFaciclityMinimumQuantityRequest, + IPatientTransferRequest, + IPatientTransferResponse, + IInvestigationResponse, + IInvestigationRequest, + IConsultationBedResponse, + ITriageDetailResponse, + ITriageRequest, + ITriageResponse, + IMinQuantityRequest, + IMinQuantityResponse, + IMinQuantityItemResponse, + IItemRequest, + IItemResponse, + ISetMinQuantityRequest, + ISetMinQuantityResponse, + IFlagInventoryItemResponse, + IAssetBedResponse, + IStateListResponse, + IStateDitrictResponse, + IDistrictLocalBodyResponse, + IWardLocalBodyResponse, + IAllPatientRequest, + IDeleteInventoryLog, + ICreateTriageRequest, + ICreateTriageResponse, +} from "../Components/Facility/models"; import { UserModel } from "../Components/Users/models"; import { PaginatedResponse } from "../Utils/request/types"; @@ -79,11 +132,14 @@ const routes = { userListFacility: { path: "/api/v1/users/{username}/get_facilities/", + TRes: Type(), }, addUserFacility: { path: "/api/v1/users/{username}/add_facility/", method: "PUT", + TBody: Type(), + TRes: Type(), }, addUserSkill: { @@ -94,6 +150,8 @@ const routes = { deleteUserFacility: { path: "/api/v1/users/{username}/delete_facility/", method: "DELETE", + TBody: Type(), + TRes: Type(), }, clearHomeFacility: { @@ -123,8 +181,9 @@ const routes = { }, deleteUser: { - path: "/api/v1/users", + path: "/api/v1/users/{username}", method: "DELETE", + TRes: Type(), }, addUser: { @@ -159,6 +218,8 @@ const routes = { getPermittedFacilities: { path: "/api/v1/facility/", + TBody: Type(), + TRes: Type(), }, getAllFacilities: { @@ -168,24 +229,32 @@ const routes = { createFacility: { path: "/api/v1/facility/", method: "POST", + TRes: Type(), + TBody: Type(), }, getPermittedFacility: { path: "/api/v1/facility/{id}/", + TRes: Type(), }, getAnyFacility: { path: "/api/v1/getallfacilities/{id}/", + TRes: Type(), }, updateFacility: { - path: "/api/v1/facility", + path: "/api/v1/facility/{id}/", method: "PUT", + TRes: Type(), + TBody: Type(), }, partialUpdateFacility: { - path: "/api/v1/facility", + path: "/api/v1/facility/{id}/", method: "PATCH", + TBody: Type(), + TRes: Type(), }, deleteFacilityCoverImage: { @@ -195,6 +264,8 @@ const routes = { getFacilityUsers: { path: "/api/v1/facility/{facility_id}/get_users/", + TBody: Type(), + TRes: Type(), }, listFacilityAssetLocation: { @@ -223,6 +294,8 @@ const routes = { listAssetBeds: { path: "/api/v1/assetbed/", method: "GET", + TBody: Type(), + TRes: Type(), }, createAssetBed: { path: "/api/v1/assetbed/", @@ -298,8 +371,10 @@ const routes = { // Download Api deleteFacility: { - path: "/api/v1/facility", + path: "/api/v1/facility/{id}", method: "DELETE", + TRes: Type(), + Tbody: Type(), }, downloadFacility: { @@ -333,6 +408,7 @@ const routes = { }, getConsultation: { path: "/api/v1/consultation/{id}/", + TRes: Type(), }, updateConsultation: { path: "/api/v1/consultation/{id}/", @@ -383,6 +459,7 @@ const routes = { getCapacity: { path: "/api/v1/facility/{facilityId}/capacity/", + TRes: Type(), }, getCapacityBed: { @@ -396,6 +473,7 @@ const routes = { listDoctor: { path: "/api/v1/facility/{facilityId}/hospital_doctor/", + TRes: Type(), }, getDoctor: { path: "/api/v1/facility/{facilityId}/hospital_doctor/{id}/", @@ -420,13 +498,18 @@ const routes = { createTriage: { path: "/api/v1/facility/{facilityId}/patient_stats/", method: "POST", + TBody: Type(), + TRes: Type(), }, getTriage: { path: "/api/v1/facility/{facilityId}/patient_stats/", + TBody: Type(), + TRes: Type(), }, getTriageDetails: { path: "/api/v1/facility/{facilityId}/patient_stats/{id}/", + TRes: Type(), }, // //Care Center @@ -442,6 +525,8 @@ const routes = { }, patientList: { path: "/api/v1/patient/", + TBody: Type(), + TRes: Type(), }, addPatient: { path: "/api/v1/patient/", @@ -449,6 +534,7 @@ const routes = { }, getPatient: { path: "/api/v1/patient/{id}/", + TRes: Type(), }, updatePatient: { path: "/api/v1/patient/{id}/", @@ -461,6 +547,8 @@ const routes = { transferPatient: { path: "/api/v1/patient/{id}/transfer/", method: "POST", + TBody: Type(), + TRes: Type(), }, getPatientNotes: { path: "/api/v1/patient/{patientId}/notes/", @@ -511,19 +599,25 @@ const routes = { // States statesList: { path: "/api/v1/state/", + TRes: Type(), }, getState: { path: "/api/v1/state/{id}/", + TBody: Type(), + TRes: Type(), }, // Districts getDistrict: { path: "/api/v1/district/{id}/", + TBody: Type(), + TRes: Type(), }, getDistrictByState: { path: "/api/v1/state/{id}/districts/", + TRes: Type(), }, getDistrictByName: { path: "/api/v1/district/", @@ -533,11 +627,14 @@ const routes = { }, getLocalbodyByDistrict: { path: "/api/v1/district/{id}/local_bodies/", + TRes: Type(), }, // Local Body getLocalBody: { path: "/api/v1/local_body/{id}/", + TBody: Type(), + TRes: Type(), }, getAllLocalBody: { path: "/api/v1/local_body/", @@ -555,6 +652,7 @@ const routes = { }, getWardByLocalBody: { path: "/api/v1/ward/?local_body={id}", + TRes: Type(), }, // Sample Test @@ -572,29 +670,47 @@ const routes = { //inventory getItems: { path: "/api/v1/items/", + TBody: Type(), + TRes: Type(), }, createInventory: { path: "/api/v1/facility/{facilityId}/inventory/", method: "POST", }, getInventoryLog: { - path: "/api/v1/facility", + path: "/api/v1/facility/{id}/inventory/", + TBody: Type(), + TRes: Type(), }, setMinQuantity: { path: "/api/v1/facility/{facilityId}/min_quantity/", method: "POST", + TBody: Type(), + TRes: Type(), }, getMinQuantity: { - path: "/api/v1/facility", + path: "/api/v1/facility/{id}/min_quantity/", + method: "GET", + TBody: Type(), + TRes: Type(), + }, + + getMinQuantityOfItem: { + path: "/api/v1/facility/{id}/min_quantity/{external_id}", method: "GET", + TRes: Type(), }, updateMinQuantity: { path: "/api/v1/facility/{facilityId}/min_quantity/{inventoryId}", method: "PATCH", + TBody: Type(), + TRes: Type(), }, getInventorySummary: { - path: "/api/v1/facility", + path: "/api/v1/facility/{id}/inventorysummary/", method: "GET", + TBody: Type(), + TRes: Type(), }, getItemName: { path: "/api/v1/items", @@ -603,10 +719,13 @@ const routes = { flagInventoryItem: { path: "/api/v1/facility/{facility_external_id}/inventory/{external_id}/flag/", method: "PUT", + TBody: Type(), + TRes: Type(), }, deleteLastInventoryLog: { path: "/api/v1/facility/{facility_external_id}/inventory/delete_last/?item={id}", method: "DELETE", + TRes: Type(), }, dischargeSummaryGenerate: { path: "/api/v1/consultation/{external_id}/generate_discharge_summary/", @@ -693,6 +812,8 @@ const routes = { sendNotificationMessages: { path: "/api/v1/notification/notify/", method: "POST", + TRes: Type(), + Tbody: Type(), }, // FileUpload Create @@ -733,6 +854,8 @@ const routes = { getInvestigation: { path: "/api/v1/consultation/{consultation_external_id}/investigation/", method: "GET", + TBody: Type(), + TRes: Type(), }, getPatientInvestigation: { path: "/api/v1/patient/{patient_external_id}/investigation/", From 4eaf9f18fac55894557eb21c9fbb4f17b9c8e9fc Mon Sep 17 00:00:00 2001 From: sriharsh05 Date: Sat, 14 Oct 2023 18:11:50 +0530 Subject: [PATCH 02/10] add required fire requests in actions.tsx --- src/Redux/actions.tsx | 87 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 4 deletions(-) diff --git a/src/Redux/actions.tsx b/src/Redux/actions.tsx index fd7c412301a..b1c3bf28685 100644 --- a/src/Redux/actions.tsx +++ b/src/Redux/actions.tsx @@ -24,7 +24,9 @@ export const signupUser = (params: object) => { export const addUser = (params: object) => { return fireRequest("addUser", [], params); }; - +export const deleteUser = (username: string) => { + return fireRequest("deleteUser", [username], {}); +}; export const checkResetToken = (params: object) => { return fireRequest("checkResetToken", [], params); }; @@ -76,7 +78,9 @@ export const deleteUserSkill = (username: string, id: string) => { export const clearHomeFacility = (username: string) => { return fireRequest("clearHomeFacility", [], {}, { username }); }; - +export const getUserListFacility = (pathParam: object) => { + return fireRequest("userListFacility", [], {}, pathParam); +}; export const getAllFacilities = (params: object) => { return fireRequest("getAllFacilities", [], params); }; @@ -84,11 +88,20 @@ export const getAllFacilities = (params: object) => { export const getAllSkills = (params: object) => { return fireRequest("getAllSkills", [], params); }; - +export const addUserFacility = (username: string, facility: string) => { + return fireRequest("addUserFacility", [], { facility }, { username }); +}; export const getOnlineDoctors = () => { return fireRequest("getOnlineDoctors", [], {}, {}); }; - +export const deleteUserFacility = (username: string, facility: string) => { + return fireRequest( + "deleteUserFacility", + [], + { data: { facility } }, + { username } + ); +}; export const listFacilityAssetLocation = (params: object, pathParam: object) => fireRequest("listFacilityAssetLocation", [], params, pathParam); export const createFacilityAssetLocation = ( @@ -98,6 +111,9 @@ export const createFacilityAssetLocation = ( fireRequest("createFacilityAssetLocation", [], params, { facility_external_id: facility_id, }); +export const getPermittedFacilities = (params: object) => { + return fireRequest("getPermittedFacilities", [], params); +}; export const getFacilityAssetLocation = ( facility_external_id: string, external_id: string @@ -108,6 +124,23 @@ export const getFacilityAssetLocation = ( {}, { facility_external_id, external_id } ); + +export const getPermittedFacility = (id: number | string, key?: string) => { + return fireRequest("getPermittedFacility", [], {}, { id: id }, key); +}; + +export const getAnyFacility = (id: number | string, key?: string) => { + return fireRequest("getAnyFacility", [], {}, { id: id }, key); +}; + +export const getFacilityUsers = (id: string, params?: object) => { + return fireRequest( + "getFacilityUsers", + [], + { ...params }, + { facility_id: id } + ); +}; export const updateFacilityAssetLocation = ( params: object, facility_external_id: string, @@ -335,6 +368,12 @@ export const getDoctor = (pathParam: object) => { export const deleteCapacity = (pathParam: object) => { return fireRequest("deleteCapacityBed", [], {}, pathParam); }; +export const listCapacity = (params: object, pathParam: object) => { + return fireRequest("getCapacity", [], params, pathParam); +}; +export const listDoctor = (params: object, pathParam: object) => { + return fireRequest("listDoctor", [], params, pathParam); +}; //Patient export const searchPatient = (params: object) => { @@ -366,6 +405,12 @@ export const addPatientNote = (patientId: string, params: object) => { export const getStatesByText = (params: object) => { return fireRequest("statesList", [], params); }; +export const getAllPatient = (params: object, altKey: string) => { + return fireRequest("patientList", [], params, null, altKey); +}; +export const getPatient = (pathParam: object) => { + return fireRequest("getPatient", [], {}, pathParam); +}; // District/State/Local body/ward export const getDistrictByState = (pathParam: object) => { @@ -374,11 +419,23 @@ export const getDistrictByState = (pathParam: object) => { export const getDistrictByName = (params: object) => { return fireRequest("getDistrictByName", [], params, null); }; +export const getStates = () => { + return fireRequest("statesList", []); +}; export const getLocalbodyByName = (params: object) => { return fireRequest("getLocalbodyByName", [], params, null); }; +export const getDistrict = (id: number, key?: string) => { + return fireRequest("getDistrict", [], {}, { id: id }, key); +}; +export const getLocalbodyByDistrict = (pathParam: object) => { + return fireRequest("getLocalbodyByDistrict", [], {}, pathParam); +}; +export const getWardByLocalBody = (pathParam: object) => { + return fireRequest("getWardByLocalBody", [], {}, pathParam); +}; export const getWards = (params: object) => { return fireRequest("getWards", [], params); }; @@ -388,6 +445,9 @@ export const getAllLocalBodyByDistrict = (pathParam: object) => { }; // Local Body +export const getLocalBody = (pathParam: object) => { + return fireRequest("getLocalBody", [], {}, pathParam); +}; export const getAllLocalBody = (params: object) => { return fireRequest("getAllLocalBody", [], params); }; @@ -451,9 +511,13 @@ export const updateConsultation = (id: number, params: object) => { return fireRequest("updateConsultation", [], params, { id: id }); }; //Inventory +export const getItems = (params: object) => { + return fireRequest("getItems", [], params); +}; export const postInventory = (params: object, pathParams: object) => { return fireRequest("createInventory", [], params, pathParams); }; + export const getInventoryLog = (params: object, pathParams: object) => { return fireRequest("getInventoryLog", [params, "inventory"], pathParams); }; @@ -468,6 +532,13 @@ export const getMinQuantityOfItem = ( ]); }; +export const getInventorySummary = (facilityId: number, params: object) => { + return fireRequest( + "getInventorySummary", + [facilityId, "inventorysummary"], + params + ); +}; export const getItemName = (id: number) => { return fireRequest("getItemName", [id], {}); }; @@ -647,6 +718,14 @@ export const getInvestigationSessions = ( consultation_external_id: consultation_external_id, }); }; +export const getInvestigation = ( + params: object, + consultation_external_id: string +) => { + return fireRequest("getInvestigation", [], params, { + consultation_external_id: consultation_external_id, + }); +}; export const getPatientInvestigation = ( params: object, From 593c1df86ec8b96372a651e6385509b7f268ea05 Mon Sep 17 00:00:00 2001 From: sriharsh05 Date: Sun, 22 Oct 2023 18:15:54 +0530 Subject: [PATCH 03/10] add PaginatedResponseType wherever required --- src/Components/Facility/FacilityHome.tsx | 2 +- src/Components/Facility/models.tsx | 280 +++++++---------------- 2 files changed, 89 insertions(+), 193 deletions(-) diff --git a/src/Components/Facility/FacilityHome.tsx b/src/Components/Facility/FacilityHome.tsx index 2a33121f171..d98c5f3a3b9 100644 --- a/src/Components/Facility/FacilityHome.tsx +++ b/src/Components/Facility/FacilityHome.tsx @@ -152,7 +152,7 @@ export const FacilityHome = (props: any) => { if (capacityRes && capacityData) { const transformedCapacityData = { id: Number(capacityData.results[0].id), - room_type: capacityData.results[0].room_type_text, + room_type: capacityData.results[0].room_type, modified_date: capacityData.results[0].modified_date, total_capacity: capacityData.results[0].total_capacity, current_capacity: capacityData.results[0].current_capacity, diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx index 849bde4c38f..2552d215f16 100644 --- a/src/Components/Facility/models.tsx +++ b/src/Components/Facility/models.tsx @@ -3,6 +3,7 @@ import { ProcedureType } from "../Common/prescription-builder/ProcedureBuilder"; import { NormalPrescription, PRNPrescription } from "../Medicine/models"; import { AssetData } from "../Assets/AssetTypes"; import { UserBareMinimum } from "../Users/models"; +import { PaginatedResponse } from "../../Utils/request/types"; export interface LocalBodyModel { name: string; @@ -229,30 +230,22 @@ export type ICD11DiagnosisModel = { label: string; }; +type UnitModel = { + id: number; + name: string; +}; + export type IFacilityNotificationRequest = { facility?: string; message?: string; }; -export type IStateListResponse = { - count: number; - next: string; - previous: string; - results: { - id: number; - name: string; - }[]; -}; - -export type IStateDitrictResponse = { - id: number; - name: string; -}; +export type IStateListResponse = PaginatedResponse; +export type IStateDitrictResponse = StateModel; export type IDistrictLocalBodyResponse = IStateDitrictResponse & { state: number; }; - export type IWardLocalBodyResponse = IStateDitrictResponse & { number: number; local_body: number; @@ -281,24 +274,6 @@ export type IFacilityRequest = Omit< longitude?: string; phone_number?: string | undefined; }; - -export type IAllFacilitiesResponse = { - id: string; - name: string; - local_body: number; - district: number; - state: number; - ward_object: WardModel; - local_body_object: { id: number } & LocalBodyModel; - district_object: DistrictModel; - state_object: StateModel; - facility_type: string; - read_cover_image_url: string; - features: number[]; - patient_count: string; - bed_count: string; -}; - export type IFacilityResponse = Omit< IAllFacilitiesResponse, "facility_type" @@ -323,32 +298,31 @@ export type IFacilityResponse = Omit< expected_type_c_cylinders: number; expected_type_d_cylinders: number; }; - -export type IListDoctorResponse = { - count: number; - next: string; - previous: string; - results: { - id: string; - area_text: number; - area: number; - count: number; - }[]; +export type IAllFacilitiesResponse = { + id: string; + name: string; + local_body: number; + district: number; + state: number; + ward_object: WardModel; + local_body_object: { id: number } & LocalBodyModel; + district_object: DistrictModel; + state_object: StateModel; + facility_type: string; + read_cover_image_url: string; + features: number[]; + patient_count: string; + bed_count: string; }; -export type IListCapacityResponse = { +export type IListDoctorResponse = PaginatedResponse<{ + id: string; + area_text: number; + area: number; count: number; - next: string; - previous: string; - results: { - id: string; - room_type_text: number; - modified_date: string; - room_type: number; - total_capacity: number; - current_capacity: number; - }[]; -}; +}>; + +export type IListCapacityResponse = PaginatedResponse; export type IUserListFacilityResponse = { id: number; @@ -449,25 +423,14 @@ export type IPermittedFacilityRequest = { state?: number; state_name?: string; }; +export type IPermittedFacilityResponse = PaginatedResponse; -export type IPermittedFacilityResponse = { - count: number; - next: string | null; - previous: string | null; - results: IFacilityResponse[]; -}; - -export type IStateResponse = { - id: number; - name: string; -}; - +export type IStateResponse = StateModel; export type IStateRequest = { id?: number; }; export type IDistrictResponse = IStateResponse; - export type IDistrictRequest = IStateRequest; export type ILocalBodyResponse = IStateResponse & { @@ -475,23 +438,13 @@ export type ILocalBodyResponse = IStateResponse & { localbody_code: string; district: number; }; - export type ILocalBodyRequest = IStateRequest; interface InventoryItemObjectModel { id: number; - default_unit: { - id: number; - name: string; - }; - allowed_units: { - id: number; - name: string; - }[]; - tags: { - id: number; - name: string; - }[]; + default_unit: UnitModel; + allowed_units: UnitModel[]; + tags: UnitModel[]; name: string; description: string; min_quantity: number; @@ -501,24 +454,15 @@ export type IInventorySummaryRequest = { limit?: number; offset?: number; }; - -export type IInventorySummaryResponse = { - count: number; - next: string | null; - previous: string | null; - results: { - id: string; - item_object: InventoryItemObjectModel; - unit_object: { - id: number; - name: string; - }; - created_date: string; - quantity: number; - is_low: boolean; - item: number; - }[]; -}; +export type IInventorySummaryResponse = PaginatedResponse<{ + id: string; + item_object: InventoryItemObjectModel; + unit_object: UnitModel; + created_date: string; + quantity: number; + is_low: boolean; + item: number; +}>; export type IInventoryLogRequest = { item?: number; @@ -526,7 +470,6 @@ export type IInventoryLogRequest = { name?: string; offset?: number; }; - export type IInventoryLogResponse = Omit< IInventorySummaryResponse, "results" @@ -551,7 +494,6 @@ export type IFaciclityMinimumQuantityRequest = { min_quantity?: number; item?: number; }; - export type IFaciclityMinimumQuantityResponse = { id: string; item_object: InventoryItemObjectModel; @@ -560,11 +502,6 @@ export type IFaciclityMinimumQuantityResponse = { item: number; }; -export type IPatientTransferRequest = { - facility?: string; - date_of_birth?: string; -}; - interface FacilityObjectModel { id: string; name: string; @@ -582,6 +519,10 @@ interface FacilityObjectModel { bed_count: string; } +export type IPatientTransferRequest = { + facility?: string; + date_of_birth?: string; +}; export type IPatientTransferResponse = { date_of_birth: string; patient: string; @@ -599,40 +540,34 @@ export type IInvestigationRequest = { session?: string; sessions?: string; }; - -export type IInvestigationResponse = { - count: number; - next: string | null; - previous: string | null; - results: { - id: string; - group_object: { - external_id: string; - name: string; - }; - investigation_object: { - external_id: string; - name: string; - unit: string; - ideal_value: string; - min_value: number; - max_value: number; - investigation_type: string; - choices: string; - }; - session_object: { - session_external_id: string; - session_created_date: string; - created_by: number; - }; - value: number; - notes: string; - investigation: number; - group: number; - consultation: number; - session: number; - }[]; -}; +export type IInvestigationResponse = PaginatedResponse<{ + id: string; + group_object: { + external_id: string; + name: string; + }; + investigation_object: { + external_id: string; + name: string; + unit: string; + ideal_value: string; + min_value: number; + max_value: number; + investigation_type: string; + choices: string; + }; + session_object: { + session_external_id: string; + session_created_date: string; + created_by: number; + }; + value: number; + notes: string; + investigation: number; + group: number; + consultation: number; + session: number; +}>; interface BedObjectModel { id: string; @@ -742,42 +677,19 @@ export type ITriageDetailResponse = { num_patient_confirmed_positive: number; }; -// export interface PatientStatsModel { -// id?: number; -// entryDate?: string; -// num_patients_visited?: number; -// num_patients_home_quarantine?: number; -// num_patients_isolation?: number; -// num_patient_referred?: number; -// entry_date?: number; -// num_patient_confirmed_positive?: number; -// } - export type ITriageRequest = { entry_date_after?: string; entry_date_before?: string; limit?: number; offset?: number; }; - -export type ITriageResponse = { - count: number; - next: string; - previous: string; - results: ITriageDetailResponse[]; -}; +export type ITriageResponse = PaginatedResponse; export type IMinQuantityRequest = { limit?: number; offset?: number; }; - -export type IMinQuantityResponse = { - count: number; - next: string; - previous: string; - results: IMinQuantityItemResponse[]; -}; +export type IMinQuantityResponse = PaginatedResponse; export type IMinQuantityItemResponse = { id: string; @@ -792,28 +704,18 @@ export type IItemRequest = { name?: number; offset?: number; }; - -export type IItemResponse = { - count: number; - next: string; - previous: string; - results: InventoryItemObjectModel[]; -}; +export type IItemResponse = PaginatedResponse; export type ISetMinQuantityRequest = { min_quantity?: number; item?: number; }; - export type ISetMinQuantityResponse = IMinQuantityItemResponse; export type IFlagInventoryItemResponse = { id: string; item_object: InventoryItemObjectModel; - unit_object: { - id: number; - name: string; - }; + unit_object: UnitModel; external_id: string; created_date: string; current_stock: number; @@ -826,19 +728,14 @@ export type IFlagInventoryItemResponse = { created_by: number; }; -export type IAssetBedResponse = { - count: number; - next: string; - previous: string; - results: { - id: string; - asset_object: Asset; - bed_object: BedObjectModel; - created_date: string; - modified_date: string; - meta: Record; - }[]; -}; +export type IAssetBedResponse = PaginatedResponse<{ + id: string; + asset_object: Asset; + bed_object: BedObjectModel; + created_date: string; + modified_date: string; + meta: Record; +}>; export type IAllPatientRequest = { facility?: string; @@ -853,7 +750,6 @@ export type ICreateTriageRequest = { num_patient_referred?: number; num_patient_confirmed_positive?: number; }; - export type ICreateTriageResponse = { id: string; entry_date: string; From 51b46a6b794f6d37dee00157aef53c4452e83981 Mon Sep 17 00:00:00 2001 From: sriharsh05 Date: Sun, 22 Oct 2023 20:36:37 +0530 Subject: [PATCH 04/10] defined models and replaced any with those models --- src/Components/Facility/FacilityUsers.tsx | 2 +- src/Components/Facility/InventoryLog.tsx | 1 - src/Components/Facility/LegacyFacilityCNS.tsx | 6 +++--- src/Components/Facility/models.tsx | 9 +++++++++ src/Redux/api.tsx | 20 ++++++++++--------- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/Components/Facility/FacilityUsers.tsx b/src/Components/Facility/FacilityUsers.tsx index 46f475c4ff7..4e0859e5c8a 100644 --- a/src/Components/Facility/FacilityUsers.tsx +++ b/src/Components/Facility/FacilityUsers.tsx @@ -151,7 +151,7 @@ export default function FacilityUsers(props: any) { setIsFacilityLoading(true); await request(routes.deleteUserFacility, { // body given in the dispatch call but there is no body in API documentation - body: String(unlinkFacilityData?.facility?.id), + body: { id: String(unlinkFacilityData?.facility?.id) }, pathParams: { username: unlinkFacilityData.userName, }, diff --git a/src/Components/Facility/InventoryLog.tsx b/src/Components/Facility/InventoryLog.tsx index 0de667e4373..d272d47bca2 100644 --- a/src/Components/Facility/InventoryLog.tsx +++ b/src/Components/Facility/InventoryLog.tsx @@ -72,7 +72,6 @@ export default function InventoryLog(props: any) { setSaving(true); // request body is not given in the dispath call const { res } = await request(routes.flagInventoryItem, { - body: {}, pathParams: { facility_external_id: facilityId, external_id: id, diff --git a/src/Components/Facility/LegacyFacilityCNS.tsx b/src/Components/Facility/LegacyFacilityCNS.tsx index ebd68e5e670..f664cc3ff08 100644 --- a/src/Components/Facility/LegacyFacilityCNS.tsx +++ b/src/Components/Facility/LegacyFacilityCNS.tsx @@ -124,8 +124,8 @@ export default function LegacyFacilityCNS({ is_active: true, }, }); - if (res && res.status === 200) { - const patients = data.results as PatientModel[]; + if (res && res.status === 200 && data) { + const patients = data as PatientModel[]; return patients.filter( (patient) => !!patient.last_consultation?.current_bed?.bed_object.id ); @@ -135,7 +135,7 @@ export default function LegacyFacilityCNS({ async function fetchPatientMonitorAsset(patient: PatientModel) { // Request body in API documentation is not matching with request body of dispatch call const { res, data } = await request(routes.listAssetBeds, { - body: `asset-bed-${patient.id}`, + body: { id: `asset-bed-${patient.id}` }, pathParams: { bed: patient.last_consultation?.current_bed?.bed_object?.id || "", }, diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx index 2552d215f16..c4d7731d6c5 100644 --- a/src/Components/Facility/models.tsx +++ b/src/Components/Facility/models.tsx @@ -240,6 +240,10 @@ export type IFacilityNotificationRequest = { message?: string; }; +export type IFacilityNotificationResponse = { + [key: string]: string; +}; + export type IStateListResponse = PaginatedResponse; export type IStateDitrictResponse = StateModel; @@ -355,6 +359,9 @@ export type IUserListFacilityResponse = { pf_auth: string; }; +export type IDeleteUserRequest = { + id?: string; +}; export type IDeleteUserResponse = { detail?: string; }; @@ -737,6 +744,8 @@ export type IAssetBedResponse = PaginatedResponse<{ meta: Record; }>; +export type IAssetBedRequest = IDeleteUserRequest; + export type IAllPatientRequest = { facility?: string; is_active?: boolean; diff --git a/src/Redux/api.tsx b/src/Redux/api.tsx index 075f25c880d..10d70f6d0dd 100644 --- a/src/Redux/api.tsx +++ b/src/Redux/api.tsx @@ -53,7 +53,11 @@ import { IDeleteInventoryLog, ICreateTriageRequest, ICreateTriageResponse, + IDeleteUserRequest, + IAssetBedRequest, + IFacilityNotificationResponse, } from "../Components/Facility/models"; +import { PatientModel } from "../Components/Patient/models"; import { UserModel } from "../Components/Users/models"; import { PaginatedResponse } from "../Utils/request/types"; @@ -150,7 +154,7 @@ const routes = { deleteUserFacility: { path: "/api/v1/users/{username}/delete_facility/", method: "DELETE", - TBody: Type(), + TBody: Type(), TRes: Type(), }, @@ -253,7 +257,7 @@ const routes = { partialUpdateFacility: { path: "/api/v1/facility/{id}/", method: "PATCH", - TBody: Type(), + TBody: Type(), TRes: Type(), }, @@ -294,7 +298,7 @@ const routes = { listAssetBeds: { path: "/api/v1/assetbed/", method: "GET", - TBody: Type(), + TBody: Type(), TRes: Type(), }, createAssetBed: { @@ -373,8 +377,7 @@ const routes = { deleteFacility: { path: "/api/v1/facility/{id}", method: "DELETE", - TRes: Type(), - Tbody: Type(), + TRes: Type(), }, downloadFacility: { @@ -526,7 +529,7 @@ const routes = { patientList: { path: "/api/v1/patient/", TBody: Type(), - TRes: Type(), + TRes: Type(), }, addPatient: { path: "/api/v1/patient/", @@ -534,7 +537,7 @@ const routes = { }, getPatient: { path: "/api/v1/patient/{id}/", - TRes: Type(), + TRes: Type(), }, updatePatient: { path: "/api/v1/patient/{id}/", @@ -719,7 +722,6 @@ const routes = { flagInventoryItem: { path: "/api/v1/facility/{facility_external_id}/inventory/{external_id}/flag/", method: "PUT", - TBody: Type(), TRes: Type(), }, deleteLastInventoryLog: { @@ -812,7 +814,7 @@ const routes = { sendNotificationMessages: { path: "/api/v1/notification/notify/", method: "POST", - TRes: Type(), + TRes: Type(), Tbody: Type(), }, From c0eec3e04b6e0f608f1fe4b2a623d2f6359a7af8 Mon Sep 17 00:00:00 2001 From: sriharsh05 Date: Sun, 22 Oct 2023 22:43:08 +0530 Subject: [PATCH 05/10] defined and reused existing interfaces --- src/Components/Facility/models.tsx | 85 +++++++++++------------------- 1 file changed, 30 insertions(+), 55 deletions(-) diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx index c4d7731d6c5..00076471c59 100644 --- a/src/Components/Facility/models.tsx +++ b/src/Components/Facility/models.tsx @@ -175,16 +175,8 @@ export interface InventoryItemsModel { count?: number; id?: number; name?: string; - default_unit?: { - id: number; - name: string; - }; - allowed_units?: [ - { - id: number; - name: string; - } - ]; + default_unit?: UnitModel; + allowed_units?: UnitModel[]; } export interface LocationModel { @@ -230,6 +222,17 @@ export type ICD11DiagnosisModel = { label: string; }; +export interface BaseRequest { + limit?: number; + offset?: number; +} + +export interface BaseResponse { + id: string; + created_date: string; + modified_date: string; +} + type UnitModel = { id: number; name: string; @@ -386,11 +389,7 @@ export type IUserFacilityRequest = { export type IUserFacilityResponse = IUserListFacilityResponse; -export type IFacilityUserRequest = { - limit?: number; - offset?: number; -}; - +export type IFacilityUserRequest = BaseRequest; export type IFacilityUserResponse = { count: number; next: string | null; @@ -457,10 +456,7 @@ interface InventoryItemObjectModel { min_quantity: number; } -export type IInventorySummaryRequest = { - limit?: number; - offset?: number; -}; +export type IInventorySummaryRequest = BaseRequest; export type IInventorySummaryResponse = PaginatedResponse<{ id: string; item_object: InventoryItemObjectModel; @@ -576,8 +572,7 @@ export type IInvestigationResponse = PaginatedResponse<{ session: number; }>; -interface BedObjectModel { - id: string; +type BedObjectModel = BaseResponse & { bed_type: number; location_object: { id: string; @@ -592,27 +587,21 @@ interface BedObjectModel { location_type: number; }; is_occupied: boolean; - created_date: string; - modified_date: string; name: string; description: string; meta: Record; -} +}; -export type IConsultationBedResponse = { - id: string; +export type IConsultationBedResponse = BaseResponse & { bed_object: BedObjectModel; assets_objects: Asset[]; last_daily_round: string; start_date: string; - created_date: string; - modified_date: string; end_date: string; meta: Record; }; -type Asset = { - id: string; +type Asset = BaseResponse & { status: number; asset_type: number; location_object: { @@ -636,8 +625,6 @@ type Asset = { serviced_on: string; note: string; }; - created_date: string; - modified_date: string; name: string; description: string; asset_class: string; @@ -671,12 +658,9 @@ type ServiceEdit = { note: string; }; -export type ITriageDetailResponse = { - id: string; +export type ITriageDetailResponse = BaseResponse & { entry_date: string; facility: string; - created_date: string; - modified_date: string; num_patients_visited: number; num_patients_home_quarantine: number; num_patients_isolation: number; @@ -684,18 +668,13 @@ export type ITriageDetailResponse = { num_patient_confirmed_positive: number; }; -export type ITriageRequest = { +export type ITriageRequest = BaseRequest & { entry_date_after?: string; entry_date_before?: string; - limit?: number; - offset?: number; }; export type ITriageResponse = PaginatedResponse; -export type IMinQuantityRequest = { - limit?: number; - offset?: number; -}; +export type IMinQuantityRequest = BaseRequest; export type IMinQuantityResponse = PaginatedResponse; export type IMinQuantityItemResponse = { @@ -735,14 +714,13 @@ export type IFlagInventoryItemResponse = { created_by: number; }; -export type IAssetBedResponse = PaginatedResponse<{ - id: string; - asset_object: Asset; - bed_object: BedObjectModel; - created_date: string; - modified_date: string; - meta: Record; -}>; +export type IAssetBedResponse = PaginatedResponse< + BaseResponse & { + asset_object: Asset; + bed_object: BedObjectModel; + meta: Record; + } +>; export type IAssetBedRequest = IDeleteUserRequest; @@ -759,12 +737,9 @@ export type ICreateTriageRequest = { num_patient_referred?: number; num_patient_confirmed_positive?: number; }; -export type ICreateTriageResponse = { - id: string; +export type ICreateTriageResponse = BaseResponse & { entry_date: string; facility: string; - created_date: string; - modified_date: string; num_patients_visited: number; num_patients_home_quarantine: number; num_patients_isolation: number; From ca42eb82796f29cf76dcfaea593db8bedac57940 Mon Sep 17 00:00:00 2001 From: sriharsh05 Date: Fri, 27 Oct 2023 18:24:15 +0530 Subject: [PATCH 06/10] remove unnecessary TBody and models for get requests --- src/Components/Facility/FacilityUsers.tsx | 4 +- src/Components/Facility/HospitalList.tsx | 2 +- src/Components/Facility/InventoryList.tsx | 2 +- src/Components/Facility/InventoryLog.tsx | 2 +- src/Components/Facility/LegacyFacilityCNS.tsx | 4 +- src/Components/Facility/MinQuantityList.tsx | 2 +- src/Components/Facility/SetInventoryForm.tsx | 3 +- src/Components/Facility/TreatmentSummary.tsx | 1 - src/Components/Facility/models.tsx | 90 ++----------------- src/Redux/api.tsx | 66 ++++---------- 10 files changed, 30 insertions(+), 146 deletions(-) diff --git a/src/Components/Facility/FacilityUsers.tsx b/src/Components/Facility/FacilityUsers.tsx index 4e0859e5c8a..51da42b3337 100644 --- a/src/Components/Facility/FacilityUsers.tsx +++ b/src/Components/Facility/FacilityUsers.tsx @@ -80,7 +80,7 @@ export default function FacilityUsers(props: any) { }, [facilityId]); const { res, data, refetch } = useQuery(routes.getFacilityUsers, { - body: { offset: offset, limit: limit }, + query: { offset: offset, limit: limit }, pathParams: { facility_id: facilityId }, }); @@ -151,7 +151,7 @@ export default function FacilityUsers(props: any) { setIsFacilityLoading(true); await request(routes.deleteUserFacility, { // body given in the dispatch call but there is no body in API documentation - body: { id: String(unlinkFacilityData?.facility?.id) }, + // body: { id: String(unlinkFacilityData?.facility?.id) }, pathParams: { username: unlinkFacilityData.userName, }, diff --git a/src/Components/Facility/HospitalList.tsx b/src/Components/Facility/HospitalList.tsx index b9cadbcfc5f..b4ad113a0f8 100644 --- a/src/Components/Facility/HospitalList.tsx +++ b/src/Components/Facility/HospitalList.tsx @@ -50,7 +50,7 @@ export const HospitalList = () => { data: permittedData, refetch: permittedFacilitiesFetch, } = useQuery(routes.getPermittedFacilities, { - body: { + query: { district: qParams.district, district_name: districtName, facility_type: qParams.facility_type, diff --git a/src/Components/Facility/InventoryList.tsx b/src/Components/Facility/InventoryList.tsx index 2608f1de01e..db180f5563c 100644 --- a/src/Components/Facility/InventoryList.tsx +++ b/src/Components/Facility/InventoryList.tsx @@ -24,7 +24,7 @@ export default function InventoryList(props: any) { const limit = 14; const { res, data, refetch } = useQuery(routes.getInventorySummary, { - body: { + query: { limit, offset, }, diff --git a/src/Components/Facility/InventoryLog.tsx b/src/Components/Facility/InventoryLog.tsx index d272d47bca2..2b27e48e74f 100644 --- a/src/Components/Facility/InventoryLog.tsx +++ b/src/Components/Facility/InventoryLog.tsx @@ -29,7 +29,7 @@ export default function InventoryLog(props: any) { const [facilityName, setFacilityName] = useState(""); const { res, data, refetch } = useQuery(routes.getInventoryLog, { - body: { + query: { item: item, limit: limit, name: facilityName, diff --git a/src/Components/Facility/LegacyFacilityCNS.tsx b/src/Components/Facility/LegacyFacilityCNS.tsx index f664cc3ff08..457ae172983 100644 --- a/src/Components/Facility/LegacyFacilityCNS.tsx +++ b/src/Components/Facility/LegacyFacilityCNS.tsx @@ -119,7 +119,7 @@ export default function LegacyFacilityCNS({ async function fetchPatients() { const { res, data } = await request(routes.patientList, { - body: { + query: { facility: facilityId, is_active: true, }, @@ -135,7 +135,7 @@ export default function LegacyFacilityCNS({ async function fetchPatientMonitorAsset(patient: PatientModel) { // Request body in API documentation is not matching with request body of dispatch call const { res, data } = await request(routes.listAssetBeds, { - body: { id: `asset-bed-${patient.id}` }, + query: { id: `asset-bed-${patient.id}` }, pathParams: { bed: patient.last_consultation?.current_bed?.bed_object?.id || "", }, diff --git a/src/Components/Facility/MinQuantityList.tsx b/src/Components/Facility/MinQuantityList.tsx index d091343e041..42ada81027b 100644 --- a/src/Components/Facility/MinQuantityList.tsx +++ b/src/Components/Facility/MinQuantityList.tsx @@ -25,7 +25,7 @@ export default function MinQuantityList(props: any) { const limit = 14; const { res, data, refetch } = useQuery(routes.getMinQuantity, { - body: { + query: { limit: limit, offset: offset, }, diff --git a/src/Components/Facility/SetInventoryForm.tsx b/src/Components/Facility/SetInventoryForm.tsx index 289a574aa92..e9a44050695 100644 --- a/src/Components/Facility/SetInventoryForm.tsx +++ b/src/Components/Facility/SetInventoryForm.tsx @@ -57,7 +57,6 @@ export const SetInventoryForm = (props: any) => { data: minQuantityData, refetch: minQuantityFetch, } = useQuery(routes.getMinQuantity, { - body: {}, pathParams: { id: facilityId, }, @@ -73,7 +72,7 @@ export const SetInventoryForm = (props: any) => { ); } const { res, data } = await request(routes.getItems, { - body: { + query: { limit: limit, offset: offset, }, diff --git a/src/Components/Facility/TreatmentSummary.tsx b/src/Components/Facility/TreatmentSummary.tsx index b70a65b2e60..26299bad021 100644 --- a/src/Components/Facility/TreatmentSummary.tsx +++ b/src/Components/Facility/TreatmentSummary.tsx @@ -44,7 +44,6 @@ const TreatmentSummary = (props: any) => { data: investigationData, refetch: investigationFetch, } = useQuery(routes.getInvestigation, { - body: {}, pathParams: { consultation_external_id: consultationId, }, diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx index 00076471c59..f18ada26042 100644 --- a/src/Components/Facility/models.tsx +++ b/src/Components/Facility/models.tsx @@ -222,11 +222,6 @@ export type ICD11DiagnosisModel = { label: string; }; -export interface BaseRequest { - limit?: number; - offset?: number; -} - export interface BaseResponse { id: string; created_date: string; @@ -248,12 +243,11 @@ export type IFacilityNotificationResponse = { }; export type IStateListResponse = PaginatedResponse; -export type IStateDitrictResponse = StateModel; -export type IDistrictLocalBodyResponse = IStateDitrictResponse & { +export type IDistrictLocalBodyResponse = StateModel & { state: number; }; -export type IWardLocalBodyResponse = IStateDitrictResponse & { +export type IWardLocalBodyResponse = StateModel & { number: number; local_body: number; }; @@ -329,8 +323,6 @@ export type IListDoctorResponse = PaginatedResponse<{ count: number; }>; -export type IListCapacityResponse = PaginatedResponse; - export type IUserListFacilityResponse = { id: number; username: string; @@ -362,15 +354,10 @@ export type IUserListFacilityResponse = { pf_auth: string; }; -export type IDeleteUserRequest = { - id?: string; -}; -export type IDeleteUserResponse = { +export type DeleteModel = { detail?: string; }; -export type IDeleteInventoryLog = IDeleteUserResponse; - export type IUserFacilityRequest = { username?: string; first_name?: string; @@ -389,7 +376,6 @@ export type IUserFacilityRequest = { export type IUserFacilityResponse = IUserListFacilityResponse; -export type IFacilityUserRequest = BaseRequest; export type IFacilityUserResponse = { count: number; next: string | null; @@ -415,38 +401,13 @@ export type IFacilityUserResponse = { }[]; }; -export type IPermittedFacilityRequest = { - district?: number; - district_name?: string; - facility_type?: number; - kasp_empanelled?: boolean; - limit?: number; - local_body?: number; - local_body_name?: string; - name?: string; - offset?: number; - search_text?: string; - state?: number; - state_name?: string; -}; -export type IPermittedFacilityResponse = PaginatedResponse; - -export type IStateResponse = StateModel; -export type IStateRequest = { - id?: number; -}; - -export type IDistrictResponse = IStateResponse; -export type IDistrictRequest = IStateRequest; - -export type ILocalBodyResponse = IStateResponse & { +export type ILocalBodyResponse = StateModel & { body_type: number; localbody_code: string; district: number; }; -export type ILocalBodyRequest = IStateRequest; -interface InventoryItemObjectModel { +export interface InventoryItemObjectModel { id: number; default_unit: UnitModel; allowed_units: UnitModel[]; @@ -456,7 +417,6 @@ interface InventoryItemObjectModel { min_quantity: number; } -export type IInventorySummaryRequest = BaseRequest; export type IInventorySummaryResponse = PaginatedResponse<{ id: string; item_object: InventoryItemObjectModel; @@ -467,12 +427,6 @@ export type IInventorySummaryResponse = PaginatedResponse<{ item: number; }>; -export type IInventoryLogRequest = { - item?: number; - limit?: number; - name?: string; - offset?: number; -}; export type IInventoryLogResponse = Omit< IInventorySummaryResponse, "results" @@ -532,17 +486,6 @@ export type IPatientTransferResponse = { facility_object: FacilityObjectModel; }; -export type IInvestigationRequest = { - created_date_after?: string; - created_date_before?: string; - investigation?: string; - investigations?: string; - modified_date_after?: string; - modified_date_before?: string; - page?: number; - session?: string; - sessions?: string; -}; export type IInvestigationResponse = PaginatedResponse<{ id: string; group_object: { @@ -668,15 +611,6 @@ export type ITriageDetailResponse = BaseResponse & { num_patient_confirmed_positive: number; }; -export type ITriageRequest = BaseRequest & { - entry_date_after?: string; - entry_date_before?: string; -}; -export type ITriageResponse = PaginatedResponse; - -export type IMinQuantityRequest = BaseRequest; -export type IMinQuantityResponse = PaginatedResponse; - export type IMinQuantityItemResponse = { id: string; item_object: InventoryItemObjectModel; @@ -685,13 +619,6 @@ export type IMinQuantityItemResponse = { item: number; }; -export type IItemRequest = { - limit?: number; - name?: number; - offset?: number; -}; -export type IItemResponse = PaginatedResponse; - export type ISetMinQuantityRequest = { min_quantity?: number; item?: number; @@ -722,13 +649,6 @@ export type IAssetBedResponse = PaginatedResponse< } >; -export type IAssetBedRequest = IDeleteUserRequest; - -export type IAllPatientRequest = { - facility?: string; - is_active?: boolean; -}; - export type ICreateTriageRequest = { entry_date?: string; num_patients_visited?: number; diff --git a/src/Redux/api.tsx b/src/Redux/api.tsx index 10d70f6d0dd..18b48aeb799 100644 --- a/src/Redux/api.tsx +++ b/src/Redux/api.tsx @@ -2,60 +2,40 @@ import { IConfig } from "../Common/hooks/useConfig"; import { AssetData } from "../Components/Assets/AssetTypes"; import { IUserFacilityRequest, - IDeleteUserResponse, IFacilityNotificationRequest, IFacilityRequest, IFacilityResponse, - IListCapacityResponse, IListDoctorResponse, IUserListFacilityResponse, LocationModel, IUserFacilityResponse, IAllFacilitiesResponse, - IFacilityUserRequest, IFacilityUserResponse, - IPermittedFacilityRequest, - IPermittedFacilityResponse, - IStateResponse, - IStateRequest, - IDistrictRequest, - IDistrictResponse, - ILocalBodyRequest, ILocalBodyResponse, - IInventorySummaryRequest, IInventorySummaryResponse, - IInventoryLogRequest, IInventoryLogResponse, IFaciclityMinimumQuantityResponse, IFaciclityMinimumQuantityRequest, IPatientTransferRequest, IPatientTransferResponse, IInvestigationResponse, - IInvestigationRequest, IConsultationBedResponse, ITriageDetailResponse, - ITriageRequest, - ITriageResponse, - IMinQuantityRequest, - IMinQuantityResponse, IMinQuantityItemResponse, - IItemRequest, - IItemResponse, ISetMinQuantityRequest, ISetMinQuantityResponse, IFlagInventoryItemResponse, IAssetBedResponse, IStateListResponse, - IStateDitrictResponse, IDistrictLocalBodyResponse, IWardLocalBodyResponse, - IAllPatientRequest, - IDeleteInventoryLog, ICreateTriageRequest, ICreateTriageResponse, - IDeleteUserRequest, - IAssetBedRequest, IFacilityNotificationResponse, + CapacityModal, + StateModel, + InventoryItemObjectModel, + DeleteModel, } from "../Components/Facility/models"; import { PatientModel } from "../Components/Patient/models"; import { UserModel } from "../Components/Users/models"; @@ -154,8 +134,7 @@ const routes = { deleteUserFacility: { path: "/api/v1/users/{username}/delete_facility/", method: "DELETE", - TBody: Type(), - TRes: Type(), + TRes: Type(), }, clearHomeFacility: { @@ -187,7 +166,7 @@ const routes = { deleteUser: { path: "/api/v1/users/{username}", method: "DELETE", - TRes: Type(), + TRes: Type(), }, addUser: { @@ -222,8 +201,7 @@ const routes = { getPermittedFacilities: { path: "/api/v1/facility/", - TBody: Type(), - TRes: Type(), + TRes: Type>(), }, getAllFacilities: { @@ -268,7 +246,6 @@ const routes = { getFacilityUsers: { path: "/api/v1/facility/{facility_id}/get_users/", - TBody: Type(), TRes: Type(), }, @@ -298,7 +275,6 @@ const routes = { listAssetBeds: { path: "/api/v1/assetbed/", method: "GET", - TBody: Type(), TRes: Type(), }, createAssetBed: { @@ -377,7 +353,7 @@ const routes = { deleteFacility: { path: "/api/v1/facility/{id}", method: "DELETE", - TRes: Type(), + TRes: Type(), }, downloadFacility: { @@ -462,7 +438,7 @@ const routes = { getCapacity: { path: "/api/v1/facility/{facilityId}/capacity/", - TRes: Type(), + TRes: Type>(), }, getCapacityBed: { @@ -506,8 +482,7 @@ const routes = { }, getTriage: { path: "/api/v1/facility/{facilityId}/patient_stats/", - TBody: Type(), - TRes: Type(), + TRes: Type>(), }, getTriageDetails: { @@ -528,7 +503,6 @@ const routes = { }, patientList: { path: "/api/v1/patient/", - TBody: Type(), TRes: Type(), }, addPatient: { @@ -607,20 +581,18 @@ const routes = { getState: { path: "/api/v1/state/{id}/", - TBody: Type(), - TRes: Type(), + TRes: Type(), }, // Districts getDistrict: { path: "/api/v1/district/{id}/", - TBody: Type(), - TRes: Type(), + TRes: Type(), }, getDistrictByState: { path: "/api/v1/state/{id}/districts/", - TRes: Type(), + TRes: Type(), }, getDistrictByName: { path: "/api/v1/district/", @@ -636,7 +608,6 @@ const routes = { // Local Body getLocalBody: { path: "/api/v1/local_body/{id}/", - TBody: Type(), TRes: Type(), }, getAllLocalBody: { @@ -673,8 +644,7 @@ const routes = { //inventory getItems: { path: "/api/v1/items/", - TBody: Type(), - TRes: Type(), + TRes: Type>(), }, createInventory: { path: "/api/v1/facility/{facilityId}/inventory/", @@ -682,7 +652,6 @@ const routes = { }, getInventoryLog: { path: "/api/v1/facility/{id}/inventory/", - TBody: Type(), TRes: Type(), }, setMinQuantity: { @@ -694,8 +663,7 @@ const routes = { getMinQuantity: { path: "/api/v1/facility/{id}/min_quantity/", method: "GET", - TBody: Type(), - TRes: Type(), + TRes: Type>(), }, getMinQuantityOfItem: { @@ -712,7 +680,6 @@ const routes = { getInventorySummary: { path: "/api/v1/facility/{id}/inventorysummary/", method: "GET", - TBody: Type(), TRes: Type(), }, getItemName: { @@ -727,7 +694,7 @@ const routes = { deleteLastInventoryLog: { path: "/api/v1/facility/{facility_external_id}/inventory/delete_last/?item={id}", method: "DELETE", - TRes: Type(), + TRes: Type(), }, dischargeSummaryGenerate: { path: "/api/v1/consultation/{external_id}/generate_discharge_summary/", @@ -856,7 +823,6 @@ const routes = { getInvestigation: { path: "/api/v1/consultation/{consultation_external_id}/investigation/", method: "GET", - TBody: Type(), TRes: Type(), }, getPatientInvestigation: { From 72e5b27e138587331973d36c2c45401b878e88ad Mon Sep 17 00:00:00 2001 From: sriharsh05 Date: Mon, 30 Oct 2023 22:57:42 +0530 Subject: [PATCH 07/10] remove redundant models --- package-lock.json | 16 -------- src/Components/Facility/FacilityCreate.tsx | 6 +-- src/Components/Facility/models.tsx | 46 +++++++--------------- src/Redux/api.tsx | 17 ++++---- 4 files changed, 25 insertions(+), 60 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4871fbe374b..2a9fe3f520f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14496,8 +14496,6 @@ }, "node_modules/npm/node_modules/cross-spawn/node_modules/which": { "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, "inBundle": true, "license": "ISC", @@ -15254,8 +15252,6 @@ }, "node_modules/npm/node_modules/minipass": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", - "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", "dev": true, "inBundle": true, "license": "ISC", @@ -16398,8 +16394,6 @@ }, "node_modules/npm/node_modules/tar": { "version": "6.1.15", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.15.tgz", - "integrity": "sha512-/zKt9UyngnxIT/EAGYuxaMYgOIJiP81ab9ZfkILq4oNLPFX50qyYmu7jRj9qeXoxmJHjGlbH0+cm2uy1WCs10A==", "dev": true, "inBundle": true, "license": "ISC", @@ -16500,8 +16494,6 @@ }, "node_modules/npm/node_modules/util-deprecate": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true, "inBundle": true, "license": "MIT" @@ -16569,8 +16561,6 @@ }, "node_modules/npm/node_modules/wrap-ansi": { "version": "8.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", - "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", "dev": true, "inBundle": true, "license": "MIT", @@ -16589,8 +16579,6 @@ "node_modules/npm/node_modules/wrap-ansi-cjs": { "name": "wrap-ansi", "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, "inBundle": true, "license": "MIT", @@ -16670,8 +16658,6 @@ }, "node_modules/npm/node_modules/wrappy": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true, "inBundle": true, "license": "ISC" @@ -16691,8 +16677,6 @@ }, "node_modules/npm/node_modules/yallist": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true, "inBundle": true, "license": "ISC" diff --git a/src/Components/Facility/FacilityCreate.tsx b/src/Components/Facility/FacilityCreate.tsx index 88b55debfa7..6be883b7031 100644 --- a/src/Components/Facility/FacilityCreate.tsx +++ b/src/Components/Facility/FacilityCreate.tsx @@ -259,9 +259,9 @@ export const FacilityCreate = (props: FacilityProps) => { setIsWardLoading(true); if (wardsData) { const updatedWards = { - id: wardsData.id, - name: wardsData.name, - number: wardsData.number, + id: wardsData.results[0].id, + name: wardsData.results[0].name, + number: wardsData.results[0].number, }; setWard([updatedWards]); } diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx index f18ada26042..d1bc96144d7 100644 --- a/src/Components/Facility/models.tsx +++ b/src/Components/Facility/models.tsx @@ -247,10 +247,6 @@ export type IStateListResponse = PaginatedResponse; export type IDistrictLocalBodyResponse = StateModel & { state: number; }; -export type IWardLocalBodyResponse = StateModel & { - number: number; - local_body: number; -}; export type IFacilityRequest = Omit< FacilityModel, @@ -275,10 +271,20 @@ export type IFacilityRequest = Omit< longitude?: string; phone_number?: string | undefined; }; -export type IFacilityResponse = Omit< - IAllFacilitiesResponse, - "facility_type" -> & { +export type IFacilityResponse = { + id: string; + name: string; + local_body: number; + district: number; + state: number; + ward_object: WardModel; + local_body_object: { id: number } & LocalBodyModel; + district_object: DistrictModel; + state_object: StateModel; + read_cover_image_url: string; + features: number[]; + patient_count: string; + bed_count: string; ward: number; facility_type: number; address: string; @@ -299,22 +305,6 @@ export type IFacilityResponse = Omit< expected_type_c_cylinders: number; expected_type_d_cylinders: number; }; -export type IAllFacilitiesResponse = { - id: string; - name: string; - local_body: number; - district: number; - state: number; - ward_object: WardModel; - local_body_object: { id: number } & LocalBodyModel; - district_object: DistrictModel; - state_object: StateModel; - facility_type: string; - read_cover_image_url: string; - features: number[]; - patient_count: string; - bed_count: string; -}; export type IListDoctorResponse = PaginatedResponse<{ id: string; @@ -641,14 +631,6 @@ export type IFlagInventoryItemResponse = { created_by: number; }; -export type IAssetBedResponse = PaginatedResponse< - BaseResponse & { - asset_object: Asset; - bed_object: BedObjectModel; - meta: Record; - } ->; - export type ICreateTriageRequest = { entry_date?: string; num_patients_visited?: number; diff --git a/src/Redux/api.tsx b/src/Redux/api.tsx index 18b48aeb799..15b89e2a1a7 100644 --- a/src/Redux/api.tsx +++ b/src/Redux/api.tsx @@ -1,5 +1,5 @@ import { IConfig } from "../Common/hooks/useConfig"; -import { AssetData } from "../Components/Assets/AssetTypes"; +import { AssetBedModel, AssetData } from "../Components/Assets/AssetTypes"; import { IUserFacilityRequest, IFacilityNotificationRequest, @@ -9,7 +9,6 @@ import { IUserListFacilityResponse, LocationModel, IUserFacilityResponse, - IAllFacilitiesResponse, IFacilityUserResponse, ILocalBodyResponse, IInventorySummaryResponse, @@ -25,10 +24,8 @@ import { ISetMinQuantityRequest, ISetMinQuantityResponse, IFlagInventoryItemResponse, - IAssetBedResponse, IStateListResponse, IDistrictLocalBodyResponse, - IWardLocalBodyResponse, ICreateTriageRequest, ICreateTriageResponse, IFacilityNotificationResponse, @@ -36,6 +33,8 @@ import { StateModel, InventoryItemObjectModel, DeleteModel, + FacilityModel, + WardModel, } from "../Components/Facility/models"; import { PatientModel } from "../Components/Patient/models"; import { UserModel } from "../Components/Users/models"; @@ -222,7 +221,7 @@ const routes = { getAnyFacility: { path: "/api/v1/getallfacilities/{id}/", - TRes: Type(), + TRes: Type(), }, updateFacility: { @@ -235,8 +234,8 @@ const routes = { partialUpdateFacility: { path: "/api/v1/facility/{id}/", method: "PATCH", - TBody: Type(), - TRes: Type(), + TBody: Type(), + TRes: Type(), }, deleteFacilityCoverImage: { @@ -275,7 +274,7 @@ const routes = { listAssetBeds: { path: "/api/v1/assetbed/", method: "GET", - TRes: Type(), + TRes: Type>(), }, createAssetBed: { path: "/api/v1/assetbed/", @@ -626,7 +625,7 @@ const routes = { }, getWardByLocalBody: { path: "/api/v1/ward/?local_body={id}", - TRes: Type(), + TRes: Type>(), }, // Sample Test From 1abf2c9719ad976b11e1737f4f1ca04d037b8a57 Mon Sep 17 00:00:00 2001 From: sriharsh05 Date: Tue, 31 Oct 2023 12:52:18 +0530 Subject: [PATCH 08/10] add missing properties to objects --- package-lock.json | 288 +++--------------- src/Components/Facility/HospitalList.tsx | 3 + src/Components/Facility/LegacyFacilityCNS.tsx | 28 +- 3 files changed, 56 insertions(+), 263 deletions(-) diff --git a/package-lock.json b/package-lock.json index 29d2abb713f..80e47519f87 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14826,6 +14826,8 @@ }, "node_modules/npm/node_modules/@isaacs/cliui/node_modules/string-width": { "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", "dev": true, "inBundle": true, "license": "MIT", @@ -14860,8 +14862,6 @@ }, "node_modules/npm/node_modules/@isaacs/string-locale-compare": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@isaacs/string-locale-compare/-/string-locale-compare-1.1.0.tgz", - "integrity": "sha512-SQ7Kzhh9+D+ZW9MA0zkYv3VXhIDNx+LzM6EJ+/65I3QY+enU6Itte7E5XX7EWrqLW2FN4n06GWzBnPoC3th2aQ==", "dev": true, "inBundle": true, "license": "ISC" @@ -14934,8 +14934,6 @@ }, "node_modules/npm/node_modules/@npmcli/disparity-colors": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@npmcli/disparity-colors/-/disparity-colors-3.0.0.tgz", - "integrity": "sha512-5R/z157/f20Fi0Ou4ZttL51V0xz0EdPEOauFtPCEYOLInDBRCj1/TxOJ5aGTrtShxEshN2d+hXb9ZKSi5RLBcg==", "dev": true, "inBundle": true, "license": "ISC", @@ -14948,8 +14946,6 @@ }, "node_modules/npm/node_modules/@npmcli/fs": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-3.1.0.tgz", - "integrity": "sha512-7kZUAaLscfgbwBQRbvdMYaZOWyMEcPTH/tJjnyAWJ/dvvs9Ef+CERx/qJb9GExJpl1qipaDGn7KqHnFGGixd0w==", "dev": true, "inBundle": true, "license": "ISC", @@ -14962,8 +14958,6 @@ }, "node_modules/npm/node_modules/@npmcli/git": { "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@npmcli/git/-/git-4.1.0.tgz", - "integrity": "sha512-9hwoB3gStVfa0N31ymBmrX+GuDGdVA/QWShZVqE0HK2Af+7QGGrCTbZia/SW0ImUTjTne7SP91qxDmtXvDHRPQ==", "dev": true, "inBundle": true, "license": "ISC", @@ -14983,8 +14977,6 @@ }, "node_modules/npm/node_modules/@npmcli/installed-package-contents": { "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@npmcli/installed-package-contents/-/installed-package-contents-2.0.2.tgz", - "integrity": "sha512-xACzLPhnfD51GKvTOOuNX2/V4G4mz9/1I2MfDoye9kBM3RYe5g2YbscsaGoTlaWqkxeiapBWyseULVKpSVHtKQ==", "dev": true, "inBundle": true, "license": "ISC", @@ -15001,8 +14993,6 @@ }, "node_modules/npm/node_modules/@npmcli/map-workspaces": { "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@npmcli/map-workspaces/-/map-workspaces-3.0.4.tgz", - "integrity": "sha512-Z0TbvXkRbacjFFLpVpV0e2mheCh+WzQpcqL+4xp49uNJOxOnIAPZyXtUxZ5Qn3QBTGKA11Exjd9a5411rBrhDg==", "dev": true, "inBundle": true, "license": "ISC", @@ -15018,8 +15008,6 @@ }, "node_modules/npm/node_modules/@npmcli/metavuln-calculator": { "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@npmcli/metavuln-calculator/-/metavuln-calculator-5.0.1.tgz", - "integrity": "sha512-qb8Q9wIIlEPj3WeA1Lba91R4ZboPL0uspzV0F9uwP+9AYMVB2zOoa7Pbk12g6D2NHAinSbHh6QYmGuRyHZ874Q==", "dev": true, "inBundle": true, "license": "ISC", @@ -15035,8 +15023,6 @@ }, "node_modules/npm/node_modules/@npmcli/name-from-folder": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@npmcli/name-from-folder/-/name-from-folder-2.0.0.tgz", - "integrity": "sha512-pwK+BfEBZJbKdNYpHHRTNBwBoqrN/iIMO0AiGvYsp3Hoaq0WbgGSWQR6SCldZovoDpY3yje5lkFUe6gsDgJ2vg==", "dev": true, "inBundle": true, "license": "ISC", @@ -15046,8 +15032,6 @@ }, "node_modules/npm/node_modules/@npmcli/node-gyp": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@npmcli/node-gyp/-/node-gyp-3.0.0.tgz", - "integrity": "sha512-gp8pRXC2oOxu0DUE1/M3bYtb1b3/DbJ5aM113+XJBgfXdussRAsX0YOrOhdd8WvnAR6auDBvJomGAkLKA5ydxA==", "dev": true, "inBundle": true, "license": "ISC", @@ -15057,8 +15041,6 @@ }, "node_modules/npm/node_modules/@npmcli/package-json": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-4.0.1.tgz", - "integrity": "sha512-lRCEGdHZomFsURroh522YvA/2cVb9oPIJrjHanCJZkiasz1BzcnLr3tBJhlV7S86MBJBuAQ33is2D60YitZL2Q==", "dev": true, "inBundle": true, "license": "ISC", @@ -15077,8 +15059,6 @@ }, "node_modules/npm/node_modules/@npmcli/promise-spawn": { "version": "6.0.2", - "resolved": "https://registry.npmjs.org/@npmcli/promise-spawn/-/promise-spawn-6.0.2.tgz", - "integrity": "sha512-gGq0NJkIGSwdbUt4yhdF8ZrmkGKVz9vAdVzpOfnom+V8PLSmSOVhZwbNvZZS1EYcJN5hzzKBxmmVVAInM6HQLg==", "dev": true, "inBundle": true, "license": "ISC", @@ -15103,8 +15083,6 @@ }, "node_modules/npm/node_modules/@npmcli/run-script": { "version": "6.0.2", - "resolved": "https://registry.npmjs.org/@npmcli/run-script/-/run-script-6.0.2.tgz", - "integrity": "sha512-NCcr1uQo1k5U+SYlnIrbAh3cxy+OQT1VtqiAbxdymSlptbzBb62AjH2xXgjNCoP073hoa1CfCAcwoZ8k96C4nA==", "dev": true, "inBundle": true, "license": "ISC", @@ -15155,8 +15133,6 @@ }, "node_modules/npm/node_modules/@tootallnate/once": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz", - "integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==", "dev": true, "inBundle": true, "license": "MIT", @@ -15166,8 +15142,6 @@ }, "node_modules/npm/node_modules/@tufjs/canonical-json": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@tufjs/canonical-json/-/canonical-json-1.0.0.tgz", - "integrity": "sha512-QTnf++uxunWvG2z3UFNzAoQPHxnSXOwtaI3iJ+AohhV+5vONuArPjJE7aPXPVXfXJsqrVbZBu9b81AJoSd09IQ==", "dev": true, "inBundle": true, "license": "MIT", @@ -15177,8 +15151,6 @@ }, "node_modules/npm/node_modules/@tufjs/models": { "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@tufjs/models/-/models-1.0.4.tgz", - "integrity": "sha512-qaGV9ltJP0EO25YfFUPhxRVK0evXFIAGicsVXuRim4Ed9cjPxYhNnNJ49SFmbeLgtxpslIkX317IgpfcHPVj/A==", "dev": true, "inBundle": true, "license": "MIT", @@ -15192,8 +15164,6 @@ }, "node_modules/npm/node_modules/abbrev": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-2.0.0.tgz", - "integrity": "sha512-6/mh1E2u2YgEsCHdY0Yx5oW+61gZU+1vXaoiHHrpKeuRNNgFvS+/jrwHiQhB5apAf5oB7UB7E19ol2R2LKH8hQ==", "dev": true, "inBundle": true, "license": "ISC", @@ -15203,8 +15173,6 @@ }, "node_modules/npm/node_modules/abort-controller": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", - "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", "dev": true, "inBundle": true, "license": "MIT", @@ -15296,8 +15264,6 @@ }, "node_modules/npm/node_modules/archy": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", - "integrity": "sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw==", "dev": true, "inBundle": true, "license": "MIT" @@ -15362,8 +15328,6 @@ }, "node_modules/npm/node_modules/binary-extensions": { "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", "dev": true, "inBundle": true, "license": "MIT", @@ -15384,8 +15348,6 @@ }, "node_modules/npm/node_modules/buffer": { "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", "dev": true, "funding": [ { @@ -15410,8 +15372,6 @@ }, "node_modules/npm/node_modules/builtins": { "version": "5.0.1", - "resolved": "https://registry.npmjs.org/builtins/-/builtins-5.0.1.tgz", - "integrity": "sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==", "dev": true, "inBundle": true, "license": "MIT", @@ -15444,8 +15404,6 @@ }, "node_modules/npm/node_modules/chalk": { "version": "5.3.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", - "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", "dev": true, "inBundle": true, "license": "MIT", @@ -15469,8 +15427,6 @@ }, "node_modules/npm/node_modules/ci-info": { "version": "3.8.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", - "integrity": "sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==", "dev": true, "funding": [ { @@ -15486,8 +15442,6 @@ }, "node_modules/npm/node_modules/cidr-regex": { "version": "3.1.1", - "resolved": "https://registry.npmjs.org/cidr-regex/-/cidr-regex-3.1.1.tgz", - "integrity": "sha512-RBqYd32aDwbCMFJRL6wHOlDNYJsPNTt8vC82ErHF5vKt8QQzxm1FrkW8s/R5pVrXMf17sba09Uoy91PKiddAsw==", "dev": true, "inBundle": true, "license": "BSD-2-Clause", @@ -15511,8 +15465,6 @@ }, "node_modules/npm/node_modules/cli-columns": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/cli-columns/-/cli-columns-4.0.0.tgz", - "integrity": "sha512-XW2Vg+w+L9on9wtwKpyzluIPCWXjaBahI7mTcYjx+BVIYD9c3yqcv/yKC7CmdCZat4rq2yiE1UMSJC5ivKfMtQ==", "dev": true, "inBundle": true, "license": "MIT", @@ -15526,8 +15478,6 @@ }, "node_modules/npm/node_modules/cli-table3": { "version": "0.6.3", - "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.3.tgz", - "integrity": "sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg==", "dev": true, "inBundle": true, "license": "MIT", @@ -15554,8 +15504,6 @@ }, "node_modules/npm/node_modules/cmd-shim": { "version": "6.0.1", - "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-6.0.1.tgz", - "integrity": "sha512-S9iI9y0nKR4hwEQsVWpyxld/6kRfGepGfzff83FcaiEBpmvlbA2nnGe7Cylgrx2f/p1P5S5wpRm9oL8z1PbS3Q==", "dev": true, "inBundle": true, "license": "ISC", @@ -15587,8 +15535,6 @@ }, "node_modules/npm/node_modules/color-support": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", - "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", "dev": true, "inBundle": true, "license": "ISC", @@ -15598,8 +15544,6 @@ }, "node_modules/npm/node_modules/columnify": { "version": "1.6.0", - "resolved": "https://registry.npmjs.org/columnify/-/columnify-1.6.0.tgz", - "integrity": "sha512-lomjuFZKfM6MSAnV9aCZC9sc0qGbmZdfygNv+nCpqVkSKdCxCklLtd16O0EILGkImHw9ZpHkAnHaB+8Zxq5W6Q==", "dev": true, "inBundle": true, "license": "MIT", @@ -15613,8 +15557,6 @@ }, "node_modules/npm/node_modules/common-ancestor-path": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/common-ancestor-path/-/common-ancestor-path-1.0.1.tgz", - "integrity": "sha512-L3sHRo1pXXEqX8VU28kfgUY+YGsk09hPqZiZmLacNib6XNTCM8ubYeT7ryXQw8asB1sKgcU5lkB7ONug08aB8w==", "dev": true, "inBundle": true, "license": "ISC" @@ -15653,6 +15595,8 @@ }, "node_modules/npm/node_modules/cross-spawn/node_modules/which": { "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, "inBundle": true, "license": "ISC", @@ -15701,6 +15645,8 @@ }, "node_modules/npm/node_modules/debug/node_modules/ms": { "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true, "inBundle": true, "license": "MIT" @@ -15738,8 +15684,6 @@ }, "node_modules/npm/node_modules/diff": { "version": "5.1.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz", - "integrity": "sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==", "dev": true, "inBundle": true, "license": "BSD-3-Clause", @@ -15765,8 +15709,6 @@ }, "node_modules/npm/node_modules/encoding": { "version": "0.1.13", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", - "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", "dev": true, "inBundle": true, "license": "MIT", @@ -15777,8 +15719,6 @@ }, "node_modules/npm/node_modules/env-paths": { "version": "2.2.1", - "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", - "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", "dev": true, "inBundle": true, "license": "MIT", @@ -15788,16 +15728,12 @@ }, "node_modules/npm/node_modules/err-code": { "version": "2.0.3", - "resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz", - "integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==", "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/event-target-shim": { "version": "5.0.1", - "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", - "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", "dev": true, "inBundle": true, "license": "MIT", @@ -15818,16 +15754,12 @@ }, "node_modules/npm/node_modules/exponential-backoff": { "version": "3.1.1", - "resolved": "https://registry.npmjs.org/exponential-backoff/-/exponential-backoff-3.1.1.tgz", - "integrity": "sha512-dX7e/LHVJ6W3DE1MHWi9S1EYzDESENfLrYohG2G++ovZrYOkm4Knwa0mc1cn84xJOR4KEU0WSchhLbd0UklbHw==", "dev": true, "inBundle": true, "license": "Apache-2.0" }, "node_modules/npm/node_modules/fastest-levenshtein": { "version": "1.0.16", - "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz", - "integrity": "sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==", "dev": true, "inBundle": true, "license": "MIT", @@ -15883,8 +15815,6 @@ }, "node_modules/npm/node_modules/gauge": { "version": "5.0.1", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-5.0.1.tgz", - "integrity": "sha512-CmykPMJGuNan/3S4kZOpvvPYSNqSHANiWnh9XcMU2pSjtBfF0XzZ2p1bFAxTbnFxyBuPxQYHhzwaoOmUdqzvxQ==", "dev": true, "inBundle": true, "license": "ISC", @@ -15926,8 +15856,6 @@ }, "node_modules/npm/node_modules/graceful-fs": { "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", "dev": true, "inBundle": true, "license": "ISC" @@ -15956,8 +15884,6 @@ }, "node_modules/npm/node_modules/hosted-git-info": { "version": "6.1.1", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-6.1.1.tgz", - "integrity": "sha512-r0EI+HBMcXadMrugk0GCQ+6BQV39PiWAZVfq7oIckeGiN7sjRGyQxPdft3nQekFTCQbYxLBH+/axZMeH8UX6+w==", "dev": true, "inBundle": true, "license": "ISC", @@ -15970,16 +15896,12 @@ }, "node_modules/npm/node_modules/http-cache-semantics": { "version": "4.1.1", - "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz", - "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==", "dev": true, "inBundle": true, "license": "BSD-2-Clause" }, "node_modules/npm/node_modules/http-proxy-agent": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz", - "integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==", "dev": true, "inBundle": true, "license": "MIT", @@ -16009,8 +15931,6 @@ }, "node_modules/npm/node_modules/humanize-ms": { "version": "1.2.1", - "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", - "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", "dev": true, "inBundle": true, "license": "MIT", @@ -16020,8 +15940,6 @@ }, "node_modules/npm/node_modules/iconv-lite": { "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", "dev": true, "inBundle": true, "license": "MIT", @@ -16035,8 +15953,6 @@ }, "node_modules/npm/node_modules/ieee754": { "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", "dev": true, "funding": [ { @@ -16057,8 +15973,6 @@ }, "node_modules/npm/node_modules/ignore-walk": { "version": "6.0.3", - "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-6.0.3.tgz", - "integrity": "sha512-C7FfFoTA+bI10qfeydT8aZbvr91vAEU+2W5BZUlzPec47oNb07SsOfwYrtxuvOYdUApPP/Qlh4DtAO51Ekk2QA==", "dev": true, "inBundle": true, "license": "ISC", @@ -16113,8 +16027,6 @@ }, "node_modules/npm/node_modules/ini": { "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ini/-/ini-4.1.1.tgz", - "integrity": "sha512-QQnnxNyfvmHFIsj7gkPcYymR8Jdw/o7mp5ZFihxn6h8Ci6fh3Dx4E1gPjpQEpIuPo9XVNY/ZUwh4BPMjGyL01g==", "dev": true, "inBundle": true, "license": "ISC", @@ -16124,8 +16036,6 @@ }, "node_modules/npm/node_modules/init-package-json": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-5.0.0.tgz", - "integrity": "sha512-kBhlSheBfYmq3e0L1ii+VKe3zBTLL5lDCDWR+f9dLmEGSB3MqLlMlsolubSsyI88Bg6EA+BIMlomAnQ1SwgQBw==", "dev": true, "inBundle": true, "license": "ISC", @@ -16152,8 +16062,6 @@ }, "node_modules/npm/node_modules/ip-regex": { "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-4.3.0.tgz", - "integrity": "sha512-B9ZWJxHHOHUhUjCPrMpLD4xEq35bUTClHM1S6CBU5ixQnkZmwipwgc96vAd7AAGM9TGHvJR+Uss+/Ak6UphK+Q==", "dev": true, "inBundle": true, "license": "MIT", @@ -16163,8 +16071,6 @@ }, "node_modules/npm/node_modules/is-cidr": { "version": "4.0.2", - "resolved": "https://registry.npmjs.org/is-cidr/-/is-cidr-4.0.2.tgz", - "integrity": "sha512-z4a1ENUajDbEl/Q6/pVBpTR1nBjjEE1X7qb7bmWYanNnPoKAvUCPFKeXV6Fe4mgTkWKBqiHIcwsI3SndiO5FeA==", "dev": true, "inBundle": true, "license": "BSD-2-Clause", @@ -16200,8 +16106,6 @@ }, "node_modules/npm/node_modules/is-lambda": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-lambda/-/is-lambda-1.0.1.tgz", - "integrity": "sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ==", "dev": true, "inBundle": true, "license": "MIT" @@ -16234,8 +16138,6 @@ }, "node_modules/npm/node_modules/json-parse-even-better-errors": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-3.0.0.tgz", - "integrity": "sha512-iZbGHafX/59r39gPwVPRBGw0QQKnA7tte5pSMrhWOW7swGsVvVTjmfyAV9pNqk8YGT7tRCdxRu8uzcgZwoDooA==", "dev": true, "inBundle": true, "license": "MIT", @@ -16245,8 +16147,6 @@ }, "node_modules/npm/node_modules/json-stringify-nice": { "version": "1.1.4", - "resolved": "https://registry.npmjs.org/json-stringify-nice/-/json-stringify-nice-1.1.4.tgz", - "integrity": "sha512-5Z5RFW63yxReJ7vANgW6eZFGWaQvnPE3WNmZoOJrSkGju2etKA2L5rrOa1sm877TVTFt57A80BH1bArcmlLfPw==", "dev": true, "inBundle": true, "license": "ISC", @@ -16256,8 +16156,6 @@ }, "node_modules/npm/node_modules/jsonparse": { "version": "1.3.1", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==", "dev": true, "engines": [ "node >= 0.2.0" @@ -16267,24 +16165,18 @@ }, "node_modules/npm/node_modules/just-diff": { "version": "6.0.2", - "resolved": "https://registry.npmjs.org/just-diff/-/just-diff-6.0.2.tgz", - "integrity": "sha512-S59eriX5u3/QhMNq3v/gm8Kd0w8OS6Tz2FS1NG4blv+z0MuQcBRJyFWjdovM0Rad4/P4aUPFtnkNjMjyMlMSYA==", "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/just-diff-apply": { "version": "5.5.0", - "resolved": "https://registry.npmjs.org/just-diff-apply/-/just-diff-apply-5.5.0.tgz", - "integrity": "sha512-OYTthRfSh55WOItVqwpefPtNt2VdKsq5AnAK6apdtR6yCH8pr0CmSr710J0Mf+WdQy7K/OzMy7K2MgAfdQURDw==", "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/libnpmaccess": { "version": "7.0.2", - "resolved": "https://registry.npmjs.org/libnpmaccess/-/libnpmaccess-7.0.2.tgz", - "integrity": "sha512-vHBVMw1JFMTgEk15zRsJuSAg7QtGGHpUSEfnbcRL1/gTBag9iEfJbyjpDmdJmwMhvpoLoNBtdAUCdGnaP32hhw==", "dev": true, "inBundle": true, "license": "ISC", @@ -16352,8 +16244,6 @@ }, "node_modules/npm/node_modules/libnpmhook": { "version": "9.0.3", - "resolved": "https://registry.npmjs.org/libnpmhook/-/libnpmhook-9.0.3.tgz", - "integrity": "sha512-wMZe58sI7KLhg0+nUWZW5KdMfjNNcOIIbkoP19BDHYoUF9El7eeUWkGNxUGzpHkPKiGoQ1z/v6CYin4deebeuw==", "dev": true, "inBundle": true, "license": "ISC", @@ -16367,8 +16257,6 @@ }, "node_modules/npm/node_modules/libnpmorg": { "version": "5.0.4", - "resolved": "https://registry.npmjs.org/libnpmorg/-/libnpmorg-5.0.4.tgz", - "integrity": "sha512-YqYXLMAN0Y1eJH4w3hUFN9648xfSdvJANMsdeZTOWJOW4Pqp8qapJFzQdqCfUkg+tEuQmnaFQQKXvkMZC51+Mw==", "dev": true, "inBundle": true, "license": "ISC", @@ -16397,8 +16285,6 @@ }, "node_modules/npm/node_modules/libnpmpublish": { "version": "7.5.0", - "resolved": "https://registry.npmjs.org/libnpmpublish/-/libnpmpublish-7.5.0.tgz", - "integrity": "sha512-zctH6QcTJ093lpxmkufr2zr3AJ9V90hcRilDFNin6n91ODj+S28RdyMFFJpa9NwyztmyV2hlWLyZv0GaOQBDyA==", "dev": true, "inBundle": true, "license": "ISC", @@ -16418,8 +16304,6 @@ }, "node_modules/npm/node_modules/libnpmsearch": { "version": "6.0.2", - "resolved": "https://registry.npmjs.org/libnpmsearch/-/libnpmsearch-6.0.2.tgz", - "integrity": "sha512-p+5BF19AvnVg8mcIQhy6yWhI6jHQRVMYaIaKeITEfYAffWsqbottA/WZdMtHL76hViC6SFM1WdclM1w5eAIa1g==", "dev": true, "inBundle": true, "license": "ISC", @@ -16432,8 +16316,6 @@ }, "node_modules/npm/node_modules/libnpmteam": { "version": "5.0.3", - "resolved": "https://registry.npmjs.org/libnpmteam/-/libnpmteam-5.0.3.tgz", - "integrity": "sha512-7XOGhi45s+ml6TyrhJUTyrErcoDMKGKfEtiTEco4ofU7BGGAUOalVztKMVLLJgJOOXdIAIlzCHqkTXEuSiyCiA==", "dev": true, "inBundle": true, "license": "ISC", @@ -16447,8 +16329,6 @@ }, "node_modules/npm/node_modules/libnpmversion": { "version": "4.0.2", - "resolved": "https://registry.npmjs.org/libnpmversion/-/libnpmversion-4.0.2.tgz", - "integrity": "sha512-n1X70mFHv8Piy4yos+MFWUARSkTbyV5cdsHScaIkuwYvRAF/s2VtYScDzWB4Oe8uNEuGNdjiRR1E/Dh1tMvv6g==", "dev": true, "inBundle": true, "license": "ISC", @@ -16465,8 +16345,6 @@ }, "node_modules/npm/node_modules/lru-cache": { "version": "7.18.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", - "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", "dev": true, "inBundle": true, "license": "ISC", @@ -16476,8 +16354,6 @@ }, "node_modules/npm/node_modules/make-fetch-happen": { "version": "11.1.1", - "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-11.1.1.tgz", - "integrity": "sha512-rLWS7GCSTcEujjVBs2YqG7Y4643u8ucvCJeSRqiLYhesrDuzeuFIk37xREzAsfQaqzl8b9rNCE4m6J8tvX4Q8w==", "dev": true, "inBundle": true, "license": "ISC", @@ -16521,6 +16397,8 @@ }, "node_modules/npm/node_modules/minipass": { "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", "dev": true, "inBundle": true, "license": "ISC", @@ -16530,8 +16408,6 @@ }, "node_modules/npm/node_modules/minipass-collect": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/minipass-collect/-/minipass-collect-1.0.2.tgz", - "integrity": "sha512-6T6lH0H8OG9kITm/Jm6tdooIbogG9e0tLgpY6mphXSm/A9u8Nq1ryBG+Qspiub9LjWlBPsPS3tWQ/Botq4FdxA==", "dev": true, "inBundle": true, "license": "ISC", @@ -16544,6 +16420,8 @@ }, "node_modules/npm/node_modules/minipass-collect/node_modules/minipass": { "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", "dev": true, "inBundle": true, "license": "ISC", @@ -16573,8 +16451,6 @@ }, "node_modules/npm/node_modules/minipass-flush": { "version": "1.0.5", - "resolved": "https://registry.npmjs.org/minipass-flush/-/minipass-flush-1.0.5.tgz", - "integrity": "sha512-JmQSYYpPUqX5Jyn1mXaRwOda1uQ8HP5KAT/oDSLCzt1BYRhQU0/hDtsB1ufZfEEzMZ9aAVmsBw8+FWsIXlClWw==", "dev": true, "inBundle": true, "license": "ISC", @@ -16587,6 +16463,8 @@ }, "node_modules/npm/node_modules/minipass-flush/node_modules/minipass": { "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", "dev": true, "inBundle": true, "license": "ISC", @@ -16599,8 +16477,6 @@ }, "node_modules/npm/node_modules/minipass-json-stream": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minipass-json-stream/-/minipass-json-stream-1.0.1.tgz", - "integrity": "sha512-ODqY18UZt/I8k+b7rl2AENgbWE8IDYam+undIJONvigAz8KR5GWblsFTEfQs0WODsjbSXWlm+JHEv8Gr6Tfdbg==", "dev": true, "inBundle": true, "license": "MIT", @@ -16611,6 +16487,8 @@ }, "node_modules/npm/node_modules/minipass-json-stream/node_modules/minipass": { "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", "dev": true, "inBundle": true, "license": "ISC", @@ -16623,8 +16501,6 @@ }, "node_modules/npm/node_modules/minipass-pipeline": { "version": "1.2.4", - "resolved": "https://registry.npmjs.org/minipass-pipeline/-/minipass-pipeline-1.2.4.tgz", - "integrity": "sha512-xuIq7cIOt09RPRJ19gdi4b+RiNvDFYe5JH+ggNvBqGqpQXcru3PcRmOZuHBKWK1Txf9+cQ+HMVN4d6z46LZP7A==", "dev": true, "inBundle": true, "license": "ISC", @@ -16637,6 +16513,8 @@ }, "node_modules/npm/node_modules/minipass-pipeline/node_modules/minipass": { "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", "dev": true, "inBundle": true, "license": "ISC", @@ -16649,8 +16527,6 @@ }, "node_modules/npm/node_modules/minipass-sized": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/minipass-sized/-/minipass-sized-1.0.3.tgz", - "integrity": "sha512-MbkQQ2CTiBMlA2Dm/5cY+9SWFEN8pzzOXi6rlM5Xxq0Yqbda5ZQy9sU75a673FE9ZK0Zsbr6Y5iP6u9nktfg2g==", "dev": true, "inBundle": true, "license": "ISC", @@ -16663,6 +16539,8 @@ }, "node_modules/npm/node_modules/minipass-sized/node_modules/minipass": { "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", "dev": true, "inBundle": true, "license": "ISC", @@ -16690,6 +16568,8 @@ }, "node_modules/npm/node_modules/minizlib/node_modules/minipass": { "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", "dev": true, "inBundle": true, "license": "ISC", @@ -16716,16 +16596,12 @@ }, "node_modules/npm/node_modules/ms": { "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/mute-stream": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-1.0.0.tgz", - "integrity": "sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==", "dev": true, "inBundle": true, "license": "ISC", @@ -16735,8 +16611,6 @@ }, "node_modules/npm/node_modules/negotiator": { "version": "0.6.3", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", - "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", "dev": true, "inBundle": true, "license": "MIT", @@ -16746,8 +16620,6 @@ }, "node_modules/npm/node_modules/node-gyp": { "version": "9.4.0", - "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-9.4.0.tgz", - "integrity": "sha512-dMXsYP6gc9rRbejLXmTbVRYjAHw7ppswsKyMxuxJxxOHzluIO1rGp9TOQgjFJ+2MCqcOcQTOPB/8Xwhr+7s4Eg==", "dev": true, "inBundle": true, "license": "MIT", @@ -16773,16 +16645,12 @@ }, "node_modules/npm/node_modules/node-gyp/node_modules/abbrev": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/node-gyp/node_modules/are-we-there-yet": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.1.tgz", - "integrity": "sha512-QZW4EDmGwlYur0Yyf/b2uGucHQMa8aFUP7eu9ddR73vvhFyt4V0Vl3QHPcTNJ8l6qYOBdxgXdnBXQrHilfRQBg==", "dev": true, "inBundle": true, "license": "ISC", @@ -16808,8 +16676,6 @@ }, "node_modules/npm/node_modules/node-gyp/node_modules/gauge": { "version": "4.0.4", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz", - "integrity": "sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==", "dev": true, "inBundle": true, "license": "ISC", @@ -16829,6 +16695,8 @@ }, "node_modules/npm/node_modules/node-gyp/node_modules/glob": { "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, "inBundle": true, "license": "ISC", @@ -16932,8 +16800,6 @@ }, "node_modules/npm/node_modules/nopt": { "version": "7.2.0", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-7.2.0.tgz", - "integrity": "sha512-CVDtwCdhYIvnAzFoJ6NJ6dX3oga9/HyciQDnG1vQDjSLMeKLJ4A93ZqYKDrgYSr1FBY5/hMYC+2VCi24pgpkGA==", "dev": true, "inBundle": true, "license": "ISC", @@ -16949,8 +16815,6 @@ }, "node_modules/npm/node_modules/normalize-package-data": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-5.0.0.tgz", - "integrity": "sha512-h9iPVIfrVZ9wVYQnxFgtw1ugSvGEMOlyPWWtm8BMJhnwyEL/FLbYbTY3V3PpjI/BUK67n9PEWDu6eHzu1fB15Q==", "dev": true, "inBundle": true, "license": "BSD-2-Clause", @@ -16966,8 +16830,6 @@ }, "node_modules/npm/node_modules/npm-audit-report": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/npm-audit-report/-/npm-audit-report-5.0.0.tgz", - "integrity": "sha512-EkXrzat7zERmUhHaoren1YhTxFwsOu5jypE84k6632SXTHcQE1z8V51GC6GVZt8LxkC+tbBcKMUBZAgk8SUSbw==", "dev": true, "inBundle": true, "license": "ISC", @@ -16977,8 +16839,6 @@ }, "node_modules/npm/node_modules/npm-bundled": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-3.0.0.tgz", - "integrity": "sha512-Vq0eyEQy+elFpzsKjMss9kxqb9tG3YHg4dsyWuUENuzvSUWe1TCnW/vV9FkhvBk/brEDoDiVd+M1Btosa6ImdQ==", "dev": true, "inBundle": true, "license": "ISC", @@ -17003,8 +16863,6 @@ }, "node_modules/npm/node_modules/npm-normalize-package-bin": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz", - "integrity": "sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==", "dev": true, "inBundle": true, "license": "ISC", @@ -17014,8 +16872,6 @@ }, "node_modules/npm/node_modules/npm-package-arg": { "version": "10.1.0", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-10.1.0.tgz", - "integrity": "sha512-uFyyCEmgBfZTtrKk/5xDfHp6+MdrqGotX/VoOyEEl3mBwiEE5FlBaePanazJSVMPT7vKepcjYBY2ztg9A3yPIA==", "dev": true, "inBundle": true, "license": "ISC", @@ -17031,8 +16887,6 @@ }, "node_modules/npm/node_modules/npm-packlist": { "version": "7.0.4", - "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-7.0.4.tgz", - "integrity": "sha512-d6RGEuRrNS5/N84iglPivjaJPxhDbZmlbTwTDX2IbcRHG5bZCdtysYMhwiPvcF4GisXHGn7xsxv+GQ7T/02M5Q==", "dev": true, "inBundle": true, "license": "ISC", @@ -17060,8 +16914,6 @@ }, "node_modules/npm/node_modules/npm-profile": { "version": "7.0.1", - "resolved": "https://registry.npmjs.org/npm-profile/-/npm-profile-7.0.1.tgz", - "integrity": "sha512-VReArOY/fCx5dWL66cbJ2OMogTQAVVQA//8jjmjkarboki3V7UJ0XbGFW+khRwiAJFQjuH0Bqr/yF7Y5RZdkMQ==", "dev": true, "inBundle": true, "license": "ISC", @@ -17075,8 +16927,6 @@ }, "node_modules/npm/node_modules/npm-registry-fetch": { "version": "14.0.5", - "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-14.0.5.tgz", - "integrity": "sha512-kIDMIo4aBm6xg7jOttupWZamsZRkAqMqwqqbVXnUqstY5+tapvv6bkH/qMR76jdgV+YljEUCyWx3hRYMrJiAgA==", "dev": true, "inBundle": true, "license": "ISC", @@ -17095,8 +16945,6 @@ }, "node_modules/npm/node_modules/npm-user-validate": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/npm-user-validate/-/npm-user-validate-2.0.0.tgz", - "integrity": "sha512-sSWeqAYJ2dUPStJB+AEj0DyLRltr/f6YNcvCA7phkB8/RMLMnVsQ41GMwHo/ERZLYNDsyB2wPm7pZo1mqPOl7Q==", "dev": true, "inBundle": true, "license": "BSD-2-Clause", @@ -17106,8 +16954,6 @@ }, "node_modules/npm/node_modules/npmlog": { "version": "7.0.1", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-7.0.1.tgz", - "integrity": "sha512-uJ0YFk/mCQpLBt+bxN88AKd+gyqZvZDbtiNxk6Waqcj2aPRyfVx8ITawkyQynxUagInjdYT1+qj4NfA5KJJUxg==", "dev": true, "inBundle": true, "license": "ISC", @@ -17151,8 +16997,6 @@ }, "node_modules/npm/node_modules/pacote": { "version": "15.2.0", - "resolved": "https://registry.npmjs.org/pacote/-/pacote-15.2.0.tgz", - "integrity": "sha512-rJVZeIwHTUta23sIZgEIM62WYwbmGbThdbnkt81ravBplQv+HjyroqnLRNH2+sLJHcGZmLRmhPwACqhfTcOmnA==", "dev": true, "inBundle": true, "license": "ISC", @@ -17185,8 +17029,6 @@ }, "node_modules/npm/node_modules/parse-conflict-json": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/parse-conflict-json/-/parse-conflict-json-3.0.1.tgz", - "integrity": "sha512-01TvEktc68vwbJOtWZluyWeVGWjP+bZwXtPDMQVbBKzbJ/vZBif0L69KH1+cHv1SZ6e0FKLvjyHe8mqsIqYOmw==", "dev": true, "inBundle": true, "license": "ISC", @@ -17248,8 +17090,6 @@ }, "node_modules/npm/node_modules/postcss-selector-parser": { "version": "6.0.13", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.13.tgz", - "integrity": "sha512-EaV1Gl4mUEV4ddhDnv/xtj7sxwrwxdetHdWUGnT4VJQf+4d05v6lHYZr8N573k5Z0BViss7BDhfWtKS3+sfAqQ==", "dev": true, "inBundle": true, "license": "MIT", @@ -17263,8 +17103,6 @@ }, "node_modules/npm/node_modules/proc-log": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-3.0.0.tgz", - "integrity": "sha512-++Vn7NS4Xf9NacaU9Xq3URUuqZETPsf8L4j5/ckhaRYsfPeRyzGw+iDjFhV/Jr3uNmTvvddEJFWh5R1gRgUH8A==", "dev": true, "inBundle": true, "license": "ISC", @@ -17285,8 +17123,6 @@ }, "node_modules/npm/node_modules/promise-all-reject-late": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/promise-all-reject-late/-/promise-all-reject-late-1.0.1.tgz", - "integrity": "sha512-vuf0Lf0lOxyQREH7GDIOUMLS7kz+gs8i6B+Yi8dC68a2sychGrHTJYghMBD6k7eUcH0H5P73EckCA48xijWqXw==", "dev": true, "inBundle": true, "license": "ISC", @@ -17296,8 +17132,6 @@ }, "node_modules/npm/node_modules/promise-call-limit": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/promise-call-limit/-/promise-call-limit-1.0.2.tgz", - "integrity": "sha512-1vTUnfI2hzui8AEIixbdAJlFY4LFDXqQswy/2eOlThAscXCY4It8FdVuI0fMJGAB2aWGbdQf/gv0skKYXmdrHA==", "dev": true, "inBundle": true, "license": "ISC", @@ -17307,16 +17141,12 @@ }, "node_modules/npm/node_modules/promise-inflight": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", - "integrity": "sha512-6zWPyEOFaQBJYcGMHBKTKJ3u6TBsnMFOIZSa6ce1e/ZrrsOlnHRHbabMjLiBYKp+n44X9eUI6VUPaukCXHuG4g==", "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/promise-retry": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/promise-retry/-/promise-retry-2.0.1.tgz", - "integrity": "sha512-y+WKFlBR8BGXnsNlIHFGPZmyDf3DFMoLhaflAnyZgV6rG6xu+JwesTo2Q9R6XwYmtmwAFCkAk3e35jEdoeh/3g==", "dev": true, "inBundle": true, "license": "MIT", @@ -17330,8 +17160,6 @@ }, "node_modules/npm/node_modules/promzard": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/promzard/-/promzard-1.0.0.tgz", - "integrity": "sha512-KQVDEubSUHGSt5xLakaToDFrSoZhStB8dXLzk2xvwR67gJktrHFvpR63oZgHyK19WKbHFLXJqCPXdVR3aBP8Ig==", "dev": true, "inBundle": true, "license": "ISC", @@ -17344,8 +17172,6 @@ }, "node_modules/npm/node_modules/qrcode-terminal": { "version": "0.12.0", - "resolved": "https://registry.npmjs.org/qrcode-terminal/-/qrcode-terminal-0.12.0.tgz", - "integrity": "sha512-EXtzRZmC+YGmGlDFbXKxQiMZNwCLEO6BANKXG4iCtSIM0yqc/pappSx3RIKr4r0uh5JsBckOXeKrB3Iz7mdQpQ==", "dev": true, "inBundle": true, "bin": { @@ -17354,8 +17180,6 @@ }, "node_modules/npm/node_modules/read": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/read/-/read-2.1.0.tgz", - "integrity": "sha512-bvxi1QLJHcaywCAEsAk4DG3nVoqiY2Csps3qzWalhj5hFqRn1d/OixkFXtLO1PrgHUcAP0FNaSY/5GYNfENFFQ==", "dev": true, "inBundle": true, "license": "ISC", @@ -17368,8 +17192,6 @@ }, "node_modules/npm/node_modules/read-cmd-shim": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-4.0.0.tgz", - "integrity": "sha512-yILWifhaSEEytfXI76kB9xEEiG1AiozaCJZ83A87ytjRiN+jVibXjedjCRNjoZviinhG+4UkalO3mWTd8u5O0Q==", "dev": true, "inBundle": true, "license": "ISC", @@ -17379,8 +17201,6 @@ }, "node_modules/npm/node_modules/read-package-json": { "version": "6.0.4", - "resolved": "https://registry.npmjs.org/read-package-json/-/read-package-json-6.0.4.tgz", - "integrity": "sha512-AEtWXYfopBj2z5N5PbkAOeNHRPUg5q+Nen7QLxV8M2zJq1ym6/lCz3fYNTCXe19puu2d06jfHhrP7v/S2PtMMw==", "dev": true, "inBundle": true, "license": "ISC", @@ -17396,8 +17216,6 @@ }, "node_modules/npm/node_modules/read-package-json-fast": { "version": "3.0.2", - "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-3.0.2.tgz", - "integrity": "sha512-0J+Msgym3vrLOUB3hzQCuZHII0xkNGCtz/HJH9xZshwv9DbDwkw1KaE3gx/e2J5rpEY5rtOy6cyhKOPrkP7FZw==", "dev": true, "inBundle": true, "license": "ISC", @@ -17426,8 +17244,6 @@ }, "node_modules/npm/node_modules/retry": { "version": "0.12.0", - "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", - "integrity": "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==", "dev": true, "inBundle": true, "license": "MIT", @@ -17466,6 +17282,8 @@ }, "node_modules/npm/node_modules/rimraf/node_modules/glob": { "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, "inBundle": true, "license": "ISC", @@ -17522,8 +17340,6 @@ }, "node_modules/npm/node_modules/safer-buffer": { "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true, "inBundle": true, "license": "MIT", @@ -17548,6 +17364,8 @@ }, "node_modules/npm/node_modules/semver/node_modules/lru-cache": { "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, "inBundle": true, "license": "ISC", @@ -17624,8 +17442,6 @@ }, "node_modules/npm/node_modules/smart-buffer": { "version": "4.2.0", - "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", - "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", "dev": true, "inBundle": true, "license": "MIT", @@ -17636,8 +17452,6 @@ }, "node_modules/npm/node_modules/socks": { "version": "2.7.1", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", - "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", "dev": true, "inBundle": true, "license": "MIT", @@ -17652,8 +17466,6 @@ }, "node_modules/npm/node_modules/socks-proxy-agent": { "version": "7.0.0", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-7.0.0.tgz", - "integrity": "sha512-Fgl0YPZ902wEsAyiQ+idGd1A7rSFx/ayC1CQVMw5P+EQx2V0SgpGtf6OKFhVjPflPUl9YMmEOnmfjCdMUsygww==", "dev": true, "inBundle": true, "license": "MIT", @@ -17793,8 +17605,6 @@ }, "node_modules/npm/node_modules/supports-color": { "version": "9.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-9.4.0.tgz", - "integrity": "sha512-VL+lNrEoIXww1coLPOmiEmK/0sGigko5COxI09KzHc2VJXJsQ37UaQ+8quuxjDeA7+KnLGTWRyOXSLLR2Wb4jw==", "dev": true, "inBundle": true, "license": "MIT", @@ -17807,6 +17617,8 @@ }, "node_modules/npm/node_modules/tar": { "version": "6.1.15", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.15.tgz", + "integrity": "sha512-/zKt9UyngnxIT/EAGYuxaMYgOIJiP81ab9ZfkILq4oNLPFX50qyYmu7jRj9qeXoxmJHjGlbH0+cm2uy1WCs10A==", "dev": true, "inBundle": true, "license": "ISC", @@ -17824,6 +17636,8 @@ }, "node_modules/npm/node_modules/tar/node_modules/fs-minipass": { "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", "dev": true, "inBundle": true, "license": "ISC", @@ -17836,6 +17650,8 @@ }, "node_modules/npm/node_modules/tar/node_modules/fs-minipass/node_modules/minipass": { "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", "dev": true, "inBundle": true, "license": "ISC", @@ -17848,24 +17664,18 @@ }, "node_modules/npm/node_modules/text-table": { "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/tiny-relative-date": { "version": "1.3.0", - "resolved": "https://registry.npmjs.org/tiny-relative-date/-/tiny-relative-date-1.3.0.tgz", - "integrity": "sha512-MOQHpzllWxDCHHaDno30hhLfbouoYlOI8YlMNtvKe1zXbjEVhbcEovQxvZrPvtiYW630GQDoMMarCnjfyfHA+A==", "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/treeverse": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/treeverse/-/treeverse-3.0.0.tgz", - "integrity": "sha512-gcANaAnd2QDZFmHFEOF4k7uc1J/6a6z3DJMd/QwEyxLoKGiptJRwid582r7QIsFlFMIZ3SnxfS52S4hm2DHkuQ==", "dev": true, "inBundle": true, "license": "ISC", @@ -17875,8 +17685,6 @@ }, "node_modules/npm/node_modules/tuf-js": { "version": "1.1.7", - "resolved": "https://registry.npmjs.org/tuf-js/-/tuf-js-1.1.7.tgz", - "integrity": "sha512-i3P9Kgw3ytjELUfpuKVDNBJvk4u5bXL6gskv572mcevPbSKCV3zt3djhmlEQ65yERjIbOSncy7U4cQJaB1CBCg==", "dev": true, "inBundle": true, "license": "MIT", @@ -17891,8 +17699,6 @@ }, "node_modules/npm/node_modules/unique-filename": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-3.0.0.tgz", - "integrity": "sha512-afXhuC55wkAmZ0P18QsVE6kp8JaxrEokN2HGIoIVv2ijHQd419H0+6EigAFcIzXeMIkcIkNBpB3L/DXB3cTS/g==", "dev": true, "inBundle": true, "license": "ISC", @@ -17905,8 +17711,6 @@ }, "node_modules/npm/node_modules/unique-slug": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-4.0.0.tgz", - "integrity": "sha512-WrcA6AyEfqDX5bWige/4NQfPZMtASNVxdmWR76WESYQVAACSgWcR6e9i0mofqqBxYFtL4oAxPIptY73/0YE1DQ==", "dev": true, "inBundle": true, "license": "ISC", @@ -17919,14 +17723,14 @@ }, "node_modules/npm/node_modules/util-deprecate": { "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/validate-npm-package-license": { "version": "3.0.4", - "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", - "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", "dev": true, "inBundle": true, "license": "Apache-2.0", @@ -17937,8 +17741,6 @@ }, "node_modules/npm/node_modules/validate-npm-package-name": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-5.0.0.tgz", - "integrity": "sha512-YuKoXDAhBYxY7SfOKxHBDoSyENFeW5VvIIQp2TGQuit8gpK6MnWaQelBKxso72DoxTZfZdcP3W90LqpSkgPzLQ==", "dev": true, "inBundle": true, "license": "ISC", @@ -17951,16 +17753,12 @@ }, "node_modules/npm/node_modules/walk-up-path": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/walk-up-path/-/walk-up-path-3.0.1.tgz", - "integrity": "sha512-9YlCL/ynK3CTlrSRrDxZvUauLzAswPCrsaCgilqFevUYpeEW0/3ScEjaa3kbW/T0ghhkEr7mv+fpjqn1Y1YuTA==", "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/wcwidth": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", - "integrity": "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==", "dev": true, "inBundle": true, "license": "MIT", @@ -17970,8 +17768,6 @@ }, "node_modules/npm/node_modules/which": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/which/-/which-3.0.1.tgz", - "integrity": "sha512-XA1b62dzQzLfaEOSQFTCOd5KFf/1VSzZo7/7TUjnya6u0vGGKzU96UQBZTAThCb2j4/xjBAyii1OhRLJEivHvg==", "dev": true, "inBundle": true, "license": "ISC", @@ -17987,8 +17783,6 @@ }, "node_modules/npm/node_modules/wide-align": { "version": "1.1.5", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", - "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", "dev": true, "inBundle": true, "license": "ISC", @@ -17998,6 +17792,8 @@ }, "node_modules/npm/node_modules/wrap-ansi": { "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", "dev": true, "inBundle": true, "license": "MIT", @@ -18016,6 +17812,8 @@ "node_modules/npm/node_modules/wrap-ansi-cjs": { "name": "wrap-ansi", "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, "inBundle": true, "license": "MIT", @@ -18047,6 +17845,8 @@ }, "node_modules/npm/node_modules/wrap-ansi/node_modules/ansi-styles": { "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", "dev": true, "inBundle": true, "license": "MIT", @@ -18067,6 +17867,8 @@ }, "node_modules/npm/node_modules/wrap-ansi/node_modules/string-width": { "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", "dev": true, "inBundle": true, "license": "MIT", @@ -18101,14 +17903,14 @@ }, "node_modules/npm/node_modules/wrappy": { "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/write-file-atomic": { "version": "5.0.1", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", - "integrity": "sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==", "dev": true, "inBundle": true, "license": "ISC", @@ -18122,6 +17924,8 @@ }, "node_modules/npm/node_modules/yallist": { "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true, "inBundle": true, "license": "ISC" diff --git a/src/Components/Facility/HospitalList.tsx b/src/Components/Facility/HospitalList.tsx index b4ad113a0f8..1c8ed7a74c3 100644 --- a/src/Components/Facility/HospitalList.tsx +++ b/src/Components/Facility/HospitalList.tsx @@ -93,9 +93,12 @@ export const HospitalList = () => { local_body_object: result.local_body_object, district_object: result.district_object, state_object: result.state_object, + state: result.state, ward_object: result.ward_object, modified_date: result.modified_date, created_date: result.created_date, + local_body: result.local_body, + ward: result.ward, })); setData(transformedData); diff --git a/src/Components/Facility/LegacyFacilityCNS.tsx b/src/Components/Facility/LegacyFacilityCNS.tsx index c994c028614..2109b87dc05 100644 --- a/src/Components/Facility/LegacyFacilityCNS.tsx +++ b/src/Components/Facility/LegacyFacilityCNS.tsx @@ -82,29 +82,15 @@ export default function LegacyFacilityCNS({ expected_type_c_cylinders: data.expected_type_c_cylinders, expected_type_d_cylinders: data.expected_type_d_cylinders, expected_oxygen_requirement: data.expected_oxygen_requirement, - local_body_object: { - name: data.local_body_object.name, - body_type: data.local_body_object.body_type, - localbody_code: data.local_body_object.localbody_code, - district: data.local_body_object.district, - }, - district_object: { - id: data.district_object.id, - name: data.district_object.name, - state: data.district_object.state, - }, - state_object: { - id: data.state_object.id, - name: data.state_object.name, - }, - ward_object: { - id: data.ward_object.id, - name: data.ward_object.name, - number: data.ward_object.number, - local_body: data.ward_object.local_body, - }, + local_body_object: data.local_body_object, + district_object: data.district_object, + state_object: data.state_object, + ward_object: data.ward_object, modified_date: data.modified_date, created_date: data.created_date, + local_body: data.local_body, + ward: data.ward, + state: data.state, }; setFacility(updateData); From c86062a7f72227b4acb2f50d60c7a430bc82e7d8 Mon Sep 17 00:00:00 2001 From: sriharsh05 Date: Wed, 1 Nov 2023 12:18:51 +0530 Subject: [PATCH 09/10] use preFetch and onResponse for useQuery --- src/Components/Facility/FacilityCard.tsx | 2 +- src/Components/Facility/FacilityCreate.tsx | 234 ++++++++---------- src/Components/Facility/FacilityHome.tsx | 74 ++++-- src/Components/Facility/FacilityUsers.tsx | 26 +- src/Components/Facility/HospitalList.tsx | 68 ++--- src/Components/Facility/InventoryList.tsx | 25 +- src/Components/Facility/InventoryLog.tsx | 33 ++- src/Components/Facility/LegacyFacilityCNS.tsx | 4 +- src/Components/Facility/MinQuantityList.tsx | 25 +- .../Facility/MinQuantityRequiredModal.tsx | 7 +- src/Components/Facility/SetInventoryForm.tsx | 7 +- .../Facility/TransferPatientDialog.tsx | 2 +- src/Components/Facility/TreatmentSummary.tsx | 86 +++---- src/Components/Facility/TriageForm.tsx | 116 ++++----- 14 files changed, 316 insertions(+), 393 deletions(-) diff --git a/src/Components/Facility/FacilityCard.tsx b/src/Components/Facility/FacilityCard.tsx index 2689193b4c2..12af4e13142 100644 --- a/src/Components/Facility/FacilityCard.tsx +++ b/src/Components/Facility/FacilityCard.tsx @@ -32,7 +32,7 @@ export const FacilityCard = (props: { facility: any; userType: any }) => { message: notifyMessage, }, }); - if (res && res.status == 204) { + if (res?.ok && res.status == 204) { Notification.Success({ msg: "Facility Notified", }); diff --git a/src/Components/Facility/FacilityCreate.tsx b/src/Components/Facility/FacilityCreate.tsx index 6be883b7031..002ab94deb2 100644 --- a/src/Components/Facility/FacilityCreate.tsx +++ b/src/Components/Facility/FacilityCreate.tsx @@ -167,45 +167,38 @@ export const FacilityCreate = (props: FacilityProps) => { const buttonText = !facilityId ? "Save Facility" : "Update Facility"; const [newId, setNewId] = useState(0); - const { - res: districtRes, - data: districtData, - refetch: districtFetch, - } = useQuery(routes.getDistrictByState, { - pathParams: { - id: String(newId), - }, - }); - - useEffect(() => { - if (newId > 0) { - setIsDistrictLoading(true); - if (districtRes && districtData) { - setDistricts([districtData]); - } - setIsDistrictLoading(false); + const { data: districtData, refetch: districtFetch } = useQuery( + routes.getDistrictByState, + { + pathParams: { + id: String(newId), + }, + onResponse: ({ res, data }) => { + if (newId > 0) { + setIsDistrictLoading(true); + if (res?.ok && data) { + setDistricts([data]); + } + setIsDistrictLoading(false); + } + }, } - }, [newId, districtData]); + ); - const { - res: localBodyRes, - data: localBodyData, - refetch: localBodyFetch, - } = useQuery(routes.getLocalbodyByDistrict, { + const { refetch: localBodyFetch } = useQuery(routes.getLocalbodyByDistrict, { pathParams: { id: String(newId), }, - }); - - useEffect(() => { - if (newId > 0) { - setIsLocalbodyLoading(true); - if (localBodyData) { - setLocalBodies([localBodyData]); + onResponse: ({ res, data }) => { + if (newId > 0) { + setIsLocalbodyLoading(true); + if (res?.ok && data) { + setLocalBodies([data]); + } + setIsLocalbodyLoading(false); } - setIsLocalbodyLoading(false); - } - }, [newId, localBodyRes, localBodyData]); + }, + }); const getSteps = (): Step[] => { return [ @@ -244,109 +237,88 @@ export const FacilityCreate = (props: FacilityProps) => { ]; }; - const { - res: wardsRes, - data: wardsData, - refetch: wardsFetch, - } = useQuery(routes.getWardByLocalBody, { + const { refetch: wardsFetch } = useQuery(routes.getWardByLocalBody, { pathParams: { id: String(newId), }, - }); - - useEffect(() => { - if (newId > 0) { - setIsWardLoading(true); - if (wardsData) { - const updatedWards = { - id: wardsData.results[0].id, - name: wardsData.results[0].name, - number: wardsData.results[0].number, - }; - setWard([updatedWards]); + onResponse: ({ res, data }) => { + if (newId > 0) { + setIsWardLoading(true); + if (res?.ok && data) { + const updatedWards = { + id: data.results[0].id, + name: data.results[0].name, + number: data.results[0].number, + }; + setWard([updatedWards]); + } + setIsWardLoading(false); } - setIsWardLoading(false); - } - }, [newId, wardsRes, wardsData]); + }, + }); - const { - res: facilityRes, - data: facilityData, - refetch: facilityFetch, - } = useQuery(routes.getPermittedFacility, { + const { refetch: facilityFetch } = useQuery(routes.getPermittedFacility, { pathParams: { id: facilityId || "", }, + onResponse: ({ res, data }) => { + if (facilityId) { + setIsLoading(true); + if (res && data) { + const formData = { + facility_type: String(data.facility_type), + name: data.name, + state: data.state ? data.state : 0, + district: data.district ? data.district : 0, + local_body: data.local_body ? data.local_body : 0, + features: data.features || [], + ward: data.ward_object ? data.ward_object.id : 0, + kasp_empanelled: data.kasp_empanelled + ? String(data.kasp_empanelled) + : "false", + address: data.address, + pincode: String(data.pincode), + phone_number: + data.phone_number.length == 10 + ? "+91" + data.phone_number + : data.phone_number, + latitude: data.latitude || "", + longitude: data.longitude || "", + type_b_cylinders: data.type_b_cylinders, + type_c_cylinders: data.type_c_cylinders, + type_d_cylinders: data.type_d_cylinders, + expected_type_b_cylinders: data.expected_type_b_cylinders, + expected_type_c_cylinders: data.expected_type_c_cylinders, + expected_type_d_cylinders: data.expected_type_d_cylinders, + expected_oxygen_requirement: data.expected_oxygen_requirement, + oxygen_capacity: data.oxygen_capacity, + }; + dispatch({ type: "set_form", form: formData }); + Promise.all([ + setNewId(data.state), + districtFetch(), + setNewId(data.district), + localBodyFetch(), + setNewId(data.local_body), + wardsFetch(), + ]); + } else { + navigate(`/facility/${facilityId}`); + } + setIsLoading(false); + } + }, }); - useEffect(() => { - if (facilityId) { - setIsLoading(true); - if (facilityData) { - const formData = { - facility_type: String(facilityData.facility_type), - name: facilityData.name, - state: facilityData.state ? facilityData.state : 0, - district: facilityData.district ? facilityData.district : 0, - local_body: facilityData.local_body ? facilityData.local_body : 0, - features: facilityData.features || [], - ward: facilityData.ward_object ? facilityData.ward_object.id : 0, - kasp_empanelled: facilityData.kasp_empanelled - ? String(facilityData.kasp_empanelled) - : "false", - address: facilityData.address, - pincode: String(facilityData.pincode), - phone_number: - facilityData.phone_number.length == 10 - ? "+91" + facilityData.phone_number - : facilityData.phone_number, - latitude: facilityData.latitude || "", - longitude: facilityData.longitude || "", - type_b_cylinders: facilityData.type_b_cylinders, - type_c_cylinders: facilityData.type_c_cylinders, - type_d_cylinders: facilityData.type_d_cylinders, - expected_type_b_cylinders: facilityData.expected_type_b_cylinders, - expected_type_c_cylinders: facilityData.expected_type_c_cylinders, - expected_type_d_cylinders: facilityData.expected_type_d_cylinders, - expected_oxygen_requirement: facilityData.expected_oxygen_requirement, - oxygen_capacity: facilityData.oxygen_capacity, - }; - dispatch({ type: "set_form", form: formData }); - Promise.all([ - setNewId(facilityData.state), - districtFetch(), - setNewId(facilityData.district), - localBodyFetch(), - setNewId(facilityData.local_body), - wardsFetch(), - ]); - } else { - navigate(`/facility/${facilityId}`); + const { refetch: fetchStates } = useQuery(routes.statesList, { + onResponse: ({ res, data }) => { + setIsStateLoading(true); + if (res && data) { + setStates([...data.results]); } - setIsLoading(false); - } - }, [ - facilityId, - facilityRes, - facilityData, - districtFetch, - localBodyFetch, - wardsFetch, - ]); - - const { - res: statesRes, - data: statesData, - refetch: fetchStates, - } = useQuery(routes.statesList, {}); - - useEffect(() => { - setIsStateLoading(true); - if (statesRes && statesData) { - setStates([...statesData.results]); - } - setIsStateLoading(false); - }, [statesRes, statesData]); + setIsStateLoading(false); + }, + }); useEffect(() => { if (facilityId) { @@ -559,7 +531,11 @@ export const FacilityCreate = (props: FacilityProps) => { body: data, }); - if (res && (res.status === 200 || res.status === 201) && requestData) { + if ( + res?.ok && + (res.status === 200 || res.status === 201) && + requestData + ) { const id = requestData.id; dispatch({ type: "set_form", form: initForm }); if (!facilityId) { @@ -684,7 +660,7 @@ export const FacilityCreate = (props: FacilityProps) => { const { res, data } = await request(routes.listDoctor, { pathParams: { facilityId: createdFacilityId }, }); - if (res && data) { + if (res?.ok && data) { const convertedResult = data.results.map((result) => { return { ...result, @@ -736,7 +712,7 @@ export const FacilityCreate = (props: FacilityProps) => { const { res, data } = await request(routes.listDoctor, { pathParams: { facilityId: createdFacilityId }, }); - if (res && data) { + if (res?.ok && data) { const convertedResult = data.results.map((result) => { return { ...result, @@ -777,7 +753,7 @@ export const FacilityCreate = (props: FacilityProps) => { const { res, data } = await request(routes.getCapacity, { pathParams: { facilityId: createdFacilityId }, }); - if (res && data) { + if (res?.ok && data) { const convertedResult = data.results.map((result) => { return { ...result, diff --git a/src/Components/Facility/FacilityHome.tsx b/src/Components/Facility/FacilityHome.tsx index 87ba421632f..d09ee63759a 100644 --- a/src/Components/Facility/FacilityHome.tsx +++ b/src/Components/Facility/FacilityHome.tsx @@ -52,10 +52,44 @@ export const getFacilityFeatureIcon = (featureId: number) => { ); }; +const initialFacilityState: FacilityModel = { + id: undefined, + name: "", + read_cover_image_url: "", + facility_type: "", + address: "", + features: [], + location: { + latitude: 0, + longitude: 0, + }, + oxygen_capacity: 0, + phone_number: "", + type_b_cylinders: 0, + type_c_cylinders: 0, + type_d_cylinders: 0, + middleware_address: "", + expected_type_b_cylinders: 0, + expected_type_c_cylinders: 0, + expected_type_d_cylinders: 0, + expected_oxygen_requirement: 0, + local_body_object: undefined, + district_object: undefined, + state_object: undefined, + ward_object: undefined, + modified_date: "", + created_date: "", + state: 0, + district: 0, + local_body: 0, + ward: 0, +}; + export const FacilityHome = (props: any) => { const { t } = useTranslation(); const { facilityId } = props; - const [facilityData, setFacilityData] = useState({}); + const [facilityData, setFacilityData] = + useState(initialFacilityState); const [capacityData, setCapacityData] = useState>([]); const [doctorData, setDoctorData] = useState>([]); const [isLoading, setIsLoading] = useState(false); @@ -73,20 +107,19 @@ export const FacilityHome = (props: any) => { useMessageListener((data) => console.log(data)); - const { - res: permittedFacilityRes, - data: permittedFacilityData, - refetch: permittedFacilityFetch, - } = useQuery(routes.getPermittedFacility, { - pathParams: { - id: facilityId, - }, - }); + const { res: permittedFacilityRes, data: permittedFacilityData } = useQuery( + routes.getPermittedFacility, + { + pathParams: { + id: facilityId, + }, + } + ); useEffect(() => { const fetchData = async () => { setIsLoading(true); - if (permittedFacilityRes) { + if (permittedFacilityRes?.ok) { const { res: capacityRes, data: capacityData } = await request( routes.getCapacity, { @@ -147,9 +180,12 @@ export const FacilityHome = (props: any) => { ward_object: permittedFacilityData.ward_object, modified_date: permittedFacilityData.modified_date, created_date: permittedFacilityData.created_date, + state: permittedFacilityData.state, + local_body: permittedFacilityData.local_body, + ward: permittedFacilityData.ward, }; setFacilityData(transformedPermittedFacilityData); - if (capacityRes && capacityData) { + if (capacityRes?.ok && capacityData) { const transformedCapacityData = { id: Number(capacityData.results[0].id), room_type: capacityData.results[0].room_type, @@ -159,7 +195,7 @@ export const FacilityHome = (props: any) => { }; setCapacityData([transformedCapacityData]); } - if (doctorRes && doctorData) { + if (doctorRes?.ok && doctorData) { const transformedDoctorData = { id: Number(doctorData.results[0].id), area: doctorData.results[0].area, @@ -176,7 +212,7 @@ export const FacilityHome = (props: any) => { setTotalDoctors(totalCount); } if ( - triageRes && + triageRes?.ok && triageData && triageData.results && triageData.results.length @@ -205,13 +241,9 @@ export const FacilityHome = (props: any) => { setIsLoading(false); } }; - fetchData(); + if (permittedFacilityRes?.ok) fetchData(); }, [facilityId, permittedFacilityRes, permittedFacilityData]); - useEffect(() => { - permittedFacilityFetch(); - }, [permittedFacilityFetch]); - const handleDeleteClose = () => { setOpenDeleteDialog(false); }; @@ -220,7 +252,7 @@ export const FacilityHome = (props: any) => { const { res, data } = await request(routes.deleteFacility, { pathParams: { id: facilityId }, }); - if (res?.status === 204) { + if (res?.ok && res?.status === 204) { Notification.Success({ msg: "Facility deleted successfully", }); @@ -349,7 +381,7 @@ export const FacilityHome = (props: any) => { const { res, data } = await request(routes.listDoctor, { pathParams: { facilityId: facilityId }, }); - if (res && data) { + if (res?.ok && data) { const convertedResult = data.results.map((result) => { return { ...result, diff --git a/src/Components/Facility/FacilityUsers.tsx b/src/Components/Facility/FacilityUsers.tsx index 712ef98312a..28abe2c31cc 100644 --- a/src/Components/Facility/FacilityUsers.tsx +++ b/src/Components/Facility/FacilityUsers.tsx @@ -79,24 +79,20 @@ export default function FacilityUsers(props: any) { fetchFacilityName(); }, [facilityId]); - const { res, data, refetch } = useQuery(routes.getFacilityUsers, { + const { refetch } = useQuery(routes.getFacilityUsers, { query: { offset: offset, limit: limit }, pathParams: { facility_id: facilityId }, + prefetch: facilityId !== undefined, + onResponse: ({ res, data }) => { + setIsLoading(true); + if (res?.ok && data) { + setUsers(data.results); + setTotalCount(data.count); + } + setIsLoading(false); + }, }); - useEffect(() => { - setIsLoading(true); - if (res && data) { - setUsers(data.results); - setTotalCount(data.count); - } - setIsLoading(false); - }, [facilityId, offset, limit, res, data]); - - useEffect(() => { - refetch(); - }, [refetch]); - const handlePagination = (page: number, limit: number) => { const offset = (page - 1) * limit; setCurrentPage(page); @@ -111,7 +107,7 @@ export default function FacilityUsers(props: any) { const { res, data } = await request(routes.userListFacility, { pathParams: { username: username }, }); - if (res && data) { + if (res?.ok && data) { const updated = users.map((user) => { return user.username === username ? { diff --git a/src/Components/Facility/HospitalList.tsx b/src/Components/Facility/HospitalList.tsx index 1c8ed7a74c3..0942abeb408 100644 --- a/src/Components/Facility/HospitalList.tsx +++ b/src/Components/Facility/HospitalList.tsx @@ -67,7 +67,7 @@ export const HospitalList = () => { useEffect(() => { setIsLoading(true); - if (permittedDataRes && permittedData) { + if (permittedDataRes?.ok && permittedData) { const transformedData = permittedData.results.map((result) => ({ id: Number(result.id), name: result.name, @@ -121,66 +121,42 @@ export const HospitalList = () => { permittedFacilitiesFetch(); }, [permittedFacilitiesFetch]); - const { - res: stateNameRes, - data: stateNameData, - refetch: stateNameFetch, - } = useQuery(routes.getState, { + useQuery(routes.getState, { pathParams: { id: qParams.state, }, + prefetch: qParams.state !== undefined, + onResponse: ({ res, data }) => { + if (res?.ok && data) { + setStateName(data.name); + } + }, }); - useEffect(() => { - if (stateNameRes && stateNameData) { - setStateName(stateNameData.name); - } - }, [qParams.state, stateNameRes, stateNameData]); - - useEffect(() => { - stateNameFetch(); - }, [stateNameFetch]); - - const { - res: DistrictNameRes, - data: DistrictNameData, - refetch: DistrictNameFetch, - } = useQuery(routes.getDistrict, { + useQuery(routes.getDistrict, { pathParams: { id: qParams.district, }, + prefetch: qParams.district !== undefined, + onResponse: ({ res, data }) => { + if (res?.ok && data) { + setDistrictName(data.name); + } + }, }); - useEffect(() => { - if (DistrictNameRes && DistrictNameData) { - setDistrictName(DistrictNameData.name); - } - }, [qParams.district, DistrictNameRes, DistrictNameData]); - - useEffect(() => { - DistrictNameFetch(); - }, [DistrictNameFetch]); - - const { - res: LocalbodyNameRes, - data: LocalbodyNameData, - refetch: LocalbodyNameFetch, - } = useQuery(routes.getLocalBody, { + useQuery(routes.getLocalBody, { pathParams: { id: qParams.local_body, }, + prefetch: qParams.local_body !== undefined, + onResponse: ({ res, data }) => { + if (res?.ok && data) { + setLocalbodyName(data.name); + } + }, }); - useEffect(() => { - if (LocalbodyNameRes && LocalbodyNameData) { - setLocalbodyName(LocalbodyNameData.name); - } - }, [qParams.local_body, LocalbodyNameRes, LocalbodyNameData]); - - useEffect(() => { - LocalbodyNameFetch(); - }, [LocalbodyNameFetch]); - const findFacilityTypeById = (id: number) => { const facility_type = FACILITY_TYPES.find((type) => type.id == id); return facility_type?.text; diff --git a/src/Components/Facility/InventoryList.tsx b/src/Components/Facility/InventoryList.tsx index db180f5563c..52b63a69e70 100644 --- a/src/Components/Facility/InventoryList.tsx +++ b/src/Components/Facility/InventoryList.tsx @@ -23,7 +23,7 @@ export default function InventoryList(props: any) { const [facilityName, setFacilityName] = useState(""); const limit = 14; - const { res, data, refetch } = useQuery(routes.getInventorySummary, { + useQuery(routes.getInventorySummary, { query: { limit, offset, @@ -31,21 +31,16 @@ export default function InventoryList(props: any) { pathParams: { id: facilityId, }, + onResponse: ({ res, data }) => { + setIsLoading(true); + if (res?.ok && data) { + setInventory(data.results); + setTotalCount(data.count); + } + setIsLoading(false); + }, }); - useEffect(() => { - setIsLoading(true); - if (data) { - setInventory(data.results); - setTotalCount(data.count); - } - setIsLoading(false); - }, [offset, facilityId, res, data]); - - useEffect(() => { - refetch(); - }, [refetch]); - useEffect(() => { async function fetchFacilityName() { if (facilityId) { @@ -54,7 +49,7 @@ export default function InventoryList(props: any) { id: facilityId, }, }); - if (res && data) setFacilityName(data.name || ""); + if (res?.ok && data) setFacilityName(data.name || ""); } else { setFacilityName(""); } diff --git a/src/Components/Facility/InventoryLog.tsx b/src/Components/Facility/InventoryLog.tsx index 2b27e48e74f..8d1928b8b97 100644 --- a/src/Components/Facility/InventoryLog.tsx +++ b/src/Components/Facility/InventoryLog.tsx @@ -28,7 +28,7 @@ export default function InventoryLog(props: any) { const [itemName, setItemName] = useState(" "); const [facilityName, setFacilityName] = useState(""); - const { res, data, refetch } = useQuery(routes.getInventoryLog, { + const { refetch } = useQuery(routes.getInventoryLog, { query: { item: item, limit: limit, @@ -38,19 +38,19 @@ export default function InventoryLog(props: any) { pathParams: { id: facilityId, }, + prefetch: facilityId !== undefined, + onResponse: ({ res, data }) => { + setIsLoading(true); + if (res?.ok && data) { + setInventory(data.results); + setCurrentStock(data.results[0].current_stock); + setTotalCount(data.count); + setItemName(data.results[0].item_object.name); + } + setIsLoading(false); + }, }); - useEffect(() => { - setIsLoading(true); - if (data) { - setInventory(data.results); - setCurrentStock(data.results[0].current_stock); - setTotalCount(data.count); - setItemName(data.results[0].item_object.name); - } - setIsLoading(false); - }, [offset, facilityId, res, data]); - useEffect(() => { async function fetchFacilityName() { if (facilityId) { @@ -60,7 +60,7 @@ export default function InventoryLog(props: any) { }, }); - if (res && data) setFacilityName(data.name || ""); + if (res?.ok && data) setFacilityName(data.name || ""); } else { setFacilityName(""); } @@ -77,7 +77,7 @@ export default function InventoryLog(props: any) { external_id: id, }, }); - if (res && res.status === 204) { + if (res?.ok && res.status === 204) { Notification.Success({ msg: "Updated Successfully", }); @@ -96,7 +96,7 @@ export default function InventoryLog(props: any) { }, }); - if (res?.status === 201) { + if (res?.ok && res?.status === 201) { Notification.Success({ msg: "Last entry deleted Successfully", }); @@ -109,9 +109,6 @@ export default function InventoryLog(props: any) { setSaving(false); }; - useEffect(() => { - refetch(); - }, [refetch]); const handlePagination = (page: number, limit: number) => { const offset = (page - 1) * limit; setCurrentPage(page); diff --git a/src/Components/Facility/LegacyFacilityCNS.tsx b/src/Components/Facility/LegacyFacilityCNS.tsx index 2109b87dc05..6bc1870d29e 100644 --- a/src/Components/Facility/LegacyFacilityCNS.tsx +++ b/src/Components/Facility/LegacyFacilityCNS.tsx @@ -59,7 +59,7 @@ export default function LegacyFacilityCNS({ const { res, data } = await request(routes.getPermittedFacility, { pathParams: { facilityId }, }); - if (res?.status === 200 && data) { + if (res?.ok && res?.status === 200 && data) { const updateData = { id: Number(data.id), name: data.name, @@ -110,7 +110,7 @@ export default function LegacyFacilityCNS({ is_active: true, }, }); - if (res && res.status === 200 && data) { + if (res?.ok && res.status === 200 && data) { const patients = data as PatientModel[]; return patients.filter( (patient) => !!patient.last_consultation?.current_bed?.bed_object.id diff --git a/src/Components/Facility/MinQuantityList.tsx b/src/Components/Facility/MinQuantityList.tsx index 42ada81027b..bc66dad0e2d 100644 --- a/src/Components/Facility/MinQuantityList.tsx +++ b/src/Components/Facility/MinQuantityList.tsx @@ -24,7 +24,7 @@ export default function MinQuantityList(props: any) { const [selectedItem, setSelectedItem] = useState({ id: 0, item_id: 0 }); const limit = 14; - const { res, data, refetch } = useQuery(routes.getMinQuantity, { + const { refetch } = useQuery(routes.getMinQuantity, { query: { limit: limit, offset: offset, @@ -32,21 +32,16 @@ export default function MinQuantityList(props: any) { pathParams: { id: facilityId, }, + onResponse: ({ res, data }) => { + setIsLoading(true); + if (res?.ok && data) { + setInventory(data.results); + setTotalCount(data.count); + } + setIsLoading(false); + }, }); - useEffect(() => { - setIsLoading(true); - if (res && data) { - setInventory(data.results); - setTotalCount(data.count); - } - setIsLoading(false); - }, [offset, facilityId, res, data]); - - useEffect(() => { - refetch(); - }, [refetch]); - useEffect(() => { async function fetchFacilityName() { if (facilityId) { @@ -55,7 +50,7 @@ export default function MinQuantityList(props: any) { id: facilityId, }, }); - if (res && data) setFacilityName(data.name || ""); + if (res?.ok && data) setFacilityName(data.name || ""); } else { setFacilityName(""); } diff --git a/src/Components/Facility/MinQuantityRequiredModal.tsx b/src/Components/Facility/MinQuantityRequiredModal.tsx index b70b873a6d8..aa0dafcdc06 100644 --- a/src/Components/Facility/MinQuantityRequiredModal.tsx +++ b/src/Components/Facility/MinQuantityRequiredModal.tsx @@ -67,15 +67,14 @@ export const MinQuantityRequiredModal = (props: any) => { id: facilityId, }, }); - if (res && data) setFacilityName(data.name || ""); + if (res?.ok && data) setFacilityName(data.name || ""); } else { setFacilityName(""); } setIsLoading(false); }; - - fetchData(); + if (minQuantityRes?.ok && minQuantityData) fetchData(); }, [facilityId, inventoryId, minQuantityData, minQuantityRes, state.form]); useEffect(() => { @@ -97,7 +96,7 @@ export const MinQuantityRequiredModal = (props: any) => { }, }); setIsLoading(false); - if (res && data) { + if (res?.ok && data) { Notification.Success({ msg: "Minimum quantity updated successfully", }); diff --git a/src/Components/Facility/SetInventoryForm.tsx b/src/Components/Facility/SetInventoryForm.tsx index e9a44050695..86a493dee08 100644 --- a/src/Components/Facility/SetInventoryForm.tsx +++ b/src/Components/Facility/SetInventoryForm.tsx @@ -66,7 +66,7 @@ export const SetInventoryForm = (props: any) => { const fetchData = async () => { setIsLoading(true); const existingItemIDs: number[] = []; - if (minQuantityRes && minQuantityData) { + if (minQuantityRes?.ok && minQuantityData) { minQuantityData.results.map((item: any) => existingItemIDs.push(item.item_object.id) ); @@ -77,7 +77,7 @@ export const SetInventoryForm = (props: any) => { offset: offset, }, }); - if (res && data) { + if (res?.ok && data) { const filteredData = data.results.filter( (item: any) => !existingItemIDs.includes(item.id) ); @@ -100,8 +100,7 @@ export const SetInventoryForm = (props: any) => { } setIsLoading(false); }; - - fetchData(); + if (minQuantityRes && minQuantityData) fetchData(); }, [minQuantityData, minQuantityRes, state.form]); useEffect(() => { diff --git a/src/Components/Facility/TransferPatientDialog.tsx b/src/Components/Facility/TransferPatientDialog.tsx index 993c2ee3a6a..dd832edf3c5 100644 --- a/src/Components/Facility/TransferPatientDialog.tsx +++ b/src/Components/Facility/TransferPatientDialog.tsx @@ -123,7 +123,7 @@ const TransferPatientDialog = (props: Props) => { }, }); setIsLoading(false); - if (res && data && res.status === 200) { + if (res?.ok && data && res.status === 200) { dispatch({ type: "set_form", form: initForm }); handleOk(); Notification.Success({ diff --git a/src/Components/Facility/TreatmentSummary.tsx b/src/Components/Facility/TreatmentSummary.tsx index 26299bad021..fb9a652b361 100644 --- a/src/Components/Facility/TreatmentSummary.tsx +++ b/src/Components/Facility/TreatmentSummary.tsx @@ -19,72 +19,54 @@ const TreatmentSummary = (props: any) => { const [investigations, setInvestigations] = useState>([]); const [dailyRounds, setDailyRounds] = useState({}); - const { - res: patientRes, - data: patientResData, - refetch: patientFetch, - } = useQuery(routes.getPatient, { + const { refetch: patientFetch } = useQuery(routes.getPatient, { pathParams: { id: patientId, }, + prefetch: patientId !== undefined, + onResponse: ({ res, data }) => { + setIsLoading(true); + if (res?.ok && data) { + setPatientData(data); + } + setIsLoading(false); + }, }); - useEffect(() => { - setIsLoading(true); - if (patientRes && patientResData) { - setPatientData(patientResData); - } else { - setPatientData({}); - } - setIsLoading(false); - }, [patientId, patientRes, patientResData]); - - const { - res: investigationRes, - data: investigationData, - refetch: investigationFetch, - } = useQuery(routes.getInvestigation, { + const { refetch: investigationFetch } = useQuery(routes.getInvestigation, { pathParams: { consultation_external_id: consultationId, }, + prefetch: consultationId !== undefined, + onResponse: ({ res, data }) => { + setIsLoading(true); + if (res?.ok && data) { + const valueMap = data.results.reduce( + (acc: any, cur: { id: any }) => ({ ...acc, [cur.id]: cur }), + {} + ); + setInvestigations(valueMap); + } + setIsLoading(false); + }, }); - useEffect(() => { - setIsLoading(true); - if (investigationRes && investigationData?.results) { - const valueMap = investigationData.results.reduce( - (acc: any, cur: { id: any }) => ({ ...acc, [cur.id]: cur }), - {} - ); - setInvestigations(valueMap); - } else { - setInvestigations([]); - } - setIsLoading(false); - }, [consultationId, investigationRes, investigationData]); - - const { - res: consultationRes, - data: consultationfetchData, - refetch: consultationFetch, - } = useQuery(routes.getConsultation, { + const { refetch: consultationFetch } = useQuery(routes.getConsultation, { pathParams: { id: consultationId, }, - }); - - useEffect(() => { - setIsLoading(true); - if (consultationRes && consultationfetchData) { - setConsultationData(consultationfetchData); - if (consultationfetchData.last_daily_round) { - setDailyRounds(consultationfetchData.last_daily_round); // add last_daily_rounds in model(not specified in documentation) + prefetch: consultationId !== undefined, + onResponse: ({ res, data }) => { + setIsLoading(true); + if (res?.ok && data) { + setConsultationData(data); + if (data.last_daily_round) { + setDailyRounds(data.last_daily_round); // added last_daily_rounds in model(not present in documentation) + } } - } else { - setConsultationData({}); - } - setIsLoading(false); - }, [consultationId, consultationRes, consultationfetchData]); + setIsLoading(false); + }, + }); useEffect(() => { patientFetch(); diff --git a/src/Components/Facility/TriageForm.tsx b/src/Components/Facility/TriageForm.tsx index 7dda4039a28..4061e73055a 100644 --- a/src/Components/Facility/TriageForm.tsx +++ b/src/Components/Facility/TriageForm.tsx @@ -69,85 +69,61 @@ export const TriageForm = (props: triageFormProps) => { const headerText = !id ? "Add Triage" : "Edit Triage"; const buttonText = !id ? "Save Triage" : "Update Triage"; - const { - res: dataRes, - data: dataFetch, - refetch: fetchData, - } = useQuery(routes.getTriageDetails, { + useQuery(routes.getTriageDetails, { pathParams: { facilityId: String(facilityId), id: String(id), }, + prefetch: id !== undefined && facilityId !== undefined, + onResponse: ({ res, data }) => { + setIsLoading(true); + if (res?.ok && data) { + // Edit Form functionality + dispatch({ + type: "set_form", + form: { + entry_date: data.entry_date + ? dayjs(data.entry_date).toDate() + : null, + num_patients_visited: data.num_patients_visited, + num_patients_home_quarantine: data.num_patients_home_quarantine, + num_patients_isolation: data.num_patients_isolation, + num_patient_referred: data.num_patient_referred, + num_patient_confirmed_positive: data.num_patient_confirmed_positive, + }, + }); + } + setIsLoading(false); + }, }); - useEffect(() => { - setIsLoading(true); - if (id && dataFetch) { - // Edit Form functionality - dispatch({ - type: "set_form", - form: { - entry_date: dataFetch.entry_date - ? dayjs(dataFetch.entry_date).toDate() - : null, - num_patients_visited: dataFetch.num_patients_visited, - num_patients_home_quarantine: dataFetch.num_patients_home_quarantine, - num_patients_isolation: dataFetch.num_patients_isolation, - num_patient_referred: dataFetch.num_patient_referred, - num_patient_confirmed_positive: - dataFetch.num_patient_confirmed_positive, - }, - }); - } - setIsLoading(false); - }, [facilityId, id, dataFetch, dataRes]); - - useEffect(() => { - fetchData(); - }, [fetchData, id]); - - const { - res: triageRes, - data: triageData, - refetch: triageFetch, - } = useQuery(routes.getTriage, { + useQuery(routes.getTriage, { pathParams: { facilityId: String(facilityId), }, + prefetch: facilityId !== undefined, + onResponse: ({ res, data }) => { + if (res?.ok && data && data.results && data.results.length > 0) { + const firstResult = data.results[0]; + const updatedDataArray: PatientStatsModel[] = [ + { + id: Number(firstResult.id), + entryDate: firstResult.entry_date.toString(), + num_patients_visited: firstResult.num_patients_visited, + num_patients_home_quarantine: + firstResult.num_patients_home_quarantine, + num_patients_isolation: firstResult.num_patients_isolation, + num_patient_referred: firstResult.num_patient_referred, + entry_date: Number(firstResult.entry_date), + num_patient_confirmed_positive: + firstResult.num_patient_confirmed_positive, + }, + ]; + setPatientStatsData(updatedDataArray); + } + }, }); - // this will fetch all triage data of the facility - useEffect(() => { - if ( - triageRes && - triageData && - triageData.results && - triageData.results.length > 0 - ) { - const firstResult = triageData.results[0]; - const updatedDataArray: PatientStatsModel[] = [ - { - id: Number(firstResult.id), - entryDate: firstResult.entry_date.toString(), - num_patients_visited: firstResult.num_patients_visited, - num_patients_home_quarantine: - firstResult.num_patients_home_quarantine, - num_patients_isolation: firstResult.num_patients_isolation, - num_patient_referred: firstResult.num_patient_referred, - entry_date: Number(firstResult.entry_date), - num_patient_confirmed_positive: - firstResult.num_patient_confirmed_positive, - }, - ]; - - setPatientStatsData(updatedDataArray); - } - }, [facilityId, triageData, triageRes]); - - useEffect(() => { - triageFetch(); - }, [triageFetch]); - useEffect(() => { async function fetchFacilityName() { if (facilityId) { @@ -156,7 +132,7 @@ export const TriageForm = (props: triageFormProps) => { id: String(facilityId), }, }); - if (res && data) setFacilityName(data.name || ""); + if (res?.ok && data) setFacilityName(data.name || ""); } else { setFacilityName(""); } @@ -228,7 +204,7 @@ export const TriageForm = (props: triageFormProps) => { }, }); setIsLoading(false); - if (res && data) { + if (res?.ok && data) { dispatch({ type: "set_form", form: initForm }); if (id) { Notification.Success({ From 74024f68fe382d27070ff506306a117bd0dca7f6 Mon Sep 17 00:00:00 2001 From: sriharsh05 Date: Tue, 7 Nov 2023 12:23:02 +0530 Subject: [PATCH 10/10] discarded changes made to package-lock.json in one of the previous commit --- src/Components/Facility/HospitalList.tsx | 3 -- src/Components/Facility/LegacyFacilityCNS.tsx | 28 ++++++++++++++----- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/Components/Facility/HospitalList.tsx b/src/Components/Facility/HospitalList.tsx index 0942abeb408..caf18e3481f 100644 --- a/src/Components/Facility/HospitalList.tsx +++ b/src/Components/Facility/HospitalList.tsx @@ -93,12 +93,9 @@ export const HospitalList = () => { local_body_object: result.local_body_object, district_object: result.district_object, state_object: result.state_object, - state: result.state, ward_object: result.ward_object, modified_date: result.modified_date, created_date: result.created_date, - local_body: result.local_body, - ward: result.ward, })); setData(transformedData); diff --git a/src/Components/Facility/LegacyFacilityCNS.tsx b/src/Components/Facility/LegacyFacilityCNS.tsx index 6bc1870d29e..6f10a82de0d 100644 --- a/src/Components/Facility/LegacyFacilityCNS.tsx +++ b/src/Components/Facility/LegacyFacilityCNS.tsx @@ -82,15 +82,29 @@ export default function LegacyFacilityCNS({ expected_type_c_cylinders: data.expected_type_c_cylinders, expected_type_d_cylinders: data.expected_type_d_cylinders, expected_oxygen_requirement: data.expected_oxygen_requirement, - local_body_object: data.local_body_object, - district_object: data.district_object, - state_object: data.state_object, - ward_object: data.ward_object, + local_body_object: { + name: data.local_body_object.name, + body_type: data.local_body_object.body_type, + localbody_code: data.local_body_object.localbody_code, + district: data.local_body_object.district, + }, + district_object: { + id: data.district_object.id, + name: data.district_object.name, + state: data.district_object.state, + }, + state_object: { + id: data.state_object.id, + name: data.state_object.name, + }, + ward_object: { + id: data.ward_object.id, + name: data.ward_object.name, + number: data.ward_object.number, + local_body: data.ward_object.local_body, + }, modified_date: data.modified_date, created_date: data.created_date, - local_body: data.local_body, - ward: data.ward, - state: data.state, }; setFacility(updateData);