2023-08-11 11:48:33 +00:00
|
|
|
import { useEffect } from "react";
|
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
|
2024-03-19 14:38:35 +00:00
|
|
|
import { useMobxStore } from "@/lib/mobx/store-provider";
|
2023-08-11 11:48:33 +00:00
|
|
|
|
|
|
|
const MobxStoreInit = () => {
|
2023-12-06 15:01:42 +00:00
|
|
|
const { user: userStore } = useMobxStore();
|
2023-09-01 11:12:30 +00:00
|
|
|
|
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;
|