groups: show invites in home workspace
@@ -19,6 +19,7 @@ import { useLocalStorageState } from "~/logic/lib/useLocalStorageState";
import { getGroupFromWorkspace } from "~/logic/lib/workspace";
import { SidebarAppConfigs } from './types';
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}
