스케줄 페이지 작업 완료 .
This commit is contained in:
1 parent
29e0c7d79c
commit
4d91da9b9a
13 files changed
+1301
-49
No files matched your search
@@ -83,6 +83,7 @@ const Sidebar: React.FC<SidebarProps> = ({ activeItem, onNavigate, onHome, userI
|
||||
{ id: '새 프로젝트 만들기', label: t('sidebar.newProject'), disabled: false, icon: <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg> },
|
||||
{ id: 'ADO2 콘텐츠', label: t('sidebar.ado2Contents'), disabled: false, icon: <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/></svg> },
|
||||
{ id: '내 콘텐츠', label: t('sidebar.myContents'), disabled: true, icon: <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg> },
|
||||
{ id: '콘텐츠 캘린더', label: '콘텐츠 캘린더', disabled: false, icon: <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg> },
|
||||
{ id: '내 정보', label: t('sidebar.myInfo'), disabled: false, icon: <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg> },
|
||||
];
|
||||
|
||||
|
||||
@@ -26,6 +26,90 @@ const getPlatformIcon = (platform: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 미니 캘린더 컴포넌트
|
||||
const MiniCalendar: React.FC<{
|
||||
selectedDate: Date | null;
|
||||
onSelect: (date: Date) => void;
|
||||
minDate?: Date;
|
||||
}> = ({ selectedDate, onSelect, minDate }) => {
|
||||
const today = new Date();
|
||||
const [viewYear, setViewYear] = useState(selectedDate?.getFullYear() ?? today.getFullYear());
|
||||
const [viewMonth, setViewMonth] = useState(selectedDate?.getMonth() ?? today.getMonth());
|
||||
|
||||
const DAY_LABELS = ['일', '월', '화', '수', '목', '금', '토'];
|
||||
|
||||
const firstDay = new Date(viewYear, viewMonth, 1).getDay();
|
||||
const daysInMonth = new Date(viewYear, viewMonth + 1, 0).getDate();
|
||||
const daysInPrevMonth = new Date(viewYear, viewMonth, 0).getDate();
|
||||
|
||||
const cells: { date: Date; currentMonth: boolean }[] = [];
|
||||
for (let i = firstDay - 1; i >= 0; i--) {
|
||||
cells.push({ date: new Date(viewYear, viewMonth - 1, daysInPrevMonth - i), currentMonth: false });
|
||||
}
|
||||
for (let d = 1; d <= daysInMonth; d++) {
|
||||
cells.push({ date: new Date(viewYear, viewMonth, d), currentMonth: true });
|
||||
}
|
||||
while (cells.length % 7 !== 0) {
|
||||
cells.push({ date: new Date(viewYear, viewMonth + 1, cells.length - daysInMonth - firstDay + 1), currentMonth: false });
|
||||
}
|
||||
|
||||
const isSameDay = (a: Date, b: Date) =>
|
||||
a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
||||
|
||||
const isDisabled = (date: Date) => {
|
||||
if (!minDate) return false;
|
||||
const min = new Date(minDate); min.setHours(0,0,0,0);
|
||||
const d = new Date(date); d.setHours(0,0,0,0);
|
||||
return d < min;
|
||||
};
|
||||
|
||||
const prevMonth = () => {
|
||||
if (viewMonth === 0) { setViewYear(y => y - 1); setViewMonth(11); }
|
||||
else setViewMonth(m => m - 1);
|
||||
};
|
||||
const nextMonth = () => {
|
||||
if (viewMonth === 11) { setViewYear(y => y + 1); setViewMonth(0); }
|
||||
else setViewMonth(m => m + 1);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="mini-calendar">
|
||||
<div className="mini-calendar-header">
|
||||
<button type="button" className="mini-calendar-nav" onClick={prevMonth}>‹</button>
|
||||
<span className="mini-calendar-title">{viewYear}년 {viewMonth + 1}월</span>
|
||||
<button type="button" className="mini-calendar-nav" onClick={nextMonth}>›</button>
|
||||
</div>
|
||||
<div className="mini-calendar-grid">
|
||||
{DAY_LABELS.map(d => (
|
||||
<div key={d} className="mini-calendar-day-label">{d}</div>
|
||||
))}
|
||||
{cells.map((cell, i) => {
|
||||
const disabled = isDisabled(cell.date);
|
||||
const isSelected = selectedDate ? isSameDay(cell.date, selectedDate) : false;
|
||||
const isToday = isSameDay(cell.date, today);
|
||||
return (
|
||||
<button
|
||||
key={i}
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
className={[
|
||||
'mini-calendar-cell',
|
||||
cell.currentMonth ? '' : 'other-month',
|
||||
isSelected ? 'selected' : '',
|
||||
isToday && !isSelected ? 'today' : '',
|
||||
disabled ? 'disabled' : '',
|
||||
].join(' ')}
|
||||
onClick={() => !disabled && onSelect(cell.date)}
|
||||
>
|
||||
{cell.date.getDate()}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const SocialPostingModal: React.FC<SocialPostingModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
@@ -39,6 +123,9 @@ const SocialPostingModal: React.FC<SocialPostingModalProps> = ({
|
||||
const [tags, setTags] = useState('');
|
||||
const [privacy, setPrivacy] = useState<PrivacyType>('public');
|
||||
const [publishTime, setPublishTime] = useState<PublishTimeType>('now');
|
||||
const [scheduledDate, setScheduledDate] = useState<Date | null>(null);
|
||||
const [scheduledHour, setScheduledHour] = useState<number>(12);
|
||||
const [scheduledMinute, setScheduledMinute] = useState<number>(0);
|
||||
const [isLoadingAccounts, setIsLoadingAccounts] = useState(false);
|
||||
const [isPosting, setIsPosting] = useState(false);
|
||||
const [isChannelDropdownOpen, setIsChannelDropdownOpen] = useState(false);
|
||||
@@ -137,6 +224,20 @@ const SocialPostingModal: React.FC<SocialPostingModalProps> = ({
|
||||
return;
|
||||
}
|
||||
|
||||
if (publishTime === 'schedule' && !scheduledDate) {
|
||||
alert('게시 날짜를 선택해주세요.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (publishTime === 'schedule' && scheduledDate) {
|
||||
const dt = new Date(scheduledDate);
|
||||
dt.setHours(scheduledHour, scheduledMinute, 0, 0);
|
||||
if (dt <= new Date()) {
|
||||
alert('현재 시각 이후의 시간을 선택해주세요.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const selectedAcc = socialAccounts.find(acc => acc.platform_user_id === selectedChannel);
|
||||
if (!selectedAcc) {
|
||||
alert(t('social.selectChannel'));
|
||||
@@ -170,6 +271,15 @@ const SocialPostingModal: React.FC<SocialPostingModalProps> = ({
|
||||
.filter(tag => tag.length > 0);
|
||||
|
||||
// Request payload 로그
|
||||
let scheduledAt: string | null = null;
|
||||
if (publishTime === 'schedule' && scheduledDate) {
|
||||
const dt = new Date(scheduledDate);
|
||||
dt.setHours(scheduledHour, scheduledMinute, 0, 0);
|
||||
// 로컬 시간 기준으로 전송 (Z 없이)
|
||||
const pad = (n: number) => String(n).padStart(2, '0');
|
||||
scheduledAt = `${dt.getFullYear()}-${pad(dt.getMonth()+1)}-${pad(dt.getDate())}T${pad(dt.getHours())}:${pad(dt.getMinutes())}:00`;
|
||||
}
|
||||
|
||||
const requestPayload = {
|
||||
video_id: video.video_id,
|
||||
social_account_id: selectedAcc.id,
|
||||
@@ -177,7 +287,7 @@ const SocialPostingModal: React.FC<SocialPostingModalProps> = ({
|
||||
description: description.trim(),
|
||||
tags: tagsArray,
|
||||
privacy_status: privacy,
|
||||
scheduled_at: publishTime === 'now' ? null : null,
|
||||
scheduled_at: scheduledAt,
|
||||
};
|
||||
console.log('[Upload] Request payload:', requestPayload);
|
||||
|
||||
@@ -188,23 +298,31 @@ const SocialPostingModal: React.FC<SocialPostingModalProps> = ({
|
||||
throw new Error(uploadResponse.message || t('social.uploadStartFailed'));
|
||||
}
|
||||
|
||||
// Poll for upload completion
|
||||
const result = await waitForUploadComplete(
|
||||
uploadResponse.upload_id,
|
||||
(status, progress) => {
|
||||
setUploadStatus(status as UploadStatus);
|
||||
setUploadProgress(progress || 0);
|
||||
}
|
||||
);
|
||||
if (publishTime === 'schedule') {
|
||||
// 예약 업로드: 폴링 없이 바로 완료 처리
|
||||
setUploadStatus('completed');
|
||||
setUploadProgress(100);
|
||||
onClose();
|
||||
resetForm();
|
||||
} else {
|
||||
// 즉시 업로드: 완료될 때까지 폴링
|
||||
const result = await waitForUploadComplete(
|
||||
uploadResponse.upload_id,
|
||||
(status, progress) => {
|
||||
setUploadStatus(status as UploadStatus);
|
||||
setUploadProgress(progress || 0);
|
||||
}
|
||||
);
|
||||
|
||||
// Upload completed successfully
|
||||
setUploadStatus('completed');
|
||||
setUploadProgress(100);
|
||||
setUploadYoutubeUrl(result.platform_url);
|
||||
// Upload completed successfully
|
||||
setUploadStatus('completed');
|
||||
setUploadProgress(100);
|
||||
setUploadYoutubeUrl(result.platform_url);
|
||||
|
||||
// Close the posting modal (keep progress modal open)
|
||||
onClose();
|
||||
resetForm();
|
||||
// Close the posting modal (keep progress modal open)
|
||||
onClose();
|
||||
resetForm();
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof TokenExpiredError) {
|
||||
setShowUploadProgress(false);
|
||||
@@ -226,6 +344,9 @@ const SocialPostingModal: React.FC<SocialPostingModalProps> = ({
|
||||
setTags('');
|
||||
setPrivacy('public');
|
||||
setPublishTime('now');
|
||||
setScheduledDate(null);
|
||||
setScheduledHour(12);
|
||||
setScheduledMinute(0);
|
||||
setSelectedChannel('');
|
||||
setIsChannelDropdownOpen(false);
|
||||
setIsPrivacyDropdownOpen(false);
|
||||
@@ -267,6 +388,7 @@ const SocialPostingModal: React.FC<SocialPostingModalProps> = ({
|
||||
channelName={uploadChannelName || selectedAccount?.display_name || ''}
|
||||
youtubeUrl={uploadYoutubeUrl}
|
||||
errorMessage={uploadErrorMessage}
|
||||
isScheduled={publishTime === 'schedule'}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -491,11 +613,105 @@ const SocialPostingModal: React.FC<SocialPostingModalProps> = ({
|
||||
value="schedule"
|
||||
checked={publishTime === 'schedule'}
|
||||
onChange={() => setPublishTime('schedule')}
|
||||
disabled
|
||||
/>
|
||||
<span className="radio-label disabled">{t('social.publishSchedule')}</span>
|
||||
<span className="radio-label">{t('social.publishSchedule')}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{/* 시간 설정 UI */}
|
||||
{publishTime === 'schedule' && (() => {
|
||||
const now = new Date();
|
||||
const isTodaySelected = scheduledDate
|
||||
? scheduledDate.getFullYear() === now.getFullYear() &&
|
||||
scheduledDate.getMonth() === now.getMonth() &&
|
||||
scheduledDate.getDate() === now.getDate()
|
||||
: false;
|
||||
|
||||
// 오늘 선택 시: 현재 시각 기준으로 선택 가능한 최소 시간 계산
|
||||
// 현재 분을 10분 단위 올림하여 최소 분 결정
|
||||
const nowMinute = now.getMinutes();
|
||||
const minMinuteForCurrentHour = Math.ceil((nowMinute + 1) / 10) * 10;
|
||||
const minHour = isTodaySelected
|
||||
? (minMinuteForCurrentHour >= 60 ? now.getHours() + 1 : now.getHours())
|
||||
: 0;
|
||||
|
||||
// 선택된 시간이 오늘 최소 시간보다 작으면 분 옵션 제한
|
||||
const minMinuteForSelectedHour = isTodaySelected && scheduledHour === now.getHours()
|
||||
? minMinuteForCurrentHour >= 60 ? 0 : minMinuteForCurrentHour
|
||||
: 0;
|
||||
|
||||
const handleDateSelect = (date: Date) => {
|
||||
const selectedIsToday =
|
||||
date.getFullYear() === now.getFullYear() &&
|
||||
date.getMonth() === now.getMonth() &&
|
||||
date.getDate() === now.getDate();
|
||||
|
||||
setScheduledDate(date);
|
||||
|
||||
// 오늘을 선택했을 때 현재 설정된 시간이 과거라면 최솟값으로 보정
|
||||
if (selectedIsToday) {
|
||||
const minMin = Math.ceil((now.getMinutes() + 1) / 10) * 10;
|
||||
const minH = minMin >= 60 ? now.getHours() + 1 : now.getHours();
|
||||
const adjMin = minMin >= 60 ? 0 : minMin;
|
||||
if (scheduledHour < minH || (scheduledHour === minH && scheduledMinute < adjMin)) {
|
||||
setScheduledHour(minH);
|
||||
setScheduledMinute(adjMin);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleHourChange = (h: number) => {
|
||||
setScheduledHour(h);
|
||||
// 시간 변경 시 분이 과거가 되면 최솟값으로 보정
|
||||
if (isTodaySelected && h === now.getHours()) {
|
||||
const minMin = Math.ceil((now.getMinutes() + 1) / 10) * 10;
|
||||
const adjMin = minMin >= 60 ? 0 : minMin;
|
||||
if (scheduledMinute < adjMin) setScheduledMinute(adjMin);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="schedule-datetime-picker">
|
||||
<MiniCalendar
|
||||
selectedDate={scheduledDate}
|
||||
onSelect={handleDateSelect}
|
||||
minDate={new Date()}
|
||||
/>
|
||||
<div className="schedule-time-picker">
|
||||
<span className="schedule-time-label">시간 설정</span>
|
||||
<div className="schedule-time-selects">
|
||||
<select
|
||||
className="schedule-time-select"
|
||||
value={scheduledHour}
|
||||
onChange={(e) => handleHourChange(Number(e.target.value))}
|
||||
>
|
||||
{Array.from({ length: 24 }, (_, i) => (
|
||||
<option key={i} value={i} disabled={isTodaySelected && i < minHour}>
|
||||
{String(i).padStart(2, '0')}시
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<select
|
||||
className="schedule-time-select"
|
||||
value={scheduledMinute}
|
||||
onChange={(e) => setScheduledMinute(Number(e.target.value))}
|
||||
>
|
||||
{[0, 10, 20, 30, 40, 50].map(m => (
|
||||
<option key={m} value={m} disabled={isTodaySelected && m < minMinuteForSelectedHour}>
|
||||
{String(m).padStart(2, '0')}분
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
{scheduledDate && (
|
||||
<p className="schedule-datetime-preview">
|
||||
{scheduledDate.getFullYear()}.{String(scheduledDate.getMonth()+1).padStart(2,'0')}.{String(scheduledDate.getDate()).padStart(2,'0')} {String(scheduledHour).padStart(2,'0')}:{String(scheduledMinute).padStart(2,'0')} 예약
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -516,7 +732,12 @@ const SocialPostingModal: React.FC<SocialPostingModalProps> = ({
|
||||
<button
|
||||
className="social-posting-btn submit"
|
||||
onClick={handlePost}
|
||||
disabled={isPosting || socialAccounts.length === 0 || !title.trim()}
|
||||
disabled={
|
||||
isPosting ||
|
||||
socialAccounts.length === 0 ||
|
||||
!title.trim() ||
|
||||
(publishTime === 'schedule' && !scheduledDate)
|
||||
}
|
||||
>
|
||||
{isPosting ? t('social.posting') : t('social.post')}
|
||||
</button>
|
||||
|
||||
@@ -13,6 +13,7 @@ interface UploadProgressModalProps {
|
||||
channelName: string;
|
||||
youtubeUrl?: string;
|
||||
errorMessage?: string;
|
||||
isScheduled?: boolean;
|
||||
}
|
||||
|
||||
const UploadProgressModal: React.FC<UploadProgressModalProps> = ({
|
||||
@@ -24,6 +25,7 @@ const UploadProgressModal: React.FC<UploadProgressModalProps> = ({
|
||||
channelName,
|
||||
youtubeUrl,
|
||||
errorMessage,
|
||||
isScheduled = false,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
if (!isOpen) return null;
|
||||
@@ -35,7 +37,7 @@ const UploadProgressModal: React.FC<UploadProgressModalProps> = ({
|
||||
case 'uploading':
|
||||
return t('upload.statusUploading');
|
||||
case 'completed':
|
||||
return t('upload.statusCompleted');
|
||||
return isScheduled ? t('upload.statusScheduled') : t('upload.statusCompleted');
|
||||
case 'failed':
|
||||
return t('upload.statusFailed');
|
||||
default:
|
||||
@@ -83,7 +85,7 @@ const UploadProgressModal: React.FC<UploadProgressModalProps> = ({
|
||||
<div className="upload-progress-modal">
|
||||
{/* Header */}
|
||||
<div className="upload-progress-header">
|
||||
<h2 className="upload-progress-title">{t('upload.title')}</h2>
|
||||
<h2 className="upload-progress-title">{isScheduled && status === 'completed' ? t('upload.titleScheduled') : t('upload.title')}</h2>
|
||||
{canClose && (
|
||||
<button className="upload-progress-close" onClick={onClose}>
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||
|
||||
Reference in new issue
Block a user