1+ import { Mail } from "lucide-react" ;
2+ import { toast } from "sonner" ;
3+
4+ import { Button } from "@/components/ui/button" ;
5+ import {
6+ Card ,
7+ CardContent ,
8+ CardDescription ,
9+ CardHeader ,
10+ CardTitle ,
11+ } from "@/components/ui/card" ;
12+ import { Input } from "@/components/ui/input" ;
13+ import { Label } from "@/components/ui/label" ;
14+
15+ interface EmailIntegrationCardProps {
16+ orgHandle : string ;
17+ workflowHandle : string ;
18+ deploymentVersion ?: string ;
19+ emailDomain ?: string ;
20+ }
21+
22+ export function EmailIntegrationCard ( {
23+ orgHandle,
24+ workflowHandle,
25+ deploymentVersion,
26+ emailDomain = "dafthunk.com" ,
27+ } : EmailIntegrationCardProps ) {
28+ let emailAddress = `workflow+${ orgHandle } +${ workflowHandle } ` ;
29+ if ( deploymentVersion && deploymentVersion !== "latest" ) {
30+ emailAddress += `+${ deploymentVersion } ` ;
31+ }
32+ emailAddress += `@${ emailDomain } ` ;
33+
34+ const handleCopyEmail = ( ) => {
35+ navigator . clipboard . writeText ( emailAddress ) ;
36+ toast . success ( "Email address copied to clipboard" ) ;
37+ } ;
38+
39+ const description = deploymentVersion
40+ ? `Send emails to this address to trigger version ${ deploymentVersion } of the workflow.`
41+ : "Send emails to this address to trigger the workflow. This will always trigger the latest deployed version of the workflow." ;
42+
43+ return (
44+ < Card >
45+ < CardHeader >
46+ < CardTitle className = "flex items-center text-xl" >
47+ < Mail className = "mr-2 h-4 w-4" />
48+ Email Integration
49+ </ CardTitle >
50+ < CardDescription > { description } </ CardDescription >
51+ </ CardHeader >
52+ < CardContent >
53+ < div className = "space-y-2" >
54+ < Label htmlFor = "email-address" > Workflow Email Address</ Label >
55+ < div className = "flex items-center gap-2" >
56+ < Input
57+ id = "email-address"
58+ value = { emailAddress }
59+ readOnly
60+ className = "font-mono h-9"
61+ />
62+ < Button variant = "outline" onClick = { handleCopyEmail } >
63+ Copy
64+ </ Button >
65+ </ div >
66+ </ div >
67+ < p className = "text-sm text-muted-foreground mt-4" >
68+ The email subject will be used as the 'subject' input and the email
69+ body (text version) as the 'body' input for the workflow, if your
70+ workflow is configured to accept these inputs.
71+ </ p >
72+ </ CardContent >
73+ </ Card >
74+ ) ;
75+ }
0 commit comments