mirror of
https://github.com/KabKebab/GS13.git
synced 2026-08-23 21:16:16 +01:00
58 lines
1.2 KiB
JavaScript
58 lines
1.2 KiB
JavaScript
import { useBackend } from '../backend';
|
|
import { Box, Button, Grid, Section, NoticeBox } from '../components';
|
|
import { toTitleCase } from 'common/string';
|
|
|
|
export const EightBallVote = props => {
|
|
const { act, data } = useBackend(props);
|
|
|
|
const {
|
|
question,
|
|
shaking,
|
|
answers = [],
|
|
} = data;
|
|
|
|
if (!shaking) {
|
|
return (
|
|
<NoticeBox>
|
|
No question is currently being asked.
|
|
</NoticeBox>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Section>
|
|
<Box
|
|
bold
|
|
textAlign="center"
|
|
fontSize="16px"
|
|
m={1}>
|
|
"{question}"
|
|
</Box>
|
|
<Grid>
|
|
{answers.map(answer => (
|
|
<Grid.Column key={answer.answer}>
|
|
<Button
|
|
fluid
|
|
bold
|
|
content={toTitleCase(answer.answer)}
|
|
selected={answer.selected}
|
|
fontSize="16px"
|
|
lineHeight="24px"
|
|
textAlign="center"
|
|
mb={1}
|
|
onClick={() => act('vote', {
|
|
answer: answer.answer,
|
|
})} />
|
|
<Box
|
|
bold
|
|
textAlign="center"
|
|
fontSize="30px">
|
|
{answer.amount}
|
|
</Box>
|
|
</Grid.Column>
|
|
))}
|
|
</Grid>
|
|
</Section>
|
|
);
|
|
};
|