-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- link to profile on dashboard #3
- Loading branch information
Showing
20 changed files
with
274 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.next | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import UserCommunityList from './user-community-list.component'; | ||
|
||
export default UserCommunityList; |
77 changes: 77 additions & 0 deletions
77
app/components/user-community-list/user-community-list.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import Link from 'next/link'; | ||
import React from 'react'; | ||
import { List, Avatar } from 'antd'; | ||
import { request } from 'graphql-request'; | ||
import useSWR from 'swr'; | ||
|
||
const useDashboardData = (profileId) => { | ||
const { data, error } = useSWR(profileId, (id) => | ||
request( | ||
'/api/graphql', | ||
`query ViewProfile($id: ID!) { | ||
profile: findUserProfileByID(id: $id) { | ||
memberships { | ||
data { | ||
role | ||
createdAt | ||
communityProfile { | ||
_id | ||
name | ||
iconUrl | ||
} | ||
} | ||
} | ||
} | ||
}`, | ||
{ id } | ||
) | ||
); | ||
return { data, error }; | ||
}; | ||
|
||
const UserCommunityList = ({ userId }) => { | ||
const { data } = useDashboardData(userId); | ||
|
||
const items = data ? (data.profile.memberships?.data as any[]) : []; | ||
|
||
// todo set locale to be based on the users localeCode | ||
const formatter = new Intl.DateTimeFormat('en-GB'); | ||
|
||
return ( | ||
<List | ||
header="Community Memberships" | ||
itemLayout="horizontal" | ||
dataSource={items} | ||
loading={!data} | ||
renderItem={({ createdAt, role, communityProfile }) => ( | ||
<List.Item | ||
extra={<div>Since {formatter.format(new Date(createdAt))}</div>} | ||
actions={[ | ||
<Link | ||
key="view" | ||
href="/communities/[communityId]" | ||
as={`/communities/${communityProfile._id}`} | ||
> | ||
<a>View</a> | ||
</Link>, | ||
]} | ||
> | ||
<List.Item.Meta | ||
avatar={<Avatar size="large" src={communityProfile.iconUrl} />} | ||
title={ | ||
<Link | ||
href="/communities/[communityId]" | ||
as={`/communities/${communityProfile._id}`} | ||
> | ||
<a>{communityProfile.name}</a> | ||
</Link> | ||
} | ||
description={role} | ||
/> | ||
</List.Item> | ||
)} | ||
/> | ||
); | ||
}; | ||
|
||
export default UserCommunityList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.