import axios from 'axios'; import reduce from 'image-blob-reduce'; import { useContext, useEffect } from 'react'; import * as cookie from 'react-cookies'; import { AccountAvatar } from '../components/account'; import { Footer } from '../components/footer'; import { CurrentGameSettings } from '../components/gameSettings'; import { NavBar } from '../components/navbar'; import { CenteredPage, PageTitle } from '../components/page'; import PreferencesContext from '../components/preferencesContext'; import ThemePicker from '../components/themes'; import { CheckBox, ColorPicker, IconLabelButton, Vierkant } from '../components/ui'; import EditOutlinedIcon from '@material-ui/icons/EditOutlined'; import PublishOutlinedIcon from '@material-ui/icons/PublishOutlined'; import VisibilityOutlinedIcon from '@material-ui/icons/VisibilityOutlined'; async function uploadNewProfileImage() { if (!this.result) return; var result = this.result.split(';'); var mimeType = result[0].substr(5); if (!['image/png', 'image/jpeg'].includes(mimeType)) return; var blob = await (await fetch(this.result)).blob(); var image = await new reduce().toBlob(blob, { max: 256 }); var reader = new FileReader(); reader.readAsBinaryString(image); reader.onload = async () => { await axios.request({ method: 'post', url: `/api/user/avatar`, headers: { 'content-type': 'image/png' }, data: btoa(reader.result as string), }); window.location.reload(); // TODO: this is straight garbage }; } export default function SettingsPage() { useEffect(() => { var loggedIn = !!cookie.load('token'); if (!loggedIn) window.location.href = '/'; }, []); var { preferences, updatePreference } = useContext(PreferencesContext); return (
Hier staat hij dan
******@example.com