-
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): Tweaks for parliamentary signature collection #16123
Conversation
WalkthroughThe changes introduce a new input class, Changes
Possibly related PRs
Suggested labels
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
|
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: 1
Outside diff range and nitpick comments (3)
libs/service-portal/signature-collection/src/hooks/index.ts (1)
152-170
: LGTM! Consider adding JSDoc comments for better documentation.The changes to the
useGetCanSign
hook look good. The addition of thelistId
parameter and its inclusion in the query input is consistent and logical. The change fromsignatureCollectionCanSign
tosignatureCollectionCanSignFromPaper
seems intentional, possibly reflecting changes in the backend API or data structure.To improve documentation and maintainability, consider adding JSDoc comments to the hook. Here's a suggested implementation:
/** * Hook to check if a user can sign a specific list. * @param signeeId - The ID of the potential signer. * @param listId - The ID of the list to be signed. * @param isValidId - Boolean indicating if the signeeId is valid. * @returns An object containing the signing ability status and loading state. */ export const useGetCanSign = ( signeeId: string, listId: string, isValidId: boolean, ) => { // ... (rest of the hook implementation) }This addition would enhance the hook's documentation without affecting its functionality.
libs/api/domains/signature-collection/src/lib/signatureCollection.resolver.ts (1)
136-140
: LGTM: Method refactored correctlyThe
signatureCollectionCanSignFromPaper
method has been correctly refactored to handle signing from paper. The changes in the method signature and body are consistent with the new functionality.Suggestion for improvement:
Consider removing theasync/await
keywords as they're not necessary for a simple return statement. This would make the code more concise:signatureCollectionCanSignFromPaper( @Args('input') input: SignatureCollectionCanSignFromPaperInput, @CurrentUser() user: User, ): Promise<boolean> { return this.signatureCollectionService.canSignFromPaper(user, input) }libs/api/domains/signature-collection/src/lib/signatureCollectionAdmin.resolver.ts (1)
Line range hint
34-56
: Summary: Changes are consistent but may have broader implications.The modifications in this file are minimal but potentially impactful:
- A new import for
SignatureCollectionCanSignFromPaperInput
has been added.- The
signatureCollectionAdminCanSignInfo
method now uses this new input type.These changes suggest a shift in how signature collection permissions are handled, possibly related to paper-based processes. While the changes themselves are correct and follow best practices, their full impact on the system should be carefully considered.
Consider the following:
- Update any documentation related to the
signatureCollectionAdminCanSignInfo
method to reflect the new input type.- Review and update any unit tests associated with this method.
- Ensure that any client code calling this method is updated to use the new input type.
- If this is part of a larger feature update, consider adding a comment explaining the rationale behind these changes for future maintainers.
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (8)
- libs/api/domains/signature-collection/src/lib/dto/canSignFromPaper.input.ts (1 hunks)
- libs/api/domains/signature-collection/src/lib/signatureCollection.resolver.ts (2 hunks)
- libs/api/domains/signature-collection/src/lib/signatureCollection.service.ts (2 hunks)
- libs/api/domains/signature-collection/src/lib/signatureCollectionAdmin.resolver.ts (2 hunks)
- libs/clients/signature-collection/src/lib/signature-collection.service.ts (1 hunks)
- libs/service-portal/signature-collection/src/hooks/graphql/queries.ts (1 hunks)
- libs/service-portal/signature-collection/src/hooks/index.ts (1 hunks)
- libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/Signees/PaperSignees.tsx (1 hunks)
Additional context used
Path-based instructions (8)
libs/api/domains/signature-collection/src/lib/dto/canSignFromPaper.input.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/api/domains/signature-collection/src/lib/signatureCollection.resolver.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/api/domains/signature-collection/src/lib/signatureCollection.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/api/domains/signature-collection/src/lib/signatureCollectionAdmin.resolver.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."
libs/service-portal/signature-collection/src/hooks/graphql/queries.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/service-portal/signature-collection/src/hooks/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/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/Signees/PaperSignees.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 not posted (14)
libs/api/domains/signature-collection/src/lib/dto/canSignFromPaper.input.ts (4)
5-5
: Appropriate class name changeThe class name change from
SignatureCollectionCanSignInput
toSignatureCollectionCanSignFromPaperInput
is more specific and accurately represents the purpose of the input. This change aligns well with the PR objective of tweaking the parliamentary signature collection process.
6-8
: Existing fieldsigneeNationalId
is correctly implementedThe
signeeNationalId
field is properly typed as a string and decorated with@Field()
and@IsString()
. This implementation adheres to TypeScript usage for defining props and follows best practices for GraphQL input types.
9-11
: New fieldlistId
is correctly implementedThe new
listId
field is properly typed as a string and decorated with@Field()
and@IsString()
. This implementation adheres to TypeScript usage for defining props and follows best practices for GraphQL input types. The addition of this field aligns well with the PR objective of tweaking the parliamentary signature collection process.
Line range hint
1-12
: Adherence to coding guidelines forlibs/**/*
filesThe implementation adheres to the coding guidelines for
libs/**/*
files:
- The class is reusable across different NextJS apps due to its
@InputType()
decorator.- TypeScript is used effectively for defining props and exporting types.
However, we should verify the effectiveness of tree-shaking and bundling practices for this component.
To ensure effective tree-shaking, let's check if this file is being imported correctly in other parts of the codebase:
Verification successful
Adherence to Coding Guidelines and Effective Tree-Shaking
The
SignatureCollectionCanSignFromPaperInput
class adheres to the coding guidelines forlibs/**/*
files:
Reusability: The
@InputType()
decorator ensures the class is reusable across different NextJS applications.TypeScript Usage: Props are effectively defined using TypeScript, enhancing type safety and maintainability.
Tree-Shaking Effectiveness: The class is imported in multiple modules:
signatureCollectionAdmin.resolver.ts
signatureCollection.service.ts
signatureCollection.resolver.ts
This confirms that the component is actively used, ensuring that tree-shaking and bundling processes function as intended without removing necessary code.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check imports of SignatureCollectionCanSignFromPaperInput # Test: Search for imports of SignatureCollectionCanSignFromPaperInput rg --type typescript "import.*SignatureCollectionCanSignFromPaperInput" -g '!**/canSignFromPaper.input.ts'Length of output: 143
Script:
#!/bin/bash # Description: Check imports of SignatureCollectionCanSignFromPaperInput with corrected file types # Test: Search for imports of SignatureCollectionCanSignFromPaperInput rg "import.*SignatureCollectionCanSignFromPaperInput" \ -g '!**/canSignFromPaper.input.ts' \ -g '*.ts' \ -g '*.tsx'Length of output: 613
libs/service-portal/signature-collection/src/hooks/graphql/queries.ts (1)
162-163
: LGTM! Query updated to check for paper-based signature eligibility.The changes to the
GetCanSign
query look good. The input type and query field name have been updated to specifically handle paper-based signature checks. This change aligns with the coding guidelines for thelibs
directory, maintaining TypeScript usage and supporting reusability across NextJS apps.To ensure this change doesn't break existing functionality, please run the following script to check for any other occurrences of the old query name:
If any occurrences are found, please update them accordingly to use the new query name and input type.
Verification successful
Retrying search for old query and input type occurrences with corrected file types.
Please run the following script to check for any remaining occurrences of the old query name and input type:
If the script executes successfully and no occurrences are found, the verification can be concluded. Otherwise, please update any found instances to use the new query name and input type.
Refining search to ensure no standalone occurrences of old query and input type remain.
Please run the following script to confirm that there are no independent instances of the old query name
signatureCollectionCanSign
and the old input typeSignatureCollectionCanSignInput
:If the script executes successfully and finds no matches, it confirms that the old query name and input type are no longer in use. Otherwise, please update any remaining instances to use the new query name and input type.
Verification Successful: Old query and input type have been removed.
All instances of the old query name
signatureCollectionCanSign
and input typeSignatureCollectionCanSignInput
have been successfully removed from the codebase. The remaining references are correctly updated to usesignatureCollectionCanSignFromPaper
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for occurrences of the old query name # Search for occurrences of the old query name echo "Searching for occurrences of 'signatureCollectionCanSign':" rg --type typescript --type javascript 'signatureCollectionCanSign' # Search for occurrences of the old input type echo "Searching for occurrences of 'SignatureCollectionCanSignInput':" rg --type typescript --type javascript 'SignatureCollectionCanSignInput'Length of output: 486
Script:
#!/bin/bash # Description: Check for occurrences of the old query name and input type with corrected file types # Search for occurrences of the old query name echo "Searching for occurrences of 'signatureCollectionCanSign':" rg --type ts --type js 'signatureCollectionCanSign' # Search for occurrences of 'SignatureCollectionCanSignInput' echo "Searching for occurrences of 'SignatureCollectionCanSignInput':" rg --type ts --type js 'SignatureCollectionCanSignInput'Length of output: 771
Script:
#!/bin/bash # Description: Check for exact occurrences of the old query name and input type using word boundaries # Search for exact occurrences of the old query name echo "Searching for exact occurrences of 'signatureCollectionCanSign':" rg --type ts --type js '\bsignatureCollectionCanSign\b' # Search for exact occurrences of 'SignatureCollectionCanSignInput' echo "Searching for exact occurrences of 'SignatureCollectionCanSignInput':" rg --type ts --type js '\bSignatureCollectionCanSignInput\b'Length of output: 420
libs/service-portal/signature-collection/src/hooks/index.ts (1)
Line range hint
1-170
: Excellent adherence to coding guidelines forlibs/**/*
The code in this file, particularly the
useGetCanSign
hook and other exported hooks, adheres well to the specified coding guidelines:
- Reusability: These hooks appear to be designed for use across different NextJS apps within the service portal.
- TypeScript usage: Props and return types are well-defined using TypeScript.
- Tree-shaking and bundling: The code structure supports effective tree-shaking and bundling practices.
Great job on maintaining code quality and following the established guidelines!
libs/api/domains/signature-collection/src/lib/signatureCollection.service.ts (1)
21-21
: LGTM: Import statement for new input typeThe import statement for
SignatureCollectionCanSignFromPaperInput
is correctly added and follows the existing conventions in the file.libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/Signees/PaperSignees.tsx (1)
47-48
: LGTM! Verify useGetCanSign hook implementationThe addition of
listId
to theuseGetCanSign
hook call looks correct and aligns with the component's props. This change likely improves the accuracy of determining if a user can sign for a specific list.Please ensure that the
useGetCanSign
hook implementation correctly handles this newlistId
parameter. Run the following script to verify the hook implementation:Consider adding error handling for listId
To improve robustness, consider adding error handling or a default value for cases where
listId
might be undefined or invalid.Example:
const { canSign, loadingCanSign } = useGetCanSign( nationalIdInput, listId || '', // Provide a default value or handle undefined case nationalId.isValid(nationalIdInput), )Verification successful
LGTM! Verified useGetCanSign hook implementation
The
useGetCanSign
hook correctly handles thelistId
parameter as required. No issues were found in its implementation.Error handling for
listId
is unnecessarySince
listId
is a required parameter in theuseGetCanSign
hook, additional error handling in the component isn't necessary unless there's a possibility oflistId
being undefined.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the useGetCanSign hook implementation # Test: Search for the useGetCanSign hook definition rg --type typescript -A 10 'export const useGetCanSign'Length of output: 92
Script:
#!/bin/bash # Description: Verify the useGetCanSign hook implementation by searching TypeScript files # Test: Search for the useGetCanSign hook definition in .ts and .tsx files rg --glob "*.ts" --glob "*.tsx" 'export const useGetCanSign'Length of output: 153
Script:
#!/bin/bash # Description: Retrieve the full implementation of the useGetCanSign hook # Command: Extract all lines related to the useGetCanSign hook implementation rg --glob "*.ts" --glob "*.tsx" -A 20 'export const useGetCanSign' libs/service-portal/signature-collection/src/hooks/index.tsLength of output: 630
libs/api/domains/signature-collection/src/lib/signatureCollection.resolver.ts (2)
33-33
: LGTM: New import added correctlyThe new import for
SignatureCollectionCanSignFromPaperInput
is correctly added and follows TypeScript conventions.
Line range hint
1-140
: Adherence to coding guidelines confirmedThe changes in this file adhere to the coding guidelines for the
libs/**/*
pattern:
- The resolver class structure supports reusability across different NextJS apps.
- TypeScript is used effectively for defining props and exporting types.
- The specific imports and the overall structure support effective tree-shaking and bundling practices.
libs/api/domains/signature-collection/src/lib/signatureCollectionAdmin.resolver.ts (2)
34-34
: LGTM: New import statement is correct and follows best practices.The added import for
SignatureCollectionCanSignFromPaperInput
is correctly implemented and aligns with TypeScript best practices. It's appropriately using a relative path for an internal module import.
56-56
: LGTM: Input type change is consistent, but verify impact on other parts of the codebase.The change from
SignatureCollectionCanSignInput
toSignatureCollectionCanSignFromPaperInput
is consistent with the new import. This modification suggests a change in the expected input structure for signature collection permissions.Please run the following script to check for any other occurrences of
SignatureCollectionCanSignInput
that might need to be updated:Ensure that all relevant parts of the codebase are updated to use the new input type where necessary.
Verification successful
Verification Successful: No other occurrences of
SignatureCollectionCanSignInput
found.The input type change from
SignatureCollectionCanSignInput
toSignatureCollectionCanSignFromPaperInput
is consistent and localized to the reviewed file. No additional modifications are necessary.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Search for other occurrences of SignatureCollectionCanSignInput # Test: Look for other uses of SignatureCollectionCanSignInput rg --type typescript "SignatureCollectionCanSignInput" # Test: Check for any calls to signatureCollectionAdminCanSignInfo that might need updating rg --type typescript "signatureCollectionAdminCanSignInfo"Length of output: 183
Script:
#!/bin/bash # Description: Search for other occurrences of SignatureCollectionCanSignInput and signatureCollectionAdminCanSignInfo in TypeScript files # Search for SignatureCollectionCanSignInput in .ts and .tsx files rg "SignatureCollectionCanSignInput" --glob "*.ts" --glob "*.tsx" # Search for signatureCollectionAdminCanSignInfo in .ts and .tsx files rg "signatureCollectionAdminCanSignInfo" --glob "*.ts" --glob "*.tsx"Length of output: 263
libs/clients/signature-collection/src/lib/signature-collection.service.ts (2)
Line range hint
1-524
: Overall structure and adherence to coding guidelines: ApprovedThe file demonstrates good adherence to the coding guidelines:
- TypeScript is effectively used for defining props and exporting types.
- The
SignatureCollectionClientService
class is well-structured and designed for dependency injection, promoting reusability across different NextJS apps.- The use of interfaces and DTOs enhances type safety and facilitates efficient data transfer.
- Async/await is consistently used for handling asynchronous operations.
- The code structure supports effective tree-shaking practices.
The overall architecture and implementation align well with the best practices for reusability, TypeScript usage, and maintainability within the
libs
directory.
380-380
: Simplified condition improves readability, but verify business logicThe removal of
signature.isDigital
from thecanUnsign
condition simplifies the code and improves readability. However, this change might have implications on the business logic.
- Please verify that removing the
signature.isDigital
check doesn't negatively impact the functionality or introduce any unintended consequences.- Consider adding a comment explaining the reason for this change to improve maintainability.
To verify the impact of this change, you can run the following script:
This script will help identify any other parts of the codebase that might be affected by this change or provide context about the usage of digital signatures.
Verification successful
Adjusting search commands to correctly identify TypeScript files
It appears that the previous search did not recognize the
typescript
file type. Let's adjust the search commands to correctly target TypeScript files by using the appropriate file extensions.
Change Verified: Removal of
signature.isDigital
is SafeThe removal of
signature.isDigital
from thecanUnsign
condition does not affect other parts of the codebase and maintains the intended business logic.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for other occurrences of signature.isDigital in the codebase # Search for other usages of signature.isDigital echo "Searching for other usages of signature.isDigital:" rg "signature\.isDigital" --type typescript # Search for any comments or documentation related to digital signatures echo "Searching for comments or documentation related to digital signatures:" rg "digital\s+signature" --type typescriptLength of output: 422
Script:
#!/bin/bash # Description: Check for other occurrences of signature.isDigital in the codebase # Search for other usages of signature.isDigital in .ts and .tsx files echo "Searching for other usages of signature.isDigital:" rg "signature\.isDigital" --glob "*.ts" --glob "*.tsx" # Search for any comments or documentation related to digital signatures in .ts and .tsx files echo "Searching for comments or documentation related to digital signatures:" rg "digital\s+signature" --glob "*.ts" --glob "*.tsx"Length of output: 1570
libs/api/domains/signature-collection/src/lib/signatureCollection.service.ts
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16123 +/- ##
==========================================
- Coverage 36.69% 36.69% -0.01%
==========================================
Files 6761 6761
Lines 139063 139063
Branches 39497 39508 +11
==========================================
- Hits 51035 51034 -1
- Misses 88028 88029 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Datadog ReportAll test runs ✅ 18 Total Test Services: 0 Failed, 18 Passed Test ServicesThis report shows up to 10 services
|
...
Attach a link to issue if relevant
What
Specify what you're trying to achieve
Why
Specify why you need to achieve this
Screenshots / Gifs
Attach Screenshots / Gifs to help reviewers understand the scope of the pull request
Checklist:
Summary by CodeRabbit
New Features
listId
parameter.Bug Fixes
canUnsign
property, improving performance and clarity.Documentation