Merge pull request 'fix(web): satisfy React hook lint rules' (#5) from release/87 into main

Reviewed-on: #5
This commit was merged in pull request #5.
This commit is contained in:
dahyeon committed 2026-07-25 06:40:40 +00:00
commit ac0d2b53f0
8 files changed
+374 -256

No files matched your search

+17 -7
View File
@@ -1,20 +1,30 @@
import { useEffect, useState } from 'react';
import { useState } from 'react';
import { useQueryClient } from '@tanstack/react-query';
import { setAuthUserId, useAuthUserId } from '../config';
export default function DevAuthSwitcher() {
const authUserId = useAuthUserId();
const queryClient = useQueryClient();
const [inputValue, setInputValue] = useState(authUserId ?? '');
useEffect(() => {
setInputValue(authUserId ?? '');
}, [authUserId]);
if (!import.meta.env.DEV) {
return null;
}
return (
<DevAuthSwitcherForm
key={authUserId ?? 'no-auth-user'}
authUserId={authUserId}
/>
);
}
function DevAuthSwitcherForm({
authUserId,
}: {
authUserId: string | null;
}) {
const queryClient = useQueryClient();
const [inputValue, setInputValue] = useState(authUserId ?? '');
function updateAuthUserId(nextValue: string | null) {
setAuthUserId(nextValue);
void queryClient.invalidateQueries();
+1 -44
View File
@@ -1,21 +1,9 @@
import type { ApiTierInfo } from "../api/types";
import { formatRankBadge, formatRankDetail } from "./rankBadgeUtils";
type RankBadgeSize = "sm" | "md";
type RankBadgeTooltipPlacement = "left" | "bottom";
const TIER_NAMES: Record<string, string> = {
IRON: "아이언",
BRONZE: "브론즈",
SILVER: "실버",
GOLD: "골드",
PLATINUM: "플래티넘",
EMERALD: "에메랄드",
DIAMOND: "다이아몬드",
MASTER: "마스터",
GRANDMASTER: "그랜드마스터",
CHALLENGER: "챌린저",
};
const SIZE_CLASSES: Record<RankBadgeSize, string> = {
sm: "h-[17px] min-w-[18px]",
md: "h-[18px] min-w-[20px]",
@@ -26,21 +14,6 @@ const TOOLTIP_CLASSES: Record<RankBadgeTooltipPlacement, string> = {
bottom: "tooltip-bottom",
};
function normalizeRank(rank: string | undefined) {
switch (rank) {
case "I":
return "1";
case "II":
return "2";
case "III":
return "3";
case "IV":
return "4";
default:
return rank;
}
}
function rankBadgeClass(tier: ApiTierInfo | undefined) {
switch (tier?.tier) {
case "CHALLENGER":
@@ -68,22 +41,6 @@ function rankBadgeClass(tier: ApiTierInfo | undefined) {
}
}
export function formatRankBadge(tier: ApiTierInfo | undefined) {
if (!tier) return "U";
const tierInitial =
tier.tier === "GRANDMASTER" ? "GM" : tier.tier.slice(0, 1);
const rank = normalizeRank(tier.rank);
return rank ? `${tierInitial}${rank}` : tierInitial;
}
export function formatRankDetail(tier: ApiTierInfo | undefined) {
if (!tier) return "랭크 정보 없음";
const tierName = TIER_NAMES[tier.tier] ?? tier.tier;
const rank = normalizeRank(tier.rank);
const label = rank ? `${tierName} ${rank}` : tierName;
return `${label} - ${tier.leaguePoints} LP`;
}
export function RankBadge({
tier,
size = "md",
+21 -9
View File
@@ -67,6 +67,7 @@ const TIER_COMPACT_NAMES: Record<string, string> = {
};
type PeriodKey = "30" | "90" | "all";
type PeriodFilter = { key: PeriodKey; cutoffTimestamp: number };
type SummaryVariant = "footer" | "inline";
type SummaryDirection = "up" | "down" | "flat";
@@ -314,18 +315,17 @@ export default function TierHistoryChart({
const [queue, setQueue] = useState(
availableQueues[0] ?? "RANKED_SOLO_5x5",
);
const [period, setPeriod] = useState<PeriodKey>("all");
const [periodFilter, setPeriodFilter] = useState<PeriodFilter>({
key: "all",
cutoffTimestamp: 0,
});
const period = periodFilter.key;
const activeQueue = availableQueues.includes(queue)
? queue
: (availableQueues[0] ?? "RANKED_SOLO_5x5");
const points = useMemo<ChartPoint[]>(() => {
const periodDays =
PERIOD_OPTIONS.find((option) => option.key === period)?.days ?? null;
const cutoff =
periodDays === null ? 0 : Date.now() - periodDays * 24 * 60 * 60 * 1000;
return entries
.filter((entry) => entry.queueType === activeQueue)
.map((entry) => ({
@@ -337,9 +337,9 @@ export default function TierHistoryChart({
wins: entry.wins,
losses: entry.losses,
}))
.filter((point) => point.ts >= cutoff)
.filter((point) => point.ts >= periodFilter.cutoffTimestamp)
.sort((left, right) => left.ts - right.ts);
}, [entries, activeQueue, period]);
}, [entries, activeQueue, periodFilter.cutoffTimestamp]);
// 티어 경계(가로 점선) 후보 — 데이터 범위 안에 드는 티어 floor만.
const tierLines = useMemo(() => {
@@ -408,7 +408,19 @@ export default function TierHistoryChart({
<select
className="h-7 border border-base-content/10 bg-base-100 px-2 text-xs text-base-content focus:border-primary/30 focus:outline-none"
value={period}
onChange={(event) => setPeriod(event.target.value as PeriodKey)}
onChange={(event) => {
const nextPeriod = event.target.value as PeriodKey;
const days =
PERIOD_OPTIONS.find((option) => option.key === nextPeriod)
?.days ?? null;
setPeriodFilter({
key: nextPeriod,
cutoffTimestamp:
days === null
? 0
: Date.now() - days * 24 * 60 * 60 * 1000,
});
}}
>
{PERIOD_OPTIONS.map((option) => (
<option key={option.key} value={option.key}>
+45
View File
@@ -0,0 +1,45 @@
import type { ApiTierInfo } from "../api/types";
const TIER_NAMES: Record<string, string> = {
IRON: "아이언",
BRONZE: "브론즈",
SILVER: "실버",
GOLD: "골드",
PLATINUM: "플래티넘",
EMERALD: "에메랄드",
DIAMOND: "다이아몬드",
MASTER: "마스터",
GRANDMASTER: "그랜드마스터",
CHALLENGER: "챌린저",
};
function normalizeRank(rank: string | undefined) {
switch (rank) {
case "I":
return "1";
case "II":
return "2";
case "III":
return "3";
case "IV":
return "4";
default:
return rank;
}
}
export function formatRankBadge(tier: ApiTierInfo | undefined) {
if (!tier) return "U";
const tierInitial =
tier.tier === "GRANDMASTER" ? "GM" : tier.tier.slice(0, 1);
const rank = normalizeRank(tier.rank);
return rank ? `${tierInitial}${rank}` : tierInitial;
}
export function formatRankDetail(tier: ApiTierInfo | undefined) {
if (!tier) return "랭크 정보 없음";
const tierName = TIER_NAMES[tier.tier] ?? tier.tier;
const rank = normalizeRank(tier.rank);
const label = rank ? `${tierName} ${rank}` : tierName;
return `${label} - ${tier.leaguePoints} LP`;
}