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:
commit
ac0d2b53f0
8 files changed
+374
-256
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { io, type Socket } from 'socket.io-client';
|
import { io, type Socket } from 'socket.io-client';
|
||||||
import { API_BASE_URL, useAuthUserId } from '../config';
|
import { API_BASE_URL, useAuthUserId } from '../config';
|
||||||
import { acquireAccessToken } from '../lib/auth/token-provider';
|
import { acquireAccessToken } from '../lib/auth/token-provider';
|
||||||
@@ -140,6 +140,9 @@ function mergeChatMessages(
|
|||||||
|
|
||||||
export function useAuctionSocket(matchId: string | undefined) {
|
export function useAuctionSocket(matchId: string | undefined) {
|
||||||
const authUserId = useAuthUserId();
|
const authUserId = useAuthUserId();
|
||||||
|
const connectionKey = matchId
|
||||||
|
? JSON.stringify([matchId, authUserId ?? null])
|
||||||
|
: null;
|
||||||
const socketRef = useRef<Socket | null>(null);
|
const socketRef = useRef<Socket | null>(null);
|
||||||
const pendingBidTimeoutsRef = useRef<
|
const pendingBidTimeoutsRef = useRef<
|
||||||
Record<string, ReturnType<typeof setTimeout>>
|
Record<string, ReturnType<typeof setTimeout>>
|
||||||
@@ -166,9 +169,14 @@ export function useAuctionSocket(matchId: string | undefined) {
|
|||||||
Record<string, { action: string }>
|
Record<string, { action: string }>
|
||||||
>({});
|
>({});
|
||||||
const [resetAt, setResetAt] = useState<number | null>(null);
|
const [resetAt, setResetAt] = useState<number | null>(null);
|
||||||
const [connectionStatus, setConnectionStatus] =
|
const [connectionState, setConnectionState] = useState<{
|
||||||
useState<ConnectionStatus>('idle');
|
key: string;
|
||||||
const [error, setError] = useState<string | null>(null);
|
status: ConnectionStatus;
|
||||||
|
}>({ key: '', status: 'idle' });
|
||||||
|
const [errorState, setErrorState] = useState<{
|
||||||
|
key: string;
|
||||||
|
message: string | null;
|
||||||
|
}>({ key: '', message: null });
|
||||||
const [serverTimeOffsetMs, setServerTimeOffsetMs] = useState(0);
|
const [serverTimeOffsetMs, setServerTimeOffsetMs] = useState(0);
|
||||||
const [serverRoundTripMs, setServerRoundTripMs] = useState<number | null>(
|
const [serverRoundTripMs, setServerRoundTripMs] = useState<number | null>(
|
||||||
null,
|
null,
|
||||||
@@ -176,53 +184,50 @@ export function useAuctionSocket(matchId: string | undefined) {
|
|||||||
const [bidLatencyDiagnostics, setBidLatencyDiagnostics] =
|
const [bidLatencyDiagnostics, setBidLatencyDiagnostics] =
|
||||||
useState<BidLatencyDiagnostics | null>(null);
|
useState<BidLatencyDiagnostics | null>(null);
|
||||||
|
|
||||||
function syncLatestConfirmedBidPointAmountFromAuction(
|
const commitAuctionState = useCallback(
|
||||||
nextAuction: ApiAuction,
|
(nextAuction: ApiAuction, source = 'socket-state'): boolean => {
|
||||||
) {
|
const currentAuction = latestAuctionRef.current;
|
||||||
latestConfirmedBidPointAmountRef.current =
|
const applied = shouldApplyIncomingAuctionState(
|
||||||
resolveCurrentBidPointAmount(nextAuction);
|
currentAuction,
|
||||||
}
|
nextAuction,
|
||||||
|
);
|
||||||
|
const currentRevision =
|
||||||
|
typeof currentAuction?.revision === 'number'
|
||||||
|
? currentAuction.revision
|
||||||
|
: -1;
|
||||||
|
const incomingRevision =
|
||||||
|
typeof nextAuction?.revision === 'number' ? nextAuction.revision : -1;
|
||||||
|
// 단조성을 깨고 적용되는 경우(=revision이 같거나 뒤로 가는데도 반영됨).
|
||||||
|
// force-resync/lifecycle 교체로만 발생하며, "2~3 버전 롤백"의 직접 증거가 된다.
|
||||||
|
const isBackwardApply =
|
||||||
|
applied &&
|
||||||
|
currentRevision >= 0 &&
|
||||||
|
incomingRevision >= 0 &&
|
||||||
|
incomingRevision <= currentRevision;
|
||||||
|
addNewRelicPageAction('AuctionClientStateApply', {
|
||||||
|
matchId: matchId ?? 'none',
|
||||||
|
source,
|
||||||
|
applied,
|
||||||
|
isBackwardApply,
|
||||||
|
revisionDelta: incomingRevision - currentRevision,
|
||||||
|
...describeAuctionForTelemetry('current', currentAuction),
|
||||||
|
...describeAuctionForTelemetry('incoming', nextAuction),
|
||||||
|
});
|
||||||
|
|
||||||
function commitAuctionState(
|
if (!applied) {
|
||||||
nextAuction: ApiAuction,
|
return false;
|
||||||
source = 'socket-state',
|
}
|
||||||
): boolean {
|
|
||||||
const currentAuction = latestAuctionRef.current;
|
|
||||||
const applied = shouldApplyIncomingAuctionState(currentAuction, nextAuction);
|
|
||||||
const currentRevision =
|
|
||||||
typeof currentAuction?.revision === 'number'
|
|
||||||
? currentAuction.revision
|
|
||||||
: -1;
|
|
||||||
const incomingRevision =
|
|
||||||
typeof nextAuction?.revision === 'number' ? nextAuction.revision : -1;
|
|
||||||
// 단조성을 깨고 적용되는 경우(=revision이 같거나 뒤로 가는데도 반영됨).
|
|
||||||
// force-resync/lifecycle 교체로만 발생하며, "2~3 버전 롤백"의 직접 증거가 된다.
|
|
||||||
const isBackwardApply =
|
|
||||||
applied &&
|
|
||||||
currentRevision >= 0 &&
|
|
||||||
incomingRevision >= 0 &&
|
|
||||||
incomingRevision <= currentRevision;
|
|
||||||
addNewRelicPageAction('AuctionClientStateApply', {
|
|
||||||
matchId: matchId ?? 'none',
|
|
||||||
source,
|
|
||||||
applied,
|
|
||||||
isBackwardApply,
|
|
||||||
revisionDelta: incomingRevision - currentRevision,
|
|
||||||
...describeAuctionForTelemetry('current', currentAuction),
|
|
||||||
...describeAuctionForTelemetry('incoming', nextAuction),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!applied) {
|
latestAuctionRef.current = nextAuction;
|
||||||
return false;
|
latestConfirmedBidPointAmountRef.current =
|
||||||
}
|
resolveCurrentBidPointAmount(nextAuction);
|
||||||
|
setAuction(nextAuction);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
[matchId],
|
||||||
|
);
|
||||||
|
|
||||||
latestAuctionRef.current = nextAuction;
|
const commitBidDelta = useCallback((payload: BidDeltaPayload): boolean => {
|
||||||
syncLatestConfirmedBidPointAmountFromAuction(nextAuction);
|
|
||||||
setAuction(nextAuction);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function commitBidDelta(payload: BidDeltaPayload): boolean {
|
|
||||||
const currentAuction = latestAuctionRef.current;
|
const currentAuction = latestAuctionRef.current;
|
||||||
const nextAuction = applyBidDelta(currentAuction, payload);
|
const nextAuction = applyBidDelta(currentAuction, payload);
|
||||||
if (!nextAuction || nextAuction === currentAuction) {
|
if (!nextAuction || nextAuction === currentAuction) {
|
||||||
@@ -230,10 +235,18 @@ export function useAuctionSocket(matchId: string | undefined) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
latestAuctionRef.current = nextAuction;
|
latestAuctionRef.current = nextAuction;
|
||||||
syncLatestConfirmedBidPointAmountFromAuction(nextAuction);
|
latestConfirmedBidPointAmountRef.current =
|
||||||
|
resolveCurrentBidPointAmount(nextAuction);
|
||||||
setAuction(nextAuction);
|
setAuction(nextAuction);
|
||||||
return true;
|
return true;
|
||||||
}
|
}, []);
|
||||||
|
|
||||||
|
const setError = useCallback(
|
||||||
|
(message: string | null) => {
|
||||||
|
setErrorState({ key: connectionKey ?? '', message });
|
||||||
|
},
|
||||||
|
[connectionKey],
|
||||||
|
);
|
||||||
|
|
||||||
function applyFallbackServerTimestamp(currentServerTimestampMS?: number) {
|
function applyFallbackServerTimestamp(currentServerTimestampMS?: number) {
|
||||||
if (hasSyncedServerTimeRef.current) return;
|
if (hasSyncedServerTimeRef.current) return;
|
||||||
@@ -345,14 +358,47 @@ export function useAuctionSocket(matchId: string | undefined) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const clearPendingBidRequest = useCallback((bidRequestId: string) => {
|
||||||
|
const timeoutId = pendingBidTimeoutsRef.current[bidRequestId];
|
||||||
|
if (timeoutId) clearTimeout(timeoutId);
|
||||||
|
delete pendingBidTimeoutsRef.current[bidRequestId];
|
||||||
|
setPendingBidRequests((current) => {
|
||||||
|
const next = { ...current };
|
||||||
|
delete next[bidRequestId];
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const clearPendingActionRequest = useCallback(
|
||||||
|
(auctionActionRequestId: string) => {
|
||||||
|
const timeoutId =
|
||||||
|
pendingActionTimeoutsRef.current[auctionActionRequestId];
|
||||||
|
if (timeoutId) clearTimeout(timeoutId);
|
||||||
|
delete pendingActionTimeoutsRef.current[auctionActionRequestId];
|
||||||
|
setPendingActionRequests((current) => {
|
||||||
|
const next = { ...current };
|
||||||
|
delete next[auctionActionRequestId];
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
|
const clearPendingActionRequests = useCallback(() => {
|
||||||
|
Object.values(pendingActionTimeoutsRef.current).forEach((timeoutId) =>
|
||||||
|
clearTimeout(timeoutId),
|
||||||
|
);
|
||||||
|
pendingActionTimeoutsRef.current = {};
|
||||||
|
setPendingActionRequests({});
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!matchId) {
|
if (!matchId || !connectionKey) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const activeConnectionKey = connectionKey;
|
||||||
let disposed = false;
|
let disposed = false;
|
||||||
setConnectionStatus('connecting');
|
|
||||||
setError(null);
|
|
||||||
|
|
||||||
void (async () => {
|
void (async () => {
|
||||||
const accessToken = await acquireAccessToken().catch((error) => {
|
const accessToken = await acquireAccessToken().catch((error) => {
|
||||||
@@ -373,7 +419,11 @@ export function useAuctionSocket(matchId: string | undefined) {
|
|||||||
socketRef.current = socket;
|
socketRef.current = socket;
|
||||||
|
|
||||||
socket.on('connect', () => {
|
socket.on('connect', () => {
|
||||||
setConnectionStatus('connected');
|
setConnectionState({
|
||||||
|
key: activeConnectionKey,
|
||||||
|
status: 'connected',
|
||||||
|
});
|
||||||
|
setError(null);
|
||||||
socket.emit('join', { matchId });
|
socket.emit('join', { matchId });
|
||||||
requestServerTimeSync(socket);
|
requestServerTimeSync(socket);
|
||||||
if (timeSyncIntervalRef.current) {
|
if (timeSyncIntervalRef.current) {
|
||||||
@@ -387,7 +437,10 @@ export function useAuctionSocket(matchId: string | undefined) {
|
|||||||
|
|
||||||
socket.on('disconnect', () => {
|
socket.on('disconnect', () => {
|
||||||
clearTimeSyncTimers();
|
clearTimeSyncTimers();
|
||||||
setConnectionStatus('disconnected');
|
setConnectionState({
|
||||||
|
key: activeConnectionKey,
|
||||||
|
status: 'disconnected',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('state', (nextAuction: ApiAuction) => {
|
socket.on('state', (nextAuction: ApiAuction) => {
|
||||||
@@ -520,42 +573,20 @@ export function useAuctionSocket(matchId: string | undefined) {
|
|||||||
hasSyncedServerTimeRef.current = false;
|
hasSyncedServerTimeRef.current = false;
|
||||||
setPendingBidRequests({});
|
setPendingBidRequests({});
|
||||||
setPendingActionRequests({});
|
setPendingActionRequests({});
|
||||||
setConnectionStatus('idle');
|
|
||||||
setServerTimeOffsetMs(0);
|
setServerTimeOffsetMs(0);
|
||||||
setServerRoundTripMs(null);
|
setServerRoundTripMs(null);
|
||||||
setBidLatencyDiagnostics(null);
|
setBidLatencyDiagnostics(null);
|
||||||
};
|
};
|
||||||
}, [authUserId, matchId]);
|
}, [
|
||||||
|
authUserId,
|
||||||
function clearPendingBidRequest(bidRequestId: string) {
|
clearPendingActionRequests,
|
||||||
const timeoutId = pendingBidTimeoutsRef.current[bidRequestId];
|
clearPendingBidRequest,
|
||||||
if (timeoutId) clearTimeout(timeoutId);
|
commitAuctionState,
|
||||||
delete pendingBidTimeoutsRef.current[bidRequestId];
|
commitBidDelta,
|
||||||
setPendingBidRequests((current) => {
|
connectionKey,
|
||||||
const next = { ...current };
|
matchId,
|
||||||
delete next[bidRequestId];
|
setError,
|
||||||
return next;
|
]);
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearPendingActionRequest(auctionActionRequestId: string) {
|
|
||||||
const timeoutId = pendingActionTimeoutsRef.current[auctionActionRequestId];
|
|
||||||
if (timeoutId) clearTimeout(timeoutId);
|
|
||||||
delete pendingActionTimeoutsRef.current[auctionActionRequestId];
|
|
||||||
setPendingActionRequests((current) => {
|
|
||||||
const next = { ...current };
|
|
||||||
delete next[auctionActionRequestId];
|
|
||||||
return next;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearPendingActionRequests() {
|
|
||||||
Object.values(pendingActionTimeoutsRef.current).forEach((timeoutId) =>
|
|
||||||
clearTimeout(timeoutId),
|
|
||||||
);
|
|
||||||
pendingActionTimeoutsRef.current = {};
|
|
||||||
setPendingActionRequests({});
|
|
||||||
}
|
|
||||||
|
|
||||||
function emit(eventName: string, payload?: unknown) {
|
function emit(eventName: string, payload?: unknown) {
|
||||||
const socket = socketRef.current;
|
const socket = socketRef.current;
|
||||||
@@ -737,9 +768,16 @@ export function useAuctionSocket(matchId: string | undefined) {
|
|||||||
const currentAuction = auction;
|
const currentAuction = auction;
|
||||||
const visibleAuction =
|
const visibleAuction =
|
||||||
currentAuction && currentAuction.matchId === matchId ? currentAuction : null;
|
currentAuction && currentAuction.matchId === matchId ? currentAuction : null;
|
||||||
const visibleConnectionStatus: ConnectionStatus = matchId
|
const visibleConnectionStatus: ConnectionStatus =
|
||||||
? connectionStatus
|
connectionKey === null
|
||||||
: 'idle';
|
? 'idle'
|
||||||
|
: connectionState.key === connectionKey
|
||||||
|
? connectionState.status
|
||||||
|
: 'connecting';
|
||||||
|
const visibleError =
|
||||||
|
connectionKey !== null && errorState.key === connectionKey
|
||||||
|
? errorState.message
|
||||||
|
: null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
auction: visibleAuction,
|
auction: visibleAuction,
|
||||||
@@ -750,7 +788,7 @@ export function useAuctionSocket(matchId: string | undefined) {
|
|||||||
pendingBidRequests,
|
pendingBidRequests,
|
||||||
resetAt,
|
resetAt,
|
||||||
connectionStatus: visibleConnectionStatus,
|
connectionStatus: visibleConnectionStatus,
|
||||||
error,
|
error: visibleError,
|
||||||
bidLatencyDiagnostics,
|
bidLatencyDiagnostics,
|
||||||
serverRoundTripMs: matchId ? serverRoundTripMs : null,
|
serverRoundTripMs: matchId ? serverRoundTripMs : null,
|
||||||
serverTimeOffsetMs: matchId ? serverTimeOffsetMs : 0,
|
serverTimeOffsetMs: matchId ? serverTimeOffsetMs : 0,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useEffect, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import { io, type Socket } from 'socket.io-client';
|
import { io } from 'socket.io-client';
|
||||||
import { API_BASE_URL } from '../config';
|
import { API_BASE_URL } from '../config';
|
||||||
import type { ApiRiotRefreshEvent } from './types';
|
import type { ApiRiotRefreshEvent } from './types';
|
||||||
|
|
||||||
@@ -19,37 +19,43 @@ export function useRiotRefreshSocket({
|
|||||||
parentJobId?: string;
|
parentJobId?: string;
|
||||||
onEvent: (event: ApiRiotRefreshEvent) => void;
|
onEvent: (event: ApiRiotRefreshEvent) => void;
|
||||||
}) {
|
}) {
|
||||||
const socketRef = useRef<Socket | null>(null);
|
const subscriptionKey =
|
||||||
|
puuid || parentJobId ? JSON.stringify([puuid, parentJobId]) : null;
|
||||||
const onEventRef = useRef(onEvent);
|
const onEventRef = useRef(onEvent);
|
||||||
const [connectionStatus, setConnectionStatus] =
|
const [connectionState, setConnectionState] = useState<{
|
||||||
useState<ConnectionStatus>('idle');
|
key: string;
|
||||||
const [error, setError] = useState<string | null>(null);
|
status: ConnectionStatus;
|
||||||
|
error: string | null;
|
||||||
|
}>({ key: '', status: 'idle', error: null });
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onEventRef.current = onEvent;
|
onEventRef.current = onEvent;
|
||||||
}, [onEvent]);
|
}, [onEvent]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!puuid && !parentJobId) {
|
if (!subscriptionKey) {
|
||||||
setConnectionStatus('idle');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setConnectionStatus('connecting');
|
|
||||||
setError(null);
|
|
||||||
|
|
||||||
const socket = io(`${API_BASE_URL}/riot-refresh`, {
|
const socket = io(`${API_BASE_URL}/riot-refresh`, {
|
||||||
transports: ['websocket'],
|
transports: ['websocket'],
|
||||||
});
|
});
|
||||||
socketRef.current = socket;
|
|
||||||
|
|
||||||
socket.on('connect', () => {
|
socket.on('connect', () => {
|
||||||
setConnectionStatus('connected');
|
setConnectionState({
|
||||||
|
key: subscriptionKey,
|
||||||
|
status: 'connected',
|
||||||
|
error: null,
|
||||||
|
});
|
||||||
socket.emit('subscribe', { puuid, parentJobId });
|
socket.emit('subscribe', { puuid, parentJobId });
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('disconnect', () => {
|
socket.on('disconnect', () => {
|
||||||
setConnectionStatus('disconnected');
|
setConnectionState((current) => ({
|
||||||
|
key: subscriptionKey,
|
||||||
|
status: 'disconnected',
|
||||||
|
error: current.key === subscriptionKey ? current.error : null,
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('riot-refresh', (event: ApiRiotRefreshEvent) => {
|
socket.on('riot-refresh', (event: ApiRiotRefreshEvent) => {
|
||||||
@@ -57,17 +63,29 @@ export function useRiotRefreshSocket({
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on('error', (payload: { message?: string }) => {
|
socket.on('error', (payload: { message?: string }) => {
|
||||||
setConnectionStatus('error');
|
setConnectionState({
|
||||||
setError(payload.message ?? '전적 갱신 소켓 연결 중 오류가 발생했습니다.');
|
key: subscriptionKey,
|
||||||
|
status: 'error',
|
||||||
|
error:
|
||||||
|
payload.message ?? '전적 갱신 소켓 연결 중 오류가 발생했습니다.',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.removeAllListeners();
|
socket.removeAllListeners();
|
||||||
socket.disconnect();
|
socket.disconnect();
|
||||||
socketRef.current = null;
|
|
||||||
setConnectionStatus('idle');
|
|
||||||
};
|
};
|
||||||
}, [parentJobId, puuid]);
|
}, [parentJobId, puuid, subscriptionKey]);
|
||||||
|
|
||||||
return { connectionStatus, error };
|
const hasCurrentConnection =
|
||||||
|
subscriptionKey !== null && connectionState.key === subscriptionKey;
|
||||||
|
return {
|
||||||
|
connectionStatus:
|
||||||
|
subscriptionKey === null
|
||||||
|
? 'idle'
|
||||||
|
: hasCurrentConnection
|
||||||
|
? connectionState.status
|
||||||
|
: 'connecting',
|
||||||
|
error: hasCurrentConnection ? connectionState.error : null,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
@@ -1,20 +1,30 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useQueryClient } from '@tanstack/react-query';
|
import { useQueryClient } from '@tanstack/react-query';
|
||||||
import { setAuthUserId, useAuthUserId } from '../config';
|
import { setAuthUserId, useAuthUserId } from '../config';
|
||||||
|
|
||||||
export default function DevAuthSwitcher() {
|
export default function DevAuthSwitcher() {
|
||||||
const authUserId = useAuthUserId();
|
const authUserId = useAuthUserId();
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const [inputValue, setInputValue] = useState(authUserId ?? '');
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setInputValue(authUserId ?? '');
|
|
||||||
}, [authUserId]);
|
|
||||||
|
|
||||||
if (!import.meta.env.DEV) {
|
if (!import.meta.env.DEV) {
|
||||||
return null;
|
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) {
|
function updateAuthUserId(nextValue: string | null) {
|
||||||
setAuthUserId(nextValue);
|
setAuthUserId(nextValue);
|
||||||
void queryClient.invalidateQueries();
|
void queryClient.invalidateQueries();
|
||||||
|
|||||||
@@ -1,21 +1,9 @@
|
|||||||
import type { ApiTierInfo } from "../api/types";
|
import type { ApiTierInfo } from "../api/types";
|
||||||
|
import { formatRankBadge, formatRankDetail } from "./rankBadgeUtils";
|
||||||
|
|
||||||
type RankBadgeSize = "sm" | "md";
|
type RankBadgeSize = "sm" | "md";
|
||||||
type RankBadgeTooltipPlacement = "left" | "bottom";
|
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> = {
|
const SIZE_CLASSES: Record<RankBadgeSize, string> = {
|
||||||
sm: "h-[17px] min-w-[18px]",
|
sm: "h-[17px] min-w-[18px]",
|
||||||
md: "h-[18px] min-w-[20px]",
|
md: "h-[18px] min-w-[20px]",
|
||||||
@@ -26,21 +14,6 @@ const TOOLTIP_CLASSES: Record<RankBadgeTooltipPlacement, string> = {
|
|||||||
bottom: "tooltip-bottom",
|
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) {
|
function rankBadgeClass(tier: ApiTierInfo | undefined) {
|
||||||
switch (tier?.tier) {
|
switch (tier?.tier) {
|
||||||
case "CHALLENGER":
|
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({
|
export function RankBadge({
|
||||||
tier,
|
tier,
|
||||||
size = "md",
|
size = "md",
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ const TIER_COMPACT_NAMES: Record<string, string> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type PeriodKey = "30" | "90" | "all";
|
type PeriodKey = "30" | "90" | "all";
|
||||||
|
type PeriodFilter = { key: PeriodKey; cutoffTimestamp: number };
|
||||||
type SummaryVariant = "footer" | "inline";
|
type SummaryVariant = "footer" | "inline";
|
||||||
type SummaryDirection = "up" | "down" | "flat";
|
type SummaryDirection = "up" | "down" | "flat";
|
||||||
|
|
||||||
@@ -314,18 +315,17 @@ export default function TierHistoryChart({
|
|||||||
const [queue, setQueue] = useState(
|
const [queue, setQueue] = useState(
|
||||||
availableQueues[0] ?? "RANKED_SOLO_5x5",
|
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)
|
const activeQueue = availableQueues.includes(queue)
|
||||||
? queue
|
? queue
|
||||||
: (availableQueues[0] ?? "RANKED_SOLO_5x5");
|
: (availableQueues[0] ?? "RANKED_SOLO_5x5");
|
||||||
|
|
||||||
const points = useMemo<ChartPoint[]>(() => {
|
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
|
return entries
|
||||||
.filter((entry) => entry.queueType === activeQueue)
|
.filter((entry) => entry.queueType === activeQueue)
|
||||||
.map((entry) => ({
|
.map((entry) => ({
|
||||||
@@ -337,9 +337,9 @@ export default function TierHistoryChart({
|
|||||||
wins: entry.wins,
|
wins: entry.wins,
|
||||||
losses: entry.losses,
|
losses: entry.losses,
|
||||||
}))
|
}))
|
||||||
.filter((point) => point.ts >= cutoff)
|
.filter((point) => point.ts >= periodFilter.cutoffTimestamp)
|
||||||
.sort((left, right) => left.ts - right.ts);
|
.sort((left, right) => left.ts - right.ts);
|
||||||
}, [entries, activeQueue, period]);
|
}, [entries, activeQueue, periodFilter.cutoffTimestamp]);
|
||||||
|
|
||||||
// 티어 경계(가로 점선) 후보 — 데이터 범위 안에 드는 티어 floor만.
|
// 티어 경계(가로 점선) 후보 — 데이터 범위 안에 드는 티어 floor만.
|
||||||
const tierLines = useMemo(() => {
|
const tierLines = useMemo(() => {
|
||||||
@@ -408,7 +408,19 @@ export default function TierHistoryChart({
|
|||||||
<select
|
<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"
|
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}
|
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) => (
|
{PERIOD_OPTIONS.map((option) => (
|
||||||
<option key={option.key} value={option.key}>
|
<option key={option.key} value={option.key}>
|
||||||
|
|||||||
@@ -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`;
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ import {
|
|||||||
lazy,
|
lazy,
|
||||||
memo,
|
memo,
|
||||||
Suspense,
|
Suspense,
|
||||||
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
useLayoutEffect,
|
useLayoutEffect,
|
||||||
useMemo,
|
useMemo,
|
||||||
@@ -51,7 +52,8 @@ import {
|
|||||||
teamIndexLabel,
|
teamIndexLabel,
|
||||||
} from "../lib/league";
|
} from "../lib/league";
|
||||||
import { internalMatchGamePath } from "../lib/internal-match-routes";
|
import { internalMatchGamePath } from "../lib/internal-match-routes";
|
||||||
import { formatRankDetail, RankBadge } from "../components/RankBadge";
|
import { RankBadge } from "../components/RankBadge";
|
||||||
|
import { formatRankDetail } from "../components/rankBadgeUtils";
|
||||||
import type {
|
import type {
|
||||||
ApiAuction,
|
ApiAuction,
|
||||||
ApiAuctionChatMessage,
|
ApiAuctionChatMessage,
|
||||||
@@ -1616,7 +1618,6 @@ function BidControls({
|
|||||||
serverTimeOffsetMs: number;
|
serverTimeOffsetMs: number;
|
||||||
onBid: (teamIndex: number, amount: number) => void;
|
onBid: (teamIndex: number, amount: number) => void;
|
||||||
}) {
|
}) {
|
||||||
const [bidAmount, setBidAmount] = useState(100);
|
|
||||||
const minBid = state.currentBid + AUCTION_MIN_BID_POINTS;
|
const minBid = state.currentBid + AUCTION_MIN_BID_POINTS;
|
||||||
const activeTeam = captainRole
|
const activeTeam = captainRole
|
||||||
? state.teams.find((team) => team.teamIndex === captainRole.teamIndex)
|
? state.teams.find((team) => team.teamIndex === captainRole.teamIndex)
|
||||||
@@ -1627,6 +1628,23 @@ function BidControls({
|
|||||||
? getReservedPointsAfterCurrentBid(activeTeam)
|
? getReservedPointsAfterCurrentBid(activeTeam)
|
||||||
: 0;
|
: 0;
|
||||||
const maxBid = activeTeam ? getMaxBidForTeam(activeTeam) : 0;
|
const maxBid = activeTeam ? getMaxBidForTeam(activeTeam) : 0;
|
||||||
|
const defaultBidAmount = Math.max(minBid, Math.ceil(minBid / 10) * 10);
|
||||||
|
const bidContextKey = `${activeTeam?.teamIndex ?? "spectator"}:${maxBid}:${minBid}`;
|
||||||
|
const [bidDraft, setBidDraft] = useState({
|
||||||
|
contextKey: bidContextKey,
|
||||||
|
amount: activeTeam
|
||||||
|
? Math.min(maxBid, defaultBidAmount)
|
||||||
|
: defaultBidAmount,
|
||||||
|
});
|
||||||
|
const bidAmount =
|
||||||
|
bidDraft.contextKey === bidContextKey
|
||||||
|
? bidDraft.amount
|
||||||
|
: activeTeam
|
||||||
|
? Math.min(maxBid, defaultBidAmount)
|
||||||
|
: defaultBidAmount;
|
||||||
|
const setBidAmount = (amount: number) => {
|
||||||
|
setBidDraft({ contextKey: bidContextKey, amount });
|
||||||
|
};
|
||||||
const canAffordNextBid = !isActiveTeamFull && maxBid >= minBid;
|
const canAffordNextBid = !isActiveTeamFull && maxBid >= minBid;
|
||||||
const isBidExpired = useIsDeadlineExpired(
|
const isBidExpired = useIsDeadlineExpired(
|
||||||
state.deadline,
|
state.deadline,
|
||||||
@@ -1637,11 +1655,6 @@ function BidControls({
|
|||||||
? Math.min(maxBid, Math.max(minBid, bidAmount))
|
? Math.min(maxBid, Math.max(minBid, bidAmount))
|
||||||
: Math.max(minBid, bidAmount);
|
: Math.max(minBid, bidAmount);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const nextBid = Math.max(minBid, Math.ceil(minBid / 10) * 10);
|
|
||||||
setBidAmount(activeTeam ? Math.min(maxBid, nextBid) : nextBid);
|
|
||||||
}, [activeTeam, maxBid, minBid]);
|
|
||||||
|
|
||||||
if (state.phase !== "bidding") return null;
|
if (state.phase !== "bidding") return null;
|
||||||
|
|
||||||
if (!activeTeam) {
|
if (!activeTeam) {
|
||||||
@@ -1843,7 +1856,10 @@ export default function AuctionPage() {
|
|||||||
const resetAuctionMutation = useResetAuction(DEFAULT_COMMUNITY_ID);
|
const resetAuctionMutation = useResetAuction(DEFAULT_COMMUNITY_ID);
|
||||||
const socket = useAuctionSocket(id);
|
const socket = useAuctionSocket(id);
|
||||||
const captainTeamIndex = useDevCaptainTeamIndex();
|
const captainTeamIndex = useDevCaptainTeamIndex();
|
||||||
const [assignedPosition, setAssignedPosition] = useState<Position>("MID");
|
const [assignedPositionDraft, setAssignedPositionDraft] = useState<{
|
||||||
|
playerId: string | null;
|
||||||
|
position: Position;
|
||||||
|
}>({ playerId: null, position: "MID" });
|
||||||
const [showCancelModal, setShowCancelModal] = useState(false);
|
const [showCancelModal, setShowCancelModal] = useState(false);
|
||||||
const [cancelConfirmText, setCancelConfirmText] = useState("");
|
const [cancelConfirmText, setCancelConfirmText] = useState("");
|
||||||
const [undoTargetSequence, setUndoTargetSequence] = useState<number | null>(
|
const [undoTargetSequence, setUndoTargetSequence] = useState<number | null>(
|
||||||
@@ -1853,7 +1869,7 @@ export default function AuctionPage() {
|
|||||||
const historyBackTo = `${location.pathname}${location.search}${location.hash}`;
|
const historyBackTo = `${location.pathname}${location.search}${location.hash}`;
|
||||||
const canConfirmAuctionCancel = cancelConfirmText.trim() === "예";
|
const canConfirmAuctionCancel = cancelConfirmText.trim() === "예";
|
||||||
|
|
||||||
async function clearAuctionDataAfterCancel() {
|
const clearAuctionDataAfterCancel = useCallback(async () => {
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
const auctionQueryKey = ["auction", DEFAULT_COMMUNITY_ID, id] as const;
|
const auctionQueryKey = ["auction", DEFAULT_COMMUNITY_ID, id] as const;
|
||||||
const auctionHistoryQueryKey = [
|
const auctionHistoryQueryKey = [
|
||||||
@@ -1878,7 +1894,7 @@ export default function AuctionPage() {
|
|||||||
queryKey: ["match", DEFAULT_COMMUNITY_ID, id],
|
queryKey: ["match", DEFAULT_COMMUNITY_ID, id],
|
||||||
exact: true,
|
exact: true,
|
||||||
});
|
});
|
||||||
}
|
}, [id, queryClient]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!showCancelModal) return;
|
if (!showCancelModal) return;
|
||||||
@@ -1893,6 +1909,14 @@ export default function AuctionPage() {
|
|||||||
: null,
|
: null,
|
||||||
[liveAuction, matchQuery.data],
|
[liveAuction, matchQuery.data],
|
||||||
);
|
);
|
||||||
|
const currentPlayerId = auctionState?.currentPlayer?.id ?? null;
|
||||||
|
const assignedPosition =
|
||||||
|
assignedPositionDraft.playerId === currentPlayerId
|
||||||
|
? assignedPositionDraft.position
|
||||||
|
: (auctionState?.currentPlayer?.mainPosition ?? "MID");
|
||||||
|
const setAssignedPosition = (position: Position) => {
|
||||||
|
setAssignedPositionDraft({ playerId: currentPlayerId, position });
|
||||||
|
};
|
||||||
const availableTeamIndexes = useMemo(() => {
|
const availableTeamIndexes = useMemo(() => {
|
||||||
const indexes = new Set(
|
const indexes = new Set(
|
||||||
(auctionState?.teams ?? []).map((team) => team.teamIndex),
|
(auctionState?.teams ?? []).map((team) => team.teamIndex),
|
||||||
@@ -1907,12 +1931,6 @@ export default function AuctionPage() {
|
|||||||
};
|
};
|
||||||
const chatSenderLabel = resolveChatSenderLabel(currentUser, captainRole);
|
const chatSenderLabel = resolveChatSenderLabel(currentUser, captainRole);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (auctionState?.currentPlayer) {
|
|
||||||
setAssignedPosition(auctionState.currentPlayer.mainPosition);
|
|
||||||
}
|
|
||||||
}, [auctionState?.currentPlayer?.id]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (availableTeamIndexes.length === 0) return;
|
if (availableTeamIndexes.length === 0) return;
|
||||||
if (
|
if (
|
||||||
@@ -1928,7 +1946,7 @@ export default function AuctionPage() {
|
|||||||
void clearAuctionDataAfterCancel().finally(() => {
|
void clearAuctionDataAfterCancel().finally(() => {
|
||||||
navigate(`/match/${id}`, { replace: true });
|
navigate(`/match/${id}`, { replace: true });
|
||||||
});
|
});
|
||||||
}, [id, navigate, socket.resetAt]);
|
}, [clearAuctionDataAfterCancel, id, navigate, socket.resetAt]);
|
||||||
|
|
||||||
if (!DEFAULT_COMMUNITY_ID) {
|
if (!DEFAULT_COMMUNITY_ID) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import { useQueryClient } from '@tanstack/react-query';
|
import { useQueryClient } from '@tanstack/react-query';
|
||||||
import { Link, useParams } from 'react-router';
|
import { Link, useParams } from 'react-router';
|
||||||
import {
|
import {
|
||||||
@@ -8,11 +8,17 @@ import {
|
|||||||
useMe,
|
useMe,
|
||||||
useStartLegacyImport,
|
useStartLegacyImport,
|
||||||
} from '../../api/hooks';
|
} from '../../api/hooks';
|
||||||
import type { LegacyImportJob, StartLegacyImportRequest } from '../../api/types';
|
import type {
|
||||||
|
LegacyImportJob,
|
||||||
|
LegacyImportMemberWindow,
|
||||||
|
StartLegacyImportRequest,
|
||||||
|
} from '../../api/types';
|
||||||
import { DEFAULT_COMMUNITY_ID } from '../../config';
|
import { DEFAULT_COMMUNITY_ID } from '../../config';
|
||||||
|
|
||||||
const DEFAULT_START = '2024-05-01T00:00:00.000Z';
|
const DEFAULT_START = '2024-05-01T00:00:00.000Z';
|
||||||
|
|
||||||
|
type MemberWindowOverride = { startTime: string; endTime: string };
|
||||||
|
|
||||||
function toInputValue(value: string) {
|
function toInputValue(value: string) {
|
||||||
const date = new Date(value);
|
const date = new Date(value);
|
||||||
const local = new Date(date.getTime() - date.getTimezoneOffset() * 60_000);
|
const local = new Date(date.getTime() - date.getTimezoneOffset() * 60_000);
|
||||||
@@ -44,6 +50,15 @@ function progress(job: LegacyImportJob) {
|
|||||||
return Math.round((job.processedMembers / job.totalMembers) * 100);
|
return Math.round((job.processedMembers / job.totalMembers) * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function defaultMemberOverride(
|
||||||
|
member: LegacyImportMemberWindow,
|
||||||
|
): MemberWindowOverride {
|
||||||
|
return {
|
||||||
|
startTime: toInputValue(member.startTime),
|
||||||
|
endTime: toInputValue(member.endTime),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function JobCard({
|
function JobCard({
|
||||||
job,
|
job,
|
||||||
onCancel,
|
onCancel,
|
||||||
@@ -111,7 +126,7 @@ export default function LegacyImportPage() {
|
|||||||
const [windowEnd, setWindowEnd] = useState('');
|
const [windowEnd, setWindowEnd] = useState('');
|
||||||
const [message, setMessage] = useState<string | null>(null);
|
const [message, setMessage] = useState<string | null>(null);
|
||||||
const [overrides, setOverrides] = useState<
|
const [overrides, setOverrides] = useState<
|
||||||
Record<string, { startTime: string; endTime: string }>
|
Record<string, MemberWindowOverride>
|
||||||
>({});
|
>({});
|
||||||
const currentUser =
|
const currentUser =
|
||||||
meQuery.data?.memberships.find(
|
meQuery.data?.memberships.find(
|
||||||
@@ -131,20 +146,6 @@ export default function LegacyImportPage() {
|
|||||||
const cancelMutation = useCancelLegacyImport(communityId);
|
const cancelMutation = useCancelLegacyImport(communityId);
|
||||||
const members = membersQuery.data?.members ?? [];
|
const members = membersQuery.data?.members ?? [];
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setOverrides(
|
|
||||||
Object.fromEntries(
|
|
||||||
members.map((member) => [
|
|
||||||
member.userId,
|
|
||||||
{
|
|
||||||
startTime: toInputValue(member.startTime),
|
|
||||||
endTime: toInputValue(member.endTime),
|
|
||||||
},
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}, [members]);
|
|
||||||
|
|
||||||
const manageableMemberships =
|
const manageableMemberships =
|
||||||
meQuery.data?.memberships.filter((membership) => {
|
meQuery.data?.memberships.filter((membership) => {
|
||||||
const role = membership.user.role;
|
const role = membership.user.role;
|
||||||
@@ -180,11 +181,15 @@ export default function LegacyImportPage() {
|
|||||||
const payload: StartLegacyImportRequest = {
|
const payload: StartLegacyImportRequest = {
|
||||||
windowStart: fromInputValue(windowStart),
|
windowStart: fromInputValue(windowStart),
|
||||||
windowEnd: fromInputValue(windowEnd),
|
windowEnd: fromInputValue(windowEnd),
|
||||||
memberOverrides: members.map((member) => ({
|
memberOverrides: members.map((member) => {
|
||||||
userId: member.userId,
|
const override =
|
||||||
startTime: fromInputValue(overrides[member.userId]?.startTime ?? ''),
|
overrides[member.userId] ?? defaultMemberOverride(member);
|
||||||
endTime: fromInputValue(overrides[member.userId]?.endTime ?? ''),
|
return {
|
||||||
})),
|
userId: member.userId,
|
||||||
|
startTime: fromInputValue(override.startTime),
|
||||||
|
endTime: fromInputValue(override.endTime),
|
||||||
|
};
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
startMutation.mutate(payload, {
|
startMutation.mutate(payload, {
|
||||||
onSuccess: async (result) => {
|
onSuccess: async (result) => {
|
||||||
@@ -323,53 +328,68 @@ export default function LegacyImportPage() {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{members.map((member) => (
|
{members.map((member) => {
|
||||||
<tr key={member.userId} className="border-b border-base-content/5">
|
const override =
|
||||||
<td className="px-3 py-2 text-sm font-bold">
|
overrides[member.userId] ?? defaultMemberOverride(member);
|
||||||
{member.displayName}
|
return (
|
||||||
</td>
|
<tr
|
||||||
<td className="px-3 py-2 text-xs text-base-content/45">
|
key={member.userId}
|
||||||
{member.gameName}#{member.tagLine}
|
className="border-b border-base-content/5"
|
||||||
</td>
|
>
|
||||||
<td className="px-3 py-2 text-xs">
|
<td className="px-3 py-2 text-sm font-bold">
|
||||||
{member.isActivated ? '활성' : '비활성'}
|
{member.displayName}
|
||||||
</td>
|
</td>
|
||||||
<td className="px-3 py-2">
|
<td className="px-3 py-2 text-xs text-base-content/45">
|
||||||
<input
|
{member.gameName}#{member.tagLine}
|
||||||
type="datetime-local"
|
</td>
|
||||||
value={overrides[member.userId]?.startTime ?? ''}
|
<td className="px-3 py-2 text-xs">
|
||||||
onChange={(event) =>
|
{member.isActivated ? '활성' : '비활성'}
|
||||||
setOverrides((current) => ({
|
</td>
|
||||||
...current,
|
<td className="px-3 py-2">
|
||||||
[member.userId]: {
|
<input
|
||||||
...current[member.userId],
|
type="datetime-local"
|
||||||
startTime: event.target.value,
|
value={override.startTime}
|
||||||
endTime: current[member.userId]?.endTime ?? '',
|
onChange={(event) =>
|
||||||
},
|
setOverrides((current) => {
|
||||||
}))
|
const currentOverride =
|
||||||
}
|
current[member.userId] ??
|
||||||
className="border border-base-content/10 bg-transparent px-2 py-1 text-xs"
|
defaultMemberOverride(member);
|
||||||
/>
|
return {
|
||||||
</td>
|
...current,
|
||||||
<td className="px-3 py-2">
|
[member.userId]: {
|
||||||
<input
|
...currentOverride,
|
||||||
type="datetime-local"
|
startTime: event.target.value,
|
||||||
value={overrides[member.userId]?.endTime ?? ''}
|
},
|
||||||
onChange={(event) =>
|
};
|
||||||
setOverrides((current) => ({
|
})
|
||||||
...current,
|
}
|
||||||
[member.userId]: {
|
className="border border-base-content/10 bg-transparent px-2 py-1 text-xs"
|
||||||
...current[member.userId],
|
/>
|
||||||
startTime: current[member.userId]?.startTime ?? '',
|
</td>
|
||||||
endTime: event.target.value,
|
<td className="px-3 py-2">
|
||||||
},
|
<input
|
||||||
}))
|
type="datetime-local"
|
||||||
}
|
value={override.endTime}
|
||||||
className="border border-base-content/10 bg-transparent px-2 py-1 text-xs"
|
onChange={(event) =>
|
||||||
/>
|
setOverrides((current) => {
|
||||||
</td>
|
const currentOverride =
|
||||||
</tr>
|
current[member.userId] ??
|
||||||
))}
|
defaultMemberOverride(member);
|
||||||
|
return {
|
||||||
|
...current,
|
||||||
|
[member.userId]: {
|
||||||
|
...currentOverride,
|
||||||
|
endTime: event.target.value,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
})
|
||||||
|
}
|
||||||
|
className="border border-base-content/10 bg-transparent px-2 py-1 text-xs"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
})}
|
||||||
{members.length === 0 && (
|
{members.length === 0 && (
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={5} className="px-4 py-8 text-center text-sm text-base-content/35">
|
<td colSpan={5} className="px-4 py-8 text-center text-sm text-base-content/35">
|
||||||
|
|||||||
Reference in new issue
Block a user