Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix 1 : incomplete facilities color coding and facility export #255

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions components/HeaderLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ export default function HeaderLayout({
</button>
<ul className="flex-col md:flex-row items-start md:items-start bg-gray-50 inset-x-4 mt-1 md:mx-6 py-1 md:p-1 md:bg-transparent shadow border md:border-none md:shadow-none gap-5 hidden md:flex group-focus:flex group-active:flex group-hover:flex absolute md:relative">
{/* Dashboard / Home */}
{
isLoggedIn &&

<li className="flex-wrap font-semibold" id="dashboard">
<Link href={isLoggedIn ? "/dashboard" : "/"}>
<p
Expand All @@ -184,8 +187,11 @@ export default function HeaderLayout({
</p>
</Link>
</li>
}
{/* Facilities */}
{

isLoggedIn &&
<li className="flex-wrap font-semibold">
<Link href="/facilities">
<p
Expand All @@ -205,9 +211,11 @@ export default function HeaderLayout({
</p>
</Link>
</li>
}

{/* Community Units */}

{
isLoggedIn &&
<li className="flex-wrap font-semibold">
<Link href="/community-units">
<p
Expand All @@ -225,11 +233,13 @@ export default function HeaderLayout({
</p>
</Link>
</li>
}

{/* Users */}

{( groupID == 7 ||
groupID == 2 ||
groupID == 5 ||
groupID == 3 ) && isLoggedIn &&
<li className="flex-wrap font-semibold">
<Link href="/users">
Expand Down Expand Up @@ -270,8 +280,7 @@ export default function HeaderLayout({
}
{/* System setup */}
{
hasPermission(/^common.add_county$/, userPermissions) &&
hasPermission(/^common.delete_county$/, userPermissions) && isLoggedIn&&
groupID == 7 && isLoggedIn &&
<li className="flex-wrap font-semibold">
<Link href="/system_setup">
<p
Expand Down Expand Up @@ -511,18 +520,7 @@ export default function HeaderLayout({
</button>
)}
</Menu.Item>
{/* <Menu.Item as="li" className="flex items-center w-full gap-1">
{({ active }) => (
<a
className={`w-full hover:text-blue-400 font-medium flex items-center ${active && "text-blue-400"
}`}
href="https://KMHFR.health.go.ke/"
target="_blank"
>
KMHFR live <ExternalLinkIcon className="h-4 w-4 ml-2" />
</a>
)}
</Menu.Item> */}

<Menu.Item
as="li"

Expand Down
10 changes: 7 additions & 3 deletions pages/auth/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@ const Login = (props) => {
<label className="text-gray-800">Email / P_No</label>
<input type="text"
data-testid="email_input"
autoComplete='on'
value={username}
onChange={ev => {
setError('')
setUsername(ev.target.value)
}}
className="border w-full py-3 px-3 leading-none border-blue-600 bg-transparent focus:outline-none focus:border-indigo-700 focus:bg-white text-gray-700" placeholder="email/personal_number" />
className="border w-full py-3 px-3 leading-none border-blue-600 bg-transparent focus:outline-none focus:border-indigo-700 focus:bg-white text-gray-700" placeholder="[email protected]" />
</div>

<div className="flex-col gap-0 items-start w-full">
Expand Down Expand Up @@ -131,7 +132,11 @@ const Login = (props) => {
setError('')
setPassword(ev.target.value)
}}
value={password} className="border w-full py-3 px-3 leading-none border-blue-600 bg-transparent focus:outline-none focus:border-indigo-700 focus:bg-white text-gray-700 pr-16" name="password" type={hidePassword ? 'password' : 'text'}
value={password}
autoSave='on'
autoComplete='on'
aria-autocomplete='inline'
className="border w-full py-3 px-3 leading-none border-blue-600 bg-transparent focus:outline-none focus:border-indigo-700 focus:bg-white text-gray-700 pr-16" name="password" type={hidePassword ? 'password' : 'text'}
/>
</div>
</div>
Expand All @@ -141,7 +146,6 @@ const Login = (props) => {
>{loading ? "Loading..." : "Log in"}</button>
<div className="flex justify-end items-center w-full px-2">
<a data-testid="forgot_password_link" onClick={()=>router.push('/auth/reset_password')} className="text-base text-gray-700 hover:text-blue-700 focus:text-blue-700 active:text-blue-700 hover:underline focus:underline active:underline">Forgot password?</a>

</div>
</div>
</form>
Expand Down
15 changes: 13 additions & 2 deletions pages/community-units/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,19 @@ CommunityUnit.getInitialProps = async (ctx) => {
url = url + '&' + flt.replace('chu_', '') + '=' + ctx?.query[flt];
}
});
// let current_url = url + '&page_size=25000' //change the limit on prod
let current_url = url + '&page_size=100';

// Fetch All facility Count

const getCHUCount = async () => {
return (await (await fetch(`${API_URL}/units/chul?format=json`, {headers: {
'Authorization': 'Bearer ' + token,
'Accept': 'application/json'
}})).json())?.count
}

// const count = await getCHUCount();

let current_url = url + `&page_size=11000`;
if (ctx?.query?.page) {
url = `${url}&page=${ctx.query.page}`;
}
Expand Down
34 changes: 22 additions & 12 deletions pages/facilities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const FacilityHome = (props) => {
</div>
}

<Menu.Items as="ul" className="absolute top-10 right-0 flex flex-col gap-y-1 items-center justify-start bg-white shadow-lg border border-gray-200 p-1 w-1/2">
<Menu.Items as="ul" className="absolute top-10 right-0 z-10 flex flex-col gap-y-1 items-center justify-start bg-white shadow-lg border border-gray-200 p-1 w-1/2">

<Menu.Item as="li" className="p-0 flex items-center w-full text-center hover:bg-gray-200 focus:bg-gray-200 active:bg-gray-200">
{({ active }) => (
Expand Down Expand Up @@ -440,7 +440,7 @@ const FacilityHome = (props) => {
{/* Data Indicator section */}
<div className='w-full p-2 flex justify-between border-b border-blue-600'>
{/* search input */}
{/* `${router.asPath}&qf=approved&approved=true&approved_national_level=true&rejected=false` || '/facilities' */}

<Formik
initialValues={
{
Expand Down Expand Up @@ -531,10 +531,10 @@ const FacilityHome = (props) => {
facilities.map((facility, index) => (
<div key={index}
title={`Incomplete Details : ${facility?.is_complete ? 'none' : facility?.in_complete_details}`}
className="grid grid-cols-8 gap-2 border-b border-blue-600 py-4 hover:bg-blue-50 w-full">
className={`grid grid-cols-8 gap-2 border-b py-4 w-full ${!facility?.is_complete ? 'bg-yellow-50 border-yellow-500 hover:bg-blue-50' : 'bg-transparent border-blue-600 hover:border-yellow-100' }`}>
<div className="px-2 col-span-8 md:col-span-8 lg:col-span-6 flex flex-col group items-center justify-start text-left">
<h3 className="text-2xl font-semibold w-full">
<span onClick={() => router.push({pathname: `/facilities/${facility?.id}`, query: {qf: router.query.qf}})} className="cursor-pointer hover:text-blue-600 group-focus:text-blue-800 active:text-blue-800 " >
<span onClick={() => router.push({pathname: `/facilities/${facility?.id}`, query: {qf: router.query.qf}})} className={`cursor-pointer ${facility?.is_complete ? 'hover:text-blue-600' : 'hover:text-yellow-600'} group-focus:text-blue-800 active:text-blue-800`} >
{facility?.official_name || facility?.official_name || facility?.name}
</span>
</h3>
Expand Down Expand Up @@ -573,9 +573,11 @@ const FacilityHome = (props) => {
</div>
</div>
<div className="col-span-8 md:col-span-8 lg:col-span-2 grid grid-cols-2 grid-rows-4 gap-x-2 gap-y-1 text-lg">
{/* {console.log({facility})} */}
{(facility?.operational || facility?.operation_status_name) ? <span className={"shadow-sm col-start-2 leading-none whitespace-nowrap text-sm py-1 px-2 bg-blue-200 font-semibold text-blue-900"}>Operational</span> : ""}
{!facility?.rejected ? <span className={"shadow-sm leading-none whitespace-nowrap text-sm col-start-2 py-1 px-2 " + (facility?.approved_national_level ? "bg-green-200 font-semibold text-green-900" : "bg-gray-500 font-semibold p-1 text-gray-50")}>{facility?.approved_national_level ? "Approved" : "Not approved"}</span> : <span className={"shadow-sm col-start-2 leading-none whitespace-nowrap text-sm font-semibold py-1 px-2 bg-red-200 text-red-900"}>{facility?.rejected ? "Rejected" : ""}</span>}
{facility?.has_edits ? <span className={"shadow-sm leading-none whitespace-nowrap text-sm col-start-2 py-1 px-2 bg-yellow-200 font-semibold text-yellow-900"}>Has edits</span> : ""}
{!facility?.is_complete ? <span className={"shadow-sm leading-none whitespace-nowrap text-sm col-start-2 py-1 px-2 bg-pink-200 font-semibold text-pink-900"}>Incomplete</span> : ""}
</div>
</div>
))
Expand Down Expand Up @@ -703,9 +705,13 @@ FacilityHome.getInitialProps = async (ctx) => {

const API_URL = process.env.NEXT_PUBLIC_API_URL;




const fetchFilters = token => {
let filters_url = API_URL + '/common/filtering_summaries/?fields=county%2Cfacility_type%2Cconstituency%2Cward%2Coperation_status%2Cservice_category%2Cowner_type%2Cowner%2Cservice%2Ckeph_level%2Csub_county'


return fetch(filters_url, {
headers: {
'Authorization': 'Bearer ' + token,
Expand All @@ -724,7 +730,7 @@ FacilityHome.getInitialProps = async (ctx) => {
})
}

const fetchData = (token) => {
const fetchData = async (token) => {

let url = API_URL + '/facilities/facilities/?fields=id,code,official_name,facility_type_name,owner_name,county,sub_county,constituency_name,ward_name,updated,operation_status_name,sub_county_name,name,is_complete,in_complete_details,approved_national_level,has_edits,approved,rejected,keph_level'

Expand Down Expand Up @@ -777,22 +783,26 @@ FacilityHome.getInitialProps = async (ctx) => {
}


// Remove approved field if fetching for Facilities pending approval
// if (flt === 'to_publish') url = url.replace('approved,', '')



})

// Fetch All facility Count

// const getFacilityCount = async () => {
// return (await (await fetch(`${API_URL}/facilities/facilities?format=json`, {headers: {
// 'Authorization': 'Bearer ' + token,
// 'Accept': 'application/json'
// }})).json())?.count
// }

let current_url = url + '&page_size=100'

let current_url = url + `&page_size=19000`
if (ctx?.query?.page) {
url = `${url}&page=${ctx.query.page}`
}



console.log({url});

return fetch(url, {
headers: {
'Authorization': 'Bearer ' + token,
Expand Down
Loading