Skip to content

Commit

Permalink
Update readme, attempt to fix netlify form
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanzitting committed Dec 7, 2022
1 parent ed098ea commit 07b1805
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[![Netlify Status](https://api.netlify.com/api/v1/badges/3701b349-13d2-40b8-a955-16e595d73fd1/deploy-status)](https://app.netlify.com/sites/open-sgf/deploys)

## Staging Preview
This will be a 404 until we change the build directory from `dist` to `.next` in the Netlify settings on launch.

[dev--open-sgf.netlify.app](https://dev--open-sgf.netlify.app)


Expand Down
31 changes: 17 additions & 14 deletions src/components/Blocks/ContactForm/ContactForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@ import { Button } from '@/components/atoms/Button/Button';
import styles from './ContactForm.module.scss';

export function ContactForm(): JSX.Element {
function handleSubmit(event: any) {
async function handleSubmit(event: any) {
event.preventDefault();

const myForm = event.target;
const formData = new FormData(myForm);

fetch('/', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams(formData as unknown as string).toString(),
})
.then(() => {
console.log('Form successfully submitted');
myForm.reset();
})
.catch((error) => alert(error));
try {
await fetch('/', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams(formData as unknown as string).toString(),
});

console.log('Form successfully submitted.');

myForm.reset();
} catch (e) {
alert(e);
}
}

return (
Expand All @@ -42,15 +45,15 @@ export function ContactForm(): JSX.Element {
<div data-netlify-recaptcha="true"></div>
<div className={styles.formRow}>
<label htmlFor="name">Name</label>
<input type="text" id="name" />
<input type="text" id="name" name="name"/>
</div>
<div className={styles.formRow}>
<label htmlFor="email">Email</label>
<input type="email" id="email" />
<input type="email" id="email" name="email"/>
</div>
<div className={styles.formRow}>
<label htmlFor="message">Message</label>
<textarea id="message" />
<textarea id="message" name="message"/>
</div>
<Button text="Submit" />
</form>
Expand Down

0 comments on commit 07b1805

Please sign in to comment.