feat(ssulbox): 썰박스 진입 탭·생성 플로우와 통합 콘텐츠 목록 분기

This commit is contained in:
skkim committed 2026-08-11 14:57:33 +09:00
1 parent c4c46db0d9
commit bb0ab91bcc
26 files changed
+2793 -119

No files matched your search

+128
View File
@@ -0,0 +1,128 @@
import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { VideoListItem } from '../../types/api';
interface SsulViewerModalProps {
/** null 이면 닫힘 */
item: VideoListItem | null;
onClose: () => void;
}
/**
* 썰박스 콘텐츠 뷰어.
*
* **castad `VideoDetailModal` 과 같은 형식**을 쓴다 — 백드롭·패널 인라인 스타일과
* `video-detail-*` 클래스를 그대로 재사용하므로 통합 목록에서 어떤 카드를 열든
* 같은 모양이 나온다. 신규 CSS 를 만들지 않는다.
*
* 컴포넌트를 그대로 못 쓰는 이유: `VideoDetailModal` 은 `videoId` 로 `/video/{id}` 를
* 조회하는데, 썰박스 id 를 넘기면 **id 가 겹치는 다른 ADO2 영상**이 열린다
* (`video.id` 와 `ssul_content.id` 는 각각 1부터 시작하는 독립 시퀀스).
* 목록이 이미 재생에 필요한 정보를 갖고 있어 추가 조회도 필요 없다.
*
* 좋아요·댓글·공유는 castad API 를 video_id 로 호출하므로 여기서는 빼 뒀다.
* `/ssul/*` 반응 API 가 붙으면 추가한다.
*/
const SsulViewerModal: React.FC<SsulViewerModalProps> = ({ item, onClose }) => {
const { t } = useTranslation();
// 가로 영상이면 castad 와 동일하게 landscape 레이아웃으로 전환한다
const [isLandscape, setIsLandscape] = useState(false);
useEffect(() => {
if (!item) return;
// 모달 열릴 때 배경 스크롤 잠금
const prev = document.body.style.overflow;
document.body.style.overflow = 'hidden';
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape') onClose();
};
document.addEventListener('keydown', handleKeyDown);
return () => {
document.body.style.overflow = prev;
document.removeEventListener('keydown', handleKeyDown);
};
}, [item, onClose]);
// 다른 콘텐츠를 열면 방향 판정을 초기화한다(이전 값이 남으면 레이아웃이 틀어진다)
useEffect(() => {
setIsLandscape(false);
}, [item?.type, item?.video_id]);
if (!item) return null;
const formatDate = (value?: string) => {
if (!value) return '';
const d = new Date(value);
return `${d.getFullYear()}.${String(d.getMonth() + 1).padStart(2, '0')}.${String(
d.getDate()
).padStart(2, '0')}`;
};
return (
<div
style={{
position: 'fixed',
inset: 0,
background: 'rgba(0, 0, 0, 0.85)',
zIndex: 2000,
display: 'flex',
overflowY: 'auto',
padding: '24px 16px',
}}
onClick={onClose}
>
<div
style={{
background: '#01282A',
borderRadius: '16px',
width: '100%',
maxWidth: '800px',
margin: 'auto',
position: 'relative',
}}
onClick={(e) => e.stopPropagation()}
>
<div className="video-detail-modal-content">
{/* 헤더 */}
<div className="video-detail-header">
<button
className="video-detail-close-btn"
onClick={onClose}
aria-label={t('videoDetail.closeAriaLabel')}
>
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />
</svg>
</button>
</div>
<div className={`video-detail-content ${isLandscape ? 'landscape' : ''}`}>
<video
src={item.result_movie_url}
controls
autoPlay
controlsList="nodownload"
onContextMenu={(e) => e.preventDefault()}
className="video-detail-player"
onLoadedMetadata={(e) => {
const v = e.currentTarget;
setIsLandscape(v.videoWidth > v.videoHeight);
}}
/>
<div className="video-detail-info">
<h2 className="video-detail-store">
{item.store_name || t('ssulbox.viewer.untitled')}
</h2>
<p className="video-detail-date">{formatDate(item.created_at)}</p>
</div>
</div>
</div>
</div>
</div>
);
};
export default SsulViewerModal;