Skip to content

Commit

Permalink
remove redundant models
Browse files Browse the repository at this point in the history
  • Loading branch information
sriharsh05 committed Oct 30, 2023
1 parent ca42eb8 commit 72e5b27
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 60 deletions.
16 changes: 0 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/Components/Facility/FacilityCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
46 changes: 14 additions & 32 deletions src/Components/Facility/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,6 @@ export type IStateListResponse = PaginatedResponse<UnitModel>;
export type IDistrictLocalBodyResponse = StateModel & {
state: number;
};
export type IWardLocalBodyResponse = StateModel & {
number: number;
local_body: number;
};

export type IFacilityRequest = Omit<
FacilityModel,
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -641,14 +631,6 @@ export type IFlagInventoryItemResponse = {
created_by: number;
};

export type IAssetBedResponse = PaginatedResponse<
BaseResponse & {
asset_object: Asset;
bed_object: BedObjectModel;
meta: Record<string, string>;
}
>;

export type ICreateTriageRequest = {
entry_date?: string;
num_patients_visited?: number;
Expand Down
17 changes: 8 additions & 9 deletions src/Redux/api.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -9,7 +9,6 @@ import {
IUserListFacilityResponse,
LocationModel,
IUserFacilityResponse,
IAllFacilitiesResponse,
IFacilityUserResponse,
ILocalBodyResponse,
IInventorySummaryResponse,
Expand All @@ -25,17 +24,17 @@ import {
ISetMinQuantityRequest,
ISetMinQuantityResponse,
IFlagInventoryItemResponse,
IAssetBedResponse,
IStateListResponse,
IDistrictLocalBodyResponse,
IWardLocalBodyResponse,
ICreateTriageRequest,
ICreateTriageResponse,
IFacilityNotificationResponse,
CapacityModal,
StateModel,
InventoryItemObjectModel,
DeleteModel,
FacilityModel,
WardModel,
} from "../Components/Facility/models";
import { PatientModel } from "../Components/Patient/models";
import { UserModel } from "../Components/Users/models";
Expand Down Expand Up @@ -222,7 +221,7 @@ const routes = {

getAnyFacility: {
path: "/api/v1/getallfacilities/{id}/",
TRes: Type<IAllFacilitiesResponse>(),
TRes: Type<FacilityModel>(),
},

updateFacility: {
Expand All @@ -235,8 +234,8 @@ const routes = {
partialUpdateFacility: {
path: "/api/v1/facility/{id}/",
method: "PATCH",
TBody: Type<IFacilityRequest>(),
TRes: Type<IFacilityResponse>(),
TBody: Type<FacilityModel>(),
TRes: Type<FacilityModel>(),
},

deleteFacilityCoverImage: {
Expand Down Expand Up @@ -275,7 +274,7 @@ const routes = {
listAssetBeds: {
path: "/api/v1/assetbed/",
method: "GET",
TRes: Type<IAssetBedResponse>(),
TRes: Type<PaginatedResponse<AssetBedModel>>(),
},
createAssetBed: {
path: "/api/v1/assetbed/",
Expand Down Expand Up @@ -626,7 +625,7 @@ const routes = {
},
getWardByLocalBody: {
path: "/api/v1/ward/?local_body={id}",
TRes: Type<IWardLocalBodyResponse>(),
TRes: Type<PaginatedResponse<WardModel>>(),
},

// Sample Test
Expand Down

0 comments on commit 72e5b27

Please sign in to comment.