forked from Yara724/api
fix: return inquiry-specific Persian not-found messages
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user