Add projects to user profile

Signed-off-by: Sebastian Martinez <sebastinez@me.com>
Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
Sebastian Martinez
2021-07-20 14:16:53 +02:00
committed by Alexis Sellier
parent 44abcdee67
commit 77145b1359
2 changed files with 36 additions and 0 deletions
+8
View File
@@ -216,6 +216,14 @@ export class Org {
}
}
// Return only Orgs that have a specific user as owner
static async getOrgsByOwner(owner: string, config: Config): Promise<Org[]> {
const orgsResult = await utils.querySubgraph(config.orgs.subgraph, GetOrgsByOwner, { owners: [owner] });
return orgsResult.orgs.map((o: { id: string; owner: string }) => {
return new Org(o.id, o.owner);
});
}
static async getOrgsByMember(memberAddr: string, config: Config): Promise<Org[]> {
const safeResult = await utils.querySubgraph(
config.safe.subgraph, GetSafes, { owners: [memberAddr] }
+28
View File
@@ -5,6 +5,9 @@
import Avatar from '@app/Avatar.svelte';
import { Profile } from '@app/profile';
import Loading from '@app/Loading.svelte';
import { Org } from '@app/base/orgs/Org';
import Message from '@app/Message.svelte';
import Project from '@app/base/projects/Widget.svelte';
export let address: string;
export let config: Config;
@@ -45,6 +48,12 @@
display: flex; /* Ensures correct vertical positioning of icons */
margin-right: 1rem;
}
.projects {
margin-top: 2rem;
}
.projects .project {
margin-bottom: 1rem;
}
</style>
{#await Profile.get(address, config)}
@@ -74,5 +83,24 @@
</div>
</div>
</header>
<div class="projects">
{#await Org.getOrgsByOwner(address, config)}
<Loading center fadeIn />
{:then orgs}
{#each orgs as org}
{#await org.getProjects(config) then projects}
{#each projects as project}
<div class="project">
<Project {project} org={org.address} {config} seed={profile.seed} />
</div>
{/each}
{:catch err}
<Message error>
<strong>Error: </strong> failed to load projects: {err.message}.
</Message>
{/await}
{/each}
{/await}
</div>
</main>
{/await}