name the stores
This commit is contained in:
@@ -1,14 +1,15 @@
|
|||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
import Flatastic from "@/api/flatastic";
|
import Flatastic from "@/api/flatastic";
|
||||||
import type { FlatasticChore } from "@/types/flatasticChore";
|
import type { FlatasticChore } from "@/types/flatasticChore";
|
||||||
|
import { devtools } from "zustand/middleware";
|
||||||
|
|
||||||
interface FlatasticStore {
|
interface FlatasticStore {
|
||||||
chores: FlatasticChore[];
|
chores: FlatasticChore[];
|
||||||
fetch: () => Promise<void>;
|
fetch: () => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const useFlatasticStore = create<FlatasticStore>(
|
const useFlatasticStore = create(
|
||||||
(set: (state: Partial<FlatasticStore>) => void) => ({
|
devtools((set) => ({
|
||||||
chores: [],
|
chores: [],
|
||||||
fetch: async () => {
|
fetch: async () => {
|
||||||
if (!import.meta.env.VITE_FLATTASTIC_API_KEY) {
|
if (!import.meta.env.VITE_FLATTASTIC_API_KEY) {
|
||||||
@@ -20,6 +21,8 @@ const useFlatasticStore = create<FlatasticStore>(
|
|||||||
console.log("Flatastic chores fetched:", data);
|
console.log("Flatastic chores fetched:", data);
|
||||||
set({ chores: data as FlatasticChore[] });
|
set({ chores: data as FlatasticChore[] });
|
||||||
},
|
},
|
||||||
|
}), {
|
||||||
|
name: "flatastic-store",
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ const useKVVStore = create(
|
|||||||
pStreet: pStreetJson as DepartureType[],
|
pStreet: pStreetJson as DepartureType[],
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
})),
|
}), {
|
||||||
|
name: "kvv-store",
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
export { useKVVStore };
|
export { useKVVStore };
|
||||||
|
|||||||
Reference in New Issue
Block a user