From c82692cc8b535b19b109c833f3bdcaf26b513ba9 Mon Sep 17 00:00:00 2001 From: Gib Date: Fri, 23 May 2025 13:54:06 -0500 Subject: [PATCH] Add templates? Maybe? --- .../default/profile/ResetPasswordForm.tsx | 130 ++++++++++++++++++ .../mail_templates/change_email_address.html | 43 ++++++ src/server/mail_templates/confirm_signup.html | 41 ++++++ src/server/mail_templates/invite_user.html | 41 ++++++ src/server/mail_templates/magic_link.html | 43 ++++++ .../mail_templates/reauthentication.html | 42 ++++++ src/server/mail_templates/reset_password.html | 43 ++++++ 7 files changed, 383 insertions(+) create mode 100644 src/components/default/profile/ResetPasswordForm.tsx create mode 100644 src/server/mail_templates/change_email_address.html create mode 100644 src/server/mail_templates/confirm_signup.html create mode 100644 src/server/mail_templates/invite_user.html create mode 100644 src/server/mail_templates/magic_link.html create mode 100644 src/server/mail_templates/reauthentication.html create mode 100644 src/server/mail_templates/reset_password.html diff --git a/src/components/default/profile/ResetPasswordForm.tsx b/src/components/default/profile/ResetPasswordForm.tsx new file mode 100644 index 0000000..ab0cea9 --- /dev/null +++ b/src/components/default/profile/ResetPasswordForm.tsx @@ -0,0 +1,130 @@ +import { z } from 'zod'; +import { zodResolver } from '@hookform/resolvers/zod'; +import { useForm } from 'react-hook-form'; +import { + Button, + CardDescription, + CardHeader, + CardTitle, + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, + Input, +} from '@/components/ui'; +import { Loader2 } from 'lucide-react'; +import { useState } from 'react'; + +const formSchema = z + .object({ + password: z.string().min(8, { + message: 'Password must be at least 8 characters.', + }), + confirmPassword: z.string(), + }) + .refine((data) => data.password === data.confirmPassword, { + message: 'Passwords do not match.', + path: ['confirmPassword'], + }); + +type ResetPasswordFormProps = { + onSubmit: (values: z.infer) => Promise; + message?: string; +}; + +export const ResetPasswordForm = ({ + onSubmit, + message, +}: ResetPasswordFormProps) => { + const [isLoading, setIsLoading] = useState(false); + const [statusMessage, setStatusMessage] = useState(message ?? ''); + + const form = useForm>({ + resolver: zodResolver(formSchema), + defaultValues: { + password: '', + confirmPassword: '', + }, + }); + + const handleSubmit = async (values: z.infer) => { + setIsLoading(true); + try { + await onSubmit(values); + setStatusMessage('Password updated successfully'); + form.reset(); + } catch (error) { + setStatusMessage(error instanceof Error ? error.message : 'An error occurred'); + } finally { + setIsLoading(false); + } + }; + + return ( +
+ + Change Password + + Update your password to keep your account secure + + + +
+ + ( + + New Password + + + + + Enter your new password. Must be at least 8 characters. + + + + )} + /> + ( + + Confirm Password + + + + + Please re-enter your new password to confirm. + + + + )} + /> + {statusMessage && ( +
+ {statusMessage} +
+ )} +
+ +
+ + +
+ ); +}; diff --git a/src/server/mail_templates/change_email_address.html b/src/server/mail_templates/change_email_address.html new file mode 100644 index 0000000..d9b65fa --- /dev/null +++ b/src/server/mail_templates/change_email_address.html @@ -0,0 +1,43 @@ + + + + Confirm Change of Email + + +
+
+ + + + + +
+ Tech Tracker Logo + +

Tech Tracker

+
+
+ +

Confirm Change of Email

+ +

Hello,

+ +

We received a request to change your email address from {{ .Email }} to {{ .NewEmail }}.

