Allow users to see 0% FR answers via show more button

This commit is contained in:
Ian Philips 2022-09-12 14:30:15 -06:00
parent 4456a771fd
commit 0af1ff112b
2 changed files with 19 additions and 6 deletions

View File

@ -23,6 +23,7 @@ import { Avatar } from 'web/components/avatar'
import { Linkify } from 'web/components/linkify' import { Linkify } from 'web/components/linkify'
import { BuyButton } from 'web/components/yes-no-selector' import { BuyButton } from 'web/components/yes-no-selector'
import { UserLink } from 'web/components/user-link' import { UserLink } from 'web/components/user-link'
import { Button } from 'web/components/button'
export function AnswersPanel(props: { export function AnswersPanel(props: {
contract: FreeResponseContract | MultipleChoiceContract contract: FreeResponseContract | MultipleChoiceContract
@ -30,13 +31,14 @@ export function AnswersPanel(props: {
const { contract } = props const { contract } = props
const { creatorId, resolution, resolutions, totalBets, outcomeType } = const { creatorId, resolution, resolutions, totalBets, outcomeType } =
contract contract
const [showAllAnswers, setShowAllAnswers] = useState(false)
const answers = useAnswers(contract.id) ?? contract.answers const answers = useAnswers(contract.id) ?? contract.answers
const [winningAnswers, losingAnswers] = partition( const [winningAnswers, losingAnswers] = partition(
answers.filter( answers.filter((answer) =>
(answer) => (answer.id !== '0' || outcomeType === 'MULTIPLE_CHOICE') && showAllAnswers
(answer.id !== '0' || outcomeType === 'MULTIPLE_CHOICE') && ? true
totalBets[answer.id] > 0.000000001 : totalBets[answer.id] > 0
), ),
(answer) => (answer) =>
answer.id === resolution || (resolutions && resolutions[answer.id]) answer.id === resolution || (resolutions && resolutions[answer.id])
@ -127,6 +129,17 @@ export function AnswersPanel(props: {
</div> </div>
</div> </div>
))} ))}
<Row className={'justify-end'}>
{!showAllAnswers && (
<Button
color={'gray-white'}
onClick={() => setShowAllAnswers(true)}
size={'md'}
>
Show More
</Button>
)}
</Row>
</div> </div>
</div> </div>
)} )}

View File

@ -76,7 +76,7 @@ export function CreateAnswerPanel(props: { contract: FreeResponseContract }) {
if (existingAnswer) { if (existingAnswer) {
setAnswerError( setAnswerError(
existingAnswer existingAnswer
? `"${existingAnswer.text}" already exists as an answer` ? `"${existingAnswer.text}" already exists as an answer. Can't see it? Hit the 'Show More' button right above this box.`
: '' : ''
) )
return return
@ -237,7 +237,7 @@ const AnswerError = (props: { text: string; level: answerErrorLevel }) => {
}[level] ?? '' }[level] ?? ''
return ( return (
<div <div
className={`${colorClass} mb-2 mr-auto self-center whitespace-nowrap text-xs font-medium tracking-wide`} className={`${colorClass} mb-2 mr-auto self-center text-xs font-medium tracking-wide`}
> >
{text} {text}
</div> </div>