Skip to content

OBPIH-7186 Change expiration date confirm modal in old inbound workflow#5591

Merged
alannadolny merged 4 commits intodevelopfrom
OBPIH-7186
Nov 5, 2025
Merged

OBPIH-7186 Change expiration date confirm modal in old inbound workflow#5591
alannadolny merged 4 commits intodevelopfrom
OBPIH-7186

Conversation

@SebastianLib
Copy link
Collaborator

@SebastianLib SebastianLib commented Nov 3, 2025

✨ Description of Change

Link to GitHub issue or Jira ticket:
https://pihemr.atlassian.net/browse/OBPIH-7186

Description:
There is a small chance that the new inbound will be released now, so we also need to add this new confirmation modal to the old inbound workflow

📷 Screenshots & Recordings (optional)

@github-actions github-actions bot added the domain: frontend Changes or discussions relating to the frontend UI label Nov 3, 2025
@SebastianLib SebastianLib added the type: feature A new piece of functionality for the app label Nov 3, 2025
@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 8.50%. Comparing base (1bb7314) to head (ba49f53).
⚠️ Report is 178 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff              @@
##             develop   #5591      +/-   ##
============================================
- Coverage       9.12%   8.50%   -0.63%     
+ Complexity      1170    1116      -54     
============================================
  Files            701     711      +10     
  Lines          45281   45583     +302     
  Branches       10851   10907      +56     
============================================
- Hits            4131    3875     -256     
- Misses         40497   41134     +637     
+ Partials         653     574      -79     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

item.inventoryItem &&
item.inventoryItem.expirationDate !== item.expirationDate &&
item.inventoryItem.quantity &&
item.inventoryItem.quantity !== '0',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you seem to do two .some methods to check those, and here, the .filter kinda "combines" those two statements.
Instead of checking hasExpiryMismatch and do a nested hasNonZeroQuantity and then checking if itemsWithMismatchedExpiry size is > 0, can't you just do the itemsWithMismatchedExpiry length check immediately?

TL:DR: I think you can get rid of ifs from 648 and 653 lines and just keep the one from 672.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it on purpose. We want to display this "warning" modal only when an item has a different inventoryItem.expirationDate and its inventoryItem.quantity is not equal to 0. We don't want to display the modal for items that only have a different inventoryItem.expirationDate but their inventoryItem.quantity is 0 although we still want to update inventory Item. That's why I use two .some

I know it's a bit weird, but that's how it was working before my changes. Maybe we should just display everything?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but in the filter you don't check OR, but AND, so you filter items that align with what you wrote so:

We want to display this "warning" modal only when an item has a different inventoryItem.expirationDate and its inventoryItem.quantity is not equal to 0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We check in the filter "AND" not "OR" because some items might only meet the first .some() (different inventoryItem.expirationDate). In that case, we still want to update them but not show them in the modal.
The modal should only display items that meet both conditions (different inventoryItem.expirationDate and inventoryItem.quantity not equal 0), so we can’t use an OR there.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok @SebastianLib , after you sent me the whole method on Slack, I understand the case.
Then what I think is worth doing is negating the logic, so to check if (!hasExpiry...) immedietaly and eventually do the return transitionToNextStep at the top.
By doing so, you will get rid of one nested if.


if (itemsWithMismatchedExpiry.length > 0) {
const shouldUpdateExpirationDate = await
this.confirmExpirationDateSave(itemsWithMismatchedExpiry);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the formatting looks weird here. don't break the await calls to another line. If you need to move it due to the eslint error as the line is too long, move it together with the await.

variant="primary"
onClick={onConfirm}
/>
<div data-testid="modal-with-table">
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alannadolny did I set the data-testid in the correct place?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

@alannadolny alannadolny merged commit 41f2c0a into develop Nov 5, 2025
7 checks passed
@alannadolny alannadolny deleted the OBPIH-7186 branch November 5, 2025 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: frontend Changes or discussions relating to the frontend UI type: feature A new piece of functionality for the app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants