Rename mentor matching to similar players

This commit is contained in:
dahyeon committed 2026-07-03 03:18:59 -07:00
1 parent cfbc74d882
commit ce00bc84b5
14 files changed
+529 -388

No files matched your search

+41 -30
View File
@@ -107,7 +107,7 @@
.chart-section,
.champion-section,
.insight-section,
.mentor-section,
.similar-section,
.dashboard-summary {
border: 1px solid var(--border);
border-radius: 8px;
@@ -344,7 +344,7 @@
.chart-section,
.champion-section,
.insight-section,
.mentor-section {
.similar-section {
padding: 24px;
}
@@ -466,28 +466,28 @@
line-height: 1.55;
}
.mentor-message {
.similar-message {
margin-top: 16px;
}
.mentor-table-wrap {
.similar-table-wrap {
margin-top: 18px;
overflow-x: auto;
}
.mentor-table-wrap:focus-visible {
.similar-table-wrap:focus-visible {
outline: 3px solid color-mix(in srgb, var(--accent) 42%, transparent);
outline-offset: 3px;
}
.mentor-table {
.similar-table {
width: 100%;
min-width: 780px;
border-collapse: separate;
border-spacing: 0 10px;
}
.mentor-table th {
.similar-table th {
padding: 0 12px;
color: var(--text-subtle);
font-size: 12px;
@@ -497,7 +497,7 @@
text-transform: uppercase;
}
.mentor-table td {
.similar-table td {
min-width: 0;
padding: 14px 12px;
border-block: 1px solid var(--border);
@@ -505,51 +505,51 @@
vertical-align: top;
}
.mentor-table td:first-child {
.similar-table td:first-child {
border-left: 1px solid var(--border);
border-radius: 8px 0 0 8px;
}
.mentor-table td:last-child {
.similar-table td:last-child {
border-right: 1px solid var(--border);
border-radius: 0 8px 8px 0;
}
.mentor-player,
.mentor-score,
.mentor-metric-groups,
.mentor-metric-group {
.similar-player,
.similar-score,
.similar-metric-groups,
.similar-metric-group {
min-width: 0;
display: grid;
gap: 6px;
}
.mentor-player strong,
.mentor-score strong,
.mentor-chip strong {
.similar-player strong,
.similar-score strong,
.similar-chip strong {
overflow: hidden;
color: var(--text-strong);
text-overflow: ellipsis;
white-space: nowrap;
}
.mentor-player span,
.mentor-score span,
.mentor-chip span,
.mentor-metric-group > span,
.mentor-empty {
.similar-player span,
.similar-score span,
.similar-chip span,
.similar-metric-group > span,
.similar-empty {
color: var(--text-subtle);
font-size: 12px;
font-weight: 700;
line-height: 1.35;
}
.mentor-score strong {
.similar-score strong {
font-size: 22px;
line-height: 1;
}
.mentor-chip-list {
.similar-chip-list {
display: flex;
flex-wrap: wrap;
gap: 6px;
@@ -558,7 +558,7 @@
list-style: none;
}
.mentor-chip {
.similar-chip {
max-width: 100%;
display: inline-flex;
align-items: center;
@@ -569,23 +569,34 @@
padding: 5px 8px;
}
.mentor-chip strong {
.similar-chip strong {
min-width: 0;
}
.mentor-chip span {
.similar-chip span {
flex: 0 0 auto;
white-space: nowrap;
}
.mentor-chip-accent {
.similar-chip-accent {
border-color: color-mix(in srgb, var(--accent) 48%, var(--border));
}
.mentor-chip-muted {
.similar-chip-muted {
background: color-mix(in srgb, var(--surface) 74%, var(--surface-soft));
}
.similar-tier-badge {
justify-self: start;
border: 1px solid color-mix(in srgb, var(--accent) 48%, var(--border));
border-radius: 999px;
padding: 3px 8px;
color: var(--text-strong);
font-size: 11px;
font-weight: 700;
line-height: 1.2;
}
.empty-view {
min-height: calc(100svh - 240px);
display: grid;
@@ -685,7 +696,7 @@
.chart-section,
.champion-section,
.insight-section,
.mentor-section,
.similar-section,
.dashboard-summary {
padding: 18px;
}
+5 -5
View File
@@ -2,8 +2,8 @@ import type {
AnalysisJobStatusDto,
AnalysisRequestAcceptedDto,
AnalysisRequestDto,
MentorMatchesDto,
PlayerAnalysisDto,
SimilarPlayersDto,
} from '@persona-lenz/shared';
export class ApiClientError extends Error {
@@ -99,12 +99,12 @@ export async function getLatestPlayerAnalysis(
);
}
export async function getMentorMatches(
export async function getSimilarPlayers(
puuid: string,
limit = 10,
): Promise<MentorMatchesDto> {
): Promise<SimilarPlayersDto> {
const params = new URLSearchParams({ limit: String(limit) });
return fetchJson<MentorMatchesDto>(
`/api/players/${encodeURIComponent(puuid)}/mentor-matches?${params}`,
return fetchJson<SimilarPlayersDto>(
`/api/players/${encodeURIComponent(puuid)}/similar-players?${params}`,
);
}
+112 -73
View File
@@ -3,13 +3,14 @@ import { Link, useParams } from 'react-router-dom';
import {
METRICS,
type ChampionPoolEntryDto,
type GapMentorMetricDto,
type MentorMatchDto,
type MentorMatchesDto,
type LeadMetricDto,
type MetricId,
type MetricValueDto,
type PlayerAnalysisDto,
type SimilarMentorMetricDto,
type SimilarMetricDto,
type SimilarPlayerDto,
type SimilarPlayersDto,
type TierComparison,
type TierInfoDto,
} from '@persona-lenz/shared';
import {
@@ -23,8 +24,8 @@ import {
} from 'recharts';
import {
getLatestPlayerAnalysis,
getMentorMatches,
getReadableErrorMessage,
getSimilarPlayers,
} from '../api/analysis';
import {
loadChampionCatalog,
@@ -45,19 +46,18 @@ interface RadarMetricDatum {
value: number;
}
const MENTOR_MATCH_LIMIT = 10;
const SIMILAR_PLAYER_LIMIT = 10;
export function DashboardPage() {
const { puuid } = useParams<{ puuid: string }>();
const [analysis, setAnalysis] = useState<PlayerAnalysisDto | null>(null);
const [championCatalog, setChampionCatalog] =
useState<ChampionCatalog | null>(null);
const [mentorMatches, setMentorMatches] =
useState<MentorMatchesDto | null>(null);
const [similarPlayers, setSimilarPlayers] =
useState<SimilarPlayersDto | null>(null);
const [errorMessage, setErrorMessage] = useState<string | null>(null);
const [mentorErrorMessage, setMentorErrorMessage] = useState<string | null>(
null,
);
const [similarPlayersErrorMessage, setSimilarPlayersErrorMessage] =
useState<string | null>(null);
const [isLoading, setIsLoading] = useState(true);
const missingPuuidMessage = puuid ? null : '플레이어 식별자가 없습니다.';
@@ -73,12 +73,12 @@ export function DashboardPage() {
setIsLoading(true);
setAnalysis(null);
setErrorMessage(null);
setMentorErrorMessage(null);
setMentorMatches(null);
setSimilarPlayersErrorMessage(null);
setSimilarPlayers(null);
const mentorMatchesResultPromise = getMentorMatches(
const similarPlayersResultPromise = getSimilarPlayers(
currentPuuid,
MENTOR_MATCH_LIMIT,
SIMILAR_PLAYER_LIMIT,
).then(
(value) => ({ status: 'fulfilled', value }) as const,
(reason: unknown) => ({ status: 'rejected', reason }) as const,
@@ -105,17 +105,17 @@ export function DashboardPage() {
setIsLoading(false);
}
const mentorMatchesResult = await mentorMatchesResultPromise;
const similarPlayersResult = await similarPlayersResultPromise;
if (!isActive) {
return;
}
if (mentorMatchesResult.status === 'fulfilled') {
setMentorMatches(mentorMatchesResult.value);
if (similarPlayersResult.status === 'fulfilled') {
setSimilarPlayers(similarPlayersResult.value);
} else {
setMentorErrorMessage(
getReadableErrorMessage(mentorMatchesResult.reason),
setSimilarPlayersErrorMessage(
getReadableErrorMessage(similarPlayersResult.reason),
);
}
}
@@ -289,10 +289,10 @@ export function DashboardPage() {
)}
</section>
<MentorMatchSection
<SimilarPlayerSection
catalog={championCatalog}
errorMessage={mentorErrorMessage}
mentorMatches={mentorMatches}
errorMessage={similarPlayersErrorMessage}
similarPlayers={similarPlayers}
/>
</article>
);
@@ -380,87 +380,104 @@ function ChampionPoolRow({
);
}
function MentorMatchSection({
function SimilarPlayerSection({
catalog,
errorMessage,
mentorMatches,
similarPlayers,
}: {
catalog: ChampionCatalog | null;
errorMessage: string | null;
mentorMatches: MentorMatchesDto | null;
similarPlayers: SimilarPlayersDto | null;
}) {
const matches = mentorMatches?.matches ?? [];
const matches = similarPlayers?.matches ?? [];
return (
<section className="mentor-section" aria-labelledby="mentor-title">
<section className="similar-section" aria-labelledby="similar-title">
<div className="section-heading">
<div>
<h2 id="mentor-title">유사 상위 티어 비교</h2>
<h2 id="similar-title">나와 비슷한 플레이어</h2>
<p className="section-copy">
당신과 비슷한 상위 티어 그룹은 이런 경향을 보입니다.
플레이스타일 벡터가 가장 가까운 유저들입니다. 티어가 다르다면 어떤
지표에서 차이가 나는지 확인해보세요.
</p>
</div>
<span className="status-pill">
{mentorMatches ? `${matches.length} matches` : 'mentor match'}
{similarPlayers ? `${matches.length} players` : 'similar players'}
</span>
</div>
{errorMessage ? (
<p className="message message-warning mentor-message" role="status">
멘토 비교를 불러오지 못했습니다. {errorMessage}
<p className="message message-warning similar-message" role="status">
비슷한 플레이어 목록을 불러오지 못했습니다. {errorMessage}
</p>
) : null}
{!errorMessage && mentorMatches && matches.length === 0 ? (
{!errorMessage && similarPlayers && matches.length === 0 ? (
<p className="empty-copy">
조건에 맞는 상위 티어 seed 프로필이 아직 없습니다.
비교 가능한 프로필이 아직 충분히 수집되지 않았습니다.
</p>
) : null}
{!errorMessage && !mentorMatches ? (
<p className="empty-copy">멘토 비교 결과를 준비 중입니다.</p>
{!errorMessage && !similarPlayers ? (
<p className="empty-copy">비슷한 플레이어를 찾는 중입니다.</p>
) : null}
{matches.length > 0 ? (
<div
aria-label="유사 상위 티어 비교 테이블"
className="mentor-table-wrap"
aria-label="나와 비슷한 플레이어 테이블"
className="similar-table-wrap"
role="region"
tabIndex={0}
>
<table className="mentor-table">
<table className="similar-table">
<thead>
<tr>
<th scope="col">플레이어</th>
<th scope="col">점수</th>
<th scope="col">유사도</th>
<th scope="col">주요 챔피언</th>
<th scope="col">비교 지표</th>
</tr>
</thead>
<tbody>
{matches.map((match) => (
<tr key={match.mentorDisplayId}>
<tr key={match.displayId}>
<td>
<div className="mentor-player">
<strong>{formatMentorName(match)}</strong>
<div className="similar-player">
<strong>{formatSimilarPlayerName(match)}</strong>
<span>
{formatMentorTier(match)} · {ROLE_LABELS[match.mainRole]} ·{' '}
{formatSimilarPlayerTier(match)} ·{' '}
{ROLE_LABELS[match.mainRole]} ·{' '}
{match.sampleGameCount}게임
</span>
{formatTierComparison(match.tierComparison) ? (
<span className="similar-tier-badge">
{formatTierComparison(match.tierComparison)}
</span>
) : null}
</div>
</td>
<td>
<div className="mentor-score">
<strong>{formatPercent(match.finalScore)}</strong>
<span>스타일 {formatPercent(match.similarityScore)}</span>
<div className="similar-score">
<strong>{formatPercent(match.similarityScore)}</strong>
<span>종합 {formatPercent(match.finalScore)}</span>
</div>
</td>
<td>
<MentorChampionList catalog={catalog} match={match} />
<SimilarPlayerChampionList catalog={catalog} match={match} />
</td>
<td>
<div className="mentor-metric-groups">
<GapMetricChips values={match.gapMetrics} />
<div className="similar-metric-groups">
<LeadMetricChips
accent
emptyLabel="이 유저가 앞서는 지표 없음"
title="이 유저가 앞서는 지표"
values={match.strongerMetrics}
/>
<LeadMetricChips
emptyLabel={null}
title="내가 앞서는 지표"
values={match.weakerMetrics}
/>
<SimilarMetricChips values={match.similarMetrics} />
</div>
</td>
@@ -474,21 +491,21 @@ function MentorMatchSection({
);
}
function MentorChampionList({
function SimilarPlayerChampionList({
catalog,
match,
}: {
catalog: ChampionCatalog | null;
match: MentorMatchDto;
match: SimilarPlayerDto;
}) {
if (match.mainChampions.length === 0) {
return <span className="mentor-empty">챔피언 기록 없음</span>;
return <span className="similar-empty">챔피언 기록 없음</span>;
}
return (
<ul className="mentor-chip-list">
<ul className="similar-chip-list">
{match.mainChampions.map((entry) => (
<li className="mentor-chip" key={entry.championId}>
<li className="similar-chip" key={entry.championId}>
<strong>{formatChampionName(catalog, entry.championId)}</strong>
<span>{entry.games}게임</span>
</li>
@@ -497,19 +514,34 @@ function MentorChampionList({
);
}
function GapMetricChips({ values }: { values: GapMentorMetricDto[] }) {
function LeadMetricChips({
accent = false,
emptyLabel,
title,
values,
}: {
accent?: boolean;
emptyLabel: string | null;
title: string;
values: LeadMetricDto[];
}) {
if (values.length === 0) {
return <span className="mentor-empty">뚜렷한 우위 지표 없음</span>;
return emptyLabel ? (
<span className="similar-empty">{emptyLabel}</span>
) : null;
}
return (
<div className="mentor-metric-group">
<span>앞서는 지표</span>
<ul className="mentor-chip-list">
<div className="similar-metric-group">
<span>{title}</span>
<ul className="similar-chip-list">
{values.map((value) => (
<li className="mentor-chip mentor-chip-accent" key={value.metricId}>
<li
className={`similar-chip ${accent ? 'similar-chip-accent' : ''}`}
key={value.metricId}
>
<strong>{getMetricLabel(value.metricId)}</strong>
<span>+{formatPercent(value.mentorAdvantage)}</span>
<span>+{formatPercent(value.lead)}</span>
</li>
))}
</ul>
@@ -517,17 +549,17 @@ function GapMetricChips({ values }: { values: GapMentorMetricDto[] }) {
);
}
function SimilarMetricChips({ values }: { values: SimilarMentorMetricDto[] }) {
function SimilarMetricChips({ values }: { values: SimilarMetricDto[] }) {
if (values.length === 0) {
return null;
}
return (
<div className="mentor-metric-group">
<div className="similar-metric-group">
<span>비슷한 지표</span>
<ul className="mentor-chip-list">
<ul className="similar-chip-list">
{values.map((value) => (
<li className="mentor-chip mentor-chip-muted" key={value.metricId}>
<li className="similar-chip similar-chip-muted" key={value.metricId}>
<strong>{getMetricLabel(value.metricId)}</strong>
<span>차이 {formatPercent(value.absoluteGap)}</span>
</li>
@@ -537,21 +569,28 @@ function SimilarMetricChips({ values }: { values: SimilarMentorMetricDto[] }) {
);
}
function formatMentorName(match: MentorMatchDto): string {
function formatSimilarPlayerName(match: SimilarPlayerDto): string {
if (match.riotId) {
return `${match.riotId.gameName}#${match.riotId.tagLine}`;
}
return formatMentorDisplayId(match.mentorDisplayId);
return formatSimilarPlayerDisplayId(match.displayId);
}
function formatMentorDisplayId(mentorDisplayId: string): string {
const numericSuffix = mentorDisplayId.match(/^mentor-(\d+)$/)?.[1];
function formatSimilarPlayerDisplayId(displayId: string): string {
const numericSuffix = displayId.match(/^similar-(\d+)$/)?.[1];
return numericSuffix ? `상위 티어 멘토 #${numericSuffix}` : '상위 티어 멘토';
return numericSuffix ? `비슷한 플레이어 #${numericSuffix}` : '비슷한 플레이어';
}
function formatMentorTier(match: MentorMatchDto): string {
function formatTierComparison(tierComparison: TierComparison): string | null {
if (tierComparison === 'higher') return '나보다 높은 티어';
if (tierComparison === 'lower') return '나보다 낮은 티어';
if (tierComparison === 'same') return '같은 티어';
return null;
}
function formatSimilarPlayerTier(match: SimilarPlayerDto): string {
const tier = [match.tier, match.division].filter(Boolean).join(' ');
if (!tier) {