From 7838e19e88e269026e24803f26cd52b467b4ef36 Mon Sep 17 00:00:00 2001 From: martmull Date: Wed, 10 Jan 2024 17:29:47 +0100 Subject: [PATCH] Revert "Revert "Revert "Remove test files""" This reverts commit f851333c24e9cfe3f425c9cbbd1e079efce5c3dd. --- .../commands/database-command.module.ts | 2 + .../emails/clean-inactive-workspace.email.tsx | 41 +++++++++++++++++++ .../src/workspace/toto.command.ts | 34 +++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 packages/twenty-server/src/emails/clean-inactive-workspace.email.tsx create mode 100644 packages/twenty-server/src/workspace/toto.command.ts diff --git a/packages/twenty-server/src/database/commands/database-command.module.ts b/packages/twenty-server/src/database/commands/database-command.module.ts index daa3e29867c..2ca336d30ea 100644 --- a/packages/twenty-server/src/database/commands/database-command.module.ts +++ b/packages/twenty-server/src/database/commands/database-command.module.ts @@ -10,6 +10,7 @@ import { DataSeedDemoWorkspaceCommand } from 'src/database/commands/data-seed-de import { WorkspaceDataSourceModule } from 'src/workspace/workspace-datasource/workspace-datasource.module'; import { WorkspaceSyncMetadataModule } from 'src/workspace/workspace-sync-metadata/workspace-sync-metadata.module'; import { ObjectMetadataModule } from 'src/metadata/object-metadata/object-metadata.module'; +import { TotoCommand } from 'src/workspace/toto.command'; @Module({ imports: [ @@ -25,6 +26,7 @@ import { ObjectMetadataModule } from 'src/metadata/object-metadata/object-metada DataSeedWorkspaceCommand, DataSeedDemoWorkspaceCommand, ConfirmationQuestion, + TotoCommand, ], }) export class DatabaseCommandModule {} diff --git a/packages/twenty-server/src/emails/clean-inactive-workspace.email.tsx b/packages/twenty-server/src/emails/clean-inactive-workspace.email.tsx new file mode 100644 index 00000000000..7837d38ec5d --- /dev/null +++ b/packages/twenty-server/src/emails/clean-inactive-workspace.email.tsx @@ -0,0 +1,41 @@ +import * as React from 'react'; + +import { HighlightedText } from 'src/emails/components/HighlightedText'; +import { MainText } from 'src/emails/components/MainText'; +import { Title } from 'src/emails/components/Title'; +import { BaseEmail } from 'src/emails/components/BaseEmail'; +import { CallToAction } from 'src/emails/components/CallToAction'; + +export const CleanInactiveWorkspaceEmail = ({ + title, + daysLeft, + userName, + workspaceDisplayName, +}) => { + const daysLeftInfo = daysLeft > 1 ? `${daysLeft} days left` : `One day left`; + + return ( + + + <HighlightedText value={daysLeftInfo} /> + <MainText> + Hello {userName}, + <br /> + <br /> + It appears that there has been a period of inactivity on your{' '} + <b>{workspaceDisplayName}</b> workspace. + <br /> + <br /> + Please note that the account is due for deactivation soon, and all + associated data within this workspace will be deleted. + <br /> + <br /> + No need for concern, though! Simply log in to your workspace within the + next 10 days to retain access. + </MainText> + <CallToAction href="https://app.twenty.com" value="Connect to Twenty" /> + </BaseEmail> + ); +}; + +export default CleanInactiveWorkspaceEmail; diff --git a/packages/twenty-server/src/workspace/toto.command.ts b/packages/twenty-server/src/workspace/toto.command.ts new file mode 100644 index 00000000000..ab3f629b270 --- /dev/null +++ b/packages/twenty-server/src/workspace/toto.command.ts @@ -0,0 +1,34 @@ +import { Command, CommandRunner } from 'nest-commander'; +import { render } from '@react-email/render'; + +import CleanInactiveWorkspaceEmail from 'src/emails/clean-inactive-workspace.email'; +import { EmailService } from 'src/integrations/email/email.service'; + +@Command({ + name: 'test-send-email', +}) +export class TotoCommand extends CommandRunner { + constructor(private readonly emailService: EmailService) { + super(); + } + + async run(): Promise<void> { + const emailData = { + title: 'Inactive Workspace 😴', + daysLeft: 10, + userName: 'Martin Müller', + workspaceDisplayName: 'Stripe', + }; + const html = render(CleanInactiveWorkspaceEmail(emailData), { + pretty: true, + }); + const text = render(CleanInactiveWorkspaceEmail(emailData), { + plainText: true, + }); + + console.log(html); + + await this.emailService.send({ to: 'martmull@hotmail.fr', html, text }); + //await this.emailService.send({ to: 'martmull@hotmail.fr', html, text }); + } +}