groups: show invites in home workspace

This commit is contained in:
Matilde Park 2020-10-09 14:35:40 -04:00
parent 9b8d197e8f
commit 072a9643eb

View File

@ -18,7 +18,8 @@ import { SidebarListHeader } from "./SidebarListHeader";
import { useLocalStorageState } from "~/logic/lib/useLocalStorageState";
import { getGroupFromWorkspace } from "~/logic/lib/workspace";
import { SidebarAppConfigs } from './types';
import {SidebarList} from "./SidebarList";
import { SidebarList } from "./SidebarList";
import { SidebarInvite } from './SidebarInvite';
interface SidebarProps {
children: ReactNode;
@ -50,6 +51,27 @@ const SidebarStickySpacer = styled(Box)`
}
`;
const inviteItems = (invites, api) => {
const returned = [];
Object.keys(invites).filter((e) => {
return e !== '/contacts';
}).map((appKey) => {
const app = invites[appKey];
Object.keys(app).map((uid) => {
const invite = app[uid];
const inviteItem =
<SidebarInvite
key={uid}
invite={invite}
onAccept={() => api.invite.accept(appKey, uid)}
onDecline={() => api.invite.decline(appKey, uid)}
/>;
returned.push(inviteItem);
});
});
return returned;
};
export function Sidebar(props: SidebarProps) {
const { invites, api, associations, selected, apps, workspace } = props;
const groupPath = getGroupFromWorkspace(workspace);
@ -65,6 +87,8 @@ export function Sidebar(props: SidebarProps) {
hideUnjoined: false,
}
);
const sidebarInvites = (workspace?.type === 'home')
? inviteItems(invites, api) : null;
return (
<Col
display={display}
@ -85,6 +109,7 @@ export function Sidebar(props: SidebarProps) {
workspace={props.workspace}
/>
<SidebarListHeader initialValues={config} handleSubmit={setConfig} />
{sidebarInvites}
<SidebarList
config={config}
associations={associations}