Skip to content

Commit 45fefff

Browse files
committed
fix : suspense 오류 해결 및 video check page video 응답 연동
1 parent 152e9c4 commit 45fefff

9 files changed

Lines changed: 64 additions & 57 deletions

File tree

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
import { Suspense } from 'react';
22
import { InfoContents } from '../../_components/info/info-contents';
33
import { LoadingSpinner } from '@/components/loading-spinner';
4-
import { getStoreByUserClient } from '@/lib/api/store/store';
54
import { getStoreByUserServer } from '@/lib/api/store/store-server';
6-
import { QueryClient } from '@tanstack/react-query';
75

86
export default async function MyPageInfoPage() {
9-
const queryClient = new QueryClient();
10-
11-
await queryClient.prefetchQuery({
12-
queryKey: ['store-user'],
13-
queryFn: () => getStoreByUserServer(),
14-
staleTime: Infinity,
15-
});
7+
const storeData = await getStoreByUserServer();
168

179
return (
1810
<Suspense fallback={<LoadingSpinner />}>
19-
<InfoContents />
11+
<InfoContents initialStoreData={storeData} />
2012
</Suspense>
2113
);
2214
}
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import { getVideo } from '@/lib/api/video/video';
22
import { VideoPlayer } from '../../../_components/manage-video/video-player';
33

