From dbefaa0557b67187d0cba72fe3a14d6ea77fea2f Mon Sep 17 00:00:00 2001 From: Ralex <95540504+Ralex91@users.noreply.github.com> Date: Sat, 25 Oct 2025 15:04:03 +0200 Subject: [PATCH] refactor(components): use arrow function syntax and improve consistency --- packages/web/src/app/(auth)/manager/page.tsx | 4 +- packages/web/src/app/(auth)/page.tsx | 4 +- packages/web/src/app/game/[gameId]/page.tsx | 4 +- .../src/app/game/manager/[gameId]/page.tsx | 4 +- packages/web/src/app/layout.tsx | 24 +++---- packages/web/src/components/AnswerButton.tsx | 30 ++++---- packages/web/src/components/Button.tsx | 27 +++---- packages/web/src/components/Form.tsx | 14 ++-- packages/web/src/components/Input.tsx | 28 ++++---- .../web/src/components/game/GameWrapper.tsx | 13 ++-- .../game/create/ManagerPassword.tsx | 4 +- .../components/game/create/SelectQuizz.tsx | 4 +- .../web/src/components/game/join/Room.tsx | 4 +- .../web/src/components/game/join/Username.tsx | 4 +- .../src/components/game/states/Answers.tsx | 6 +- .../components/game/states/Leaderboard.tsx | 40 +++++------ .../web/src/components/game/states/Podium.tsx | 10 +-- .../src/components/game/states/Prepared.tsx | 46 ++++++------ .../src/components/game/states/Question.tsx | 6 +- .../src/components/game/states/Responses.tsx | 33 ++------- .../web/src/components/game/states/Result.tsx | 6 +- .../web/src/components/game/states/Room.tsx | 4 +- .../web/src/components/game/states/Start.tsx | 4 +- .../web/src/components/game/states/Wait.tsx | 20 +++--- packages/web/src/components/icons/Circle.tsx | 42 +++++------ .../web/src/components/icons/CricleCheck.tsx | 70 +++++++++---------- .../web/src/components/icons/CricleXmark.tsx | 58 +++++++-------- .../web/src/components/icons/Pentagon.tsx | 70 +++++++++---------- packages/web/src/components/icons/Rhombus.tsx | 34 ++++----- packages/web/src/components/icons/Square.tsx | 24 +++---- .../web/src/components/icons/Triangle.tsx | 24 +++---- packages/web/src/utils/score.ts | 23 ++++++ 32 files changed, 351 insertions(+), 337 deletions(-) create mode 100644 packages/web/src/utils/score.ts diff --git a/packages/web/src/app/(auth)/manager/page.tsx b/packages/web/src/app/(auth)/manager/page.tsx index b7c3b05..0b77bfc 100644 --- a/packages/web/src/app/(auth)/manager/page.tsx +++ b/packages/web/src/app/(auth)/manager/page.tsx @@ -8,7 +8,7 @@ import { useManagerStore } from "@rahoot/web/stores/manager" import { useRouter } from "next/navigation" import { useState } from "react" -export default function Manager() { +const Manager = () => { const { setGameId, setStatus } = useManagerStore() const router = useRouter() const { socket } = useSocket() @@ -40,3 +40,5 @@ export default function Manager() { return } + +export default Manager diff --git a/packages/web/src/app/(auth)/page.tsx b/packages/web/src/app/(auth)/page.tsx index 546b3b8..976f754 100644 --- a/packages/web/src/app/(auth)/page.tsx +++ b/packages/web/src/app/(auth)/page.tsx @@ -7,7 +7,7 @@ import { usePlayerStore } from "@rahoot/web/stores/player" import { useEffect } from "react" import toast from "react-hot-toast" -export default function Home() { +const Home = () => { const { isConnected, connect } = useSocket() const { player } = usePlayerStore() @@ -27,3 +27,5 @@ export default function Home() { return } + +export default Home diff --git a/packages/web/src/app/game/[gameId]/page.tsx b/packages/web/src/app/game/[gameId]/page.tsx index 1ab789a..df8ed01 100644 --- a/packages/web/src/app/game/[gameId]/page.tsx +++ b/packages/web/src/app/game/[gameId]/page.tsx @@ -15,7 +15,7 @@ import { GAME_STATE_COMPONENTS } from "@rahoot/web/utils/constants" import { useParams, useRouter } from "next/navigation" import toast from "react-hot-toast" -export default function Game() { +const Game = () => { const router = useRouter() const { socket } = useSocket() const { gameId: gameIdParam }: { gameId?: string } = useParams() @@ -95,3 +95,5 @@ export default function Game() { return {component} } + +export default Game diff --git a/packages/web/src/app/game/manager/[gameId]/page.tsx b/packages/web/src/app/game/manager/[gameId]/page.tsx index 24bcddd..ab4f86e 100644 --- a/packages/web/src/app/game/manager/[gameId]/page.tsx +++ b/packages/web/src/app/game/manager/[gameId]/page.tsx @@ -17,7 +17,7 @@ import { GAME_STATE_COMPONENTS_MANAGER } from "@rahoot/web/utils/constants" import { useParams, useRouter } from "next/navigation" import toast from "react-hot-toast" -export default function ManagerGame() { +const ManagerGame = () => { const router = useRouter() const { gameId: gameIdParam }: { gameId?: string } = useParams() const { socket } = useSocket() @@ -131,3 +131,5 @@ export default function ManagerGame() { ) } + +export default ManagerGame diff --git a/packages/web/src/app/layout.tsx b/packages/web/src/app/layout.tsx index 99c9970..e61d32c 100644 --- a/packages/web/src/app/layout.tsx +++ b/packages/web/src/app/layout.tsx @@ -15,15 +15,15 @@ export const metadata: Metadata = { icons: "/icon.svg", } -export default function RootLayout({ children }: PropsWithChildren) { - return ( - - - -
{children}
- -
- - - ) -} +const RootLayout = ({ children }: PropsWithChildren) => ( + + + +
{children}
+ +
+ + +) + +export default RootLayout diff --git a/packages/web/src/components/AnswerButton.tsx b/packages/web/src/components/AnswerButton.tsx index 9706e84..7b757ab 100644 --- a/packages/web/src/components/AnswerButton.tsx +++ b/packages/web/src/components/AnswerButton.tsx @@ -6,22 +6,22 @@ type Props = PropsWithChildren & icon: ElementType } -export default function AnswerButton({ +const AnswerButton = ({ className, icon: Icon, children, ...otherProps -}: Props) { - return ( - - ) -} +}: Props) => ( + +) + +export default AnswerButton diff --git a/packages/web/src/components/Button.tsx b/packages/web/src/components/Button.tsx index 9505e7b..b6c5b56 100644 --- a/packages/web/src/components/Button.tsx +++ b/packages/web/src/components/Button.tsx @@ -2,16 +2,17 @@ import clsx from "clsx" import { ButtonHTMLAttributes, PropsWithChildren } from "react" type Props = ButtonHTMLAttributes & PropsWithChildren -export default function Button({ children, className, ...otherProps }: Props) { - return ( - - ) -} + +const Button = ({ children, className, ...otherProps }: Props) => ( + +) + +export default Button diff --git a/packages/web/src/components/Form.tsx b/packages/web/src/components/Form.tsx index bd584f6..7df80d5 100644 --- a/packages/web/src/components/Form.tsx +++ b/packages/web/src/components/Form.tsx @@ -1,9 +1,9 @@ import { PropsWithChildren } from "react" -export default function Form({ children }: PropsWithChildren) { - return ( -
- {children} -
- ) -} +const Form = ({ children }: PropsWithChildren) => ( +
+ {children} +
+) + +export default Form diff --git a/packages/web/src/components/Input.tsx b/packages/web/src/components/Input.tsx index 6b83b23..0246d9a 100644 --- a/packages/web/src/components/Input.tsx +++ b/packages/web/src/components/Input.tsx @@ -3,19 +3,15 @@ import React from "react" type Props = React.InputHTMLAttributes -export default function Input({ - className, - type = "text", - ...otherProps -}: Props) { - return ( - - ) -} +const Input = ({ className, type = "text", ...otherProps }: Props) => ( + +) + +export default Input diff --git a/packages/web/src/components/game/GameWrapper.tsx b/packages/web/src/components/game/GameWrapper.tsx index 49eb8ed..dff2b4e 100644 --- a/packages/web/src/components/game/GameWrapper.tsx +++ b/packages/web/src/components/game/GameWrapper.tsx @@ -3,13 +3,13 @@ import { Status } from "@rahoot/common/types/game/status" import background from "@rahoot/web/assets/background.webp" import Button from "@rahoot/web/components/Button" +import Loader from "@rahoot/web/components/Loader" import { useEvent, useSocket } from "@rahoot/web/contexts/socketProvider" import { usePlayerStore } from "@rahoot/web/stores/player" import { useQuestionStore } from "@rahoot/web/stores/question" import { MANAGER_SKIP_BTN } from "@rahoot/web/utils/constants" import Image from "next/image" import { PropsWithChildren } from "react" -import Loader from "../Loader" type Props = PropsWithChildren & { statusName: Status @@ -17,12 +17,7 @@ type Props = PropsWithChildren & { manager?: boolean } -export default function GameWrapper({ - children, - statusName, - onNext, - manager, -}: Props) { +const GameWrapper = ({ children, statusName, onNext, manager }: Props) => { const { isConnected } = useSocket() const { player } = usePlayerStore() const { questionStates, setQuestionStates } = useQuestionStore() @@ -61,7 +56,7 @@ export default function GameWrapper({ {manager && next && (