import { Fragment, useState, useRef } from 'react'; import { me, updateAvatar } from '../api'; import Button from './Button'; import Icon from './Icon'; import UploadButton from './UploadButton'; import Avatar from './Avatar'; import { useVisitor } from './VisitorContext'; /** * @param {{ onChange: Function }} props */ function ChangeAvatarForm({ onChange }) { const [visitor] = useVisitor(); const [avatar, setAvatar] = useState(''); const [preview, setPreview] = useState(); const avatarInput = useRef(); let avatarChanged = (newAvatar) => { setAvatar(newAvatar); setPreview(''); if (newAvatar) { let reader = new FileReader(); reader.onloadend = (preview) => { setPreview(preview.target.result); }; reader.readAsDataURL(avatarInput.current.files[0]); } }; let previewUser = { ...visitor, uname: '' }; if (preview) { previewUser = { ...visitor, avatar: preview, uname: '' }; } let onSubmitAvatar = (event) => { if (event.preventDefault) { event.preventDefault(); } updateAvatar(avatarInput.current.files[0]).then(() => { avatarChanged(''); me().then(visitor => { onChange(visitor); }); }); }; return (
Recommendations: PNG, 96x96, <50Kb. Also, JPG and GIF supported. ); } /** * @param {{ onChange: Function }} props */ export default function Settings({ onChange }) { const [visitor] = useVisitor(); let passwordChanged = (event) => { console.log('password changed'); }; let onSubmitPassword = (event) => { if (event.preventDefault) { event.preventDefault(); } console.log('password update'); }; let emailChanged = (event) => { console.log('email update'); }; let disableTelegram = () => { console.log('telegram disable'); }; let disableFacebook = (event) => { if (event.preventDefault) { event.preventDefault(); } console.log('facebook disable'); }; let enableFacebook = (event) => { if (event.preventDefault) { event.preventDefault(); } console.log('facebook enable'); }; let disableTwitter = () => { console.log('twitter disable'); }; let deleteJid = () => { }; let addEmail = () => { }; let deleteEmail = () => { }; return (
Changing your avatar
Changing your password

Change password:
(max. length - 16 symbols)

Telegram {visitor.telegramName ? (
Telegram: {visitor.telegramName}
) : (

To connect Telegram account: send any text message to @Juick_bot

)}
{ visitor.jids && (
XMPP accounts

Your accounts:

{ visitor.jids.map(jid =>
) }

{ visitor.jids && visitor.jids.length > 1 &&

}

To add new jabber account: send any text message to juick@juick.com

)}
E-mail

Add account:

Your accounts:

{ visitor.emails ? visitor.emails.map(email =>
) : '-' }

{ visitor.emails && visitor.emails.length > 1 && }
{ visitor.emails && <> {/** email_off **/}
You can receive notifications to email:
Sent to
{/** /email_off **/}

 

You can post to Juick via e-mail. Send your plain text messages to juick@juick.com. You can attach one photo or video file.

}
Facebook { visitor.facebookStatus && visitor.facebookStatus.connected ? ( visitor.facebookStatus.crosspostEnabled ?
Facebook: Enabled
:
Facebook: Disabled
) : (

Cross-posting to Facebook: Connect to Facebook

)}
Twitter {visitor.twitterName ?
Twitter: {visitor.twitterName}
:

Cross-posting to Twitter: Connect to Twitter

}
); }