-
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(signature-colletion): remove candidate if all lists removed #16425
Conversation
WalkthroughThe pull request includes modifications to several files related to the parliamentary list creation service. Key changes involve simplifying dependencies, enhancing method readability, and streamlining logic for candidate validation. Additionally, API definitions have been updated to include an Changes
Possibly related PRs
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: 4
🧹 Outside diff range and nitpick comments (1)
libs/application/template-api-modules/src/lib/modules/templates/signature-collection/parliamentary-list-creation/parliamentary-list-creation.service.ts (1)
Line range hint
46-62
: Approved changes with a minor suggestion.The modifications to the
parliamentaryCollection
method improve code readability and simplify the logic. The added comment provides valuable context for the implementation. These changes align well with our coding guidelines for reusability and TypeScript usage.Consider using the non-null assertion operator (
!
) forauth.nationalId
to avoid potential TypeScript errors, as it's a crucial part of the logic:(c) => c.nationalId.replace('-', '') === auth.nationalId!,This change ensures that TypeScript understands that
auth.nationalId
will always be defined in this context.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (4)
- libs/application/template-api-modules/src/lib/modules/templates/signature-collection/parliamentary-list-creation/parliamentary-list-creation.service.ts (2 hunks)
- libs/application/templates/signature-collection/parliamentary-list-creation/src/dataProviders/index.ts (1 hunks)
- libs/application/templates/signature-collection/parliamentary-list-creation/src/lib/errors.ts (1 hunks)
- libs/clients/signature-collection/src/lib/signature-collection.service.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
libs/application/template-api-modules/src/lib/modules/templates/signature-collection/parliamentary-list-creation/parliamentary-list-creation.service.ts (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."
libs/application/templates/signature-collection/parliamentary-list-creation/src/dataProviders/index.ts (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."
libs/application/templates/signature-collection/parliamentary-list-creation/src/lib/errors.ts (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."
libs/clients/signature-collection/src/lib/signature-collection.service.ts (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 (5)
libs/application/templates/signature-collection/parliamentary-list-creation/src/dataProviders/index.ts (1)
5-5
: LGTM! The addition of theorder
property enhances API structure.The changes introduce an
order
property to each API definition, which provides a clear sequence for these APIs. This addition:
- Improves the structure and organization of the API definitions.
- Could facilitate easier processing or rendering of these APIs in a specific order.
- Maintains consistency across all three constants.
The modifications align well with the coding guidelines for files in the
libs
directory, ensuring reusability and proper TypeScript usage.Also applies to: 10-10, 15-15
libs/application/templates/signature-collection/parliamentary-list-creation/src/lib/errors.ts (1)
37-37
: Improved error message clarity and user guidanceThe update to the
alreadyCandidate
error message is a positive change. It not only informs users that they are already candidates but also guides them to where they can find more information about their candidacy ("Mínar Síður"). This enhancement improves the user experience by providing clear next steps, which is particularly important in error scenarios.libs/application/template-api-modules/src/lib/modules/templates/signature-collection/parliamentary-list-creation/parliamentary-list-creation.service.ts (1)
Line range hint
1-162
: Compliance with coding guidelines confirmed.This file adheres to the coding guidelines for
libs/**/*
:
- It uses TypeScript effectively for defining props and exporting types.
- The service is designed to be reusable across different NextJS apps.
- There are no apparent issues with tree-shaking or bundling practices.
libs/clients/signature-collection/src/lib/signature-collection.service.ts (2)
419-419
: Confirm logic for detecting invalid signatures.The assignment
const noInvalidSignature = !signatures?.find((s) => !s.valid)
relies on the assumption that ifsignatures
is undefined or empty, there are no invalid signatures. Ensure this aligns with the intended logic.Run the following script to test the behavior when
signatures
is undefined or empty:#!/bin/bash # Description: Verify noInvalidSignature logic when signatures are undefined or empty. # Expected: noInvalidSignature should be true when signatures is undefined or an empty array. echo "Testing with signatures undefined:" node -e " const signatures = undefined; const noInvalidSignature = !signatures?.find((s) => !s.valid); console.log('noInvalidSignature (undefined):', noInvalidSignature); " echo "Testing with signatures empty array:" node -e " const signatures = []; const noInvalidSignature = !signatures?.find((s) => !s.valid); console.log('noInvalidSignature (empty array):', noInvalidSignature); "This script will confirm that
noInvalidSignature
evaluates totrue
whensignatures
is undefined or empty.
372-374
: Handle potential parsing errors of candidate ID.The
parseInt(id)
function may returnNaN
ifid
is not a valid number string, which could causeframbodIDDelete
to fail.Run the following script to verify that all candidate IDs are valid numeric strings:
This script searches for instances where
candidate.id
is used and extracts the IDs to ensure they are numeric.
libs/clients/signature-collection/src/lib/signature-collection.service.ts
Outdated
Show resolved
Hide resolved
Datadog ReportAll test runs ✅ 5 Total Test Services: 0 Failed, 5 Passed Test Services
🔻 Code Coverage Decreases vs Default Branch (1)
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16425 +/- ##
=======================================
Coverage 36.72% 36.72%
=======================================
Files 6809 6809
Lines 141163 141134 -29
Branches 40246 40235 -11
=======================================
- Hits 51844 51835 -9
+ Misses 89319 89299 -20
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 9 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
….service.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Minor suggestions, need to merge for release asap
* fix: remove candidate if all lists removed * fix: remove candidate if all lists removed make sure has candidate id * chore: nx format:write update dirty files * Update libs/clients/signature-collection/src/lib/signature-collection.service.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: andes-it <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
* fix(signature-colletion): remove candidate if all lists removed (#16425) * fix: remove candidate if all lists removed * fix: remove candidate if all lists removed make sure has candidate id * chore: nx format:write update dirty files * Update libs/clients/signature-collection/src/lib/signature-collection.service.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: andes-it <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(signature-collections): fixes 16.10 (#16423) * fix(signature-collections): fixes 16.10 * tweak --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(signature-collection): sc fixes 16.10 (#16428) * fix(signature-collection): updating card * cleanup * chore: nx format:write update dirty files --------- Co-authored-by: andes-it <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --------- Co-authored-by: Alex Diljar Birkisbur Hellsing <[email protected]> Co-authored-by: andes-it <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: albinagu <[email protected]>
Candidate is not removed when the last list is removed. This fixes that
Summary by CodeRabbit
New Features
order
property for better structure.Improvements