Skip to content

Commit

Permalink
Merge pull request #69 from palladiumkenya/AddKephLevel
Browse files Browse the repository at this point in the history
Add keph level
  • Loading branch information
MaryKilewe authored Apr 4, 2024
2 parents 0789ac8 + c84afee commit 2fb12e3
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 36 deletions.
10 changes: 7 additions & 3 deletions src/components/EditPartners.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,17 @@ const EditPartners = (props) => {
<p class="mb-3 text-center">Update details about a partner</p>

<fieldset disabled={!isOrgSteward}>
<Label for="lat">SDP CODE:</Label>
<Input type="text" name="partner" value={Partner_data.sdp_code} disabled/>
<Label for="sdp_code">SDP CODE:</Label>
<Input type="text" name="sdp_code" value={Partner_data.sdp_code} disabled/>

<Label for="lat">Partner:</Label>
<Label for="partner">Partner:</Label>
<Input type="text" name="partner" value={Partner_data.partner}
onChange={(e) => {setPartner_data({...Partner_data, "partner":e.target.value}) }}/>

<Label for="prime_partner_name">Prime Partner Name:</Label>
<Input type="text" name="prime_partner_name" value={Partner_data.prime_partner_name}
onChange={(e) => {setPartner_data({...Partner_data, "prime_partner_name":e.target.value}) }}/>

<Label for="partner">Agency:</Label>
<Input id="agency" name="agency_id" type="select" value={Partner_data.agency_id}
onChange={(e) => {setPartner_data({...Partner_data, "agency_id":e.target.value}) }}>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ function Footer(props) {

return (
<footer class="shadow" style={{backgroundColor:'#2f4050',position: "fixed",
bottom: 0, width:"100%", color:"white", fontSize:"10px"}}>
Version 1.000
bottom: 0, width:"100%", color:"white", fontSize:"10px"}}>
Version 2.000

</footer>

);

}

export default Footer;
export default Footer;
40 changes: 24 additions & 16 deletions src/components/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,31 @@ const Home = (props) =>{
setFileUpload(event.target.files[0])
}

