Skip to content

Commit

Permalink
SurveyResponse: do not show topic checkboxes in form in case of no to…
Browse files Browse the repository at this point in the history
…pics
  • Loading branch information
JohannaPeanut committed Apr 2, 2024
1 parent 22b39c3 commit 839344a
Showing 1 changed file with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,15 @@ export function EditableSurveyResponseFilterForm<S extends z.ZodType<any, any>>(
return { value, label }
}),
]
const topicsOptions = [
...topics.map((t) => {
return { value: String(t.id), label: t.title }
}),
{ value: "0", label: "Ohne Thema" },
]
const topicsOptions = topics.length
? [
...topics.map((t) => {
return { value: String(t.id), label: t.title }
}),
{ value: "0", label: "Ohne Thema" },
]
: []

// @ts-expect-error
const categoriesOptions = feedbackQuestion?.props?.responses.map((r: TResponse) => {
return { value: String(r.id), label: r.text.de }
Expand Down Expand Up @@ -207,13 +210,15 @@ export function EditableSurveyResponseFilterForm<S extends z.ZodType<any, any>>(
scope="categories"
items={categoriesOptions}
/>
<LabeledCheckboxGroup
label="Themen"
classLabelOverwrite="font-semibold mb-3"
scope="topics"
items={topicsOptions}
classNameItemWrapper="grid grid-cols-5 grid-rows-6 grid-flow-col-dense"
/>
{!!topicsOptions.length && (
<LabeledCheckboxGroup
label="Themen"
classLabelOverwrite="font-semibold mb-3"
scope="topics"
items={topicsOptions}
classNameItemWrapper="grid grid-cols-5 grid-rows-6 grid-flow-col-dense"
/>
)}
</div>
<button
type="button"
Expand Down

0 comments on commit 839344a

Please sign in to comment.