@@ -6,30 +6,31 @@ import Lottie from 'react-lottie-player';
66
77import lottiePick from '#/lotties/pick.json' ;
88import { MainFooter } from '../MainFooter' ;
9- import { usePosePickQuery } from '@/apis' ;
109import { PrimaryButton } from '@/components/Button' ;
1110import PoseImage from '@/components/Modal/PoseImage' ;
1211import { SelectionBasic } from '@/components/Selection' ;
1312import { PEOPLE_COUNT_LIST } from '@/constants' ;
1413import { useDidMount } from '@/hooks' ;
14+ import { getPosePick } from '@/server/api' ;
1515
16- const DEFAULT_IMAGE = '/images/image-frame.png' ;
16+ const DEFAULT_IMAGE = '/images/image-frame.png' as const ;
1717
1818export default function PickComponent ( ) {
1919 const [ countState , setCountState ] = useState ( 1 ) ;
20+ const [ isLoading , setisLoading ] = useState ( false ) ;
2021 const [ isLottiePlaying , setIsLottiePlaying ] = useState ( true ) ;
21- const { refetch, data } = usePosePickQuery ( countState ) ;
22- const imageSrc = data ?. poseInfo ?. imageKey || DEFAULT_IMAGE ;
22+ const [ imageSrc , setImageSrc ] = useState < string > ( DEFAULT_IMAGE ) ;
2323
2424 useDidMount ( async ( ) => {
2525 await delay ( 2200 ) ;
2626 setIsLottiePlaying ( false ) ;
2727 } ) ;
2828
2929 const handlePickClick = async ( ) => {
30- refetch ( ) ;
30+ setisLoading ( true ) ;
3131 setIsLottiePlaying ( true ) ;
32- await delay ( 900 ) ;
32+ const imageUrl = ( await getPosePick ( countState ) ) . data . imageUrl ;
33+ setImageSrc ( imageUrl ) ;
3334 setIsLottiePlaying ( false ) ;
3435 } ;
3536
@@ -43,13 +44,13 @@ export default function PickComponent() {
4344 />
4445 </ div >
4546 < div className = "relative flex grow" >
46- { isLottiePlaying && (
47+ { ( isLottiePlaying || isLoading ) && (
4748 < div className = "absolute inset-x-0 inset-y-0 z-10 flex justify-center bg-black" >
4849 < Lottie animationData = { lottiePick } play />
4950 </ div >
5051 ) }
5152 < div className = "absolute inset-x-0 inset-y-0 bg-black" >
52- < PoseImage src = { imageSrc } />
53+ < PoseImage src = { imageSrc } onLoad = { ( ) => setisLoading ( false ) } />
5354 </ div >
5455 </ div >
5556 < MainFooter >
0 commit comments