Capture the following details
- Email address Optional, but if present should be a valid email address
- Message A place for the visitor to write their message.
Information, should be submitted as a POST
request to an API endpoint /api/contact
The shape of the payload should follow
{
"data" : {
"type": "contact-message",
"attributes": {
"email": "sample@example.com",
"message": "Just wanted to say hello. etc"
}
}
}
Assume that the API will return a HTTP 201
response on sucess
There is a very crude php app that you can use by running
./server
First, install yarn and use nvm to install Node ≥ 6 on your machine.
nvm install node
nvm use node
php -S localhost:5000 -t ./api
cd web
yarn
yarn start
Open http://localhost:3000/ to view the contact form app (unless your CLI provides a different address).
View console.log
outputs by opening the Console panel on Chrome or other browser.
- I used Create React App to bootstrap the app.
- Attempt to write basic tests, but Enzyme 3 has some breaking changes requiring further configuration.
- I’ve left in
console.log
s so you can view when functions are being called in the console panel and their resulting output.
- The contact form needs more comprehensive unit testing.