From a5eb1f2edf8bf7463fed711681d2682f9b958c21 Mon Sep 17 00:00:00 2001 From: chief-bube Date: Fri, 13 Jan 2023 09:07:03 -0800 Subject: [PATCH] Worked on the form validation --- src/assets/css/style.css | 22 +++++ src/component/Contact/Main.js | 149 ++++++++++++++++++++++------- src/vendors/service/siteService.js | 8 +- 3 files changed, 142 insertions(+), 37 deletions(-) diff --git a/src/assets/css/style.css b/src/assets/css/style.css index 6025ce5..bab1b11 100644 --- a/src/assets/css/style.css +++ b/src/assets/css/style.css @@ -3521,6 +3521,28 @@ header.fix_style.white_header { margin-bottom: 20px; } +/* For the err msg */ +.contact_page_section .contact_inner .contact_form form .form-group span{ + font-size: 12px; + color: tomato; + padding: 3px; + display: none; +} + +.contact_page_section .contact_inner .contact_form form .form-group input:invalid ~ span{ + display: block; +} + +/* +input:invalid[focused="true"]{ + border: 1px solid red; +} + +input:invalid[focused="true"] ~ span{ + display: block; +} +*/ + .contact_page_section .contact_inner .contact_form diff --git a/src/component/Contact/Main.js b/src/component/Contact/Main.js index 7b65228..b9ec1d1 100644 --- a/src/component/Contact/Main.js +++ b/src/component/Contact/Main.js @@ -7,18 +7,71 @@ import BGImg2 from "../../assets/images/bread_crumb_bg_two.png"; import SiteService from "../../vendors/service/siteService"; -const Main = ({ brdcum }) => { - let [countries, setCountries] = useState([]) // initial state for country dropdown - let countryClass = new SiteService() // instantiating the class +// Form Inputs +const FormInput = (props) => { + let { + name, + type, + placeholder, + required, + maxLenght, + errorMessage, + value, + onChange, + } = props; + return ( +
+ + {errorMessage} +
+ ); +}; + +const Main = ({ brdcum }) => { + // Form Validation + const [values, setValues] = useState({ + name: "", + email: "", + phone: "", + msg: "", + }); //initial state values + const [countries, setCountries] = useState([]); // initial state for country dropdown + + // Gave a generic name for multiple calls + const API_CALL = new SiteService(); // instantiating the class + const allCountry = () => { - return countryClass.countryData(); - } + return API_CALL.countryData(); + }; + + const contactForm = () => { + return API_CALL.contactData(); + }; + + // Submitting form + const handleSubmit = (e) => { + e.preventDefault(); + }; + + const onChange = (e) => { + setValues({ ...values, [e.target.name]: e.target.value }); + }; //CALLS THE API AFTER COMPONENT LOADS - useEffect(()=>{ - allCountry().then((data)=> setCountries(Object.values(data.data))) - },[]) + useEffect(() => { + allCountry().then((data) => setCountries(Object.values(data.data))); + console.log(values); + }, []); return ( <> @@ -77,44 +130,64 @@ const Main = ({ brdcum }) => {

- Leave a message + Leave a message

Fill up form below, our team will get back soon

-
-
- -
-
- -
+ + {/* Contact Form */} + + + +
-
- -
+ +
@@ -130,6 +203,8 @@ const Main = ({ brdcum }) => {
+ + {/* Contact Info */}
image @@ -153,7 +228,9 @@ const Main = ({ brdcum }) => {
Email Us - example@gmail.com + + {process.env.REACT_APP_SUPPORT_EMAIL} +
  • @@ -162,7 +239,9 @@ const Main = ({ brdcum }) => {
  • Call Us - +1 (888) 553-46-11 + + {process.env.REACT_APP_US_PHONE} +
  • @@ -171,7 +250,7 @@ const Main = ({ brdcum }) => {
    Visit Us -

    5687, Business Avenue, New York, USA 5687

    +

    {process.env.REACT_APP_US_ADDRESS}

  • diff --git a/src/vendors/service/siteService.js b/src/vendors/service/siteService.js index dbea9f4..7cf0e67 100644 --- a/src/vendors/service/siteService.js +++ b/src/vendors/service/siteService.js @@ -13,11 +13,15 @@ class SiteService { return this.getAuxEnd("/country", null); } + contactData() { + return this.postAuxEnd("/contact", null) + } + faqData() {} - + //---------------------------------------- ----- //---------------------------------------- ----- - // Unified call below + // Unified call below //---------------------------------------- ----- //---------------------------------------- ----- getAuxEnd(uri, reqData) {