Repository navigation
Ezra/311 partner shipment status updates - #313
Conversation
✅ Deploy Preview for hope-for-haiti ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Greptile SummaryThis PR fixes a bug where partner-facing shipment status views would fall back to the hardcoded default ( Key changes:
Areas to address:
Score: 88/100 — The fix is correct and well-tested. The only deduction is for the normalization inconsistency across services and minor trailing whitespace. Confidence Score: 5/5Safe to merge — the fix correctly broadens status lookup to items with only one shipping number, and all remaining findings are minor style/consistency suggestions. All identified issues are P2: one inconsistency around missing src/services/allocationService.ts and src/services/signOffService.ts — consider adding Important Files Changed
|
| OR: shippingNumberPairs.map((pair) => ({ | ||
| donorShippingNumber: pair.donorShippingNumber ?? null, | ||
| hfhShippingNumber: pair.hfhShippingNumber ?? null, | ||
| })), |
There was a problem hiding this comment.
Pairs not normalized before query
shippingNumberPairs is constructed directly from Prisma model fields and filtered with hasShippingIdentifier, but is never passed through normalizeShippingTuple before being mapped into the query. This means an empty-string shipping number (e.g. "") would be sent to the database as "" rather than null, potentially failing to match a ShippingStatus record that was stored with null.
By contrast, shippingStatusService.ts explicitly normalizes its pairs before querying:
const validPairs = shippingNumberPairs
.map((pair) => normalizeShippingTuple(pair))
.filter((pair) => hasShippingIdentifier(pair));For consistency and safety, normalize the pairs here too:
| OR: shippingNumberPairs.map((pair) => ({ | |
| donorShippingNumber: pair.donorShippingNumber ?? null, | |
| hfhShippingNumber: pair.hfhShippingNumber ?? null, | |
| })), | |
| OR: shippingNumberPairs.map((pair) => { | |
| const normalized = normalizeShippingTuple(pair); | |
| return { | |
| donorShippingNumber: normalized.donorShippingNumber, | |
| hfhShippingNumber: normalized.hfhShippingNumber, | |
| }; | |
| }), |
The same pattern applies in src/services/signOffService.ts (line 207), where the tuple is also not normalized before being used in the findFirst where clause — normalizeShippingTuple(tuple) should be used there as well.
| donorShippingNumber: tuple.donorShippingNumber, | ||
| }, | ||
| }); | ||
| const normalizedTuple = normalizeShippingTuple(tuple); |
There was a problem hiding this comment.
There is a trailing space after the semicolon on this line.
| const normalizedTuple = normalizeShippingTuple(tuple); | |
| const normalizedTuple = normalizeShippingTuple(tuple); |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Description
When there were entries in the database that didn't have both teh donorShippingNumber AND teh hfhShippingNumber, it would skip and return the default status. This change implements a fix to prevent the partner from seeing the hardcoded default status and the actual status.
Resolves ticket number: #311
Explain what your code changes:
shippingStatusService - removing lookupPairs and using the existing validPairs instead because that's what we are looking for
distributionService - removed the if conditional that checks for both shipping numbers
allocationService - removing lookupPairs and using the existing shippingNumberPairs because that's what we're looking for
signOffService - simplified the if conditional to just do the check for hasShippingIdentifier
List the steps you took to test your code:
Used a db script with 3 different entries where:
These items were then linked to Hope Medical Center as the partner and confirmed that all of the items would show the actual status rather than the default status.

Checklist