[OBPIH-6626] [Bug-Fix] Prevent multiple full outbound imports from happening#4791
Conversation
| // If the save went sucessfully, redirect to the stock movement view page | ||
| window.location = STOCK_MOVEMENT_URL.show(response.data?.data?.id); | ||
| } catch (e) { | ||
| spinner.hide(); |
There was a problem hiding this comment.
Is this hide only in the catch block? What happens if everything goes well?
There was a problem hiding this comment.
if everything goes well we are going to get redirected to the show page of the stock movement.
When we call
window.location = STOCK_MOVEMENT_URL.show(response.data?.data?.id);it still takes some time and if we hide the spinner overlay before redirecting, then user will still be able to click the finish button and the issue will not be resolved.
I decided to keep the show overlay until we are redirected, I believe this looks like a natural behavior for the user - it's like after clicking finish we are waiting for the show page to load.
There was a problem hiding this comment.
I think the hide should be called in the finally. Because of redux-persist we might then come back to the React page with the show state of the spinner.
There was a problem hiding this comment.
spinner is blacklisted and is not stored in the redux-presist
There was a problem hiding this comment.
ok, I was too lazy to check it myself, so thanks for confirming.
|
one comment above |
|
Moreover I think that the backend should also prevent it. I had that in mind, but since I focused on happy case, I didn't make such validations, but I strongly believe we should also have some kind of "if shipment exists, do not allow to create", etc. |
|
@kchelstowski I might be wrong but I am not sure how would that be possible? is there any identifier that we can use to say that this outbound is already created? But I don't think so... |
|
@drodzewicz after adding the spinner, it won't be possible from the frontend perspective, and what I meant is rather something "nice to have" especially if we ever want to support editing an outbound through that workflow - this would then require refactor of API to make additional checks, but we can live without that for now. |
✨ Description of Change
Link to GitHub issue or Jira ticket: OBPIH-6626
Description:
TLDR; of the issue: After submitting the full outbound request user is waiting for the redirect to happen and is able to click "Finish" button since after first submit it is not disabled and as a result for each click submits a "NEW" full outbound stock movement.
My solution was to display the spinner overlay which should prevent the user from interacting with the UI while the request is being processed.
📷 Screenshots & Recordings (optional)
📈 Test Plan
Description of test plan (if applicable):
✅ Quality Checks
[OBS-123]for Jira,[#0000]for GitHub, or[OBS-123, OBPIH-123]if there are multiple), or with[N/A]if not applicable