Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ UPSTASH_REDIS_REST_TOKEN=

# Optional: WalletConnect project ID
# NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=

# Optional: Resend API key for feedback emails
# RESEND_API_KEY=
# RESEND_FROM_EMAIL=Certified <noreply@certified.one>
73 changes: 73 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"next": "^16.1.6",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"resend": "^6.10.0",
"viem": "^2.46.3",
"wagmi": "^2.19.5"
},
Expand Down
61 changes: 61 additions & 0 deletions src/app/api/feedback/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { NextRequest, NextResponse } from "next/server";
import { Resend } from "resend";

const resend = new Resend(process.env.RESEND_API_KEY);
const SUPPORT_EMAIL = "support@hypercerts.org";
const FROM_EMAIL = process.env.RESEND_FROM_EMAIL || "Certified <no-reply@certified.one>";

export async function POST(req: NextRequest) {
try {
const { message, email } = await req.json();

if (!message || typeof message !== "string" || !message.trim()) {
return NextResponse.json({ error: "Message is required" }, { status: 400 });
}

if (email && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
return NextResponse.json({ error: "Invalid email address" }, { status: 400 });
}

// Send feedback to support
await resend.emails.send({
from: FROM_EMAIL,
to: SUPPORT_EMAIL,
subject: "New feedback for Certified.app",
text: [
"New feedback received:",
"",
message,
"",
email ? `Reply-to: ${email}` : "No email provided",
].join("\n"),
...(email ? { replyTo: email } : {}),
});

// Send confirmation to user if they provided an email
if (email) {
await resend.emails.send({
from: FROM_EMAIL,
to: email,
subject: "Thank you for your feedback to Certified.app",
text: [
"Thank you for sharing your feedback with us!",
"",
"We've received the following message:",
"",
`"${message}"`,
"",
"We appreciate your input and will review it carefully.",
"",
"Best regards,",
"The Certified Team",
].join("\n"),
});
}

return NextResponse.json({ success: true });
} catch (error) {
console.error("Feedback error:", error);
return NextResponse.json({ error: "Failed to send feedback" }, { status: 500 });
}
}
Loading