From c06018d88c3f2368cffa7dbda9c06cc856f299bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EA=B2=BD?= Date: Thu, 15 Oct 2026 10:57:04 +0900 Subject: [PATCH] =?UTF-8?q?feat(p2v):=20=EB=AC=B4=EB=B9=99=20=ED=8F=AC?= =?UTF-8?q?=EC=8A=A4=ED=84=B0=C2=B7=EB=A1=B1=EC=BB=B7=20=ED=86=B5=ED=95=A9?= =?UTF-8?q?=20=EB=B0=8F=20=EC=83=81=EC=84=B8=C2=B7=EC=86=8C=EC=85=9C=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 9 + src/components/ContentDetailContent.tsx | 489 +++++++++++++++++++++ src/components/LicenseBadge.tsx | 46 -- src/components/P2vKeyGate.tsx | 49 --- src/components/P2vViewerModal.tsx | 55 +++ src/components/PipelineTabs.tsx | 16 +- src/components/SocialPostingModal.tsx | 4 +- src/components/pipelineIcons.tsx | 10 - src/hooks/useP2vJob.ts | 100 +---- src/hooks/usePlayreelJob.ts | 9 + src/hooks/usePolledJob.ts | 87 ++++ src/locales/en.json | 251 ++++++++++- src/locales/ko.json | 267 +++++++++-- src/pages/Dashboard/ADO2ContentsPage.tsx | 23 +- src/pages/Dashboard/GenerationFlow.tsx | 168 +++++-- src/pages/Dashboard/MyContentsPage.tsx | 29 +- src/pages/Dashboard/UrlInputContent.tsx | 57 ++- src/pages/P2v/P2vDetailPage.tsx | 25 ++ src/pages/P2v/PlayreelAutoApprovePanel.tsx | 52 +++ src/pages/P2v/PlayreelCreateForm.tsx | 78 ++++ src/pages/P2v/PlayreelGateContent.tsx | 467 ++++++++++++++++++++ src/pages/P2v/PlayreelMakingContent.tsx | 88 ++++ src/pages/P2v/PlayreelResultContent.tsx | 61 +++ src/pages/Poster/PosterCreateForm.tsx | 59 +-- src/pages/Poster/PosterMakingContent.tsx | 12 +- src/pages/Poster/PosterResultContent.tsx | 10 +- src/pages/Poster/PosterReviewContent.tsx | 3 +- src/pages/Poster/PosterStartChoice.tsx | 72 +++ src/pages/Poster/StylingContent.tsx | 335 -------------- src/pages/Ssulbox/SsulDetailContent.tsx | 484 +------------------- src/pages/Ssulbox/SsulResultContent.tsx | 4 +- src/styles/generation-flow.css | 12 +- src/styles/index.css | 1 + src/styles/landing.css | 2 +- src/styles/playreel-p2v.css | 266 +++++++++++ src/styles/poster-p2v.css | 466 ++++++++------------ src/types/api.ts | 18 +- src/utils/nativeShare.ts | 8 +- src/utils/p2vApi.ts | 190 +++----- src/utils/playreelApi.ts | 170 +++++++ src/utils/playreelPrefs.ts | 72 +++ src/utils/storageKeys.ts | 6 + 42 files changed, 3020 insertions(+), 1610 deletions(-) create mode 100644 src/components/ContentDetailContent.tsx delete mode 100644 src/components/LicenseBadge.tsx delete mode 100644 src/components/P2vKeyGate.tsx create mode 100644 src/components/P2vViewerModal.tsx create mode 100644 src/hooks/usePlayreelJob.ts create mode 100644 src/hooks/usePolledJob.ts create mode 100644 src/pages/P2v/P2vDetailPage.tsx create mode 100644 src/pages/P2v/PlayreelAutoApprovePanel.tsx create mode 100644 src/pages/P2v/PlayreelCreateForm.tsx create mode 100644 src/pages/P2v/PlayreelGateContent.tsx create mode 100644 src/pages/P2v/PlayreelMakingContent.tsx create mode 100644 src/pages/P2v/PlayreelResultContent.tsx create mode 100644 src/pages/Poster/PosterStartChoice.tsx delete mode 100644 src/pages/Poster/StylingContent.tsx create mode 100644 src/styles/playreel-p2v.css create mode 100644 src/utils/playreelApi.ts create mode 100644 src/utils/playreelPrefs.ts diff --git a/src/App.tsx b/src/App.tsx index 17d2168..c7f417e 100755 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,6 +7,7 @@ import SocialConnectError from './pages/Social/SocialConnectError'; import YouTubeOAuthCallback from './pages/Social/YouTubeOAuthCallback'; import VideoDetailPage from './components/VideoDetailPage'; import SsulDetailPage from './pages/Ssulbox/SsulDetailPage'; +import P2vDetailPage from './pages/P2v/P2vDetailPage'; import { kakaoCallback, saveTokens, storeUtmFromUrl, trackViewContent, trackCompleteRegistration } from './utils/api'; import { clearSessionStorage } from './utils/storageKeys'; import { NAV } from './components/navItems'; @@ -154,6 +155,14 @@ const App: React.FC = () => { return ; } + const p2vDetailMatch = pathname.match(/^\/p2v\/(f1|playreel)\/(\d+)\/?$/); + if (p2vDetailMatch) { + return ; + } + // 카카오 콜백 처리 중 로딩 화면 표시 if (isProcessingCallback) { return ( diff --git a/src/components/ContentDetailContent.tsx b/src/components/ContentDetailContent.tsx new file mode 100644 index 0000000..0fe682a --- /dev/null +++ b/src/components/ContentDetailContent.tsx @@ -0,0 +1,489 @@ +import React, { useCallback, useEffect, useRef, useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { + API_URL, + deleteComment, + getSsulContentById, + getUserMe, + getVideoComments, + isLoggedIn, + postVideoComment, + toggleVideoLike, +} from '../utils/api'; +import type { SsulDetailItem } from '../utils/api'; +import { CommentItem, P2vContentType, UserMeResponse } from '../types/api'; +import { buildContentShareUrl, tryNativeShare } from '../utils/nativeShare'; +import LoginPromptModal from './LoginPromptModal'; +import { isSafeHttpUrl } from '../utils/url'; +import { getP2vContentById } from '../utils/p2vApi'; + +interface ContentDetailContentProps { + contentId: string; + contentType: 'ssul' | P2vContentType; + isModal?: boolean; + onClose?: () => void; +} + +type DetailContent = Pick & { poster_url?: string | null }; + +/** Shared public detail UI for Ssulbox and P2V content. */ +const ContentDetailContent: React.FC = ({ + contentId, + contentType, + isModal = false, + onClose, +}) => { + const { t } = useTranslation(); + const authed = isLoggedIn(); + + const [content, setContent] = useState(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + const [likeCount, setLikeCount] = useState(0); + const [isLiked, setIsLiked] = useState(false); + const [likeSubmitting, setLikeSubmitting] = useState(false); + + const [copied, setCopied] = useState(false); + const [isLandscape, setIsLandscape] = useState(false); + const [showSiteOverlay, setShowSiteOverlay] = useState(false); + const [showLoginModal, setShowLoginModal] = useState(false); + + const [comments, setComments] = useState([]); + const [commentsTotal, setCommentsTotal] = useState(0); + const [commentsPage, setCommentsPage] = useState(1); + const [commentsHasNext, setCommentsHasNext] = useState(false); + const [commentsLoading, setCommentsLoading] = useState(false); + const [commentInput, setCommentInput] = useState(''); + const [commentSubmitting, setCommentSubmitting] = useState(false); + const commentTextareaRef = useRef(null); + + const [currentUser, setCurrentUser] = useState(null); + + const fetchComments = useCallback( + async (page: number, append = false) => { + setCommentsLoading(true); + try { + const res = await getVideoComments(contentId, page, 20, contentType); + const sorted = [...res.items].sort( + (a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime() + ); + setComments((prev) => (append ? [...prev, ...sorted] : sorted)); + setCommentsTotal(res.total); + setCommentsHasNext(res.has_next); + setCommentsPage(page); + } catch (err) { + console.error('Failed to fetch content comments:', err); + } finally { + setCommentsLoading(false); + } + }, + [contentId, contentType] + ); + + useEffect(() => { + const fetchContent = async () => { + setLoading(true); + setError(null); + setShowSiteOverlay(false); + try { + const data = contentType === 'ssul' + ? await getSsulContentById(contentId) + : await getP2vContentById(contentType, contentId).then((item) => ({ + ...item, store_name: item.title, + })); + setContent(data); + setLikeCount(data.like_count); + setIsLiked(data.is_liked_by_me); + } catch (err) { + console.error('Failed to fetch content:', err); + setError(t('ado2Contents.loadFailed')); + } finally { + setLoading(false); + } + }; + + setIsLandscape(false); + fetchContent(); + fetchComments(1); + }, [contentId, contentType, fetchComments, t]); + + useEffect(() => { + if (!authed) return; + getUserMe().then(setCurrentUser).catch((err) => { + console.error('Failed to fetch current user:', err); + }); + }, [authed]); + + const formatDate = (dateString: string) => { + const date = new Date(dateString); + return t('videoDetail.dateFormat', { + year: date.getFullYear(), + month: date.getMonth() + 1, + day: date.getDate(), + }); + }; + + const formatCommentDate = (dateString: string) => { + const date = new Date(dateString); + return `${date.getFullYear()}.${String(date.getMonth() + 1).padStart(2, '0')}.${String( + date.getDate() + ).padStart(2, '0')}`; + }; + + // ID 가 같아도 콘텐츠 종류에 맞는 공유 경로로 연다. + const shareUrl = buildContentShareUrl(API_URL, contentId, contentType); + + const handleCopyLink = async () => { + try { + await navigator.clipboard.writeText(shareUrl); + } catch { + // clipboard API 미지원 환경에서는 무시 + } + setCopied(true); + setTimeout(() => setCopied(false), 2000); + }; + + const handleShareButtonClick = async () => { + const handled = await tryNativeShare({ + title: content?.store_name ?? t('videoDetail.kakaoDefaultTitle'), + url: shareUrl, + }); + if (handled) { + return; + } + await handleCopyLink(); + }; + + const handleLike = async () => { + if (!authed) { + setShowLoginModal(true); + return; + } + + if (likeSubmitting) return; + const prevLiked = isLiked; + const prevCount = likeCount; + setLikeSubmitting(true); + setIsLiked(!prevLiked); + setLikeCount(prevLiked ? prevCount - 1 : prevCount + 1); + try { + const result = await toggleVideoLike(contentId, contentType); + setIsLiked(result.is_liked); + setLikeCount(result.like_count); + } catch (err) { + console.error('Failed to toggle content like:', err); + setIsLiked(prevLiked); + setLikeCount(prevCount); + } finally { + setLikeSubmitting(false); + } + }; + + const handleHeaderAction = () => { + onClose?.(); + }; + + const handleCommentFocus = () => { + if (!authed) setShowLoginModal(true); + }; + + const handleCommentSubmit = async () => { + if (!authed) { + setShowLoginModal(true); + return; + } + if (!commentInput.trim() || commentSubmitting) return; + setCommentSubmitting(true); + try { + await postVideoComment(contentId, commentInput.trim(), undefined, contentType); + setCommentInput(''); + if (commentTextareaRef.current) { + commentTextareaRef.current.style.height = 'auto'; + } + await fetchComments(1); + } catch (err) { + console.error('Failed to post content comment:', err); + } finally { + setCommentSubmitting(false); + } + }; + + const handleDeleteComment = async (commentId: number) => { + try { + await deleteComment(commentId); + await fetchComments(commentsPage); + } catch (err) { + console.error('Failed to delete content comment:', err); + } + }; + + const renderCommentContent = (content_: string | null, isDeleted: boolean) => { + if (isDeleted) { + return ( + + {t('videoDetail.deletedComment')} + + ); + } + return content_; + }; + + return ( +
+ {/* 헤더 */} +
+ {isModal ? ( + <> + {/* 제목이 없으면 space-between 인 헤더에서 닫기 버튼이 왼쪽으로 붙는다. + 문구는 ADO2 상세와 같은 키를 쓴다 — 통합 목록에서 열리는 같은 + 모달이므로 콘텐츠 종류에 따라 제목이 바뀌면 오히려 어색하다. */} +

{t('sidebar.ado2Contents')}

+ + + ) : ( + + )} +
+ +
+ {loading ? ( +
+
+

{t('ado2Contents.loading')}

+
+ ) : error ? ( +

{error}

+ ) : content ? ( +
+
+
+ +
+

+ {content.store_name || t('ssulbox.viewer.untitled')} +

+

{formatDate(content.created_at)}

+ + {/* 좋아요 + 공유 */} +
+ + +
+ + {/* 댓글 섹션 */} +
+
+

{t('videoDetail.commentsTitle')}

+ {commentsTotal} +
+ + {authed && currentUser && ( +
+ {currentUser.profile_image_url && ( + {currentUser.nickname} + )} + {currentUser.nickname} +
+ )} + +
+