Finish converting TOS agree checkbox to controlled component

This commit is contained in:
Alex Liebowitz 2017-06-16 05:32:54 -04:00
parent 26e6245b89
commit c3973ac780

View file

@ -12,7 +12,7 @@ class PublishPage extends React.PureComponent {
constructor(props) { constructor(props) {
super(props); super(props);
this._requiredFields = ["meta_title", "name", "bid", "tos_agree"]; this._requiredFields = ["name", "bid", "meta_title", "tosAgree"];
this.state = { this.state = {
rawName: "", rawName: "",
@ -38,6 +38,7 @@ class PublishPage extends React.PureComponent {
copyrightNotice: "", copyrightNotice: "",
otherLicenseDescription: "", otherLicenseDescription: "",
otherLicenseUrl: "", otherLicenseUrl: "",
tosAgree: false,
prefillDone: false, prefillDone: false,
uploadProgress: 0.0, uploadProgress: 0.0,
uploaded: false, uploaded: false,
@ -354,7 +355,7 @@ class PublishPage extends React.PureComponent {
handleTOSChange(event) { handleTOSChange(event) {
this.setState({ this.setState({
TOSAgreed: event.target.checked, tosAgree: event.target.checked,
}); });
} }
@ -826,15 +827,11 @@ class PublishPage extends React.PureComponent {
<Link <Link
href="https://www.lbry.io/termsofservice" href="https://www.lbry.io/termsofservice"
label={__("LBRY terms of service")} label={__("LBRY terms of service")}
checked={this.state.TOSAgreed}
/> />
</span> </span>
} }
type="checkbox" type="checkbox"
name="tos_agree" checked={this.state.tosAgree}
ref={field => {
this.refs.tos_agree = field;
}}
onChange={event => { onChange={event => {
this.handleTOSChange(event); this.handleTOSChange(event);
}} }}