refactor: update email configuration to use fromEmail and supportEmail in website settings
This commit is contained in:
parent
222154397a
commit
b0ebee8633
@ -34,7 +34,7 @@ export const sendMessageAction = actionClient
|
||||
try {
|
||||
const { name, email, message } = parsedInput;
|
||||
|
||||
if (!websiteConfig.mail.contact) {
|
||||
if (!websiteConfig.mail.supportEmail) {
|
||||
console.error('The mail receiver is not set');
|
||||
throw new Error('The mail receiver is not set');
|
||||
}
|
||||
@ -43,7 +43,7 @@ export const sendMessageAction = actionClient
|
||||
|
||||
// Send message as an email to admin
|
||||
const result = await sendEmail({
|
||||
to: websiteConfig.mail.contact,
|
||||
to: websiteConfig.mail.supportEmail,
|
||||
template: 'contactMessage',
|
||||
context: {
|
||||
name,
|
||||
|
@ -62,13 +62,13 @@ export default async function AboutPage() {
|
||||
{t('introduction')}
|
||||
</p>
|
||||
|
||||
{websiteConfig.mail.contact && (
|
||||
{websiteConfig.mail.supportEmail && (
|
||||
<div className="flex items-center gap-4">
|
||||
<Button className="rounded-lg cursor-pointer">
|
||||
<MailIcon className="mr-1 size-4" />
|
||||
<a href={`mailto:${websiteConfig.mail.contact}`}>
|
||||
{t('talkWithMe')}
|
||||
</a>
|
||||
<a href={`mailto:${websiteConfig.mail.supportEmail}`}>
|
||||
{t('talkWithMe')}
|
||||
</a>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
@ -89,7 +89,7 @@ export default function HeroSection() {
|
||||
speedSegment={0.3}
|
||||
delay={0.5}
|
||||
as="p"
|
||||
className="mx-auto mt-8 max-w-2xl text-balance text-lg"
|
||||
className="mx-auto mt-8 max-w-4xl text-balance text-lg text-muted-foreground"
|
||||
>
|
||||
{t('description')}
|
||||
</TextEffect>
|
||||
|
@ -59,7 +59,8 @@ export const websiteConfig: WebsiteConfig = {
|
||||
},
|
||||
mail: {
|
||||
provider: 'resend',
|
||||
contact: 'support@mksaas.com',
|
||||
fromEmail: 'support@mksaas.com',
|
||||
supportEmail: 'support@mksaas.com',
|
||||
},
|
||||
newsletter: {
|
||||
provider: 'resend',
|
||||
|
@ -26,7 +26,7 @@ export class ResendProvider implements MailProvider {
|
||||
throw new Error('RESEND_API_KEY environment variable is not set.');
|
||||
}
|
||||
|
||||
if (!websiteConfig.mail.contact) {
|
||||
if (!websiteConfig.mail.fromEmail) {
|
||||
throw new Error(
|
||||
'Default from email address is not set in websiteConfig.'
|
||||
);
|
||||
@ -34,7 +34,7 @@ export class ResendProvider implements MailProvider {
|
||||
|
||||
const apiKey = process.env.RESEND_API_KEY;
|
||||
this.resend = new Resend(apiKey);
|
||||
this.from = websiteConfig.mail.contact;
|
||||
this.from = websiteConfig.mail.fromEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
|
3
src/types/index.d.ts
vendored
3
src/types/index.d.ts
vendored
@ -99,7 +99,8 @@ export interface BlogConfig {
|
||||
*/
|
||||
export interface MailConfig {
|
||||
provider: 'resend'; // The email provider, only resend is supported for now
|
||||
contact?: string; // Sender email address, as well as recipient email address
|
||||
fromEmail?: string; // The email address to send from
|
||||
supportEmail?: string; // The email address to send support emails to
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user