19 lines
452 B
JavaScript
19 lines
452 B
JavaScript
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;
|