diff --git a/plugins/plugins/core/become-minter/components/not-sponsored.js b/plugins/plugins/core/become-minter/components/not-sponsored.js new file mode 100644 index 00000000..c298b55c --- /dev/null +++ b/plugins/plugins/core/become-minter/components/not-sponsored.js @@ -0,0 +1,137 @@ +import { LitElement, html } from 'lit'; +import { Epml } from '../../../../epml.js'; +import '../../components/ButtonIconCopy.js'; +import { use, translate, registerTranslateConfig } from 'lit-translate'; + +registerTranslateConfig({ + loader: (lang) => fetch(`/language/${lang}.json`).then((res) => res.json()), +}); + +import '@polymer/paper-spinner/paper-spinner-lite.js'; +import '@material/mwc-button'; +import '@material/mwc-textfield'; +import '@vaadin/button'; +import { pageStyles } from '../become-minter-css.src.js'; + +const parentEpml = new Epml({ type: 'WINDOW', source: window.parent }); + +class NotSponsored extends LitElement { + static properties = { + atMount: { type: Function }, + isLoadingSponsorshipKeySubmit: { type: Boolean }, + sponsorshipKeyValue: { type: String }, + addMintingAccountMessage: { type: String }, + }; + + static styles = [pageStyles]; + + constructor() { + super(); + this.isLoadingSponsorshipKeySubmit = false; + this.sponsorshipKeyValue = ''; + this.addMintingAccountMessage = ''; + this.atMount = () => {}; + } + + renderErr1Text() { + return html`${translate('nodepage.nchange27')}`; + } + + renderErr2Text() { + return html`${translate('nodepage.nchange28')}`; + } + + getApiKey() { + const myNode = + window.parent.reduxStore.getState().app.nodeConfig.knownNodes[ + window.parent.reduxStore.getState().app.nodeConfig.node + ]; + let apiKey = myNode.apiKey; + return apiKey; + } + + addMintingAccount(e) { + this.isLoadingSponsorshipKeySubmit = true; + this.addMintingAccountMessage = 'Loading...'; + + parentEpml + .request('apiCall', { + url: `/admin/mintingaccounts?apiKey=${this.getApiKey()}`, + method: 'POST', + body: this.sponsorshipKeyValue, + }) + .then((res) => { + if (res === true) { + // refetch data + this.atMount(); + this.sponsorshipKeyValue = ''; + this.addMintingAccountMessage = this.renderErr1Text(); + this.isLoadingSponsorshipKeySubmit = false; + } else { + this.sponsorshipKeyValue = ''; + this.addMintingAccountMessage = this.renderErr2Text(); + this.isLoadingSponsorshipKeySubmit = false; + } + }); + } + + inputHandler(e) { + this.sponsorshipKeyValue = e.target.value; + } + + render() { + return html` +
+ ${translate('mintingpage.mchange34')} +
++ ${translate('mintingpage.mchange36')} +
++ ${translate('mintingpage.mchange37')} +
+ + ++ ${this.rewardSharePublicKey} +
+