fix(web): consolidate player search in stats page

This commit is contained in:
dahyeon committed 2026-11-11 02:10:37 +09:00
1 parent f6686bbf17
commit cc358697d4
6 files changed
+66 -49

No files matched your search

+2 -42
View File
@@ -6,11 +6,10 @@ import {
Route,
Routes,
useLocation,
useNavigate,
} from "react-router";
import { useState, type FormEvent, type ReactNode } from "react";
import type { ReactNode } from "react";
import { useMsal } from "@azure/msal-react";
import { LogOut, Moon, Search, Sun } from "lucide-react";
import { LogOut, Moon, Sun } from "lucide-react";
import DevAuthSwitcher from "./components/DevAuthSwitcher";
import { DEFAULT_COMMUNITY_ID, setTheme, useTheme } from "./config";
import { useCommunity, useMatch, useMe } from "./api/hooks";
@@ -123,44 +122,6 @@ function PrimaryNavLink({
);
}
/** 선수 이름으로 전적 순위표를 바로 찾는 머리글 검색. */
function HeaderPlayerSearch() {
const navigate = useNavigate();
const [value, setValue] = useState("");
function handleSubmit(event: FormEvent<HTMLFormElement>) {
event.preventDefault();
const query = value.trim();
if (!query) return;
const params = new URLSearchParams({ view: "ranking", q: query });
void navigate(
`/communities/${DEFAULT_COMMUNITY_ID}/internal-stats?${params.toString()}`,
);
setValue("");
}
return (
<form
role="search"
onSubmit={handleSubmit}
className="relative hidden w-56 min-w-0 md:block lg:w-72"
>
<Search
className="pointer-events-none absolute left-3.5 top-1/2 size-[18px] -translate-y-1/2 text-content-subtle"
aria-hidden="true"
/>
<input
type="search"
value={value}
onChange={(event) => setValue(event.target.value)}
placeholder="선수 이름 검색"
aria-label="선수 이름으로 전적 검색"
className="h-11 w-full rounded-full border border-line-strong bg-sunken pr-4 pl-10 text-[15px] text-content placeholder:text-content-muted focus-visible:bg-card focus-visible:placeholder:text-content-subtle"
/>
</form>
);
}
function AppHeader() {
const { pathname } = useLocation();
const matchId = matchPath("/match/:id/*", pathname)?.params.id;
@@ -192,7 +153,6 @@ function AppHeader() {
</span>
</Link>
<div className="contents sm:col-start-3 sm:row-start-1 sm:flex sm:min-w-0 sm:items-center sm:justify-end sm:gap-1 lg:gap-2">
{DEFAULT_COMMUNITY_ID && <HeaderPlayerSearch />}
<div className="col-start-1 row-start-1 justify-self-start sm:shrink-0">
<ThemeToggle />
</div>