continue dispatch-server
This commit is contained in:
16
apps/dispatch/app/_store/connectionStore.ts
Normal file
16
apps/dispatch/app/_store/connectionStore.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { create } from "zustand";
|
||||
import { socket } from "../(dispatch)/socket";
|
||||
|
||||
console.log("connectionStore");
|
||||
|
||||
export const connectionStore = create((set) => ({
|
||||
isConnected: false,
|
||||
connect: async (jwt: string) => {
|
||||
socket.auth = { token: "jwt" };
|
||||
socket.connect();
|
||||
},
|
||||
}));
|
||||
|
||||
socket.on("connect", () => {
|
||||
connectionStore.setState({ isConnected: true });
|
||||
});
|
||||
9
apps/dispatch/app/_store/stationsStore.ts
Normal file
9
apps/dispatch/app/_store/stationsStore.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { create } from "zustand";
|
||||
import { socket } from "../(dispatch)/socket";
|
||||
|
||||
export const stationStore = create((set) => {
|
||||
return {
|
||||
stations: [],
|
||||
setStations: (stations: any) => set({ stations }),
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user