-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contact us page implemented #160
Open
zvyaan
wants to merge
2
commits into
trypear:main
Choose a base branch
from
zvyaan:contact-us-page
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import ContactUs from "@/components/contact"; | ||
import { constructMetadata } from "@/lib/utils"; | ||
import { Metadata } from "next/types"; | ||
|
||
export const metadata: Metadata = constructMetadata({ | ||
title: "Contact Us", | ||
description: "Contact PearAI.", | ||
canonical: "/contact", | ||
}); | ||
|
||
export default function Pricing() { | ||
return ( | ||
<> | ||
<ContactUs /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,297 @@ | ||
"use client"; | ||
import Link from "next/link"; | ||
import { useState } from "react"; | ||
import { signup, signinWithOAuth, contactSubmit } from "@/app/(auth)/actions"; | ||
import { Provider } from "@supabase/supabase-js"; | ||
import { zodResolver } from "@hookform/resolvers/zod"; | ||
import { useForm } from "react-hook-form"; | ||
import { Button } from "@/components/ui/button"; | ||
import { Input } from "@/components/ui/input"; | ||
import { Select } from "@/components/ui/select"; | ||
import { | ||
Form, | ||
FormField, | ||
FormItem, | ||
FormLabel, | ||
FormControl, | ||
FormMessage, | ||
} from "@/components/ui/form"; | ||
import { contactSchema, ContactFormData } from "@/utils/form-schema"; | ||
import { toast } from "sonner"; | ||
import { useRouter } from "next/navigation"; | ||
|
||
const organisationSizes = [ | ||
{ value: "1-10", label: "1-10 employees" }, | ||
{ value: "11-50", label: "11-50 employees" }, | ||
{ value: "51-200", label: "51-200 employees" }, | ||
{ value: "201-500", label: "201-500 employees" }, | ||
{ value: "501-1000", label: "501-1000 employees" }, | ||
{ value: "1001+", label: "1001+ employees" }, | ||
]; | ||
|
||
export default function ContactUs() { | ||
const [isSubmitting, setIsSubmitting] = useState(false); | ||
const [errorMessage, setErrorMessage] = useState<string | null>(null); | ||
const form = useForm<ContactFormData>({ | ||
resolver: zodResolver(contactSchema), | ||
defaultValues: { | ||
first_name: "", | ||
last_name: "", | ||
email: "", | ||
job_title: "", | ||
company_name: "", | ||
organisation_size: "", | ||
phone_number: "", | ||
message: "", | ||
}, | ||
}); | ||
const router = useRouter(); | ||
|
||
const handleContactSubmit = async (data: ContactFormData) => { | ||
if (isSubmitting) return; | ||
setIsSubmitting(true); | ||
setErrorMessage(null); | ||
|
||
try { | ||
const formData = new FormData(); | ||
formData.append("first-name", data.first_name); | ||
formData.append("last-name", data.last_name); | ||
formData.append("email", data.email); | ||
formData.append("job-title", data.job_title); | ||
formData.append("company-name", data.company_name || ""); | ||
formData.append("organisation-size", data.organisation_size); | ||
formData.append("phone-number", data.phone_number || ""); | ||
formData.append("message", data.message); | ||
|
||
const response = await contactSubmit(formData); | ||
if (response?.error) { | ||
setErrorMessage(response.error); | ||
} else { | ||
toast.success("Successfully submitted! We will get back to you soon."); | ||
router.push("/about"); | ||
} | ||
} catch (error) { | ||
setErrorMessage("An unexpected error occurred. Please try again."); | ||
} finally { | ||
setIsSubmitting(false); | ||
} | ||
}; | ||
|
||
return ( | ||
<section className="relative"> | ||
<div className="mx-auto max-w-6xl px-4 sm:px-6"> | ||
<div className="md:pt-30 pb-12 pt-24 md:pb-16"> | ||
<div className="md:pb-15 mx-auto max-w-3xl pb-4 text-center text-xl sm:text-2xl md:text-3xl lg:text-4xl"> | ||
<h1 className="text-3xl font-bold leading-tight sm:text-4xl md:text-5xl lg:text-6xl"> | ||
Looking for a <span className="text-primary-700">custom</span>{" "} | ||
pricing option? Get in touch! | ||
</h1> | ||
</div> | ||
|
||
<div className="mx-auto max-w-2xl"> | ||
<div className="my-6 flex items-center"> | ||
<div | ||
className="mr-3 grow border-t border-solid border-gray-400" | ||
aria-hidden="true" | ||
/> | ||
<div className="text-gray-600"> | ||
Please contact us using the form below | ||
</div> | ||
<div | ||
className="ml-3 grow border-t border-solid border-gray-400" | ||
aria-hidden="true" | ||
/> | ||
</div> | ||
|
||
<Form {...form}> | ||
<form | ||
onSubmit={form.handleSubmit(handleContactSubmit)} | ||
className="space-y-4" | ||
> | ||
<FormField | ||
name="first_name" | ||
control={form.control} | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel htmlFor="first_name"> | ||
First Name <span className="text-red-600"> *</span> | ||
</FormLabel> | ||
<FormControl> | ||
<Input | ||
id="first_name" | ||
placeholder="First name" | ||
{...field} | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
|
||
<FormField | ||
name="last_name" | ||
control={form.control} | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel htmlFor="last_name"> | ||
Last Name <span className="text-red-600"> *</span> | ||
</FormLabel> | ||
<FormControl> | ||
<Input | ||
id="last_name" | ||
placeholder="Last name" | ||
{...field} | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
|
||
<FormField | ||
name="email" | ||
control={form.control} | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel htmlFor="email"> | ||
Work Email <span className="text-red-600"> *</span> | ||
</FormLabel> | ||
<FormControl> | ||
<Input | ||
id="email" | ||
type="email" | ||
placeholder="[email protected]" | ||
{...field} | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
|
||
<FormField | ||
name="job_title" | ||
control={form.control} | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel htmlFor="job_title"> | ||
Job Title <span className="text-red-600"> *</span> | ||
</FormLabel> | ||
<FormControl> | ||
<Input | ||
id="job_title" | ||
placeholder="Your job title" | ||
{...field} | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
|
||
<FormField | ||
name="company_name" | ||
control={form.control} | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel htmlFor="company_name"> | ||
Company Name <span className="text-red-600"> *</span> | ||
</FormLabel> | ||
<FormControl> | ||
<Input | ||
id="company_name" | ||
placeholder="Your company or app name" | ||
{...field} | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
|
||
<FormField | ||
name="organisation_size" | ||
control={form.control} | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel htmlFor="organisation_size"> | ||
Organisation Size{" "} | ||
<span className="text-red-600"> *</span> | ||
</FormLabel> | ||
<FormControl> | ||
<Select id="organisation_size" {...field}> | ||
<option value="" disabled> | ||
Select your organisation size | ||
</option> | ||
{organisationSizes.map((size) => ( | ||
<option key={size.value} value={size.value}> | ||
{size.label} | ||
</option> | ||
))} | ||
</Select> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
|
||
<FormField | ||
name="phone_number" | ||
control={form.control} | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel htmlFor="phone_number">Phone Number</FormLabel> | ||
<FormControl> | ||
<Input | ||
id="phone_number" | ||
placeholder="Your phone number" | ||
{...field} | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
|
||
<FormField | ||
name="message" | ||
control={form.control} | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel htmlFor="message"> | ||
Message <span className="text-red-600"> *</span> | ||
</FormLabel> | ||
<FormControl> | ||
<textarea | ||
id="message" | ||
placeholder="Describe your needs here" | ||
className="h-36 w-full resize-none rounded-md border border-gray-200 p-3 text-sm" | ||
{...field} | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
|
||
<Button | ||
type="submit" | ||
size="lg" | ||
className="w-full rounded-md" | ||
disabled={isSubmitting} | ||
isLoading={isSubmitting} | ||
> | ||
{isSubmitting ? "Submitting..." : "Submit"} | ||
</Button> | ||
|
||
{errorMessage && ( | ||
<p className="text-center text-red-500">{errorMessage}</p> | ||
)} | ||
</form> | ||
</Form> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as React from "react"; | ||
import { cn } from "@/lib/utils"; | ||
|
||
export interface SelectProps | ||
extends React.SelectHTMLAttributes<HTMLSelectElement> {} | ||
|
||
const Select = React.forwardRef<HTMLSelectElement, SelectProps>( | ||
({ className, ...props }, ref) => { | ||
return ( | ||
<select | ||
className={cn( | ||
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", | ||
className, | ||
)} | ||
ref={ref} | ||
{...props} | ||
> | ||
{props.children} | ||
</select> | ||
); | ||
}, | ||
); | ||
|
||
Select.displayName = "Select"; | ||
|
||
export { Select }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend using the
isSubmitting
status provided informState
byreact-hook-form
to avoid manually setting the update status.