검색히스토리 추가 및 번역 수정

This commit is contained in:
skkim committed 2026-04-24 15:50:05 +09:00
1 parent 29cee13da7
commit 044fd21b2d
16 files changed
+629 -171

No files matched your search

+39 -30
View File
@@ -1,5 +1,6 @@
import React, { useState, useEffect, useCallback, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { UploadHistoryItem } from '../../types/api';
import { getUploadHistory, cancelUpload, retryUpload } from '../../utils/api';
@@ -53,13 +54,13 @@ const statusColor = (status: UploadStatus) => {
}
};
// 상태 라벨
const statusLabel = (status: UploadStatus) => {
// 상태 라벨 (컴포넌트 내부에서 t()로 처리)
const statusLabelKey = (status: UploadStatus) => {
switch (status) {
case 'completed': return '완료';
case 'completed': return 'contentCalendar.status.completed';
case 'scheduled':
case 'pending': return '예약';
case 'failed': return '실패';
case 'pending': return 'contentCalendar.status.scheduled';
case 'failed': return 'contentCalendar.status.failed';
default: return status;
}
};
@@ -69,6 +70,7 @@ interface ContentCalendarContentProps {
}
const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavigate }) => {
const { t } = useTranslation();
const today = new Date();
const [year, setYear] = useState(today.getFullYear());
const [month, setMonth] = useState(today.getMonth());
@@ -203,7 +205,7 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
// 취소
const handleCancel = async (uploadId: number) => {
if (!window.confirm('예약을 취소하시겠습니까?')) return;
if (!window.confirm(t('contentCalendar.cancelConfirm'))) return;
// 낙관적 업데이트: 먼저 UI에서 제거
setAllItems(prev => prev.filter(i => i.upload_id !== uploadId));
setPanelItems(prev => prev.filter(i => i.upload_id !== uploadId));
@@ -212,7 +214,7 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
} catch {
// 실패 시 다시 불러오기
refreshAll();
alert('취소에 실패했습니다.');
alert(t('contentCalendar.cancelFailed'));
}
};
@@ -222,7 +224,7 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
await retryUpload(uploadId);
refreshAll();
} catch {
alert('재시도에 실패했습니다.');
alert(t('contentCalendar.retryFailed'));
}
};
@@ -234,10 +236,11 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
return `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`;
};
// 날짜 표시 (M월 D)
// 날짜 표시
const formatDateLabel = (key: string) => {
const [, m, d] = key.split('-');
return `${parseInt(m)}월 ${parseInt(d)}`;
const months = t('contentCalendar.months', { returnObjects: true }) as string[];
return t('contentCalendar.monthDay', { month: months[parseInt(m) - 1], day: parseInt(d) });
};
const buildCalendarDays = (): CalendarDay[] => {
@@ -266,9 +269,15 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
};
const calendarDays = buildCalendarDays();
const monthNames = ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'];
const dayLabels = ['일','월','화','수','목','금','토'];
const monthNames = t('contentCalendar.months', { returnObjects: true }) as string[];
const dayLabels = t('contentCalendar.days', { returnObjects: true }) as string[];
const tabs: TabType[] = ['전체','완료','예약','실패'];
const tabLabels: Record<TabType, string> = {
'전체': t('contentCalendar.tabs.all'),
'완료': t('contentCalendar.tabs.completed'),
'예약': t('contentCalendar.tabs.scheduled'),
'실패': t('contentCalendar.tabs.failed'),
};
// ── 캘린더 그리드 ──────────────────────────────────────────────
const renderCalendarGrid = () => {
@@ -388,7 +397,7 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
<div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
<div style={{ width: 8, height: 8, borderRadius: '50%', backgroundColor: '#1ba64f', flexShrink: 0 }} />
<span style={{ fontFamily: 'Pretendard, sans-serif', fontWeight: 500, fontSize: 11, color: '#01191a', lineHeight: 1, whiteSpace: 'nowrap' }}>
완료 {summary.completed}
{t('contentCalendar.completedCount', { count: summary.completed })}
</span>
</div>
)}
@@ -396,7 +405,7 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
<div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
<div style={{ width: 8, height: 8, borderRadius: '50%', backgroundColor: '#2563eb', flexShrink: 0 }} />
<span style={{ fontFamily: 'Pretendard, sans-serif', fontWeight: 500, fontSize: 11, color: '#01191a', lineHeight: 1, whiteSpace: 'nowrap' }}>
예약 {summary.scheduled}
{t('contentCalendar.scheduledCount', { count: summary.scheduled })}
</span>
</div>
)}
@@ -404,7 +413,7 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
<div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
<div style={{ width: 8, height: 8, borderRadius: '50%', backgroundColor: '#e15252', flexShrink: 0 }} />
<span style={{ fontFamily: 'Pretendard, sans-serif', fontWeight: 500, fontSize: 11, color: '#01191a', lineHeight: 1, whiteSpace: 'nowrap' }}>
실패 {summary.failed}
{t('contentCalendar.failedCount', { count: summary.failed })}
</span>
</div>
)}
@@ -432,7 +441,7 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
letterSpacing: '-0.096px', lineHeight: '22px', whiteSpace: 'nowrap',
}}
>
{tab}
{tabLabels[tab]}
</button>
))}
</div>
@@ -442,9 +451,9 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
const renderStats = () => (
<div style={{ display: 'flex', gap: 16, alignItems: 'center' }}>
{[
{ label: '예약', value: totalStats.scheduled },
{ label: '완료', value: totalStats.completed },
{ label: '실패', value: totalStats.failed },
{ label: t('contentCalendar.tabs.scheduled'), value: totalStats.scheduled },
{ label: t('contentCalendar.tabs.completed'), value: totalStats.completed },
{ label: t('contentCalendar.tabs.failed'), value: totalStats.failed },
].map((item, idx) => (
<React.Fragment key={item.label}>
{idx > 0 && <div style={{ width: 0, height: 14, borderLeft: '1px solid #379599' }} />}
@@ -483,7 +492,7 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
color: '#e5f1f2', letterSpacing: '-0.096px', lineHeight: '22px',
margin: 0, whiteSpace: 'nowrap',
}}>
{year}년 {monthNames[month]}
{t('contentCalendar.yearMonth', { year, month: monthNames[month] })}
</p>
<button
onClick={handleNextMonth}
@@ -529,7 +538,7 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
fontFamily: 'Pretendard, sans-serif', fontWeight: 500, fontSize: 13,
color: statusColor(item.status as UploadStatus), lineHeight: 1,
}}>
{statusLabel(item.status as UploadStatus)}
{t(statusLabelKey(item.status as UploadStatus))}
</span>
<span style={{
fontFamily: 'Pretendard, sans-serif', fontWeight: 400, fontSize: 13,
@@ -575,7 +584,7 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
color: '#9bcacc', cursor: 'pointer',
}}
>
취소
{t('contentCalendar.cancel')}
</button>
)}
{isFailed && (
@@ -588,7 +597,7 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
color: '#ffffff', cursor: 'pointer',
}}
>
재시도
{t('contentCalendar.retry')}
</button>
)}
</div>
@@ -602,7 +611,7 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
if (panelLoading) {
return (
<div style={{ flex: 1, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<span style={{ color: '#9bcacc', fontFamily: 'Pretendard, sans-serif', fontSize: 14 }}>불러오는 중...</span>
<span style={{ color: '#9bcacc', fontFamily: 'Pretendard, sans-serif', fontSize: 14 }}>{t('contentCalendar.loading')}</span>
</div>
);
}
@@ -617,13 +626,13 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
fontFamily: 'Pretendard, sans-serif', fontWeight: 700, fontSize: 16,
color: '#e5f1f2', letterSpacing: '-0.096px', lineHeight: '22px', margin: 0,
}}>
최근 결과 없음
{t('contentCalendar.noResults')}
</p>
<p style={{
fontFamily: 'Pretendard, sans-serif', fontWeight: 500, fontSize: 12,
color: '#9bcacc', letterSpacing: '-0.072px', lineHeight: 1, margin: 0,
}}>
제작한 콘텐츠를 소셜 채널에 업로드해 보세요
{t('contentCalendar.noResultsDesc')}
</p>
</div>
<button
@@ -635,7 +644,7 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
color: '#ffffff',
}}
>
ADO2 콘텐츠
{t('contentCalendar.ado2Contents')}
</button>
</div>
);
@@ -681,7 +690,7 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
fontFamily: 'Pretendard, sans-serif', fontWeight: 700, fontSize: 30,
color: '#ffffff', letterSpacing: '-0.18px', lineHeight: 1.3, margin: 0,
}}>
콘텐츠 캘린더
{t('contentCalendar.title')}
</p>
</div>
@@ -746,7 +755,7 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
fontFamily: 'Pretendard, sans-serif', fontWeight: 700, fontSize: 30,
color: '#ffffff', letterSpacing: '-0.18px', lineHeight: 1.3, margin: 0,
}}>
콘텐츠 캘린더
{t('contentCalendar.title')}
</p>
</div>
@@ -774,7 +783,7 @@ const ContentCalendarContent: React.FC<ContentCalendarContentProps> = ({ onNavig
</div>
{loading ? (
<div style={{ flex: 1, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<span style={{ color: '#9bcacc', fontFamily: 'Pretendard, sans-serif', fontSize: 14 }}>불러오는 중...</span>
<span style={{ color: '#9bcacc', fontFamily: 'Pretendard, sans-serif', fontSize: 14 }}>{t('contentCalendar.loading')}</span>
</div>
) : renderCalendarGrid()}
</div>