1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/** @jsxImportSource https://esm.sh/react */
import { lessons } from "https://esm.town/v/petermillspaugh/lessons";
import { email as sendEmail } from "https://esm.town/v/std/email?v=11";
import { renderToString } from "npm:react-dom/server";
export async function sendLessonResponses({ email, lesson, formData }) {
const fillBlankResponse = formData.get("fill-in-the-blank") as string;
const reflectionResponse = formData.get("reflection") as string;
const jsx = (
<>
<h1>Your responses for lesson {Number(lesson) + 1}: {lessons[lesson].title}</h1>
<h2>Fill-in-the-blank</h2>
<p>
<strong>Prompt:</strong> {lessons[lesson].fillBlank}
</p>
<p>
<strong>Your response:</strong> {fillBlankResponse}
</p>
<h2>Review</h2>
{lessons[lesson].quiz.map(({ question, answer }) => (
<>
<h3>{question}</h3>
<p>
<strong>Your response:</strong> {formData.get(`ANSWER-${question}`) as string}
</p>
<p>
<strong>Answer:</strong> {answer}
</p>
</>
))}
<h2>Reflection</h2>
<p>{reflectionResponse}</p>
</>
);
await sendEmail({
to: email,
from: {
name: "Make It Stick (in 10 days, via email)",
email: "petermillspaugh.sendLesson@valtown.email",
},
replyTo: "pete@petemillspaugh.com",
subject: `Your responses for lesson ${Number(lesson) + 1}: ${lessons[lesson].title}`,
html: renderToString(jsx),
});
}