From 2060619e673e720167f7a5f57d97af1e9e1def77 Mon Sep 17 00:00:00 2001 From: Michael Rooplall Date: Mon, 11 Dec 2023 20:02:02 -0500 Subject: [PATCH] Implement Contact Page functionality --- app/Contact/page.js | 352 +++++++++++++++++++++++++++++++++----------- package-lock.json | 145 ++++++++++++++++++ package.json | 4 + 3 files changed, 417 insertions(+), 84 deletions(-) diff --git a/app/Contact/page.js b/app/Contact/page.js index 666224e..901f3d6 100644 --- a/app/Contact/page.js +++ b/app/Contact/page.js @@ -7,11 +7,20 @@ import Header from '@components/Header/Header' import SubheaderShape from '@components/SubheaderShape/SubheaderShape' import Footer from '@components/Footer/Footer' +import { Tooltip } from 'react-tooltip' +import { useForm, Controller } from 'react-hook-form' + +import { ToastContainer, toast } from 'react-toastify'; +import 'react-toastify/dist/ReactToastify.css'; + import SponsorBlock from '@components/SponsorBlock/SponsorBlock' import {useRef, useState} from 'react'; import Link from 'next/link' +import 'react-phone-number-input/style.css' +import PhoneInput, {isValidPhoneNumber} from 'react-phone-number-input/input' + import { Button } from '@components/Button/Button' const PhoneIconSVG = () => { @@ -57,7 +66,7 @@ const PinIconSVG = () => { const contactInformation = [ { icon : , - text : "(347) 858 5959" + text : "(347) 858-5959" }, { icon : , @@ -73,10 +82,11 @@ const contactInformation = [ } ] -const ContactInput = ({inputRef, onChange, value, label}) => { +const ContactInput = ({label, inputType = "text", inputKey, register, required = false, pattern, error}) => { return (
{ > {label} + { + error && + { + (error.type == 'required') ? '*Required' : '*Invalid' + } + + } { - onChange(value); - }} - value={value} + label={inputKey} + type={inputType} style={{ borderWidth : '0px 0px 2px 0px', borderStyle : null, @@ -105,16 +126,81 @@ const ContactInput = ({inputRef, onChange, value, label}) => { margin : 0, fontSize : 18 }} + + {...register(inputKey, {required : required, pattern : pattern})} />
) } +const ContactPhoneNumberInput = ({label, inputKey, control, error}) => { + return ( +
+ + {label} + + { + error && + { + (error.type == 'required') ? '*Required' : '*Invalid' + } + + } + { + if (value == undefined) return true; + return isValidPhoneNumber(value) + } + }} + render={({ field: { onChange, value } }) => ( + + )} + /> +
+ ) +} -const ContactInputTextArea = ({inputRef, onChange, value, label}) => { + +const ContactInputTextArea = ({label, inputKey, register, required = false, error}) => { return (
{ > {label} + { + error && + { + (error.type == 'required') ? '*Required' : '*Invalid' + } + + }