-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdrawing.tsx
More file actions
77 lines (64 loc) · 1.96 KB
/
drawing.tsx
File metadata and controls
77 lines (64 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import Lottie from 'lottie-react';
import { useEffect, useState } from 'react';
import InfoSection from '@pages/admin/ticket-drawing/components/info-section/info-section';
import type { WinnerData } from '@pages/admin/ticket-drawing/types/winner-data';
import Title from '@shared/components/title/title';
import * as styles from './drawing.css';
import confetiLottieAnimation from '../../../../../assets/lottie/confeti.json';
interface DrawingProps {
winner: WinnerData | null;
onReExecuteRaffle: () => void;
}
const Drawing = ({ winner, onReExecuteRaffle }: DrawingProps) => {
const [isConfetiPlaying, setIsConfetiPlaying] = useState(false);
const [animationKey, setAnimationKey] = useState(0);
const animationData = confetiLottieAnimation;
useEffect(() => {
if (winner) {
setIsConfetiPlaying(false);
setAnimationKey((prev) => prev + 1);
setTimeout(() => {
setIsConfetiPlaying(true);
}, 100);
}
}, [winner]);
const handleReExecuteRaffle = () => {
setIsConfetiPlaying(false);
setAnimationKey((prev) => prev + 1);
setTimeout(() => {
setIsConfetiPlaying(true);
}, 100);
onReExecuteRaffle();
};
return (
<>
<div className={styles.title}>
<Title
mainTitle="당첨자 추첨"
subTitle="응모권 당첨자 페이지입니다."
/>
</div>
<>
<div className={styles.container}>
<p className={styles.text}>당첨자</p>
<InfoSection
value={winner?.name || ''}
studentnumber={winner?.studentId || ''}
handleButtonClick={handleReExecuteRaffle}
/>
</div>
<div className={styles.confetiLottie}>
{isConfetiPlaying && (
<Lottie
key={animationKey}
animationData={animationData}
autoPlay={true}
loop={false}
/>
)}
</div>
</>
</>
);
};
export default Drawing;