diff options
| author | 8cy <[email protected]> | 2020-10-12 19:50:30 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-10-12 19:50:30 -0700 |
| commit | c87d894d01b789f7953f558ad5cc68080c0f8b29 (patch) | |
| tree | 1f42fa39ea03d1e4ccd92b56b4758b3fe783eee5 /src/components/contact/Form.js | |
| download | me-c87d894d01b789f7953f558ad5cc68080c0f8b29.tar.xz me-c87d894d01b789f7953f558ad5cc68080c0f8b29.zip | |
woops i forgot to commit these files lul
Diffstat (limited to 'src/components/contact/Form.js')
| -rw-r--r-- | src/components/contact/Form.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/components/contact/Form.js b/src/components/contact/Form.js new file mode 100644 index 0000000..ec398fa --- /dev/null +++ b/src/components/contact/Form.js @@ -0,0 +1,64 @@ +import React, { Component } from 'react'; + +const encode = (data) => { + return Object.keys(data) + .map(key => encodeURIComponent(key) + "=" + encodeURIComponent(data[key])) + .join("&"); +} + +export default class Form extends Component { + constructor(props) { + super(props); + this.state = { name: '', method: '', message: '' }; + } + + handleSubmit = e => { + fetch('/', { + method: 'POST', + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + body: encode({ 'form-name': 'contact-form', ...this.state }) + }); + + e.preventDefault(); + } + + handleChange = e => this.setState({ [e.target.name]: e.target.value }); + + render() { + const { name, method, message } = this.state; + return( + <div className="container-fluid"> + <div className="row"> + <div className="col-lg-8"> + <form name="contact-form" id="contact-form" action="/contact" onSubmit={this.handleSubmit} netlify> + <ul> + <li className="wow fadeInUp" data-wow-delay="1.4s"> + <label htmlFor="name">Name:</label> + <div className="textarea"> + <input type="text" name="name" id="name" defaultValue={name} onChange={this.handleChange} required /> + </div> + </li> + <li className="wow fadeInUp" data-wow-delay="1.6s"> + <label htmlFor="method">Email/ Discord:</label> + <div className="textarea"> + <input type="text" name="method" id="method" defaultValue={method} onChange={this.handleChange} required /> + </div> + </li> + <li className="wow fadeInUp" data-wow-delay="1.6s"> + <label htmlFor="message">Message:</label> + <div className="textarea"> + <input type="text" name="message" id="message" defaultValue={message} onChange={this.handleChange} required /> + </div> + </li> + </ul> + + <button type="submit" name="contact-form" id="contact-form" className="send wow fadeInUp"> + Send Message + </button> + </form> + </div> + </div> + </div> + ) + } +}
\ No newline at end of file |