@vrplatform/email 1.0.2-434 → 1.0.2-43698123618

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/build/main/components/ActionEmailTemplate.d.ts +3 -1
  2. package/build/main/components/ActionEmailTemplate.js +9 -13
  3. package/build/main/components/ActionEmailTemplate.js.map +1 -1
  4. package/build/main/components/Button.js.map +1 -1
  5. package/build/main/components/EmailContainer.d.ts +4 -1
  6. package/build/main/components/EmailContainer.js +4 -3
  7. package/build/main/components/EmailContainer.js.map +1 -1
  8. package/build/main/components/EmailHeading.d.ts +8 -0
  9. package/build/main/components/EmailHeading.js +21 -0
  10. package/build/main/components/EmailHeading.js.map +1 -0
  11. package/build/main/components/index.d.ts +1 -0
  12. package/build/main/components/index.js +1 -0
  13. package/build/main/components/index.js.map +1 -1
  14. package/build/main/components/utils/parse-email-html.js +13 -4
  15. package/build/main/components/utils/parse-email-html.js.map +1 -1
  16. package/build/main/const.d.ts +4 -4
  17. package/build/main/index.d.ts +1 -1
  18. package/build/main/index.js +2 -3
  19. package/build/main/index.js.map +1 -1
  20. package/build/main/render.d.ts +2 -0
  21. package/build/main/render.js +24 -0
  22. package/build/main/render.js.map +1 -0
  23. package/build/main/templates/BankAccountChangedEmailTemplate.d.ts +12 -0
  24. package/build/main/templates/BankAccountChangedEmailTemplate.js +12 -0
  25. package/build/main/templates/BankAccountChangedEmailTemplate.js.map +1 -0
  26. package/build/main/templates/BankAccountChangedTeamAdminEmailTemplate.d.ts +17 -0
  27. package/build/main/templates/BankAccountChangedTeamAdminEmailTemplate.js +12 -0
  28. package/build/main/templates/BankAccountChangedTeamAdminEmailTemplate.js.map +1 -0
  29. package/build/main/templates/BankDetailsRequestEmailTemplate.d.ts +17 -0
  30. package/build/main/templates/BankDetailsRequestEmailTemplate.js +15 -0
  31. package/build/main/templates/BankDetailsRequestEmailTemplate.js.map +1 -0
  32. package/build/main/templates/InviteOwnerEmailTemplate.d.ts +2 -2
  33. package/build/main/templates/InviteOwnerEmailTemplate.js +1 -1
  34. package/build/main/templates/InviteOwnerEmailTemplate.js.map +1 -1
  35. package/build/main/templates/InvitePmEmailTemplate.d.ts +2 -1
  36. package/build/main/templates/InvitePmEmailTemplate.js +4 -7
  37. package/build/main/templates/InvitePmEmailTemplate.js.map +1 -1
  38. package/build/main/templates/OwnerStatementEmailTemplate.d.ts +6 -3
  39. package/build/main/templates/OwnerStatementEmailTemplate.js +70 -9
  40. package/build/main/templates/OwnerStatementEmailTemplate.js.map +1 -1
  41. package/build/main/templates/TeamRoleGrantedEmailTemplate.d.ts +12 -0
  42. package/build/main/templates/TeamRoleGrantedEmailTemplate.js +12 -0
  43. package/build/main/templates/TeamRoleGrantedEmailTemplate.js.map +1 -0
  44. package/build/main/templates/TenantDeletionEmailTemplate.js +2 -6
  45. package/build/main/templates/TenantDeletionEmailTemplate.js.map +1 -1
  46. package/build/main/templates/TenantSuspensionEmailTemplate.js +2 -6
  47. package/build/main/templates/TenantSuspensionEmailTemplate.js.map +1 -1
  48. package/build/main/templates/index.d.ts +4 -0
  49. package/build/main/templates/index.js +5 -0
  50. package/build/main/templates/index.js.map +1 -1
  51. package/build/main/theme.js.map +1 -1
  52. package/build/main/types.d.ts +3 -0
  53. package/build/main/types.js.map +1 -1
  54. package/build/main/utils/find-postmark-email.d.ts +8 -0
  55. package/build/main/utils/find-postmark-email.js +88 -0
  56. package/build/main/utils/find-postmark-email.js.map +1 -0
  57. package/build/main/utils/index.d.ts +1 -0
  58. package/build/main/utils/index.js +1 -0
  59. package/build/main/utils/index.js.map +1 -1
  60. package/build/main/utils/send-email.d.ts +28 -3
  61. package/build/main/utils/send-email.js +142 -22
  62. package/build/main/utils/send-email.js.map +1 -1
  63. package/build/module/components/ActionEmailTemplate.d.ts +3 -1
  64. package/build/module/components/ActionEmailTemplate.js +9 -13
  65. package/build/module/components/ActionEmailTemplate.js.map +1 -1
  66. package/build/module/components/EmailContainer.d.ts +4 -1
  67. package/build/module/components/EmailContainer.js +5 -4
  68. package/build/module/components/EmailContainer.js.map +1 -1
  69. package/build/module/components/EmailHeading.d.ts +8 -0
  70. package/build/module/components/EmailHeading.js +17 -0
  71. package/build/module/components/EmailHeading.js.map +1 -0
  72. package/build/module/components/index.d.ts +1 -0
  73. package/build/module/components/index.js +1 -0
  74. package/build/module/components/index.js.map +1 -1
  75. package/build/module/components/utils/parse-email-html.js +13 -4
  76. package/build/module/components/utils/parse-email-html.js.map +1 -1
  77. package/build/module/const.d.ts +4 -4
  78. package/build/module/index.d.ts +1 -1
  79. package/build/module/index.js +1 -1
  80. package/build/module/index.js.map +1 -1
  81. package/build/module/render.d.ts +2 -0
  82. package/build/module/render.js +20 -0
  83. package/build/module/render.js.map +1 -0
  84. package/build/module/templates/BankAccountChangedEmailTemplate.d.ts +12 -0
  85. package/build/module/templates/BankAccountChangedEmailTemplate.js +8 -0
  86. package/build/module/templates/BankAccountChangedEmailTemplate.js.map +1 -0
  87. package/build/module/templates/BankAccountChangedTeamAdminEmailTemplate.d.ts +17 -0
  88. package/build/module/templates/BankAccountChangedTeamAdminEmailTemplate.js +8 -0
  89. package/build/module/templates/BankAccountChangedTeamAdminEmailTemplate.js.map +1 -0
  90. package/build/module/templates/BankDetailsRequestEmailTemplate.d.ts +17 -0
  91. package/build/module/templates/BankDetailsRequestEmailTemplate.js +11 -0
  92. package/build/module/templates/BankDetailsRequestEmailTemplate.js.map +1 -0
  93. package/build/module/templates/InviteOwnerEmailTemplate.d.ts +2 -2
  94. package/build/module/templates/InviteOwnerEmailTemplate.js +1 -1
  95. package/build/module/templates/InviteOwnerEmailTemplate.js.map +1 -1
  96. package/build/module/templates/InvitePmEmailTemplate.d.ts +2 -1
  97. package/build/module/templates/InvitePmEmailTemplate.js +4 -7
  98. package/build/module/templates/InvitePmEmailTemplate.js.map +1 -1
  99. package/build/module/templates/OwnerStatementEmailTemplate.d.ts +6 -3
  100. package/build/module/templates/OwnerStatementEmailTemplate.js +71 -10
  101. package/build/module/templates/OwnerStatementEmailTemplate.js.map +1 -1
  102. package/build/module/templates/TeamRoleGrantedEmailTemplate.d.ts +12 -0
  103. package/build/module/templates/TeamRoleGrantedEmailTemplate.js +8 -0
  104. package/build/module/templates/TeamRoleGrantedEmailTemplate.js.map +1 -0
  105. package/build/module/templates/TenantDeletionEmailTemplate.js +3 -7
  106. package/build/module/templates/TenantDeletionEmailTemplate.js.map +1 -1
  107. package/build/module/templates/TenantSuspensionEmailTemplate.js +3 -7
  108. package/build/module/templates/TenantSuspensionEmailTemplate.js.map +1 -1
  109. package/build/module/templates/index.d.ts +4 -0
  110. package/build/module/templates/index.js +5 -0
  111. package/build/module/templates/index.js.map +1 -1
  112. package/build/module/types.d.ts +3 -0
  113. package/build/module/types.js.map +1 -1
  114. package/build/module/utils/find-postmark-email.d.ts +8 -0
  115. package/build/module/utils/find-postmark-email.js +52 -0
  116. package/build/module/utils/find-postmark-email.js.map +1 -0
  117. package/build/module/utils/index.d.ts +1 -0
  118. package/build/module/utils/index.js +1 -0
  119. package/build/module/utils/index.js.map +1 -1
  120. package/build/module/utils/send-email.d.ts +28 -3
  121. package/build/module/utils/send-email.js +108 -22
  122. package/build/module/utils/send-email.js.map +1 -1
  123. package/package.json +8 -7
  124. package/src/components/ActionEmailTemplate.tsx +14 -16
  125. package/src/components/EmailContainer.tsx +20 -4
  126. package/src/components/EmailHeading.tsx +36 -0
  127. package/src/components/index.ts +1 -0
  128. package/src/components/utils/parse-email-html.ts +20 -6
  129. package/src/index.ts +1 -1
  130. package/src/render.ts +24 -0
  131. package/src/templates/BankAccountChangedEmailTemplate.tsx +53 -0
  132. package/src/templates/BankAccountChangedTeamAdminEmailTemplate.tsx +55 -0
  133. package/src/templates/BankDetailsRequestEmailTemplate.tsx +63 -0
  134. package/src/templates/InviteOwnerEmailTemplate.tsx +1 -0
  135. package/src/templates/InvitePmEmailTemplate.tsx +5 -7
  136. package/src/templates/OwnerStatementEmailTemplate.tsx +178 -14
  137. package/src/templates/TeamRoleGrantedEmailTemplate.tsx +54 -0
  138. package/src/templates/TenantDeletionEmailTemplate.tsx +9 -10
  139. package/src/templates/TenantSuspensionEmailTemplate.tsx +9 -10
  140. package/src/templates/index.ts +6 -0
  141. package/src/types.ts +3 -0
  142. package/src/utils/find-postmark-email.ts +80 -0
  143. package/src/utils/index.ts +1 -0
  144. package/src/utils/send-email.ts +184 -28
