Skip to content

Commit

Permalink
Added facility features (#2800)
Browse files Browse the repository at this point in the history
  • Loading branch information
skks1212 committed Jul 4, 2022
1 parent 9fceec2 commit 75ee9f2
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 3 deletions.
23 changes: 23 additions & 0 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -690,3 +690,26 @@ export const getCameraPTZ: (precision: number) => CameraPTZ[] = (precision) => [
shortcutKey: ["F"],
},
];

export const FACILITY_FEATURE_TYPES = [
{
id : 1,
name : "CT Scan Facility"
},
{
id : 2,
name : "Maternity Care"
},
{
id : 3,
name : "X-Ray facility"
},
{
id : 4,
name : "Neonatal care"
},
{
id : 5,
name : "Operation theater"
}
];
23 changes: 21 additions & 2 deletions src/Components/Facility/FacilityCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { parsePhoneNumberFromString } from "libphonenumber-js";
import React, { useCallback, useReducer, useState } from "react";
import { useDispatch } from "react-redux";
import {
FACILITY_FEATURE_TYPES,
FACILITY_TYPES,
KASP_ENABLED,
KASP_STRING,
Expand All @@ -42,6 +43,7 @@ import {
import * as Notification from "../../Utils/Notifications.js";
import {
MultilineInputField,
MultiSelectField,
PhoneNumberField,
SelectField,
TextInputField,
Expand Down Expand Up @@ -73,6 +75,7 @@ type FacilityForm = {
state: string;
district: string;
local_body: string;
features : string[];
ward: string;
kasp_empanelled: string;
address: string;
Expand All @@ -98,6 +101,7 @@ const initForm: FacilityForm = {
local_body: "",
ward: "",
kasp_empanelled: "false",
features : [],
address: "",
phone_number: "",
latitude: "",
Expand Down Expand Up @@ -229,6 +233,7 @@ export const FacilityCreate = (props: FacilityProps) => {
state: res.data.state ? res.data.state : "",
district: res.data.district ? res.data.district : "",
local_body: res.data.local_body ? res.data.local_body : "",
features : res.data.features || [],
ward: res.data.ward_object ? res.data.ward_object.id : initialWards,
kasp_empanelled: res.data.kasp_empanelled
? String(res.data.kasp_empanelled)
Expand Down Expand Up @@ -408,6 +413,7 @@ export const FacilityCreate = (props: FacilityProps) => {
address: state.form.address,
pincode: state.form.pincode,
local_body: state.form.local_body,
features : state.form.features,
ward: state.form.ward,
kasp_empanelled: JSON.parse(state.form.kasp_empanelled),
location:
Expand Down Expand Up @@ -529,7 +535,20 @@ export const FacilityCreate = (props: FacilityProps) => {
errors={state.errors.name}
/>
</div>

<div className="">
<InputLabel id="features-label">Features*</InputLabel>
<MultiSelectField
data-test="facility-features"
name="features"
variant="outlined"
margin="dense"
value={state.form.features}
options={FACILITY_FEATURE_TYPES}
onChange={(e)=>handleChange(e)}
optionValue="name"
errors={state.errors.features}
/>
</div>
<div>
<InputLabel id="gender-label">State*</InputLabel>
{isStateLoading ? (
Expand Down Expand Up @@ -574,7 +593,7 @@ export const FacilityCreate = (props: FacilityProps) => {
)}
</div>

<div className="md:col-span-2">
<div className="">
<InputLabel id="local_body-label">Localbody*</InputLabel>
{isLocalbodyLoading ? (
<CircularProgress size={20} />
Expand Down
15 changes: 14 additions & 1 deletion src/Components/Facility/FacilityHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import DialogActions from "@material-ui/core/DialogActions";
import DialogTitle from "@material-ui/core/DialogTitle";
import DialogContent from "@material-ui/core/DialogContent";
import DialogContentText from "@material-ui/core/DialogContentText";
import { BED_TYPES, DOCTOR_SPECIALIZATION } from "../../Common/constants";
import { BED_TYPES, DOCTOR_SPECIALIZATION, FACILITY_FEATURE_TYPES } from "../../Common/constants";
import { statusType, useAbortableEffect } from "../../Common/utils";
import {
getPermittedFacility,
Expand Down Expand Up @@ -244,6 +244,19 @@ export const FacilityHome = (props: any) => {
</a>
</div>
</div>
<div className="flex items-center gap-3 mt-4">
<div>
<h1 className="text-lg font-bold">Features</h1>
<div className="flex gap-2 flex-wrap mt-2">
{facilityData.features?.map((feature, i)=>(
<div key={i} className="bg-primary-100 text-primary-600 font-semibold px-3 py-1 rounded-full border border-primary-600 text-sm">
{FACILITY_FEATURE_TYPES.filter(f=>f.id === feature)[0].name}
</div>
))}
</div>

</div>
</div>
</div>
<div className="lg:flex-1 min-w-[300px] md:flex flex-col justify-between">
<div className="mb-4">
Expand Down
8 changes: 8 additions & 0 deletions src/Components/Facility/HospitalList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { statusType, useAbortableEffect } from "../../Common/utils";

import {
DOWNLOAD_TYPES,
FACILITY_FEATURE_TYPES,
FACILITY_TYPES,
KASP_STRING,
} from "../../Common/constants";
Expand Down Expand Up @@ -378,6 +379,13 @@ export const HospitalList = (props: any) => {
{facility.facility_type}
</div>
</div>
<div className="flex gap-1 flex-wrap mt-2">
{facility.features?.map((feature : number, i : number)=>(
<div key={i} className="bg-primary-100 text-primary-600 font-semibold px-3 py-1 rounded-full border text-xs">
{FACILITY_FEATURE_TYPES.filter(f=>f.id === feature)[0].name}
</div>
))}
</div>
<div className="mt-2 flex justify-between">
<div className="flex flex-col">
<div className="font-semibold">
Expand Down
1 change: 1 addition & 0 deletions src/Components/Facility/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface FacilityModel {
cover_image_url?: string;
facility_type?: string;
address?: string;
features? : number[];
location?: {
latitude: number;
longitude: number;
Expand Down

0 comments on commit 75ee9f2

Please sign in to comment.