Add templates? Maybe?
This commit is contained in:
parent
44a1ea8a37
commit
c82692cc8b
130
src/components/default/profile/ResetPasswordForm.tsx
Normal file
130
src/components/default/profile/ResetPasswordForm.tsx
Normal file
@ -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<typeof formSchema>) => Promise<void>;
|
||||
message?: string;
|
||||
};
|
||||
|
||||
export const ResetPasswordForm = ({
|
||||
onSubmit,
|
||||
message,
|
||||
}: ResetPasswordFormProps) => {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [statusMessage, setStatusMessage] = useState(message ?? '');
|
||||
|
||||
const form = useForm<z.infer<typeof formSchema>>({
|
||||
resolver: zodResolver(formSchema),
|
||||
defaultValues: {
|
||||
password: '',
|
||||
confirmPassword: '',
|
||||
},
|
||||
});
|
||||
|
||||
const handleSubmit = async (values: z.infer<typeof formSchema>) => {
|
||||
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 (
|
||||
<div>
|
||||
<CardHeader className='pb-5'>
|
||||
<CardTitle className='text-xl'>Change Password</CardTitle>
|
||||
<CardDescription>
|
||||
Update your password to keep your account secure
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(handleSubmit)} className='space-y-6'>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name='password'
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>New Password</FormLabel>
|
||||
<FormControl>
|
||||
<Input type='password' {...field} />
|
||||
</FormControl>
|
||||
<FormDescription>
|
||||
Enter your new password. Must be at least 8 characters.
|
||||
</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name='confirmPassword'
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Confirm Password</FormLabel>
|
||||
<FormControl>
|
||||
<Input type='password' {...field} />
|
||||
</FormControl>
|
||||
<FormDescription>
|
||||
Please re-enter your new password to confirm.
|
||||
</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
{statusMessage && (
|
||||
<div className={`text-sm text-center ${statusMessage.includes('error') || statusMessage.includes('failed') ? 'text-destructive' : 'text-green-600'}`}>
|
||||
{statusMessage}
|
||||
</div>
|
||||
)}
|
||||
<div className='flex justify-center'>
|
||||
<Button type='submit' disabled={isLoading}>
|
||||
{isLoading ? (
|
||||
<>
|
||||
<Loader2 className='mr-2 h-4 w-4 animate-spin' />
|
||||
Updating Password...
|
||||
</>
|
||||
) : (
|
||||
'Update Password'
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
);
|
||||
};
|
43
src/server/mail_templates/change_email_address.html
Normal file
43
src/server/mail_templates/change_email_address.html
Normal file
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Confirm Change of Email</title>
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; margin: 0; padding: 0;">
|
||||
<div style="max-width: 600px; margin: 0 auto; padding: 20px;">
|
||||
<div style="text-align: center; margin-bottom: 20px;">
|
||||
<table style="margin: 0 auto;">
|
||||
<tr>
|
||||
<td style="vertical-align: middle; padding-right: 15px;">
|
||||
<img src="https://git.gbrown.org/gib/Tech_Tracker_Web/raw/branch/master/public/images/tech_tracker_logo.png" alt="Tech Tracker Logo" style="max-width: 80px; height: auto;">
|
||||
</td>
|
||||
<td style="vertical-align: middle;">
|
||||
<h1 style="margin: 0; font-size: 48px; color: #001084;">Tech Tracker</h1>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h1 style="color: #000033; text-align: center;">Confirm Change of Email</h1>
|
||||
|
||||
<p>Hello,</p>
|
||||
|
||||
<p>We received a request to change your email address from <strong>{{ .Email }}</strong> to <strong>{{ .NewEmail }}</strong>.</p>
|
||||
|
||||
<p>To confirm this change, please click the button below:</p>
|
||||
|
||||
<div style="text-align: center; margin: 30px 0;">
|
||||
<a href="{{ .ConfirmationURL }}"
|
||||
style="background-color: #2232A6; color: white; padding: 12px 24px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
Confirm Email Change
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<p>If you didn't request this change, please contact support immediately.</p>
|
||||
|
||||
<div style="margin-top: 40px; padding-top: 20px; border-top: 1px solid #eaeaea; text-align: center; color: #666; font-size: 14px;">
|
||||
<p>Tech Tracker - City of Gulfport</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
41
src/server/mail_templates/confirm_signup.html
Normal file
41
src/server/mail_templates/confirm_signup.html
Normal file
@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Confirm Your Email</title>
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; margin: 0; padding: 0;">
|
||||
<div style="max-width: 600px; margin: 0 auto; padding: 20px;">
|
||||
<div style="text-align: center; margin-bottom: 20px;">
|
||||
<table style="margin: 0 auto;">
|
||||
<tr>
|
||||
<td style="vertical-align: middle; padding-right: 15px;">
|
||||
<img src="https://git.gbrown.org/gib/Tech_Tracker_Web/raw/branch/master/public/images/tech_tracker_logo.png" alt="Tech Tracker Logo" style="max-width: 80px; height: auto;">
|
||||
</td>
|
||||
<td style="vertical-align: middle;">
|
||||
<h1 style="margin: 0; font-size: 48px; color: #001084;">Tech Tracker</h1>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h1 style="color: #000033; text-align: center;">Confirm Your Email</h1>
|
||||
|
||||
<p>Hello,</p>
|
||||
|
||||
<p>Thank you for signing up for Tech Tracker. To complete your registration, please confirm your email address by clicking the button below:</p>
|
||||
|
||||
<div style="text-align: center; margin: 30px 0;">
|
||||
<a href="{{ .ConfirmationURL }}"
|
||||
style="background-color: #2232A6; color: white; padding: 12px 24px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
Confirm Email Address
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<p>If you didn't create an account with Tech Tracker, you can safely ignore this email.</p>
|
||||
|
||||
<div style="margin-top: 40px; padding-top: 20px; border-top: 1px solid #eaeaea; text-align: center; color: #666; font-size: 14px;">
|
||||
<p>Tech Tracker - City of Gulfport</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
41
src/server/mail_templates/invite_user.html
Normal file
41
src/server/mail_templates/invite_user.html
Normal file
@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>You've Been Invited</title>
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; margin: 0; padding: 0;">
|
||||
<div style="max-width: 600px; margin: 0 auto; padding: 20px;">
|
||||
<div style="text-align: center; margin-bottom: 20px;">
|
||||
<table style="margin: 0 auto;">
|
||||
<tr>
|
||||
<td style="vertical-align: middle; padding-right: 15px;">
|
||||
<img src="https://git.gbrown.org/gib/Tech_Tracker_Web/raw/branch/master/public/images/tech_tracker_logo.png" alt="Tech Tracker Logo" style="max-width: 80px; height: auto;">
|
||||
</td>
|
||||
<td style="vertical-align: middle;">
|
||||
<h1 style="margin: 0; font-size: 48px; color: #001084;">Tech Tracker</h1>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h1 style="color: #000033; text-align: center;">You've Been Invited</h1>
|
||||
|
||||
<p>Hello,</p>
|
||||
|
||||
<p>You have been invited to join Tech Tracker. To accept this invitation and create your account, please click the button below:</p>
|
||||
|
||||
<div style="text-align: center; margin: 30px 0;">
|
||||
<a href="{{ .ConfirmationURL }}"
|
||||
style="background-color: #2232A6; color: white; padding: 12px 24px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
Accept Invitation
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<p>Tech Tracker helps teams manage their projects efficiently. We're excited to have you on board!</p>
|
||||
|
||||
<div style="margin-top: 40px; padding-top: 20px; border-top: 1px solid #eaeaea; text-align: center; color: #666; font-size: 14px;">
|
||||
<p>Tech Tracker - City of Gulfport</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
43
src/server/mail_templates/magic_link.html
Normal file
43
src/server/mail_templates/magic_link.html
Normal file
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Magic Link Sign In</title>
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; margin: 0; padding: 0;">
|
||||
<div style="max-width: 600px; margin: 0 auto; padding: 20px;">
|
||||
<div style="text-align: center; margin-bottom: 20px;">
|
||||
<table style="margin: 0 auto;">
|
||||
<tr>
|
||||
<td style="vertical-align: middle; padding-right: 15px;">
|
||||
<img src="https://git.gbrown.org/gib/Tech_Tracker_Web/raw/branch/master/public/images/tech_tracker_logo.png" alt="Tech Tracker Logo" style="max-width: 80px; height: auto;">
|
||||
</td>
|
||||
<td style="vertical-align: middle;">
|
||||
<h1 style="margin: 0; font-size: 48px; color: #001084;">Tech Tracker</h1>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h1 style="color: #000033; text-align: center;">Your Magic Link</h1>
|
||||
|
||||
<p>Hello,</p>
|
||||
|
||||
<p>You requested a magic link to sign in to your Tech Tracker account. Click the button below to sign in:</p>
|
||||
|
||||
<div style="text-align: center; margin: 30px 0;">
|
||||
<a href="{{ .ConfirmationURL }}"
|
||||
style="background-color: #2232A6; color: white; padding: 12px 24px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
Sign In
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<p>This link will expire in 1 hour and can only be used once.</p>
|
||||
|
||||
<p>If you didn't request this magic link, you can safely ignore this email.</p>
|
||||
|
||||
<div style="margin-top: 40px; padding-top: 20px; border-top: 1px solid #eaeaea; text-align: center; color: #666; font-size: 14px;">
|
||||
<p>Tech Tracker - City of Gulfport</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
42
src/server/mail_templates/reauthentication.html
Normal file
42
src/server/mail_templates/reauthentication.html
Normal file
@ -0,0 +1,42 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Confirm Reauthentication</title>
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; margin: 0; padding: 0;">
|
||||
<div style="max-width: 600px; margin: 0 auto; padding: 20px;">
|
||||
<div style="text-align: center; margin-bottom: 20px;">
|
||||
<table style="margin: 0 auto;">
|
||||
<tr>
|
||||
<td style="vertical-align: middle; padding-right: 15px;">
|
||||
<img src="https://git.gbrown.org/gib/Tech_Tracker_Web/raw/branch/master/public/images/tech_tracker_logo.png" alt="Tech Tracker Logo" style="max-width: 80px; height: auto;">
|
||||
</td>
|
||||
<td style="vertical-align: middle;">
|
||||
<h1 style="margin: 0; font-size: 48px; color: #001084;">Tech Tracker</h1>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h1 style="color: #000033; text-align: center;">Confirm Reauthentication</h1>
|
||||
|
||||
<p>Hello,</p>
|
||||
|
||||
<p>For security reasons, we need to verify your identity. Please enter the following code when prompted:</p>
|
||||
|
||||
<div style="text-align: center; margin: 30px 0;">
|
||||
<div style="font-size: 24px; letter-spacing: 4px; font-weight: bold; background-color: #f3f4f6; padding: 12px; border-radius: 4px; display: inline-block; color: #111133">
|
||||
{{ .Token }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>This code will expire in 10 minutes.</p>
|
||||
|
||||
<p>If you didn't request this code, please secure your account by changing your password immediately.</p>
|
||||
|
||||
<div style="margin-top: 40px; padding-top: 20px; border-top: 1px solid #eaeaea; text-align: center; color: #666; font-size: 14px;">
|
||||
<p>Tech Tracker - City of Gulfport</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
43
src/server/mail_templates/reset_password.html
Normal file
43
src/server/mail_templates/reset_password.html
Normal file
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Reset Password</title>
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; margin: 0; padding: 0;">
|
||||
<div style="max-width: 600px; margin: 0 auto; padding: 20px;">
|
||||
<div style="text-align: center; margin-bottom: 20px;">
|
||||
<table style="margin: 0 auto;">
|
||||
<tr>
|
||||
<td style="vertical-align: middle; padding-right: 15px;">
|
||||
<img src="https://git.gbrown.org/gib/Tech_Tracker_Web/raw/branch/master/public/images/tech_tracker_logo.png" alt="Tech Tracker Logo" style="max-width: 80px; height: auto;">
|
||||
</td>
|
||||
<td style="vertical-align: middle;">
|
||||
<h1 style="margin: 0; font-size: 48px; color: #001084;">Tech Tracker</h1>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h1 style="color: #000033; text-align: center;">Reset Your Password</h1>
|
||||
|
||||
<p>Hello,</p>
|
||||
|
||||
<p>We received a request to reset your password for your Tech Tracker account. Follow this link to reset the password for your user:</p>
|
||||
|
||||
<div style="text-align: center; margin: 30px 0;">
|
||||
<a href="{{ .ConfirmationURL }}"
|
||||
style="background-color: #2232A6; color: white; padding: 12px 24px; text-decoration: none; border-radius: 4px; display: inline-block; font-weight: bold;">
|
||||
Reset Password
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<p>If you didn't request a password reset, you can safely ignore this email.</p>
|
||||
|
||||
<p>This link will expire in 1 hour.</p>
|
||||
|
||||
<div style="margin-top: 40px; padding-top: 20px; border-top: 1px solid #eaeaea; text-align: center; color: #666; font-size: 14px;">
|
||||
<p>Tech Tracker - City of Gulfport</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user