diff --git a/frontend/api.js b/frontend/api.js index a5122a2..35fba11 100644 --- a/frontend/api.js +++ b/frontend/api.js @@ -1,8 +1,8 @@ //API -const API_BASE_URL = "http://195.209.214.159/api"; +// const API_BASE_URL = "http://195.209.214.159/api"; //API local -// const API_BASE_URL = "http://localhost:3001/api"; +const API_BASE_URL = "http://localhost:3001/api"; //SHARED @@ -353,7 +353,18 @@ async function updateReport(reportId, data) { }, body: JSON.stringify(data), }); + + // handler for duplicates error before parsing + if (res.status === 409) { + showNotification( + "Отчет за этот магазин и дату уже был отправлен этим пользователем.", + "error" + ); + return { success: false, error: "Дубликат отчета" }; + } + const result = await res.json(); + if (res.ok && result.updated) { showNotification("Отчет обновлен!", "success"); hideModal("reportViewModal"); diff --git a/frontend/index.html b/frontend/index.html index 4ca771e..dca6b49 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -109,6 +109,27 @@
+ +
+ + +
+ +