feat(frontend): add dominant emotion display to UserModal

This commit is contained in:
2026-03-18 19:12:25 +00:00
parent 86926898ce
commit e5414befa7
2 changed files with 13 additions and 0 deletions

View File

@@ -12,6 +12,9 @@ type Props = {
};
export default function UserModal({ open, onClose, userData, username }: Props) {
const dominantEmotionEntry = Object.entries(userData?.avg_emotions ?? {})
.sort((a, b) => b[1] - a[1])[0];
return (
<Dialog open={open} onClose={onClose} style={styles.modalRoot}>
<div style={styles.modalBackdrop} />
@@ -66,6 +69,15 @@ export default function UserModal({ open, onClose, userData, username }: Props)
</div>
</div>
) : null}
{dominantEmotionEntry ? (
<div style={styles.topUserItem}>
<div style={styles.topUserName}>Dominant Avg Emotion</div>
<div style={styles.topUserMeta}>
{dominantEmotionEntry[0].replace("emotion_", "")} ({dominantEmotionEntry[1].toFixed(3)})
</div>
</div>
) : null}
</div>
)}
</DialogPanel>

View File

@@ -40,6 +40,7 @@ type User = {
comment: number;
comment_post_ratio: number;
comment_share: number;
avg_emotions?: Record<string, number>;
vocab?: Vocab | null;
};