+ {s.code}
+
+ Finish your setup
++ {doneCount} of {steps.length} {doneCount === 1 ? 'step' : 'steps'} done +
+Your first email is live.
', + from: 'sender@yourdomain.com', + }; + const curl = `curl -X POST ${apiUrl}/v1/send \\ + -H "Authorization: Bearer ${secret}" \\ + -H "Content-Type: application/json" \\ + -d '${JSON.stringify(body, null, 2).replace(/\n/g, '\n ')}'`; + + const node = `await fetch("${apiUrl}/v1/send", { + method: "POST", + headers: { + Authorization: "Bearer ${secret}", + "Content-Type": "application/json", + }, + body: JSON.stringify(${JSON.stringify(body, null, 2).replace(/\n/g, '\n ')}), +});`; + + const python = `import requests + +requests.post( + "${apiUrl}/v1/send", + headers={"Authorization": "Bearer ${secret}"}, + json=${JSON.stringify(body, null, 4).replace(/\n/g, '\n ')}, +)`; + + const php = `$ch = curl_init("${apiUrl}/v1/send"); +curl_setopt_array($ch, [ + CURLOPT_POST => true, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HTTPHEADER => [ + "Authorization: Bearer ${secret}", + "Content-Type: application/json", + ], + CURLOPT_POSTFIELDS => json_encode(${JSON.stringify(body, null, 4).replace(/\n/g, '\n ')}), +]); +curl_exec($ch);`; + + return [ + {id: 'curl', label: 'cURL', code: curl}, + {id: 'node', label: 'Node.js', code: node}, + {id: 'python', label: 'Python', code: python}, + {id: 'php', label: 'PHP', code: php}, + ]; +} + +export default function OnboardingDeveloper() { + const router = useRouter(); + const {activeProject} = useActiveProject(); + const {state} = useOnboardingGate(); + const {path, setPath} = useOnboardingPath(activeProject?.id); + + const snippets = useMemo( + () => buildSnippets(API_URI, activeProject?.secret ?? 'sk_your_secret_key'), + [activeProject?.secret], + ); + + useEffect(() => { + if (activeProject && !path) setPath('developer'); + }, [activeProject, path, setPath]); + + if (state !== 'show') return null; + + const handleContinue = () => { + void router.push('/'); + }; + + const handleStepClick = (href: string) => { + void router.push(href); + }; + + return ( + <> ++ Three steps to your first send. Start with your domain so emails actually reach the inbox. +
+{step.description}
++ Two minutes of setup and you'll be sending. How do you plan to use Plunk? +
+{path.description}
++ Not sure? Pick the closest fit — you can do all three once you're set up. +
++ Three steps to your first broadcast. Start anywhere — you can come back to finish the rest. +
+{step.description}
++ Four steps to your first automated email. Start with your domain so emails actually reach the inbox. +
+{step.description}
+