From 4b309838a9e652022d58f15619ae0be0ddc81e8a Mon Sep 17 00:00:00 2001 From: Rohan Moniz <60864468+rm03@users.noreply.github.com> Date: Tue, 15 Oct 2024 17:01:19 -0400 Subject: [PATCH] allow users to select multiple templates --- .../ClubPage/ClubApprovalDialog.tsx | 27 +++++++++++---- frontend/components/Settings/QueueTab.tsx | 33 +++++++++++++++++-- 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/frontend/components/ClubPage/ClubApprovalDialog.tsx b/frontend/components/ClubPage/ClubApprovalDialog.tsx index d826baaeb..faa479759 100644 --- a/frontend/components/ClubPage/ClubApprovalDialog.tsx +++ b/frontend/components/ClubPage/ClubApprovalDialog.tsx @@ -38,6 +38,7 @@ const ClubApprovalDialog = ({ club }: Props): ReactElement | null => { const [confirmModal, setConfirmModal] = useState(null) const [fairs, setFairs] = useState([]) const [templates, setTemplates] = useState([]) + const [selectedTemplates, setSelectedTemplates] = useState([]) const canApprove = apiCheckPermission('clubs.approve_club') const seeFairStatus = apiCheckPermission('clubs.see_fair_status') @@ -62,7 +63,11 @@ const ClubApprovalDialog = ({ club }: Props): ReactElement | null => { .then((resp) => resp.json()) .then(setTemplates) } - }, []) + + setComment( + selectedTemplates.map((template) => template.content).join('\n\n'), + ) + }, [selectedTemplates]) return ( <> @@ -211,17 +216,27 @@ const ClubApprovalDialog = ({ club }: Props): ReactElement | null => {
({ + value: template.id, + label: template.title, + content: template.content, + author: template.author, + }))} options={templates.map((template) => ({ value: template.id, label: template.title, content: template.content, + author: template.author, }))} - onChange={(selectedOption) => { - selectedOption ? setComment(selectedOption.content) : setComment('') + onChange={(selectedOptions) => { + if (selectedOptions) { + const selected = selectedOptions.map((option) => ({ + id: option.value, + title: option.label, + content: option.content, + author: option.author, + })) + setSelectedTemplates(selected) + } else { + setSelectedTemplates([]) + } }} />