Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mluukkai committed Sep 2, 2024
1 parent 8b2d495 commit 0b9df13
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ const GroupCreationForm = ({
onInstructorChange,
topics,
onTopicSelectChange,

groupTopicID,
groupConfigurationID,
createGroupSuccsess,
Expand All @@ -108,6 +107,7 @@ const GroupCreationForm = ({
const thistopic = topics.find((topic) => topic.id === topicid)
onNameChangeForm(thistopic.content.title)
}

return (
<div>
<form
Expand Down
22 changes: 17 additions & 5 deletions frontend/src/components/GroupManagementPage/TopicSelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,26 @@ const TopicSelect = ({
className,
groupConfig
}) => {

const filteredTopics = topics.filter(topic => {
const isSelected = (emails) => {
if (!emails || emails.length===0) {
return false
}

return emails.map(email => email.email.type).includes('topicAccepted')
}

return topic.active && topic.configuration_id === groupConfig && isSelected(topic.sentEmails)
})

return (
<Select
className={className}
value={groupTopicID}
onChange={(e) => onTopicSelectChange(e.target.value)}
>
{topics
.filter(
(topic) => topic.active && topic.configuration_id === groupConfig
)
{filteredTopics
.map((topic) => (
<MenuItem key={topic.id} value={topic.id} className="topic-menu-item">
{topic.content.title}
Expand All @@ -31,8 +41,10 @@ const TopicSelect = ({
}

const mapStateToProps = (state) => {
const id = state.groupPage.groupConfigurationID
const ids = state.configurationPage.configurations.map(config => config.id)
return {
groupConfig: state.groupPage.groupConfigurationID
groupConfig: id ? id : Math.max(...ids),
}
}

Expand Down

0 comments on commit 0b9df13

Please sign in to comment.