import * as React from "react"; import * as Strings from "~/common/strings"; import * as Constants from "~/common/constants"; import * as System from "~/components/system"; import * as Actions from "~/common/actions"; import * as Events from "~/common/custom-events"; import { css } from "@emotion/react"; const STYLES_HEADER = css` font-family: ${Constants.font.semiBold}; margin-top: 32px; `; export default class SidebarCreateSlate extends React.Component { state = { name: this.props.viewer.data && this.props.viewer.data.name ? this.props.viewer.data.name : "", email: "", twitter: "", message: "", loading: false, }; _handleSubmit = async () => { this.setState({ loading: true }); if (Strings.isEmpty(this.state.email)) { Events.dispatchMessage({ message: "Please provide an email address where we can reach you" }); this.setState({ loading: false }); return; } if (!this.state.message || !this.state.message.length) { Events.dispatchMessage({ message: "Please provide a message" }); this.setState({ loading: false }); return; } const response = await Actions.createSupportMessage({ username: this.props.viewer.username, name: this.state.name, email: this.state.email, twitter: this.state.twitter, message: this.state.message, stored: Strings.bytesToSize(this.props.viewer.stats.bytes), }); if (Events.hasError(response)) { this.setState({ loading: false }); return; } Events.dispatchMessage({ message: "Message sent. You'll hear from us shortly", status: "INFO", }); this.setState({ loading: false }); this.props.onCancel(); return; }; _handleChange = (e) => { this.setState({ [e.target.name]: e.target.value }); }; render() { return (