add proper types to store
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -90,9 +90,11 @@ export default function Flatastic() {
|
||||
|
||||
const shoppingList = flatasticData?.shoppingList || [];
|
||||
|
||||
const shoppingListRender = shoppingList.map((item) => {
|
||||
const shoppingListRender = shoppingList.map(
|
||||
(item: FlatasticShoppingItem) => {
|
||||
return shoppingItem(item);
|
||||
});
|
||||
},
|
||||
);
|
||||
const shoppingListContainer = shoppingList.length > 0 && (
|
||||
<div className={style.shoppingListContainer}>
|
||||
<h1>Shopping List</h1>
|
||||
|
||||
+15
-5
@@ -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<void>;
|
||||
}
|
||||
|
||||
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<FlatasticState>()(
|
||||
devtools(
|
||||
(set) => ({
|
||||
flatasticData: {
|
||||
|
||||
@@ -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<void>;
|
||||
}
|
||||
|
||||
const useHomeAssistantStore = create<HomeAssistantState>()(
|
||||
devtools(
|
||||
(set) => ({
|
||||
tentTemperature: 0,
|
||||
|
||||
+7
-8
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user