import React from "react"; import PropTypes from "prop-types"; import avatar from "../../assets/images/Avatar.png"; import filters from "../../assets/images/filters.png"; import lock from "../../assets/images/lock.png"; import forbiden from "../../assets/images/forbiden.png"; import IconButton from "../../components/IconButton/IconButton"; import { Link, useParams } from "react-router-dom"; import { deleteUserReq, setEnableUsersReq, userDetailsReq } from "../../store/actions/users/usersActions"; import { useDispatch, useSelector } from "react-redux"; import { USERS_PAGE } from "../../constants/pages"; import { forgetPassword } from "../../store/actions/login/loginActions"; import { useEffect } from "react"; import { useTheme } from "@emotion/react"; import { useMediaQuery } from "@mui/material"; const UserDetails = ({ history }) => { const theme = useTheme(); const matches = useMediaQuery(theme.breakpoints.down("sm")); const { id } = useParams(); const dispatch = useDispatch(); const { user } = useSelector((s) => s.userDetails); const handleReset = (email) => { dispatch( forgetPassword({ email, handleApiResponseSuccessReset, }) ); }; const enableHandler = () =>{ dispatch(setEnableUsersReq({ id: user.id })); } const handleApiResponseSuccessReset = () => { console.log('DONE!') }; const handleApiResponseSuccess = () => { history.push({ pathname: USERS_PAGE, state: { from: history.location.pathname, }, }); }; const deleteHandler = () => { dispatch(deleteUserReq({ id, handleApiResponseSuccess })); }; useEffect(()=>{ dispatch(userDetailsReq({id})) },[dispatch]) return (

Korisnik

{user && user.firstName} {user && user.lastName}

handleReset(user.email)} > {!matches && 'Resetuj password'} {!matches && {user?.isEnabled ? 'Blokiraj' : 'Odblokiraj'} } {!matches && Obrisi } {!matches && "Uredi profil"}

{user?.position ? user.position : "Position has not been declared yet."}

Kontakt

Email:

{user && user.email}

Telefon:

{user?.phoneNumber ? user.phoneNumber : "User has no phone number saved."}

Drustvene mreze

LinkedIn:

{user?.socialMedias ? user.socialMedias : "User takes not part in any social media."}

Nazad na listu korisnika
); }; export default UserDetails; UserDetails.propTypes = { history: PropTypes.shape({ replace: PropTypes.func, push: PropTypes.func, location: PropTypes.shape({ pathname: PropTypes.string, }), }), };