|
@@ -2,6 +2,8 @@ import { makeStyles, TextField } from '@material-ui/core'
|
|
import ListItemAvatar from '@mui/material/ListItemAvatar';
|
|
import ListItemAvatar from '@mui/material/ListItemAvatar';
|
|
import Avatar from '@mui/material/Avatar';
|
|
import Avatar from '@mui/material/Avatar';
|
|
import AddAPhotoIcon from '@mui/icons-material/AddAPhoto';
|
|
import AddAPhotoIcon from '@mui/icons-material/AddAPhoto';
|
|
|
|
+import PhotoCameraFrontIcon from '@mui/icons-material/PhotoCameraFront';
|
|
|
|
+import CameraIcon from '@mui/icons-material/Camera';
|
|
import { useEffect } from 'react';
|
|
import { useEffect } from 'react';
|
|
import { useDropzone } from 'react-dropzone';
|
|
import { useDropzone } from 'react-dropzone';
|
|
import Webcam from "react-webcam";
|
|
import Webcam from "react-webcam";
|
|
@@ -21,37 +23,46 @@ const useStyles = makeStyles({
|
|
backgroundColor: '#ffffff',
|
|
backgroundColor: '#ffffff',
|
|
},
|
|
},
|
|
imgWrapper: {
|
|
imgWrapper: {
|
|
- cursor: 'pointer',
|
|
|
|
marginBottom: 30,
|
|
marginBottom: 30,
|
|
- position: 'relative',
|
|
|
|
|
|
+ width: '100%',
|
|
|
|
+ display: 'flex',
|
|
|
|
+ flexWrap: 'nowrap',
|
|
|
|
+ alignItems: 'center',
|
|
|
|
+ alignContent: 'center',
|
|
|
|
+ flexDirection: 'row',
|
|
|
|
+ justifyContent:'center'
|
|
},
|
|
},
|
|
- imgDropZoneOverlay: {
|
|
|
|
- position: 'absolute',
|
|
|
|
- width: 120,
|
|
|
|
- height: 120,
|
|
|
|
- borderRadius: '50%',
|
|
|
|
- backgroundColor: '#6868687d',
|
|
|
|
|
|
+ overlay: {
|
|
|
|
+ position: 'fixed',
|
|
|
|
+ top: 0,
|
|
left: 0,
|
|
left: 0,
|
|
- zIndex: 1,
|
|
|
|
|
|
+ width: '100vw',
|
|
|
|
+ height: '100vh',
|
|
|
|
+ zIndex: 100,
|
|
|
|
+ backgroundColor: 'rgba(104, 105, 104, 0.6)',
|
|
|
|
+ overflowY: 'hidden',
|
|
display: 'flex',
|
|
display: 'flex',
|
|
justifyContent: 'center',
|
|
justifyContent: 'center',
|
|
alignContent: 'center',
|
|
alignContent: 'center',
|
|
- alignItems:'center'
|
|
|
|
|
|
+ alignItems: 'center',
|
|
|
|
+ flexDirection:'column'
|
|
},
|
|
},
|
|
- addPhoto: {
|
|
|
|
|
|
+ capturedPicture: {
|
|
|
|
+ borderRadius: 10,
|
|
|
|
+ border:'solid 2px rgb(62, 149, 231)'
|
|
|
|
+ },
|
|
|
|
+ capturePhoto: {
|
|
color: '#ffffff',
|
|
color: '#ffffff',
|
|
- transform: 'scale(1.1)',
|
|
|
|
- '&:hover': {
|
|
|
|
- transform: 'scale(1.3)',
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- avatarArrow: {
|
|
|
|
cursor: 'pointer',
|
|
cursor: 'pointer',
|
|
- alignSelf: 'flex-end',
|
|
|
|
'&:hover': {
|
|
'&:hover': {
|
|
- backgroundColor: 'rgb(62, 149, 231)'
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ color: '#48ff00',
|
|
|
|
+ animation: `$rotating 2s linear infinite`
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ '@keyframes rotating': {
|
|
|
|
+ 'from': { transform: 'rotate(0deg)'},
|
|
|
|
+ 'to': { transform: 'rotate(360deg)'},
|
|
|
|
+ },
|
|
})
|
|
})
|
|
|
|
|
|
interface IEditList {
|
|
interface IEditList {
|
|
@@ -63,13 +74,17 @@ interface IEditList {
|
|
openBtn: boolean,
|
|
openBtn: boolean,
|
|
setOpenBtn: any,
|
|
setOpenBtn: any,
|
|
file:any,
|
|
file:any,
|
|
- setFile: (file:any) => void
|
|
|
|
|
|
+ setFile: (file: any) => void,
|
|
|
|
+ camera: boolean,
|
|
|
|
+ setCamera: any,
|
|
|
|
+ selfie:any,
|
|
|
|
+ setSelfie: (file: any) => void,
|
|
}
|
|
}
|
|
|
|
|
|
const EditList = (props: IEditList) => {
|
|
const EditList = (props: IEditList) => {
|
|
const classes = useStyles()
|
|
const classes = useStyles()
|
|
const { user, name, setName, lastName, setLastName,
|
|
const { user, name, setName, lastName, setLastName,
|
|
- openBtn, setOpenBtn,setFile } = props
|
|
|
|
|
|
+ openBtn, setOpenBtn,file,setFile,camera,setCamera,selfie,setSelfie } = props
|
|
const { avatarUrl, color } = user
|
|
const { avatarUrl, color } = user
|
|
const { getRootProps, getInputProps, acceptedFiles } = useDropzone({
|
|
const { getRootProps, getInputProps, acceptedFiles } = useDropzone({
|
|
noDrag: true,
|
|
noDrag: true,
|
|
@@ -98,40 +113,64 @@ const EditList = (props: IEditList) => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ const handleOpenCamera = () => {
|
|
|
|
+ setCamera(true)
|
|
|
|
+ file&&setFile(null)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const handleCloseCamera = (e: any) => {
|
|
|
|
+ const id = e.target.id
|
|
|
|
+ if (id === 'overlay') {
|
|
|
|
+ setCamera(false)
|
|
|
|
+ setOpenBtn(true)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
if (acceptedFiles.slice(-1)[0]) {
|
|
if (acceptedFiles.slice(-1)[0]) {
|
|
setFile(acceptedFiles.slice(-1)[0])
|
|
setFile(acceptedFiles.slice(-1)[0])
|
|
|
|
+ setSelfie(false)
|
|
setOpenBtn(true)
|
|
setOpenBtn(true)
|
|
}
|
|
}
|
|
- }, [setFile,setOpenBtn,acceptedFiles])
|
|
|
|
|
|
+ }, [setFile,setSelfie,setOpenBtn,acceptedFiles])
|
|
|
|
|
|
return (
|
|
return (
|
|
- <div className={classes.container} >
|
|
|
|
- <ListItemAvatar className={classes.imgWrapper}>
|
|
|
|
- <div {...getRootProps({ className: classes.imgDropZoneOverlay })}>
|
|
|
|
- <AddAPhotoIcon className={classes.addPhoto} fontSize='large' />
|
|
|
|
|
|
+ <div className={classes.container}>
|
|
|
|
+ <div className={classes.imgWrapper}>
|
|
|
|
+ <div {...getRootProps()}>
|
|
|
|
+ <AddAPhotoIcon fontSize='large'
|
|
|
|
+ sx={{color: file ? 'rgb(62, 149, 231)' : '#6b6b6b',
|
|
|
|
+ '&:hover': { color: 'rgb(41, 139, 231)' },cursor:'pointer'}} />
|
|
<input {...getInputProps()}/>
|
|
<input {...getInputProps()}/>
|
|
</div>
|
|
</div>
|
|
- <Avatar alt={name} src={avatarUrl?`${prodAwsS3}/${avatarUrl}`:undefined}
|
|
|
|
- sx={{ background: color, width: 120, height: 120}}>
|
|
|
|
|
|
+ <ListItemAvatar style={{margin:'0px 20px'}}>
|
|
|
|
+ <Avatar alt={name} src={avatarUrl?`${prodAwsS3}/${avatarUrl}`:undefined}
|
|
|
|
+ sx={{ background: color, width: 120, height: 120,fontSize:30}}>
|
|
{`${firstLetter(name)}${firstLetter(lastName)}`}
|
|
{`${firstLetter(name)}${firstLetter(lastName)}`}
|
|
- </Avatar>
|
|
|
|
- </ListItemAvatar>
|
|
|
|
- <Webcam
|
|
|
|
|
|
+ </Avatar>
|
|
|
|
+ </ListItemAvatar>
|
|
|
|
+ <PhotoCameraFrontIcon onClick={handleOpenCamera} fontSize='large'
|
|
|
|
+ sx={{color: selfie ? 'rgb(62, 149, 231)' : '#6b6b6b',
|
|
|
|
+ '&:hover': { color: 'rgb(41, 139, 231)' },cursor:'pointer'}}/>
|
|
|
|
+ </div>
|
|
|
|
+ {camera &&
|
|
|
|
+ <div onClick={handleCloseCamera}
|
|
|
|
+ className={classes.overlay} id='overlay'>
|
|
|
|
+ <Webcam
|
|
audio={false}
|
|
audio={false}
|
|
- height={300}
|
|
|
|
screenshotFormat="image/jpeg"
|
|
screenshotFormat="image/jpeg"
|
|
- width={300}
|
|
|
|
|
|
+ width='40%'
|
|
videoConstraints={videoConstraints}
|
|
videoConstraints={videoConstraints}
|
|
|
|
+ style={{marginBottom:30}}
|
|
>
|
|
>
|
|
- {({ getScreenshot }) => (
|
|
|
|
- <button onClick={() => {
|
|
|
|
- setFile(getScreenshot())
|
|
|
|
- !openBtn&&setOpenBtn(true)
|
|
|
|
- }}>
|
|
|
|
- Capture photo
|
|
|
|
- </button>)}
|
|
|
|
- </Webcam>
|
|
|
|
|
|
+ {({ getScreenshot }) => <>
|
|
|
|
+ <CameraIcon onClick={() => setSelfie(getScreenshot())}
|
|
|
|
+ className={classes.capturePhoto} fontSize='large' style={{marginBottom:30}} />
|
|
|
|
+ <img className={classes.capturedPicture} width='300' height='174'
|
|
|
|
+ style={{visibility:selfie?'visible':'hidden'}} src={selfie} alt='chosen pic'></img>
|
|
|
|
+ </>}
|
|
|
|
+ </Webcam>
|
|
|
|
+ </div>}
|
|
<TextField
|
|
<TextField
|
|
id="name"
|
|
id="name"
|
|
name='name'
|
|
name='name'
|
|
@@ -140,7 +179,7 @@ const EditList = (props: IEditList) => {
|
|
fullWidth
|
|
fullWidth
|
|
variant='outlined'
|
|
variant='outlined'
|
|
onChange={handleTextField}
|
|
onChange={handleTextField}
|
|
- style={{marginBottom:20}}
|
|
|
|
|
|
+ style={{marginBottom:30}}
|
|
/>
|
|
/>
|
|
<TextField
|
|
<TextField
|
|
id="lastName"
|
|
id="lastName"
|