-
Notifications
You must be signed in to change notification settings - Fork 18
intervention condition added #2386
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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
npm warn config production Use WalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
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
CodeRabbit Configuration File (
|
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)
src/features/projectsV2/ProjectsMap/microComponents/PlantLocations.tsx (1)
223-223
: Improve code style, type safety, and maintainability.The condition for rendering sample interventions could be improved in several ways:
- Extract the allowed intervention types to a constant for better maintainability:
+const SAMPLE_INTERVENTION_TYPES = [ + 'multi-tree-registration', + 'enrichment-planting', + 'all', + 'default', +] as const; + +type SampleInterventionType = typeof SAMPLE_INTERVENTION_TYPES[number];
- Simplify the condition using
includes
:-selectedInterventionType === 'multi-tree-registration' || selectedInterventionType === 'enrichment-planting' || selectedInterventionType ==='all' || selectedInterventionType === 'default' +SAMPLE_INTERVENTION_TYPES.includes(selectedInterventionType as SampleInterventionType)
- Split the long line for better readability:
selectedPlantLocation && selectedPlantLocation.type !== 'single-tree-registration' && SAMPLE_INTERVENTION_TYPES.includes(selectedInterventionType as SampleInterventionType) && viewState.zoom > 14 && selectedPlantLocation.sampleInterventions
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/features/projectsV2/ProjectsMap/microComponents/PlantLocations.tsx
(1 hunks)
🔇 Additional comments (1)
src/features/projectsV2/ProjectsMap/microComponents/PlantLocations.tsx (1)
223-223
: Verify consistent usage of intervention types across the codebase.Let's ensure these intervention types are used consistently throughout the codebase.
✅ Verification successful
Intervention types are used consistently across the codebase
The intervention types are properly defined in
src/utils/constants/intervention.ts
and used consistently throughout the codebase for type-safe conditional rendering, database queries, and analytics. The specific combination in the review is valid for controlling sample tree visibility.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Search for hardcoded intervention types to ensure consistent usage echo "Searching for intervention type strings..." rg -A 2 "'multi-tree-registration'|'enrichment-planting'|'single-tree-registration'" --type typescript echo -e "\nSearching for type definitions..." ast-grep --pattern 'type $_ = $$$"multi-tree-registration"$$$' --lang typescriptLength of output: 418
Script:
#!/bin/bash # Search for intervention type strings and their definitions echo "Searching for intervention type strings..." rg -A 2 "'multi-tree-registration'|'enrichment-planting'|'single-tree-registration'" --type-add 'typescript:*.{ts,tsx}' -t typescript echo -e "\nSearching for type/enum/const definitions..." ast-grep --pattern 'type $_ = $$$"multi-tree-registration"$$$|"enrichment-planting"$$$|"single-tree-registration"$$$' --lang typescript echo -e "\nSearching for enum definitions..." ast-grep --pattern 'enum $_ { $$$ }' --lang typescript echo -e "\nSearching for const definitions..." rg "const.*=.*('multi-tree-registration'|'enrichment-planting'|'single-tree-registration')" --type-add 'typescript:*.{ts,tsx}' -t typescriptLength of output: 30067
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.
Looks good to me.
Changes in this pull request:
In this PR intervention filter condition has been added to the PlantLocation component to ensure that sample trees are hidden on the map when an intervention without sample trees is selected.
@sunil-sabat