Skip to content

Commit

Permalink
Merge pull request #309 from ertush/hotfix-dev
Browse files Browse the repository at this point in the history
Updated all the pages by adding http cache headers for next
ertush authored Feb 15, 2024
2 parents e869fc2 + 476aa61 commit b57da48
Showing 7 changed files with 115 additions and 507 deletions.
443 changes: 5 additions & 438 deletions components/HeaderLayout.js

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions pages/admin_offices/add.js
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ function AddAdminOffice(props) {
const countyOptions = props['0']?.counties;
const subCountyOptions = props['1']?.sub_counties;
const [status, setStatus] = useState(null)
const [isClient, setIsClient] = useState(false)

const [county, setCounty] = useState('');
const [hide, setHide] = useState(false)
@@ -76,15 +77,18 @@ function AddAdminOffice(props) {
}

useEffect(() => {
setIsClient(true)
setUser(userCtx)
if(user.id === 6){
router.push('/auth/login')
}
}, [])


if(isClient){
return (
<MainLayout isLoading={false} searchTerm={props?.query?.searchTerm}>
<div className="w-full grid grid-cols-5 gap-4 px-1 md:px-4 py-2 my-4">
<div className="w-full grid grid-cols-5 gap-4 px-1 md:px-4 py-2 h-auto mt-8 my-4">
<div className="col-span-5 flex flex-col gap-3 md:gap-5 px-4">
<div className="flex flex-wrap items-center justify-between gap-2 text-sm md:text-base py-3">
<div className="flex flex-row items-center justify-between gap-2 text-sm md:text-base py-3">
@@ -103,8 +107,8 @@ function AddAdminOffice(props) {
</div>

<div className='col-span-5 flex flex-col justify-center items-start px-1 md:px-4 w-full '>
<div className=' w-full flex flex-col items-start p-3 text-blue shadow-md'
style={{ minHeight: '250px', backgroundColor: '#eff6ff' }}>
<div className=' w-full flex flex-col bg-gray-50 mt-4 items-start p-3 text-blue shadow-md'
style={{ minHeight: '250px' }}>

<>

@@ -302,6 +306,10 @@ function AddAdminOffice(props) {
</MainLayout>

)
}
else {
return null
}
}

AddAdminOffice.getInitialProps = async (ctx) => {
32 changes: 23 additions & 9 deletions pages/admin_offices/index.js
Original file line number Diff line number Diff line change
@@ -40,12 +40,13 @@ const StyledDataGrid = styled(DataGrid)(() => ({



const AdminOffices = (props) => {
function AdminOffices(props) {

const router = useRouter()

const userPermissions = useContext(PermissionContext)
const userCtx = useContext(UserContext)
const [isClient, setIsClient] = useState(false)

const rows = props?.data?.results?.map(({ id, county_name, sub_county_name, name, is_national, phone_number, email }) => ({ id, county_name, sub_county_name, name, is_national: is_national == true ? 'Yes' : 'No', phone_number, email }))
const columns = [
@@ -81,6 +82,7 @@ const AdminOffices = (props) => {


useEffect(() => {
setIsClient(true)
setUser(userCtx)
if(user.id === 6){
router.push('/auth/login')
@@ -94,26 +96,27 @@ const AdminOffices = (props) => {
const [officeTheme, setOfficeTheme] = useState([]);


if(isClient) {
return (
<div className="">
<>
<Head>
<title>KMHFR - Reports</title>
<title>KMHFR - Admin Offices</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<MainLayout isLoading={false} isFullWidth={false}>
<div className="w-full grid grid-cols-7 gap-4 p-1 md:mx-4 my-2">
<div className="w-full grid grid-cols-7 mt-8 gap-4 p-1 md:mx-4 my-2">
<div className="col-span-7 flex flex-col gap-x-1">
<div className="flex flex-wrap items-center justify-between gap-2 text-sm md:text-base py-1">
<div className="flex flex-row items-center justify-between gap-x-2 gap-y-0 text-sm md:text-base py-1">
<a className="text-blue-700" href="/">Home</a> {'/'}
<span className="text-gray-500">Adminoffices</span>
<span className="text-gray-500">Admin Offices</span>
</div>
<div className={"col-span-5 flex justify-between w-full drop-shadow text-black p-4 md:divide-x bg-gray-50 shadow-md md:divide-gray-200 items-center border-l-8 " + (true && "border-blue-600")}>
<div className={"col-span-5 flex justify-between w-full drop-shadow text-black p-4 md:divide-x bg-transparent border border-blue-600 md:divide-gray-200 items-center border-l-8 " + (true && "border-blue-600")}>
<h2 className='flex items-center text-xl font-bold text-black capitalize gap-2'>

{'Admin Offices'}
</h2>
<button className=' bg-blue-600 p-2 text-white flex items-center text-lg font-semibold'
<button className='bg-blue-600 p-2 text-white flex items-center text-lg font-semibold'
onClick={() => { router.push('admin_offices/add') }}
>
{`Add Admin Office `}
@@ -122,7 +125,7 @@ const AdminOffices = (props) => {
</div>
</div>
</div>
<div className='col-span-1 w-full col-start-1 h-auto bg-gray-50 shadow-sm'>
<div className='col-span-1 w-full col-start-1 h-auto shadow-sm bg-gray-50'>

<List
sx={{ width: '100%', bgcolor: 'transparent', flexGrow: 1, paddingTop:0, paddingBottom: 0 }}
@@ -192,11 +195,22 @@ const AdminOffices = (props) => {

</div>
</MainLayout >
</div>
</>
)
}
else {
return null
}
}

AdminOffices.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 => {
9 changes: 7 additions & 2 deletions pages/community-units/index.js
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ import { SearchIcon } from '@heroicons/react/outline'



const CommunityUnit = (props) => {
function CommunityUnit (props) {
const userCtx = React.useContext(UserContext);
const [user, setUser] = useState(userCtx);
const router = useRouter();
@@ -436,7 +436,12 @@ const CommunityUnit = (props) => {

CommunityUnit.getInitialProps = async (ctx) => {

console.log(ctx.query)
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) => {
let filters_url =
21 changes: 11 additions & 10 deletions pages/reports/index.js
Original file line number Diff line number Diff line change
@@ -10,11 +10,6 @@ import {
DataGrid,
GridToolbar
} from '@mui/x-data-grid';

// import { DataGridPro, GridToolbar } from '@mui/x-data-grid-pro';

// import { Box } from '@material-ui/core';

import { propsToGridData } from '../../components/ReportsData';
import { UserContext } from '../../providers/user';

@@ -130,13 +125,13 @@ function Reports(props) {
</div>

{/* Tabs */}
<div className='w-full col-span-1 md:col-span-7 flex border border-blue-600 px-0 mx-0 h-700 flex-1'>
<div className='w-full col-span-1 md:col-span-7 flex shadow-sm bg-gray-50 px-0 mx-0 h-700 flex-1'>
<Tabs.Root
orientation="horizontal"
className="w-full flex flex-col tab-root"
defaultValue="facilities"
>
<Tabs.List className="list-none w-full flex justify-evenly flex-wrap gap-2 md:gap-3 px-4 uppercase leading-none tab-list font-semibold border-b border-blue-600">
<Tabs.List className="list-none w-full flex justify-evenly flex-wrap gap-2 md:gap-3 px-4 uppercase leading-none tab-list font-semibold border-b border-gray-400">
{/* Facilities Tab */}
<Tabs.Tab
id={1}
@@ -167,7 +162,7 @@ function Reports(props) {
defaultValue="beds_cots"
>

<Tabs.List className="list-none w-full flex justify-evenly flex-wrap gap-2 md:gap-3 px-4 uppercase leading-none tab-list font-semibold border-b border-blue-600">
<Tabs.List className="list-none w-full flex justify-evenly flex-wrap gap-2 md:gap-3 px-4 uppercase leading-none tab-list font-semibold border-b border-gray-400">
<Tabs.Tab
id={1}
value="beds_cots"
@@ -259,7 +254,7 @@ function Reports(props) {
>
{/* Beds and Cots Data Grid */}

<div style={{ height: 700, width: '100%', backgroundColor: '#eff6ff' }} className='shadow-md col-span-7'>
<div style={{ height: 700, width: '100%', backgroundColor: '#f9fafb' }} className='shadow-md col-span-7'>
<StyledDataGrid
columns={propsToGridData(props, 0).columns}
rows={propsToGridData(props, 0)?.rows}
@@ -294,7 +289,7 @@ function Reports(props) {
>
{/* Keph Level Data grid */}

<div style={{ height: 700, width: '100%', backgroundColor: '#eff6ff' }} className='shadow-md col-span-7'>
<div style={{ height: 700, width: '100%', backgroundColor: '#f9fafb' }} className='shadow-md col-span-7'>
<StyledDataGrid
columns={propsToGridData(props, 1).columns}
rows={propsToGridData(props, 1)?.rows}
@@ -759,6 +754,12 @@ function Reports(props) {

Reports.getInitialProps = async (ctx) => {

ctx?.res?.setHeader(
'Cache-Control',
'public, s-maxage=10, stale-while-revalidate=59'
)


const reports = [
'beds_and_cots_by_all_hierachies',
'facility_keph_level_report_all_hierachies',
92 changes: 49 additions & 43 deletions pages/system_setup/index.js

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions pages/user/index.js
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ const StyledDataGrid = styled(DataGrid)(() => ({
}))


const Users = (props) => {
function Users (props) {

LicenseManager.setLicenseKey("test");

@@ -231,7 +231,7 @@ const Users = (props) => {
<main className="col-span-6 md:col-span-6 flex flex-col gap-4 order-last md:order-none"> {/* CHANGED colspan */}


<div className="flex flex-col justify-center items-center w-full shadow-md" style={{backgroundColor:"#eff6ff"}}>
<div className="flex flex-col justify-center items-center w-full shadow-md" style={{backgroundColor:"#f9fafb"}}>

<div className='w-full h-auto'>
<StyledDataGrid
@@ -275,6 +275,13 @@ const Users = (props) => {
}

Users.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
// console.log(ctx.query.is_active);

0 comments on commit b57da48

Please sign in to comment.