-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Bonus Pagamenti Digitali): [#175949561] Display cashback future periods ("Inactive") in wallet #2470
feat(Bonus Pagamenti Digitali): [#175949561] Display cashback future periods ("Inactive") in wallet #2470
Conversation
…561-dispay-cashback-future-periods-in-wallet
Affected stories
|
Codecov Report
@@ Coverage Diff @@
## master #2470 +/- ##
==========================================
+ Coverage 50.47% 50.52% +0.04%
==========================================
Files 697 696 -1
Lines 19626 19584 -42
Branches 3490 3491 +1
==========================================
- Hits 9906 9894 -12
+ Misses 9674 9644 -30
Partials 46 46
Continue to review full report at Codecov.
|
22e4a8d
to
593fcd4
Compare
…561-dispay-cashback-future-periods-in-wallet
…shback-future-periods-in-wallet' into 175949561-dispay-cashback-future-periods-in-wallet
…561-dispay-cashback-future-periods-in-wallet
Co-authored-by: Cristiano Tofani <[email protected]>
Co-authored-by: Cristiano Tofani <[email protected]>
Co-authored-by: Cristiano Tofani <[email protected]>
Co-authored-by: Cristiano Tofani <[email protected]>
Co-authored-by: Cristiano Tofani <[email protected]>
// All the periods are inactive | ||
(periodList.every(p => p.period.status === "Inactive") && | ||
// This is the first inactive period | ||
periodList.indexOf(periodAmount) === 0 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a shallow equality: it checks about object reference.
const inactivePeriodA: BpdPeriodAmount = {
amount: zeroAmount,
period: {
...inactivePeriod,
startDate: new Date("2025-01-01"),
awardPeriodId: 55 as AwardPeriodId
}
};
const test = isPeriodAmountWalletVisible(
[inactivePeriodA],
inactivePeriodA,
remoteReady(true)
);
const test2 = isPeriodAmountWalletVisible(
[inactivePeriodA],
{ ...inactivePeriodA },
remoteReady(true)
);
test -> true
test2 -> false
A solution could be
import _ from "lodash";
periodList.findIndex(o => _.isEqual(o, periodAmount)) === 0
// create a sorted copy of the array | ||
.concat() | ||
.sort((pa1, pa2) => | ||
pa1.period.startDate < pa2.period.startDate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pa1.period.startDate < pa2.period.startDate | |
import _ from "lodash"; | |
_.clamp(pa1.period.startDate - pa2.period.startDate, -1, 1); |
could it be a refactoring?
Short description
This pr allows to see in the wallet a cashback card for the first "Inactive" period, if the user is enrolled to bpd and all the periods are inactive.
1 closed period - 1 active period - 2 inactive periods => 2 inactive periods are hidden
2 inactive periods => The first inactive period is shown.