2022-03-21 04:36:31 -04:00
|
|
|
import Cookies from "js-cookie";
|
|
|
|
import { useEffect, useState } from "react";
|
2022-03-06 19:46:59 -05:00
|
|
|
|
2022-03-21 04:36:31 -04:00
|
|
|
const useSignedIn = () => {
|
|
|
|
const [signedIn, setSignedIn] = useState(typeof window === 'undefined' ? false : !!Cookies.get("drift-token"));
|
2022-03-06 19:46:59 -05:00
|
|
|
|
|
|
|
useEffect(() => {
|
2022-03-21 04:36:31 -04:00
|
|
|
if (Cookies.get("drift-token")) {
|
|
|
|
setSignedIn(true);
|
|
|
|
} else {
|
|
|
|
setSignedIn(false);
|
2022-03-06 19:46:59 -05:00
|
|
|
}
|
2022-03-21 04:36:31 -04:00
|
|
|
}, []);
|
2022-03-06 19:46:59 -05:00
|
|
|
|
2022-03-21 04:36:31 -04:00
|
|
|
return signedIn;
|
2022-03-06 19:46:59 -05:00
|
|
|
}
|
|
|
|
|
2022-03-21 04:36:31 -04:00
|
|
|
export default useSignedIn;
|