From f9f1757ec07a563d652f5332fd9315a8e2ce385c Mon Sep 17 00:00:00 2001 From: Arif Hasanic Date: Sat, 27 Jun 2026 22:54:31 +0200 Subject: [PATCH] add proper types to store --- src/components/Amogus/Amogus.tsx | 1 + src/components/Flatastic/Flatastic.tsx | 8 +++++--- src/store/flatastic.ts | 20 +++++++++++++++----- src/store/homeAssistant.ts | 8 +++++++- tsconfig.app.json | 15 +++++++-------- 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/components/Amogus/Amogus.tsx b/src/components/Amogus/Amogus.tsx index 9126e4e..0681f45 100644 --- a/src/components/Amogus/Amogus.tsx +++ b/src/components/Amogus/Amogus.tsx @@ -19,6 +19,7 @@ const { innerWidth: width, innerHeight: height } = window; const getImage = (sus: Amogus) => (sus.isImposter ? imposter : amogus); const makeInitialCrewmates = (): Amogus[] => { + console.log("innerWidth", innerWidth, "innerHeight", innerHeight); return [ makeCrewmate(true), makeCrewmate(false), diff --git a/src/components/Flatastic/Flatastic.tsx b/src/components/Flatastic/Flatastic.tsx index 8513589..1768594 100644 --- a/src/components/Flatastic/Flatastic.tsx +++ b/src/components/Flatastic/Flatastic.tsx @@ -90,9 +90,11 @@ export default function Flatastic() { const shoppingList = flatasticData?.shoppingList || []; - const shoppingListRender = shoppingList.map((item) => { - return shoppingItem(item); - }); + const shoppingListRender = shoppingList.map( + (item: FlatasticShoppingItem) => { + return shoppingItem(item); + }, + ); const shoppingListContainer = shoppingList.length > 0 && (

Shopping List

diff --git a/src/store/flatastic.ts b/src/store/flatastic.ts index 83d0768..45ef627 100644 --- a/src/store/flatastic.ts +++ b/src/store/flatastic.ts @@ -7,15 +7,25 @@ import type { FlatasticUser, } from "@/types/flatasticChore"; -// biome-ignore format: deep -function parseInformationData(data): FlatasticUser[] { +interface FlatasticState { + flatasticData: { + chores: FlatasticChore[]; + users: FlatasticUser[]; + shoppingList: FlatasticShoppingItem[]; + }; + fetch: () => Promise; +} + +function parseInformationData(data: { + flatmates: Array<{ id: string; firstName: string }>; +}): FlatasticUser[] { return data.flatmates.map((user: { id: string; firstName: string }) => ({ - id: user.id as string, - firstName: user.firstName as string, + id: Number(user.id) as number, + firstName: user.firstName, })); } -const useFlatasticStore = create( +const useFlatasticStore = create()( devtools( (set) => ({ flatasticData: { diff --git a/src/store/homeAssistant.ts b/src/store/homeAssistant.ts index 7ebbf73..3878be9 100644 --- a/src/store/homeAssistant.ts +++ b/src/store/homeAssistant.ts @@ -2,7 +2,13 @@ import { create } from "zustand"; import { devtools } from "zustand/middleware"; import { fetchTentHumidity, fetchTentTemperature } from "@/api/homeAssistant"; -const useHomeAssistantStore = create( +interface HomeAssistantState { + tentTemperature: number; + tentHumidity: number; + fetch: () => Promise; +} + +const useHomeAssistantStore = create()( devtools( (set) => ({ tentTemperature: 0, diff --git a/tsconfig.app.json b/tsconfig.app.json index 765e41b..d77c897 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -14,15 +14,14 @@ "moduleDetection": "force", "noEmit": true, "jsx": "react-jsx", - "baseUrl": ".", "paths": { - "@/*": ["src/*"], - "@components/*": ["src/components/*"], - "@store/*": ["src/store/*"], - "@api/*": ["src/api/*"], - "@types/*": ["src/types/*"], - "@thunks/*": ["src/store/thunks/*"], - "@slices/*": ["src/store/slices/*"] + "@/*": ["./src/*"], + "@components/*": ["./src/components/*"], + "@store/*": ["./src/store/*"], + "@api/*": ["./src/api/*"], + "@types/*": ["./src/types/*"], + "@thunks/*": ["./src/store/thunks/*"], + "@slices/*": ["./src/store/slices/*"] }, /* Linting */