-
-
- {/* Clickable Name */}
+ {/* User Info Section */}
+
+ {/* Clickable Name */}
+
+
-
-
- {localStatus?.isMutual && (
-
-
- Connected
-
- )}
- {!localStatus?.isMutual && localStatus?.isFollowing && (
-
-
- Following
-
- )}
- {!localStatus?.isMutual && localStatus?.isFollower && (
-
-
- Follows you
-
- )}
-
- {user.bio && (
-
{user.bio}
+ {localStatus?.isMutual && (
+
+
+ Connected
+
+ )}
+ {!localStatus?.isMutual && localStatus?.isFollowing && (
+
+
+ Following
+
+ )}
+ {!localStatus?.isMutual && localStatus?.isFollower && (
+
+
+ Follows you
+
)}
+ {user.bio && (
+
{user.bio}
+ )}
+ {/* Mutual Connections */}
+
+
-
- {/* View Profile Button */}
+ {/* Action Buttons - Stack on mobile, inline on desktop */}
+
+ {/* View Profile Button */}
+
+
+ {showMessageButton && localStatus?.isMutual && (
-
- {showMessageButton && localStatus?.isMutual && (
-
- )}
-
- {localStatus?.isFollowing ? (
-
- ) : (
-
- )}
-
+ )}
+
+ {localStatus?.isFollowing ? (
+
+ ) : (
+
+ )}
diff --git a/components/connections/UserProfileModal.tsx b/components/connections/UserProfileModal.tsx
index 7319f374..05210230 100644
--- a/components/connections/UserProfileModal.tsx
+++ b/components/connections/UserProfileModal.tsx
@@ -29,6 +29,7 @@ import { connectionService } from '@/lib/services/connectionService'
import { conversationService } from '@/lib/services/conversationService'
import { useRouter } from 'next/navigation'
import Link from 'next/link'
+import { MutualConnections } from './MutualConnections'
interface UserProfileModalProps {
userId: string
@@ -214,6 +215,9 @@ export function UserProfileModal({
)}
+ {/* Mutual Connections */}
+
+
{/* Action Buttons */}
{connectionStatus.isMutual && (
diff --git a/lib/services/connectionService.ts b/lib/services/connectionService.ts
index 75b0a262..5b152269 100644
--- a/lib/services/connectionService.ts
+++ b/lib/services/connectionService.ts
@@ -179,6 +179,61 @@ export class ConnectionService {
return { isFollowing, isFollower, isMutual }
}
+
+ // Get mutual connections between current user and another user
+ async getMutualConnections(userId: string): Promise<{
+ count: number
+ users: Array<{
+ id: string
+ first_name: string | null
+ last_name: string | null
+ username: string
+ avatar_url: string | null
+ }>
+ }> {
+ const supabase = this.getSupabaseClient()
+ const { data: { user } } = await supabase.auth.getUser()
+
+ if (!user) {
+ return { count: 0, users: [] }
+ }
+
+ // Get users that both current user and target user follow
+ const { data: currentUserFollowing } = await supabase
+ .from('user_connections')
+ .select('following_id')
+ .eq('follower_id', user.id)
+
+ const { data: targetUserFollowing } = await supabase
+ .from('user_connections')
+ .select('following_id')
+ .eq('follower_id', userId)
+
+ if (!currentUserFollowing || !targetUserFollowing) {
+ return { count: 0, users: [] }
+ }
+
+ // Find mutual following
+ const currentFollowingIds = new Set(currentUserFollowing.map(c => c.following_id))
+ const mutualIds = targetUserFollowing
+ .map(c => c.following_id)
+ .filter(id => currentFollowingIds.has(id) && id !== user.id && id !== userId)
+
+ if (mutualIds.length === 0) {
+ return { count: 0, users: [] }
+ }
+
+ // Get profile info for first 3 mutual connections
+ const { data: profiles } = await supabase
+ .from('profiles')
+ .select('id, first_name, last_name, username, avatar_url')
+ .in('id', mutualIds.slice(0, 3))
+
+ return {
+ count: mutualIds.length,
+ users: profiles || []
+ }
+ }
}
export const connectionService = new ConnectionService()