From f91a7c2de7cac1349ba708f4e46df31d18550d1d Mon Sep 17 00:00:00 2001 From: Kaisa Korpela Date: Mon, 2 Aug 2021 13:48:46 +0300 Subject: [PATCH] Fix group leader name --- src/components/Actions/index.js | 2 ++ src/components/ListItem/index.js | 1 + src/components/Notifications/TaskNotification.js | 12 +----------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/components/Actions/index.js b/src/components/Actions/index.js index a87c908..e6e6d1c 100644 --- a/src/components/Actions/index.js +++ b/src/components/Actions/index.js @@ -27,6 +27,7 @@ const Actions = ({ groupGuid, isFavourite, actionsComponent, + name, }) => { const [showActions, setShowActions] = useState(false) const tasks = useSelector(state => state.tasks) @@ -90,6 +91,7 @@ const Actions = ({ task_guid: guid, user_guid: userGuid, completion_status: COMPLETION_STATUS.COMPLETED, + group_leader_name: name, } await postMemberTaskEntry(update) setShowActions(false) diff --git a/src/components/ListItem/index.js b/src/components/ListItem/index.js index 9f31aa4..2d4835d 100644 --- a/src/components/ListItem/index.js +++ b/src/components/ListItem/index.js @@ -153,6 +153,7 @@ const ListItem = ({ actionsComponent={actionsComponent} userGuid={userGuid} groupGuid={groupGuid} + name={user.name} /> ))} diff --git a/src/components/Notifications/TaskNotification.js b/src/components/Notifications/TaskNotification.js index 6fe78a2..0b164cb 100644 --- a/src/components/Notifications/TaskNotification.js +++ b/src/components/Notifications/TaskNotification.js @@ -34,24 +34,14 @@ const getStateMessage = state => { const TaskNotification = ({ notification, markRead }) => { const itemsByGuid = useSelector(state => state.itemsByGuid) - const groups = useSelector(state => state.user.userGroups) const task = itemsByGuid[notification.item_guid] const timestamp = getTimestamp(notification.created_at) - const user = groups.reduce((cur, group) => { - if (cur) { - return cur - } - const found = group.members.find(member => { - return member.memberId.toString() === notification.created_by - }) - return found - }, null) return ( - Ryhmänjohtaja {user.memberName} on{' '} + Ryhmänjohtaja {notification.group_leader_name} on{' '} {getStateMessage(notification.notification_type)} tehtäväsi{' '}