slate/components/sidebars/SidebarHelp.js

147 lines
4.0 KiB
JavaScript
Raw Normal View History

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";
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`
2021-07-07 22:24:01 +03:00
color: ${Constants.semantic.textGray};
2020-12-11 05:59:17 +03:00
font-size: ${Constants.typescale.lvl0};
2020-09-17 02:26:15 +03:00
`;
2021-08-29 03:29:17 +03:00
export default class SidebarHelp extends React.Component {
2020-09-17 02:26:15 +03:00
state = {
2021-08-29 03:29:17 +03:00
name: this.props.viewer?.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)) {
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) {
Events.dispatchMessage({ message: "Please provide a message" });
2020-09-17 02:26:15 +03:00
return;
}
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
});
Events.hasError(response);
2020-09-17 02:26:15 +03:00
};
_handleChange = (e) => {
this.setState({ [e.target.name]: e.target.value });
};
render() {
return (
<div>
2021-07-07 23:50:57 +03:00
<System.P1
2020-09-17 02:26:15 +03:00
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
2021-07-07 23:50:57 +03:00
</System.P1>
2020-09-17 02:26:15 +03:00
<div css={STYLES_GROUPING} style={{ marginTop: 24 }}>
2021-07-07 23:50:57 +03:00
<System.P1
css={STYLES_TEXT}
2021-07-07 22:14:51 +03:00
style={{ color: Constants.system.blue, cursor: "pointer" }}
onClick={() => this.props.onAction({ type: "SIDEBAR", value: "SIDEBAR_FAQ" })}
>
Check out our FAQ here!
2021-07-07 23:50:57 +03:00
</System.P1>
</div>
2020-12-11 05:59:17 +03:00
<div css={STYLES_GROUPING}>
2021-07-07 23:50:57 +03:00
<System.P1 css={STYLES_HEADER}>Your Info</System.P1>
<System.P1 css={STYLES_TEXT} style={{ marginTop: 12 }}>
2020-12-11 06:06:22 +03:00
Let us know how we can reach you!
2021-07-07 23:50:57 +03:00
</System.P1>
2020-12-11 05:59:17 +03:00
<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}>
2021-07-07 23:50:57 +03:00
<System.P1 css={STYLES_HEADER}>Message</System.P1>
2020-12-11 05:59:17 +03:00
<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>
<System.ButtonPrimary full onClick={this._handleSubmit}>
2020-09-17 02:26:15 +03:00
Send message
</System.ButtonPrimary>
</div>
);
}
}