File tree Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -2,13 +2,16 @@ import authOptions from "@/app/api/auth/[...nextauth]/authOptions";
22import BlankPageWithMessage from "@/components/BlankPageMessage" ;
33import List from "@/components/List" ;
44import ConnectionTile from "@/components/user/ConnectionTile" ;
5+ import { UserTile } from "@/components/user/UserTile" ;
56import { UserService } from "@/services/UserService" ;
67import { getServerSession } from "next-auth" ;
78
89export default async function Connections ( ) {
910 const session = ( await getServerSession ( authOptions ) ) ! ;
1011
11- const connections = await UserService . getConnections ( session . cannonToken ) ;
12+ const { connections, suggestions } = ( await UserService . getConnections (
13+ session . cannonToken ,
14+ ) ) || { connections : [ ] , suggestions : [ ] } ;
1215 if ( ! connections ) {
1316 return < BlankPageWithMessage message = "Connections not found!" /> ;
1417 }
@@ -28,6 +31,16 @@ export default async function Connections() {
2831 </ p >
2932 ) }
3033 </ List >
34+ { ! ! suggestions . length && (
35+ < List
36+ title = "Suggestions"
37+ description = "People who are connected with you"
38+ >
39+ { suggestions . map ( ( u ) => (
40+ < UserTile key = { u . id } user = { u } />
41+ ) ) }
42+ </ List >
43+ ) }
3144 </ div >
3245 ) ;
3346}
Original file line number Diff line number Diff line change @@ -39,10 +39,12 @@ export default async function UserProfile({
3939
4040 const achievements = await AchievementService . getAchievements ( ) ;
4141 const userAchievements = achievements ?. filter ( ( a ) =>
42- a . users ?. includes ( userProfile . id )
42+ a . users ?. includes ( userProfile . id ) ,
4343 ) ;
4444
45- const connections = await UserService . getConnections ( session . cannonToken ) ;
45+ const { connections } = ( await UserService . getConnections (
46+ session . cannonToken ,
47+ ) ) || { connections : [ ] } ;
4648 const connection = connections ?. find ( ( c ) => c . to === userProfile . id ) ;
4749
4850 async function handleNotesUpdate ( notes : string ) {
@@ -51,7 +53,7 @@ export default async function UserProfile({
5153 await UserService . updateConnection (
5254 session . cannonToken ,
5355 userProfile . id ,
54- notes
56+ notes ,
5557 ) ;
5658 }
5759
Original file line number Diff line number Diff line change @@ -281,9 +281,11 @@ export const UserService = (() => {
281281 return false ;
282282 } ;
283283
284+ type ConnectionsResponse = { connections : Connection [ ] ; suggestions : User [ ] } ;
285+
284286 const getConnections = async (
285287 cannonToken : string ,
286- ) : Promise < Connection [ ] | null > => {
288+ ) : Promise < ConnectionsResponse | null > => {
287289 try {
288290 const resp = await fetch ( `${ usersEndpoint } /me/connections` , {
289291 headers : {
@@ -294,7 +296,7 @@ export const UserService = (() => {
294296 tags : [ "updated-connection" ] ,
295297 } ,
296298 } ) ;
297- if ( resp . ok ) return ( await resp . json ( ) ) as Connection [ ] ;
299+ if ( resp . ok ) return ( await resp . json ( ) ) as ConnectionsResponse ;
298300 } catch ( err ) {
299301 console . error ( err ) ;
300302 }
You can’t perform that action at this time.
0 commit comments