Skip to content

Commit

Permalink
Fix report maps access to md content
Browse files Browse the repository at this point in the history
  • Loading branch information
nofurtherinformation committed Aug 6, 2024
1 parent 91bda2e commit 97d4b34
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
8 changes: 6 additions & 2 deletions components/Pages/Map/Renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ import { useMarkdownContextProvider } from "hooks/useMarkdownContext"
// lazy load the map
const Map = dynamic(() => import("components/Map/Map"), { ssr: false })

export const Renderer: React.FC<{ pageInfo: any; stats: any }> = ({ pageInfo, stats }) => {
export const Renderer: React.FC<{ pageInfo: any; stats: any; initialFilter?: any }> = ({
pageInfo,
stats,
initialFilter,
}) => {
const MarkdownProvider = useMarkdownContextProvider({
pageInfo,
stats,
})

return (
<MarkdownProvider>
<Map />
<Map initialFilter={initialFilter} />
</MarkdownProvider>
)
}
1 change: 1 addition & 0 deletions components/ReportLayout/ClientReportRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const ClientReportRenderer: React.FC<{
unit: string
children: React.ReactNode
showHeader?: boolean
mapPageInfo?: any
}> = (props) => {
const {
comparability,
Expand Down
21 changes: 18 additions & 3 deletions components/ReportLayout/ReportLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ const comparability = {
export const ReportLayout: React.FC<ReportLayoutProps> = async ({ id, showHeader = true }) => {
const unit = units[id.length as keyof typeof units]
const comparabilityOptions = comparability[id.length as keyof typeof comparability]
const [_data, statText] = await Promise.all([
const [_data, statText, mapPageInfo] = await Promise.all([
getSummaryStats<any>(unit, id),
getMdxContent("statistics", "primary.mdx"),
getMdxContent("page", "map.mdx"),
])

if (!_data.ok) {
Expand All @@ -35,8 +36,22 @@ export const ReportLayout: React.FC<ReportLayoutProps> = async ({ id, showHeader
const Wrapper = comparabilityOptions.length > 1 ? ComparabilityProvider : React.Fragment
return (
<Wrapper comparabilityOptions={comparabilityOptions}>
<ClientReportRenderer id={id} _data={_data} statText={statText} unit={unit} showHeader={showHeader}>
<ReportRenderer id={id} _data={_data} statText={statText} unit={unit} showHeader={showHeader} />
<ClientReportRenderer
id={id}
_data={_data}
statText={statText}
unit={unit}
showHeader={showHeader}
mapPageInfo={mapPageInfo}
>
<ReportRenderer
id={id}
_data={_data}
statText={statText}
unit={unit}
showHeader={showHeader}
mapPageInfo={mapPageInfo}
/>
</ClientReportRenderer>
</Wrapper>
)
Expand Down
5 changes: 4 additions & 1 deletion components/ReportLayout/ReportRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export const ReportRenderer: React.FC<{
comparability?: string
children?: React.ReactNode
showHeader?: boolean
}> = ({ _data, statText, id, unit, comparability, children, showHeader }) => {
mapPageInfo?: any
}> = ({ _data, statText, id, unit, comparability, children, showHeader, mapPageInfo }) => {
const { stats, name, data, foodAccess, marketPower, segregation, economicAdvantage, descriptionText, raceData } =
renderReportText(_data.result!, statText, id, comparability)

Expand Down Expand Up @@ -91,8 +92,10 @@ export const ReportRenderer: React.FC<{
id={id}
data={data}
stats={stats}
statText={statText}
raceData={raceData}
unit={unit}
mapPageInfo={mapPageInfo}
/>
))}
</div>
Expand Down
9 changes: 6 additions & 3 deletions components/ReportLayout/Sections.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import dynamic from "next/dynamic"
import React from "react"
import { Renderer as MapInner } from "components/Pages/Map/Renderer"
import StatList from "components/StatList"
import TimeseriesChart from "components/TimeseriesChart"
import Tooltip from "components/Tooltip"
import { columnsDict, type DataColumns, raceEthnicityLabels } from "utils/data/config"

const Map = dynamic(() => import("components/Map/Map"), { ssr: false })
// const Map = dynamic(() => import("components/Map/MapInner"), { ssr: false })
const StoreList = dynamic(() => import("components/StoreList"), { ssr: false })
// const ComparisonOverTimeChart = dynamic(() => import("components/ComparisonOverTime"), { ssr: false })
const PieChart = dynamic(() => import("components/PieChart/PieChart"), { ssr: false })
Expand Down Expand Up @@ -55,7 +56,9 @@ export const ReportSections: React.FC<{
raceData: any
unit: string
showTitle?: boolean
}> = ({ component, id, data, stats, raceData, unit, divId, showTitle = true }) => {
mapPageInfo?: any
statText?: any
}> = ({ component, id, data, stats, statText, raceData, unit, divId, showTitle = true, mapPageInfo }) => {
switch (component) {
case "Key Statistics":
return (
Expand Down Expand Up @@ -84,7 +87,7 @@ export const ReportSections: React.FC<{
<div id={divId}>
{!!showTitle && <h3 className="pb-2 text-2xl">Area Map</h3>}
<div className="relative h-[50vh] overflow-hidden">
<Map initialFilter={id} />
<MapInner initialFilter={id} pageInfo={mapPageInfo} stats={statText} />
</div>
</div>
)
Expand Down

0 comments on commit 97d4b34

Please sign in to comment.