2023-08-11 11:48:33 +00:00
|
|
|
import { useEffect } from "react";
|
2023-09-01 11:12:30 +00:00
|
|
|
// next imports
|
|
|
|
import { useRouter } from "next/router";
|
2023-10-04 13:51:04 +00:00
|
|
|
// js cookie
|
|
|
|
import Cookie from "js-cookie";
|
2023-08-11 11:48:33 +00:00
|
|
|
// mobx store
|
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
|
|
|
import { RootStore } from "store/root";
|
|
|
|
|
|
|
|
const MobxStoreInit = () => {
|
2023-10-04 13:51:04 +00:00
|
|
|
const { user: userStore }: RootStore = useMobxStore();
|
2023-08-11 11:48:33 +00:00
|
|
|
|
2023-09-01 11:12:30 +00:00
|
|
|
const router = useRouter();
|
|
|
|
const { states, labels, priorities } = router.query as { states: string[]; labels: string[]; priorities: string[] };
|
|
|
|
|
2023-10-04 13:51:04 +00:00
|
|
|
useEffect(() => {
|
|
|
|
const authToken = Cookie.get("accessToken") || null;
|
|
|
|
if (authToken) userStore.fetchCurrentUser();
|
|
|
|
}, [userStore]);
|
|
|
|
|
2023-08-11 11:48:33 +00:00
|
|
|
return <></>;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default MobxStoreInit;
|