From 0738f4392fa3f021bc8df2741ba5117dc9eba607 Mon Sep 17 00:00:00 2001 From: QuanPT <77958905+quanpt239@users.noreply.github.com> Date: Fri, 18 Oct 2024 15:36:53 +0700 Subject: [PATCH] feat(scan): add total reward (#24) --- src/components/LuckyDraw/index.module.scss | 2 +- src/components/LuckyDraw/index.tsx | 32 +++++++++++++++++----- src/components/LuckyDraw/useLuckyDraw.ts | 12 +++++++- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/components/LuckyDraw/index.module.scss b/src/components/LuckyDraw/index.module.scss index 9f5dbc86..bc6109f7 100644 --- a/src/components/LuckyDraw/index.module.scss +++ b/src/components/LuckyDraw/index.module.scss @@ -40,7 +40,7 @@ z-index: 10; width: 100%; display: flex; - flex-direction: column-reverse; + flex-direction: column; align-items: center; flex-wrap: wrap; diff --git a/src/components/LuckyDraw/index.tsx b/src/components/LuckyDraw/index.tsx index 5485a2c4..82e1f8a3 100644 --- a/src/components/LuckyDraw/index.tsx +++ b/src/components/LuckyDraw/index.tsx @@ -29,7 +29,13 @@ import { SPIN_ID_KEY, REWARD_ENUM } from './constants'; -import { getDataLogByKey, sendMultiple, useGetListSpinResult, useLuckyDrawConfig } from './useLuckyDraw'; +import { + getDataLogByKey, + sendMultiple, + useGetListSpinResult, + useGetTotalWonReward, + useLuckyDrawConfig +} from './useLuckyDraw'; import styles from './index.module.scss'; const cx = cn.bind(styles); @@ -92,6 +98,12 @@ const LuckyDraw: FC<{}> = () => { // const { spinResult } = useGetSpinResult({ id: spinId }); const { spinResult, isDone } = useGetListSpinResult({ spinIdList }); + const { totalRewarded, isLoading, refetchTotalRewarded } = useGetTotalWonReward(); + + useEffect(() => { + const intervalGetReward = setInterval(refetchTotalRewarded, 5e3); + return () => clearInterval(intervalGetReward); + }, []); useEffect(() => { if (spinIdList.length && isDone && myLuckyRef?.current) { @@ -188,6 +200,18 @@ const LuckyDraw: FC<{}> = () => { >