.
This commit is contained in:
1 parent
905bbcc6dd
commit
2472f865ad
14 files changed
+825
-18
No files matched your search
@@ -5,11 +5,14 @@ import type {
|
||||
ApiAuction,
|
||||
ApiCommunity,
|
||||
ApiMatch,
|
||||
DdragonManifest,
|
||||
MatchStatus,
|
||||
MatchesResponse,
|
||||
MeResponse,
|
||||
} from './types';
|
||||
|
||||
const DDRAGON_MANIFEST_STALE_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
interface MatchesQueryOptions {
|
||||
status?: MatchStatus;
|
||||
limit?: number;
|
||||
@@ -74,6 +77,20 @@ export function useAuction(
|
||||
});
|
||||
}
|
||||
|
||||
export function useDdragonManifest(locale = 'ko_KR') {
|
||||
return useQuery({
|
||||
queryKey: ['ddragon-manifest', locale],
|
||||
queryFn: () =>
|
||||
apiFetch<DdragonManifest>(
|
||||
`/riot/ddragon/manifest?locale=${encodeURIComponent(locale)}`,
|
||||
),
|
||||
staleTime: DDRAGON_MANIFEST_STALE_MS,
|
||||
gcTime: DDRAGON_MANIFEST_STALE_MS,
|
||||
refetchOnMount: false,
|
||||
refetchOnReconnect: false,
|
||||
});
|
||||
}
|
||||
|
||||
export function useMe() {
|
||||
const authUserId = useAuthUserId();
|
||||
|
||||
|
||||
@@ -220,3 +220,11 @@ export interface MeResponse {
|
||||
export interface MatchesResponse {
|
||||
matches: ApiMatch[];
|
||||
}
|
||||
|
||||
export interface DdragonManifest {
|
||||
version: string;
|
||||
cdn: string;
|
||||
locale: string;
|
||||
champions: Record<string, string>;
|
||||
fetchedAt: string;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { Link, useParams } from 'react-router';
|
||||
import { useAuction, useMatch, useMe } from '../api/hooks';
|
||||
import { useAuction, useDdragonManifest, useMatch, useMe } from '../api/hooks';
|
||||
import {
|
||||
formatTierLabel,
|
||||
getTierColorToken,
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
useDevCaptainSide,
|
||||
} from '../config';
|
||||
import { ApiError } from '../lib/api';
|
||||
import { championIconUrl, profileIconUrl } from '../lib/ddragon';
|
||||
import { positionIcon, positionLabel } from '../lib/league';
|
||||
import type { Position } from '../api/types';
|
||||
|
||||
@@ -53,6 +54,7 @@ function TeamPanel({
|
||||
isActive: boolean;
|
||||
isLeft: boolean;
|
||||
}) {
|
||||
const { data: ddragon } = useDdragonManifest();
|
||||
const borderColor =
|
||||
team.side === 'blue' ? 'border-blue-500/25' : 'border-red-500/25';
|
||||
const accentBar = team.side === 'blue' ? 'bg-blue-500' : 'bg-red-500';
|
||||
@@ -92,7 +94,7 @@ function TeamPanel({
|
||||
<div key={`${member.userId}-${member.assignedPosition}`} className="px-3 py-1.5 flex items-center gap-2">
|
||||
<div className="w-6 h-6 bg-base-content/10 overflow-hidden shrink-0">
|
||||
<img
|
||||
src={`https://ddragon.leagueoflegends.com/cdn/16.7.1/img/profileicon/${member.profileIconId}.png`}
|
||||
src={profileIconUrl(ddragon, member.profileIconId)}
|
||||
alt=""
|
||||
className="w-full h-full object-cover"
|
||||
loading="lazy"
|
||||
@@ -130,6 +132,7 @@ function PlayerSpotlight({
|
||||
}: {
|
||||
state: AuctionStateView;
|
||||
}) {
|
||||
const { data: ddragon } = useDdragonManifest();
|
||||
const player = state.currentPlayer;
|
||||
if (!player) return null;
|
||||
|
||||
@@ -151,7 +154,7 @@ function PlayerSpotlight({
|
||||
<div className="flex items-start gap-4">
|
||||
<div className="w-16 h-16 bg-base-content/10 overflow-hidden shrink-0">
|
||||
<img
|
||||
src={`https://ddragon.leagueoflegends.com/cdn/16.7.1/img/profileicon/${player.profileIconId}.png`}
|
||||
src={profileIconUrl(ddragon, player.profileIconId)}
|
||||
alt=""
|
||||
className="w-full h-full object-cover"
|
||||
/>
|
||||
@@ -190,15 +193,19 @@ function PlayerSpotlight({
|
||||
</h4>
|
||||
<div className="space-y-2">
|
||||
{player.masteries.length > 0 ? (
|
||||
player.masteries.map((mastery) => (
|
||||
player.masteries.map((mastery) => {
|
||||
const iconUrl = championIconUrl(ddragon, mastery.championId);
|
||||
return (
|
||||
<div key={mastery.championId} className="flex items-center gap-2">
|
||||
<div className="w-7 h-7 bg-base-content/10 overflow-hidden shrink-0">
|
||||
<img
|
||||
src={`https://ddragon.leagueoflegends.com/cdn/16.7.1/img/champion/${mastery.championId}.png`}
|
||||
alt={mastery.championName}
|
||||
className="w-full h-full object-cover"
|
||||
loading="lazy"
|
||||
/>
|
||||
{iconUrl ? (
|
||||
<img
|
||||
src={iconUrl}
|
||||
alt={mastery.championName}
|
||||
className="w-full h-full object-cover"
|
||||
loading="lazy"
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="text-[12px] font-medium text-base-content truncate">
|
||||
@@ -209,7 +216,8 @@ function PlayerSpotlight({
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
);
|
||||
})
|
||||
) : (
|
||||
<div className="text-[11px] text-base-content/25">
|
||||
숙련도 데이터가 없습니다.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { Link, useNavigate, useParams } from 'react-router';
|
||||
import { useAuction, useMatch, useMe } from '../api/hooks';
|
||||
import { useAuction, useDdragonManifest, useMatch, useMe } from '../api/hooks';
|
||||
import {
|
||||
buildDefaultPreferredPositions,
|
||||
formatTierLabel,
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
} from '../api/mappers';
|
||||
import { DEFAULT_COMMUNITY_ID, useAuthUserId } from '../config';
|
||||
import { apiFetch, ApiError } from '../lib/api';
|
||||
import { profileIconUrl } from '../lib/ddragon';
|
||||
import { positionIcon, positionLabel } from '../lib/league';
|
||||
import type { Position } from '../api/types';
|
||||
|
||||
@@ -92,6 +93,7 @@ function ParticipantRow({
|
||||
index: number;
|
||||
assignedPos?: Position;
|
||||
}) {
|
||||
const { data: ddragon } = useDdragonManifest();
|
||||
return (
|
||||
<tr className="border-b border-base-content/5 last:border-b-0 hover:bg-base-content/[0.02] transition-colors">
|
||||
<td className="py-2 px-3 text-center text-[11px] text-base-content/30 w-8">
|
||||
@@ -101,7 +103,7 @@ function ParticipantRow({
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="w-7 h-7 bg-base-content/10 overflow-hidden shrink-0">
|
||||
<img
|
||||
src={`https://ddragon.leagueoflegends.com/cdn/16.7.1/img/profileicon/${participant.profileIconId}.png`}
|
||||
src={profileIconUrl(ddragon, participant.profileIconId)}
|
||||
alt=""
|
||||
className="w-full h-full object-cover"
|
||||
loading="lazy"
|
||||
|
||||
Reference in new issue
Block a user