-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendBookingEmail.ts
52 lines (48 loc) · 1.33 KB
/
sendBookingEmail.ts
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
48
49
50
51
52
import { toast } from 'react-toastify'
const sendBookingEmail = async ({
bride,
groom,
email,
phone,
date,
location,
option,
message,
}) => {
const res = await fetch('/api/sendgrid', {
body: JSON.stringify({
to: 'email@nagygergely.info',
from: {
name: name,
email: 'email@nagygergely.info',
},
subject: 'Új árajánlat kérés!',
message: `
<h1>Árajánlat kérés tartalma:</h1>
<p>
<strong>Menyasszony neve:</strong> ${bride}<br />
<strong>Vőlegény neve:</strong> ${groom}<br />
<strong>E-mail:</strong> ${email}<br />
<strong>Telefon:</strong> ${phone}<br />
<strong>Dátum:</strong> ${date}<br />
<strong>Helyszín:</strong> ${location}<br />
<strong>Csomag:</strong> ${option}<br />
<strong>Üzenet:</strong> ${message}<br />
</p>
<h3>Vedd fel a kapcsolatot vele!</h3>
`,
}),
headers: {
'Content-Type': 'application/json',
},
method: 'POST',
})
const { error } = await res.json()
if (error) {
toast(error, { type: 'error' })
console.log(error)
return
}
toast.success('Árajánlat kérésed elküldve! Hamarosan jelentkezem!')
}
export default sendBookingEmail