From 90f9bda6f48899b53b24e2f06b66dfa0f390e409 Mon Sep 17 00:00:00 2001 From: Ruidy Nemausat Date: Sat, 7 Mar 2020 11:40:31 +0100 Subject: [PATCH] contact --- public/index.html | 2 +- src/components/ContactForm.jsx | 83 ++++++++++++++++++------------ src/controllers/MealController.jsx | 51 +++++++++++++++--- src/pages/Contact.jsx | 2 +- 4 files changed, 97 insertions(+), 41 deletions(-) diff --git a/public/index.html b/public/index.html index b86e6b1..ba78147 100644 --- a/public/index.html +++ b/public/index.html @@ -26,6 +26,6 @@
- + diff --git a/src/components/ContactForm.jsx b/src/components/ContactForm.jsx index 3ff3a42..d04bf19 100644 --- a/src/components/ContactForm.jsx +++ b/src/components/ContactForm.jsx @@ -1,23 +1,39 @@ -import React from "react"; -import { useInput } from "../utils/inputHook"; +import React, { useState } from "react"; +// import { useInput } from "../utils/inputHook"; export const ContactForm = ({ onSubmit }) => { - // const fields = ["firstname", "lastname", "email", "phone", "message"]; - - // const [firstName, setFirstName] = useState(""); + const [firstName, setFirstName] = useState(""); + const [lastName, setLastName] = useState(""); + const [email, setEmail] = useState(""); + const [phone, setPhone] = useState(""); + const [message, setMessage] = useState(""); const handleSubmit = ev => { ev.preventDefault(); onSubmit(true); }; - // const handleChange = ev => { - // const { value } = ev.target; - // setFirstName(value); - // }; + const changeFirstName = ev => { + const { value } = ev.target; + setFirstName(value); + }; + const changeLastName = ev => { + const { value } = ev.target; + setLastName(value); + }; + const changePhone = ev => { + const { value } = ev.target; + setPhone(value); + }; + const changeEmail = ev => { + const { value } = ev.target; + setEmail(value); + }; + const changeMessage = ev => { + const { value } = ev.target; + setMessage(value); + }; - // const { value, bind } = useInput(""); - const { bind } = useInput(""); return (
@@ -25,22 +41,34 @@ export const ContactForm = ({ onSubmit }) => {
- +
- +
- +
- +
@@ -52,31 +80,29 @@ export const ContactForm = ({ onSubmit }) => { const ContactFormInput = ({ id, type = "text", value, onChange }) => { return (
- {/* account_circle */} - + {/* account_circle */} +
); }; -const ContactFormTextArea = ({ id }) => { +const ContactFormTextArea = ({ id, value, onChange }) => { return (