From 52b0b6eb5c748eda05c93015d0963c24d6e197f6 Mon Sep 17 00:00:00 2001 From: Potenz Date: Sat, 13 Dec 2025 01:46:52 +0530 Subject: [PATCH] feat(ddma-eligibility) - fix1 --- .../insurance-status/ddma-buton-modal.tsx | 28 ++++--------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/apps/Frontend/src/components/insurance-status/ddma-buton-modal.tsx b/apps/Frontend/src/components/insurance-status/ddma-buton-modal.tsx index c2e5421..380c5eb 100644 --- a/apps/Frontend/src/components/insurance-status/ddma-buton-modal.tsx +++ b/apps/Frontend/src/components/insurance-status/ddma-buton-modal.tsx @@ -431,37 +431,21 @@ export function DdmaEligibilityButton({ let bodyText = ""; try { - // Try to parse JSON (works when backend returns JSON body) - result = await response.json(); - } catch (jsonErr) { - // If JSON parsing fails, try to read raw text so we can show something meaningful + result = await response.clone().json(); + } catch { try { - bodyText = await response.text(); - } catch (textErr) { - bodyText = ""; - } + bodyText = await response.clone().text(); + } catch {} } - // Determine error message robustly const backendError = - // prefer explicit error field result?.error || - // sometimes APIs return 'message' or 'detail' result?.message || result?.detail || - // if JSON parse failed but bodyText contains something useful, use it - (bodyText && bodyText.trim() ? bodyText.trim() : null); + (bodyText && bodyText.trim()) || + null; if (!response.ok) { - // Log server response for debugging - console.warn("DDMA start failed response:", { - status: response.status, - ok: response.ok, - result, - bodyText, - }); - - // Throw with the backend message if available, otherwise throw generic throw new Error( backendError || `DDMA selenium start failed (status ${response.status})`