From 4e13faeb96c982b58529438e8f1b9f0659f3aef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Djobbo=20Ma=C3=AFga?= Date: Thu, 11 Apr 2024 02:20:34 +0200 Subject: [PATCH] Readonly props --- app/layout.tsx | 8 ++++---- app/level/[level]/round/[round]/page.tsx | 9 +++------ components/CharacterDisplay.tsx | 4 ++-- components/Steps/CharacterQuizChoice.tsx | 6 +++--- components/Steps/Info.tsx | 4 ++-- components/Steps/KeywordChallenge.tsx | 4 ++-- components/Steps/LearnCharacter.tsx | 4 ++-- store/LevelStore.tsx | 8 +++++--- 8 files changed, 23 insertions(+), 24 deletions(-) diff --git a/app/layout.tsx b/app/layout.tsx index bb4033f..8396b13 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -9,11 +9,11 @@ export const metadata: Metadata = { description: "Zenji is a platform for learning Japanese", } -export default function RootLayout({ - children, -}: Readonly<{ +type RootLayoutProps = Readonly<{ children: React.ReactNode -}>) { +}> + +export default function RootLayout({ children }: RootLayoutProps) { return ( {children} diff --git a/app/level/[level]/round/[round]/page.tsx b/app/level/[level]/round/[round]/page.tsx index e7faa57..4502348 100644 --- a/app/level/[level]/round/[round]/page.tsx +++ b/app/level/[level]/round/[round]/page.tsx @@ -9,12 +9,9 @@ const paramsSchema = z.object({ round: z.number({ coerce: true }).int().catch(1), }) -type LevelRoundPageProps = { - params: { - level: string - round: string - } -} +type LevelRoundPageProps = Readonly<{ + params: unknown +}> export default function LevelRoundPage({ params }: LevelRoundPageProps) { const parsedParams = paramsSchema.safeParse(params) diff --git a/components/CharacterDisplay.tsx b/components/CharacterDisplay.tsx index 9e549a7..809f1dd 100644 --- a/components/CharacterDisplay.tsx +++ b/components/CharacterDisplay.tsx @@ -1,9 +1,9 @@ import { AnimatePresence, motion } from "framer-motion" -type CharacterDisplayProps = { +type CharacterDisplayProps = Readonly<{ character: string pronounciation?: string -} +}> export const CharacterDisplay = ({ character, diff --git a/components/Steps/CharacterQuizChoice.tsx b/components/Steps/CharacterQuizChoice.tsx index c7a2fdc..3d44718 100644 --- a/components/Steps/CharacterQuizChoice.tsx +++ b/components/Steps/CharacterQuizChoice.tsx @@ -4,15 +4,15 @@ import { Button } from "@/components/Button" import { CharacterDisplay } from "@/components/CharacterDisplay" import { useLevelStore } from "@/store/LevelStore" -type CharacterQuizChoiceStepContentProps = { +type CharacterQuizChoiceStepContentProps = Readonly<{ step: CharacterQuizChoiceStep -} +}> const Answer = { None: "None", Correct: "Correct", Incorrect: "Incorrect", -} +} as const type Choice = (typeof Answer)[keyof typeof Answer] diff --git a/components/Steps/Info.tsx b/components/Steps/Info.tsx index 246cc9c..2828264 100644 --- a/components/Steps/Info.tsx +++ b/components/Steps/Info.tsx @@ -1,9 +1,9 @@ import { type InfoStep } from "@/data/levels" import { Button } from "@/components/Button" -type InfoStepContentProps = { +type InfoStepContentProps = Readonly<{ step: InfoStep -} +}> export const Info = ({ step }: InfoStepContentProps) => { return ( diff --git a/components/Steps/KeywordChallenge.tsx b/components/Steps/KeywordChallenge.tsx index 96e2b68..49d584c 100644 --- a/components/Steps/KeywordChallenge.tsx +++ b/components/Steps/KeywordChallenge.tsx @@ -3,9 +3,9 @@ import { useMemo, useState } from "react" import { Button } from "@/components/Button" import { checkPronounciation } from "@/util/checkPronounciation" -type KeywordChallengeStepContentProps = { +type KeywordChallengeStepContentProps = Readonly<{ step: KeywordChallengeStep -} +}> export const KeywordChallenge = ({ step, diff --git a/components/Steps/LearnCharacter.tsx b/components/Steps/LearnCharacter.tsx index 64d7847..33ada6b 100644 --- a/components/Steps/LearnCharacter.tsx +++ b/components/Steps/LearnCharacter.tsx @@ -2,9 +2,9 @@ import { type LearnCharacterStep } from "@/data/levels" import { Button } from "@/components/Button" import { CharacterDisplay } from "@/components/CharacterDisplay" -type LearnCharacterStepContentProps = { +type LearnCharacterStepContentProps = Readonly<{ step: LearnCharacterStep -} +}> export const LearnCharacter = ({ step }: LearnCharacterStepContentProps) => { return ( diff --git a/store/LevelStore.tsx b/store/LevelStore.tsx index e469fa8..436c5bb 100644 --- a/store/LevelStore.tsx +++ b/store/LevelStore.tsx @@ -61,9 +61,11 @@ export const useLevelStore = () => { return store } -type LevelStoreProviderProps = { - children: ReactNode -} & SnapshotOut +type LevelStoreProviderProps = Readonly< + { + children: ReactNode + } & SnapshotOut +> export const LevelStoreProvider = ({ children,