File tree 3 files changed +23
-6
lines changed
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";
2
2
import BlankPageWithMessage from "@/components/BlankPageMessage" ;
3
3
import List from "@/components/List" ;
4
4
import ConnectionTile from "@/components/user/ConnectionTile" ;
5
+ import { UserTile } from "@/components/user/UserTile" ;
5
6
import { UserService } from "@/services/UserService" ;
6
7
import { getServerSession } from "next-auth" ;
7
8
8
9
export default async function Connections ( ) {
9
10
const session = ( await getServerSession ( authOptions ) ) ! ;
10
11
11
- const connections = await UserService . getConnections ( session . cannonToken ) ;
12
+ const { connections, suggestions } = ( await UserService . getConnections (
13
+ session . cannonToken ,
14
+ ) ) || { connections : [ ] , suggestions : [ ] } ;
12
15
if ( ! connections ) {
13
16
return < BlankPageWithMessage message = "Connections not found!" /> ;
14
17
}
@@ -28,6 +31,16 @@ export default async function Connections() {
28
31
</ p >
29
32
) }
30
33
</ 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
+ ) }
31
44
</ div >
32
45
) ;
33
46
}
Original file line number Diff line number Diff line change @@ -39,10 +39,12 @@ export default async function UserProfile({
39
39
40
40
const achievements = await AchievementService . getAchievements ( ) ;
41
41
const userAchievements = achievements ?. filter ( ( a ) =>
42
- a . users ?. includes ( userProfile . id )
42
+ a . users ?. includes ( userProfile . id ) ,
43
43
) ;
44
44
45
- const connections = await UserService . getConnections ( session . cannonToken ) ;
45
+ const { connections } = ( await UserService . getConnections (
46
+ session . cannonToken ,
47
+ ) ) || { connections : [ ] } ;
46
48
const connection = connections ?. find ( ( c ) => c . to === userProfile . id ) ;
47
49
48
50
async function handleNotesUpdate ( notes : string ) {
@@ -51,7 +53,7 @@ export default async function UserProfile({
51
53
await UserService . updateConnection (
52
54
session . cannonToken ,
53
55
userProfile . id ,
54
- notes
56
+ notes ,
55
57
) ;
56
58
}
57
59
Original file line number Diff line number Diff line change @@ -281,9 +281,11 @@ export const UserService = (() => {
281
281
return false ;
282
282
} ;
283
283
284
+ type ConnectionsResponse = { connections : Connection [ ] ; suggestions : User [ ] } ;
285
+
284
286
const getConnections = async (
285
287
cannonToken : string ,
286
- ) : Promise < Connection [ ] | null > => {
288
+ ) : Promise < ConnectionsResponse | null > => {
287
289
try {
288
290
const resp = await fetch ( `${ usersEndpoint } /me/connections` , {
289
291
headers : {
@@ -294,7 +296,7 @@ export const UserService = (() => {
294
296
tags : [ "updated-connection" ] ,
295
297
} ,
296
298
} ) ;
297
- if ( resp . ok ) return ( await resp . json ( ) ) as Connection [ ] ;
299
+ if ( resp . ok ) return ( await resp . json ( ) ) as ConnectionsResponse ;
298
300
} catch ( err ) {
299
301
console . error ( err ) ;
300
302
}
You can’t perform that action at this time.
0 commit comments