-
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(web): Pension calculator results - Only fetch preview if selected year is the most recent one #16751
fix(web): Pension calculator results - Only fetch preview if selected year is the most recent one #16751
Conversation
WalkthroughThe changes in this pull request focus on the Changes
Possibly related PRs
Suggested reviewers
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
|
Datadog ReportBranch report: ✅ 0 Failed, 84 Passed, 0 Skipped, 25.43s Total Time |
Affected services are: web, Deployed services: web. |
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
🧹 Outside diff range and nitpick comments (2)
apps/web/screens/Organization/SocialInsuranceAdministration/PensionCalculatorResults.tsx (2)
658-662
: Consider refactoring complex conditional logic for clarityThe conditional statement in lines 658-662 is quite complex, which might affect readability and maintainability. Refactoring it into a well-named variable or helper function could enhance clarity.
Example:
+ const shouldFetch2025Calculation = + calculationInput.typeOfBasePension === + SocialInsurancePensionCalculationBasePensionType.Disability && + is2025PreviewActive(customPageData) && + dateOfCalculationsOptions.length > 0 && + calculationInput.dateOfCalculations && + new Date(calculationInput.dateOfCalculations).getFullYear() === + new Date(dateOfCalculationsOptions[0].value).getFullYear(); - calculationInput.typeOfBasePension === - SocialInsurancePensionCalculationBasePensionType.Disability && - is2025PreviewActive(customPageData) && - dateOfCalculationsOptions.length > 0 && - calculationInput.dateOfCalculations && - new Date(calculationInput.dateOfCalculations).getFullYear() === - new Date(dateOfCalculationsOptions[0].value).getFullYear() + shouldFetch2025Calculation ? apolloClient.query<Query, QueryGetPensionCalculationArgs>({ query: GET_PENSION_CALCULATION, variables: { input: { ...calculationInput, dateOfCalculations: new Date(2025, 8, 1).toISOString(), typeOfBasePension: SocialInsurancePensionCalculationBasePensionType.NewSystem, }, }, }) : { data: { getPensionCalculation: { groups: [], highlightedItems: [], }, }, },
668-668
: Extract hardcoded date into a constant for maintainabilityUsing a descriptive constant for the hardcoded date improves code readability and makes future updates easier.
Example:
+ const SEPTEMBER_FIRST_2025 = new Date(2025, 8, 1).toISOString(); ...calculationInput, - dateOfCalculations: new Date(2025, 8, 1).toISOString(), + dateOfCalculations: SEPTEMBER_FIRST_2025,
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
apps/web/screens/Organization/SocialInsuranceAdministration/PensionCalculatorResults.tsx
(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
apps/web/screens/Organization/SocialInsuranceAdministration/PensionCalculatorResults.tsx (1)
Pattern apps/**/*
: "Confirm that the code adheres to the following:
- NextJS best practices, including file structure, API routes, and static generation methods.
- Efficient state management and server-side rendering techniques.
- Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (2)
apps/web/screens/Organization/SocialInsuranceAdministration/PensionCalculatorResults.tsx (2)
617-617
: Adding dateOfCalculationsOptions
enhances data validation
Including dateOfCalculationsOptions
improves the component's ability to handle date validations effectively.
707-707
: Including dateOfCalculationsOptions
in the return enhances functionality
Adding dateOfCalculationsOptions
to the returned props ensures that the component has access to the necessary date options for rendering and logic.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16751 +/- ##
==========================================
- Coverage 36.53% 36.53% -0.01%
==========================================
Files 6888 6888
Lines 143674 143568 -106
Branches 40940 40908 -32
==========================================
- Hits 52497 52456 -41
+ Misses 91177 91112 -65
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 46 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
…ly-for-current-year
… year is the most recent one (#16751) * Only fetch preview if selected year is the most recent one * Overwrite what date gets sent to backend * Add function for comparing years --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
… year is the most recent one (#16751) * Only fetch preview if selected year is the most recent one * Overwrite what date gets sent to backend * Add function for comparing years --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
… year is the most recent one (#16751) * Only fetch preview if selected year is the most recent one * Overwrite what date gets sent to backend * Add function for comparing years --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Pension calculator results - Only fetch preview if selected year is the most recent one
What
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes
Refactor