"use client" import { CommonStatusDataMap } from "@rahoot/common/types/game/status" import CricleCheck from "@rahoot/web/components/icons/CricleCheck" import CricleXmark from "@rahoot/web/components/icons/CricleXmark" import { usePlayerStore } from "@rahoot/web/stores/player" import { SFX_RESULTS_SOUND } from "@rahoot/web/utils/constants" import { useEffect } from "react" import useSound from "use-sound" type Props = { data: CommonStatusDataMap["SHOW_RESULT"] } const Result = ({ data: { correct, message, points, myPoints, rank, aheadOfMe }, }: Props) => { const player = usePlayerStore() const [sfxResults] = useSound(SFX_RESULTS_SOUND, { volume: 0.2, }) useEffect(() => { player.updatePoints(myPoints) sfxResults() }, [sfxResults]) return (
{correct ? ( ) : ( )}

{message}

{`You are top ${rank}${aheadOfMe ? `, behind ${aheadOfMe}` : ""}`}

{correct && ( +{points} )}
) } export default Result