diff --git a/backend-py/app/main.py b/backend-py/app/main.py index ac9e7cc..e9f90f1 100644 --- a/backend-py/app/main.py +++ b/backend-py/app/main.py @@ -2410,8 +2410,8 @@ def _handle_client_create(body: dict[str, Any]) -> dict[str, Any]: note = (body.get("note") or "").strip() contract_no = (body.get("contract_no") or "").strip() contract_date = (body.get("contract_date") or "").strip() - gps_lat = body.get("gps_lat") - gps_lng = body.get("gps_lng") + gps_lat = body.get("gps_lat") or "" + gps_lng = body.get("gps_lng") or "" # Валидация if not full_name: diff --git a/miniapp/assets/clients.js b/miniapp/assets/clients.js index 053b01b..a745b11 100644 --- a/miniapp/assets/clients.js +++ b/miniapp/assets/clients.js @@ -473,6 +473,17 @@ const Clients = (function () { } loading.remove(); + // API вернул ошибку — показываем её явно (вместо пустого списка) + if (data.error) { + root.appendChild(el(` +
+ Ошибка загрузки клиентов: ${escHtml(data.error)} + ${data.error === "invalid_init_data" ? "
Попробуйте перезапустить бот или открыть приложение заново." : ""} +
+ `)); + return; + } + if (!data.clients || !data.clients.length) { root.appendChild(el(`
@@ -1804,7 +1815,10 @@ const Clients = (function () { if (!BACKEND_URL) throw new Error("BACKEND_URL не задан"); const res = await fetch(`${BACKEND_URL}/api/clients`, { method: "POST", - body: JSON.stringify({ initData: tg?.initData || "" }), + body: JSON.stringify({ + initData: tg?.initData || "", + initDataUnsafe: tg?.initDataUnsafe || null, + }), }); return await res.json(); } diff --git a/miniapp/index.html b/miniapp/index.html index f7a73a5..9da4d58 100644 --- a/miniapp/index.html +++ b/miniapp/index.html @@ -12,8 +12,8 @@ - - + + @@ -35,16 +35,16 @@
CRM
- - - - - - - - - - - + + + + + + + + + + +