-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
167 additions
and
11 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Button from '@/_components/button'; | ||
import ContactForm from '@/_components/contact-form'; | ||
|
||
const Page = () => ( | ||
<div className="mx-auto flex min-h-full max-w-2xl select-text flex-col items-center justify-center px-6 py-16 text-center"> | ||
<h1 className="max-w-sm text-2xl font-bold md:max-w-xl md:text-4xl"> | ||
<span className="text-fg-1">llog</span>—achieve lasting behavior | ||
changes with your clients. | ||
</h1> | ||
<p className="mx-auto mt-6 max-w-sm"> | ||
Streamline <b>data collection</b>, create{' '} | ||
<b>data-driven training plans</b> and easily <b>monitor progress</b>. | ||
</p> | ||
<div className="mt-9 w-full max-w-lg rounded border border-alpha-1 bg-bg-2 p-8 text-left sm:rounded-[4rem] sm:p-16"> | ||
<ContactForm /> | ||
</div> | ||
<p className="mt-9 flex justify-center gap-4"> | ||
<span className="text-fg-4">Have an account?</span> | ||
<Button href="/sign-in" variant="link"> | ||
Sign in | ||
</Button> | ||
</p> | ||
</div> | ||
); | ||
|
||
export default Page; |
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,107 @@ | ||
'use client'; | ||
|
||
import Button from '@/_components/button'; | ||
import Input from '@/_components/input'; | ||
import Select, { IOption } from '@/_components/select'; | ||
import newLead from '@/_mutations/new-lead'; | ||
import { Controller, useForm } from 'react-hook-form'; | ||
|
||
export interface ContactFormValues { | ||
email: string; | ||
name: string; | ||
phone?: string; | ||
profession?: IOption; | ||
types: IOption[]; | ||
website?: string; | ||
} | ||
|
||
const ContactForm = () => { | ||
const form = useForm<ContactFormValues>({ | ||
defaultValues: { | ||
email: '', | ||
name: '', | ||
phone: '', | ||
types: [], | ||
website: '', | ||
}, | ||
}); | ||
|
||
return ( | ||
<form | ||
className="flex flex-col gap-8" | ||
onSubmit={form.handleSubmit((values) => newLead(values))} | ||
> | ||
<Input label="Name" required {...form.register('name')} /> | ||
<Input | ||
label="Email address" | ||
required | ||
type="email" | ||
{...form.register('email')} | ||
/> | ||
<Input label="Phone number" type="tel" {...form.register('phone')} /> | ||
<Input label="Company website" type="url" {...form.register('website')} /> | ||
<Controller | ||
control={form.control} | ||
name="profession" | ||
render={({ field }) => ( | ||
<Select | ||
isClearable={false} | ||
label="Profession" | ||
name={field.name} | ||
onBlur={field.onBlur} | ||
onChange={(value) => field.onChange(value)} | ||
options={[ | ||
{ id: 'trainer', label: 'Trainer' }, | ||
{ id: 'veterinarian', label: 'Veterinarian' }, | ||
{ id: 'other', label: 'Other' }, | ||
]} | ||
value={field.value} | ||
/> | ||
)} | ||
/> | ||
<Controller | ||
control={form.control} | ||
name="types" | ||
render={({ field }) => ( | ||
<Select | ||
isClearable={false} | ||
isMulti | ||
label="Case types" | ||
name={field.name} | ||
onBlur={field.onBlur} | ||
onChange={(value) => field.onChange(value)} | ||
options={[ | ||
{ id: 'aggression', label: 'Aggression' }, | ||
{ id: 'anxiety', label: 'Anxiety' }, | ||
{ id: 'fear', label: 'Fear' }, | ||
{ id: 'reactivity', label: 'Reactivity' }, | ||
{ id: 'other', label: 'Other' }, | ||
]} | ||
value={field.value} | ||
/> | ||
)} | ||
/> | ||
{form.formState.errors.root && ( | ||
<div className="text-center">{form.formState.errors.root.message}</div> | ||
)} | ||
{form.formState.isSubmitSuccessful ? ( | ||
<p className="mt-8 text-center"> | ||
Thank you for your interest in llog! | ||
<br /> | ||
We will be in touch soon. | ||
</p> | ||
) : ( | ||
<Button | ||
className="mt-8" | ||
loading={form.formState.isSubmitting} | ||
loadingText="Requesting…" | ||
type="submit" | ||
> | ||
Request a demo | ||
</Button> | ||
)} | ||
</form> | ||
); | ||
}; | ||
|
||
export default ContactForm; |
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,25 @@ | ||
'use server'; | ||
|
||
import { ContactFormValues } from '@/_components/contact-form'; | ||
import { Resend } from 'resend'; | ||
|
||
const newLead = async (data: ContactFormValues) => { | ||
const resend = new Resend(process.env.RESEND_API_KEY); | ||
|
||
await resend.emails.send({ | ||
from: '[email protected]', | ||
html: `<pre>${JSON.stringify( | ||
{ | ||
...data, | ||
profession: data.profession?.label, | ||
types: data.types.map((type) => type.label), | ||
}, | ||
null, | ||
2, | ||
)}</pre>`, | ||
subject: 'New llog demo request', | ||
to: ['[email protected]'], | ||
}); | ||
}; | ||
|
||
export default newLead; |
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