diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b05cd0d..d1449db3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Removed + +- Profile picture upload. + ## [1.11.4] - 2020-01-03 ### Changed diff --git a/react/components/Menu/ProfilePicture/BaseDropzone.tsx b/react/components/Menu/ProfilePicture/BaseDropzone.tsx deleted file mode 100644 index 09e3398d..00000000 --- a/react/components/Menu/ProfilePicture/BaseDropzone.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import React, { Component } from 'react' -import ReactDropzone from 'react-dropzone' - -const MAX_SIZE = 4 * 1024 * 1024 - -class BaseDropzone extends Component { - public state = { - isHovering: false, - } - - private handleStartHovering = () => { - this.setState({ isHovering: true }) - } - - private handleStopHovering = () => { - this.setState({ isHovering: false }) - } - - private handleDrop = (files: any) => { - this.setState({ isHovering: false }) - this.props.onDrop(files) - } - - public render() { - const { disabled, children, onClick } = this.props - const { isHovering } = this.state - return ( - - {children} - - ) - } -} - -interface Props { - disabled: boolean - onClick: () => void - onDrop: (files: any) => void -} - -export default BaseDropzone diff --git a/react/components/Menu/ProfilePicture/PictureUploader.tsx b/react/components/Menu/ProfilePicture/PictureUploader.tsx deleted file mode 100644 index cfb3b7f9..00000000 --- a/react/components/Menu/ProfilePicture/PictureUploader.tsx +++ /dev/null @@ -1,131 +0,0 @@ -import React, { Component, Fragment } from 'react' -import { FormattedMessage } from 'react-intl' -import { graphql } from 'react-apollo' -import { Button, Spinner } from 'vtex.styleguide' -import { GenericError } from 'vtex.my-account-commons' - -import UpdateProfilePicture from '../../../graphql/updateProfilePicture.gql' -import BaseDropzone from './BaseDropzone' -import PictureRenderer from './PictureRenderer' - -class PictureUploader extends Component { - public state = { - error: null, - isLoading: false, - finishedUpload: false, - previewPicture: null, - file: null, - } - - private handleImageDrop = async (acceptedFiles: any) => { - if (acceptedFiles && acceptedFiles[0]) { - this.setState({ - error: null, - finishedUpload: true, - previewPicture: URL.createObjectURL(acceptedFiles[0]), - file: acceptedFiles[0], - }) - } else { - this.setState({ error: 'alert.fileTooBig' }) - } - } - - private handleErrorReset = () => { - this.setState({ error: null }) - } - - private handleSaveClick = async (event: any) => { - event.stopPropagation() - const { updateProfilePicture } = this.props - const { file } = this.state - this.setState({ isLoading: true, finishedUpload: false }) - try { - await updateProfilePicture({ variables: { file } }) - this.setState({ isLoading: false, finishedUpload: true }) - } catch (e) { - this.setState({ error: 'alert.unknownError', isLoading: false }) - } - - this.props.onCloseClick() - } - - public render() { - const { currentPicture } = this.props - const { error, isLoading, finishedUpload, previewPicture } = this.state - const boxText = finishedUpload - ? 'upload.photoUpdated' - : 'upload.dragYourPhoto' - - return ( - - {error && ( -
- -
- )} - -
- {isLoading ? ( - - -
- -
-
- ) : ( - -
- -
-
- -
- {finishedUpload ? ( - -
- -
- -
- ) : ( - -
-
- - - -
-
- - - )} - - )} -
- - - ) - } -} - -interface Props { - updateProfilePicture: (args: Variables) => void - currentPicture?: string - onCloseClick: () => void -} - -export default graphql(UpdateProfilePicture, { - options: { refetchQueries: ['Greeting'] }, - name: 'updateProfilePicture', -})(PictureUploader) diff --git a/react/components/Menu/ProfilePicture/UserPicture.tsx b/react/components/Menu/ProfilePicture/UserPicture.tsx deleted file mode 100644 index 02288812..00000000 --- a/react/components/Menu/ProfilePicture/UserPicture.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import React, { Component } from 'react' -import { Modal } from 'vtex.styleguide' - -import PictureUploader from './PictureUploader' -import PictureRenderer from './PictureRenderer' - -class UserPicture extends Component { - public state = { - isModalOpen: false, - } - - private handleOpenModal = () => { - this.setState({ isModalOpen: true }) - } - - private handleCloseModal = () => { - this.setState({ isModalOpen: false }) - } - - public render() { - const { imagePath } = this.props - const { isModalOpen } = this.state - - return ( - - - - -
- -
-
-
- ) - } -} - -interface Props { - imagePath?: string -} - -export default UserPicture diff --git a/react/components/Menu/UserInfo.tsx b/react/components/Menu/UserInfo.tsx index 1b5b85e6..19e857cc 100644 --- a/react/components/Menu/UserInfo.tsx +++ b/react/components/Menu/UserInfo.tsx @@ -4,15 +4,15 @@ import { compose, branch, withProps, renderComponent } from 'recompose' import { FormattedMessage } from 'react-intl' import GetGreeting from '../../graphql/getGreeting.gql' -import UserPicture from './ProfilePicture/UserPicture' import UserInfoLoading from './UserInfoLoading' import styles from '../../styles.css' +import PictureRenderer from './ProfilePicture/PictureRenderer' const UserInfo: FunctionComponent = ({ profile }) => { return (
- +
{profile.firstName ? (
diff --git a/react/graphql/updateProfilePicture.gql b/react/graphql/updateProfilePicture.gql deleted file mode 100644 index 06690daa..00000000 --- a/react/graphql/updateProfilePicture.gql +++ /dev/null @@ -1,6 +0,0 @@ -mutation UpdateProfilePicture($file: Upload!) { - updateProfilePicture(file: $file) { - cacheId - profilePicture - } -}