Skip to content

Commit 3e5405e

Browse files
ncduy0303adi-herwana-nus
authored andcommitted
feat(survey_response_edit): add required chip
1 parent 8b55c67 commit 3e5405e

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

client/app/bundles/course/survey/containers/ResponseForm/ResponseSection.jsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { useFieldArray } from 'react-hook-form';
22
import { defineMessages, FormattedMessage } from 'react-intl';
3-
import { Card, CardContent, CardHeader, Typography } from '@mui/material';
3+
import { Card, CardContent, CardHeader, Chip, Typography } from '@mui/material';
44
import { red } from '@mui/material/colors';
55
import PropTypes from 'prop-types';
66

7+
import useTranslation from 'lib/hooks/useTranslation';
8+
import formTranslations from 'lib/translations/form';
9+
710
import ResponseAnswer from './ResponseAnswer';
811

912
const styles = {
@@ -27,6 +30,7 @@ const translations = defineMessages({
2730
});
2831

2932
const ResponseSection = (props) => {
33+
const { t } = useTranslation();
3034
const { control, disabled, section, sectionIndex } = props;
3135
const { fields: questionFields } = useFieldArray({
3236
control,
@@ -49,10 +53,24 @@ const ResponseSection = (props) => {
4953
<CardContent>
5054
{questionFields.map((question, questionIndex) => (
5155
<Card key={question.id} style={styles.questionCard}>
52-
<CardContent>
56+
<CardContent className="relative">
57+
<div className="absolute -left-5 top-6 flex items-center justify-center rounded-full wh-10 bg-neutral-500">
58+
<Typography color="white" variant="body2">
59+
{questionIndex + 1}
60+
</Typography>
61+
</div>
62+
{question.required && (
63+
<Chip
64+
color="error"
65+
label={t(formTranslations.starRequired)}
66+
size="small"
67+
variant="outlined"
68+
/>
69+
)}
5370
<Typography
71+
component="div"
5472
dangerouslySetInnerHTML={{
55-
__html: `${questionIndex + 1}. ${question.description}`,
73+
__html: question.description,
5674
}}
5775
variant="body2"
5876
/>

0 commit comments

Comments
 (0)