File tree 2 files changed +25
-7
lines changed
2 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,10 @@ import type {
10
10
} from './interfaces/create-batch-options.interface' ;
11
11
12
12
export class Batch {
13
- private renderAsync ?: ( component : React . ReactElement ) => Promise < string > ;
13
+ private renderAsync ?: (
14
+ component : React . ReactElement ,
15
+ options ?: { plainText ?: boolean } ,
16
+ ) => Promise < string > ;
14
17
constructor ( private readonly resend : Resend ) { }
15
18
16
19
async send (
@@ -38,8 +41,14 @@ export class Batch {
38
41
) ;
39
42
}
40
43
}
41
-
42
- email . html = await this . renderAsync ( email . react as React . ReactElement ) ;
44
+ const [ html , text ] = await Promise . all ( [
45
+ this . renderAsync ( email . react as React . ReactElement ) ,
46
+ this . renderAsync ( email . react as React . ReactElement , {
47
+ plainText : true ,
48
+ } ) ,
49
+ ] ) ;
50
+ email . html = html ;
51
+ email . text = text ;
43
52
email . react = undefined ;
44
53
}
45
54
Original file line number Diff line number Diff line change @@ -22,7 +22,10 @@ import type {
22
22
} from './interfaces/update-email-options.interface' ;
23
23
24
24
export class Emails {
25
- private renderAsync ?: ( component : React . ReactElement ) => Promise < string > ;
25
+ private renderAsync ?: (
26
+ component : React . ReactElement ,
27
+ options ?: { plainText ?: boolean } ,
28
+ ) => Promise < string > ;
26
29
constructor ( private readonly resend : Resend ) { }
27
30
28
31
async send (
@@ -48,9 +51,15 @@ export class Emails {
48
51
}
49
52
}
50
53
51
- payload . html = await this . renderAsync (
52
- payload . react as React . ReactElement ,
53
- ) ;
54
+ const reactElement = payload . react as React . ReactElement ;
55
+ const [ html , text ] = await Promise . all ( [
56
+ this . renderAsync ( reactElement ) ,
57
+ this . renderAsync ( reactElement , {
58
+ plainText : true ,
59
+ } ) ,
60
+ ] ) ;
61
+ payload . text = text ;
62
+ payload . html = html ;
54
63
}
55
64
56
65
const data = await this . resend . post < CreateEmailResponseSuccess > (
You can’t perform that action at this time.
0 commit comments