const handleExcelHISSubmit= () => {
const handleExcelHISSubmit= async () => {
setShowUploadExcelSpinner(true)

if (fileUpload) {
const formData = new FormData();
formData.append('file', fileUpload);
// Use fetch or a library like Axios to send the file to the server.
// Replace 'YOUR_UPLOAD_URL' with your server's upload endpoint.
fetch(API_URL + "/uploadExcelHIS", {
await fetch(API_URL + "/uploadExcelHIS", {
method: 'POST',
body: formData,
})
.then((response) => {
if (response.status==200){
}) .then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json(); // Parse response body as JSON
})
.then((data) => {

if (data.status_code==200){
localStorage.setItem("flashMessage", 'Successfully Synced!');
window.location.href = BASE_URL;
}else{
localStorage.setItem("flashMessage", 'Filed to Sync because of One or Two errors! Contact admin for assistance');
localStorage.setItem("flashMessage", 'Failed to Sync because of One or Two errors! Contact ' +
'admin for assistance.'+data.status_message);
window.location.href = BASE_URL;
}

Expand Down Expand Up @@ -158,16 +165,17 @@ const Home = (props) =>{
<div className="d-flex justify-content-end mb-3" style={{paddingTop:"20px"}}>
<a href="/facilities/add_facility" className="btn btn-sm green_bg_color text-white" style={{width:"200px", paddingRight:"10px"}}>Add New Facility</a>
</div>
{ isAuthenticated && userEmailAllowed &&
<div className="d-flex justify-content-end mb-3" style={{paddingTop:"10px"}}>
<SiMicrosoftexcel onClick={handleExcelHISSubmit} style={{color:"green", fontSize:"30px"}}/>
<input type="file" onChange={uploadExcelHIS} required/>
<button onClick={handleExcelHISSubmit} className="btn btn-sm green_bg_color text-white">
Upload HIS Excel
{ showUploadExcelSpinner && <Spinner style={{width: "1.2rem", height: "1.2rem"}}></Spinner> }
</button>
</div>
}
{/*{ isAuthenticated && userEmailAllowed && */}
{/* { isAuthenticated &&*/}
{/* <div className="d-flex justify-content-end mb-3" style={{paddingTop:"10px"}}>*/}
{/* <SiMicrosoftexcel onClick={handleExcelHISSubmit} style={{color:"green", fontSize:"30px"}}/>*/}
{/* <input type="file" onChange={uploadExcelHIS} accept=".xlsx" required/>*/}
{/* <button onClick={handleExcelHISSubmit} className="btn btn-sm green_bg_color text-white">*/}
{/* Upload HIS Excel*/}
{/* { showUploadExcelSpinner && <Spinner style={{width: "1.2rem", height: "1.2rem"}}></Spinner> }*/}
{/* </button>*/}
{/* </div>*/}
{/*}*/}

<div className="d-flex justify-content-between">
<h4>
Expand Down
2 changes: 1 addition & 1 deletion src/components/PendingApprovals.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const PendingApprovals = (props) =>{
<td>{facility.name}</td>
<td>{facility.county}</td>
<td>{facility.sub_county}</td>
<td>{facility.owner}</td>
<td>{facility.partner}</td>
<td style={{color:"red"}}>False</td>
<td style={{color:"red"}}>{facility.submitted_by}</td>
<td>{facility.date_edited}</td>
Expand Down
2 changes: 1 addition & 1 deletion src/components/SubmittedApprovals.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const SubmittedApprovals = (props) =>{
<td>{facility.name}</td>
<td>{facility.county}</td>
<td>{facility.sub_county}</td>
<td>{facility.owner}</td>
<td>{facility.partner}</td>
<td>{facility.submitted_by}</td>
<td>{facility.date_edited}</td>
{/* <td>{facility.emr_type}</td> */}
Expand Down
23 changes: 15 additions & 8 deletions src/components/UpdateFacility.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ const UpdateFacility = (props) => {
const [isAllowedUser, setIsAllowedUser] = useState(false); // allowed users are either organisation stwewards or HIS approvers
const [showSpinner, setShowSpinner] = useState(false);
const showSearchIcon = "none";
const [disableSubmit, setDisableSubmit] = useState(false);
const [msg, setMsg] = useState("");


const [ctToggle, setCtToggle] = useState("");
const [htsToggle, setHTSToggle] = useState("");
Expand Down Expand Up @@ -54,7 +57,7 @@ const UpdateFacility = (props) => {

await userManager.getUser().then((res) => {
// if (res.profile.OrganizationName.toLowerCase() == filtered_partner[0].partner.toLowerCase() && (res.profile.UserType == "2" || res.profile.UserType == "5")) {
if (res.profile.UserType == "2" || res.profile.UserType == "5") {
if (res.profile.UserType == "2" || res.profile.UserType == "5" || res.profile.UserType == "1") {
setIsAllowedUser(true)
} else {
setIsAllowedUser(false)
Expand Down Expand Up @@ -110,7 +113,8 @@ const UpdateFacility = (props) => {

const handleSubmit = async (event) => {
setShowSpinner(true)

setDisableSubmit(true)
const msg =''
event.preventDefault();
Facility_data['username'] = props.user.profile.name
Facility_data['email'] = props.user.profile.email
Expand All @@ -122,19 +126,19 @@ const UpdateFacility = (props) => {
.then(function (resp){
localStorage.setItem("flashMessage", "Facility has been updated. Modifications to facility data must first be approved before viewing");
window.location.href = BASE_URL + `/facilities/submitted/approvals`;
}).catch(function (error) {localStorage.setItem("flashMessage", "Error caught ===> "+error);});
}).catch(function (error) {
localStorage.setItem("flashMessage", "Error sending email to approver ");
window.location.href = BASE_URL + `/facilities/submitted/approvals`;

localStorage.setItem("flashMessage", "Facility has been updated. Modifications to facility data must first be approved before viewing");
// window.location.href = BASE_URL + `/facilities/update_facility/${fac_id}`;
// window.location.href = BASE_URL + '/'+response.data.redirect_url;
});

// setShowSpinner(false)
})
.catch(function (error) {
localStorage.setItem("flashMessage", "Error. Please contact admin for assistance "+error);
window.location.href = BASE_URL + `/facilities/update_facility/${fac_id}`;

setShowSpinner(false)
setDisableSubmit(false)
});
};

Expand Down Expand Up @@ -211,7 +215,10 @@ const UpdateFacility = (props) => {
}

<div class="d-flex justify-content-center mb-5">
<input class="btn green_bg_color text-white" value="Update Data" type="submit" style={{width:"200px"}} />
{/*<input class="btn green_bg_color text-white" value="Update Data" type="submit" style={{width:"200px"}} />*/}
<button className="btn green_bg_color text-white" type="submit" disabled={disableSubmit}>
Update Data
</button>
{showSpinner && <Spinner style={{width: "1.2rem", height: "1.2rem"}}></Spinner> }
</div>
</fieldset>
Expand Down
5 changes: 5 additions & 0 deletions src/components/ViewFacility.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ const ViewFacility = () => {
<b>Infrastructure Type : </b>
<p>{Facility_data.infrastructure_type}</p>
</div>
<div className="d-flex col-md-3 mb-2">
<b>KEPH_Level : </b>
<p>{Facility_data.KEPH_Level}</p>
</div>


<b>Facility Type</b>
<div className="d-flex justify-content-between col-md-2 mb-4">
Expand Down
2 changes: 2 additions & 0 deletions src/components/ViewPartners.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const EditPartners = () => {
<th>Agency</th>
<th>SDP Code</th>
<th>Partner name</th>
<th>Prime Partner Name</th>
<th>HIS Approver</th>
<th>Actions</th>
</tr>
Expand All @@ -95,6 +96,7 @@ const EditPartners = () => {
<td id="agency_container"> {partner.agency}</td>
<td id="agency_container"> {partner.sdp_code}</td>
<td id="agency_container">{partner.name}</td>
<td id="agency_container">{partner.prime_partner_name}</td>
<td id="agency_container">{partner.approver}</td>
<td id="agency_container">
<Link to={"/facilities/edit/partner/" + partner.id}>
Expand Down
26 changes: 22 additions & 4 deletions src/components/form_components/FacilityInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function FacilityInfo(props) {
if (props.Counties_list.length >0){
return props.Counties_list.filter(item => item.county === Number(id));
}
};
};

const [SubCounties_list, setSubCounties_list] = useState(props.facility_data.county != "" ? getInitialSubCounties(Number(props.facility_data.county)) : []);

Expand All @@ -34,9 +34,9 @@ function FacilityInfo(props) {
// }else{
// getSubCounties(e)
// }
}
};
}

};


const getSubCounties = (id) => {
Expand Down Expand Up @@ -263,6 +263,24 @@ function FacilityInfo(props) {

</Input>
</div>
<div className="form-group col-md-3 mb-4">
<Label for="KEPH_Level">KEPH_Level:</Label>
<Input id="KEPH_Level" name="KEPH_Level" type="select" required
value={props.facility_data.KEPH_Level} disabled={disabled}
className={props.Original_data && props.Original_data.KEPH_Level != props.facility_data.KEPH_Level && "highlight_changed_data"}
onChange={(e) => props.setFacility_data({
...props.facility_data,
"KEPH_Level": e.target.value
})}>
<option value=""></option>
<option value="Level 1">Level 1</option>
<option value="Level 2">Level 2</option>
<option value="Level 3">Level 3</option>
<option value="Level 4">Level 4</option>
<option value="Level 5">Level 5</option>
<option value="Level 6">Level 6</option>
</Input>
</div>

<b>Facility Type</b>
<div className="d-flex justify-content-between col-md-2 col-lg-4 mb-4">
Expand Down
1 change: 1 addition & 0 deletions src/components/json_data/initial_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const initial_data = {
"asal": false,
"pepfar": false,
"infrastructure_type": "",
"KEPH_Level": "",
"CT": false,
"HTS": false,
"IL": false,
Expand Down
4 changes: 4 additions & 0 deletions src/services/UserService.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ if (window.location.host === "localhost:3000"){
}else if (window.location.host === "data.kenyahmis.org:3838"){
client_id = "dwh.his"
authority = 'https://auth.kenyahmis.org/dwhidentity'
}else if (window.location.host === "histest.kenyahmis.org"){
client_id = "dwh.histest"
authority = 'https://identity.kenyahmis.org'
console.log("id ===> ", client_id)
}else if (window.location.host === "prod.kenyahmis.org:3001"){
client_id = "dwh.his-prod"
authority = 'https://identity.kenyahmis.org'
Expand Down

0 comments on commit 2fb12e3

Please sign in to comment.