openfoodfacts / open-prices-frontend

A vue.js front-end for Open Prices
25 stars 13 forks source link

Display if there is an authentication error #432

Open dq18 opened 8 months ago

dq18 commented 8 months ago

Problem

Currently, the only way to know if there is an authentication error (error 401) is through console. User could be un-authenticated but still see a logged-in status in UI and not understand why functionalities are not working as expected.

Proposed solution

raphodn commented 8 months ago

Similar / duplicate with https://github.com/openfoodfacts/open-prices-frontend/issues/230 ?

odin-h commented 1 month ago

I think this issue is similar enough to this other issue I experienced today, that I don't need to create yet another issue about displaying network errors in the UI (even though my issue isn't related to authentication like this issue focuses on).

Here goes; After maybe half an hour of adding prices I went back to the dashboard to check my progress and realised none of the prices had been uploaded. Only the proofs made it through. My price upload attempts had been quietly failing in the background with error 400 despite the green 'price created' popup being shown every time when clicking the upload button.

https://github.com/user-attachments/assets/275b1da7-4a04-4a43-a602-1da179dec919

Here's an example of a payload that was causing it to fail:

{
   "proof_id":11676,
   "location_id":null,
   "location_osm_id":598877047,
   "location_osm_type":"WAY",
   "date":"2024-09-28",
   "currency":"NOK",
   "product_code":"7033352287150",
   "category_tag":null,
   "origins_tags":null,
   "labels_tags":null,
   "price":"108.5",
   "price_per":null,
   "price_is_discounted":false,
   "price_without_discount":null
}

And the server response:

{"location_id":["This field may not be null."]}

~Maybe the null values are due to an older version of the web app still being cached in my browser? 🤔~ Some kind of indicator that the website was updated recently and I'm still on the old version could be useful if that's the case. Edit: Don't think it's related to cache after all. It happened again even though I cleared it. Edit2: It seems to be happening because all the location values aren't sent when it's sending you from the proof upload form after uploading an image from the gallery, to the price upload form. When opening e recent proof the issue doesn't happen.

Proposed solution: Same as suggested above. Display a popup similar to the green 'Price created' message, but with the error message and with red background color instead.