Skip to content

Commit

Permalink
added skills question as checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Li committed Aug 3, 2023
1 parent 6542dac commit 48cc614
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/pages/admin/DynamicForm/FormCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,8 @@ const FormCreate = (props) => {
type: Yup.mixed().oneOf(["TEXT", "SELECT", "CHECKBOX", "UPLOAD"]).required(),
label: Yup.string().required("Question is a required field"),
choices: Yup.string(),
required: Yup.boolean().required()
required: Yup.boolean().required(),
isSkillsQuestion: Yup.boolean()
});

const validationSchema = Yup.object({
Expand Down
44 changes: 31 additions & 13 deletions src/pages/admin/DynamicForm/components/CustomQuestion.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const CustomQuestion = (props) => {
} = props;

const {
type, label, choices, questionImageUrl, charLimit, required
type, label, choices, questionImageUrl, charLimit, required, isSkillsQuestion
} = props.data;
const questionStyles = {
// -------- QUESTION COMPONENT STYLES ----------
Expand Down Expand Up @@ -100,11 +100,16 @@ const CustomQuestion = (props) => {
flexDirection: "column",
justifyContent: "center"
},
requiredContainer: {
checkboxContainer: {
display: "flex",
justifyContent: "flex-end",
alignItems: "center",
color: "rgba(255,255,255,0.8)"
},
checkboxWrapper: {
display: "flex",
flexDirection: "row",
justifyContent: "flex-end"
}
};

Expand Down Expand Up @@ -240,18 +245,31 @@ const CustomQuestion = (props) => {
value={choices}
/>
)}

<div style={questionStyles.requiredContainer}>
<div style={questionStyles.checkboxWrapper}>
<div style={questionStyles.checkboxContainer}>
Skills Question?
<Checkbox
id={`${id}.isSkillsQuestion`}
name={`${name}.isSkillsQuestion`}
color="primary"
aria-label="Skills question?"
checked={isSkillsQuestion}
onChange={handleChange}
onBlur={handleBlur}
/>
</div>
<div style={questionStyles.checkboxContainer}>
Required?
<Checkbox
id={`${id}.required`}
name={`${name}.required`}
color="primary"
aria-label="Required question?"
checked={required}
onChange={handleChange}
onBlur={handleBlur}
/>
<Checkbox
id={`${id}.required`}
name={`${name}.required`}
color="primary"
aria-label="Required question?"
checked={required}
onChange={handleChange}
onBlur={handleBlur}
/>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 48cc614

Please sign in to comment.