= 2 },
+ { "translate-y-0! opacity-100": apparition >= 2 },
)}
>
= 3,
+ "translate-y-0! opacity-100": apparition >= 3,
},
{
"md:min-w-64": top.length < 2,
@@ -170,7 +170,7 @@ export default function Podium({ data: { subject, top } }: Props) {
className={clsx(
"z-10 flex h-[40%] w-full translate-y-full flex-col items-center gap-3 opacity-0 transition-all",
{
- "!translate-y-0 opacity-100": apparition >= 1,
+ "translate-y-0! opacity-100": apparition >= 1,
},
)}
>
@@ -200,3 +200,5 @@ export default function Podium({ data: { subject, top } }: Props) {
>
)
}
+
+export default Podium
diff --git a/packages/web/src/components/game/states/Prepared.tsx b/packages/web/src/components/game/states/Prepared.tsx
index 1053e12..9ceba61 100644
--- a/packages/web/src/components/game/states/Prepared.tsx
+++ b/packages/web/src/components/game/states/Prepared.tsx
@@ -7,27 +7,25 @@ type Props = {
data: CommonStatusDataMap["SHOW_PREPARED"]
}
-export default function Prepared({
- data: { totalAnswers, questionNumber },
-}: Props) {
- return (
-
-
- Question #{questionNumber}
-
-
- {[...Array(totalAnswers)].map((_, key) => (
-
- {createElement(ANSWERS_ICONS[key], { className: "h-10 md:h-14" })}
-
- ))}
-
-
- )
-}
+const Prepared = ({ data: { totalAnswers, questionNumber } }: Props) => (
+
+
+ Question #{questionNumber}
+
+
+ {[...Array(totalAnswers)].map((_, key) => (
+
+ {createElement(ANSWERS_ICONS[key], { className: "h-10 md:h-14" })}
+
+ ))}
+
+
+)
+
+export default Prepared
diff --git a/packages/web/src/components/game/states/Question.tsx b/packages/web/src/components/game/states/Question.tsx
index 2c1ea90..d177a00 100644
--- a/packages/web/src/components/game/states/Question.tsx
+++ b/packages/web/src/components/game/states/Question.tsx
@@ -9,9 +9,7 @@ type Props = {
data: CommonStatusDataMap["SHOW_QUESTION"]
}
-export default function Question({
- data: { question, image, cooldown },
-}: Props) {
+const Question = ({ data: { question, image, cooldown } }: Props) => {
const [sfxShow] = useSound(SFX_SHOW_SOUND, { volume: 0.5 })
useEffect(() => {
@@ -40,3 +38,5 @@ export default function Question({
)
}
+
+export default Question
diff --git a/packages/web/src/components/game/states/Responses.tsx b/packages/web/src/components/game/states/Responses.tsx
index c16156f..8bd5229 100644
--- a/packages/web/src/components/game/states/Responses.tsx
+++ b/packages/web/src/components/game/states/Responses.tsx
@@ -1,48 +1,25 @@
"use client"
import { ManagerStatusDataMap } from "@rahoot/common/types/game/status"
+import AnswerButton from "@rahoot/web/components/AnswerButton"
import {
ANSWERS_COLORS,
ANSWERS_ICONS,
SFX_ANSWERS_MUSIC,
SFX_RESULTS_SOUND,
} from "@rahoot/web/utils/constants"
+import { calculatePercentages } from "@rahoot/web/utils/score"
import clsx from "clsx"
import { useEffect, useState } from "react"
import useSound from "use-sound"
-import AnswerButton from "../../AnswerButton"
-
-const calculatePercentages = (
- objectResponses: Record,
-): Record => {
- const keys = Object.keys(objectResponses)
- const values = Object.values(objectResponses)
-
- if (!values.length) {
- return {}
- }
-
- const totalSum = values.reduce(
- (accumulator, currentValue) => accumulator + currentValue,
- 0,
- )
-
- const result: Record = {}
-
- keys.forEach((key) => {
- result[key] = `${((objectResponses[key] / totalSum) * 100).toFixed()}%`
- })
-
- return result
-}
type Props = {
data: ManagerStatusDataMap["SHOW_RESPONSES"]
}
-export default function Responses({
+const Responses = ({
data: { question, answers, responses, correct },
-}: Props) {
+}: Props) => {
const [percentages, setPercentages] = useState>({})
const [isMusicPlaying, setIsMusicPlaying] = useState(false)
@@ -123,3 +100,5 @@ export default function Responses({
)
}
+
+export default Responses
diff --git a/packages/web/src/components/game/states/Result.tsx b/packages/web/src/components/game/states/Result.tsx
index 357fa81..d94d4c5 100644
--- a/packages/web/src/components/game/states/Result.tsx
+++ b/packages/web/src/components/game/states/Result.tsx
@@ -12,9 +12,9 @@ type Props = {
data: CommonStatusDataMap["SHOW_RESULT"]
}
-export default function Result({
+const Result = ({
data: { correct, message, points, myPoints, rank, aheadOfMe },
-}: Props) {
+}: Props) => {
const player = usePlayerStore()
const [sfxResults] = useSound(SFX_RESULTS_SOUND, {
@@ -48,3 +48,5 @@ export default function Result({
)
}
+
+export default Result
diff --git a/packages/web/src/components/game/states/Room.tsx b/packages/web/src/components/game/states/Room.tsx
index 533dcdb..998efcf 100644
--- a/packages/web/src/components/game/states/Room.tsx
+++ b/packages/web/src/components/game/states/Room.tsx
@@ -10,7 +10,7 @@ type Props = {
data: ManagerStatusDataMap["SHOW_ROOM"]
}
-export default function Room({ data: { text, inviteCode } }: Props) {
+const Room = ({ data: { text, inviteCode } }: Props) => {
const { socket } = useSocket()
const { players } = useManagerStore()
const [playerList, setPlayerList] = useState