Skip to content

Commit

Permalink
Fix house bar order
Browse files Browse the repository at this point in the history
  • Loading branch information
sipec committed Nov 6, 2024
1 parent 296874f commit a14e55e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
11 changes: 6 additions & 5 deletions web/components/usa-map/house-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import { DEM_DARK_HEX, REP_DARK_HEX } from './state-election-map'
import { Col } from 'web/components/layout/col'
import { ChevronDownIcon } from '@heroicons/react/solid'
import { useIsMobile } from 'web/hooks/use-is-mobile'
import { Answer, sortAnswers } from 'common/answer'
import { Answer } from 'common/answer'
import { useMemo } from 'react'
import { CPMMMultiContract } from 'common/contract'
import { StateBar } from './senate-bar'
import { houseProbToColor } from './house-table-helpers'
import { sortBy } from 'lodash'

export function HouseBar(props: {
liveAnswers: Answer[]
liveHouseContract: CPMMMultiContract
handleClick: (newTargetAnswer: string | undefined) => void
onMouseEnter: (hoverState: string) => void
onMouseLeave: () => void
Expand All @@ -20,7 +19,6 @@ export function HouseBar(props: {
}) {
const {
liveAnswers,
liveHouseContract,
handleClick,
onMouseEnter,
onMouseLeave,
Expand All @@ -29,7 +27,10 @@ export function HouseBar(props: {
} = props

const sortedAnswers = useMemo(
() => sortAnswers(liveHouseContract, liveAnswers, 'prob-asc'),
() =>
sortBy(liveAnswers, (answer) =>
answer.resolution ? (answer.resolution === 'YES' ? 1 : 0) : answer.prob
),
[liveAnswers]
)
const isMobile = useIsMobile()
Expand Down
1 change: 0 additions & 1 deletion web/components/usa-map/house-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export function HouseTable(props: { liveHouseContract: CPMMMultiContract }) {
<>
<HouseBar
liveAnswers={answers}
liveHouseContract={liveHouseContract}
handleClick={handleClick}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
Expand Down

0 comments on commit a14e55e

Please sign in to comment.