41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
import {Grid} from "antd";
|
|
import {useDispatch} from "react-redux";
|
|
import {setSelectedUser} from "../../../Redux/Slices/usersSlice.js";
|
|
import {useGetAuthenticatedUserDataQuery} from "../../../Api/usersApi.js";
|
|
|
|
const {useBreakpoint} = Grid;
|
|
|
|
const useProfilePage = () => {
|
|
const dispatch = useDispatch();
|
|
const screens = useBreakpoint();
|
|
|
|
const {
|
|
data: userData = {},
|
|
isLoading: isLoadingUserData,
|
|
isError: isErrorUserData,
|
|
} = useGetAuthenticatedUserDataQuery(undefined, {
|
|
pollingInterval: 20000,
|
|
});
|
|
|
|
const containerStyle = {padding: screens.xs ? 16 : 24};
|
|
const cardStyle = {marginBottom: 24};
|
|
const buttonStyle = {width: screens.xs ? "100%" : "auto"};
|
|
|
|
|
|
const handleEditUser = () => {
|
|
dispatch(setSelectedUser(userData))
|
|
};
|
|
|
|
return {
|
|
userData,
|
|
containerStyle,
|
|
cardStyle,
|
|
buttonStyle,
|
|
isMobile: screens.xs,
|
|
isLoading: isLoadingUserData,
|
|
isError: isErrorUserData,
|
|
handleEditUser,
|
|
};
|
|
};
|
|
|
|
export default useProfilePage; |