From 80c3e075724cbe7ddfec9af4036326c205d960b5 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 5 Feb 2024 14:50:35 +0300 Subject: [PATCH] Revert "Fixed report page" This reverts commit 872525c10d84f343eeb566cb725302281385de15. --- components/ReportsData.js | 44 +++++++-------- pages/admin_offices/index.js | 12 +--- pages/community-units/index.js | 7 +-- pages/dashboard/index.js | 5 -- pages/facilities/index.js | 3 + pages/public/chu/index.js | 6 -- pages/public/facilities/index.js | 21 +++---- pages/reports/index.js | 94 +++++++++++--------------------- pages/system_setup/index.js | 10 +--- pages/user/index.js | 8 +-- 10 files changed, 73 insertions(+), 137 deletions(-) diff --git a/components/ReportsData.js b/components/ReportsData.js index 0b31e3a4..fa2aa147 100644 --- a/components/ReportsData.js +++ b/components/ReportsData.js @@ -1,4 +1,4 @@ -// import { OtherHouses } from "@mui/icons-material"; +import { OtherHouses } from "@mui/icons-material"; export const propsToGridData = (props, index) => { @@ -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, @@ -32,7 +32,7 @@ export const propsToGridData = (props, index) => { cots, id: index - })) || [] + })) , columns: [ { @@ -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, @@ -109,7 +109,7 @@ export const propsToGridData = (props, index) => { level_6, id: index - })) || [] + })) , columns: [ { @@ -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, @@ -233,7 +233,7 @@ export const propsToGridData = (props, index) => { supreme_council_for_muslims, id:index - })) || [] + })) , columns: [ { @@ -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, @@ -500,7 +500,7 @@ export const propsToGridData = (props, index) => { specialized_tertiary_hospitals, id:index }) - ) || [], + ), columns: [ { @@ -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, @@ -751,7 +751,7 @@ export const propsToGridData = (props, index) => { ppb, id:index }) - ) || [], + ), columns: [ { @@ -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, @@ -920,7 +920,7 @@ export const propsToGridData = (props, index) => { cat_operating_theaters, id:index }) - ) || [], + ), columns: [ { @@ -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, @@ -1319,7 +1319,7 @@ export const propsToGridData = (props, index) => { eathen_road, id:index }) - ) || [], + ), columns: [ { @@ -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, @@ -1721,7 +1721,7 @@ export const propsToGridData = (props, index) => { sub_county, id:index }) - ) || [], + ), columns: [ { @@ -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', @@ -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, @@ -1932,7 +1932,7 @@ export const propsToGridData = (props, index) => { number_of_units, id:index }) - ) || [] , + ), columns: [ { @@ -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, @@ -2023,7 +2023,7 @@ export const propsToGridData = (props, index) => { support_staffs, id:index }) - ) || [] , + ), columns: [ { diff --git a/pages/admin_offices/index.js b/pages/admin_offices/index.js index 8f0818a2..53cc7243 100644 --- a/pages/admin_offices/index.js +++ b/pages/admin_offices/index.js @@ -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, @@ -38,7 +38,7 @@ const StyledDataGrid = styled(DataGrid)(() => ({ -function AdminOffices(props) { +const AdminOffices = (props) => { const router = useRouter() @@ -120,7 +120,7 @@ function AdminOffices(props) { -
+
{ - - 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 => { diff --git a/pages/community-units/index.js b/pages/community-units/index.js index 683b0c96..7a639351 100644 --- a/pages/community-units/index.js +++ b/pages/community-units/index.js @@ -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(); @@ -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; diff --git a/pages/dashboard/index.js b/pages/dashboard/index.js index 7745003e..ffb2f373 100644 --- a/pages/dashboard/index.js +++ b/pages/dashboard/index.js @@ -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 }) diff --git a/pages/facilities/index.js b/pages/facilities/index.js index a294635f..66fd5da2 100644 --- a/pages/facilities/index.js +++ b/pages/facilities/index.js @@ -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 => { diff --git a/pages/public/chu/index.js b/pages/public/chu/index.js index f88a2e0c..2ae69c7a 100644 --- a/pages/public/chu/index.js +++ b/pages/public/chu/index.js @@ -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) => { diff --git a/pages/public/facilities/index.js b/pages/public/facilities/index.js index 9bc9b0cb..db6c28a5 100644 --- a/pages/public/facilities/index.js +++ b/pages/public/facilities/index.js @@ -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' @@ -319,7 +320,7 @@ function Home(props) {

{'Facilities'}

-

Use the filters to search for a facility +

Use thew filters to search for a facility {/* {' '}