From 72e5b27e138587331973d36c2c45401b878e88ad Mon Sep 17 00:00:00 2001 From: sriharsh05 Date: Mon, 30 Oct 2023 22:57:42 +0530 Subject: [PATCH] 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