fix: return inquiry-specific Persian not-found messages

This commit is contained in:
2026-11-18 12:31:44 +03:30
parent 7631a94071
commit 2cdbc35d2e
6 changed files with 99 additions and 34 deletions
+6 -6
View File
@@ -18,7 +18,7 @@ const NOT_FOUND_MESSAGES: Record<InquiryErrorContext, string> = {
carBodyPlate: "بیمه‌نامه بدنه فعالی مطابق پلاک و کد ملی واردشده یافت نشد.",
carBodyVin:
"بیمه‌نامه بدنه فعالی مطابق شماره شاسی (VIN) و کد ملی واردشده یافت نشد.",
personalIdentity: "اطلاعات هویتی مطابق کد ملی و تاریخ تولد واردشده یافت نشد.",
personalIdentity: "استعلام مشخصات هویتی یافت نشد",
drivingLicense:
"گواهینامه‌ای مطابق کد ملی و شماره گواهینامه واردشده یافت نشد.",
carOwnership: "مالکیتی مطابق پلاک و کد ملی واردشده یافت نشد.",
@@ -201,13 +201,13 @@ export function getInquiryErrorMessage(
): string {
const providerMessage = extractInquiryProviderMessage(error);
// Persian text supplied by the provider is already the intended client
// message. Preserve it verbatim instead of replacing it with a local
// contextual fallback such as "inquiry not found".
if (providerMessage && hasPersian(providerMessage)) return providerMessage;
// Providers use the same generic Persian not-found text for every inquiry.
// Resolve that failure using the caller's context before preserving other
// Persian messages (for example, specific input validation details).
if (isNotFound(error, providerMessage)) return NOT_FOUND_MESSAGES[context];
if (providerMessage && hasPersian(providerMessage)) return providerMessage;
if (
context === "carOwnership" &&
/not the owner|مالک.*نیست/i.test(providerMessage)