- 일정·결과·컨퍼런스 순위·프리뷰(폼/시즌전적/맞대결/머니라인) 수집 - 라이브 카드: 스코어·경기시간·득점/카드·선발 라인업(피치 뷰)·교체 현황 - 문자중계: ESPN commentary 규칙 기반 한글 변환 (미지원 템플릿은 팀명만 한글화) - MLS 레코드는 야구와 키 구조가 같아 sync_baseball_schedule/settle 재사용 - AI 예측 데이터 블록에 MLS 전용 컨텍스트 추가 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
22 lines
766 B
TypeScript
22 lines
766 B
TypeScript
import { useSearchParams } from "react-router-dom";
|
|
import type { League } from "./types";
|
|
|
|
// 리그 상태 — URL 쿼리(?league=)가 SSOT. 기본값은 KBO(메인 탭).
|
|
// 링크 공유 시에도 리그가 보존되도록 쿼리 파라미터를 쓴다.
|
|
export const DEFAULT_LEAGUE: League = "kbo";
|
|
|
|
export function useLeague(): [League, (l: League) => void] {
|
|
const [params, setParams] = useSearchParams();
|
|
const raw = params.get("league");
|
|
const league: League =
|
|
raw === "wc" || raw === "kbo" || raw === "mlb" || raw === "mls"
|
|
? raw
|
|
: DEFAULT_LEAGUE;
|
|
const setLeague = (l: League) => {
|
|
const next = new URLSearchParams(params);
|
|
next.set("league", l);
|
|
setParams(next, { replace: false });
|
|
};
|
|
return [league, setLeague];
|
|
}
|