This repository was archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
chore: implement landing page changes #116
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fddbc8b
chore: pulling
tobySolutions 5c96f24
Merge branch 'main' of https://github.com/GuiBibeau/akeru
tobySolutions bb2eb72
fix: broken 404 page
tobySolutions 7862467
Merge branch 'main' of https://github.com/GuiBibeau/akeru
tobySolutions 12e3405
chore: pulling
tobySolutions 6ed1321
chore: checkout
tobySolutions 6f19045
chore: implement landing page changes
tobySolutions 3d82831
chore: implement landing page changes
tobySolutions 0e204d6
fix: handle submitted state
tobySolutions 5995bb1
chore: remove unnecessary code lines
tobySolutions 673186b
chore: remove unnecessary code lines
tobySolutions d6aef29
chore: remove unnecessary code lines
tobySolutions 250aa48
chore: change link to repo link
tobySolutions 2addc65
chore: add updates to hero title
tobySolutions 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 hidden or 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 hidden or 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,37 @@ | ||
'use server' | ||
|
||
export type FormState = { | ||
message: string | ||
submitted: boolean | ||
} | ||
|
||
export const handleWaitlistSubmit = async ( | ||
prevState: FormState, | ||
formData: FormData, | ||
) => { | ||
const url = process.env.NEXT_GOOGLE_SHEETS_API! | ||
let rawFormData = { email: formData.get('email') } | ||
|
||
try { | ||
const response = await fetch(url, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(rawFormData), | ||
}) | ||
|
||
if (response.ok) { | ||
return { message: 'Email address sent successfully!', submitted: true } | ||
} else { | ||
console.error( | ||
'Failed to send email address. Status code:', | ||
response.status, | ||
) | ||
} | ||
} catch (error) { | ||
return { message: 'Email address not sent', submitted: false } | ||
} | ||
|
||
return { message: 'Email address not sent', submitted: false } | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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,79 @@ | ||
"use client" | ||
import { FormState, handleWaitlistSubmit } from '@/app/server' | ||
import { useFormState, useFormStatus } from 'react-dom' | ||
|
||
const initialState: FormState = { | ||
message: '', | ||
submitted: false, | ||
} | ||
|
||
function ArrowIcon(props: React.ComponentPropsWithoutRef<'svg'>) { | ||
return ( | ||
<svg viewBox="0 0 16 6" aria-hidden="true" {...props}> | ||
<path | ||
fill="currentColor" | ||
fillRule="evenodd" | ||
clipRule="evenodd" | ||
d="M16 3 10 .5v2H0v1h10v2L16 3Z" | ||
/> | ||
</svg> | ||
) | ||
} | ||
|
||
function CheckMarkIcon(props: React.ComponentPropsWithoutRef<'svg'>) { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="currentColor" | ||
fillRule="evenodd" | ||
clipRule="evenodd" | ||
aria-hidden="true" | ||
{...props} | ||
viewBox="0 0 24 24" | ||
> | ||
<path d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z" /> | ||
</svg> | ||
) | ||
} | ||
|
||
export function WaitlistForm() { | ||
const [state, formAction] = useFormState(handleWaitlistSubmit, initialState) | ||
|
||
return ( | ||
<form className="max-w-sm" action={formAction}> | ||
<div className="relative mt-6"> | ||
<input | ||
type="email" | ||
placeholder="Email address" | ||
autoComplete="email" | ||
required | ||
name={'email'} | ||
aria-label="Email address" | ||
className="block w-full rounded-2xl border border-neutral-300 bg-transparent py-4 pl-6 pr-20 text-base/6 text-neutral-950 ring-4 ring-transparent transition placeholder:text-neutral-500 focus:border-neutral-950 focus:outline-none focus:ring-neutral-950/5" | ||
/> | ||
<div className="absolute inset-y-1 right-1 flex justify-end"> | ||
<FormIconDisplay submitted={state?.submitted} /> | ||
</div> | ||
</div> | ||
</form> | ||
) | ||
} | ||
|
||
function FormIconDisplay({ submitted }: { submitted: boolean | undefined }) { | ||
const { pending } = useFormStatus() | ||
|
||
return ( | ||
<button | ||
type="submit" | ||
aria-label="Submit" | ||
disabled={pending} | ||
className="flex aspect-square h-full items-center justify-center rounded-xl bg-neutral-950 text-white transition hover:bg-neutral-800" | ||
> | ||
{submitted ? ( | ||
<CheckMarkIcon className="w-4" /> | ||
) : ( | ||
<ArrowIcon className="w-4" /> | ||
)} | ||
</button> | ||
) | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.