import * as React from 'react'; import * as System from '~/components/system'; import * as Actions from '~/common/actions'; import { css } from '@emotion/react'; import ScenePage from '~/components/core/ScenePage'; import Avatar from '~/components/core/Avatar'; const STYLES_FILE_HIDDEN = css` height: 1px; width: 1px; opacity: 0; visibility: hidden; position: fixed; top: -1px; left: -1px; `; export default class SceneEditAccount extends React.Component { state = { name: this.props.viewer.name }; _handleUpload = async (e) => { e.persist(); let file = e.target.files[0]; if (!file) { alert('Something went wrong'); } let data = new FormData(); data.append('image', file); const options = { method: 'POST', headers: { Accept: 'application/json', }, body: data, }; await fetch(`/_/upload/avatar`, options); }; _handleSave = async (e) => { const options = { method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'application/json', }, credentials: 'include', body: JSON.stringify({ local: { name: this.state.name } }), }; await fetch(`/_/local-settings`, options); }; _handleChange = (e) => { e.persist(); this.setState({ [e.target.name]: e.target.value }); }; render() { return ( Account
Upload
Save
); } }