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 getImage = (sus: Amogus) => (sus.isImposter ? imposter : amogus);
|
||||||
|
|
||||||
const makeInitialCrewmates = (): Amogus[] => {
|
const makeInitialCrewmates = (): Amogus[] => {
|
||||||
|
console.log("innerWidth", innerWidth, "innerHeight", innerHeight);
|
||||||
return [
|
return [
|
||||||
makeCrewmate(true),
|
makeCrewmate(true),
|
||||||
makeCrewmate(false),
|
makeCrewmate(false),
|
||||||
|
|||||||
@@ -90,9 +90,11 @@ export default function Flatastic() {
|
|||||||
|
|
||||||
const shoppingList = flatasticData?.shoppingList || [];
|
const shoppingList = flatasticData?.shoppingList || [];
|
||||||
|
|
||||||
const shoppingListRender = shoppingList.map((item) => {
|
const shoppingListRender = shoppingList.map(
|
||||||
return shoppingItem(item);
|
(item: FlatasticShoppingItem) => {
|
||||||
});
|
return shoppingItem(item);
|
||||||
|
},
|
||||||
|
);
|
||||||
const shoppingListContainer = shoppingList.length > 0 && (
|
const shoppingListContainer = shoppingList.length > 0 && (
|
||||||
<div className={style.shoppingListContainer}>
|
<div className={style.shoppingListContainer}>
|
||||||
<h1>Shopping List</h1>
|
<h1>Shopping List</h1>
|
||||||
|
|||||||
+15
-5
@@ -7,15 +7,25 @@ import type {
|
|||||||
FlatasticUser,
|
FlatasticUser,
|
||||||
} from "@/types/flatasticChore";
|
} from "@/types/flatasticChore";
|
||||||
|
|
||||||
// biome-ignore format: deep
|
interface FlatasticState {
|
||||||
function parseInformationData(data): FlatasticUser[] {
|
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 }) => ({
|
return data.flatmates.map((user: { id: string; firstName: string }) => ({
|
||||||
id: user.id as string,
|
id: Number(user.id) as number,
|
||||||
firstName: user.firstName as string,
|
firstName: user.firstName,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
const useFlatasticStore = create(
|
const useFlatasticStore = create<FlatasticState>()(
|
||||||
devtools(
|
devtools(
|
||||||
(set) => ({
|
(set) => ({
|
||||||
flatasticData: {
|
flatasticData: {
|
||||||
|
|||||||
@@ -2,7 +2,13 @@ import { create } from "zustand";
|
|||||||
import { devtools } from "zustand/middleware";
|
import { devtools } from "zustand/middleware";
|
||||||
import { fetchTentHumidity, fetchTentTemperature } from "@/api/homeAssistant";
|
import { fetchTentHumidity, fetchTentTemperature } from "@/api/homeAssistant";
|
||||||
|
|
||||||
const useHomeAssistantStore = create(
|
interface HomeAssistantState {
|
||||||
|
tentTemperature: number;
|
||||||
|
tentHumidity: number;
|
||||||
|
fetch: () => Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const useHomeAssistantStore = create<HomeAssistantState>()(
|
||||||
devtools(
|
devtools(
|
||||||
(set) => ({
|
(set) => ({
|
||||||
tentTemperature: 0,
|
tentTemperature: 0,
|
||||||
|
|||||||
+7
-8
@@ -14,15 +14,14 @@
|
|||||||
"moduleDetection": "force",
|
"moduleDetection": "force",
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"baseUrl": ".",
|
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["src/*"],
|
"@/*": ["./src/*"],
|
||||||
"@components/*": ["src/components/*"],
|
"@components/*": ["./src/components/*"],
|
||||||
"@store/*": ["src/store/*"],
|
"@store/*": ["./src/store/*"],
|
||||||
"@api/*": ["src/api/*"],
|
"@api/*": ["./src/api/*"],
|
||||||
"@types/*": ["src/types/*"],
|
"@types/*": ["./src/types/*"],
|
||||||
"@thunks/*": ["src/store/thunks/*"],
|
"@thunks/*": ["./src/store/thunks/*"],
|
||||||
"@slices/*": ["src/store/slices/*"]
|
"@slices/*": ["./src/store/slices/*"]
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Linting */
|
/* Linting */
|
||||||
|
|||||||
Reference in New Issue
Block a user