From a982983b0fd9fde22d8fb87d31c6f7a36de1aca3 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Tue, 6 Oct 2020 18:19:17 -0400 Subject: [PATCH] launch: display group invites on home screen --- pkg/interface/src/views/apps/launch/app.js | 2 +- .../views/apps/launch/components/Groups.tsx | 39 ++++++++++++++++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/pkg/interface/src/views/apps/launch/app.js b/pkg/interface/src/views/apps/launch/app.js index 2a92f4173..c96574272 100644 --- a/pkg/interface/src/views/apps/launch/app.js +++ b/pkg/interface/src/views/apps/launch/app.js @@ -78,7 +78,7 @@ export default class LaunchApp extends React.Component { weather={props.weather} /> - + alphabeticalOrder(a.metadata.title, b.metadata.title); export default function Groups(props: GroupsProps & Parameters[0]) { - const { associations, ...boxProps } = props; + const { associations, invites, api, ...boxProps } = props; const [recentGroups, setRecentGroups] = useLocalStorageState( "recent-groups", [] ); - const groups = Object.values(props?.associations?.contacts || {}) + const incomingGroups = Object.values(invites?.['/contacts'] || {}); + const getKeyByValue = (object, value) => { + return Object.keys(object).find(key => object[key] === value); + } + + const groups = Object.values(associations?.contacts || {}) .sort(sortGroupsAlph) .sort(sortGroupsRecent(recentGroups)) @@ -55,6 +60,36 @@ export default function Groups(props: GroupsProps & Parameters[0]) { gridGap={3} p={2} > + {incomingGroups.map((invite) => ( + + You have been invited to: + {invite.path.slice(6)} + + api.invite.accept('/contacts', getKeyByValue(invites['/contacts'], invite))} + color='blue' + mr='2' + cursor='pointer'> + Accept + + api.invite.decline('/contacts', getKeyByValue(invites['/contacts'], invite))} + cursor='pointer'> + Reject + + + + ))} {groups.map((group) => (