From 41535a68be91232818fcac00c0991db25d76dc05 Mon Sep 17 00:00:00 2001
From: MartinBraquet
Date: Thu, 11 Sep 2025 16:00:10 +0200
Subject: [PATCH] Improve email UI
---
backend/email/emails/functions/helpers.tsx | 4 +
backend/email/emails/functions/send-email.ts | 2 +-
backend/email/emails/new-endorsement.tsx | 129 ++++---------------
backend/email/emails/new-match.tsx | 102 +++++----------
backend/email/emails/new-message.tsx | 96 ++------------
backend/email/emails/test.tsx | 2 +-
backend/email/emails/utils.tsx | 118 +++++++++++++++++
backend/email/package.json | 1 +
8 files changed, 197 insertions(+), 257 deletions(-)
create mode 100644 backend/email/emails/utils.tsx
diff --git a/backend/email/emails/functions/helpers.tsx b/backend/email/emails/functions/helpers.tsx
index 49685064..e8b2102f 100644
--- a/backend/email/emails/functions/helpers.tsx
+++ b/backend/email/emails/functions/helpers.tsx
@@ -29,6 +29,7 @@ export const sendNewMatchEmail = async (
react: (
),
})
@@ -82,6 +84,7 @@ export const sendNewMessageEmail = async (
toUser={toUser}
channelId={channelId}
unsubscribeUrl={unsubscribeUrl}
+ email={privateUser.email}
/>
),
})
@@ -109,6 +112,7 @@ export const sendNewEndorsementEmail = async (
onUser={onUser}
endorsementText={text}
unsubscribeUrl={unsubscribeUrl}
+ email={privateUser.email}
/>
),
})
diff --git a/backend/email/emails/functions/send-email.ts b/backend/email/emails/functions/send-email.ts
index 4c617242..818bd71d 100644
--- a/backend/email/emails/functions/send-email.ts
+++ b/backend/email/emails/functions/send-email.ts
@@ -37,7 +37,7 @@ const getResend = () => {
if (resend) return resend
const apiKey = process.env.RESEND_KEY as string
- console.log(`RESEND_KEY: ${apiKey}`)
+ // console.log(`RESEND_KEY: ${apiKey}`)
resend = new Resend(apiKey)
return resend
}
diff --git a/backend/email/emails/new-endorsement.tsx b/backend/email/emails/new-endorsement.tsx
index cdecd00e..93dc9175 100644
--- a/backend/email/emails/new-endorsement.tsx
+++ b/backend/email/emails/new-endorsement.tsx
@@ -1,41 +1,31 @@
-import {
- Body,
- Button,
- Container,
- Column,
- Head,
- Html,
- Img,
- Link,
- Preview,
- Row,
- Section,
- Text,
-} from '@react-email/components'
-import { type User } from 'common/user'
-import { DOMAIN } from 'common/envs/constants'
-import { jamesUser, sinclairUser } from './functions/mock'
+import {Body, Button, Column, Container, Head, Html, Preview, Row, Section, Text,} from '@react-email/components'
+import {type User} from 'common/user'
+import {DOMAIN} from 'common/envs/constants'
+import {jamesUser, sinclairUser} from './functions/mock'
+import {button, container, content, Footer, main, paragraph} from "email/utils";
interface NewEndorsementEmailProps {
fromUser: User
onUser: User
endorsementText: string
unsubscribeUrl: string
+ email?: string
}
export const NewEndorsementEmail = ({
- fromUser,
- onUser,
- endorsementText,
- unsubscribeUrl,
-}: NewEndorsementEmailProps) => {
+ fromUser,
+ onUser,
+ endorsementText,
+ unsubscribeUrl,
+ email,
+ }: NewEndorsementEmailProps) => {
const name = onUser.name.split(' ')[0]
const endorsementUrl = `https://${DOMAIN}/${onUser.username}`
return (
-
+
@@ -55,15 +45,15 @@ export const NewEndorsementEmail = ({
-
-
-
+ {/**/}
+ {/*
*/}
+ {/**/}
"{endorsementText}"
@@ -75,15 +65,7 @@ export const NewEndorsementEmail = ({
-
-
- This e-mail has been sent to {name},{' '}
- {/*
- click here to unsubscribe from this type of notification
-
- . */}
-
-
+
@@ -96,37 +78,9 @@ NewEndorsementEmail.PreviewProps = {
endorsementText:
"Sinclair is someone you want to have around because she injects creativity and humor into every conversation, and her laugh is infectious! Not to mention that she's a great employee, treats everyone with respect, and is even-tempered.",
unsubscribeUrl: 'https://compassmeet.com/unsubscribe',
+ email: 'someone@gmail.com',
} as NewEndorsementEmailProps
-const main = {
- backgroundColor: '#f4f4f4',
- fontFamily: 'Arial, sans-serif',
- wordSpacing: 'normal',
-}
-
-const container = {
- margin: '0 auto',
- maxWidth: '600px',
-}
-
-const logoContainer = {
- padding: '20px 0px 5px 0px',
- textAlign: 'center' as const,
- backgroundColor: '#ffffff',
-}
-
-const content = {
- backgroundColor: '#ffffff',
- padding: '20px 25px',
-}
-
-const paragraph = {
- fontSize: '18px',
- lineHeight: '24px',
- margin: '10px 0',
- color: '#000000',
- fontFamily: 'Arial, Helvetica, sans-serif',
-}
const endorsementContainer = {
margin: '20px 0',
@@ -135,10 +89,6 @@ const endorsementContainer = {
borderRadius: '8px',
}
-const avatarImage = {
- borderRadius: '50%',
-}
-
const endorsementTextStyle = {
fontSize: '16px',
lineHeight: '22px',
@@ -146,35 +96,4 @@ const endorsementTextStyle = {
color: '#333333',
}
-const button = {
- backgroundColor: '#4887ec',
- borderRadius: '12px',
- color: '#ffffff',
- fontFamily: 'Helvetica, Arial, sans-serif',
- fontSize: '16px',
- fontWeight: 'semibold',
- textDecoration: 'none',
- textAlign: 'center' as const,
- display: 'inline-block',
- padding: '6px 10px',
- margin: '10px 0',
-}
-
-const footer = {
- margin: '20px 0',
- textAlign: 'center' as const,
-}
-
-const footerText = {
- fontSize: '11px',
- lineHeight: '22px',
- color: '#000000',
- fontFamily: 'Ubuntu, Helvetica, Arial, sans-serif',
-}
-
-const footerLink = {
- color: 'inherit',
- textDecoration: 'none',
-}
-
export default NewEndorsementEmail
diff --git a/backend/email/emails/new-match.tsx b/backend/email/emails/new-match.tsx
index 2af29b03..89e64ae6 100644
--- a/backend/email/emails/new-match.tsx
+++ b/backend/email/emails/new-match.tsx
@@ -1,51 +1,43 @@
-import {
- Body,
- Button,
- Container,
- Head,
- Html,
- Img,
- Link,
- Preview,
- Section,
- Text,
-} from '@react-email/components'
-import { DOMAIN } from 'common/envs/constants'
-import { type LoverRow } from 'common/love/lover'
-import { getLoveOgImageUrl } from 'common/love/og-image'
-import { type User } from 'common/user'
-import { jamesLover, jamesUser, sinclairUser } from './functions/mock'
+import {Body, Button, Container, Head, Html, Preview, Section, Text,} from '@react-email/components'
+import {DOMAIN} from 'common/envs/constants'
+import {type LoverRow} from 'common/love/lover'
+import {type User} from 'common/user'
+import {jamesLover, jamesUser, sinclairUser} from './functions/mock'
+import {Footer} from "email/utils";
interface NewMatchEmailProps {
onUser: User
matchedWithUser: User
matchedLover: LoverRow
unsubscribeUrl: string
+ email?: string
}
export const NewMatchEmail = ({
- onUser,
- matchedWithUser,
- matchedLover,
- unsubscribeUrl,
-}: NewMatchEmailProps) => {
+ onUser,
+ matchedWithUser,
+ matchedLover,
+ unsubscribeUrl,
+ email
+ }: NewMatchEmailProps) => {
const name = onUser.name.split(' ')[0]
- const userImgSrc = getLoveOgImageUrl(matchedWithUser, matchedLover)
+ // const userImgSrc = getLoveOgImageUrl(matchedWithUser, matchedLover)
const userUrl = `https://${DOMAIN}/${matchedWithUser.username}`
return (
-
+
{/**/}
- {/*
*/}
+ {/*
*/}
{/**/}
@@ -56,31 +48,21 @@ export const NewMatchEmail = ({
-
-
-
-
+ {/**/}
+ {/*
*/}
+ {/**/}
-
-
-
- This e-mail has been sent to {name},{' '}
- {/*
- click here to unsubscribe from this type of notification
-
- . */}
-
-
+
@@ -91,11 +73,12 @@ NewMatchEmail.PreviewProps = {
onUser: sinclairUser,
matchedWithUser: jamesUser,
matchedLover: jamesLover,
+ email: 'someone@gmail.com',
unsubscribeUrl: 'https://compassmeet.com/unsubscribe',
} as NewMatchEmailProps
const main = {
- backgroundColor: '#f4f4f4',
+ // backgroundColor: '#f4f4f4',
fontFamily: 'Arial, sans-serif',
wordSpacing: 'normal',
}
@@ -147,21 +130,4 @@ const button = {
margin: '10px 0',
}
-const footer = {
- margin: '20px 0',
- textAlign: 'center' as const,
-}
-
-const footerText = {
- fontSize: '11px',
- lineHeight: '22px',
- color: '#000000',
- fontFamily: 'Ubuntu, Helvetica, Arial, sans-serif',
-}
-
-const footerLink = {
- color: 'inherit',
- textDecoration: 'none',
-}
-
export default NewMatchEmail
diff --git a/backend/email/emails/new-message.tsx b/backend/email/emails/new-message.tsx
index 155b8bc9..a3dd00db 100644
--- a/backend/email/emails/new-message.tsx
+++ b/backend/email/emails/new-message.tsx
@@ -20,6 +20,7 @@ import {
} from './functions/mock'
import { DOMAIN } from 'common/envs/constants'
import { getLoveOgImageUrl } from 'common/love/og-image'
+import {button, container, content, Footer, imageContainer, main, paragraph, profileImage} from "email/utils";
interface NewMessageEmailProps {
fromUser: User
@@ -27,6 +28,7 @@ interface NewMessageEmailProps {
toUser: User
channelId: number
unsubscribeUrl: string
+ email?: string
}
export const NewMessageEmail = ({
@@ -35,6 +37,7 @@ export const NewMessageEmail = ({
toUser,
channelId,
unsubscribeUrl,
+ email,
}: NewMessageEmailProps) => {
const name = toUser.name.split(' ')[0]
const creatorName = fromUser.name
@@ -62,15 +65,15 @@ export const NewMessageEmail = ({
{creatorName} just messaged you!
-
-
-
+ {/**/}
+ {/*
*/}
+ {/**/}
-
-
- This e-mail has been sent to {name},{' '}
- {/*
- click here to unsubscribe from this type of notification
-
- . */}
-
-
+