@@ -25,7 +25,7 @@ import {
2525 faPaperPlane ,
2626 faEye
2727} from '@fortawesome/free-regular-svg-icons'
28- import { faTerminal } from '@fortawesome/free-solid-svg-icons'
28+ import { faTerminal , faCopy } from '@fortawesome/free-solid-svg-icons'
2929import UpsertTransactionalNotificationDrawer from '../components/transactional/UpsertTransactionalNotificationDrawer'
3030import React , { useState } from 'react'
3131import dayjs from '../lib/dayjs'
@@ -151,6 +151,43 @@ export function TransactionalNotificationsPage() {
151151 setApiModalOpen ( true )
152152 }
153153
154+ const handleCopyCommand = ( ) => {
155+ if ( ! currentApiNotification ) return
156+
157+ const curlCommand = `curl -X POST \\
158+ "${ window . location . origin } /api/transactional.send" \\
159+ -H "Content-Type: application/json" \\
160+ -H "Authorization: Bearer YOUR_API_KEY" \\
161+ -d '{
162+ "workspace_id": "${ workspaceId } ",
163+ "notification": {
164+ "id": "${ currentApiNotification . id } ",
165+ "channels": ["email"],
166+ "contact": {
167+ "email": "recipient@example.com"
168+ // other optional contact fields here
169+ },
170+ "data": {
171+ // Your template variables here
172+ },
173+ "email_options": {
174+ "reply_to": "reply@example.com",
175+ "cc": ["cc@example.com"],
176+ "bcc": ["bcc@example.com"]
177+ }
178+ }
179+ }'`
180+
181+ navigator . clipboard
182+ . writeText ( curlCommand )
183+ . then ( ( ) => {
184+ message . success ( 'Curl command copied to clipboard!' )
185+ } )
186+ . catch ( ( ) => {
187+ message . error ( 'Failed to copy to clipboard' )
188+ } )
189+ }
190+
154191 if ( notificationsError ) {
155192 return (
156193 < div >
@@ -300,7 +337,20 @@ export function TransactionalNotificationsPage() {
300337 title = "API Command"
301338 open = { apiModalOpen }
302339 onCancel = { ( ) => setApiModalOpen ( false ) }
303- footer = { null }
340+ footer = { [
341+ < Button
342+ key = "copy"
343+ type = "primary"
344+ ghost
345+ icon = { < FontAwesomeIcon icon = { faCopy } /> }
346+ onClick = { handleCopyCommand }
347+ >
348+ Copy
349+ </ Button > ,
350+ < Button key = "close" onClick = { ( ) => setApiModalOpen ( false ) } >
351+ Close
352+ </ Button >
353+ ] }
304354 width = { 800 }
305355 >
306356 { currentApiNotification && (
0 commit comments