Build the RTL Next.js experience with live catalog, journal, customer interactions, and SEO-ready canonical routes. Co-authored-by: Cursor <cursoragent@cursor.com>
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
import {
|
|
MESHKEE_API_BASE,
|
|
WEBSITE_DOMAIN,
|
|
} from "@/lib/meshkee";
|
|
|
|
export async function POST(request: Request) {
|
|
const body = (await request.json()) as {
|
|
title?: string;
|
|
name?: string;
|
|
email?: string;
|
|
cellNumber?: string;
|
|
text?: string;
|
|
};
|
|
|
|
if (!body.title?.trim() || !body.name?.trim() || !body.text?.trim()) {
|
|
return NextResponse.json(
|
|
{ message: "نام، موضوع و متن پیام الزامی است." },
|
|
{ status: 400 },
|
|
);
|
|
}
|
|
|
|
const response = await fetch(
|
|
`${MESHKEE_API_BASE}/tenants/${WEBSITE_DOMAIN}/contact-submissions`,
|
|
{
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({
|
|
title: body.title.trim(),
|
|
name: body.name.trim(),
|
|
email: body.email?.trim() || undefined,
|
|
cellNumber: body.cellNumber?.trim() || undefined,
|
|
text: body.text.trim(),
|
|
}),
|
|
cache: "no-store",
|
|
},
|
|
);
|
|
|
|
const data = await response.json().catch(() => ({}));
|
|
return NextResponse.json(data, { status: response.status });
|
|
}
|