-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix verify, add resend verify page (#94)
Signed-off-by: Sarah Funkhouser <[email protected]>
- Loading branch information
1 parent
1841683
commit 4b869f7
Showing
13 changed files
with
256 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { tv, type VariantProps } from 'tailwind-variants' | ||
|
||
const pageStyles = tv({ | ||
slots: { | ||
content: 'flex items-center justify-center h-screen relative', | ||
form: 'w-full relative z-3 px-4' | ||
}, | ||
}) | ||
|
||
export type PageVariants = VariantProps<typeof pageStyles> | ||
|
||
export { pageStyles } |
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 @@ | ||
'use client' | ||
|
||
import { Resend } from '@/components/pages/auth/resend-verify/resend' | ||
import { pageStyles } from './page.styles' | ||
|
||
const ResendVerification: React.FC = () => { | ||
const { content, form } = pageStyles() | ||
return ( | ||
<main className={content()}> | ||
<div className={form()}> | ||
<Resend /> | ||
</div> | ||
</main> | ||
) | ||
} | ||
|
||
export default ResendVerification |
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,21 @@ | ||
import { NextResponse } from 'next/server' | ||
|
||
export async function POST(request: Request) { | ||
const bodyData = await request.json() | ||
|
||
const fData = await fetch(`${process.env.API_REST_URL}/v1/resend`, { | ||
method: 'POST', | ||
headers: { | ||
'content-type': 'application/json', | ||
}, | ||
body: JSON.stringify(bodyData), | ||
}) | ||
|
||
if (fData.ok) { | ||
return NextResponse.json(await fData.json(), { status: 200 }) | ||
} | ||
|
||
if (fData.status !== 201) { | ||
return NextResponse.json(await fData.json(), { status: fData.status }) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
apps/console/src/components/pages/auth/resend-verify/resend.styles.ts
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,23 @@ | ||
import { tv, type VariantProps } from 'tailwind-variants' | ||
|
||
const resendStyles = tv({ | ||
slots: { | ||
logo: 'flex justify-center mb-10', | ||
text: "text-center text-sm", | ||
header: "text-xl text-center", | ||
wrapper: 'relative mt-1 flex flex-col gap-2 md:flex-row', | ||
input: 'w-full h-12 md:h-auto text-ziggurat-900', | ||
button: | ||
'absolute h-10 text-md md:relative md:text-md md:top-0 md:h-14', | ||
errorMessage: 'text-ziggurat-200 mt-14', | ||
success: | ||
'mt-14 text-center bg-ziggurat-900 bg-opacity-20 p-5 rounded-md text-white flex gap-3', | ||
successMessage: 'flex-1', | ||
successIcon: 'mt-1', | ||
}, | ||
}) | ||
|
||
|
||
export type ResendVariants = VariantProps<typeof resendStyles> | ||
|
||
export { resendStyles } |
89 changes: 89 additions & 0 deletions
89
apps/console/src/components/pages/auth/resend-verify/resend.tsx
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,89 @@ | ||
'use client' | ||
|
||
import { zodResolver } from '@hookform/resolvers/zod' | ||
import { useForm } from 'react-hook-form' | ||
import { z } from 'zod' | ||
|
||
import { Button } from '@repo/ui/button' | ||
import { | ||
Form, | ||
FormField, | ||
FormControl, | ||
FormMessage, | ||
FormLabel, | ||
} from '@repo/ui/form' | ||
import { Input } from '@repo/ui/input' | ||
import { resendStyles } from './resend.styles' | ||
import { resendVerification } from '@/lib/user' | ||
import { useRouter } from 'next/navigation' | ||
import { Panel } from '@repo/ui/panel' | ||
import { Logo } from '@repo/ui/logo' | ||
|
||
const formSchema = z.object({ | ||
email: z.string().email(), | ||
}) | ||
|
||
export const Resend = () => { | ||
const router = useRouter() | ||
|
||
const { | ||
wrapper, | ||
input, | ||
button, | ||
text, | ||
header, | ||
logo, | ||
} = resendStyles() | ||
|
||
const form = useForm<z.infer<typeof formSchema>>({ | ||
resolver: zodResolver(formSchema), | ||
defaultValues: { | ||
email: '', | ||
}, | ||
}) | ||
|
||
const onSubmit = ({ email }: z.infer<typeof formSchema>) => { | ||
const result = resendVerification({ email }) | ||
router.push('/verify') | ||
} | ||
|
||
|
||
return ( | ||
<> | ||
<Panel> | ||
<div className={logo()}> | ||
<Logo width={300} /> | ||
</div> | ||
<h2 className={header()}>Can't find that email?</h2> | ||
<p className={text()}> | ||
We got you, enter your email to have our robots <br /> | ||
resend that verification email right over to you. </p> | ||
<Form {...form}> | ||
<form onSubmit={form.handleSubmit(onSubmit)} className={wrapper()}> | ||
<FormField | ||
control={form.control} | ||
name="email" | ||
render={({ field }) => ( | ||
<> | ||
<FormLabel>Email</FormLabel> | ||
<FormControl> | ||
<Input | ||
type="email" | ||
placeholder="[email protected]" | ||
className={input()} | ||
{...field} | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</> | ||
)} | ||
/> | ||
<Button type="submit" className={button()}> | ||
Resend Verification | ||
</Button> | ||
</form> | ||
</Form> | ||
</Panel > | ||
</> | ||
) | ||
} |
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
22 changes: 22 additions & 0 deletions
22
apps/console/src/components/pages/auth/verify/page.styles.tsx
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,22 @@ | ||
import { tv, type VariantProps } from 'tailwind-variants' | ||
|
||
const verificationStyles = tv({ | ||
slots: { | ||
content: 'flex flex-col min-h-screen w-full items-center space-between dark:bg-dk-surface-0 bg-surface-0', | ||
wrapper: 'flex flex-col justify-center mx-auto my-auto w-full p-6 sm:w-1/3 h-full relative ease-in-out', | ||
errorMessage: 'text-ziggurat-200 mt-14', | ||
success: | ||
'mt-14 bg-ziggurat-900 bg-opacity-20 p-5 rounded-md text-white justify-center text-center', | ||
successMessage: 'text-center', | ||
successIcon: 'mt-1 justify-center items-center', | ||
loading: 'mt-14 p-5 rounded-md text-white flex gap-3', | ||
resendMessage: 'text-xs text-gray-400 mt-4 text-center', | ||
button: 'mt-12 flex w-full justify-center', | ||
logo: 'mx-auto b-3', | ||
verifying: 'text-3xl text-center mt-4 animate-pulse', | ||
}, | ||
}) | ||
|
||
export type VerificationVariants = VariantProps<typeof verificationStyles> | ||
|
||
export { verificationStyles } |
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
Oops, something went wrong.