feat(web): redesign team progress experience
This commit is contained in:
1 parent
81b951889f
commit
bb32c26694
7 files changed
+973
-183
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import type {
|
||||
BracketRoundView,
|
||||
SeriesId,
|
||||
CompetitionTeamMemberView,
|
||||
SeriesProjection,
|
||||
TeamTournamentCodeView,
|
||||
} from "@lolympus/contracts";
|
||||
@@ -10,6 +10,19 @@ export interface TeamSeriesGroup {
|
||||
codes: TeamTournamentCodeView[];
|
||||
}
|
||||
|
||||
export type TeamSeriesTone =
|
||||
| "muted"
|
||||
| "ready"
|
||||
| "live"
|
||||
| "completed"
|
||||
| "adjudicated";
|
||||
|
||||
export interface TeamSeriesPresentation {
|
||||
label: string;
|
||||
tone: TeamSeriesTone;
|
||||
showScore: boolean;
|
||||
}
|
||||
|
||||
export type TournamentCodeTone =
|
||||
| "pending"
|
||||
| "available"
|
||||
@@ -28,6 +41,12 @@ export type TournamentCodeCopyFeedback =
|
||||
|
||||
type ClipboardWriter = ((value: string) => Promise<void>) | undefined;
|
||||
|
||||
const POSITION_RANK = new Map(
|
||||
(["TOP", "JGL", "MID", "ADC", "SUP"] as const).map(
|
||||
(position, index) => [position, index],
|
||||
),
|
||||
);
|
||||
|
||||
export function createTeamSeriesGroups(
|
||||
activeSeries: readonly SeriesProjection[],
|
||||
tournamentCodes: readonly TeamTournamentCodeView[],
|
||||
@@ -74,6 +93,41 @@ export function getTeamSeriesDisplayLabel(
|
||||
: baseLabel;
|
||||
}
|
||||
|
||||
export function getTeamSeriesPresentation(
|
||||
series: SeriesProjection,
|
||||
): TeamSeriesPresentation {
|
||||
switch (series.status) {
|
||||
case "inactive":
|
||||
return { label: "비활성", tone: "muted", showScore: false };
|
||||
case "waiting":
|
||||
return { label: "대진 대기", tone: "muted", showScore: false };
|
||||
case "ready":
|
||||
return { label: "경기 가능", tone: "ready", showScore: false };
|
||||
case "in-progress":
|
||||
return { label: "진행 중", tone: "live", showScore: true };
|
||||
case "completed":
|
||||
switch (series.outcome.type) {
|
||||
case "played":
|
||||
return { label: "종료", tone: "completed", showScore: true };
|
||||
case "draw":
|
||||
return {
|
||||
label: "무승부",
|
||||
tone:
|
||||
series.outcome.basis.type === "played"
|
||||
? "completed"
|
||||
: "adjudicated",
|
||||
showScore: series.outcome.basis.type === "played",
|
||||
};
|
||||
case "walkover":
|
||||
return { label: "부전승", tone: "adjudicated", showScore: false };
|
||||
case "forfeit":
|
||||
return { label: "기권승", tone: "adjudicated", showScore: false };
|
||||
case "administrative":
|
||||
return { label: "판정승", tone: "adjudicated", showScore: false };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getTournamentCodePresentation(
|
||||
assignment: TeamTournamentCodeView,
|
||||
now = Date.now(),
|
||||
@@ -84,12 +138,58 @@ export function getTournamentCodePresentation(
|
||||
if (assignment.state === "pending" || !assignment.code) {
|
||||
return { label: "발급 대기", tone: "pending", canCopy: false };
|
||||
}
|
||||
if (
|
||||
assignment.expiresAt &&
|
||||
!Number.isFinite(Date.parse(assignment.expiresAt))
|
||||
) {
|
||||
return { label: "만료 정보 오류", tone: "expired", canCopy: false };
|
||||
}
|
||||
if (isExpired(assignment.expiresAt, now)) {
|
||||
return { label: "만료", tone: "expired", canCopy: false };
|
||||
}
|
||||
return { label: "사용 가능", tone: "available", canCopy: true };
|
||||
}
|
||||
|
||||
export function getTournamentCodeExpiryLabel(
|
||||
expiresAt: string,
|
||||
now: number,
|
||||
): string {
|
||||
const date = new Date(expiresAt);
|
||||
if (Number.isNaN(date.getTime())) return "만료 시각 정보 없음";
|
||||
|
||||
const formatted = new Intl.DateTimeFormat("ko-KR", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
timeZone: "Asia/Seoul",
|
||||
timeZoneName: "short",
|
||||
}).format(date);
|
||||
return date.getTime() <= now
|
||||
? `${formatted}에 만료됨`
|
||||
: `${formatted}까지 사용 가능`;
|
||||
}
|
||||
|
||||
export function getNextTournamentCodeExpiryDelay(
|
||||
assignments: readonly TeamTournamentCodeView[],
|
||||
now: number,
|
||||
): number | null {
|
||||
let nearestExpiry = Number.POSITIVE_INFINITY;
|
||||
for (const assignment of assignments) {
|
||||
if (assignment.state !== "reserved" || !assignment.code) continue;
|
||||
const expiry = assignment.expiresAt
|
||||
? Date.parse(assignment.expiresAt)
|
||||
: Number.NaN;
|
||||
if (Number.isFinite(expiry) && expiry > now) {
|
||||
nearestExpiry = Math.min(nearestExpiry, expiry);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Number.isFinite(nearestExpiry)) return null;
|
||||
return Math.min(nearestExpiry - now, 2_147_483_647);
|
||||
}
|
||||
|
||||
export function getTournamentCodeCopyLabel(
|
||||
assignment: TeamTournamentCodeView,
|
||||
seriesLabel: string,
|
||||
@@ -129,6 +229,21 @@ export function sortCompletedTeamSeries(
|
||||
);
|
||||
}
|
||||
|
||||
export function sortTeamMembersForRoster(
|
||||
members: readonly CompetitionTeamMemberView[],
|
||||
): CompetitionTeamMemberView[] {
|
||||
return [...members].sort(
|
||||
(left, right) =>
|
||||
(left.assignedPosition
|
||||
? (POSITION_RANK.get(left.assignedPosition) ?? POSITION_RANK.size)
|
||||
: POSITION_RANK.size) -
|
||||
(right.assignedPosition
|
||||
? (POSITION_RANK.get(right.assignedPosition) ?? POSITION_RANK.size)
|
||||
: POSITION_RANK.size) ||
|
||||
left.displayName.localeCompare(right.displayName, "ko"),
|
||||
);
|
||||
}
|
||||
|
||||
function compareSeriesDisplayOrder(
|
||||
left: SeriesProjection,
|
||||
right: SeriesProjection,
|
||||
|
||||
Reference in new issue
Block a user