2020-09-17 02:26:15 +03:00
|
|
|
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";
|
2020-11-28 07:39:01 +03:00
|
|
|
import * as Events from "~/common/custom-events";
|
2020-09-17 02:26:15 +03:00
|
|
|
|
2020-11-30 08:24:22 +03:00
|
|
|
import { css } from "@emotion/react";
|
2020-09-17 02:26:15 +03:00
|
|
|
|
|
|
|
const STYLES_HEADER = css`
|
|
|
|
font-family: ${Constants.font.semiBold};
|
2020-12-11 05:59:17 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_GROUPING = css`
|
|
|
|
width: 100%;
|
|
|
|
border: 1px solid rgba(196, 196, 196, 0.5);
|
|
|
|
background-color: ${Constants.system.white};
|
|
|
|
border-radius: 6px;
|
|
|
|
padding: 16px;
|
|
|
|
margin-bottom: 24px;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_TEXT = css`
|
|
|
|
color: ${Constants.system.textGray};
|
|
|
|
font-size: ${Constants.typescale.lvl0};
|
2020-09-17 02:26:15 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
export default class SidebarCreateSlate extends React.Component {
|
|
|
|
state = {
|
2021-05-06 03:08:14 +03:00
|
|
|
name: this.props.viewer?.data?.name ? this.props.viewer.data.name : "",
|
2020-09-17 02:26:15 +03:00
|
|
|
email: "",
|
2020-09-17 21:37:29 +03:00
|
|
|
twitter: "",
|
2020-09-17 02:26:15 +03:00
|
|
|
message: "",
|
|
|
|
};
|
|
|
|
|
|
|
|
_handleSubmit = async () => {
|
2020-09-23 23:52:00 +03:00
|
|
|
if (Strings.isEmpty(this.state.email)) {
|
2020-11-28 07:39:01 +03:00
|
|
|
Events.dispatchMessage({ message: "Please provide an email address where we can reach you" });
|
2020-09-17 02:26:15 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.state.message || !this.state.message.length) {
|
2020-11-28 07:39:01 +03:00
|
|
|
Events.dispatchMessage({ message: "Please provide a message" });
|
2020-09-17 02:26:15 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-12-22 04:20:24 +03:00
|
|
|
this.props.onCancel();
|
|
|
|
Events.dispatchMessage({
|
|
|
|
message: "Message sent. You'll hear from us shortly",
|
|
|
|
status: "INFO",
|
|
|
|
});
|
|
|
|
|
2020-09-17 02:26:15 +03:00
|
|
|
const response = await Actions.createSupportMessage({
|
2021-05-06 03:08:14 +03:00
|
|
|
username: this.props.viewer?.username || "",
|
2020-09-17 02:26:15 +03:00
|
|
|
name: this.state.name,
|
|
|
|
email: this.state.email,
|
2020-09-17 21:37:29 +03:00
|
|
|
twitter: this.state.twitter,
|
2020-09-17 02:26:15 +03:00
|
|
|
message: this.state.message,
|
2021-05-06 03:08:14 +03:00
|
|
|
stored: Strings.bytesToSize(this.props.viewer?.stats.bytes || 0),
|
2020-09-17 02:26:15 +03:00
|
|
|
});
|
|
|
|
|
2020-12-22 04:20:24 +03:00
|
|
|
Events.hasError(response);
|
2020-09-17 02:26:15 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
_handleChange = (e) => {
|
|
|
|
this.setState({ [e.target.name]: e.target.value });
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<System.P
|
|
|
|
style={{
|
|
|
|
fontFamily: Constants.font.semiBold,
|
|
|
|
fontSize: Constants.typescale.lvl3,
|
2020-12-11 05:59:17 +03:00
|
|
|
marginBottom: 36,
|
2020-09-17 02:26:15 +03:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
Talk to us
|
|
|
|
</System.P>
|
|
|
|
|
2021-03-03 01:12:47 +03:00
|
|
|
<div css={STYLES_GROUPING} style={{ marginTop: 24 }}>
|
|
|
|
<System.P
|
|
|
|
css={STYLES_TEXT}
|
|
|
|
style={{ color: Constants.system.brand, cursor: "pointer" }}
|
|
|
|
onClick={() => this.props.onAction({ type: "SIDEBAR", value: "SIDEBAR_FAQ" })}
|
|
|
|
>
|
|
|
|
Check out our FAQ here!
|
|
|
|
</System.P>
|
|
|
|
</div>
|
|
|
|
|
2020-12-11 05:59:17 +03:00
|
|
|
<div css={STYLES_GROUPING}>
|
|
|
|
<System.P css={STYLES_HEADER}>Your Info</System.P>
|
|
|
|
<System.P css={STYLES_TEXT} style={{ marginTop: 12 }}>
|
2020-12-11 06:06:22 +03:00
|
|
|
Let us know how we can reach you!
|
2020-12-11 05:59:17 +03:00
|
|
|
</System.P>
|
|
|
|
<System.Input
|
|
|
|
name="name"
|
2021-06-09 04:01:16 +03:00
|
|
|
type="text"
|
2020-12-11 05:59:17 +03:00
|
|
|
style={{ marginTop: 12 }}
|
|
|
|
placeholder="Name"
|
|
|
|
value={this.state.name}
|
|
|
|
onChange={this._handleChange}
|
|
|
|
onSubmit={this._handleSubmit}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<System.Input
|
|
|
|
name="email"
|
|
|
|
style={{ marginTop: 8 }}
|
2021-06-09 04:01:16 +03:00
|
|
|
type="email"
|
2020-12-11 05:59:17 +03:00
|
|
|
placeholder="Email"
|
|
|
|
value={this.state.email}
|
|
|
|
onChange={this._handleChange}
|
|
|
|
onSubmit={this._handleSubmit}
|
|
|
|
/>
|
|
|
|
<System.Input
|
|
|
|
name="twitter"
|
|
|
|
style={{ marginTop: 8 }}
|
2021-06-09 04:01:16 +03:00
|
|
|
type="text"
|
2020-12-11 05:59:17 +03:00
|
|
|
placeholder="Twitter (optional)"
|
|
|
|
value={this.state.twitter}
|
|
|
|
onChange={this._handleChange}
|
|
|
|
onSubmit={this._handleSubmit}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div css={STYLES_GROUPING}>
|
|
|
|
<System.P css={STYLES_HEADER}>Message</System.P>
|
|
|
|
|
|
|
|
<System.Textarea
|
|
|
|
style={{ marginTop: 16 }}
|
|
|
|
name="message"
|
|
|
|
value={this.state.message}
|
|
|
|
placeholder="Leave us your questions or feedback and we'll get back to you soon!"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
onSubmit={this._handleSubmit}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
2020-12-22 04:20:24 +03:00
|
|
|
<System.ButtonPrimary full onClick={this._handleSubmit}>
|
2020-09-17 02:26:15 +03:00
|
|
|
Send message
|
|
|
|
</System.ButtonPrimary>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|