Replace moment.js with native Date/Intl APIs#6404
Conversation
- TaxAppLabel: use Intl.DateTimeFormat with user locale for date display - useNewUserCheck: use native Date for validation and comparison - handlers (preorder): use native Date for past-date check - GiftCard utils: use native Date for expiry comparison - Add TaxAppLabel unit tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: d16a500 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
This PR removes a few moment.js usages and replaces them with native Date/Intl APIs to reduce reliance on a deprecated dependency, plus adds a unit test around TaxAppLabel date formatting.
Changes:
- Replace
momentwith nativeDatecomparisons inuseNewUserCheck, preorder handlers, and gift card expiry logic. - Update
TaxAppLabelto format dates viaIntl.DateTimeFormatusing the user locale. - Add
TaxAppLabelunit tests and a changeset entry.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/welcomePage/WelcomePageOnboarding/hooks/useNewUserCheck.ts | Swaps moment parsing/comparison for native Date parsing and > comparison. |
| src/taxes/components/TaxAppLabel.tsx | Replaces moment(created).format(...) with Intl.DateTimeFormat(locale).format(...). |
| src/taxes/components/TaxAppLabel.test.tsx | Adds unit coverage for localized date rendering and conditional sections. |
| src/products/utils/handlers.ts | Replaces moment-based preorder end-date validation with native Date comparison. |
| src/giftCards/GiftCardUpdate/providers/GiftCardDetailsProvider/utils.ts | Replaces moment-based expiry check with native Date comparison. |
| .changeset/plenty-peaches-agree.md | Adds a changeset entry for the moment removal. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6404 +/- ##
==========================================
+ Coverage 43.13% 43.14% +0.01%
==========================================
Files 2524 2525 +1
Lines 44009 44021 +12
Branches 10011 10011
==========================================
+ Hits 18983 18993 +10
- Misses 24985 24987 +2
Partials 41 41 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/giftCards/GiftCardUpdate/providers/GiftCardDetailsProvider/utils.ts
Outdated
Show resolved
Hide resolved
…/saleor-dashboard into lkostrowski/replace-moment-native
Scope of the change
Replace moment.js with native JavaScript Date and Intl APIs in 4 trivially replaceable cases. This reduces dependency on a deprecated library while maintaining equivalent functionality.
Changes:
TaxAppLabel: use Intl.DateTimeFormat with user locale for date display
useNewUserCheck: use native Date for validation and comparison
handlers (preorder): use native Date for past-date check
GiftCard utils: use native Date for expiry comparison
Add TaxAppLabel unit tests for date formatting
I confirm I added ripples for changes (see src/ripples) or my feature doesn't contain any user-facing changes
I used analytics "trackEvent" for important events
Note: Other moment.js usages in the codebase remain unchanged (12+ files still depend on moment).