Created
February 18, 2017 22:50
-
-
Save j-mcnally/642c1338952943a68bb04df9e18861f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, h, prop } from 'skatejs'; | |
const React = { createElement: h }; | |
const sym = Symbol(); | |
class WaitlistedForm extends Component { | |
static get is(){ return 'waitlisted-form' } | |
static get props () { | |
return { | |
domain: prop.string({ attribute: true }), | |
form: prop.string({ attribute: true }), | |
resultUrl: prop.string({ attribute: true }) | |
}; | |
} | |
async connectedCallback () { | |
let resp = await fetch(`https://${this.domain}/api/v2/site.json`) | |
this.site = await resp.json() | |
super.connectedCallback(); | |
} | |
disconnectedCallback () { | |
// Ensure we callback the parent. | |
super.disconnectedCallback(); | |
} | |
renderCallback () { | |
console.log(this.site) | |
let nameBlock = null | |
if (this.site.ask_name) { | |
nameBlock = (<div class="wl-row wl-name"> | |
<label>Name</label> | |
<input name="reservation[name]" /> | |
</div>) | |
} | |
return ( | |
<form action="https://{this.site.domain}/external/reservations" method="POST"> | |
{nameBlock} | |
<div class="wl-row wl-email"> | |
<label>Email</label> | |
<input name="reservation[email]" /> | |
</div> | |
<input type="submit" value="Sign Up" /> | |
</form> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment