feat(i18n): improve ai chat and settings localization
This commit is contained in:
@@ -13,7 +13,7 @@ export async function POST(request: Request) {
|
||||
const actor = await getSessionContextFromHeaders(new Headers(request.headers));
|
||||
|
||||
if (!actor) {
|
||||
return NextResponse.json({ error: "Müşteri daveti için giriş yapmalısınız." }, { status: 401 });
|
||||
return NextResponse.json({ error: "clients.detail.portalInviteUnauthenticated" }, { status: 401 });
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -23,14 +23,25 @@ export async function POST(request: Request) {
|
||||
return NextResponse.json({ success: true, invitation }, { status: 201 });
|
||||
} catch (error) {
|
||||
if (error instanceof SyntaxError) {
|
||||
return NextResponse.json({ error: "Geçersiz JSON gövdesi." }, { status: 400 });
|
||||
return NextResponse.json({ error: "clients.detail.invalidRequest" }, { status: 400 });
|
||||
}
|
||||
if (error instanceof PortalInvitationError) {
|
||||
const status = error.code === "FORBIDDEN" ? 403 : error.code === "INVALID_INPUT" ? 400 : 409;
|
||||
return NextResponse.json({ error: error.message, code: error.code }, { status });
|
||||
return NextResponse.json({ error: invitationErrorKey(error.code), code: error.code }, { status });
|
||||
}
|
||||
|
||||
console.error("Client invitation adapter failed", error);
|
||||
return NextResponse.json({ error: "Müşteri daveti oluşturulamadı." }, { status: 500 });
|
||||
return NextResponse.json({ error: "clients.detail.portalInviteFailed" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
function invitationErrorKey(code: PortalInvitationError["code"]) {
|
||||
switch (code) {
|
||||
case "FORBIDDEN":
|
||||
return "clients.detail.portalInviteForbidden";
|
||||
case "INVALID_INPUT":
|
||||
return "clients.detail.portalInviteInvalid";
|
||||
default:
|
||||
return "clients.detail.portalInviteFailed";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user