Skip to content

Commit

Permalink
Merge pull request #198 from CS3219-AY2425S1/fix/bug/question-form
Browse files Browse the repository at this point in the history
Fix category view of question form in non-admin account
  • Loading branch information
wr1159 authored Nov 14, 2024
2 parents 1ba7dd7 + a38b65f commit 47cacbe
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions frontend/components/questions/question-form-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,28 @@ const QuestionFormModal: React.FC<QuestionFormModalProps> = ({ ...props }) => {
</DialogHeader>
<div>
<Label>Category</Label>
<MultiSelect
className="mt-2"
defaultValue={question.categories as string[]}
options={CategoryEnumArray.map((category) => ({
label: category,
value: category,
}))}
onValueChange={(v) =>
setQuestion({
...question,
categories: v as CategoryEnum[],
})
}
/>
{props.isAdmin ? (
<MultiSelect
className="mt-2"
defaultValue={question.categories as string[]}
options={CategoryEnumArray.map((category) => ({
label: category,
value: category,
}))}
onValueChange={(v) =>
setQuestion({
...question,
categories: v as CategoryEnum[],
})
}
/>
) : (
<Input
className="mt-2"
value={question.categories.join(", ")}
disabled
/>
)}
</div>

<div>
Expand Down

0 comments on commit 47cacbe

Please sign in to comment.