refactor: remove WaitlistForm component and reorganize email types

- Deleted the `WaitlistForm` component to streamline the codebase and improve modularity.
- Introduced a new `types.ts` file in the `mail` directory to centralize email-related type definitions, enhancing code organization and maintainability.
- Updated imports across email components to reference the new `types.ts`, ensuring consistency and clarity in type usage.
This commit is contained in:
javayhu 2025-03-16 09:49:51 +08:00
parent 0804ac5e96
commit 657e5212f4
8 changed files with 9 additions and 36 deletions

View File

@ -1,25 +0,0 @@
'use client';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
export function WaitlistForm({ labels }: {
labels: {
email: string;
subscribe: string;
}
}) {
return (
<form action="" className="mt-8 space-y-4">
<div className="space-y-2">
<Label htmlFor="email">{labels.email}</Label>
<Input type="email" id="email" required />
</div>
<Button type="submit" className="w-full">
{labels.subscribe}
</Button>
</form>
);
}

View File

@ -8,7 +8,7 @@ import {
Tailwind,
Text
} from '@react-email/components';
import { BaseEmailProps } from '../utils/types';
import { BaseEmailProps } from '@/mail/types';
import { createTranslator } from 'use-intl/core';
interface EmailLayoutProps extends BaseEmailProps {

View File

@ -2,7 +2,7 @@ import { defaultMessages } from '@/i18n/messages';
import { routing } from '@/i18n/routing';
import EmailButton from '@/mail/components/email-button';
import EmailLayout from '@/mail/components/email-layout';
import type { BaseEmailProps } from '@/mail/utils/types';
import type { BaseEmailProps } from '@/mail/types';
import { Text } from '@react-email/components';
import { createTranslator } from 'use-intl/core';
@ -35,7 +35,6 @@ export function ForgotPassword({
);
}
// NOTICE: can not use await here!!!
ForgotPassword.PreviewProps = {
locale: routing.defaultLocale,
messages: defaultMessages,

View File

@ -1,7 +1,7 @@
import { defaultMessages } from '@/i18n/messages';
import { routing } from '@/i18n/routing';
import EmailLayout from '@/mail/components/email-layout';
import type { BaseEmailProps } from '@/mail/utils/types';
import type { BaseEmailProps } from '@/mail/types';
import { Heading, Text } from '@react-email/components';
import { createTranslator } from 'use-intl/core';

View File

@ -2,7 +2,7 @@ import { defaultMessages } from '@/i18n/messages';
import { routing } from '@/i18n/routing';
import EmailButton from '@/mail/components/email-button';
import EmailLayout from '@/mail/components/email-layout';
import type { BaseEmailProps } from '@/mail/utils/types';
import type { BaseEmailProps } from '@/mail/types';
import { Text } from '@react-email/components';
import { createTranslator } from 'use-intl/core';

View File

@ -1,13 +1,12 @@
import { websiteConfig } from '@/config';
import { SendEmailHandler } from '@/mail/utils/types';
import { SendEmailHandler } from '@/mail/types';
import { Resend } from 'resend';
// 如果没有API密钥使用一个假的密钥避免构建错误
const apiKey = process.env.RESEND_API_KEY || 'test_api_key';
export const resend = new Resend(apiKey);
const resend = new Resend(apiKey);
export const sendEmail: SendEmailHandler = async ({ to, subject, html }) => {
// 如果没有API密钥记录日志并返回避免发送请求
if (!process.env.RESEND_API_KEY) {
console.warn('RESEND_API_KEY not set, skipping email send');
return;

View File

@ -1,5 +1,5 @@
import { Locale, Messages } from 'next-intl';
import { EmailTemplates } from '../emails';
import { EmailTemplates } from './emails';
export interface BaseEmailProps {
locale: Locale;

View File

@ -4,7 +4,7 @@ import { EmailTemplates } from '@/mail/emails';
import { sendEmail } from '@/mail/provider/resend';
import { render } from '@react-email/render';
import { Locale, Messages } from 'next-intl';
import { Template } from './types';
import { Template } from '@/mail/types';
/**
* send email