aboutsummaryrefslogtreecommitdiff
path: root/src/containers/Profile
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-10-29 23:53:13 +0300
committereug-vs <eug-vs@keemail.me>2020-10-29 23:54:35 +0300
commit3fef7795681c405322aed6e1c876948ebc2cc932 (patch)
treec961340ae0364e189361ff7032377f41756e79c7 /src/containers/Profile
parente086da62473bf542d972aa53e605926f9af796f5 (diff)
downloadwhich-ui-3fef7795681c405322aed6e1c876948ebc2cc932.tar.gz
refactor: separate ImageCropAreaSelect component
Diffstat (limited to 'src/containers/Profile')
-rw-r--r--src/containers/Profile/ProfileInfo.tsx15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/containers/Profile/ProfileInfo.tsx b/src/containers/Profile/ProfileInfo.tsx
index b71e6db..4c9f17e 100644
--- a/src/containers/Profile/ProfileInfo.tsx
+++ b/src/containers/Profile/ProfileInfo.tsx
@@ -11,7 +11,7 @@ import Avatar from '../../components/Avatar/Avatar';
import { patch } from '../../requests';
import { useAuth } from '../../hooks/useAuth';
import uploadFileToS3 from '../../utils/uploadFileToS3';
-import AvatarCrop from "../../components/AvatarCrop/AvatarCrop";
+import AvatarCropModal from '../AvatarCropModal/AvatarCropModal';
interface PropTypes {
savedPolls: number;
@@ -112,13 +112,10 @@ const ProfileInfo: React.FC<PropTypes> = ({
const dateSince = useMemo(() => formatDate(userInfo?.createdAt), [userInfo]);
const handleUpdateAvatar = useCallback(async (file: File) => {
- if (user) {
- uploadFileToS3(file, 0.8, setProgress)
- .then(avatarUrl => patch(`/users/${user._id}`, { avatarUrl }))
- .then(response => setUserInfo(response.data))
- .then(() => setProgress(0));
- setAvatarToCrop('');
- }
+ if (user) uploadFileToS3(file, 0.8, setProgress)
+ .then(avatarUrl => patch(`/users/${user._id}`, { avatarUrl }))
+ .then(response => setUserInfo(response.data))
+ .then(() => setProgress(0));
}, [user, setUserInfo]);
const handleCropAvatar = useCallback( async(file: File) => {
@@ -129,7 +126,7 @@ const ProfileInfo: React.FC<PropTypes> = ({
return (
<div className={classes.root}>
{
- avatarToCrop && <AvatarCrop avatarToCrop={avatarToCrop} setAvatarToCrop={setAvatarToCrop} callback={handleUpdateAvatar}/>
+ avatarToCrop && <AvatarCropModal avatar={avatarToCrop} callback={handleUpdateAvatar}/>
}
{
!userInfo