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): [#175741693] Remove timestamp from transactions when it's equal to 00:00 #2734

Merged
merged 8 commits into from
Jan 25, 2021

Conversation

GiovanniMancini
Copy link
Contributor

@GiovanniMancini GiovanniMancini commented Jan 16, 2021

Short description

This PR proposes to hide the timestamp of a transaction when it's equal to 00:00 as in this case it isn't reliable.

List of changes proposed in this pull request

  • Modified the behavior of getSubtitle in BdpTransactionItem to conditionally format subtitle of transactions
  • Added conditional formatting in BpdTransactionDetailComponent

How to test

Unit tests: I've added 2 suites of unit tests.
Visual tests: see attached images

With amount before date
Simulator Screen Shot - iPhone 11 - 2021-01-19 at 11 21 59

With date before amount

detail_timestamp_00_00
detail_timestamp_13_24
list_items_differt_timestamp

@pagopa-github-bot pagopa-github-bot changed the title [#175741693] Remove timestamp from transactions when it's equal to 00:00 feat(Bonus Pagamenti Digitali): [#175741693] Remove timestamp from transactions when it's equal to 00:00 Jan 16, 2021
@pagopa-github-bot
Copy link
Collaborator

pagopa-github-bot commented Jan 16, 2021

Affected stories

  • 🌟 #175741693: Come CIT non voglio visualizzare l'orario delle transazioni in caso corrisponda a 00:00

Generated by 🚫 dangerJS against 4545da0

@codecov
Copy link

codecov bot commented Jan 16, 2021

Codecov Report

Merging #2734 (4545da0) into master (ec5437b) will increase coverage by 0.09%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2734      +/-   ##
==========================================
+ Coverage   53.36%   53.45%   +0.09%     
==========================================
  Files         760      760              
  Lines       21216    21224       +8     
  Branches     3697     4032     +335     
==========================================
+ Hits        11322    11346      +24     
+ Misses       9841     9823      -18     
- Partials       53       55       +2     
Impacted Files Coverage Δ
...ansaction/detail/BpdTransactionDetailComponent.tsx 93.75% <81.81%> (+16.82%) ⬆️
.../components/transactionItem/BpdTransactionItem.tsx 84.61% <100.00%> (+2.79%) ⬆️
...tails/transaction/detail/BpdTransactionWarning.tsx 69.23% <0.00%> (+23.07%) ⬆️
ts/components/CopyButtonComponent.tsx 84.61% <0.00%> (+34.61%) ⬆️

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 ec5437b...4545da0. Read the comment docs.

@@ -0,0 +1,56 @@
// import * as React from "react";
Copy link
Contributor

Choose a reason for hiding this comment

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

Could these imports be removed?

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.. I'll clean useless comments

describe("Test how the transaction subtitle changes with different timestamps", () => {
it("Subtitle shouldn't contain hours and minutes, when the transaction has a timestamp 00:00", () => {

// TODO: test input data should be moved in a separate file
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO should be followed by a ref to a story (es

* TODO: use the same component on all lists (messages, services, transaction): https://www.pivotaltracker.com/story/show/167064275
) or Can we remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll remove the TODO.. I don't know if the team agrees on having a separate module for test input data, this is just my approach

<H4 weight={"SemiBold"} color={"bluegreyDark"}>
{localeDateFormat(
<H4 weight={"SemiBold"} color={"bluegreyDark"} testID="dateValue">
{ (props.transaction.trxDate.getHours() === 0 && props.transaction.trxDate.getMinutes() === 0) ?
Copy link
Contributor

Choose a reason for hiding this comment

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

as improvement, could it be better to calculate a const once instead of make the same op twice?

const isMidNight =
    props.transaction.trxDate.getHours() +
      props.transaction.trxDate.getMinutes() ===
    0;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, your solution is more clear and readable. I'll change as you suggest

@fabriziofff fabriziofff requested a review from debiff as a code owner January 22, 2021 18:07
)} · € ${formatNumberAmount(transaction.amount)} `;
export const getSubtitle = (transaction: BpdTransaction) => {
const isMidNight =
transaction.trxDate.getHours() + transaction.trxDate.getMinutes() === 0;
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 adding also the seconds to the calculation?

Suggested change
transaction.trxDate.getHours() + transaction.trxDate.getMinutes() === 0;
transaction.trxDate.getHours() + transaction.trxDate.getMinutes() + transaction.trxDate.getSeconds() === 0;

In this way we can render the time for a transaction with timestamp 2020-12-13T00:00:31+01:00 that is a valid transaction.

Comment on lines 61 to 64
const isMidNight =
props.transaction.trxDate.getHours() +
props.transaction.trxDate.getMinutes() ===
0;
Copy link
Contributor

Choose a reason for hiding this comment

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

The same consideration about considering the seconds of the previous comment.

@fabriziofff fabriziofff merged commit b19d3f1 into master Jan 25, 2021
@fabriziofff fabriziofff deleted the 175741693-transaction-timestamp branch January 21, 2022 11:48
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.

5 participants