mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
* small typing * typing fixes --------- Co-authored-by: Igor Loskutov <igor.loskutoff@gmail.com>
23 lines
578 B
TypeScript
23 lines
578 B
TypeScript
"use client";
|
|
|
|
import { useState, useEffect } from "react";
|
|
import { useSession as useNextAuthSession } from "next-auth/react";
|
|
import { Session } from "next-auth";
|
|
|
|
export default function useSessionStatus() {
|
|
const { status: naStatus } = useNextAuthSession();
|
|
const [status, setStatus] = useState<typeof naStatus>("loading");
|
|
|
|
useEffect(() => {
|
|
if (naStatus !== "loading" && naStatus !== status) {
|
|
setStatus(naStatus);
|
|
}
|
|
}, [naStatus]);
|
|
|
|
return {
|
|
status,
|
|
isLoading: status === "loading",
|
|
isAuthenticated: status === "authenticated",
|
|
};
|
|
}
|