import React from "react";
import lbry from "../lbry.js";
import lbryio from "../lbryio.js";
import Modal from "./modal.js";
import ModalPage from "./modal-page.js";
import Link from "component/link";
import { RewardLink } from "component/reward-link";
import { FormRow } from "../component/form.js";
import { CreditAmount, Address } from "../component/common.js";
import { getLocal, setLocal } from "../utils.js";
import rewards from "../rewards";
class SubmitEmailStage extends React.Component {
constructor(props) {
super(props);
this.state = {
rewardType: null,
email: "",
submitting: false,
};
}
handleEmailChanged(event) {
this.setState({
email: event.target.value,
});
}
onEmailSaved(email) {
this.props.setStage("confirm", { email: email });
}
handleSubmit(event) {
event.preventDefault();
this.setState({
submitting: true,
});
lbryio.call("user_email", "new", { email: this.state.email }, "post").then(
() => {
this.onEmailSaved(this.state.email);
},
error => {
if (
error.xhr &&
(error.xhr.status == 409 ||
error.message == __("This email is already in use"))
) {
this.onEmailSaved(this.state.email);
return;
} else if (this._emailRow) {
this._emailRow.showError(error.message);
}
this.setState({ submitting: false });
}
);
}
render() {
return (
{__(
"Using LBRY is like dating a centaur. Totally normal up top, and way different underneath."
)}
{__("Up top, LBRY is similar to popular media sites.")}
{__(
"Below, LBRY is controlled by users -- you -- via blockchain and decentralization."
)}
{__(
"Thank you for making content freedom possible! Here's a nickel, kid."
)}
{__("You earned a reward of ")}
{" "}
{__(
"This reward will show in your Wallet momentarily, probably while you are reading this message."
)}
{__(
"LBC is used to compensate creators, to publish, and to have say in how the network works."
)}
{__(
"No need to understand it all just yet! Try watching or downloading something next."
)}
{__(
"Finally, know that LBRY is an early beta and that it earns the name."
)}
{__("An error was encountered that we cannot continue from.")} {__("At least we're earning the name beta.")} {__("Message:")} {props.errorText}
{__("Preparing for first access")}
{__("Welcome to LBRY.")}
{__("About Your Reward")}
{__( "Access to LBRY is restricted as we build and scale the network." )}
{__("There are two ways in:")}
{__("If you own at least 1 LBC, you can get in right now.")}
{ setLocal("auth_bypassed", true); this.props.setStage(null); }} disabled={disabled} label={__("Let Me In")} button={disabled ? "alt" : "primary"} />
{__("Your balance is ")}
{__("If you don't understand how to send credits, then...")}
{__( "If you provide your email, you'll automatically receive a notification when the system is open." )}
{ this.props.setStage("email"); }} label={__("Return")} />