@@ -0,0 +1,55 @@
1
+ import { Heading } from '@react-email/heading';
2
+ import { Text } from '@react-email/text';
3
+ import { Button } from '../components/Button';
4
+ import { EmailContainer } from '../components/EmailContainer';
5
+ import { THEME_COLORS } from '../theme';
6
+ import type { EmailBaseProps } from '../types';
7
+
8
+ export type BankAccountChangedTeamAdminEmailTemplateProps = {
9
+ mode: EmailBaseProps['mode'];
10
+ tenant: EmailBaseProps['tenant'];
11
+ contact: { name: string; type: 'owner' | 'vendor' };
12
+ // Added: the contact had no bank account before.
13
+ bankAccount: {
14
+ last4: string;
15
+ changedOn: string;
16
+ changedBy: string | null;
17
+ added: boolean;
18
+ };
19
+ href: string;
20
+ };
21
+
22
+ export const BankAccountChangedTeamAdminEmailTemplate = ({
23
+ mode,
24
+ tenant,
25
+ contact,
26
+ bankAccount,
27
+ href,
28
+ }: BankAccountChangedTeamAdminEmailTemplateProps) => (
29
+ <EmailContainer
30
+ title={`Bank details ${bankAccount.added ? 'added' : 'changed'} for ${contact.name}`}
31
+ shortDescription={`Future payments to ${contact.name} go to the account ending in ${bankAccount.last4}.`}
32
+ tenant={tenant}
33
+ mode={mode}
34
+ >
35
+ <Heading style={{ fontSize: 28, fontWeight: 600, marginBottom: '50px' }}>
36
+ Bank details {bankAccount.added ? 'added' : 'changed'}
37
+ </Heading>
38
+ <Text>
39
+ The bank account of {contact.type} <b>{contact.name}</b> was{' '}
40
+ {bankAccount.added ? 'added' : 'changed'} on {bankAccount.changedOn}
41
+ {bankAccount.changedBy ? ` by ${bankAccount.changedBy}` : ''}. Future
42
+ payments go to the account ending in <b>{bankAccount.last4}</b>.
43
+ </Text>
44
+ <Text>
45
+ If you did not expect this change, confirm it with {contact.name} by phone
46
+ before the next payment.
47
+ </Text>
48
+ <Button
49
+ href={href}
50
+ mode={mode}
51
+ label="Review payment setup"
52
+ themeColors={THEME_COLORS.vrplatform!}
53
+ />
54
+ </EmailContainer>
55
+ );
@@ -0,0 +1,63 @@
1
+ import { Heading } from '@react-email/heading';
2
+ import { Text } from '@react-email/text';
3
+ import { Button } from '../components/Button';
4
+ import { EmailContainer } from '../components/EmailContainer';
5
+ import type { EmailBaseProps } from '../types';
6
+
7
+ export type BankDetailsRequestEmailTemplateProps = {
8
+ mode: EmailBaseProps['mode'];
9
+ user: EmailBaseProps['user'];
10
+ tenant: EmailBaseProps['tenant'];
11
+ // The owner or vendor asked, so requests to different payees do not thread
12
+ // together.
13
+ payeeName: string;
14
+ themeColors: EmailBaseProps['themeColors'];
15
+ href: string;
16
+ // Owners enter their details in the owner portal; vendors in a one-time
17
+ // form that expires.
18
+ form:
19
+ | { type: 'ownerPortal'; setsUpLogin: boolean }
20
+ | { type: 'oneTime'; expiresOn: string };
21
+ };
22
+
23
+ export const BankDetailsRequestEmailTemplate = ({
24
+ mode,
25
+ user,
26
+ tenant,
27
+ payeeName,
28
+ themeColors,
29
+ href,
30
+ form,
31
+ }: BankDetailsRequestEmailTemplateProps) => (
32
+ <EmailContainer
33
+ title={`${tenant.name} needs payout details for ${payeeName}`}
34
+ shortDescription={`Add the bank account ${tenant.name} pays you to.`}
35
+ tenant={tenant}
36
+ mode={mode}
37
+ >
38
+ <Heading style={{ fontSize: 28, fontWeight: 600, marginBottom: '50px' }}>
39
+ {user.firstName ? `Hi ${user.firstName},` : 'Hi there,'}
40
+ </Heading>
41
+ <Text>
42
+ <b>{tenant.name}</b> needs the bank account to send your payments to. Use
43
+ the button below to add it. Never send bank details by email.
44
+ </Text>
45
+ <Text>
46
+ {form.type === 'oneTime'
47
+ ? `The link works once and expires on ${form.expiresOn}.`
48
+ : form.setsUpLogin
49
+ ? 'You will set up your owner portal login first, then add your bank details.'
50
+ : 'Sign in to your owner portal to add your bank details.'}
51
+ </Text>
52
+ <Button
53
+ href={href}
54
+ mode={mode}
55
+ label="Add bank details"
56
+ themeColors={themeColors}
57
+ />
58
+ <Text>
59
+ If you did not expect this request, contact {tenant.name} before you enter
60
+ any details.
61
+ </Text>
62
+ </EmailContainer>
63
+ );
@@ -35,6 +35,7 @@ export const InviteOwnerEmailTemplate = ({
35
35
  return (
36
36
  <ActionEmailTemplate
37
37
  {...props}
38
+ eyebrow="Owner Portal invitation"
38
39
  data={{
39
40
  ...props.data,
40
41
  // Add guidance at render time so saved custom templates receive it too.
@@ -10,6 +10,7 @@ export const getDefaultInvitePropertyManagerEmailData = (
10
10
  args: {
11
11
  appName: string;
12
12
  signInLink: string;
13
+ teamName: string;
13
14
  }
14
15
  ): ActionEmailData => {
15
16
  const signInLink =
@@ -18,13 +19,13 @@ export const getDefaultInvitePropertyManagerEmailData = (
18
19
  : `<a href='${args.signInLink}' target='_blank'>${args.signInLink}</a>`;
19
20
 
20
21
  return {
21
- bodyOne: `<p>You are invited to join us on ${args.appName}.</p><p>Accept the invitation below to set up your team access.</p>`,
22
+ bodyOne: `<p>You are invited to join ${args.teamName} on ${args.appName}.</p><p>Accept the invitation below to set up your team access.</p>`,
22
23
  bodyTwo: `<p>If you have any trouble with the button, you can use the following link below: ${signInLink}</p>`,
23
24
  buttonText: 'Accept Invitation',
24
25
  header: 'Welcome to the team!',
25
- shortDescription: `Accept your invitation to join your team on ${args.appName}.`,
26
+ shortDescription: `Accept your invitation to join ${args.teamName} on ${args.appName}.`,
26
27
  href: args.signInLink,
27
- subject: `You are invited to join your team on ${args.appName}`,
28
+ subject: `You are invited to join ${args.teamName} on ${args.appName}`,
28
29
  };
29
30
  };
30
31
 
@@ -32,15 +33,12 @@ export const InvitePmEmailTemplate = (props: ActionEmailTemplateProps) => {
32
33
  return (
33
34
  <ActionEmailTemplate
34
35
  {...props}
36
+ eyebrow="Team invitation"
35
37
  data={{
36
38
  ...props.data,
37
39
  // Add guidance at render time so saved custom templates receive it too.
38
40
  bodyTwo: `${props.data.bodyTwo}<hr style="width:100%;border:none;border-top:1px solid #eaeaea;margin:24px 0" /><p>This invitation link is for one-time setup of your team access and expires after 7 days. Sign up using the exact email address this invitation was sent to.</p><p>If your invitation expires before setup is complete, contact your team administrator for a new invitation.</p><p>For questions about team access, contact your team administrator.</p>`,
39
41
  }}
40
- tenant={{
41
- logo: undefined,
42
- name: props.tenant.name,
43
- }}
44
42
  />
45
43
  );
46
44
  };
@@ -1,14 +1,18 @@
1
+ import { Text } from '@react-email/text';
1
2
  import {
2
3
  EMAIL_ACTION_LINK_COMPONENT,
3
4
  EMAIL_DATE_COMPONENT,
4
5
  EMAIL_LISTING_COMPONENT,
5
6
  EMAIL_USER_NAME_COMPONENT,
6
7
  } from '../extensions';
7
- import {
8
- type ActionEmailData,
9
- ActionEmailTemplate,
10
- type ActionEmailTemplateProps,
8
+ import type {
9
+ ActionEmailData,
10
+ ActionEmailTemplateProps,
11
11
  } from '../components/ActionEmailTemplate';
12
+ import { Button } from '../components/Button';
13
+ import { EmailContainer } from '../components/EmailContainer';
14
+ import { EmailHeading } from '../components/EmailHeading';
15
+ import { parseEmailHtml } from '../components/utils';
12
16
 
13
17
  export const getDefaultOwnerStatementEmailData = (
14
18
  mode: 'tag' | 'text',
@@ -28,19 +32,179 @@ export const getDefaultOwnerStatementEmailData = (
28
32
  const month = mode === 'tag' ? EMAIL_DATE_COMPONENT : args.month;
29
33
  const userName = mode === 'tag' ? EMAIL_USER_NAME_COMPONENT : args.userName;
30
34
 
35
+ // Owners open the statement by link without a login and viewers log in to
36
+ // the owner portal, so the text names neither. Subject and preview text are
37
+ // plain text without tokens, so a saved template must not keep the editor's
38
+ // sample month and listing.
31
39
  return {
32
- subject: 'Owner statement was published',
33
- shortDescription: `An owner statement is ready for you. Log in to ${args.appName} now to view it.`,
34
- header: 'Owner statement was published',
35
- bodyOne: `<p>Hi ${userName},<p>Your ${month} owner statement for property ${listingName} is ready for your review on ${args.appName}.</p><p>To access your statement, please click the button below:</p>`,
36
- buttonText: 'View Owner statement',
37
- bodyTwo: `<p>If you have any trouble with the button, you can copy and paste the link below into your browser: ${ownerStatementHref}</p>`,
40
+ subject:
41
+ mode === 'tag'
42
+ ? 'Your owner statement is ready'
43
+ : `Your ${args.month} owner statement for ${args.listingName}`,
44
+ shortDescription:
45
+ mode === 'tag'
46
+ ? 'Your owner statement is ready to view.'
47
+ : `Your ${args.month} statement for ${args.listingName} is ready to view.`,
48
+ header: 'Your owner statement is ready',
49
+ bodyOne: `<p>Hi ${userName},</p><p>${args.appName} published your ${month} owner statement for ${listingName}. Open it with the button below.</p>`,
50
+ buttonText: 'View statement',
51
+ bodyTwo: `<p style="color:#737373;font-size:13px">If the button doesn't work, copy this link into your browser: ${ownerStatementHref}</p>`,
38
52
  href: args.ownerStatementHref,
39
53
  };
40
54
  };
41
55
 
42
- export const OwnerStatementEmailTemplate = (
43
- props: ActionEmailTemplateProps
44
- ) => {
45
- return <ActionEmailTemplate {...props} />;
56
+ const mutedColor = '#737373';
57
+ const borderColor = '#e5e7eb';
58
+
59
+ export const OwnerStatementEmailTemplate = ({
60
+ data,
61
+ tenant,
62
+ themeColors,
63
+ mode,
64
+ user,
65
+ listing,
66
+ month,
67
+ unsubscribeHref,
68
+ renewHref,
69
+ }: ActionEmailTemplateProps & {
70
+ /** Requests a new no-login link once the emailed one has expired. */
71
+ renewHref?: string;
72
+ }) => {
73
+ const parse = (html: string) =>
74
+ parseEmailHtml(html, {
75
+ href: data.href,
76
+ userName: user.firstName || '',
77
+ date: month || '',
78
+ listingName: listing || '',
79
+ });
80
+
81
+ return (
82
+ <EmailContainer
83
+ title={data.subject}
84
+ shortDescription={data.shortDescription}
85
+ tenant={tenant}
86
+ mode={mode}
87
+ unsubscribeHref={unsubscribeHref}
88
+ >
89
+ <EmailHeading eyebrow="Owner statement" themeColors={themeColors}>
90
+ {data.header?.trim() || 'Your owner statement is ready'}
91
+ </EmailHeading>
92
+
93
+ {data.banner?.trim() && (
94
+ <Text
95
+ style={{
96
+ padding: '16px 20px',
97
+ backgroundColor: '#f8f9fa',
98
+ borderLeft: `3px solid ${themeColors[8]}`,
99
+ borderRadius: '4px',
100
+ margin: '0 0 32px',
101
+ whiteSpace: 'pre-line',
102
+ }}
103
+ >
104
+ {data.banner.trim()}
105
+ </Text>
106
+ )}
107
+
108
+ <div
109
+ // biome-ignore lint/security/noDangerouslySetInnerHtml: values are escaped by parseEmailHtml
110
+ dangerouslySetInnerHTML={{ __html: parse(data.bodyOne) }}
111
+ />
112
+
113
+ {(listing || month) && (
114
+ <table
115
+ role="presentation"
116
+ cellPadding={0}
117
+ cellSpacing={0}
118
+ width="100%"
119
+ style={{
120
+ border: `1px solid ${borderColor}`,
121
+ borderRadius: '8px',
122
+ borderCollapse: 'separate',
123
+ margin: '24px 0 0',
124
+ }}
125
+ >
126
+ <tbody>
127
+ {[
128
+ ['Property', listing],
129
+ ['Statement', month],
130
+ ].map(([label, value], index) =>
131
+ value ? (
132
+ <tr key={label}>
133
+ <td
134
+ style={{
135
+ padding: '14px 20px',
136
+ color: mutedColor,
137
+ fontSize: 14,
138
+ borderTop: index ? `1px solid ${borderColor}` : 'none',
139
+ }}
140
+ >
141
+ {label}
142
+ </td>
143
+ <td
144
+ style={{
145
+ padding: '14px 20px',
146
+ fontSize: 14,
147
+ fontWeight: 600,
148
+ textAlign: 'right',
149
+ borderTop: index ? `1px solid ${borderColor}` : 'none',
150
+ }}
151
+ >
152
+ {value}
153
+ </td>
154
+ </tr>
155
+ ) : null
156
+ )}
157
+ </tbody>
158
+ </table>
159
+ )}
160
+
161
+ <Button
162
+ href={data.href}
163
+ mode={mode}
164
+ data-testid="view-owner-statement-button"
165
+ label={data.buttonText?.trim() || 'View statement'}
166
+ themeColors={themeColors}
167
+ style={{ marginTop: '24px', marginBottom: '32px' }}
168
+ />
169
+
170
+ {renewHref && (
171
+ <div
172
+ style={{
173
+ padding: '20px',
174
+ backgroundColor: '#f8f9fa',
175
+ borderRadius: '8px',
176
+ marginBottom: '32px',
177
+ }}
178
+ >
179
+ <Text style={{ fontWeight: 600, margin: '0 0 4px' }}>
180
+ Link expired?
181
+ </Text>
182
+ <Text style={{ color: mutedColor, fontSize: 14, margin: 0 }}>
183
+ For your security, this link opens only this statement and works for
184
+ 7 days. After that, request a new one and we'll email it to this
185
+ address.
186
+ </Text>
187
+ <Button
188
+ href={renewHref}
189
+ mode={mode}
190
+ data-testid="renew-owner-statement-link-button"
191
+ label="Send me a new link"
192
+ themeColors={themeColors}
193
+ style={{
194
+ background: '#ffffff',
195
+ border: `1px solid ${themeColors[8]}`,
196
+ color: themeColors[8],
197
+ marginTop: '16px',
198
+ marginBottom: 0,
199
+ }}
200
+ />
201
+ </div>
202
+ )}
203
+
204
+ <div
205
+ // biome-ignore lint/security/noDangerouslySetInnerHtml: values are escaped by parseEmailHtml
206
+ dangerouslySetInnerHTML={{ __html: parse(data.bodyTwo) }}
207
+ />
208
+ </EmailContainer>
209
+ );
46
210
  };
@@ -0,0 +1,54 @@
1
+ import { Heading } from '@react-email/heading';
2
+ import { Text } from '@react-email/text';
3
+ import { Button } from '../components/Button';
4
+ import { EmailContainer } from '../components/EmailContainer';
5
+ import { THEME_COLORS } from '../theme';
6
+ import type { EmailBaseProps } from '../types';
7
+
8
+ export type TeamRoleGrantedEmailTemplateProps = {
9
+ mode: EmailBaseProps['mode'];
10
+ tenant: EmailBaseProps['tenant'];
11
+ member: string;
12
+ roles: string;
13
+ grantedAt: string;
14
+ grantedBy: string | null;
15
+ partnerName: string | null;
16
+ href: string;
17
+ };
18
+
19
+ export const TeamRoleGrantedEmailTemplate = ({
20
+ mode,
21
+ tenant,
22
+ member,
23
+ roles,
24
+ grantedAt,
25
+ grantedBy,
26
+ partnerName,
27
+ href,
28
+ }: TeamRoleGrantedEmailTemplateProps) => (
29
+ <EmailContainer
30
+ title={`${member} received ${roles}`}
31
+ shortDescription={`${member} received ${roles} on ${tenant.name}.`}
32
+ tenant={tenant}
33
+ mode={mode}
34
+ >
35
+ <Heading style={{ fontSize: 28, fontWeight: 600, marginBottom: '50px' }}>
36
+ New {roles} on your team
37
+ </Heading>
38
+ <Text>
39
+ <b>{member}</b> received <b>{roles}</b> on {tenant.name} on {grantedAt}
40
+ {grantedBy ? ` from ${grantedBy}` : ''}
41
+ {partnerName ? `, acting through your partner ${partnerName}` : ''}.
42
+ </Text>
43
+ <Text>
44
+ If you did not expect this change, review the team members and remove the
45
+ role.
46
+ </Text>
47
+ <Button
48
+ href={href}
49
+ mode={mode}
50
+ label="Review team members"
51
+ themeColors={THEME_COLORS.vrplatform!}
52
+ />
53
+ </EmailContainer>
54
+ );
@@ -1,6 +1,6 @@
1
- import { Heading } from '@react-email/heading';
2
1
  import { Text } from '@react-email/text';
3
- import { EmailContainer } from '../components';
2
+ import { EmailContainer, EmailHeading } from '../components';
3
+ import { THEME_COLORS } from '../theme';
4
4
  import type { EmailBaseProps } from '../types';
5
5
 
6
6
  export type TenantDeletionEmailTemplateProps = {
@@ -25,15 +25,14 @@ export const TenantDeletionEmailTemplate = ({
25
25
  }}
26
26
  mode={mode}
27
27
  >
28
- <Heading
29
- style={{
30
- fontSize: 28,
31
- fontWeight: 600,
32
- marginBottom: '50px',
33
- }}
28
+ <EmailHeading
29
+ eyebrow="Team deleted"
30
+ themeColors={THEME_COLORS.vrplatform}
34
31
  >
35
- {user.firstName ? `Dear ${user.firstName},` : 'Hi there,'}
36
- </Heading>
32
+ Your team was deleted
33
+ </EmailHeading>
34
+
35
+ <Text>{user.firstName ? `Dear ${user.firstName},` : 'Hi there,'}</Text>
37
36
 
38
37
  <Text>
39
38
  We wanted to inform you that the team account "{tenant.name}" has been
@@ -1,6 +1,6 @@
1
- import { Heading } from '@react-email/heading';
2
1
  import { Text } from '@react-email/text';
3
- import { EmailContainer } from '../components';
2
+ import { EmailContainer, EmailHeading } from '../components';
3
+ import { THEME_COLORS } from '../theme';
4
4
  import type { EmailBaseProps } from '../types';
5
5
 
6
6
  export type TenantSuspensionEmailTemplateProps = {
@@ -25,15 +25,14 @@ export const TenantSuspensionEmailTemplate = ({
25
25
  }}
26
26
  mode={mode}
27
27
  >
28
- <Heading
29
- style={{
30
- fontSize: 28,
31
- fontWeight: 600,
32
- marginBottom: '50px',
33
- }}
28
+ <EmailHeading
29
+ eyebrow="Team suspended"
30
+ themeColors={THEME_COLORS.vrplatform}
34
31
  >
35
- {user.firstName ? `Dear ${user.firstName},` : 'Hi there,'}
36
- </Heading>
32
+ Your team access is suspended
33
+ </EmailHeading>
34
+
35
+ <Text>{user.firstName ? `Dear ${user.firstName},` : 'Hi there,'}</Text>
37
36
 
38
37
  <Text>
39
38
  We're reaching out to inform you that as of today, access to your team{' '}
@@ -1,10 +1,16 @@
1
1
  // Teams
2
+ export * from './TeamRoleGrantedEmailTemplate';
2
3
  export * from './TenantSuspensionEmailTemplate';
3
4
  export * from './TenantDeletionEmailTemplate';
4
5
 
5
6
  // Owner Statements
6
7
  export * from './OwnerStatementEmailTemplate';
7
8
 
9
+ // Payment setup
10
+ export * from './BankAccountChangedEmailTemplate';
11
+ export * from './BankAccountChangedTeamAdminEmailTemplate';
12
+ export * from './BankDetailsRequestEmailTemplate';
13
+
8
14
  // Invitations
9
15
  export * from './InviteOwnerEmailTemplate';
10
16
  export * from './InvitePmEmailTemplate';
package/src/types.ts CHANGED
@@ -2,10 +2,13 @@ export type EmailBaseProps = {
2
2
  mode: 'edit' | 'preview' | 'send';
3
3
  tenant: {
4
4
  name: string;
5
+ showPlatformBranding?: boolean;
5
6
  logo: string | undefined | null;
6
7
  };
7
8
  listing: string | undefined;
8
9
  month: string | undefined;
10
+ /** Opt-out link shown below the email body */
11
+ unsubscribeHref?: string;
9
12
  user: {
10
13
  firstName: string | undefined;
11
14
  };
@@ -0,0 +1,80 @@
1
+ import { day } from '@vrplatform/utils';
2
+ import * as z from 'zod';
3
+ import { EmailDeliveryError } from './send-email';
4
+
5
+ const postmarkMessagesResponseSchema = z.object({
6
+ TotalCount: z.number().int().nonnegative(),
7
+ Messages: z.array(
8
+ z.object({
9
+ MessageID: z.string().min(1),
10
+ ReceivedAt: z.string().refine((value) => day(value).isValid()),
11
+ Metadata: z.object({ deliveryId: z.string() }).passthrough(),
12
+ })
13
+ ),
14
+ });
15
+
16
+ export async function findPostmarkEmail(
17
+ deliveryId: string,
18
+ options: {
19
+ fetch?: (
20
+ input: string | URL | Request,
21
+ init?: RequestInit
22
+ ) => Promise<Response>;
23
+ postmarkToken?: string;
24
+ }
25
+ ) {
26
+ if (!options.postmarkToken) {
27
+ throw new EmailDeliveryError(
28
+ 'Postmark is not configured',
29
+ undefined,
30
+ false,
31
+ false
32
+ );
33
+ }
34
+
35
+ const url = new URL('https://api.postmarkapp.com/messages/outbound');
36
+ url.searchParams.set('count', '1');
37
+ url.searchParams.set('offset', '0');
38
+ url.searchParams.set('messagestream', 'outbound');
39
+ url.searchParams.set('metadata_deliveryId', deliveryId);
40
+ const response = await (options.fetch ?? fetch)(url, {
41
+ method: 'GET',
42
+ headers: {
43
+ Accept: 'application/json',
44
+ 'X-Postmark-Server-Token': options.postmarkToken,
45
+ },
46
+ });
47
+ const providerResponse: unknown = await response.json().catch(() => ({}));
48
+
49
+ if (!response.ok) {
50
+ throw new EmailDeliveryError(
51
+ 'Postmark message lookup failed',
52
+ {
53
+ provider: 'postmark',
54
+ providerCategory: 'rejected',
55
+ httpStatus: response.status,
56
+ },
57
+ false,
58
+ response.status === 429 || response.status >= 500
59
+ );
60
+ }
61
+
62
+ const result = postmarkMessagesResponseSchema.safeParse(providerResponse);
63
+ if (!result.success) {
64
+ throw new EmailDeliveryError('Postmark returned an invalid response');
65
+ }
66
+ if (result.data.TotalCount === 0) return undefined;
67
+
68
+ const message = result.data.Messages.find(
69
+ ({ Metadata }) => Metadata.deliveryId === deliveryId
70
+ );
71
+ if (!message) {
72
+ throw new EmailDeliveryError('Postmark returned an invalid response');
73
+ }
74
+
75
+ return {
76
+ httpStatus: response.status,
77
+ messageId: message.MessageID,
78
+ submittedAt: message.ReceivedAt,
79
+ };
80
+ }
@@ -1 +1,2 @@
1
+ export * from './find-postmark-email';
1
2
  export * from './send-email';