import { Component, Event, EventEmitter, Prop, State, Element } from '@stencil/core'; import { ISelfRegistrationInfo } from './selfRegistrationInfo'; import { getCountryName } from './../org-search/stateAndCountry'; import { IOrganizationInformation } from './../org-search-result/organizationInformation'; @Component({ tag: 'confirm-self-registration-request', styleUrl: 'confirm-self-registration-request.scss', shadow: true }) export class ConfirmSelfRegistrationRequest { @Prop() reviewHeader: string; @Prop() terms: string; @Prop({ reflectToAttr: true }) selfRegistrationInfo: ISelfRegistrationInfo; @State() termsAccepted: boolean = false; @Event({ bubbles: true, composed: true }) confirmEvent: EventEmitter; private timeout: any; @Element() private element: HTMLElement; getAddress(organization: IOrganizationInformation): string { const stateAndZip = [organization.orgState, organization.orgPostalCode] .filter(element => element) .map(element => element.trim()) .join(' '); const addressLine = [organization.orgCity, stateAndZip]; return addressLine .filter(element => element) .map(element => element.trim()) .join(', ') }; checkboxValueChanged(event): void { this.termsAccepted = event.target.checked; } onConfirmClick(event: Event) { event.preventDefault(); this.confirmEvent.emit(); } renderCaptcha() { const recpatcha = window['grecaptcha']; console.log(typeof recpatcha.render); if (typeof recpatcha.render !== "function") { console.log('waiting till captcha is found'); this.timeout = setInterval(() => { this.renderCaptcha(); }, 200) return; } clearTimeout(this.timeout); recpatcha.render(this.element.querySelector('#captcha'), { sitekey: '6Lf_op4UAAAAANXxRYbfMkXbR4CnXwI520y9JiWc', callback: function(response){ console.log('got cpatch response', response); } }); } componentDidLoad() { this.renderCaptcha(); } render() { return (