-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathSendExampleEmailForm.tsx
More file actions
61 lines (59 loc) · 1.59 KB
/
SendExampleEmailForm.tsx
File metadata and controls
61 lines (59 loc) · 1.59 KB
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
53
54
55
56
57
58
59
60
61
"use client";
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectTrigger,
SelectValue,
SelectLabel,
} from "@/components/shadcn/ui/select";
import { Label } from "@/components/shadcn/ui/label";
import { Button } from "@/components/shadcn/ui/button";
import { useAction } from "next-safe-action/hooks";
import { sendExampleEmailAction } from "@/actions/email";
import { toast } from "sonner";
export default function SendExampleEmailForm() {
const { executeAsync } = useAction(sendExampleEmailAction);
async function handleSend() {
const res = await executeAsync({ sendTo: "all" });
if (res?.data?.success) {
toast.success("Emails sent successfully", {
position: "bottom-right",
});
} else {
toast.error(res?.data?.error ?? "Emails failed to send.", {
position: "bottom-right",
});
}
}
return (
<div className="flex w-full items-end justify-between">
<h3 className="text-xl font-bold">
Send Example Email (Don't use in production)
</h3>
<div className="flex items-end gap-2">
<div>
<Label className="text-nowrap">Send to</Label>
<Select defaultValue="all">
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectItem value="all">All</SelectItem>
<SelectItem value="rsvpedOnly">
RSVP'd Users Only
</SelectItem>
<SelectItem value="notRsvpedOnly">
un-RSVP'd Users Only
</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
</div>
<Button onClick={handleSend}>Send</Button>
</div>
</div>
);
}