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

@ -19,6 +19,7 @@ import { useLocalStorageState } from "~/logic/lib/useLocalStorageState";
import { getGroupFromWorkspace } from "~/logic/lib/workspace"; import { getGroupFromWorkspace } from "~/logic/lib/workspace";
import { SidebarAppConfigs } from './types'; import { SidebarAppConfigs } from './types';
import { SidebarList } from "./SidebarList"; import { SidebarList } from "./SidebarList";
import { SidebarInvite } from './SidebarInvite';
interface SidebarProps { interface SidebarProps {
children: ReactNode; 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) { export function Sidebar(props: SidebarProps) {
const { invites, api, associations, selected, apps, workspace } = props; const { invites, api, associations, selected, apps, workspace } = props;
const groupPath = getGroupFromWorkspace(workspace); const groupPath = getGroupFromWorkspace(workspace);
@ -65,6 +87,8 @@ export function Sidebar(props: SidebarProps) {
hideUnjoined: false, hideUnjoined: false,
} }
); );
const sidebarInvites = (workspace?.type === 'home')
? inviteItems(invites, api) : null;
return ( return (
<Col <Col
display={display} display={display}
@ -85,6 +109,7 @@ export function Sidebar(props: SidebarProps) {
workspace={props.workspace} workspace={props.workspace}
/> />
<SidebarListHeader initialValues={config} handleSubmit={setConfig} /> <SidebarListHeader initialValues={config} handleSubmit={setConfig} />
{sidebarInvites}
<SidebarList <SidebarList
config={config} config={config}
associations={associations} associations={associations}