4-
export default async function VideoDetailPage({
5-
params,
6-
}: {
7-
params: Promise<{ video_id: string }>;
8-
}) {
9-
const videoId = (await params).video_id;
10-
console.log(videoId);
11-
// const videoInfo = await getVideo(videoId);
12-
4+
export default async function VideoDetailPage() {
5+
const videoId = localStorage.getItem('generatedVideoId');
6+
const videoInfo = await getVideo(videoId ?? '');
137
return (
148
<section className='py-6 w-full h-[calc(100vh-220px)] min-h-0'>
15-
<VideoPlayer />
9+
<VideoPlayer
10+
videoUrl={videoInfo.videoUrl ?? ''}
11+
videoId={videoId ?? ''}
12+
/>
1613
</section>
1714
);
1815
}
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { VideoCheckDescription } from '../../../../_components/manage-video/video-check-description';
22
import { cn } from '@/lib/utils/cn';
33
import { VideoCheckButton } from '../../../../_components/manage-video/video-check-button';
4+
import { getVideo } from '@/lib/api/video/video';
45

56
const VIDEO_URL =
67
'https://f002.backblazeb2.com/file/creatomate-c8xg3hsxdu/6683c14f-7d35-45ea-9402-d87fd498f5a7.mp4';
@@ -12,25 +13,25 @@ export default async function VideoCheckPage({
1213
params: Promise<{ video_id: string }>;
1314
}) {
1415
const videoId = (await params).video_id;
15-
console.log(videoId);
16+
const response = await getVideo(videoId);
1617

1718
return (
1819
<div className='pt-6 w-full h-full flex flex-col gap-6 min-h-0 overflow-y-auto custom-scrollbar'>
1920
<div className='w-full h-auto flex items-start gap-4'>
2021
<video
21-
src={VIDEO_URL}
22+
src={response.videoUrl}
2223
controls
2324
className='w-1/2 h-auto aspect-[160/284] rounded-[8px]'
2425
/>
2526
<div className='flex-1 w-full h-auto flex flex-col gap-2 '>
26-
<h4 className='text-headlineMedium text-gray500'>파일명</h4>
27+
<h4 className='text-headlineMedium text-gray500'>가게명</h4>
2728
<p className={cn('text-bodySmall text-gray600 !font-normal ')}>
28-
{VIDEO_FILE_NAME}
29+
{response.storeName}
2930
</p>
3031
</div>
3132
</div>
32-
<VideoCheckDescription />
33-
<VideoCheckButton videoUrl={VIDEO_URL} />
33+
<VideoCheckDescription video={response} />
34+
<VideoCheckButton videoUrl={response.videoUrl ?? ''} />
3435
</div>
3536
);
3637
}

src/app/(pages)/(main)/mypage/_components/info/info-contents.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ import { InfoOwner } from './info-owner';
1010
import { type StoreResponse } from '@/types/api';
1111
import { LoadingSpinnerBasic } from '@/components/loading-spinner';
1212

13-
export function InfoContents() {
13+
export function InfoContents({
14+
initialStoreData,
15+
}: {
16+
initialStoreData: StoreResponse[];
17+
}) {
1418
const { tabLabel, storeAdd } = useStoreQuery();
15-
const { data: storeData, isLoading } = useStoreByUser();
16-
17-
if (isLoading) return <LoadingSpinnerBasic />;
19+
const { data: storeData } = useStoreByUser(initialStoreData);
1820

1921
if (!storeData?.[0]) {
2022
return (

src/app/(pages)/(main)/mypage/_components/manage-video/video-check-description.tsx

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
import { FieldContainer } from '@/components/store-info';
2+
import { VideoResponse } from '@/types/api';
23

3-
const VideoDescription = [
4-
{
5-
label: '제목',
6-
value: '추천 멘트',
7-
},
8-
{
9-
label: '상세 설명',
10-
value:
11-
'📍 신촌에서 찾은 숨은 맛집, 가문의 우동!매일 직접 뽑는 쫄깃한 면발과 깊은 국물 맛이 일품이에요.\n따뜻한 우동 한 그릇으로 오늘 하루를 마무리해보세요🍲\n✅ 위치: 서울 서대문구 ○○로 ○○\n✅ 영업시간: 매일 11:00 ~ 21:00 (브레이크타임 15:00~17:00)\n✅ 전화: 02-000-0000\n#신촌맛집 #가문의우동 #우동맛집 #신촌데이트코스 #신촌점심추천 #신촌저녁추천 #신촌핫플 #서울맛집',
12-
},
13-
{
14-
label: '메뉴',
15-
value: '아메리카노\n라떼\n티\n커피라떼',
16-
},
17-
];
18-
19-
export function VideoCheckDescription() {
4+
export function VideoCheckDescription({ video }: { video: VideoResponse }) {
5+
const VideoDescription = [
6+
{
7+
label: '주소',
8+
value: video.address,
9+
},
10+
{
11+
label: '상호명',
12+
value: video.storeName,
13+
},
14+
{
15+
label: '비디오 생성시간',
16+
value: video.createdAt,
17+
},
18+
];
2019
return (
2120
<div className='flex flex-col items-start gap-8'>
2221
{VideoDescription.map(item => (
2322
<FieldContainer
2423
key={item.label}
2524
label={item.label}
26-
value={item.value}
25+
value={item.value ?? ''}
2726
/>
2827
))}
2928
</div>

src/app/(pages)/(main)/mypage/_components/manage-video/video-player.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
import { useState } from 'react';
44
import { LoadingSpinner } from '@/components/loading-spinner';
55
import { useRouter } from 'next/navigation';
6-
import type { VideoResponse } from '@/types/api';
76

8-
export function VideoPlayer() {
7+
export function VideoPlayer({
8+
videoUrl,
9+
videoId,
10+
}: {
11+
videoUrl: string;
12+
videoId: string;
13+
}) {
914
const router = useRouter();
10-
const videoUrl =
11-
'https://f002.backblazeb2.com/file/creatomate-c8xg3hsxdu/6683c14f-7d35-45ea-9402-d87fd498f5a7.mp4';
1215

1316
return (
1417
<>
@@ -40,7 +43,9 @@ export function VideoPlayer() {
4043
다시 만들기
4144
</button>
4245
<button
43-
onClick={() => router.push(`/mypage/manage-video/1/video-check`)}
46+
onClick={() =>
47+
router.push(`/mypage/manage-video/${videoId}/video-check`)
48+
}
4449
className='flex-1 w-full h-10 min-mobile:h-14 text-bodySmall rounded-[8px] bg-orange400 text-white000 cursor-pointer'
4550
>
4651
다음

src/app/(pages)/(main)/mypage/_components/manage-video/video-progress-header.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ export function VideoProgressHeader({
1010
}: {
1111
generationId: string;
1212
}) {
13-
const { status, progress, generatedVideoUrl, generatedVideoId } =
13+
const { status, progress, generatedVideoId } =
1414
useVideoGeneration(generationId);
15+
console.log(generatedVideoId);
1516

1617
return (
1718
<header className='mt-8 p-6 w-full h-auto flex flex-col items-start gap-1 bg-white000 border border-gray100 rounded-[15px] shadow-[0_4px_10px_0_rgba(154,159,160,0.15)]'>

src/hooks/use-video-generation.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { useState, useEffect } from 'react';
66
import { getVideoGenerationStatus } from '@/lib/api/video/video';
77

8-
export function useVideoGeneration(initialGenerationId: string) {
8+
export function useVideoGeneration(initialGenerationId?: string) {
99
const [generationId, setGenerationId] = useState<string | null>(null);
1010
const [generatedVideoUrl, setGeneratedVideoUrl] = useState<string | null>(
1111
null,
@@ -35,10 +35,11 @@ export function useVideoGeneration(initialGenerationId: string) {
3535
const poll = async () => {
3636
try {
3737
const result = await getVideoGenerationStatus(generationId);
38-
console.log('result:', result);
38+
console.log(result);
3939
setStatus(result.status ?? 'IDLE');
4040
setGeneratedVideoUrl(result.generatedVideoUrl ?? null);
41-
setGeneratedVideoId(result.videoGenerationId ?? null);
41+
setGeneratedVideoId(result.video?.id ?? null);
42+
localStorage.setItem('generatedVideoId', result.video?.id ?? '');
4243

4344
// 상태별 프로그레스
4445
const progressMap = {

src/types/api/videoGenerationStatusResponse.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* OpenAPI spec version: 1.0
77
*/
88
import type { VideoGenerationStatusResponseStatus } from './videoGenerationStatusResponseStatus';
9+
import { VideoResponse } from './videoResponse';
910

1011
/**
1112
* 영상 생성 상태 응답
@@ -21,4 +22,12 @@ export interface VideoGenerationStatusResponse {
2122
generatedVideoUrl?: string;
2223
/** 오류 메시지 */
2324
errorMessage?: string;
25+
video?: {
26+
id: string;
27+
videoUrl: string;
28+
address: string;
29+
storeName: string;
30+
views: number;
31+
createdAt: string;
32+
};
2433
}

0 commit comments

Comments
 (0)