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

Updated facilities dashboard and reports pages #296

Merged
merged 1 commit into from
Feb 7, 2024
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
42 changes: 21 additions & 21 deletions components/ReportsData.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const propsToGridData = (props, index) => {
// Beds and Cots, Theaters
case 0:
return {
rows: props[`${index}`]?.beds_and_cots_by_all_hierachies.map((
rows: props?.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[`${index}`]?.facility_keph_level_report_all_hierachies.map((
rows: props?.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[`${index}`]?.facility_owner_report_all_hierachies.map((
rows: props?.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[`${index}`]?.facility_type_report_all_hierachies.map((
rows: props?.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[`${index}`]?.facility_regulatory_body_report_all_hierachies.map((
rows: props?.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[`${index}`]?.facility_services_report_all_hierachies.map((
rows: props?.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[`${index}`]?.facility_infrastructure_report_all_hierachies.map((
rows: props?.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[`${index}`]?.chul_status_all_hierachies.map((
rows: props?.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[`${index}`]?.chul_services_all_hierachies,
rows: props?.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[`${index}`]?.chul_count_all_hierachies.map((
rows: props?.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[`${index}`]?.facility_human_resource_category_report_all_hierachies.map((
rows: props?.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
2 changes: 1 addition & 1 deletion pages/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ function Dashboard(props) {
</tr>
</thead>
<tbody className="text-lg">
{Object.entries(props?.data?.keph_level).map(([keph, count], i) => (
{Object.entries(props?.data?.keph_level ?? [])?.map(([keph, count], i) => (
<tr key={i}>
<td className="table-cell text-left text-gray-900 p-2">{keph}</td>
<td className="table-cell text-right font-semibold text-gray-900 p-2">{count || 0}</td>
Expand Down
4 changes: 2 additions & 2 deletions pages/reports/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Head from 'next/head';
import Link from 'next/link';
import { useState, useEffect } from 'react';
import { useState, useEffect, useContext } from 'react';
import { checkToken } from '../../controllers/auth/auth';
import MainLayout from '../../components/MainLayout';
import * as Tabs from "@radix-ui/react-tabs";
Expand Down Expand Up @@ -34,7 +34,7 @@ const StyledDataGrid = styled(DataGrid)(() => ({


function Reports(props) {
const userCtx = React.useContext(UserContext);
const userCtx = useContext(UserContext);
const [user, setUser] = useState(userCtx);


Expand Down
Loading