push rasad front on new repo
This commit is contained in:
18
src/features/authentication/hooks/useUserProfile.js
Normal file
18
src/features/authentication/hooks/useUserProfile.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { useEffect } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { getUserProfile } from "../services/getUserProfile";
|
||||
|
||||
const useUserProfile = () => {
|
||||
const dispatch = useDispatch();
|
||||
const { role, userProfile } = useSelector((state) => state.userSlice);
|
||||
|
||||
useEffect(() => {
|
||||
if (!userProfile) {
|
||||
dispatch(getUserProfile());
|
||||
}
|
||||
}, []);
|
||||
|
||||
return [role, userProfile];
|
||||
};
|
||||
|
||||
export default useUserProfile;
|
||||
Reference in New Issue
Block a user