replace redux with zustand

This commit is contained in:
2025-07-25 01:03:11 +02:00
parent 5448285211
commit 3bcd2e16a2
30 changed files with 510 additions and 534 deletions

25
src/store/kvv.ts Normal file
View File

@@ -0,0 +1,25 @@
import { create } from "zustand";
import { fetchKvvDepartures } from "@/api/kvv";
import type { DepartureType } from "@/types/departureType";
import { devtools } from "zustand/middleware";
const useKVVStore = create(
devtools((set) => ({
pStreet: [] as DepartureType[],
hStreet: [] as DepartureType[],
fetch: async () => {
const hStreetStopId = 7000044;
const pStreetStopId = 7000045;
const hStreetData = await fetchKvvDepartures(hStreetStopId);
const pStreetData = await fetchKvvDepartures(pStreetStopId);
const hStreetJson = await hStreetData.json();
const pStreetJson = await pStreetData.json();
set({
hStreet: hStreetJson as DepartureType[],
pStreet: pStreetJson as DepartureType[],
});
},
})),
);
export { useKVVStore };