+ +

To confirm this change, please click the button below:

+ + + +

If you didn't request this change, please contact support immediately.

+ +
+

Tech Tracker - City of Gulfport

+
+
+ + diff --git a/src/server/mail_templates/confirm_signup.html b/src/server/mail_templates/confirm_signup.html new file mode 100644 index 0000000..c3ae92b --- /dev/null +++ b/src/server/mail_templates/confirm_signup.html @@ -0,0 +1,41 @@ + + + + Confirm Your Email + + +
+
+ + + + + +
+ Tech Tracker Logo + +

Tech Tracker

+
+
+ +

Confirm Your Email

+ +

Hello,

+ +

Thank you for signing up for Tech Tracker. To complete your registration, please confirm your email address by clicking the button below:

+ + + +

If you didn't create an account with Tech Tracker, you can safely ignore this email.

+ +
+

Tech Tracker - City of Gulfport

+
+
+ + diff --git a/src/server/mail_templates/invite_user.html b/src/server/mail_templates/invite_user.html new file mode 100644 index 0000000..1d83290 --- /dev/null +++ b/src/server/mail_templates/invite_user.html @@ -0,0 +1,41 @@ + + + + You've Been Invited + + +
+
+ + + + + +
+ Tech Tracker Logo + +

Tech Tracker

+
+
+ +

You've Been Invited

+ +

Hello,

+ +

You have been invited to join Tech Tracker. To accept this invitation and create your account, please click the button below:

+ + + +

Tech Tracker helps teams manage their projects efficiently. We're excited to have you on board!

+ +
+

Tech Tracker - City of Gulfport

+
+
+ + diff --git a/src/server/mail_templates/magic_link.html b/src/server/mail_templates/magic_link.html new file mode 100644 index 0000000..5bc4918 --- /dev/null +++ b/src/server/mail_templates/magic_link.html @@ -0,0 +1,43 @@ + + + + Magic Link Sign In + + +
+
+ + + + + +
+ Tech Tracker Logo + +

Tech Tracker

+
+
+ +

Your Magic Link

+ +

Hello,

+ +

You requested a magic link to sign in to your Tech Tracker account. Click the button below to sign in:

+ + + +

This link will expire in 1 hour and can only be used once.

+ +

If you didn't request this magic link, you can safely ignore this email.

+ +
+

Tech Tracker - City of Gulfport

+
+
+ + diff --git a/src/server/mail_templates/reauthentication.html b/src/server/mail_templates/reauthentication.html new file mode 100644 index 0000000..da99a3b --- /dev/null +++ b/src/server/mail_templates/reauthentication.html @@ -0,0 +1,42 @@ + + + + Confirm Reauthentication + + +
+
+ + + + + +
+ Tech Tracker Logo + +

Tech Tracker

+
+
+ +

Confirm Reauthentication

+ +

Hello,

+ +

For security reasons, we need to verify your identity. Please enter the following code when prompted:

+ +
+
+ {{ .Token }} +
+
+ +

This code will expire in 10 minutes.

+ +

If you didn't request this code, please secure your account by changing your password immediately.

+ +
+

Tech Tracker - City of Gulfport

+
+
+ + diff --git a/src/server/mail_templates/reset_password.html b/src/server/mail_templates/reset_password.html new file mode 100644 index 0000000..4751289 --- /dev/null +++ b/src/server/mail_templates/reset_password.html @@ -0,0 +1,43 @@ + + + + Reset Password + + +
+
+ + + + + +
+ Tech Tracker Logo + +

Tech Tracker

+
+
+ +

Reset Your Password

+ +

Hello,

+ +

We received a request to reset your password for your Tech Tracker account. Follow this link to reset the password for your user:

+ + + +

If you didn't request a password reset, you can safely ignore this email.

+ +

This link will expire in 1 hour.

+ +
+

Tech Tracker - City of Gulfport

+
+
+ +