Added Connection Component, Store, JWT logic
This commit is contained in:
17
apps/dispatch/app/(dispatch)/_components/Connection.tsx
Normal file
17
apps/dispatch/app/(dispatch)/_components/Connection.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useSession } from "next-auth/react";
|
||||
import { connectionStore } from "../../_store/connectionStore";
|
||||
import { useEffect } from "react";
|
||||
|
||||
export const Connection = () => {
|
||||
const session = useSession();
|
||||
const cStore = connectionStore((state) => state);
|
||||
const uid = session.data?.user?.id;
|
||||
|
||||
useEffect(() => {
|
||||
if (uid) {
|
||||
cStore.connect(uid);
|
||||
}
|
||||
}, [uid]);
|
||||
|
||||
return <div>{cStore.isConnected ? "Connected" : "Not Connected"}</div>;
|
||||
};
|
||||
Reference in New Issue
Block a user