From 71baab3c06a62e21faa29eb17c1e1a10ec8da60b Mon Sep 17 00:00:00 2001 From: Kenneth Jannette Date: Sun, 14 Jan 2024 17:02:37 -0600 Subject: [PATCH] more --- src/Components/Home/DemoRequestPage.js | 40 +++++++++++++++----------- src/Constants/Fields/DemoFields.js | 20 ++++++++++++- 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/src/Components/Home/DemoRequestPage.js b/src/Components/Home/DemoRequestPage.js index 3991942..ca03dcb 100644 --- a/src/Components/Home/DemoRequestPage.js +++ b/src/Components/Home/DemoRequestPage.js @@ -4,7 +4,7 @@ import { Link, useNavigate } from "react-router-dom"; import Col from "react-bootstrap/Col"; import Form from "react-bootstrap/Form"; import Row from "react-bootstrap/Row"; -import { demofields } from "../../Constants/Fields/DemoFields"; +import { demoFields, supportFields } from "../../Constants/Fields/DemoFields"; import { useParams } from "react-router-dom"; import { splitEvery } from "../../Utils/Array"; import TextInput from "../../pageElements/TextInput"; @@ -23,21 +23,21 @@ import "../../styles/demo-request-page.scss"; const DemoRequestPage = () => { const { supReq } = useParams(); const navigate = useNavigate(); - const [data, setData] = useState(getFormDataDefaults(demofields)); + const [isBusy, setIsBusy] = useState(); const fieldsChunkSize = 2; const isSupport = supReq === "5ac45d12"; - console.log("isSupport", isSupport); - + const inputFields = isSupport ? supportFields : demoFields; + const [data, setData] = useState(getFormDataDefaults(inputFields)); const handleChangeInput = (e, name) => { - const newData = handleFormDataChange(e, name, data, demofields); + const newData = handleFormDataChange(e, name, data, inputFields); if (newData !== null) { setData(newData); } }; const validateData = () => { - const newData = getValidatedFormData(data, demofields); + const newData = getValidatedFormData(data, inputFields); const hasErrors = isFormDataHasErrors(newData); setData(newData); return hasErrors ? null : objectMap(({ value }) => value, newData); @@ -70,15 +70,23 @@ const DemoRequestPage = () => {
-

- Revolutionize Your Practice: Request A Demo -

-

- Enter your information below we will contact you to schedule -

+ {isSupport ? ( +

+ Request Techical Or Account Support +

+ ) : ( + <> +

+ Revolutionize Your Practice: Request A Demo +

+

+ Enter your information below we will contact you to schedule +

+ + )}
- {splitEvery(Object.keys(demofields), fieldsChunkSize).map( + {splitEvery(Object.keys(inputFields), fieldsChunkSize).map( (names, j) => ( {names.map((name, i) => ( @@ -94,11 +102,11 @@ const DemoRequestPage = () => { message={data[name].message} label={ data[name].value.length === 0 - ? demofields[name].label + ? inputFields[name].label : "" } - type={demofields[name].type} - values={demofields[name].values} + type={inputFields[name].type} + values={inputFields[name].values} disabled={isBusy} /> diff --git a/src/Constants/Fields/DemoFields.js b/src/Constants/Fields/DemoFields.js index cc0f88f..0fc9159 100644 --- a/src/Constants/Fields/DemoFields.js +++ b/src/Constants/Fields/DemoFields.js @@ -1,4 +1,4 @@ -export const demofields = { +export const demoFields = { firstName: { required: true, label: "First Name", maxLength: 45 }, lastName: { required: true, label: "Last Name", maxLength: 45 }, telephone: { @@ -16,3 +16,21 @@ export const demofields = { maxLength: 45, }, }; + +export const supportFields = { + firstName: { required: true, label: "First Name", maxLength: 45 }, + lastName: { required: true, label: "Last Name", maxLength: 45 }, + telephone: { + required: true, + label: "Telephone: (###) ###-####", + maxLength: 45, + type: "phone", + }, + email: { required: true, label: "Email", maxLength: 45, type: "email" }, + supportIssue: { + required: true, + label: "Support Issue", + minLength: 3, + maxLength: 45, + }, +};