feat: add Maia chess game UI
All checks were successful
Deploy blog-frontend / build-and-deploy (push) Successful in 2m11s

This commit is contained in:
박원엽
2026-06-19 14:49:28 +09:00
parent a828be323a
commit 924dd8b372
14 changed files with 1441 additions and 4 deletions

View File

@@ -0,0 +1,54 @@
import axios from 'axios';
import { ChessOutcome } from '@/types';
export type OutcomeFilter = 'ALL' | 'IN_PROGRESS' | 'WIN' | 'LOSS' | 'DRAW';
export const outcomeLabels: Record<ChessOutcome, string> = {
IN_PROGRESS: '진행중',
WIN: '승',
LOSS: '패',
DRAW: '무',
UNKNOWN: '미정',
};
export const outcomeBadgeTones: Record<ChessOutcome, 'neutral' | 'info' | 'success' | 'warning' | 'danger'> = {
IN_PROGRESS: 'info',
WIN: 'success',
LOSS: 'danger',
DRAW: 'warning',
UNKNOWN: 'neutral',
};
export const formatChessDateTime = (value?: string) => {
if (!value) return '';
const date = new Date(value);
if (Number.isNaN(date.getTime())) return value;
return new Intl.DateTimeFormat('ko-KR', {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
}).format(date);
};
export const getChessErrorMessage = (error: unknown, fallback = '요청을 처리하지 못했습니다.') => {
if (axios.isAxiosError(error)) {
if (error.response?.status === 401 || error.response?.status === 403) {
return '로그인이 필요합니다.';
}
const message = error.response?.data?.message;
if (typeof message === 'string' && message.trim()) return message;
}
if (error instanceof Error && error.message) return error.message;
return fallback;
};
export const isAuthError = (error: unknown) => {
return axios.isAxiosError(error) && (error.response?.status === 401 || error.response?.status === 403);
};