From f0568f640280cdf64f59d18493eead5b842a2d3e Mon Sep 17 00:00:00 2001 From: oonyeje Date: Mon, 23 Oct 2023 12:03:57 -0400 Subject: [PATCH] - add contact form scaffolding --- components/content/index.tsx | 52 ++++++------ components/form/ContactForm/index.tsx | 41 +++++++++ lib/content.ts | 10 +-- lib/navigationContent.tsx | 118 +++++++++++++------------- package.json | 1 + yarn.lock | 5 ++ 6 files changed, 135 insertions(+), 92 deletions(-) create mode 100644 components/form/ContactForm/index.tsx diff --git a/components/content/index.tsx b/components/content/index.tsx index 145e005..16e44df 100755 --- a/components/content/index.tsx +++ b/components/content/index.tsx @@ -1,27 +1,27 @@ -import React, { ReactNode } from "react"; -import Image from "next/image"; -import { StaticImport } from "next/dist/shared/lib/get-img-props"; - -interface ContentProps { - title: string, - heroImgSrc: string | StaticImport, - description?: string, - innerChildren?: ReactNode -} -const Content = ({ - title = '', - heroImgSrc, - description = '', - innerChildren = <> -}: ContentProps) => { - return ( -
-
{title}
- {heroImgSrc &&
} -
{description}
-
{innerChildren}
-
- ); -}; - +import React, { ReactNode } from "react"; +import Image from "next/image"; +import { StaticImport } from "next/dist/shared/lib/get-img-props"; + +interface ContentProps { + title: string, + heroImgSrc: string | StaticImport, + description?: string, + innerChildren?: ReactNode +} +const Content = ({ + title = '', + heroImgSrc = '', + description = '', + innerChildren = <> +}: ContentProps) => { + return ( +
+
{title}
+ {heroImgSrc &&
} +
{description}
+
{innerChildren}
+
+ ); +}; + export default Content; \ No newline at end of file diff --git a/components/form/ContactForm/index.tsx b/components/form/ContactForm/index.tsx new file mode 100644 index 0000000..fa87fdf --- /dev/null +++ b/components/form/ContactForm/index.tsx @@ -0,0 +1,41 @@ +import { useForm, SubmitHandler, FieldValues } from 'react-hook-form'; + +const ContactForm = () => { + const { + register, + handleSubmit, + formState: { errors }, + } = useForm(); + + const handleFormSubmission: SubmitHandler = (data) => { + console.log(data) + }; + + const handleFormError: SubmitHandler = (error) => { + console.log(error) + }; + + return ( +
+
+
+
+
+ + + {errors.firstName &&

First name is required.

} + {errors.lastName &&

Last name is required.

} +
+
+