feat: 마케팅 플랜 Phase 1~3 완성
- ContentCalendar: 드래그앤드롭(주차 내 요일 간 이동) + 엔트리 추가 버튼 + iCal Export - BrandingGuide: 색상 팔레트 인라인 편집(스와치 클릭 → hex 팝오버) + DO/DON'T 2컬럼 - WorkflowTracker: 콘텐츠 제작 파이프라인(기획→AI초안→검토→승인→배포), 동영상/이미지+텍스트 분류 - RepurposingProposal: YouTube 인기 영상 리퍼포징 제안 아코디언 섹션 - AssetDetailModal: 에셋 카드 클릭 시 상세 모달 - 디자인 시스템 감사: Lucide 라인 아이콘 제거, 원색(pink/indigo/purple) 제거, 이모지 UI 제거 - "My Assets" → "나의 소재" 일관성 변경 - FilledIcons: DownloadFilled, RocketFilled 추가 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
b84410341f
commit
2027ae9b64
19 files changed
+1547
-207
No files matched your search
@@ -0,0 +1,101 @@
|
||||
import type { CalendarWeek, CalendarEntry } from '../types/plan';
|
||||
|
||||
/**
|
||||
* Returns the Monday date of a given ISO week number in a year.
|
||||
* Week 1 = the week containing the first Thursday of the year (ISO 8601).
|
||||
*/
|
||||
function isoWeekToDate(year: number, week: number, dayOffset: number): Date {
|
||||
// Jan 4 is always in week 1
|
||||
const jan4 = new Date(year, 0, 4);
|
||||
const dayOfWeek = jan4.getDay() || 7; // convert Sun=0 to 7
|
||||
const monday = new Date(jan4);
|
||||
monday.setDate(jan4.getDate() - (dayOfWeek - 1) + (week - 1) * 7);
|
||||
monday.setDate(monday.getDate() + dayOffset);
|
||||
return monday;
|
||||
}
|
||||
|
||||
function formatICSDate(date: Date): string {
|
||||
const pad = (n: number) => String(n).padStart(2, '0');
|
||||
return (
|
||||
`${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(date.getDate())}` +
|
||||
`T${pad(date.getHours())}${pad(date.getMinutes())}${pad(date.getSeconds())}`
|
||||
);
|
||||
}
|
||||
|
||||
function escapeICS(str: string): string {
|
||||
return str
|
||||
.replace(/\\/g, '\\\\')
|
||||
.replace(/;/g, '\\;')
|
||||
.replace(/,/g, '\\,')
|
||||
.replace(/\n/g, '\\n');
|
||||
}
|
||||
|
||||
function buildVEvent(
|
||||
entry: CalendarEntry,
|
||||
weekNumber: number,
|
||||
year: number,
|
||||
uid: string,
|
||||
): string {
|
||||
const startDate = isoWeekToDate(year, weekNumber, entry.dayOfWeek);
|
||||
// All-day event: DTSTART is DATE only, DTEND is next day
|
||||
const endDate = new Date(startDate);
|
||||
endDate.setDate(endDate.getDate() + 1);
|
||||
|
||||
const formatDate = (d: Date) => {
|
||||
const pad = (n: number) => String(n).padStart(2, '0');
|
||||
return `${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}`;
|
||||
};
|
||||
|
||||
const lines = [
|
||||
'BEGIN:VEVENT',
|
||||
`UID:${uid}`,
|
||||
`DTSTAMP:${formatICSDate(new Date())}Z`,
|
||||
`DTSTART;VALUE=DATE:${formatDate(startDate)}`,
|
||||
`DTEND;VALUE=DATE:${formatDate(endDate)}`,
|
||||
`SUMMARY:${escapeICS(`[${entry.channel}] ${entry.title}`)}`,
|
||||
entry.description ? `DESCRIPTION:${escapeICS(entry.description)}` : null,
|
||||
`CATEGORIES:${escapeICS(entry.contentType.toUpperCase())}`,
|
||||
`STATUS:${entry.status === 'published' ? 'CONFIRMED' : entry.status === 'approved' ? 'TENTATIVE' : 'NEEDS-ACTION'}`,
|
||||
'END:VEVENT',
|
||||
].filter(Boolean) as string[];
|
||||
|
||||
return lines.join('\r\n');
|
||||
}
|
||||
|
||||
export function exportCalendarToICS(
|
||||
weeks: CalendarWeek[],
|
||||
calendarName = 'INFINITH 콘텐츠 캘린더',
|
||||
): void {
|
||||
const year = new Date().getFullYear();
|
||||
|
||||
const vEvents = weeks.flatMap((week) =>
|
||||
week.entries.map((entry, idx) =>
|
||||
buildVEvent(
|
||||
entry,
|
||||
week.weekNumber,
|
||||
year,
|
||||
`infinith-${week.weekNumber}-${entry.id ?? idx}@infinith.ai`,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
const icsContent = [
|
||||
'BEGIN:VCALENDAR',
|
||||
'VERSION:2.0',
|
||||
'PRODID:-//INFINITH//Marketing Content Calendar//KO',
|
||||
`X-WR-CALNAME:${escapeICS(calendarName)}`,
|
||||
'X-WR-TIMEZONE:Asia/Seoul',
|
||||
'CALSCALE:GREGORIAN',
|
||||
'METHOD:PUBLISH',
|
||||
...vEvents,
|
||||
'END:VCALENDAR',
|
||||
].join('\r\n');
|
||||
|
||||
const blob = new Blob([icsContent], { type: 'text/calendar;charset=utf-8' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = 'infinith-content-calendar.ics';
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
Reference in new issue
Block a user