mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-23 20:13:21 +03:00
Fix workspaceLogo in invite-email (#5865)
## Fixes wrong image url in email ![image](https://github.com/twentyhq/twenty/assets/29927851/5fb1524b-874d-4723-8450-0284382bbeb3) ## Done - duplicates and adapt `getImageAbsoluteURIOrBase64` from `twenty-front` in `twenty-email` - send `SERVER_URL` to email builder
This commit is contained in:
parent
a2e89af6b2
commit
28202cc9e0
@ -9,6 +9,7 @@ import { MainText } from 'src/components/MainText';
|
|||||||
import { Title } from 'src/components/Title';
|
import { Title } from 'src/components/Title';
|
||||||
import { WhatIsTwenty } from 'src/components/WhatIsTwenty';
|
import { WhatIsTwenty } from 'src/components/WhatIsTwenty';
|
||||||
import { capitalize } from 'src/utils/capitalize';
|
import { capitalize } from 'src/utils/capitalize';
|
||||||
|
import { getImageAbsoluteURIOrBase64 } from 'src/utils/getImageAbsoluteURIOrBase64';
|
||||||
|
|
||||||
type SendInviteLinkEmailProps = {
|
type SendInviteLinkEmailProps = {
|
||||||
link: string;
|
link: string;
|
||||||
@ -17,13 +18,16 @@ type SendInviteLinkEmailProps = {
|
|||||||
email: string;
|
email: string;
|
||||||
firstName: string;
|
firstName: string;
|
||||||
};
|
};
|
||||||
|
serverUrl?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SendInviteLinkEmail = ({
|
export const SendInviteLinkEmail = ({
|
||||||
link,
|
link,
|
||||||
workspace,
|
workspace,
|
||||||
sender,
|
sender,
|
||||||
|
serverUrl,
|
||||||
}: SendInviteLinkEmailProps) => {
|
}: SendInviteLinkEmailProps) => {
|
||||||
|
const workspaceLogo = getImageAbsoluteURIOrBase64(workspace.logo, serverUrl);
|
||||||
return (
|
return (
|
||||||
<BaseEmail width={333}>
|
<BaseEmail width={333}>
|
||||||
<Title value="Join your team on Twenty" />
|
<Title value="Join your team on Twenty" />
|
||||||
@ -34,7 +38,7 @@ export const SendInviteLinkEmail = ({
|
|||||||
<br />
|
<br />
|
||||||
</MainText>
|
</MainText>
|
||||||
<HighlightedContainer>
|
<HighlightedContainer>
|
||||||
{workspace.logo && <Img src={workspace.logo} width={40} height={40} />}
|
{workspaceLogo && <Img src={workspaceLogo} width={40} height={40} />}
|
||||||
{workspace.name && <HighlightedText value={workspace.name} />}
|
{workspace.name && <HighlightedText value={workspace.name} />}
|
||||||
<CallToAction href={link} value="Accept invite" />
|
<CallToAction href={link} value="Accept invite" />
|
||||||
</HighlightedContainer>
|
</HighlightedContainer>
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
export const getImageAbsoluteURIOrBase64 = (
|
||||||
|
imageUrl?: string | null,
|
||||||
|
serverUrl?: string,
|
||||||
|
) => {
|
||||||
|
if (!imageUrl) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (imageUrl?.startsWith('data:') || imageUrl?.startsWith('https:')) {
|
||||||
|
return imageUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return serverUrl?.endsWith('/')
|
||||||
|
? `${serverUrl.substring(0, serverUrl.length - 1)}/files/${imageUrl}`
|
||||||
|
: `${serverUrl || ''}/files/${imageUrl}`;
|
||||||
|
};
|
@ -119,6 +119,7 @@ export class WorkspaceService extends TypeOrmQueryService<Workspace> {
|
|||||||
link: inviteLink,
|
link: inviteLink,
|
||||||
workspace: { name: workspace.displayName, logo: workspace.logo },
|
workspace: { name: workspace.displayName, logo: workspace.logo },
|
||||||
sender: { email: sender.email, firstName: sender.firstName },
|
sender: { email: sender.email, firstName: sender.firstName },
|
||||||
|
serverUrl: this.environmentService.get('SERVER_URL'),
|
||||||
};
|
};
|
||||||
const emailTemplate = SendInviteLinkEmail(emailData);
|
const emailTemplate = SendInviteLinkEmail(emailData);
|
||||||
const html = render(emailTemplate, {
|
const html = render(emailTemplate, {
|
||||||
|
Loading…
Reference in New Issue
Block a user