feat : add redux

This commit is contained in:
alij
2024-06-16 01:24:40 +04:30
parent 2a8a2b6c71
commit db5840e0b7
5 changed files with 116 additions and 2 deletions

View File

@@ -1,3 +1,18 @@
export const isAuthenticated = () => {
return false;
import { useSelector } from "react-redux";
import { RootState } from "../redux/store";
const isTokenValid = (token: string): boolean => {
try {
if (!token) return false;
return !!token;
} catch (error) {
console.error("Token validation error:", error);
return false;
}
};
export const isAuthenticated = () : boolean => {
const {token} = useSelector((state : RootState) => state.token)
return isTokenValid(token);
};