Skip to content

Commit

Permalink
Merge pull request #295 from ertush/hotfix-dev
Browse files Browse the repository at this point in the history
Revert "Fixed report page"
  • Loading branch information
ertush authored Feb 5, 2024
2 parents 85d209e + 80c3e07 commit 6cf1102
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 137 deletions.
44 changes: 22 additions & 22 deletions components/ReportsData.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// import { OtherHouses } from "@mui/icons-material";
import { OtherHouses } from "@mui/icons-material";

export const propsToGridData = (props, index) => {

Expand All @@ -7,7 +7,7 @@ export const propsToGridData = (props, index) => {
// Beds and Cots, Theaters
case 0:
return {
rows: props?.beds_and_cots_by_all_hierachies?.map((
rows: props[`${index}`]?.beds_and_cots_by_all_hierachies.map((
{
ward__sub_county__county__name: county,
ward__sub_county__name: sub_county,
Expand All @@ -32,7 +32,7 @@ export const propsToGridData = (props, index) => {
cots,
id: index

})) || []
}))

, columns: [
{
Expand Down Expand Up @@ -86,7 +86,7 @@ export const propsToGridData = (props, index) => {
// Keph Level
case 1:
return {
rows: props?.facility_keph_level_report_all_hierachies?.map((
rows: props[`${index}`]?.facility_keph_level_report_all_hierachies.map((
{
ward__sub_county__county__name: county,
ward__sub_county__name: sub_county,
Expand All @@ -109,7 +109,7 @@ export const propsToGridData = (props, index) => {
level_6,
id: index

})) || []
}))

, columns: [
{
Expand Down Expand Up @@ -158,7 +158,7 @@ export const propsToGridData = (props, index) => {
// Facility Ownership
case 2:
return {
rows: props?.facility_owner_report_all_hierachies?.map((
rows: props[`${index}`]?.facility_owner_report_all_hierachies.map((
{
ward__sub_county__county__name: county,
ward__sub_county__name: sub_county,
Expand Down Expand Up @@ -233,7 +233,7 @@ export const propsToGridData = (props, index) => {
supreme_council_for_muslims,
id:index

})) || []
}))

, columns: [
{
Expand Down Expand Up @@ -423,7 +423,7 @@ export const propsToGridData = (props, index) => {
// Facility Type
case 3:
return {
rows: props?.facility_type_report_all_hierachies?.map((
rows: props[`${index}`]?.facility_type_report_all_hierachies.map((
{
ward__sub_county__county__name: county,
ward__sub_county__name: sub_county,
Expand Down Expand Up @@ -500,7 +500,7 @@ export const propsToGridData = (props, index) => {
specialized_tertiary_hospitals,
id:index
})
) || [],
),

columns: [
{
Expand Down Expand Up @@ -717,7 +717,7 @@ export const propsToGridData = (props, index) => {
// Regulatory Body
case 4:
return {
rows: props?.facility_regulatory_body_report_all_hierachies?.map((
rows: props[`${index}`]?.facility_regulatory_body_report_all_hierachies.map((
{
ward__sub_county__county__name: county,
ward__sub_county__name: sub_county,
Expand Down Expand Up @@ -751,7 +751,7 @@ export const propsToGridData = (props, index) => {
ppb,
id:index
})
) || [],
),

columns: [
{
Expand Down Expand Up @@ -826,7 +826,7 @@ export const propsToGridData = (props, index) => {
// Services
case 5:
return {
rows: props?.facility_services_report_all_hierachies?.map((
rows: props[`${index}`]?.facility_services_report_all_hierachies.map((
{
facility__ward__sub_county__county__name: county,
facility__ward__sub_county__name: sub_county,
Expand Down Expand Up @@ -920,7 +920,7 @@ export const propsToGridData = (props, index) => {
cat_operating_theaters,
id:index
})
) || [],
),

columns: [
{
Expand Down Expand Up @@ -1176,7 +1176,7 @@ export const propsToGridData = (props, index) => {
// Infrastructure
case 6:
return {
rows: props?.facility_infrastructure_report_all_hierachies?.map((
rows: props[`${index}`]?.facility_infrastructure_report_all_hierachies.map((
{

"ICT INFRASTRUCTURE": cat_ict_infrastructure,
Expand Down Expand Up @@ -1319,7 +1319,7 @@ export const propsToGridData = (props, index) => {
eathen_road,
id:index
})
) || [],
),

columns: [
{
Expand Down Expand Up @@ -1699,7 +1699,7 @@ export const propsToGridData = (props, index) => {
case 7:

return {
rows: props?.chul_status_all_hierachies?.map((
rows: props[`${index}`]?.chul_status_all_hierachies.map((
{
"Fully-functional": fully_functional,
"Non-functional": non_functional,
Expand All @@ -1721,7 +1721,7 @@ export const propsToGridData = (props, index) => {
sub_county,
id:index
})
) || [],
),

columns: [
{
Expand Down Expand Up @@ -1766,7 +1766,7 @@ export const propsToGridData = (props, index) => {
// CHU Services
case 9:
return {
rows: props?.chul_services_all_hierachies || [],
rows: props[`${index}`]?.chul_services_all_hierachies,
columns: [
{
headerName: 'County',
Expand Down Expand Up @@ -1912,7 +1912,7 @@ export const propsToGridData = (props, index) => {
// CHU Count
case 10:
return {
rows: props?.chul_count_all_hierachies?.map((
rows: props[`${index}`]?.chul_count_all_hierachies.map((
{
"chvs": chv,
"ward_name": ward,
Expand All @@ -1932,7 +1932,7 @@ export const propsToGridData = (props, index) => {
number_of_units,
id:index
})
) || [] ,
),

columns: [
{
Expand Down Expand Up @@ -1968,7 +1968,7 @@ export const propsToGridData = (props, index) => {
// Human resource
case 11:
return {
rows: props?.facility_human_resource_category_report_all_hierachies?.map((
rows: props[`${index}`]?.facility_human_resource_category_report_all_hierachies.map((
{

facility_id__ward__sub_county__county__name: county,
Expand Down Expand Up @@ -2023,7 +2023,7 @@ export const propsToGridData = (props, index) => {
support_staffs,
id:index
})
) || [] ,
),

columns: [
{
Expand Down
12 changes: 3 additions & 9 deletions pages/admin_offices/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { PlusIcon } from "@heroicons/react/solid";
import List from '@mui/material/List';
import ListItemButton from '@mui/material/ListItemButton';
import ListItemText from '@mui/material/ListItemText';
import { UserContext } from '../../providers/user'


import {
DataGrid,
Expand Down Expand Up @@ -38,7 +38,7 @@ const StyledDataGrid = styled(DataGrid)(() => ({



function AdminOffices(props) {
const AdminOffices = (props) => {

const router = useRouter()

Expand Down Expand Up @@ -120,7 +120,7 @@ function AdminOffices(props) {
</div>
</div>
</div>
<div className='col-span-1 w-full col-start-1 h-auto bg-blue-50 shadow-sm'>
<div className='col-span-1 w-full col-start-1 h-auto border border-blue-600'>

<List
sx={{ width: '100%', bgcolor: 'transparent', flexGrow: 1, paddingTop:0, paddingBottom: 0 }}
Expand Down Expand Up @@ -195,12 +195,6 @@ function AdminOffices(props) {
}

AdminOffices.getInitialProps = async (ctx) => {

ctx?.res?.setHeader(
'Cache-Control',
'public, s-maxage=10, stale-while-revalidate=59'
)

const API_URL = process.env.NEXT_PUBLIC_API_URL

const fetchFilters = async token => {
Expand Down
7 changes: 1 addition & 6 deletions pages/community-units/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { SearchIcon } from '@heroicons/react/outline'



function CommunityUnit (props) {
const CommunityUnit = (props) => {
const userCtx = React.useContext(UserContext);
const [user, setUser] = useState(userCtx);
const router = useRouter();
Expand Down Expand Up @@ -435,11 +435,6 @@ function CommunityUnit (props) {
};

CommunityUnit.getInitialProps = async (ctx) => {

ctx?.res?.setHeader(
'Cache-Control',
'public, s-maxage=10, stale-while-revalidate=59'
)

console.log(ctx.query)
const API_URL = process.env.NEXT_PUBLIC_API_URL;
Expand Down
5 changes: 0 additions & 5 deletions pages/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1220,11 +1220,6 @@ Dashboard.defaultProps = {

export async function getServerSideProps(ctx) {

ctx?.res?.setHeader(
'Cache-Control',
'public, s-maxage=10, stale-while-revalidate=59'
)

const token = (await checkToken(ctx.req, ctx.res))?.token

console.log({ token })
Expand Down
3 changes: 3 additions & 0 deletions pages/facilities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -713,11 +713,14 @@ function FacilityHome (props){

FacilityHome.getInitialProps = async (ctx) => {


ctx?.res?.setHeader(
'Cache-Control',
'public, s-maxage=10, stale-while-revalidate=59'
)



const API_URL = process.env.NEXT_PUBLIC_API_URL;

const fetchFilters = token => {
Expand Down
6 changes: 0 additions & 6 deletions pages/public/chu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,12 +515,6 @@ function Home(props) {
};

Home.getInitialProps = async (ctx) => {

ctx?.res?.setHeader(
'Cache-Control',
'public, s-maxage=10, stale-while-revalidate=59'
)


const API_URL = process.env.NEXT_PUBLIC_API_URL;
const fetchFilters = async (token) => {
Expand Down
21 changes: 8 additions & 13 deletions pages/public/facilities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DotsHorizontalIcon } from '@heroicons/react/solid';
import { checkToken } from '../../../controllers/auth/public_auth';
import React, { useState, useEffect, useRef } from 'react';
import { useRouter } from 'next/router';
import { SearchIcon } from "@heroicons/react/solid";
import Select from 'react-select'
import { Alert } from '@mui/lab'
import Spinner from '../../../components/Spinner'
Expand Down Expand Up @@ -319,7 +320,7 @@ function Home(props) {
<h2 className='flex items-center text-xl font-bold text-black capitalize gap-2'>
{'Facilities'}
</h2>
<p>Use the filters to search for a facility
<p>Use thew filters to search for a facility
{/* {' '}
<button className='text-lg text-blue-500 hover:underline font-semibold'
onClick={() => {
Expand Down Expand Up @@ -358,6 +359,7 @@ function Home(props) {
:
'Search'


}
</span>
{
Expand Down Expand Up @@ -692,20 +694,20 @@ function Home(props) {
<div
key={index}
className='px-1 md:px-3 grid grid-cols-8 gap-3 border-b border-gray-400 py-4 hover:bg-gray-50 w-full'>
<div className='col-span-8 flex flex-col gap-1 group items-start justify-center text-left'>
<div className='col-span-8 flex flex-col gap-1 group items-start justify-center gap-3 text-left'>
<h3 className='text-2xl w-full'>
<Link
<a
href={'/public/facilities/' + hf?.id}
className='hover:text-blue-800 group-focus:text-blue-800 active:text-blue-800'>
{/* <small className='text-gray-500'> */}
<small className='text-gray-500'>
{/* {index + props?.data?.start_index}. */}
{/* </small>{' '} */}
</small>{' '}
{
hf?.official_name ||
hf?.official_name ||
hf?.name
}
</Link>
</a>
</h3>
{/* <p className="text-sm text-gray-600 w-full">{comm_unit.nearest_landmark || ' '}{' '} {comm_unit.location_desc || ' '}</p> */}
<p className='text-sm text-gray-600 w-full flex gap-2 items-center'>
Expand Down Expand Up @@ -854,14 +856,7 @@ function Home(props) {
);
};


export async function getServerSideProps (ctx) {

ctx?.res?.setHeader(
'Cache-Control',
'public, s-maxage=10, stale-while-revalidate=59'
)

const API_URL = process.env.NEXT_PUBLIC_API_URL;


Expand Down
Loading

0 comments on commit 6cf1102

Please sign in to comment.