Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed reports rendering; pending work on human resource reports #299

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions components/ReportsData.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const propsToGridData = (props, index) => {
cots,
id: index

})) || []
})) ?? []

, columns: [
{
Expand Down Expand Up @@ -109,7 +109,7 @@ export const propsToGridData = (props, index) => {
level_6,
id: index

})) || []
})) ?? []

, columns: [
{
Expand Down Expand Up @@ -233,7 +233,7 @@ export const propsToGridData = (props, index) => {
supreme_council_for_muslims,
id:index

})) || []
})) ?? []

, columns: [
{
Expand Down Expand Up @@ -500,7 +500,7 @@ export const propsToGridData = (props, index) => {
specialized_tertiary_hospitals,
id:index
})
) || [],
) ?? [],

columns: [
{
Expand Down Expand Up @@ -751,7 +751,7 @@ export const propsToGridData = (props, index) => {
ppb,
id:index
})
) || [],
) ?? [],

columns: [
{
Expand Down Expand Up @@ -920,7 +920,7 @@ export const propsToGridData = (props, index) => {
cat_operating_theaters,
id:index
})
) || [],
) ?? [],

columns: [
{
Expand Down Expand Up @@ -1319,7 +1319,7 @@ export const propsToGridData = (props, index) => {
eathen_road,
id:index
})
) || [],
) ?? [],

columns: [
{
Expand Down Expand Up @@ -1721,7 +1721,7 @@ export const propsToGridData = (props, index) => {
sub_county,
id:index
})
) || [],
) ?? [],

columns: [
{
Expand Down Expand Up @@ -1766,7 +1766,7 @@ export const propsToGridData = (props, index) => {
// CHU Services
case 9:
return {
rows: props?.chul_services_all_hierachies || [],
rows: props?.chul_services_all_hierachies ?? [],
columns: [
{
headerName: 'County',
Expand Down Expand Up @@ -1932,7 +1932,7 @@ export const propsToGridData = (props, index) => {
number_of_units,
id:index
})
) || [],
) ?? [],

columns: [
{
Expand Down Expand Up @@ -2023,7 +2023,7 @@ export const propsToGridData = (props, index) => {
support_staffs,
id:index
})
) || [],
) ?? [],

columns: [
{
Expand Down
35 changes: 18 additions & 17 deletions pages/reports/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const StyledDataGrid = styled(DataGrid)(() => ({


function Reports(props) {

const userCtx = useContext(UserContext);
const [user, setUser] = useState(userCtx);

Expand All @@ -60,7 +61,7 @@ function Reports(props) {
lng,
id:index
}))
)(props['8']?.gis)
)(props?.gis)

const [reportTitle, setReportTitle] = useState('Beds and Cots');
const [isClient, setIsClient] = useState(false);
Expand Down Expand Up @@ -773,8 +774,7 @@ Reports.getInitialProps = async (ctx) => {
'facility_human_resource_category_report_all_hierachies'
];

const allReports = [];

const allReports = {};

return checkToken(ctx.req, ctx.res).then(async (t) => {
if (t.error) {
Expand Down Expand Up @@ -802,7 +802,7 @@ Reports.getInitialProps = async (ctx) => {
})


allReports.push({ beds_and_cots_by_all_hierachies: (await _data.json()).results })
allReports["beds_and_cots_by_all_hierachies"] = (await _data.json()).results

}
catch (err) {
Expand All @@ -828,7 +828,7 @@ Reports.getInitialProps = async (ctx) => {
},
})

allReports.push({ facility_keph_level_report_all_hierachies: (await _data.json()).results })
allReports["facility_keph_level_report_all_hierachies"] = (await _data.json()).results


}
Expand All @@ -854,7 +854,7 @@ Reports.getInitialProps = async (ctx) => {
},
})

allReports.push({ facility_owner_report_all_hierachies: (await _data.json()).results })
allReports["facility_owner_report_all_hierachies"] = (await _data.json()).results

}
catch (err) {
Expand All @@ -880,7 +880,7 @@ Reports.getInitialProps = async (ctx) => {
},
})

allReports.push({ facility_type_report_all_hierachies: (await _data.json()).results })
allReports["facility_type_report_all_hierachies"] = (await _data.json()).results

}
catch (err) {
Expand All @@ -906,7 +906,7 @@ Reports.getInitialProps = async (ctx) => {
},
})

allReports.push({ facility_regulatory_body_report_all_hierachies: (await _data.json()).results })
allReports["facility_regulatory_body_report_all_hierachies"] = (await _data.json()).results

}
catch (err) {
Expand All @@ -932,7 +932,7 @@ Reports.getInitialProps = async (ctx) => {
},
})

allReports.push({ facility_services_report_all_hierachies: (await _data.json()).results })
allReports["facility_services_report_all_hierachies"] = (await _data.json()).results

}
catch (err) {
Expand All @@ -958,7 +958,7 @@ Reports.getInitialProps = async (ctx) => {
},
})

allReports.push({ facility_human_resource_category_report_all_hierachies: (await _data.json()).results })
allReports["facility_human_resource_category_report_all_hierachies"] = (await _data.json()).results

}
catch (err) {
Expand All @@ -984,7 +984,7 @@ Reports.getInitialProps = async (ctx) => {
},
})

allReports.push({ facility_infrastructure_report_all_hierachies: (await _data.json()).results })
allReports["facility_infrastructure_report_all_hierachies"] = (await _data.json()).results

}
catch (err) {
Expand All @@ -1010,7 +1010,7 @@ Reports.getInitialProps = async (ctx) => {
},
})

allReports.push({ chul_status_all_hierachies: (await _data.json()).results })
allReports["chul_status_all_hierachies"] = (await _data.json()).results

}
catch (err) {
Expand All @@ -1035,7 +1035,7 @@ Reports.getInitialProps = async (ctx) => {
},
})

allReports.push({ chul_services_all_hierachies: (await _data.json()).results.map((
allReports["chul_services_all_hierachies"] = (await _data.json()).results.map((
{

"WASH: Water, sanitation and hygiene education, including hand washing": wash_sanitation,
Expand Down Expand Up @@ -1095,11 +1095,12 @@ Reports.getInitialProps = async (ctx) => {
id:index

})
) })
)

}
catch (err) {
console.log(`Error fetching ${report}: `, err);

allReports.push({
error: true,
err: err,
Expand All @@ -1121,7 +1122,7 @@ Reports.getInitialProps = async (ctx) => {
},
})

allReports.push({ gis: (await _data.json()).results })
allReports["gis"] = (await _data.json()).results

}
catch (err) {
Expand All @@ -1148,7 +1149,7 @@ Reports.getInitialProps = async (ctx) => {
},
})

allReports.push({ chul_status_all_hierachies: (await _data.json()).results })
allReports["chul_status_all_hierachies"] = (await _data.json()).results

}
catch (err) {
Expand All @@ -1173,7 +1174,7 @@ Reports.getInitialProps = async (ctx) => {
},
})

allReports.push({ chul_count_all_hierachies: (await _data.json()).results })
allReports["chul_count_all_hierachies"] = (await _data.json()).results

}
catch (err) {
Expand Down
Loading