feat: 영상 공유·포스터 썸네일·좋아요 상태를 서버 연동으로 전환
This commit is contained in:
1 parent
9c0c3de35f
commit
3566c1f7bc
10 files changed
+146
-69
No files matched your search
@@ -1,12 +1,14 @@
|
|||||||
import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { toggleVideoLike } from '../utils/api';
|
import { API_URL, toggleVideoLike } from '../utils/api';
|
||||||
|
import { buildVideoShareUrl, tryNativeShare } from '../utils/nativeShare';
|
||||||
|
|
||||||
interface ContentCardSocialActionsProps {
|
interface ContentCardSocialActionsProps {
|
||||||
videoId: number;
|
videoId: number;
|
||||||
storeName: string;
|
storeName: string;
|
||||||
region?: string;
|
region?: string;
|
||||||
|
posterUrl?: string | null;
|
||||||
commentCount: number;
|
commentCount: number;
|
||||||
initialLikeCount: number;
|
initialLikeCount: number;
|
||||||
initialIsLiked?: boolean;
|
initialIsLiked?: boolean;
|
||||||
@@ -16,6 +18,7 @@ const ContentCardSocialActions: React.FC<ContentCardSocialActionsProps> = ({
|
|||||||
videoId,
|
videoId,
|
||||||
storeName,
|
storeName,
|
||||||
region,
|
region,
|
||||||
|
posterUrl,
|
||||||
commentCount,
|
commentCount,
|
||||||
initialLikeCount,
|
initialLikeCount,
|
||||||
initialIsLiked = false,
|
initialIsLiked = false,
|
||||||
@@ -33,7 +36,11 @@ const ContentCardSocialActions: React.FC<ContentCardSocialActionsProps> = ({
|
|||||||
const shareMenuRef = useRef<HTMLDivElement>(null);
|
const shareMenuRef = useRef<HTMLDivElement>(null);
|
||||||
const likeDebounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
const likeDebounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
|
|
||||||
const shareUrl = `${window.location.origin}/video/${videoId}`;
|
const videoPageUrl = `${window.location.origin}/video/${videoId}`;
|
||||||
|
const shareUrl = buildVideoShareUrl(API_URL, videoId);
|
||||||
|
const shareTitle = storeName || t('videoDetail.kakaoDefaultTitle');
|
||||||
|
const shareDescription = t('videoDetail.kakaoDescription', { region: region ?? '' });
|
||||||
|
const shareImageUrl = posterUrl || `${window.location.origin}/assets/images/hero-background.png`;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!shareMenuOpen) return;
|
if (!shareMenuOpen) return;
|
||||||
@@ -96,15 +103,15 @@ const ContentCardSocialActions: React.FC<ContentCardSocialActionsProps> = ({
|
|||||||
kakao.Share.sendDefault({
|
kakao.Share.sendDefault({
|
||||||
objectType: 'feed',
|
objectType: 'feed',
|
||||||
content: {
|
content: {
|
||||||
title: storeName || t('videoDetail.kakaoDefaultTitle'),
|
title: shareTitle,
|
||||||
description: t('videoDetail.kakaoDescription', { region: region ?? '' }),
|
description: shareDescription,
|
||||||
imageUrl: 'https://ado2.o2osolution.ai/favicon_48.svg',
|
imageUrl: shareImageUrl,
|
||||||
link: { mobileWebUrl: shareUrl, webUrl: shareUrl },
|
link: { mobileWebUrl: videoPageUrl, webUrl: videoPageUrl },
|
||||||
},
|
},
|
||||||
buttons: [{ title: t('videoDetail.kakaoButtonTitle'), link: { mobileWebUrl: shareUrl, webUrl: shareUrl } }],
|
buttons: [{ title: t('videoDetail.kakaoButtonTitle'), link: { mobileWebUrl: videoPageUrl, webUrl: videoPageUrl } }],
|
||||||
});
|
});
|
||||||
} else if (navigator.share) {
|
} else if (navigator.share) {
|
||||||
navigator.share({ url: shareUrl }).catch(() => {});
|
navigator.share({ title: shareTitle, text: shareDescription, url: shareUrl }).catch(() => {});
|
||||||
} else {
|
} else {
|
||||||
handleCopyLink();
|
handleCopyLink();
|
||||||
}
|
}
|
||||||
@@ -144,8 +151,19 @@ const ContentCardSocialActions: React.FC<ContentCardSocialActionsProps> = ({
|
|||||||
}, 500);
|
}, 500);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleShareBtnClick = (e: React.MouseEvent) => {
|
const handleShareBtnClick = async (e: React.MouseEvent) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
|
const handled = await tryNativeShare({
|
||||||
|
title: shareTitle,
|
||||||
|
text: shareDescription,
|
||||||
|
url: shareUrl,
|
||||||
|
});
|
||||||
|
if (handled) {
|
||||||
|
setShareMenuOpen(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const rect = shareBtnRef.current?.getBoundingClientRect();
|
const rect = shareBtnRef.current?.getBoundingClientRect();
|
||||||
if (rect) {
|
if (rect) {
|
||||||
// 초기 추정 위치(측정 전 첫 렌더용) — useLayoutEffect가 실제 크기 기준으로 다시 보정한다
|
// 초기 추정 위치(측정 전 첫 렌더용) — useLayoutEffect가 실제 크기 기준으로 다시 보정한다
|
||||||
|
|||||||
@@ -7,8 +7,11 @@ import {
|
|||||||
deleteComment,
|
deleteComment,
|
||||||
toggleVideoLike,
|
toggleVideoLike,
|
||||||
isLoggedIn,
|
isLoggedIn,
|
||||||
|
getUserMe,
|
||||||
|
API_URL,
|
||||||
} from '../utils/api';
|
} from '../utils/api';
|
||||||
import { VideoDetailItem, CommentItem } from '../types/api';
|
import { VideoDetailItem, CommentItem, UserMeResponse } from '../types/api';
|
||||||
|
import { buildVideoShareUrl, tryNativeShare } from '../utils/nativeShare';
|
||||||
import LoginPromptModal from './LoginPromptModal';
|
import LoginPromptModal from './LoginPromptModal';
|
||||||
|
|
||||||
interface VideoDetailContentProps {
|
interface VideoDetailContentProps {
|
||||||
@@ -42,16 +45,7 @@ const VideoDetailContent: React.FC<VideoDetailContentProps> = ({ videoId, isModa
|
|||||||
const [commentSubmitting, setCommentSubmitting] = useState(false);
|
const [commentSubmitting, setCommentSubmitting] = useState(false);
|
||||||
const commentTextareaRef = useRef<HTMLTextAreaElement>(null);
|
const commentTextareaRef = useRef<HTMLTextAreaElement>(null);
|
||||||
|
|
||||||
const [commentNickname, setCommentNickname] = useState('');
|
const [currentUser, setCurrentUser] = useState<UserMeResponse | null>(null);
|
||||||
const [commentAvatarSeedIdx, setCommentAvatarSeedIdx] = useState(0);
|
|
||||||
|
|
||||||
// 고정 seed 목록: 브라우저가 캐싱하여 중복 요청 없음
|
|
||||||
const AVATAR_SEEDS = ['42', '77', '123', '256', '512', '888', '1024', '2048', '3141', '9999'];
|
|
||||||
const commentAvatarSeed = AVATAR_SEEDS[commentAvatarSeedIdx % AVATAR_SEEDS.length];
|
|
||||||
|
|
||||||
const handleChangeAvatar = useCallback(() => {
|
|
||||||
setCommentAvatarSeedIdx(prev => (prev + 1) % AVATAR_SEEDS.length);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const fetchComments = useCallback(async (page: number, append = false) => {
|
const fetchComments = useCallback(async (page: number, append = false) => {
|
||||||
setCommentsLoading(true);
|
setCommentsLoading(true);
|
||||||
@@ -92,6 +86,13 @@ const VideoDetailContent: React.FC<VideoDetailContentProps> = ({ videoId, isModa
|
|||||||
fetchComments(1);
|
fetchComments(1);
|
||||||
}, [videoId, fetchComments]);
|
}, [videoId, fetchComments]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!authed) return;
|
||||||
|
getUserMe().then(setCurrentUser).catch((err) => {
|
||||||
|
console.error('Failed to fetch current user:', err);
|
||||||
|
});
|
||||||
|
}, [authed]);
|
||||||
|
|
||||||
const formatDate = (dateString: string) => {
|
const formatDate = (dateString: string) => {
|
||||||
const date = new Date(dateString);
|
const date = new Date(dateString);
|
||||||
return t('videoDetail.dateFormat', { year: date.getFullYear(), month: date.getMonth() + 1, day: date.getDate() });
|
return t('videoDetail.dateFormat', { year: date.getFullYear(), month: date.getMonth() + 1, day: date.getDate() });
|
||||||
@@ -102,7 +103,11 @@ const VideoDetailContent: React.FC<VideoDetailContentProps> = ({ videoId, isModa
|
|||||||
return `${date.getFullYear()}.${String(date.getMonth() + 1).padStart(2, '0')}.${String(date.getDate()).padStart(2, '0')}`;
|
return `${date.getFullYear()}.${String(date.getMonth() + 1).padStart(2, '0')}.${String(date.getDate()).padStart(2, '0')}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const shareUrl = `${window.location.origin}/video/${videoId}`;
|
const videoPageUrl = `${window.location.origin}/video/${videoId}`;
|
||||||
|
const shareUrl = buildVideoShareUrl(API_URL, videoId);
|
||||||
|
const shareTitle = video?.store_name ?? t('videoDetail.kakaoDefaultTitle');
|
||||||
|
const shareDescription = t('videoDetail.kakaoDescription', { region: video?.region ?? '' });
|
||||||
|
const shareImageUrl = video?.poster_url || `${window.location.origin}/assets/images/hero-background.png`;
|
||||||
|
|
||||||
const handleCopyLink = async () => {
|
const handleCopyLink = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -120,15 +125,15 @@ const VideoDetailContent: React.FC<VideoDetailContentProps> = ({ videoId, isModa
|
|||||||
kakao.Share.sendDefault({
|
kakao.Share.sendDefault({
|
||||||
objectType: 'feed',
|
objectType: 'feed',
|
||||||
content: {
|
content: {
|
||||||
title: video?.store_name ?? t('videoDetail.kakaoDefaultTitle'),
|
title: shareTitle,
|
||||||
description: t('videoDetail.kakaoDescription', { region: video?.region ?? '' }),
|
description: shareDescription,
|
||||||
imageUrl: 'https://ado2.o2osolution.ai/favicon_48.svg',
|
imageUrl: shareImageUrl,
|
||||||
link: { mobileWebUrl: shareUrl, webUrl: shareUrl },
|
link: { mobileWebUrl: videoPageUrl, webUrl: videoPageUrl },
|
||||||
},
|
},
|
||||||
buttons: [{ title: t('videoDetail.kakaoButtonTitle'), link: { mobileWebUrl: shareUrl, webUrl: shareUrl } }],
|
buttons: [{ title: t('videoDetail.kakaoButtonTitle'), link: { mobileWebUrl: videoPageUrl, webUrl: videoPageUrl } }],
|
||||||
});
|
});
|
||||||
} else if (navigator.share) {
|
} else if (navigator.share) {
|
||||||
navigator.share({ url: shareUrl }).catch(() => {});
|
navigator.share({ title: shareTitle, text: shareDescription, url: shareUrl }).catch(() => {});
|
||||||
} else {
|
} else {
|
||||||
handleCopyLink();
|
handleCopyLink();
|
||||||
}
|
}
|
||||||
@@ -147,6 +152,20 @@ const VideoDetailContent: React.FC<VideoDetailContentProps> = ({ videoId, isModa
|
|||||||
|
|
||||||
const shareMenuRef = React.useRef<HTMLDivElement>(null);
|
const shareMenuRef = React.useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
const handleShareButtonClick = async () => {
|
||||||
|
const handled = await tryNativeShare({
|
||||||
|
title: shareTitle,
|
||||||
|
text: shareDescription,
|
||||||
|
url: shareUrl,
|
||||||
|
});
|
||||||
|
if (handled) {
|
||||||
|
setShareMenuOpen(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setShareMenuOpen((open) => !open);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!shareMenuOpen) return;
|
if (!shareMenuOpen) return;
|
||||||
const handleClickOutside = (e: MouseEvent) => {
|
const handleClickOutside = (e: MouseEvent) => {
|
||||||
@@ -197,13 +216,11 @@ const VideoDetailContent: React.FC<VideoDetailContentProps> = ({ videoId, isModa
|
|||||||
if (!commentInput.trim() || commentSubmitting) return;
|
if (!commentInput.trim() || commentSubmitting) return;
|
||||||
setCommentSubmitting(true);
|
setCommentSubmitting(true);
|
||||||
try {
|
try {
|
||||||
await postVideoComment(videoId, commentInput.trim(), commentNickname);
|
await postVideoComment(videoId, commentInput.trim());
|
||||||
setCommentInput('');
|
setCommentInput('');
|
||||||
if (commentTextareaRef.current) {
|
if (commentTextareaRef.current) {
|
||||||
commentTextareaRef.current.style.height = 'auto';
|
commentTextareaRef.current.style.height = 'auto';
|
||||||
}
|
}
|
||||||
setCommentNickname('');
|
|
||||||
setCommentAvatarSeedIdx(prev => (prev + 1) % AVATAR_SEEDS.length);
|
|
||||||
await fetchComments(1);
|
await fetchComments(1);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to post comment:', err);
|
console.error('Failed to post comment:', err);
|
||||||
@@ -287,7 +304,7 @@ const VideoDetailContent: React.FC<VideoDetailContentProps> = ({ videoId, isModa
|
|||||||
<div style={{ position: 'relative' }} ref={shareMenuRef}>
|
<div style={{ position: 'relative' }} ref={shareMenuRef}>
|
||||||
<button
|
<button
|
||||||
className="video-detail-copy-btn"
|
className="video-detail-copy-btn"
|
||||||
onClick={() => setShareMenuOpen(v => !v)}
|
onClick={handleShareButtonClick}
|
||||||
>
|
>
|
||||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
||||||
<circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/>
|
<circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/>
|
||||||
@@ -339,25 +356,17 @@ const VideoDetailContent: React.FC<VideoDetailContentProps> = ({ videoId, isModa
|
|||||||
<span className="video-detail-comments-count">{commentsTotal}</span>
|
<span className="video-detail-comments-count">{commentsTotal}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 댓글 작성자 프로필 선택 */}
|
{/* 댓글 작성자 프로필 (카카오 로그인 정보) */}
|
||||||
{authed && (
|
{authed && currentUser && (
|
||||||
<div className="video-detail-comment-profile">
|
<div className="video-detail-comment-profile">
|
||||||
<img
|
{currentUser.profile_image_url && (
|
||||||
src={`https://api.dicebear.com/9.x/pixel-art/svg?seed=${commentAvatarSeed}`}
|
<img
|
||||||
alt={t('videoDetail.changeAvatarTitle')}
|
src={currentUser.profile_image_url}
|
||||||
className="video-detail-comment-avatar"
|
alt={currentUser.nickname}
|
||||||
onClick={handleChangeAvatar}
|
className="video-detail-comment-avatar"
|
||||||
style={{ cursor: 'pointer' }}
|
/>
|
||||||
title={t('videoDetail.changeAvatarTitle')}
|
)}
|
||||||
/>
|
<span className="video-detail-comment-nickname">{currentUser.nickname}</span>
|
||||||
<input
|
|
||||||
className="video-detail-nickname-input"
|
|
||||||
type="text"
|
|
||||||
placeholder={t('videoDetail.nicknamePlaceholder')}
|
|
||||||
value={commentNickname}
|
|
||||||
onChange={(e) => setCommentNickname(e.target.value)}
|
|
||||||
maxLength={20}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -398,11 +407,13 @@ const VideoDetailContent: React.FC<VideoDetailContentProps> = ({ videoId, isModa
|
|||||||
<ul className="video-detail-comment-list">
|
<ul className="video-detail-comment-list">
|
||||||
{comments.map((c) => (
|
{comments.map((c) => (
|
||||||
<li key={c.id} className="video-detail-comment-item">
|
<li key={c.id} className="video-detail-comment-item">
|
||||||
<img
|
{c.profile_image_url && (
|
||||||
src={`https://api.dicebear.com/9.x/pixel-art/svg?seed=${c.id}`}
|
<img
|
||||||
alt="avatar"
|
src={c.profile_image_url}
|
||||||
className="video-detail-comment-avatar"
|
alt={c.nickname || t('videoDetail.anonymous')}
|
||||||
/>
|
className="video-detail-comment-avatar"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<div className="video-detail-comment-body">
|
<div className="video-detail-comment-body">
|
||||||
<span className="video-detail-comment-nickname">
|
<span className="video-detail-comment-nickname">
|
||||||
{c.nickname || t('videoDetail.anonymous')}
|
{c.nickname || t('videoDetail.anonymous')}
|
||||||
@@ -427,11 +438,13 @@ const VideoDetailContent: React.FC<VideoDetailContentProps> = ({ videoId, isModa
|
|||||||
<ul className="video-detail-reply-list">
|
<ul className="video-detail-reply-list">
|
||||||
{c.replies.map((r) => (
|
{c.replies.map((r) => (
|
||||||
<li key={r.id} className="video-detail-reply-item">
|
<li key={r.id} className="video-detail-reply-item">
|
||||||
<img
|
{r.profile_image_url && (
|
||||||
src={`https://api.dicebear.com/9.x/pixel-art/svg?seed=${r.id}`}
|
<img
|
||||||
alt="avatar"
|
src={r.profile_image_url}
|
||||||
className="video-detail-comment-avatar small"
|
alt={r.nickname || t('videoDetail.anonymous')}
|
||||||
/>
|
className="video-detail-comment-avatar small"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<div className="video-detail-comment-body">
|
<div className="video-detail-comment-body">
|
||||||
<span className="video-detail-comment-nickname">
|
<span className="video-detail-comment-nickname">
|
||||||
{r.nickname || t('videoDetail.anonymous')}
|
{r.nickname || t('videoDetail.anonymous')}
|
||||||
|
|||||||
@@ -630,8 +630,6 @@
|
|||||||
"shareTwitter": "X (Twitter)",
|
"shareTwitter": "X (Twitter)",
|
||||||
"copyUrl": "Copy URL",
|
"copyUrl": "Copy URL",
|
||||||
"commentsTitle": "Comments",
|
"commentsTitle": "Comments",
|
||||||
"changeAvatarTitle": "Click to change avatar",
|
|
||||||
"nicknamePlaceholder": "Author name",
|
|
||||||
"commentPlaceholder": "Write a comment...",
|
"commentPlaceholder": "Write a comment...",
|
||||||
"commentLoginRequired": "Please log in to write a comment",
|
"commentLoginRequired": "Please log in to write a comment",
|
||||||
"commentSubmitting": "Submitting",
|
"commentSubmitting": "Submitting",
|
||||||
|
|||||||
@@ -629,8 +629,6 @@
|
|||||||
"shareTwitter": "X (트위터)",
|
"shareTwitter": "X (트위터)",
|
||||||
"copyUrl": "URL 복사",
|
"copyUrl": "URL 복사",
|
||||||
"commentsTitle": "댓글",
|
"commentsTitle": "댓글",
|
||||||
"changeAvatarTitle": "클릭하여 아바타 변경",
|
|
||||||
"nicknamePlaceholder": "작성자 이름",
|
|
||||||
"commentPlaceholder": "댓글을 입력하세요...",
|
"commentPlaceholder": "댓글을 입력하세요...",
|
||||||
"commentLoginRequired": "로그인 후 댓글을 작성할 수 있습니다",
|
"commentLoginRequired": "로그인 후 댓글을 작성할 수 있습니다",
|
||||||
"commentSubmitting": "작성 중",
|
"commentSubmitting": "작성 중",
|
||||||
|
|||||||
@@ -151,7 +151,15 @@ const ADO2ContentsPage: React.FC<ADO2ContentsPageProps> = () => {
|
|||||||
onKeyDown={(e) => e.key === 'Enter' && handleCardClick(video.video_id)}
|
onKeyDown={(e) => e.key === 'Enter' && handleCardClick(video.video_id)}
|
||||||
>
|
>
|
||||||
<div className="content-card-thumbnail ado2-gallery-thumbnail-wrap">
|
<div className="content-card-thumbnail ado2-gallery-thumbnail-wrap">
|
||||||
{video.thumbnail_url ? (
|
{video.poster_url ? (
|
||||||
|
<img
|
||||||
|
src={video.poster_url}
|
||||||
|
alt={video.store_name}
|
||||||
|
loading="lazy"
|
||||||
|
decoding="async"
|
||||||
|
className="content-video-preview"
|
||||||
|
/>
|
||||||
|
) : video.thumbnail_url ? (
|
||||||
<img
|
<img
|
||||||
src={video.thumbnail_url}
|
src={video.thumbnail_url}
|
||||||
alt={video.store_name}
|
alt={video.store_name}
|
||||||
@@ -186,6 +194,7 @@ const ADO2ContentsPage: React.FC<ADO2ContentsPageProps> = () => {
|
|||||||
videoId={video.video_id}
|
videoId={video.video_id}
|
||||||
storeName={video.store_name}
|
storeName={video.store_name}
|
||||||
region={video.region}
|
region={video.region}
|
||||||
|
posterUrl={video.poster_url}
|
||||||
commentCount={video.comment_count ?? 0}
|
commentCount={video.comment_count ?? 0}
|
||||||
initialLikeCount={video.like_count ?? 0}
|
initialLikeCount={video.like_count ?? 0}
|
||||||
initialIsLiked={video.is_liked_by_me}
|
initialIsLiked={video.is_liked_by_me}
|
||||||
|
|||||||
@@ -563,6 +563,7 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
|
|||||||
created_at: new Date().toISOString(),
|
created_at: new Date().toISOString(),
|
||||||
like_count: 0,
|
like_count: 0,
|
||||||
comment_count: 0,
|
comment_count: 0,
|
||||||
|
is_liked_by_me: false,
|
||||||
} : null}
|
} : null}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -248,7 +248,15 @@ const MyContentsPage: React.FC<MyContentsPageProps> = ({ onNavigate }) => {
|
|||||||
style={{ cursor: 'pointer' }}
|
style={{ cursor: 'pointer' }}
|
||||||
onClick={() => setSelectedVideoId(video.video_id)}
|
onClick={() => setSelectedVideoId(video.video_id)}
|
||||||
>
|
>
|
||||||
{video.result_movie_url ? (
|
{video.poster_url ? (
|
||||||
|
<img
|
||||||
|
src={video.poster_url}
|
||||||
|
alt={video.store_name}
|
||||||
|
loading="lazy"
|
||||||
|
decoding="async"
|
||||||
|
className="content-video-preview"
|
||||||
|
/>
|
||||||
|
) : video.result_movie_url ? (
|
||||||
<VideoPreviewCard
|
<VideoPreviewCard
|
||||||
src={video.result_movie_url}
|
src={video.result_movie_url}
|
||||||
className="content-video-preview"
|
className="content-video-preview"
|
||||||
@@ -283,6 +291,7 @@ const MyContentsPage: React.FC<MyContentsPageProps> = ({ onNavigate }) => {
|
|||||||
videoId={video.video_id}
|
videoId={video.video_id}
|
||||||
storeName={video.store_name}
|
storeName={video.store_name}
|
||||||
region={video.region}
|
region={video.region}
|
||||||
|
posterUrl={video.poster_url}
|
||||||
commentCount={video.comment_count ?? 0}
|
commentCount={video.comment_count ?? 0}
|
||||||
initialLikeCount={video.like_count ?? 0}
|
initialLikeCount={video.like_count ?? 0}
|
||||||
initialIsLiked={video.is_liked_by_me}
|
initialIsLiked={video.is_liked_by_me}
|
||||||
|
|||||||
+5
-1
@@ -276,17 +276,19 @@ export interface VideoListItem {
|
|||||||
region: string;
|
region: string;
|
||||||
task_id: string;
|
task_id: string;
|
||||||
result_movie_url: string;
|
result_movie_url: string;
|
||||||
|
poster_url?: string | null;
|
||||||
thumbnail_url?: string;
|
thumbnail_url?: string;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
like_count: number;
|
like_count: number;
|
||||||
comment_count: number;
|
comment_count: number;
|
||||||
is_liked_by_me?: boolean;
|
is_liked_by_me: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 비디오 상세 아이템
|
// 비디오 상세 아이템
|
||||||
export interface VideoDetailItem {
|
export interface VideoDetailItem {
|
||||||
video_id: number;
|
video_id: number;
|
||||||
result_movie_url: string;
|
result_movie_url: string;
|
||||||
|
poster_url?: string | null;
|
||||||
store_name: string;
|
store_name: string;
|
||||||
region: string;
|
region: string;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
@@ -309,6 +311,7 @@ export interface VideosListResponse {
|
|||||||
export interface CommentReply {
|
export interface CommentReply {
|
||||||
id: number;
|
id: number;
|
||||||
nickname: string;
|
nickname: string;
|
||||||
|
profile_image_url: string | null;
|
||||||
content: string | null;
|
content: string | null;
|
||||||
is_deleted: boolean;
|
is_deleted: boolean;
|
||||||
is_mine: boolean;
|
is_mine: boolean;
|
||||||
@@ -319,6 +322,7 @@ export interface CommentReply {
|
|||||||
export interface CommentItem {
|
export interface CommentItem {
|
||||||
id: number;
|
id: number;
|
||||||
nickname: string;
|
nickname: string;
|
||||||
|
profile_image_url: string | null;
|
||||||
content: string | null;
|
content: string | null;
|
||||||
is_deleted: boolean;
|
is_deleted: boolean;
|
||||||
is_mine: boolean;
|
is_mine: boolean;
|
||||||
|
|||||||
+3
-3
@@ -609,12 +609,12 @@ export async function getVideoComments(videoId: string, page: number = 1, pageSi
|
|||||||
return response.json();
|
return response.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 댓글 작성
|
// 댓글 작성 (작성자 닉네임/프로필은 서버가 로그인된 카카오 정보로 채움)
|
||||||
export async function postVideoComment(videoId: string, content: string, nickname?: string, parentId?: number): Promise<CommentItem> {
|
export async function postVideoComment(videoId: string, content: string, parentId?: number): Promise<CommentItem> {
|
||||||
const response = await authenticatedFetch(`${API_URL}/comment/video/${videoId}`, {
|
const response = await authenticatedFetch(`${API_URL}/comment/video/${videoId}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ content, nickname: nickname || '익명', parent_id: parentId ?? null }),
|
body: JSON.stringify({ content, parent_id: parentId ?? null }),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* 기기의 네이티브 공유 시트를 열고 요청을 처리했는지 반환합니다.
|
||||||
|
*
|
||||||
|
* 사용자가 공유 시트를 닫은 경우도 정상적으로 처리된 것으로 간주해
|
||||||
|
* 별도의 공유 메뉴가 뒤이어 열리지 않도록 합니다.
|
||||||
|
*/
|
||||||
|
export async function tryNativeShare(data: ShareData): Promise<boolean> {
|
||||||
|
if (typeof navigator.share !== 'function') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await navigator.share(data);
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof Error && error.name === 'AbortError') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** API 서버가 제공하는 영상별 Open Graph 공유 페이지 URL을 만듭니다. */
|
||||||
|
export function buildVideoShareUrl(apiBaseUrl: string, videoId: number | string): string {
|
||||||
|
return `${apiBaseUrl.replace(/\/$/, '')}/video/share/${encodeURIComponent(String(videoId))}`;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user