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): [#176191528,#176269223] Supercashback graphical component and textual summary update #2633

Conversation

fabriziofff
Copy link
Contributor

@fabriziofff fabriziofff commented Dec 22, 2020

Short description

This pr adds the Supercashback graphical component and update the textual summary conditions for the Active state.

export const ActiveTextualSummary: React.FunctionComponent<Props> = props => {
  // active period but still not enough transaction
  if (
    props.period.amount.transactionNumber < props.period.minTransactionNumber &&
    props.period.amount.totalCashback > 0
  ) {
    return <Warning period={props.period} />;
  }
  if (
    props.period.amount.transactionNumber >= props.period.minTransactionNumber
  ) {
    // The user is in the supercashback ranking atm
    if (
      isBpdRankingReady(props.period.ranking) &&
      props.period.ranking.ranking <= props.period.minPosition
    ) {
      return (
        <SuperCashback superCashbackAmount={props.period.superCashbackAmount} />
      );
    }
    // The max cashback amount is reached
    {
      if (props.period.amount.totalCashback >= props.period.maxPeriodCashback) {
        return <MaxAmount name={props.name} />;
      }
    }
    // Cashback unlocked! visible for the next 10 transaction only
    if (
      props.period.amount.transactionNumber <=
      props.period.minTransactionNumber + 10
    ) {
      return <Unlock {...props} />;
    }
  }
  return null;
};
Warning && transactionNumber==0 Warning && transactionNumber > 0 Unlock
MaxAmount SuperCashback
No Supercashback available

List of changes proposed in this pull request

  • Added missing field superCashbackAmount in BpdPeriod
  • Changed BpdSummaryComponent in order to display the supercashback ranking preview item SuperCashbackRankingSummary
  • Deprecated PercentageTransactionsSummary
  • Refactoring of TextualSummary and added new textual states
  • Added formatIntegerNumber to format an integer with delimiter

How to test

  • run ts/features/bonus/bpd/screens/details/components/summary/__test__/bpdSummaryComponent.test.tsx
  • run the application with different period / amount / ranking

@pagopa-github-bot pagopa-github-bot changed the title [#176191528] Supercashback graphical component and textual summary update feat(Bonus Pagamenti Digitali): [#176191528] Supercashback graphical component and textual summary update Dec 22, 2020
@pagopa-github-bot
Copy link
Collaborator

pagopa-github-bot commented Dec 22, 2020

Affected stories

  • 🌟 #176191528: Come CIT voglio visualizzare le mie statistiche generali sulla posizione in classifica con un componente d'anteprima
  • 🌟 #176269223: Come CIT voglio visualizzare l'icona della clessidra per l'infobox del graceperiod

Generated by 🚫 dangerJS against 993b375

…back-graphical-component-and-textual-summary-update' into 176191528-supercashback-graphical-component-and-textual-summary-update
@codecov
Copy link

codecov bot commented Dec 22, 2020

Codecov Report

Merging #2633 (993b375) into master (063e09d) will increase coverage by 0.11%.
The diff coverage is 98.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2633      +/-   ##
==========================================
+ Coverage   50.93%   51.05%   +0.11%     
==========================================
  Files         716      720       +4     
  Lines       20456    20515      +59     
  Branches     3613     3940     +327     
==========================================
+ Hits        10420    10473      +53     
- Misses       9992     9998       +6     
  Partials       44       44              
Impacted Files Coverage Δ
ts/features/bonus/bpd/saga/networking/periods.ts 63.15% <ø> (ø)
...eens/details/components/summary/base/ShadowBox.tsx 100.00% <ø> (ø)
...details/components/summary/BpdSummaryComponent.tsx 92.00% <90.00%> (-2.74%) ⬇️
...components/summary/SuperCashbackRankingSummary.tsx 95.65% <95.65%> (ø)
...omponents/summary/TransactionsGraphicalSummary.tsx 87.50% <100.00%> (-8.50%) ⬇️
...ts/summary/textualSummary/ActiveTextualSummary.tsx 100.00% <100.00%> (ø)
...ts/summary/textualSummary/ClosedTextualSummary.tsx 100.00% <100.00%> (ø)
.../summary/textualSummary/InactiveTextualSummary.tsx 100.00% <100.00%> (ø)
...mponents/summary/textualSummary/TextualSummary.tsx 100.00% <100.00%> (ø)
ts/utils/stringBuilder.ts 90.00% <100.00%> (+1.11%) ⬆️
... and 6 more

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 063e09d...993b375. Read the comment docs.

…back-graphical-component-and-textual-summary-update' into 176191528-supercashback-graphical-component-and-textual-summary-update
@fabriziofff fabriziofff marked this pull request as ready for review December 22, 2020 19:55
@fabriziofff fabriziofff changed the title feat(Bonus Pagamenti Digitali): [#176191528] Supercashback graphical component and textual summary update feat(Bonus Pagamenti Digitali): [#176191528,#176269223] Supercashback graphical component and textual summary update Dec 23, 2020
precision: 0,
delimiter: I18n.t("global.localization.delimiterSeparator"),
separator: I18n.t("global.localization.decimalSeparator")
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add some test here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in e2b97cc

* @param props
* @constructor
*/
export const TextualSummary = (props: Props) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

What you think about use React.ReactElement as return type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, added in 1b961af

* @param props
* @constructor
*/
export const InactiveTextualSummary = (props: { period: BpdPeriod }) => (
Copy link
Contributor

Choose a reason for hiding this comment

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

What you think about use React.ReactElement as return type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in 1b961af

);
}
// The max cashback amount is reached
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this curly brackets are needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed in 1b961af

…528-supercashback-graphical-component-and-textual-summary-update
@fabriziofff fabriziofff requested a review from debiff December 28, 2020 11:44
@Undermaken Undermaken merged commit 162bb6f into master Dec 28, 2020
@Undermaken Undermaken deleted the 176191528-supercashback-graphical-component-and-textual-summary-update branch December 28, 2020 17:34
@fabriziofff fabriziofff restored the 176191528-supercashback-graphical-component-and-textual-summary-update branch December 28, 2020 19:11
@fabriziofff fabriziofff deleted the 176191528-supercashback-graphical-component-and-textual-summary-update branch January 21, 2022 11:45
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