Skip to content

Commit

Permalink
Updated public/chu/index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ertush committed Feb 21, 2024
1 parent 9a4088b commit b2bce0c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 37 deletions.
16 changes: 8 additions & 8 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ function Home(props) {

<div class="w-[60%] mx-auto flex justify-between flex-wrap gap-8 h-auto mt-6 ">

<div class="w-[200px] h-[200px] rounded flex flex-col bg-gray-100 shadow-sm p-2">
<div class="w-[200px] h-[200px] rounded flex flex-col bg-gray-300/45 shadow-sm p-2">
<div className='flex w-full h-full justify-center items-center'>
<h1 className='text-5xl text-blue-600 font-bold'>{props?.data?.moh}</h1>
</div>
Expand All @@ -414,7 +414,7 @@ function Home(props) {
</div>
</div>

<div class="w-[200px] h-[200px] rounded flex flex-col bg-gray-100 shadow-sm p-2">
<div class="w-[200px] h-[200px] rounded flex flex-col bg-gray-300/45 shadow-sm p-2">
<div className='flex w-full h-full justify-center items-center'>
<h1 className='text-5xl text-blue-600 font-bold'>{props?.data?.faith_based}</h1>
</div>
Expand All @@ -424,7 +424,7 @@ function Home(props) {
</div>
</div>

<div class="w-[200px] h-[200px] rounded flex flex-col bg-gray-100 shadow-sm p-2">
<div class="w-[200px] h-[200px] rounded flex flex-col bg-gray-300/45 shadow-sm p-2">
<div className='flex w-full h-full justify-center items-center'>
<h1 className='text-5xl text-blue-600 font-bold'>{props?.data?.private_facilities}</h1>
</div>
Expand All @@ -434,7 +434,7 @@ function Home(props) {
</div>
</div>

<div class="w-[200px] h-[200px] rounded flex flex-col bg-gray-100 shadow-sm p-2">
<div class="w-[200px] h-[200px] rounded flex flex-col bg-gray-300/45 shadow-sm p-2">
<div className='flex w-full h-full justify-center items-center'>
<h1 className='text-5xl text-blue-600 font-bold'>{props?.data?.ngo}</h1>
</div>
Expand All @@ -455,7 +455,7 @@ function Home(props) {

<div class="w-[60%] mx-auto flex justify-between flex-wrap gap-8 h-auto mt-6 ">

<div class="w-[200px] h-[200px] rounded flex flex-col bg-gray-100 shadow-sm p-2">
<div class="w-[200px] h-[200px] rounded flex flex-col bg-gray-300/45 shadow-sm p-2">
<div className='flex w-full h-full justify-center items-center'>
<h1 className='text-5xl text-blue-600 font-bold'>{props?.data?.chu_fully_functional}</h1>
</div>
Expand All @@ -465,7 +465,7 @@ function Home(props) {
</div>
</div>

<div class="w-[200px] h-[200px] rounded flex flex-col bg-gray-100 shadow-sm p-2">
<div class="w-[200px] h-[200px] rounded flex flex-col bg-gray-300/45 shadow-sm p-2">
<div className='flex w-full h-full justify-center items-center'>
<h1 className='text-5xl text-blue-600 font-bold'>{props?.data?.chu_semi_functional}</h1>
</div>
Expand All @@ -475,7 +475,7 @@ function Home(props) {
</div>
</div>

<div class="w-[200px] h-[200px] rounded flex flex-col bg-gray-100 shadow-sm p-2">
<div class="w-[200px] h-[200px] rounded flex flex-col bg-gray-300/45 shadow-sm p-2">
<div className='flex w-full h-full justify-center items-center'>
<h1 className='text-5xl text-blue-600 font-bold'>{props?.data?.chu_non_functional}</h1>
</div>
Expand All @@ -485,7 +485,7 @@ function Home(props) {
</div>
</div>

<div class="w-[200px] h-[200px] rounded flex flex-col bg-gray-100 shadow-sm p-2">
<div class="w-[200px] h-[200px] rounded flex flex-col bg-gray-300/45 shadow-sm p-2">
<div className='flex w-full h-full justify-center items-center'>
<h1 className='text-5xl text-blue-600 font-bold'>{props?.data?.chu_closed}</h1>
</div>
Expand Down
59 changes: 32 additions & 27 deletions pages/public/chu/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
{
Expand All @@ -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'))
Expand All @@ -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, {
Expand Down Expand Up @@ -75,7 +80,7 @@ const CommunityUnit = (props) => {
return (
<>
<Head>
<title> `KMHFR - ${cu?.name || cu?.official_name}`</title>
<title> KMHFR - {cu?.name || cu?.official_name}</title>
<link rel="icon" href="/favicon.ico" />

</Head>
Expand Down Expand Up @@ -105,7 +110,7 @@ const CommunityUnit = (props) => {

<div
className={
"md:col-span-7 grid grid-cols-6 gap-5 md:gap-8 py-6 w-full bg-gray-50 drop-shadow text-black p-4 md:divide-x md:divide-gray-200z shadow-md items-center border-l-8 " +
"md:col-span-7 grid grid-cols-6 gap-5 md:gap-8 py-6 w-full bg-gray-50 drop-shadow text-black p-4 md:divide-x md:divide-gray-200z shadow-sm items-center border-l-8 " +
(cu.active ? "border-blue-600" : "border-red-600")
}
>
Expand All @@ -128,12 +133,12 @@ const CommunityUnit = (props) => {
</div>
</div>

<button
{/* <button
className=" bg-indigo-500 col-span-1 col-start-6 min-w-0 p-2 text-white text-lg font-semibold"
onClick={() => { window.location.href = url}}
>
Print
</button>
</button> */}
</div>

</div>
Expand All @@ -143,7 +148,7 @@ const CommunityUnit = (props) => {
<div className="col-span-1 md:col-span-7 flex flex-row gap-3 mt-4">

{/* CHU Details Tab section */}
<div className="bg-gray-50 shadow-md flex flex-col gap-3 m-4 w-2/3">
<div className="bg-gray-50 shadow-sm flex flex-col gap-3 m-4 w-2/3">
{/* Approve/Reject, Edit Buttons */}


Expand All @@ -160,28 +165,28 @@ const CommunityUnit = (props) => {
>
Overview
</Tabs.Tab>
<Tabs.Tab
{/* <Tabs.Tab
id={2}
value="services"
className="p-2 whitespace-nowrap focus:outline:none flex items-center justify-center text-gray-400 text-base hover:text-black cursor-default border-b-2 border-transparent tab-item"
>
Services
</Tabs.Tab>
<Tabs.Tab
</Tabs.Tab> */}
{/* <Tabs.Tab
id={3}
value="hr_staffing"
className="p-2 whitespace-nowrap focus:outline:none flex items-center justify-center text-gray-400 text-base hover:text-black cursor-default border-b-2 border-transparent tab-item"
>
HR &amp; Staffing
</Tabs.Tab>
</Tabs.Tab> */}
<Tabs.Tab
id={3}
value="chu_ratings"
className="p-2 whitespace-nowrap focus:outline:none flex items-center justify-center text-gray-400 text-base hover:text-black cursor-default border-b-2 border-transparent tab-item"
>
Chu Ratings
</Tabs.Tab>
</Tabs.List>
</Tabs.List>
{/*End of the vertical tabs */}

<Tabs.Panel
Expand Down Expand Up @@ -341,7 +346,7 @@ const CommunityUnit = (props) => {
</p>
</div>
)}
{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) => (
<div
key={i}
Expand All @@ -358,15 +363,16 @@ const CommunityUnit = (props) => {
{contact.contact || " - "}
</p>
</div>
))}
))} */}
</div>
{/* <div> */}

{/* </div> */}

</div>
</Tabs.Panel>
<Tabs.Panel

{/* <Tabs.Panel
value="services"
className="grow-1 p-4 tab-panel"
>
Expand Down Expand Up @@ -399,9 +405,9 @@ const CommunityUnit = (props) => {
</ul>
</div>
</div>
</Tabs.Panel>
</Tabs.Panel> */}

<Tabs.Panel
{/* <Tabs.Panel
value="hr_staffing"
className="grow-1 p-4 tab-panel"
>
Expand Down Expand Up @@ -436,7 +442,7 @@ const CommunityUnit = (props) => {
</div>
</div>
</Tabs.Panel>
</Tabs.Panel> */}

{/* chu ratings */}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions pages/public/facilities/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ const FacilityDetails = (props) => {
{facility?.official_name ?? ""} ( #
<i className="text-black">{facility?.code || "NO_CODE"}</i> )
</span>
<div className="flex flex-row gap-2 items-center ml-auto">
{/* <div className="flex flex-row gap-2 items-center ml-auto">
<button
onClick={()=>handlePrint(props['4'].token, facility.id)}
className="p-2 text-center -md font-semibold text-base text-white bg-indigo-500 justify-end mr-2"
>
Print
</button>
</div>
</div> */}
</div>
{/* Header Bunner */}
<div
Expand Down
1 change: 1 addition & 0 deletions pages/public/facilities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ function Home(props) {
}

console.log({url})

fetch(url, {
headers: {
Authorization: 'Bearer ' + props?.token,
Expand Down

0 comments on commit b2bce0c

Please sign in to comment.