diff --git a/src/components/input-text.js b/src/components/input-text.js index c833cdf..8f48efb 100644 --- a/src/components/input-text.js +++ b/src/components/input-text.js @@ -18,11 +18,26 @@ const Input = styled.input` border: 1px solid var(--theme-color-dark); `; -export default function InputText({ id, label, required, textArea }) { +export default function InputText({ + id, + name, + label, + value, + onChange, + required, + textArea +}) { return ( - + ); } diff --git a/src/icons/check-circle.svg b/src/icons/check-circle.svg new file mode 100644 index 0000000..337210f --- /dev/null +++ b/src/icons/check-circle.svg @@ -0,0 +1,3 @@ + diff --git a/src/pages/contact.js b/src/pages/contact.js new file mode 100644 index 0000000..3243aa2 --- /dev/null +++ b/src/pages/contact.js @@ -0,0 +1,146 @@ +import React, { useState } from "react"; +import { graphql } from "gatsby"; +import Layout from "../layout"; +import { + Button, + Header, + Icon, + IconWithContent, + InputText, + Link, + Section, + Text +} from "../components"; +import Phone from "../icons/phone.svg"; +import Envelope from "../icons/envelope.svg"; +import CheckCircle from "../icons/check-circle.svg"; + +const encodeData = data => + Object.keys(data) + .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(data[key])}`) + .join("&"); + +export default function Index({ data }) { + const [submitted, setSubmitted] = useState(); + + const handleSubmit = e => { + e.preventDefault(); + const body = encodeData({ + "form-name": "contact", + name: e.target.name.value, + email: e.target.email.value, + telephone: e.target.telephone.value, + message: e.target.message.value + }); + fetch("/contact", { + method: "POST", + headers: { "Content-Type": "application/x-www-form-urlencoded" }, + body + }) + .then(res => { + if (res.status !== 200) { + console.log("error", res); + } else { + setSubmitted(true); + } + }) + .catch(error => console.log(error)); + }; + return ( + +
+

Get in touch

+
+
+
+ Get in touch with us + More info here + + + + + + 07123 456789 + + + + + + + + quotations@abcprojectdesign.com + + +
+
+ {submitted ? ( + + + + + <> + + Thank you for contacting us + + + We will be in touch shortly + + + + ) : ( + <> + + + + + + Contact us + + +
+ + + + + + + + + )} +
+
+
+ ); +} + +export const query = graphql` + query { + headerImage: file(relativePath: { eq: "bathroom.png" }) { + childImageSharp { + fluid(maxWidth: 1920, quality: 100) { + ...GatsbyImageSharpFluid_withWebp + } + } + } + } +`;