-
Notifications
You must be signed in to change notification settings - Fork 69
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
Apply User-Defined Date Formatting Settings to WP Admin React Components #9635
Apply User-Defined Date Formatting Settings to WP Admin React Components #9635
Conversation
…rview page" This reverts commit 0086c7c.
…g-arent-respected-in-react-components
…g-arent-respected-in-react-components
Thank you, everyone, for your helpful comments!
@haszari I also prefer this option, and it seems we are all aligned on it. I've made the necessary changes to use the BannerNotice component in this commit. For context, I completely agree that this is a bug. However, my main concern has been avoiding unintended negative impacts from fixing it, especially given the low number of complaints. The suggestion to show a notice for merchants resonated with me as a practical solution. Additionally, I appreciated @rogermattic's idea to place the notice within the table context, as it would have been more targeted. Initially, I assumed it would be straightforward to implement this change using the new TableCard component from the woocommerce/components repository. However, after gaining more experience, I realized I underestimated the complexity. Specifically, the plugin relies on the woocommerce/components bundle from WooCommerce core, which means we would need to wait for a new WooCommerce core release. This approach would be problematic, as merchants who update WooPayments without updating WooCommerce core would not see the notice. Given this limitation, I believe moving forward with the BannerNotice is the best option. While not ideal, it ensures we can inform merchants about the change effectively. I've added the notice to all pages under the Payments navigation menu. Below are some screenshots for your review—please let me know your thoughts. Lastly, I’ll be on extended AFK starting Dec 23rd, so it would be great to get additional reviews and feedback next week. Thank you! |
…g-arent-respected-in-react-components
…g-arent-respected-in-react-components
Looks good to me! Thank you! |
…g-arent-respected-in-react-components
…g-arent-respected-in-react-components
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.
I’ve conducted a round of testing on this PR and can see that it is looking good! It is so good to see more consistent datetime handling across the UI and in the code. 🙌
I've left a suggestion about using WP option rather than localStorage
to persist the banner dismissal state, which should improve UX for merchants who dismiss the notice.
To summarise the only inconsistencies that I’ve found (not blocking merge):
- Server-generated CSVs datetimes do not use the WP settings datetime format
- Client-generated CSV datetimes do use the WP settings datetime format, except for Transactions
- Transaction client-generated CSV export looks to be intentionally matching the server formatting instead
- We shouldn’t worry about inconsistencies across JS/server CSVs in this PR, since we are fixing those in Reporting: Move all CSV exports to endpoint (server) exports #9969. @Automattic/helix we should consider a consistent, intentional approach to datetime formatting as part of the Simplify CSV project paJDYF-g1S-p2 – either use the WP Settings datetime formatting, or use a standard format, e.g. ISO 8601.
- The main dates and times of the transaction timeline view don’t use the WP settings datetime format – this may need to be fixed upstream in
@woocommerce/components
- Server-generated VAT invoices use a server-defined format – again, not a worry for this PR
Steps tested
- Set WP date/time settings to
m_d_Y
H_i
(12_17_2024
23_56
) - Set WP store TZ to New York
- Set browser time to Mumbai (Browser Dev Tools → More Tools → Sensors)
- Payments → Overview
- New notice displayed and links to the correct page ✅
- Dismissing the notice works ✅
- Payout dates are formatted as per WP settings ✅
- Payout detail view
- Dates and times formatted as per WP settings ✅
- Payouts list view
- Dates and times formatted as per WP settings ✅
- Client-side CSV export dates and times are formatted as per WP settings ✅
- Server CSV export dates and times are not formatted as per WP settings
⚠️
- Transaction detail view
- Transation summary and dispute dates and times formatted as per WP settings ✅
- Timeline event details (e.g. payout event) dates and times are formatted as per WP settings ✅
- Main timeline dates and times are not formatted as per WP settings
⚠️
- Transactions list view
- Dates and times formatted as per WP settings ✅
- Client-side CSV export dates and times are not formatted as per WP settings
⚠️ - Server CSV export dates and times are not formatted as per WP settings
⚠️
- Disputes list view
- Dates and times formatted as per WP settings ✅
- Client-side CSV export dates and times are formatted as per WP settings ✅
- Server CSV export dates and times are not formatted as per WP settings
⚠️
- Dispute challenge view
- Dates and times formatted as per WP settings ✅
- Capital Loan list view
- Dates and times formatted as per WP settings ✅
- Documents list view
- Dates and times formatted as per WP settings ✅
- VAT invoice download
- Dates and times are formatted as per WP settings
⚠️ (server-generated)
- Dates and times are formatted as per WP settings
…g-arent-respected-in-react-components
This reverts commit b6bf313.
…date-and-time-formatting-arent-respected-in-react-components
…g-arent-respected-in-react-components
…g-arent-respected-in-react-components
…g-arent-respected-in-react-components
…g-arent-respected-in-react-components
Fixes #6567
This pull request includes changes to ensure that user-defined date and time formatting settings are respected across various React components in the WooCommerce Payments plugin. The most important changes include the replacement of
dateI18n
with custom date formatting functions, the addition of a newDateFormatNotice
component, and updates to test files to accommodate these changes.Improvements to date and time formatting:
client/capital/index.tsx
: ReplaceddateI18n
withformatDateTimeFromString
for date formatting in loan status and rows data. AddedDateFormatNotice
component to display a notice about date format changes. [1] [2] [3] [4] [5]client/components/account-status/account-fees/expiration-description.js
: ReplaceddateI18n
withformatDateTimeFromString
for expiration date formatting. [1] [2]client/components/active-loan-summary/index.tsx
: ReplaceddateI18n
withformatDateTimeFromTimestamp
for various date fields in the active loan summary. [1] [2] [3]client/components/disputed-order-notice/index.js
: ReplaceddateI18n
withformatDateTimeFromString
for dispute notice dates and ensured consistent timezone-independent comparison using UTC. [1] [2]Addition of
DateFormatNotice
component:client/components/date-format-notice/index.tsx
: Added a new component to display a notice about the date and time formats matching user preferences.client/components/date-format-notice/style.scss
: Added styles for theDateFormatNotice
component.Test updates:
DateFormatNotice
component in snapshots. [1] [2] [3] [4] [5] [6] [7] [8] [9]Testing instructions
General Date and Time Display Testing
WP Admin > Settings > General
and set your preferred Date and Time Formats and Timezone.Component Specific Testing
Transactions
WP Admin > Payments > Transactions
.Date / Time
andDeposit Date
columns.Capital Loans
This section is hidden if your user does not have capital loans. Follow the steps in this guide to create one offer for your user. Once the offer is created, your user will get an email to confirm it. Visit the link in the email, but make sure to use your local store URL, not the server one.
WP Admin > Payments > Capital loans
Active loan overview
dates are formatted according to the user settings.All Loans
table dates are formatted according to the user settings. There are two columns that contain dates:Disbursed
andFirst Paydown
.Deposits
WP Admin > Payments > Deposits
Disputes
You can use test cards to create disputed orders.
WP Admin > Payments > Disputes
Disputed on
column (you may need to reveal it)Challenge Dispute
and verify the dates in the form are correctDocuments
In the server, you can use the cli to add a document to your account
wp wcpay add_document_for_account 236870460 vat_invoice --period_from="2024-10-01 00:00:00" --period_to="2024-10-31 23:59:59"
WP Admin > Payments > Documents
Date and time format change notice
WP Admin > Payments
menu i.e.Transactions
.npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge