-
Notifications
You must be signed in to change notification settings - Fork 0
Add Emailing #7
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
Open
PunGrumpy
wants to merge
5
commits into
main
Choose a base branch
from
dev/email
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.
+1,155
−70
Open
Add Emailing #7
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c68b8db
feat(email): implement email functionality with password reset and ve…
PunGrumpy 3c7f676
refactor(auth): remove core keys from environment configuration
PunGrumpy 0dc2c47
chore(dependencies): add @repo/email to package.json and bun.lock for…
PunGrumpy 88c1186
refactor(header): remove size prop from buttons for consistent styling
PunGrumpy 23ead0a
chore(labeler): update labeler configuration to include analytics and…
PunGrumpy 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
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
102 changes: 102 additions & 0 deletions
102
apps/web/app/(unauthenticated)/forgot-password/forgot-password.tsx
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,102 @@ | ||
| 'use client' | ||
|
|
||
| import { zodResolver } from '@hookform/resolvers/zod' | ||
| import { forgetPassword } from '@repo/auth/client' | ||
| import { Alert } from '@repo/ui/components/ui/alert' | ||
| import { Button } from '@repo/ui/components/ui/button' | ||
| import { | ||
| Form, | ||
| FormControl, | ||
| FormField, | ||
| FormItem, | ||
| FormLabel, | ||
| FormMessage | ||
| } from '@repo/ui/components/ui/form' | ||
| import { Input } from '@repo/ui/components/ui/input' | ||
| import { AlertCircle, PartyPopper } from 'lucide-react' | ||
| import { useState } from 'react' | ||
| import { useForm } from 'react-hook-form' | ||
| import type { z } from 'zod' | ||
| import { formSchema } from './schema' | ||
|
|
||
| export const ForgotPassword = () => { | ||
| const [status, setStatus] = useState<boolean>(false) | ||
| const [generalError, setGeneralError] = useState<string | null>(null) | ||
| const form = useForm<z.infer<typeof formSchema>>({ | ||
| resolver: zodResolver(formSchema), | ||
| defaultValues: { | ||
| email: '' | ||
| } | ||
| }) | ||
|
|
||
| const onSubmit = async ({ email }: z.infer<typeof formSchema>) => { | ||
| try { | ||
| const { data, error } = await forgetPassword({ | ||
| email, | ||
| redirectTo: '/reset-password' | ||
| }) | ||
|
|
||
| if (error) { | ||
| setGeneralError(error.message || 'Failed to send reset password email.') | ||
| } | ||
|
|
||
| if (data && !error) { | ||
| setStatus(true) | ||
| } | ||
| } catch { | ||
| setGeneralError( | ||
| 'Could not connect to the authentication service. Please try again later or contact support if the issue persists.' | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <div className="flex w-full flex-1 flex-col items-center justify-center gap-6 p-6"> | ||
| <div className="mx-auto mb-4 max-w-md text-center"> | ||
| <h1 className="font-semibold text-3xl">Forgot Password?</h1> | ||
| </div> | ||
| <div className="mx-auto w-full max-w-80 space-y-4"> | ||
| {generalError && ( | ||
| <Alert variant="destructive" className="flex bg-destructive/15"> | ||
| <AlertCircle className="inline-block size-4" /> | ||
| {generalError} | ||
| </Alert> | ||
| )} | ||
| {status && ( | ||
| <Alert className="flex bg-success/15 text-success"> | ||
| <PartyPopper className="inline-block size-4" /> | ||
| Check your email for a link to reset your password. | ||
| </Alert> | ||
| )} | ||
| <Form {...form}> | ||
| <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4"> | ||
| <FormField | ||
| control={form.control} | ||
| name="email" | ||
| render={({ field }) => ( | ||
| <FormItem> | ||
| <FormLabel>Email</FormLabel> | ||
| <FormControl> | ||
| <Input disabled={status} placeholder="Email" {...field} /> | ||
| </FormControl> | ||
| <FormMessage /> | ||
| </FormItem> | ||
| )} | ||
| /> | ||
| <Button | ||
| type="submit" | ||
| variant={form.formState.isValid ? 'default' : 'outline'} | ||
| size="lg" | ||
| className="mt-4 w-full" | ||
| disabled={ | ||
| form.formState.isSubmitting || !form.formState.isValid || status | ||
| } | ||
| > | ||
| {form.formState.isSubmitting ? 'Sending...' : 'Send Reset Link'} | ||
| </Button> | ||
| </form> | ||
| </Form> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } |
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,9 @@ | ||
| import dynamic from 'next/dynamic' | ||
|
|
||
| const ForgotPassword = dynamic(() => | ||
| import('./forgot-password').then(mod => mod.ForgotPassword) | ||
| ) | ||
|
|
||
| export default function ForgotPasswordPage() { | ||
| return <ForgotPassword /> | ||
| } |
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,5 @@ | ||
| import { z } from 'zod' | ||
|
|
||
| export const formSchema = z.object({ | ||
| email: z.string().email() | ||
| }) |
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
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,9 @@ | ||
| import dynamic from 'next/dynamic' | ||
|
|
||
| const ResetPassword = dynamic(() => | ||
| import('./reset-password').then(mod => mod.ResetPassword) | ||
| ) | ||
|
|
||
| export default function ResetPasswordPage() { | ||
| return <ResetPassword /> | ||
| } |
Oops, something went wrong.
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.
Incorrect loading text for login form.
The button displays "Signing up..." during submission, but this is a login form, not a signup form.
📝 Committable suggestion