Skip to content

Commit f4633aa

Browse files
committed
feat: Enhance game history display with clickable opponent usernames
- Added a link to opponent usernames in the game history, allowing users to navigate to the opponent's profile. - Implemented styling for the link to ensure it is visually distinct and user-friendly.
1 parent 7e4e706 commit f4633aa

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

components/gameHistory.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react';
22
import { useTranslation } from '@/components/useTranslations';
33
import formatTime from '../utils/formatTime';
44
import styles from '../styles/gameHistory.module.css';
5+
import Link from 'next/link';
56

67
export default function GameHistory({ session, onGameClick, targetUserSecret = null, targetUserData = null }) {
78
const { t: text } = useTranslation("common");
@@ -184,9 +185,20 @@ export default function GameHistory({ session, onGameClick, targetUserSecret = n
184185
</span>
185186
</div>
186187
<div className={styles.statItem}>
187-
<span className={styles.statLabel}>{text('opponent')}</span>
188+
<span className={styles.statLabel}>{text('opponent')}</span>
188189
<span className={styles.statValue}>
189-
{game.opponent?.username || text('unknown')}
190+
{game.opponent?.username ? (
191+
<Link
192+
href={`/user?u=${encodeURIComponent(game.opponent.username)}`}
193+
onClick={(e) => e.stopPropagation()}
194+
target="_blank"
195+
style={{ color: 'cyan', textDecoration: 'underline', cursor: 'pointer' }}
196+
>
197+
{game.opponent.username}
198+
</Link>
199+
) : (
200+
text('unknown')
201+
)}
190202
</span>
191203
</div>
192204
<div className={styles.statItem}>

0 commit comments

Comments
 (0)