-
Notifications
You must be signed in to change notification settings - Fork 61
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
fix(service-portal): Change date check #17605
base: main
Are you sure you want to change the base?
Conversation
we want to show delegations that expire today
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options. WalkthroughThe pull request modifies the Changes
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx (1)
30-30
: Improve type safety of the date expiration check.While the logic change correctly fixes the date comparison, we can improve type safety:
-const isDateExpired = (date?: string | null) => date && new Date(date) < startOfDay(new Date()) +const isDateExpired = (date?: string | null): boolean => { + if (!date) return false; + const expirationDate = new Date(date); + return !isNaN(expirationDate.getTime()) && expirationDate < startOfDay(new Date()); +}This change:
- Adds explicit return type
- Validates date parsing
- Makes the logic more readable
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx (1)
Pattern libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
🔇 Additional comments (2)
libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx (2)
21-21
: LGTM! Import follows tree-shaking best practices.The direct import from
date-fns/startOfDay
ensures optimal tree-shaking, consistent with the existing date-fns imports.
30-30
: Consider timezone implications in date comparisons.The current implementation uses local timezone for date comparisons. Depending on your requirements, you might want to:
- Use UTC for consistent date comparisons across timezones
- Consider the user's timezone when determining expiration
Let's verify if there are any timezone-related issues reported:
✅ Verification successful
The current implementation using local timezone is acceptable for client-side expiration checks.
The code consistently uses the browser's local timezone which is typically the desired behavior for user-facing expiration checks. However, consider documenting this assumption and if multi-timezone support becomes a requirement:
- Store dates in UTC format on the server
- Add explicit timezone handling where needed using date-fns-tz
- Include timezone information in the date string when comparing across zones
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for timezone-related discussions or issues rg -i "timezone|tz|utc" --type tsLength of output: 66169
Script:
#!/bin/bash # Search for date-fns imports and usage rg -i "from 'date-fns'" --type ts -A 2Length of output: 470
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.
LGTM
Datadog ReportAll test runs ✅ 10 Total Test Services: 0 Failed, 10 Passed Test ServicesThis report shows up to 10 services
🔻 Code Coverage Decreases vs Default Branch (1)
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #17605 +/- ##
=======================================
Coverage 35.57% 35.57%
=======================================
Files 7030 7030
Lines 150489 150489
Branches 42973 42973
=======================================
+ Hits 53536 53538 +2
+ Misses 96953 96951 -2 Flags with carried forward coverage won't be shown. Click here to find out more. see 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
What
We want to show delegations that expire today
Why
Users can select today as expire date, expecting it to expire at end of day
Screenshots / Gifs
Attach Screenshots / Gifs to help reviewers understand the scope of the pull request
Checklist:
Summary by CodeRabbit