Clarify rendering logic

This commit is contained in:
Ian Philips 2022-05-03 16:36:18 -04:00
parent d57eecb0c0
commit 72a996a230

View File

@ -313,25 +313,44 @@ export function CommentInput(props: {
</div> </div>
)} )}
</div> </div>
<button {!user && (
className={'btn btn-outline btn-sm text-transform: mt-1 capitalize'} <button
onClick={() => { className={
if (answerOutcome === undefined) { 'btn btn-outline btn-sm text-transform: mt-1 capitalize'
submitComment(id)
} else if (!focused) {
setFocused(true)
} else {
submitComment(id)
setFocused(false)
} }
}} onClick={() => submitComment(id)}
> >
{user Sign in to Comment
? !focused && answerOutcome !== undefined </button>
? 'Add Comment' )}
: 'Comment' {user && answerOutcome === undefined && (
: 'Sign in to comment'} <button
</button> className={
'btn btn-outline btn-sm text-transform: mt-1 capitalize'
}
onClick={() => submitComment(id)}
>
Comment
</button>
)}
{user && answerOutcome !== undefined && (
<button
className={
focused
? 'btn btn-outline btn-sm text-transform: mt-1 capitalize'
: 'btn btn-ghost btn-sm text-transform: mt-1 capitalize'
}
onClick={() => {
if (!focused) setFocused(true)
else {
submitComment(id)
setFocused(false)
}
}}
>
{!focused ? 'Add Comment' : 'Comment'}
</button>
)}
</div> </div>
</Row> </Row>
</> </>