From b2bce0c692a41163deb0a27118656410e6b8aa45 Mon Sep 17 00:00:00 2001 From: eric Date: Wed, 21 Feb 2024 10:13:24 +0300 Subject: [PATCH] Updated public/chu/index.js --- pages/index.js | 16 ++++----- pages/public/chu/[id].js | 59 +++++++++++++++++--------------- pages/public/facilities/[id].js | 4 +-- pages/public/facilities/index.js | 1 + 4 files changed, 43 insertions(+), 37 deletions(-) diff --git a/pages/index.js b/pages/index.js index be7fb276..2e0a902e 100644 --- a/pages/index.js +++ b/pages/index.js @@ -404,7 +404,7 @@ function Home(props) {
-
+

{props?.data?.moh}

@@ -414,7 +414,7 @@ function Home(props) {
-
+

{props?.data?.faith_based}

@@ -424,7 +424,7 @@ function Home(props) {
-
+

{props?.data?.private_facilities}

@@ -434,7 +434,7 @@ function Home(props) {
-
+

{props?.data?.ngo}

@@ -455,7 +455,7 @@ function Home(props) {
-
+

{props?.data?.chu_fully_functional}

@@ -465,7 +465,7 @@ function Home(props) {
-
+

{props?.data?.chu_semi_functional}

@@ -475,7 +475,7 @@ function Home(props) {
-
+

{props?.data?.chu_non_functional}

@@ -485,7 +485,7 @@ function Home(props) {
-
+

{props?.data?.chu_closed}

diff --git a/pages/public/chu/[id].js b/pages/public/chu/[id].js index 6dd1d309..c0aa69e6 100644 --- a/pages/public/chu/[id].js +++ b/pages/public/chu/[id].js @@ -11,7 +11,7 @@ import dynamic from "next/dynamic"; import Link from 'next/link'; import StarRatingComponent from 'react-star-rating-component'; -const CommunityUnit = (props) => { +function CommunityUnit(props) { const Map = dynamic( () => import("../../../components/Map"), { @@ -23,8 +23,10 @@ const CommunityUnit = (props) => { ssr: false, } // This line is important. It's what prevents server-side render ); - let cu = props['0']?.data; - const center = props['1'].center + let cu = props?.data; + + const center = props?.center + useEffect(() => { if (typeof window !== 'undefined') { //auth.add_group // let usr = JSON.parse(window.sessionStorage.getItem('user')) @@ -37,15 +39,18 @@ const CommunityUnit = (props) => { const [rating, setRating] = useState(0); const [comment, setComment] = useState('') - const url = `${process.env.NEXT_PUBLIC_API_URL}/chul/units_detail_report/${cu.id}/?access_token=${props['2'].access_token}&format=pdf` + const url = `${process.env.NEXT_PUBLIC_API_URL}/chul/units_detail_report/${cu.id}/?access_token=${props?.access_token}&format=pdf` const handleRating = async (event) => { + event.preventDefault(); + let rate = { chu: cu.id, rating: rating, comment: comment } + let url = `/api/common/submit_form_data/?path=rate_chu` try { await fetch(url, { @@ -75,7 +80,7 @@ const CommunityUnit = (props) => { return ( <> - `KMHFR - ${cu?.name || cu?.official_name}` + KMHFR - {cu?.name || cu?.official_name} @@ -105,7 +110,7 @@ const CommunityUnit = (props) => {
@@ -128,12 +133,12 @@ const CommunityUnit = (props) => {
- + */}
@@ -143,7 +148,7 @@ const CommunityUnit = (props) => {
{/* CHU Details Tab section */} -
+
{/* Approve/Reject, Edit Buttons */} @@ -160,20 +165,20 @@ const CommunityUnit = (props) => { > Overview - Services - - */} + {/* HR & Staffing - + */} { > Chu Ratings - + {/*End of the vertical tabs */} {

)} - {cu.officer_in_charge && cu.officer_in_charge.contacts.length > 0 && + {/* {cu.officer_in_charge && cu.officer_in_charge.contacts.length > 0 && cu.officer_in_charge.contacts.map((contact, i) => (
{ {contact.contact || " - "}

- ))} + ))} */}
{/*
*/} @@ -366,7 +371,8 @@ const CommunityUnit = (props) => {
- @@ -399,9 +405,9 @@ const CommunityUnit = (props) => {
- + */} - @@ -436,7 +442,7 @@ const CommunityUnit = (props) => {
- + */} {/* chu ratings */} @@ -538,7 +544,8 @@ const CommunityUnit = (props) => { }; CommunityUnit.getInitialProps = async (ctx) => { - const alldata =[] + + const alldata = {} let _data; if (ctx.query.q) { const query = ctx.query.q; @@ -593,13 +600,11 @@ CommunityUnit.getInitialProps = async (ctx) => { const [lng, lat] = _data?.properties.center.coordinates; - alldata.push({ - center: [lat, lng], - }); + alldata["center"] = [lat, lng]; + - alldata.push({ - access_token: token, - }); + alldata["access_token"] = token; + } catch (e) { console.error("Error in fetching ward boundaries", e.message); } diff --git a/pages/public/facilities/[id].js b/pages/public/facilities/[id].js index 63416f90..39ccd80f 100644 --- a/pages/public/facilities/[id].js +++ b/pages/public/facilities/[id].js @@ -68,14 +68,14 @@ const FacilityDetails = (props) => { {facility?.official_name ?? ""} ( # {facility?.code || "NO_CODE"} ) -
+ {/*
-
+
*/} {/* Header Bunner */}