fix: Improve types to remove unsafe casts#31
fix: Improve types to remove unsafe casts#31miles-grant-ibigroup merged 8 commits intofares-overhaulfrom
Conversation
| return ( | ||
| <> | ||
| <FaresV2Table legs={multipleFareOptionsItinerary.legs} /> | ||
| {/* <FaresV2Table legs={multipleFareOptionsItinerary.legs} /> */} |
There was a problem hiding this comment.
there seems to be some bad data in this one, it doesn't conform to the GraphQL schema
There was a problem hiding this comment.
This sounds like an OTP issue and not our issue
There was a problem hiding this comment.
did you grab this mock recently? OTP will never return malformed data. I'll double check to make sure I'm right about this being incorrect but maybe the schema changed slightly more recently to be more strict?
There was a problem hiding this comment.
I double checked and I think I was wrong about how the GraphQL schema works. Since FareProduct has a couple different implementations, I thought it had to be one of those (and both of those have a required price field). But actually, I believe you can have a fare product that is just the "parent" object and doesn't use one of the two implementations, which would allow it to not have a price. Since my code currently crashes with the missing price, I have a bit more work to do here...
miles-grant-ibigroup
left a comment
There was a problem hiding this comment.
I like your changes but disagree that we should implement them right away. I'd prefer to merge what we have now to avoid having to make fares v2 support a breaking change
| return ( | ||
| <> | ||
| <FaresV2Table legs={multipleFareOptionsItinerary.legs} /> | ||
| {/* <FaresV2Table legs={multipleFareOptionsItinerary.legs} /> */} |
There was a problem hiding this comment.
This sounds like an OTP issue and not our issue
|
okay, made some fixes, let me know what you think! |
miles-grant-ibigroup
left a comment
There was a problem hiding this comment.
trip-details fare summary isn't working right (try with otp-rr if you can't replicate). Not sure what's going on there. otherwise everything looks great thanks
packages/core-utils/src/itinerary.ts
Outdated
| } | ||
| return clonedFare; | ||
| const alreadySeen = seenFareIds?.indexOf(fare.id) > -1; | ||
| const currency = fare.product.price.currency; |
There was a problem hiding this comment.
You could inline this
| const currency = fare.product.price.currency; | |
| const {currency} = fare.product.price; |
packages/core-utils/src/itinerary.ts
Outdated
| alternateFareProducts: relevantFareProducts.splice(1).map(fp => fp.product), | ||
| price: cheapestRelevantFareProduct?.product?.price, | ||
| productUseId: cheapestRelevantFareProduct?.id, | ||
| appliedFareProduct: relevantFareProducts[0]?.product, |
packages/core-utils/src/itinerary.ts
Outdated
| if (!prev.some(p => p.productUseId === cur.productUseId)) { | ||
| prev.push({ productUseId: cur.productUseId, price: cur.price }); | ||
| prev.push({ | ||
| productUseId: cur.productUseId, |
There was a problem hiding this comment.
We could get this from the applied fare product?
There was a problem hiding this comment.
actually no, that's a different ID. That's the fare product ID but the product use ID is the random string that belongs to that instance of the fare product.
There was a problem hiding this comment.
I did refactor this to use an object and look up the keys in the reducer for performance.
| index > 0 && <TransferIcon size={16} />} | ||
| {price | ||
| ? renderFare(price?.currency?.code, price?.amount) | ||
| {legPrice |
There was a problem hiding this comment.
add a comment that legprice exists when original amount exists. There's probably a lot of cleanup possible overall but we can put it as a todo for now
miles-grant-ibigroup
left a comment
There was a problem hiding this comment.
Beautiful and clean I am so excited
taking a crack at making a better fare product type for the right side of the calculation functions