fix: hide empty radiobuttons
This commit is contained in:
parent
c9f9f3a4b0
commit
d36d3656bc
@ -160,5 +160,4 @@ export default function QuizPreviewLayout() {
|
|||||||
</Box>
|
</Box>
|
||||||
</Paper>
|
</Paper>
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,19 +2,19 @@ import { Box, Typography } from "@mui/material";
|
|||||||
import LabeledDatePicker from "@ui_kit/LabeledDatePicker";
|
import LabeledDatePicker from "@ui_kit/LabeledDatePicker";
|
||||||
import { QuizQuestionDate } from "model/questionTypes/date";
|
import { QuizQuestionDate } from "model/questionTypes/date";
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
question: QuizQuestionDate;
|
question: QuizQuestionDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Date({ question }: Props) {
|
export default function Date({ question }: Props) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{
|
<Box
|
||||||
|
sx={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
gap: 1,
|
gap: 1,
|
||||||
}}>
|
}}
|
||||||
|
>
|
||||||
<Typography variant="h6">{question.title}</Typography>
|
<Typography variant="h6">{question.title}</Typography>
|
||||||
<LabeledDatePicker />
|
<LabeledDatePicker />
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@ -31,7 +31,9 @@ export default function Emoji({ question }: Props) {
|
|||||||
value={value}
|
value={value}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
>
|
>
|
||||||
{question.content.variants.map((variant, index) => (
|
{question.content.variants
|
||||||
|
.filter(({ answer }) => answer)
|
||||||
|
.map((variant, index) => (
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
key={index}
|
key={index}
|
||||||
value={variant.answer}
|
value={variant.answer}
|
||||||
|
|||||||
@ -53,7 +53,9 @@ export default function Images({ question }: Props) {
|
|||||||
gap: 1,
|
gap: 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{question.content.variants.map((variant, index) => (
|
{question.content.variants
|
||||||
|
.filter(({ answer }) => answer)
|
||||||
|
.map((variant, index) => (
|
||||||
<ButtonBase
|
<ButtonBase
|
||||||
key={index}
|
key={index}
|
||||||
onClick={() => handleVariantClick(index)}
|
onClick={() => handleVariantClick(index)}
|
||||||
|
|||||||
@ -1,9 +1,16 @@
|
|||||||
import ArrowDownIcon from "@icons/ArrowDownIcon";
|
import ArrowDownIcon from "@icons/ArrowDownIcon";
|
||||||
import { Box, FormControl, MenuItem, Select, SelectChangeEvent, Typography, useTheme } from "@mui/material";
|
import {
|
||||||
|
Box,
|
||||||
|
FormControl,
|
||||||
|
MenuItem,
|
||||||
|
Select,
|
||||||
|
SelectChangeEvent,
|
||||||
|
Typography,
|
||||||
|
useTheme,
|
||||||
|
} from "@mui/material";
|
||||||
import { QuizQuestionSelect } from "model/questionTypes/select";
|
import { QuizQuestionSelect } from "model/questionTypes/select";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
question: QuizQuestionSelect;
|
question: QuizQuestionSelect;
|
||||||
}
|
}
|
||||||
@ -17,11 +24,13 @@ export default function Text({ question }: Props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{
|
<Box
|
||||||
|
sx={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
gap: 1,
|
gap: 1,
|
||||||
}}>
|
}}
|
||||||
|
>
|
||||||
<Typography variant="h6">{question.title}</Typography>
|
<Typography variant="h6">{question.title}</Typography>
|
||||||
<FormControl
|
<FormControl
|
||||||
fullWidth
|
fullWidth
|
||||||
@ -79,7 +88,9 @@ export default function Text({ question }: Props) {
|
|||||||
}}
|
}}
|
||||||
IconComponent={(props) => <ArrowDownIcon {...props} />}
|
IconComponent={(props) => <ArrowDownIcon {...props} />}
|
||||||
>
|
>
|
||||||
{question.content.variants.map(variant => (
|
{question.content.variants
|
||||||
|
.filter(({ answer }) => answer)
|
||||||
|
.map((variant) => (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
key={variant.answer}
|
key={variant.answer}
|
||||||
value={variant.answer}
|
value={variant.answer}
|
||||||
|
|||||||
@ -25,29 +25,32 @@ export default function Variant({ question }: Props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<FormControl fullWidth>
|
<FormControl fullWidth>
|
||||||
<FormLabel
|
<FormLabel id="quiz-question-radio-group" data-cy="variant-title">
|
||||||
id="quiz-question-radio-group"
|
{question.title}
|
||||||
data-cy="variant-title"
|
</FormLabel>
|
||||||
>{question.title}</FormLabel>
|
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
aria-labelledby="quiz-question-radio-group"
|
aria-labelledby="quiz-question-radio-group"
|
||||||
value={value}
|
value={value}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
>
|
>
|
||||||
{question.content.variants.map((variant, index) => (
|
{question.content.variants
|
||||||
|
.filter(({ answer }) => answer)
|
||||||
|
.map((variant, index) => (
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
key={index}
|
key={index}
|
||||||
value={variant.answer}
|
value={variant.answer}
|
||||||
control={<Radio
|
control={
|
||||||
|
<Radio
|
||||||
inputProps={{
|
inputProps={{
|
||||||
"data-cy": "variant-radio",
|
"data-cy": "variant-radio",
|
||||||
}}
|
}}
|
||||||
/>}
|
/>
|
||||||
|
}
|
||||||
label={
|
label={
|
||||||
<Box sx={{ display: "flex", alignItems: "center", gap: 2 }}>
|
<Box sx={{ display: "flex", alignItems: "center", gap: 2 }}>
|
||||||
<Typography
|
<Typography data-cy="variant-answer">
|
||||||
data-cy="variant-answer"
|
{variant.answer}
|
||||||
>{variant.answer}</Typography>
|
</Typography>
|
||||||
<Tooltip title={variant.hints} placement="right">
|
<Tooltip title={variant.hints} placement="right">
|
||||||
<Box>
|
<Box>
|
||||||
<InfoIcon />
|
<InfoIcon />
|
||||||
|
|||||||
@ -46,7 +46,9 @@ export default function Varimg({ question }: Props) {
|
|||||||
value={currentVariant?.answer ?? ""}
|
value={currentVariant?.answer ?? ""}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
>
|
>
|
||||||
{question.content.variants.map((variant, index) => (
|
{question.content.variants
|
||||||
|
.filter(({ answer }) => answer)
|
||||||
|
.map((variant, index) => (
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
key={index}
|
key={index}
|
||||||
value={variant.answer}
|
value={variant.answer}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user