-
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): add missing sorting and modify organization filter #17936
Conversation
WalkthroughThis pull request introduces a new sorting mechanism in the grant cards list component. The grants are sorted either by the most recently updated timestamp or alphabetically based on a new Changes
Sequence Diagram(s)sequenceDiagram
participant GC as GrantCardsList Component
participant DT as Grant Data
GC->>DT: Initialize grantItems using spread operator
GC->>GC: Check if multiple grant items exist
alt Sorting is MostRecentlyUpdatedFirst
GC->>DT: Sort grantItems by lastUpdateTimestamp (ascending)
else Sorting is Alphabetical
GC->>DT: Sort grantItems by name (alphabetically)
end
GC->>GC: Map sorted grantItems to cards for display
Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches
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 (2)
apps/web/screens/Grants/SearchResults/SearchResultsFilter.tsx (1)
136-146
: Consider making organization filter options configurable.The organization filter options are currently hardcoded. Consider moving these to a configuration file or fetching them from an API to improve maintainability and make future organization changes easier to manage.
- filters: [ - { - value: 'rannis', - label: 'Rannís', - }, - { - value: 'umhverfisstofnun', - label: 'Umhverfis- og orkustofnun', - }, - ], + filters: ORGANIZATION_FILTERS, // Import from a config fileapps/web/components/GrantCardsList/GrantCardsList.tsx (1)
169-173
: Consider simplifying the date comparison.The timestamp comparison can be simplified by directly comparing the ISO strings, as they are in a format that allows lexicographical comparison.
- grantItems.sort( - (a, b) => - new Date(a.lastUpdateTimestamp).getTime() - - new Date(b.lastUpdateTimestamp).getTime(), - ) + grantItems.sort((a, b) => + a.lastUpdateTimestamp.localeCompare(b.lastUpdateTimestamp) + )
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/web/components/GrantCardsList/GrantCardsList.tsx
(3 hunks)apps/web/screens/Grants/SearchResults/SearchResultsFilter.tsx
(1 hunks)libs/cms/src/lib/models/grant.model.ts
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`apps/**/*`: "Confirm that the code adheres to the following...
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."
apps/web/screens/Grants/SearchResults/SearchResultsFilter.tsx
apps/web/components/GrantCardsList/GrantCardsList.tsx
`libs/**/*`: "Confirm that the code adheres to the following...
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."
libs/cms/src/lib/models/grant.model.ts
🔇 Additional comments (2)
libs/cms/src/lib/models/grant.model.ts (1)
38-39
: LGTM! Well-implemented timestamp field.The implementation of
lastUpdateTimestamp
is robust:
- Proper GraphQL field decoration
- Non-nullable field type
- Fallback to creation timestamp using nullish coalescing
Also applies to: 154-154
apps/web/components/GrantCardsList/GrantCardsList.tsx (1)
126-127
: LGTM! Clean implementation of sorting functionality.The implementation is well-structured:
- Creates a new array to avoid mutations
- Applies sorting only when needed (multiple items)
- Clear and readable sorting logic
Also applies to: 167-177
View your CI Pipeline Execution ↗ for commit c3deac3.
☁️ Nx Cloud last updated this comment at |
fix: add missing sorting and modify organization filter
What
orkustofnun
toumhverfisstofnun
Checklist:
Summary by CodeRabbit