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:
parent
0804ac5e96
commit
657e5212f4
@ -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>
|
||||
);
|
||||
}
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Locale, Messages } from 'next-intl';
|
||||
import { EmailTemplates } from '../emails';
|
||||
import { EmailTemplates } from './emails';
|
||||
|
||||
export interface BaseEmailProps {
|
||||
locale: Locale;
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user