Skip to content
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

Merged
merged 17 commits into from
Dec 2, 2020

Conversation

fabriziofff
Copy link
Contributor

@fabriziofff fabriziofff commented Dec 1, 2020

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.

@pagopa-github-bot pagopa-github-bot changed the title [#175949561] Dispay cashback future periods ("Inactive") in wallet feat(Bonus Pagamenti Digitali): [#175949561] Dispay cashback future periods ("Inactive") in wallet Dec 1, 2020
@pagopa-github-bot
Copy link
Collaborator

pagopa-github-bot commented Dec 1, 2020

Affected stories

  • 🌟 #175949561: Come CIT voglio vedere nel wallet i periodi futuri del cashback (se sono iscritto al cashback)

Generated by 🚫 dangerJS against 7752c86

@Undermaken Undermaken changed the title feat(Bonus Pagamenti Digitali): [#175949561] Dispay cashback future periods ("Inactive") in wallet feat(Bonus Pagamenti Digitali): [#175949561] Display cashback future periods ("Inactive") in wallet Dec 1, 2020
@codecov
Copy link

codecov bot commented Dec 1, 2020

Codecov Report

Merging #2470 (7752c86) into master (f53125e) will increase coverage by 0.04%.
The diff coverage is 82.35%.

Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
...d/components/bpdCardComponent/BpdCardComponent.tsx 36.92% <0.00%> (-1.18%) ⬇️
ts/features/bonus/bpd/navigation/actions.ts 100.00% <ø> (ø)
ts/features/bonus/bpd/navigation/routes.ts 100.00% <ø> (ø)
...tures/bonus/bpd/store/reducers/details/combiner.ts 61.53% <92.30%> (+14.47%) ⬆️
ts/features/bonus/bpd/navigation/navigator.ts 100.00% <100.00%> (ø)
...es/bonus/bpd/screens/details/BpdPeriodSelector.tsx 62.50% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f53125e...7752c86. Read the comment docs.

@fabriziofff fabriziofff force-pushed the 175949561-dispay-cashback-future-periods-in-wallet branch from 22e4a8d to 593fcd4 Compare December 1, 2020 11:40
@fabriziofff fabriziofff marked this pull request as draft December 1, 2020 20:09
@fabriziofff fabriziofff marked this pull request as ready for review December 1, 2020 20:30
@CrisTofani CrisTofani merged commit 08e1e9d into master Dec 2, 2020
@CrisTofani CrisTofani deleted the 175949561-dispay-cashback-future-periods-in-wallet branch December 2, 2020 10:36
// All the periods are inactive
(periodList.every(p => p.period.status === "Inactive") &&
// This is the first inactive period
periodList.indexOf(periodAmount) === 0 &&
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pa1.period.startDate < pa2.period.startDate
import _ from "lodash";
_.clamp(pa1.period.startDate - pa2.period.startDate, -1, 1);

could it be a refactoring?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants