"use client" import { ManagerStatusDataMap } from "@rahoot/common/types/game/status" import useScreenSize from "@rahoot/web/hook/useScreenSize" import { SFX_PODIUM_FIRST, SFX_PODIUM_SECOND, SFX_PODIUM_THREE, SFX_SNEAR_ROOL, } from "@rahoot/web/utils/constants" import clsx from "clsx" import { useEffect, useState } from "react" import ReactConfetti from "react-confetti" import useSound from "use-sound" type Props = { data: ManagerStatusDataMap["FINISHED"] } export default function Podium({ data: { subject, top } }: Props) { const [apparition, setApparition] = useState(0) const { width, height } = useScreenSize() const [sfxtThree] = useSound(SFX_PODIUM_THREE, { volume: 0.2, }) const [sfxSecond] = useSound(SFX_PODIUM_SECOND, { volume: 0.2, }) const [sfxRool, { stop: sfxRoolStop }] = useSound(SFX_SNEAR_ROOL, { volume: 0.2, }) const [sfxFirst] = useSound(SFX_PODIUM_FIRST, { volume: 0.2, }) useEffect(() => { switch (apparition) { case 4: sfxRoolStop() sfxFirst() break case 3: sfxRool() break case 2: sfxSecond() break case 1: sfxtThree() break } }, [apparition, sfxFirst, sfxSecond, sfxtThree, sfxRool, sfxRoolStop]) useEffect(() => { if (top.length < 3) { setApparition(4) return } const interval = setInterval(() => { if (apparition > 4) { clearInterval(interval) return } setApparition((value) => value + 1) }, 2000) // eslint-disable-next-line consistent-return return () => clearInterval(interval) }, [apparition, top.length]) return ( <> {apparition >= 4 && ( )} {apparition >= 3 && top.length >= 3 && (
)}

{subject}

{top[1] && (
= 2 }, )} >

= 4, }, )} > {top[1].username}

2

{top[1].points}

)}
= 3, }, { "md:min-w-64": top.length < 2, }, )} >

= 4 }, )} > {top[0].username}

1

{top[0].points}

{top[2] && (
= 1, }, )} >

= 4, }, )} > {top[2].username}

3

{top[2].points}

)}
) }