Skip to content

Commit a1291e7

Browse files
authored
Merge pull request #412 from wri/fix/add-ortto-dashboard
add ortto submission to dashboard page
2 parents 4e642f2 + b6e7a68 commit a1291e7

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

app/dashboard/page.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,32 @@ export default function UserSettingsPage() {
225225
if (!res.ok) {
226226
throw new Error("Failed to save profile");
227227
}
228+
229+
// Submit to Ortto directly from client (no secrets needed)
230+
const topicLabels = form.topics.map(
231+
(code) => config?.topics?.[code] || code
232+
);
233+
try {
234+
const orttoRes = await fetch("https://ortto.wri.org/custom-forms/gnw/", {
235+
method: "POST",
236+
headers: { "Content-Type": "application/json" },
237+
body: JSON.stringify({
238+
email: form.email,
239+
firstName: form.firstName,
240+
lastName: form.lastName,
241+
sector: form.sector,
242+
jobTitle: form.jobTitle,
243+
companyOrganization: form.company,
244+
countryCode: form.country,
245+
Topics: topicLabels,
246+
receiveNewsEmails: form.receiveNewsEmails,
247+
}),
248+
});
249+
console.log("[Client] Ortto submission status:", orttoRes.status, orttoRes.ok ? "OK" : "FAILED");
250+
} catch (e) {
251+
console.error("[Client] Ortto submission error:", e);
252+
}
253+
228254
toaster.create({
229255
title: "Profile saved",
230256
description: "Your changes have been saved successfully.",

0 commit comments

Comments
 (0)