这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
1 change: 0 additions & 1 deletion docs/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ function SubmitForm() {
})
.then((res) => res.json())
.then((res) => {
Cookies.set("ckId", res.id, { expires: 365 });
return router.push("/confirm");
});
e.preventDefault();
Expand Down
76 changes: 12 additions & 64 deletions docs/components/pages/confirm.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
/* eslint-disable react/no-unescaped-entities */
import axios from "axios";
import Head from "next/head";
import { Container } from "../Container";
import { Radio, RadioGroup } from "../RadioGroup";
import { useCkViewer } from "../useCkViewer";

export default function Confirm() {
const { data, mutate } = useCkViewer();

return (
<>
<Head>
Expand All @@ -19,65 +14,18 @@ export default function Confirm() {
<div className="pt-20 mx-auto ">
<div className="max-w-md mx-auto rounded-lg shadow-xl dark:bg-gray-900 dark:bg-opacity-80">
<div className="p-6 rounded-lg shadow-sm ">
{data && data?.fields?.job_title ? (
<div className="mx-auto space-y-4 dark:text-white">
<h2 className="text-xl font-bold">
Thanks so much! There's one last step.
</h2>
<p>
<strong className="relative inline-block text-transparent bg-clip-text bg-gradient-to-r from-blue-500 to-red-500">
Please confirm your email.
</strong>{" "}
Please check your inbox for an email that just got sent.
You'll need to click the confirmation link to receive any
further emails.
</p>{" "}
<p>
If you don't see the email after a few minutes, you might
check your spam folder or other filters and add{" "}
<code className="p-1 text-sm bg-gray-200 rounded-sm dark:bg-gray-700 ">
hello@turborepo.org
</code>{" "}
to your contacts.
</p>
<p>
Thanks,
<br />
The Turborepo Team
</p>
</div>
) : (
<div className="mx-auto space-y-4 dark:text-white">
<div className="text-2xl font-semibold leading-tight text-center">
How would you describe yourself?
</div>
<RadioGroup
label={
<span className="mb-2 font-medium sr-only">
Choose one:
</span>
}
onChange={(job_title) => {
axios
.put(`/api/user/${data.id}`, {
...data,
fields: {
...data.fields,
job_title,
},
})
.then(() => mutate(`/api/user/${data.id}`, true))
.catch((err) => console.log(err));
}}
>
<Radio value="manager">Engineering Manager</Radio>
<Radio value="senior">Senior Developer</Radio>
<Radio value="junior">Junior Developer</Radio>
<Radio value="novice">Novice Developer</Radio>
<Radio value="none">Choose not to say</Radio>
</RadioGroup>
</div>
)}
<div className="mx-auto space-y-4 dark:text-white">
<h2 className="text-xl font-bold">Thanks so much!</h2>
<p>
Keep an eye on your inbox for product updates and
announcements from Turborepo and Vercel.
</p>{" "}
<p>
Thanks,
<br />
The Turborepo Team
</p>
</div>
</div>
</div>
</div>
Expand Down
29 changes: 19 additions & 10 deletions docs/pages/api/signup.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
import { NextApiRequest, NextApiResponse } from "next";
import { subscribeToForm } from "../../lib/ConvertKitApi";

const FORM_ID = process.env.CONVERTKIT_FORM_ID;
const CAMPAIGN_ID = process.env.TURBOREPO_SFDC_CAMPAIGN_ID;
const TRAY_URL = process.env.TRAY_URL;

export default async function handle(
req: NextApiRequest,
res: NextApiResponse
) {
if (req.method === "POST") {
const subscriber = await subscribeToForm({
formId: FORM_ID,
const user = {
email: req.body.email,
firstName: req.body.firstName,
fields: {
last_name: req.body.lastName,
},
});
campaign_id: CAMPAIGN_ID,
};

return res.status(201).json(subscriber);
try {
const trayRes = await fetch(TRAY_URL, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({ user: user }),
});

return res.status(201).json(user);
} catch (error) {
return res.status(500).json(error);
}
} else {
return res.status(404).send(null);
}
Expand Down