Skip to content

Commit 0e1c585

Browse files
csantosrMrRoiz
authored andcommitted
fix: fixing linting and typing errors
1 parent dadd711 commit 0e1c585

File tree

6 files changed

+36
-32
lines changed

6 files changed

+36
-32
lines changed

app/[lang]/game/local/_store/game-settings.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { atom } from 'jotai';
2-
import type z from 'zod';
3-
import type { localGameFormSchema } from '../setup/_components/form';
2+
import type { LocalGameFormSchema } from '../setup/_components/form';
43

5-
export const gameSettingsAtom = atom<z.infer<typeof localGameFormSchema>>({
4+
export const gameSettingsAtom = atom<LocalGameFormSchema>({
65
players: [],
76
numberOfSpies: '0',
87
randomNumberOfSpies: false,

app/[lang]/game/local/play/_components/game.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
'use client';
22

3-
import { useAtomValue } from "jotai";
4-
import { type FC, useCallback, useMemo, useState } from "react";
5-
import { GameCard } from "@/game/_components/card";
6-
import { gameSettingsAtom } from "../../_store/game-settings";
7-
import { GameTimer } from "./timer";
8-
import { Dictionary } from "@/dictionaries";
9-
import enWords from "@/word-bank/en.json";
10-
import esWords from "@/word-bank/es.json";
11-
import type { Locale } from "@/dictionaries";
3+
import { useAtomValue } from 'jotai';
4+
import { type FC, useCallback, useMemo, useState } from 'react';
5+
import type { Dictionary, Locale } from '@/dictionaries';
6+
import { GameCard } from '@/game/_components/card';
7+
import enWords from '@/word-bank/en.json';
8+
import esWords from '@/word-bank/es.json';
9+
import { gameSettingsAtom } from '../../_store/game-settings';
10+
import { GameTimer } from './timer';
1211

13-
14-
export const Game: FC<{ dict: Dictionary; lang: Locale }> = ({ dict, lang }) => {
12+
export const Game: FC<{ dict: Dictionary; lang: Locale }> = ({
13+
dict,
14+
lang,
15+
}) => {
1516
const gameSettings = useAtomValue(gameSettingsAtom);
1617
const [currentPlayerIndex, setCurrentPlayerIndex] = useState(0);
1718
const [gameKey, setGameKey] = useState(0);
1819

1920
// Get random word based on language
2021
const word = useMemo(() => {
21-
const words = lang === "es" ? esWords : enWords;
22+
const words = lang === 'es' ? esWords : enWords;
2223
const randomIndex = Math.floor(Math.random() * words.length);
2324
return words[randomIndex];
24-
}, [lang, gameKey]);
25+
}, [lang]);
2526

2627
// Generate spy assignments
2728
// biome-ignore lint/correctness/useExhaustiveDependencies: gameKey is intentionally used to trigger regeneration

app/[lang]/game/local/play/_components/timer.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ export const GameTimer: FC<GameTimerProps> = ({
5656
const formattedTime = `${minutes}:${seconds.toString().padStart(2, '0')}`;
5757

5858
const getTimerColor = () => {
59-
if (isExpired || isStopped) return "text-destructive";
60-
if (timeLeft <= 30) return "text-destructive";
61-
if (timeLeft <= 60) return "text-warning";
62-
return "text-foreground";
59+
if (isExpired || isStopped) return 'text-destructive';
60+
if (timeLeft <= 30) return 'text-destructive';
61+
if (timeLeft <= 60) return 'text-warning';
62+
return 'text-foreground';
6363
};
6464

6565
const isFinished = isExpired || isStopped;
@@ -72,9 +72,7 @@ export const GameTimer: FC<GameTimerProps> = ({
7272
<div className="text-center">
7373
<h2 className="mb-2 font-bold text-2xl">{dict.timer.title}</h2>
7474
<p className="text-muted-foreground">
75-
{isFinished
76-
? dict.timer.timeUpDescription
77-
: dict.timer.description}
75+
{isFinished ? dict.timer.timeUpDescription : dict.timer.description}
7876
</p>
7977
</div>
8078

@@ -83,10 +81,11 @@ export const GameTimer: FC<GameTimerProps> = ({
8381
'flex h-64 w-64 items-center justify-center rounded-full border-4 shadow-lg transition-colors',
8482
getTimerColor(),
8583
{
86-
"animate-pulse border-destructive": isExpired,
87-
"border-destructive": (timeLeft <= 30 && !isFinished) || isStopped,
88-
"border-warning": timeLeft > 30 && timeLeft <= 60 && !isFinished,
89-
"border-border": timeLeft > 60 && !isFinished,
84+
'animate-pulse border-destructive': isExpired,
85+
'border-destructive':
86+
(timeLeft <= 30 && !isFinished) || isStopped,
87+
'border-warning': timeLeft > 30 && timeLeft <= 60 && !isFinished,
88+
'border-border': timeLeft > 60 && !isFinished,
9089
},
9190
)}>
9291
<div className="text-center">

app/[lang]/game/local/play/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const Page = async ({ params }: PageProps<'/[lang]/game/local/play'>) => {
88

99
const dict = await getDictionary(lang);
1010

11-
return <Game dict={dict} lang={params.lang} />;
11+
return <Game dict={dict} lang={lang} />;
1212
};
1313

1414
export default Page;

app/[lang]/game/local/setup/_components/form.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ const createLocalGameFormSchema = (dict: Dictionary) =>
5252
},
5353
);
5454

55+
export type LocalGameFormSchema = z.infer<
56+
ReturnType<typeof createLocalGameFormSchema>
57+
>;
58+
5559
export const LocalUsersForm: FC<{ dict: Dictionary; lang: string }> = ({
5660
dict,
5761
lang,

app/layout.tsx renamed to app/[lang]/layout.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Metadata } from 'next';
22
import { Geist, Geist_Mono } from 'next/font/google';
3-
import './globals.css';
4-
import { ThemeProvider } from './_providers/theme-provider';
3+
import '../globals.css';
4+
import { ThemeProvider } from '../_providers/theme-provider';
55

66
const geistSans = Geist({
77
variable: '--font-geist-sans',
@@ -38,9 +38,10 @@ export const metadata: Metadata = {
3838
export default async function RootLayout({
3939
children,
4040
params,
41-
}: LayoutProps<'/[lang]/game'>) {
41+
}: LayoutProps<'/[lang]'>) {
42+
const { lang } = await params;
4243
return (
43-
<html lang={(await params).lang} suppressHydrationWarning>
44+
<html lang={lang} suppressHydrationWarning>
4445
<body
4546
className={`${geistSans.variable} ${geistMono.variable} antialiased`}>
4647
<ThemeProvider

0 commit comments

Comments
 (0)