From 104d3c8bae3c77646a23854d24170a640e3c0656 Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 13 Aug 2024 17:09:09 +0300 Subject: [PATCH 1/2] Fixed facilities page navigation --- pages/facilities/index.js | 68 ++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/pages/facilities/index.js b/pages/facilities/index.js index aecbd60..d08acf4 100644 --- a/pages/facilities/index.js +++ b/pages/facilities/index.js @@ -142,44 +142,43 @@ function FacilityHome (props){ function handleNext() { - const params = Object.fromEntries(pageParams.entries()) + // const params = Object.fromEntries(pageParams.entries()) + router.push({ pathname:'/facilities', query: { - next: Buffer.from(`${props?.next}`).toString('base64'), //default: page_size=30 - ...params + next: Buffer.from(`${props?.next}`).toString('base64') //default: page_size=30 + + // ...params } }) } function handlePrevious() { - const params = Object.fromEntries(pageParams.entries()) - + + // const params = Object.fromEntries(pageParams.entries()) + router.push({ pathname:'/facilities', query: { - previous: Buffer.from(`${props?.previous}`).toString('base64'), - ...params - + previous: Buffer.from(`${props?.previous}`).toString('base64') //default: page_size=30 + //...params } }) } function handlePageLoad(e) { - const params = Object.fromEntries(pageParams.entries()) - const page = e.target.innerHTML - console.log({page}) + // const params = Object.fromEntries(pageParams.entries()) router.push({ pathname:'/facilities', query: { - page, - ...params - + page + // ...params } }) } @@ -272,7 +271,7 @@ function FacilityHome (props){ onClick={() => { - window.location.href = `${process.env.NEXT_PUBLIC_FACILITY_EXPORT_URL}?access_token=${props?.token}&format=excel&page_size=${props?.count}&page=1${orgUnitFilter}` + window.location.href = orgUnitFilter ? `${process.env.NEXT_PUBLIC_FACILITY_EXPORT_URL}?access_token=${props?.token}&format=excel&page_size=${props?.count}&page=1${orgUnitFilter}` : `${process.env.NEXT_PUBLIC_FACILITY_EXPORT_URL}?access_token=${props?.token}&format=excel&page_size=${props?.count}&page=1` }}> @@ -793,24 +792,27 @@ function FacilityHome (props){
- - - - - - - - + + + + + { + props?.current_page > 5 && (props?.count / 10) > 100 && + Array(props?.current_page + 5).fill(0).map((_, i) => i+1).slice(props?.current_page - 6, props?.current_page + 5).map(i => ( + + )) + } + + { + props?.current_page <= 5 && (props?.count / 10) > 100 && + Array(10).fill(0).map((_, i) => i+1).slice(0, 10).map(i => ( + + )) + }
From 8fdbe5539da5b5f8b8cb2062ec510de53ed46fbc Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 13 Aug 2024 18:39:20 +0300 Subject: [PATCH 2/2] Fixed UI for public facilities --- components/FacilityDetailsTabs.js | 2 +- components/FacilityDetailsTabsPublic.js | 728 ++++++++++++++++-------- pages/public/chu/[id].js | 529 +++++++++-------- pages/public/chu/index.js | 6 +- pages/public/facilities/[id].js | 71 ++- pages/public/facilities/index.js | 15 +- 6 files changed, 846 insertions(+), 505 deletions(-) diff --git a/components/FacilityDetailsTabs.js b/components/FacilityDetailsTabs.js index 1090f39..c3cfced 100644 --- a/components/FacilityDetailsTabs.js +++ b/components/FacilityDetailsTabs.js @@ -33,7 +33,7 @@ function FacilityDetailsTabs({ facility, token }) { diff --git a/components/FacilityDetailsTabsPublic.js b/components/FacilityDetailsTabsPublic.js index 6930c72..789989e 100644 --- a/components/FacilityDetailsTabsPublic.js +++ b/components/FacilityDetailsTabsPublic.js @@ -4,6 +4,7 @@ import { UserContext } from '../providers/user'; import { CheckCircleIcon, XCircleIcon } from "@heroicons/react/solid"; import StarRatingComponent from "react-star-rating-component"; import { useAlert } from "react-alert"; +import Link from 'next/link' function FacilityDetailsTabsPulic({ facility }) { @@ -83,325 +84,579 @@ function FacilityDetailsTabsPulic({ facility }) { }; return ( -
+
+ - + Overview Services Facility Units -
- - {/* Status */} -
- -

- Status: -

+
+
+ {/* Basic Details */} +
+

+ Basic Details +

-
+
- {/* Facility Type */} -
-
+ + - +
-

- {facility?.facility_type_name || ""} -

- -
+
+ +
+
+ + {/* Status */} +
+

+ Status +

+ {facility?.closed && - {/* Open Status */} -
-
+
- + + +
+ } + {facility?.closed && ( +
+ + +
+ )} +
+ {facility?.reporting_in_dhis && ( + <> + +
+ + + + )} +
- + {facility?.nhif_accreditation && ( + +
+ + +
+ )} + + {facility?.open_normal_day && ( - {/* Regulation */} -
-
+
+
-
-
-
+ )} + {facility?.open_weekends && ( - {/* Ownership */} -
-

- Ownership: -

+
+ + -
- - {/* Category */} -
-
- -

- {facility?.owner_type_name || " - "} -

-
-
+
+ )} - {/* Owner */} -
-
-
+ )} + + {facility?.is_classified && ( + +
+ + + +
+ )} + + {facility?.is_published && ( +
+ + + +
+ )}
- {/* Loction */} -
-

- Location: -

+
+ {/* Regulation */} +
+

+ Regulation +

+ {facility?.date_established && ( +
+ + +
+ )} + {facility?.date_requested && ( +
+ + +
+ )} + {facility?.date_approved && ( +
+ + +
+ )} + + {facility?.regulated && ( +
-
- - {/* County */} -
-
+ -

- {facility?.county || " - "} -

-
- {/* Sub County */} -
-
- -

- {facility?.sub_county_name || " - "} -

+ )} +
+ + +
+
+ + +
+
+ + +
+
+ +
- {/* Constituency */} -
-
- -

- {facility?.constituency_name || " - "} -

-
-
- - {/* Ward */} -
-
- -

- {facility?.ward_name || " - "} -

-
+ {/* Ownership */} +
+

+ Ownership +

+
+ + +
+
+ + +
+
- {/* Town */} -
-
- -

- {facility?.town_name || " - "} -

-
-
- {/* Description */} -
-
- -

- {facility?.location_desc || " - "} -

-
+
+ {/* Location */} +
+

+ Location +

+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
- {/* Nearest landmark */} -
-
- -

- {facility?.nearest_landmark || " - "} -

-
-
+ {/* Bed Capacity */} +
+

+ Bed capacity +

+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
- {/* Plot number */} -
-
- -

- {facility?.plot_number || " - "} -

- -
- - {/* Bed capacity */} -
-

- Bed capacity: -

-
-
- -

- {facility?.number_of_beds} -

+
+ {/* Theaters */} +
+

+ Surgical Theatres +

+
+ +
-
- -
-
- -

- {facility?.number_of_cots} -

+
+ +
- {/*
-

- Contacts: + {/* Contacts */} +
+

+ Community Units

- {facility?.facility_contacts && - facility?.facility_contacts.length > 0 && - facility?.facility_contacts.map((contact) => ( + + {facility?.cu && + facility?.cu.length > 0 ? + + facility?.cu.map(({name, id}) => (
-
+ + {name} + +
+ )) + : + +
+ + -

- {contact.contact || " - "} -

-
- - ))} - {facility?.officer_in_charge && ( -
-
+ + + } + {/* {facility?.officer_in_charge && ( +
-

+

-
+
)} {facility?.officer_in_charge && @@ -409,9 +664,8 @@ function FacilityDetailsTabsPulic({ facility }) { facility?.officer_in_charge.contacts.map((contact) => (
-
-

+

-
+
- ))} -
*/} + ))} */} +

-
+ +
diff --git a/pages/public/chu/[id].js b/pages/public/chu/[id].js index 4c6f86f..3a5fa36 100644 --- a/pages/public/chu/[id].js +++ b/pages/public/chu/[id].js @@ -97,7 +97,7 @@ function CommunityUnit(props) { Home {"/"} - + Community units {"/"} @@ -153,10 +153,11 @@ function CommunityUnit(props) { defaultValue="overview" > + Overview @@ -164,9 +165,9 @@ function CommunityUnit(props) { - Chu Ratings + Chu Ratings {/*End of the vertical tabs */} @@ -175,240 +176,314 @@ function CommunityUnit(props) { value="overview" className="grow-1 p-4 tab-panel" > -
- -
-

- Status: -

-
- -

- {cu.status_name - ?.toLocaleLowerCase() - .includes("fully-") ? ( - - - {cu?.status_name || "Yes"} - - ) : cu.status_name - ?.toLocaleLowerCase() - .includes("semi") ? ( - - - {cu?.status_name || "Yes"} - - ) : ( - - - {cu?.status_name || "No"} - - )} -

-
-
- -
-

- Coverage: -

-
- -

- {cu.households_monitored || " - "} -

-
-
- -
-

- Location: -

-
- - - - {cu.facility_name || " - "} - -
-
- -

- {cu.facility_ward || " - "} -

-
-
- -

- {cu.facility_constituency || " - "} -

-
-
- -

- {cu.facility_subcounty || " - "} -

-
-
- -

- {cu.facility_county || " - "} -

-
-
-
-

- Regulation: -

- {cu.date_established && ( -
- -

- {new Date(cu.date_established).toLocaleDateString( - "en-GB", - { - year: "numeric", - month: "long", - day: "numeric", - } - ) || " - "} -

-
+
+
+
+

+ Status +

+ +
+ +

+ {cu?.status_name + ?.toLocaleLowerCase() + .includes("fully-") ? ( + + + {cu?.status_name || "Fully functional"} + + ) : cu.status_name + ?.toLocaleLowerCase() + .includes("semi") ? ( + + + {cu?.status_name || "Semi Functional"} + + ) : ( + + {/* */} + {cu?.status_name || "Non Functional"} + )} -

+

+
- {/*
-

- Contacts: -

- {cu.contacts && cu.contacts.length > 0 ? - cu.contacts.map((contact, i) => ( -
- -

- {contact.contact || " - "} -

-
- )) : -

- Use the linked facility's contacts. -

- } - - {cu.officer_in_charge && ( -
- -

- {cu.officer_in_charge.name || " - "} -

-
+
+ +

+ {cu.is_approved ? ( + + + Yes + + ) : ( + + + No + )} - -

*/} - {/*
*/} - - {/*
*/} - +

- - {/* -
-
-

- Services -
-

-
    - {cu?.services && cu?.services.length > 0 ? ( - cu?.services.map((service, i) => ( -
  • -
    -

    - {service.name} -

    -
    - -
  • - )) + {true && ( +
    + +

    + {cu.deleted ? ( + + Deleted + ) : ( -

  • -

    No services listed for this cu.

    -
  • + + Not Deleted + )} -
+

-
-
*/} - - {/* -
-
-

- - Health Unit workers - -

-
    - {cu?.health_unit_workers && cu?.health_unit_workers.length > 0 ? ( - cu?.health_unit_workers.map((hr, i) => ( -
  • -
    -

    - {hr.name} {hr.is_incharge ? (In charge) : null} -

    -
    - -
  • - )) + )} + {true && ( +
    + +

    + {cu.is_closed ? ( + + CHU Closed {cu.closed_date || ""} + + ) : ( + + Not closed + + )} +

    +
    + )} + {cu.closing_reason && ( +
    + +

    + {cu.closed_date && <>{cu.closed_date}. }{" "} + {cu.closing_reason || ""} +

    +
    + )} + + {true && ( +
    + +

    + {cu.has_edits ? ( + + Yes + ) : ( -

  • -

    No HR data listed for this cu.

    -
  • + + No edits + )} -
+

+ )} + {true && ( +
+ +

+ {cu.is_rejected ? ( + + CHU rejected {cu.closed_date || ""} + + ) : ( + + Not rejected + + )} +

+
+ )} +
+ +
+

+ Coverage +

+
+ +

+ {cu.households_monitored || " - "} +

+
+
+ +

+ {cu.number_of_chvs || " - "} +

+
+
+
+ +
+
+

+ Location +

+
+ +

+ {cu.facility_name || " - "} +

+
+
+ +

+ {cu.facility_ward || " - "} +

+
+
+ +

+ {cu.facility_constituency || " - "} +

+
+
+ +

+ {cu.facility_subcounty || " - "} +

+
+
+ +

+ {cu.facility_county || " - "} +

+
+
+ +
+

+ Regulation: +

+ {cu.date_established && ( +
+ +

+ {new Date(cu.date_established).toLocaleDateString( + "en-GB", + { + year: "numeric", + month: "long", + day: "numeric", + } + ) || " - "} +

+
+ )} + {cu.date_operational && ( +
+ +

+ {new Date(cu.date_operational).toLocaleDateString( + "en-GB", + { + year: "numeric", + month: "long", + day: "numeric", + } + ) || " - "} +

+
+ )} +
+ +

+ {cu.regulated ? ( + + + Yes + + ) : ( + + + No + + )} +

- */} +
+
+ { + cu?.contacts && cu?.contacts.length > 0 && +
+
+

+ Facility +

+ {cu.facility_name ? + +
+ + + {cu?.facility_name} + +
+ : + +
+ +

+ - +

+
+ + } + +
+
+ } + {/*
*/} + + + + + +
+ + + + {/* chu ratings */} @@ -475,7 +550,7 @@ function CommunityUnit(props) {
{/* Map Section */} -
+

{cu?.facility_ward} Ward

{cu?.lat_long && cu?.lat_long.length > 0 ? (
@@ -493,8 +568,8 @@ function CommunityUnit(props) {
) : (
-
-

No location data found for this facility?.

+
+

{cu?.facility_ward} location data found.

)} diff --git a/pages/public/chu/index.js b/pages/public/chu/index.js index 2752ff9..8a6b47c 100644 --- a/pages/public/chu/index.js +++ b/pages/public/chu/index.js @@ -12,17 +12,17 @@ import Alert from '@mui/material/Alert' function Home(props) { const router = useRouter(); - // const cus = props?.data?.results; + const [cus, setcus] = useState(props?.data) const filters = props?.filters; const [drillDown, setDrillDown] = useState({}); const [reset, setReset] = useState(false) - const qf = props?.query?.qf || 'all'; + // const qf = props?.query?.qf || 'all'; const [viewAll, setViewAll] = useState(true); const API_URL = process.env.NEXT_PUBLIC_API_URL; const code = useRef(null) - const allchus = useRef(null) + // const allchus = useRef(null) const name = useRef(null) const county = useRef(null) const subcounty = useRef(null) diff --git a/pages/public/facilities/[id].js b/pages/public/facilities/[id].js index 9fd08aa..9f08e76 100644 --- a/pages/public/facilities/[id].js +++ b/pages/public/facilities/[id].js @@ -11,9 +11,9 @@ import FacilityDetailsTabsPulic from "../../../components/FacilityDetailsTabsPub import {z} from 'zod' -const FacilityDetails = (props) => { +function FacilityDetails(props) { - const userCtx = useContext(UserContext) + // const userCtx = useContext(UserContext) const Map = dynamic( @@ -29,9 +29,9 @@ const FacilityDetails = (props) => { ); - const facility = props["0"]?.data; - const wardName = props["0"]?.data.ward_name; - const center = props["1"]?.geoLocation.center; + const facility = {cu: props?.cu, ...props?.data} + const wardName = props?.data?.ward_name; + const center = props?.geo_details?.geoLocation.center; // const [isViewChangeLog, setIsViewChangeLog] = useState(false) @@ -77,9 +77,10 @@ const FacilityDetails = (props) => { (facility?.is_approved ? "border-gray-600" : "border-red-600") } > -
+
+

- {facility?.official_name} + {facility?.official_name}

{ {/* end facility approval */} -