bcgov / entity

ServiceBC Registry Team working on Legal Entities
Apache License 2.0
23 stars 59 forks source link

Names-Examination UI Duplicate patch request with 401 response on Approval #22784

Open EPortman opened 3 months ago

EPortman commented 3 months ago

When pressing the approval or quick approval buttons, there is a 401 error that appears in the console and two get requests are sent.

image.png

It seems the problem is here. app/store/examine/index.ts (parseNr)

    // if the current state is not INPROGRESS, HOLD, or DRAFT clear any existing name record in currentNameObj
    if (
      ![Status.InProgress, Status.Hold, Status.Draft].includes(nrStatus.value)
    ) {
      setCurrentNameChoice(undefined)
    }

The choice gets updated to undefined, and then when it gets to the last if check here:

  async function makeDecision(decision: Status) {
    if (!currentNameObj.value) return

    if (decision === Status.Approved) {
      if (consentRequired.value) {
        currentNameObj.value.state = Status.Condition
      } else {
        currentNameObj.value.state = Status.Approved
        // If there were conflicts selected but this is an approval, remove the selected conflicts.
        // Do NOT clear the conflicts if the "Consent Required" condition is also set - then it's intentional.
        conflicts.clearSelectedConflicts()
      }
    } else {
      currentNameObj.value.state = Status.Rejected
    }
    populateNameChoice(currentNameObj.value)

    await pushDecision(currentNameObj.value)
    if (
      ![Status.Approved, Status.Condition].includes(currentNameObj?.value?.state)
    ) {
      await attemptNextNameChoice()
    }
  }

It will attempt next name choice since it is undefined - which should not happen on approvals. It really looks like simply removing that first block of code setting the currentNameObj to undefined will fix this problem.

EPortman commented 5 days ago

For QA

This ticket is to prevent errors in the web developer tools - network tab when approving NRs. Before the code changes when an NR was approved a 401 UNAUTHORIZED error was occurring after the approval request that was successful. This hapened on both the approve and quick approve button. This error did not have an effect on the application as the first approval worked.

image.png

After the code changes this error is no longer seen (just the successful one).

image.png