Skip to content

Commit

Permalink
Merge pull request #429 from Klimatbyran/staging
Browse files Browse the repository at this point in the history
Hotfix for broken column headers in municipality list
  • Loading branch information
elvbom authored Mar 19, 2024
2 parents e529668 + 63edf19 commit 810cf9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function StartPage({ municipalities }: PropsType) {
)
}

const cols = listColumns(selectedDataset)
const cols = listColumns(selectedDataset, datasetDescriptions[selectedDataset].columnHeader)
const rankedData = rankData(municipalities, selectedDataset) // fixme hur byter jag ut denna till municipalityData?

const isDefaultDataView = selectedDataView === defaultDataView
Expand Down
9 changes: 6 additions & 3 deletions utils/createMunicipalityList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const rankData = (municipalities: Municipality[], selectedData: SelectedD

export const listColumns = (
selectedData: SelectedData,
columnHeader: string,
): ColumnDef<{
name: string
dataPoint: string | number | Date | JSX.Element
Expand All @@ -97,7 +98,7 @@ export const listColumns = (

return [
{
header: 'Har plan?',
header: isClimatePlan ? 'Har plan?' : 'Ranking',
cell: (row) => {
if (isClimatePlan) {
return row.row.original.index === -1
Expand All @@ -124,14 +125,16 @@ export const listColumns = (
accessorKey: 'name',
},
{
header: 'Antagen år',
header: () => columnHeader,
cell: (row) => {
const { formattedDataPoint } = row.row.original

if (isClimatePlan) {
return row.row.original.dataPoint !== 'Saknas'
? <span style={{ color: 'grey' }}>{row.row.original.yearAdapted}</span>
: <span style={{ color: 'grey' }}>Saknar plan</span>
}
return row.cell.row.index + 1
return formattedDataPoint
},
accessorKey: 'dataPoint',
},
Expand Down

0 comments on commit 810cf9f

Please sign in to comment.