jwplayer / ott-web-app

Reference implementation for JWP-powered apps
Apache License 2.0
69 stars 52 forks source link

Fix / missing feedback when submitting coupon #476

Closed ChristiaanScheermeijer closed 3 months ago

ChristiaanScheermeijer commented 3 months ago

Description

This PR addresses an issue we found during testing. For some reason, there was no feedback when submitting a coupon code. I tried to reproduce this, but the only way I could was to make the updateOrder fetch fail. For example, Google Chrome can be put in "Offline" mode using the network tab.

Because there was no feedback, I traced the code and remembered (and spotted some TOODs :-)) that the updateOrder method was a bit funky.

This PR addresses some problems and solves the TODOs:

  1. Prevent responseData.errors to contain Error objects (only strings are expected)
  2. Handle errors in try/catch only in the CheckoutController
  3. Throw errors with "fixed" messages in integrations
  4. Add a generic form error when the request fails due to (service outage/network problems)
  5. Prevent mutating the order in the JWP updateOrder method

Although the generic error shows "Unknown error", we know the reason. But we should solve this problem structurally, not just for the updateOrder method.

CC: @langemike

github-actions[bot] commented 3 months ago

Visit the preview URL for this PR (updated for commit 766793b):

https://ottwebapp--pr476-fix-coupon-feedback-blhze9wl.web.app

(expires Fri, 26 Apr 2024 11:11:12 GMT)

šŸ”„ via Firebase Hosting GitHub Action šŸŒŽ

Sign: c198f8a3a199ba8747819f7f1e45cf602b777529