1
1
import Button from "@Components/button/Button" ;
2
- import Templates from "@Constant/templates" ;
2
+ import IconCat from "@Components/icons/IconCat" ;
3
+ import IconSound from "@Components/icons/IconSound" ;
4
+ import VideoPlayer from "@Components/video/VideoPlayer" ;
5
+ import useLateTemplate from "@Hooks/useLateTemplate" ;
6
+ import useVideo from "@Hooks/useVideo" ;
7
+ import { mergeClassName } from "@Utils/styleExtension" ;
3
8
import { useNavigate , useParams } from "react-router-dom" ;
4
9
5
10
export default function PreparePage ( ) {
6
- const { templateId } = useParams ( ) ;
7
11
const navigate = useNavigate ( ) ;
8
12
9
- // @ts -expect-error
10
- const templateInfo : ( typeof Templates ) [ "id1" ] = Templates ?. [ templateId ] ;
13
+ const { templateId } = useParams ( ) ;
14
+ const templateQuery = useLateTemplate ( ) ;
15
+
16
+ const { isMuted, toggleMute } = useVideo ( { defaultMuted : false } ) ;
11
17
12
- if ( ! templateInfo ) {
13
- throw new Error ( "invalid template id" ) ;
14
- }
18
+ if ( templateQuery . status === "pending" ) return < div > loading</ div > ;
19
+ if ( templateQuery . status === "error" ) return < div > error</ div > ;
20
+
21
+ const template = templateQuery . data . find (
22
+ ( template ) => template . id === templateId
23
+ ) ;
24
+
25
+ if ( ! template || template . state !== "ready" ) return < div > error</ div > ;
15
26
16
27
const goBack = ( ) => navigate ( - 1 ) ;
17
28
const goShooting = ( ) => navigate ( `/shooting/${ templateId } ` ) ;
18
29
19
- const { label, title, description, src } = templateInfo ;
20
-
21
30
return (
22
31
< div className = "w-full h-full flex flex-col justify-between" >
23
32
< div className = "relative w-full overflow-hidden max-h-full" >
24
- < img className = "w-full h-full" src = { src } />
25
- < div className = "absolute top-0 flex flex-col w-full h-full py-[24px] px-[16px] justify-between" >
33
+ < VideoPlayer src = { template . previewVideoSrc } muted = { isMuted } />
34
+
35
+ < div className = "absolute top-0 flex flex-col w-full h-full py-[24px] px-[16px] justify-between pointer-events-none" >
26
36
< div className = "flex flex-row justify-between" >
27
37
< button
28
- className = "flex flex-row items-center gap-[8px]"
38
+ className = "flex flex-row items-center gap-[8px] pointer-events-auto "
29
39
onClick = { goBack }
30
40
>
31
41
< div >
32
42
< BackIcon />
33
43
</ div >
34
44
< div className = "font-yClover text-white font-bold" > 뒤로가기</ div >
35
45
</ button >
36
- < button className = "flex justify-center items-center w-[40px] h-[40px] bg-[rgba(255,255,255,0.25)] rounded-[8px]" >
46
+ < button
47
+ className = { mergeClassName (
48
+ "flex justify-center items-center w-[40px] h-[40px] bg-[rgba(255,255,255,0.25)] rounded-[8px] pointer-events-auto"
49
+ ) }
50
+ onClick = { toggleMute }
51
+ >
37
52
< IconSound />
38
53
</ button >
39
54
</ div >
40
- < div className = "flex flex-col gap-[20px]" >
41
- < div className = "flex flex-col gap-[8px]" >
42
- < div className = "py-[4px] px-[8px] w-fit rounded-full bg-[#FCD55F] font-yClover font-bold text-[#191919]" >
43
- { label }
44
- </ div >
45
- < div className = "font-yClover font-bold text-white leading-5" >
46
- { title }
47
- </ div >
48
- </ div >
49
- < div className = "flex flex-col gap-[8px] font-yClover font-regular text-white" >
50
- { description . map ( ( item ) => (
51
- < div key = { item } > { item } </ div >
52
- ) ) }
55
+ < div className = "flex flex-col gap-[8px]" >
56
+ < p className = "font-yClover font-bold text-[24px] text-white leading-[120%]" >
57
+ { template . title }
58
+ </ p >
59
+ < div className = "flex flex-1 gap-[8px]" >
60
+ < IconCat />
61
+ < p className = "flex flex-col w-full gap-[8px] font-yClover font-normal text-[14px] leading-[140%] text-white whitespace-pre-line" >
62
+ { template . description }
63
+ </ p >
53
64
</ div >
54
65
</ div >
55
66
</ div >
56
67
</ div >
57
- < div className = "flex flex-row items-center pt-[52px] pb-[40px] px-[16px] gap-[16px] justify-center" >
58
- < Button className = "w-full" variant = { "primary" } onClick = { goShooting } >
68
+ < div className = "absolute w-full bottom-[25px] flex flex-row items-center pt-[52px] pb-[40px] px-[16px] gap-[16px] justify-center" >
69
+ < Button
70
+ className = "w-full h-[56px]"
71
+ variant = { "primary" }
72
+ onClick = { goShooting }
73
+ >
59
74
직접 촬영할래
60
75
</ Button >
61
- < Button className = "w-full" variant = { "primary" } >
76
+ < Button className = "w-full h-[56px] bg-[#9CA3AF] " variant = { "primary" } >
62
77
업로르할래
63
78
</ Button >
64
79
</ div >
@@ -82,26 +97,3 @@ function BackIcon() {
82
97
</ svg >
83
98
) ;
84
99
}
85
-
86
- function IconSound ( ) {
87
- return (
88
- < svg
89
- xmlns = "http://www.w3.org/2000/svg"
90
- width = "25"
91
- height = "24"
92
- viewBox = "0 0 25 24"
93
- fill = "none"
94
- >
95
- < path
96
- d = "M2.04617 14.4299C1.60587 13.6959 1.37329 12.856 1.37329 12C1.37329 11.1441 1.60587 10.3042 2.04617 9.57016C2.18156 9.34419 2.36273 9.14905 2.57804 8.99728C2.79335 8.8455 3.03803 8.74044 3.29635 8.68886L5.42784 8.26206C5.55495 8.23689 5.6696 8.16891 5.75266 8.06944L8.35626 4.94335C9.8444 3.15557 10.5897 2.26294 11.2532 2.50341C11.9192 2.74388 11.9192 3.90719 11.9192 6.23382V17.7688C11.9192 20.0941 11.9192 21.2562 11.2545 21.4979C10.591 21.7371 9.84566 20.8445 8.35752 19.058L5.75014 15.9306C5.6674 15.8314 5.55324 15.7634 5.42658 15.738L3.29509 15.3112C3.03677 15.2596 2.79209 15.1546 2.57678 15.0028C2.36147 14.851 2.18156 14.6559 2.04617 14.4299Z"
97
- fill = "white"
98
- />
99
- < path
100
- d = "M15.1121 7.54826C16.2867 8.7229 16.9495 10.3142 16.9559 11.9755C16.9622 13.6367 16.3117 15.233 15.1461 16.4166M20.3004 4.87793C22.1799 6.75719 23.2404 9.30317 23.2507 11.961C23.2611 14.6188 22.2205 17.173 20.3558 19.0668"
101
- stroke = "white"
102
- strokeWidth = "2.518"
103
- strokeLinecap = "round"
104
- />
105
- </ svg >
106
- ) ;
107
- }
0 commit comments