Skip to content
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

feat(auth-admin): View delegation and refactor access card #16243

Merged
merged 34 commits into from
Oct 9, 2024

Conversation

magnearun
Copy link
Contributor

@magnearun magnearun commented Oct 2, 2024

What

Refactor AccessCard, now it displays actions depending on what functions are provided, if onDelete is provided a delete button is displayed etc, moving the logic about when different actions are displayed out side of the card.

General mandate delegations should only have the View action in "From me" list í Access control

Adds createdBy field to Delegations, used to display who created the general mandate delegations

Updates the View modal to dislpay referenceId and createdby when viewing a general mandate delegation.

Why

Now making changes to different actions on the card you can be confident you are not messing up what actions show up on other lists elsewhere.

Match design and show correct actions in correct places

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a loading state in the Create Delegation Confirm Modal for improved user feedback during operations.
    • Added a Delegation View Modal for displaying detailed information about delegations.
    • Implemented a Delegation Delete Modal for confirming deletion actions.
  • Improvements

    • Updated delegation type labels for better clarity and consistency in the Create Delegation Screen.
    • Enhanced type safety for delegation types, ensuring more reliable operations within the delegation process.
    • Improved loading state management in the delegation creation flow for a smoother user experience.
  • Localization

    • Continued enhancements to localization for better accessibility and user understanding, including new message definitions for delegation-related information.
    • Added new messages to support additional context about delegation creators and other relevant details.

Copy link
Contributor

coderabbitai bot commented Oct 2, 2024

Walkthrough

The changes in this pull request involve modifications across several components related to delegation management. A new loading boolean prop is added to the CreateDelegationConfirmModal component, enhancing its ability to manage loading states. The delegation type handling is updated for better type safety, with the removal of the typeLabels object. Additionally, new components for viewing and deleting delegations are introduced, and the GraphQL query for delegations is enhanced to include creator information. Overall, these updates improve the functionality and user experience related to delegations.

Changes

File Change Summary
libs/portals/admin/delegation-admin/src/components/CreateDelegationConfirmModal.tsx Added loading prop to CreateDelegationConfirmModalProps, removed typeLabels, and updated title localization.
libs/portals/admin/delegation-admin/src/screens/CreateDelegation/CreateDelegation.tsx Imported AuthDelegationType, updated typeOptions, added loading state, and modified handling of showConfirmModal.
libs/portals/admin/delegation-admin/src/components/DelegationList.tsx Refactored deletion logic, added DelegationDeleteModal and DelegationViewModal components, and updated AccessCard.
libs/portals/admin/delegation-admin/src/screens/DelegationAdminDetails/DelegationAdmin.graphql Added createdBy field to getCustomDelegationsAdmin query for incoming and outgoing delegations.
libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx Updated AccessCardProps interface, made onDelete optional, and added onEdit and onRenew properties.
libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx Introduced DelegationViewModal component for displaying delegation details.
libs/portals/shared-modules/delegations/src/components/delegations/incoming/DelegationsIncoming.tsx Updated to use DelegationViewModal and refined delegation action handling.
libs/portals/shared-modules/delegations/src/index.ts Added export for DelegationViewModal component.
libs/portals/shared-modules/delegations/src/lib/messages.ts Added new message definitions for internationalization related to delegations.

Possibly related PRs

Suggested reviewers

  • thorkellmani

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 2, 2024

Datadog Report

All test runs 8f838cd 🔗

15 Total Test Services: 0 Failed, 15 Passed
🔻 Test Sessions change in coverage: 2 decreased, 1 increased (+0.02%), 31 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-web 0 0 0 2 0 8.52s 1 no change Link
api 0 0 0 4 0 2.61s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 12.2s 1 decreased (-0.26%) Link
application-system-api 0 0 0 120 2 3m 38.59s 1 no change Link
application-template-api-modules 0 0 0 134 0 2m 9.02s 1 no change Link
auth-api-lib 0 0 0 20 0 35.69s 1 no change Link
services-auth-admin-api 0 0 0 128 0 3m 49.7s 1 no change Link
services-auth-delegation-api 0 0 0 256 0 3m 4.83s 1 no change Link
services-auth-ids-api 0 0 0 152 0 1m 14.5s 1 no change Link
services-auth-personal-representative 0 0 0 59 0 1m 29.81s 1 decreased (-0.02%) Link

🔻 Code Coverage Decreases vs Default Branch (2)

  • api-domains-auth-admin - jest 47.96% (-0.26%) - Details
  • services-auth-personal-representative - jest 43.98% (-0.02%) - Details

Copy link

codecov bot commented Oct 2, 2024

Codecov Report

Attention: Patch coverage is 14.28571% with 6 lines in your changes missing coverage. Please review.

Project coverage is 36.78%. Comparing base (386d587) to head (1d9272b).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...c/lib/delegationAdmin/delegation-admin.resolver.ts 0.00% 6 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16243      +/-   ##
==========================================
- Coverage   36.78%   36.78%   -0.01%     
==========================================
  Files        6805     6805              
  Lines      140832   140839       +7     
  Branches    40023    40025       +2     
==========================================
+ Hits        51812    51814       +2     
- Misses      89020    89025       +5     
Flag Coverage Δ
air-discount-scheme-web 0.00% <ø> (ø)
api 3.37% <ø> (ø)
api-domains-auth-admin 48.48% <0.00%> (-0.29%) ⬇️
api-domains-health-insurance 34.72% <ø> (ø)
application-system-api 41.68% <ø> (ø)
application-template-api-modules 24.03% <ø> (ø)
application-templates-accident-notification 29.44% <ø> (ø)
application-ui-shell 21.29% <ø> (ø)
clients-license-client 1.83% <ø> (ø)
download-service 44.19% <ø> (ø)
license-api 42.66% <ø> (-0.06%) ⬇️
services-auth-admin-api 52.13% <100.00%> (+<0.01%) ⬆️
services-auth-delegation-api 57.66% <100.00%> (+<0.01%) ⬆️
services-auth-ids-api 51.72% <100.00%> (+0.01%) ⬆️
services-auth-personal-representative 45.42% <100.00%> (+0.03%) ⬆️
services-auth-personal-representative-public 41.49% <100.00%> (-0.04%) ⬇️
services-auth-public-api 49.21% <100.00%> (+<0.01%) ⬆️
services-user-notification 47.04% <ø> (+0.02%) ⬆️
services-user-profile 62.17% <ø> (+0.07%) ⬆️
web 1.83% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...-api-lib/src/lib/delegations/dto/delegation.dto.ts 100.00% <100.00%> (ø)
...lib/src/lib/delegations/models/delegation.model.ts 95.65% <ø> (ø)
...c/lib/delegationAdmin/delegation-admin.resolver.ts 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 386d587...1d9272b. Read the comment docs.

@magnearun magnearun changed the title Feat/view delegation and refactor access card feat(auth-admin): View delegation and refactor access card Oct 3, 2024
@magnearun magnearun marked this pull request as ready for review October 3, 2024 10:32
@magnearun magnearun requested review from a team as code owners October 3, 2024 10:32
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 13

🧹 Outside diff range and nitpick comments (11)
libs/portals/admin/delegation-admin/src/components/DelegationList.tsx (3)

25-26: LGTM! Consider enhancing type safety for the variant prop.

The changes to the AccessCard props align well with the refactoring objectives. The removal of canModify and the change from direction to variant streamline the component's API.

To further improve type safety and maintain consistency with the DelegationProps interface, consider using a type assertion or updating the AccessCard component to accept the same direction type:

variant={direction as 'incoming' | 'outgoing'}

This ensures that the variant prop matches the expected values defined in the DelegationProps interface.


27-39: LGTM! Consider adding error handling to the delete operation.

The new implementation of the onDelete prop is well-structured and aligns with the PR objectives. The conditional check for delegation.referenceId ensures that the delete action is only available when appropriate.

To further improve the robustness of the code, consider adding error handling:

onDelete={
  !!delegation.referenceId &&
  (async () => {
    try {
      const { data } = await deleteCustomDelegationAdminMutation({
        variables: {
          id: delegation.id as string,
        },
      })
      if (data) {
        revalidate()
      }
    } catch (error) {
      console.error('Error deleting delegation:', error)
      // Consider adding user feedback here, e.g., showing an error toast
    }
  })
}

This addition will ensure that any errors during the deletion process are properly caught and logged, improving the overall reliability of the application.


Line range hint 1-45: Enhance adherence to coding guidelines for library components.

While the component generally follows the guidelines for libs/**/*, consider the following improvements:

  1. Export the DelegationProps interface to allow reuse in other components:
export interface DelegationProps {
  direction: 'incoming' | 'outgoing'
  delegationsList: AuthCustomDelegation[]
}
  1. To improve tree-shaking, consider exporting the component as a named export instead of default:
export const DelegationList = ({ delegationsList, direction }: DelegationProps) => {
  // ... component implementation ...
}

These changes will enhance the reusability of the component and its types across different NextJS apps while also improving tree-shaking capabilities.

libs/api/mocks/src/domains/auth/factories.ts (1)

47-51: LGTM! Consider making the type field configurable.

The addition of the createdBy property aligns well with the PR objectives and follows the existing code style. Good job on maintaining consistency with the other properties in the factory.

A minor suggestion for improvement:

Consider making the type field configurable instead of hardcoding it as 'Person'. This would allow for more flexibility in generating mock data. Here's a possible implementation:

-  createdBy: () => ({
+  createdBy: (type = 'Person') => ({
     nationalId: createNationalId('person'),
     name: faker.name.findName(),
-    type: 'Person',
+    type,
   }),

This change would allow you to specify a different type when needed while keeping 'Person' as the default.

libs/api/domains/auth/src/lib/models/delegation.model.ts (1)

54-56: LGTM! Consider adding a comment for clarity.

The addition of the createdBy field to the Delegation abstract class is well-implemented and aligns with the PR objectives. The use of TypeScript for prop definition and the @Field decorator from @nestjs/graphql adheres to the coding guidelines.

Consider adding a brief comment explaining the purpose of the createdBy field for improved code documentation:

 @Field(() => Identity, { nullable: true })
+// Represents the identity of the user who created the delegation
 createdBy?: Identity
libs/api/domains/auth-admin/src/lib/delegationAdmin/delegation-admin.resolver.ts (1)

94-103: LGTM with a minor suggestion for improvement

The new resolveCreatedByIdentity method is well-implemented and adheres to the coding guidelines. It uses TypeScript, leverages the reusable IdentityLoader, and is part of a tree-shakeable resolver class.

To further improve type safety, consider explicitly typing the return value:

@ResolveField('createdBy', () => Identity, { nullable: true })
resolveCreatedByIdentity(
  @Loader(IdentityLoader) identityLoader: IdentityDataLoader,
  @Parent() customDelegation: DelegationDTO,
): Promise<Identity | null> {
  if (!customDelegation.createdByNationalId) {
    return Promise.resolve(null);
  }
  return identityLoader.load(customDelegation.createdByNationalId);
}

This change makes the return type explicit and ensures that the method always returns a Promise, maintaining consistency with other resolver methods.

libs/api/domains/auth/src/lib/resolvers/delegation.resolver.ts (1)

131-140: LGTM! Consider adding error handling.

The new resolveCreatedBy method is well-implemented and aligns with the PR objectives. It properly uses TypeScript, follows the existing coding patterns, and handles the case where createdByNationalId might not exist.

Consider adding error handling for the getIdentity call:

@ResolveField('createdBy', () => Identity, { nullable: true })
async resolveCreatedBy(
  @Parent() delegation: DelegationDTO,
): Promise<Identity | null> {
  if (!delegation.createdByNationalId) {
    return null;
  }

  try {
    return await this.identityService.getIdentity(delegation.createdByNationalId);
  } catch (error) {
    console.error(`Failed to resolve identity for createdByNationalId: ${delegation.createdByNationalId}`, error);
    return null;
  }
}

This change would ensure that any errors in fetching the identity are logged and don't cause the entire resolver to fail.

libs/portals/shared-modules/delegations/src/lib/messages.ts (2)

117-120: LGTM! Consider adding a description.

The createdBy message is correctly structured and aligns with the PR objectives. It follows the existing patterns in the file and contributes to the reusability of components across different NextJS apps.

Consider adding a description for this message to provide context for translators, similar to some other messages in this file. For example:

createdBy: {
  id: 'sp.access-control-delegations:created-by',
  defaultMessage: 'Skráð af',
  description: 'Label indicating who created the delegation',
},

238-241: LGTM! Consider adding a description.

The referenceId message is correctly structured and aligns with the PR objectives. It follows the existing patterns in the file and contributes to the reusability of components across different NextJS apps.

Consider adding a description for this message to provide context for translators. For example:

referenceId: {
  id: 'sp.access-control-delegations:reference-id',
  defaultMessage: 'Númer máls í Zendesk',
  description: 'Label for the Zendesk reference ID',
},
libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx (1)

207-210: LGTM: Proper TypeScript usage with a suggestion for improvement

The component demonstrates good use of TypeScript for defining props and types, aligning with the coding guidelines. The type casting on line 207 ensures type safety when accessing properties of different delegation types.

However, consider using a type guard function to determine the delegation type instead of type casting. This could improve type inference and make the code more robust:

function isOutgoingDelegation(delegation: AuthCustomDelegation): delegation is AuthCustomDelegationOutgoing {
  return 'to' in delegation;
}

// Usage
{isOutgoing
  ? isOutgoingDelegation(delegation) ? delegation.to.name : ''
  : 'from' in delegation ? delegation.from.name : ''}

This approach would provide better type safety and make the code more self-documenting.

libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx (1)

118-118: Ensure the image path in imgSrc is correct and accessible

The image path ./assets/images/skjaldarmerki.svg may not resolve correctly depending on the build configuration and directory structure. Consider importing the image directly or verifying that the relative path is correct in the context of the compiled code.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7a9c112 and e91f452.

📒 Files selected for processing (15)
  • libs/api/domains/auth-admin/src/lib/delegationAdmin/delegation-admin.resolver.ts (1 hunks)
  • libs/api/domains/auth/src/lib/models/delegation.model.ts (1 hunks)
  • libs/api/domains/auth/src/lib/resolvers/delegation.resolver.ts (1 hunks)
  • libs/api/mocks/src/domains/auth/factories.ts (1 hunks)
  • libs/auth-api-lib/src/lib/delegations/dto/delegation.dto.ts (1 hunks)
  • libs/auth-api-lib/src/lib/delegations/models/delegation.model.ts (1 hunks)
  • libs/portals/admin/delegation-admin/src/components/DelegationList.tsx (1 hunks)
  • libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx (6 hunks)
  • libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx (3 hunks)
  • libs/portals/shared-modules/delegations/src/components/delegations/incoming/DelegationIncoming.graphql (1 hunks)
  • libs/portals/shared-modules/delegations/src/components/delegations/incoming/DelegationsIncoming.tsx (4 hunks)
  • libs/portals/shared-modules/delegations/src/components/delegations/outgoing/DelegationsOutgoing.graphql (1 hunks)
  • libs/portals/shared-modules/delegations/src/components/delegations/outgoing/DelegationsOutgoing.tsx (5 hunks)
  • libs/portals/shared-modules/delegations/src/lib/messages.ts (2 hunks)
  • libs/portals/shared-modules/delegations/src/types/customDelegation.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (15)
libs/api/domains/auth-admin/src/lib/delegationAdmin/delegation-admin.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/auth/src/lib/models/delegation.model.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/auth/src/lib/resolvers/delegation.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/mocks/src/domains/auth/factories.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/auth-api-lib/src/lib/delegations/dto/delegation.dto.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/auth-api-lib/src/lib/delegations/models/delegation.model.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/portals/admin/delegation-admin/src/components/DelegationList.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."
libs/portals/shared-modules/delegations/src/components/access/AccessCard.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."
libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.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."
libs/portals/shared-modules/delegations/src/components/delegations/incoming/DelegationIncoming.graphql (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/portals/shared-modules/delegations/src/components/delegations/incoming/DelegationsIncoming.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."
libs/portals/shared-modules/delegations/src/components/delegations/outgoing/DelegationsOutgoing.graphql (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/portals/shared-modules/delegations/src/components/delegations/outgoing/DelegationsOutgoing.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."
libs/portals/shared-modules/delegations/src/lib/messages.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/portals/shared-modules/delegations/src/types/customDelegation.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 (19)
libs/portals/shared-modules/delegations/src/types/customDelegation.ts (2)

Line range hint 1-17: Well-structured types for reusability across NextJS apps.

The file demonstrates good practices in TypeScript usage:

  1. Clear type definitions using GraphQL query results.
  2. Effective use of utility types like Extract.
  3. Export of well-defined types for reuse.

These practices align with the coding guidelines for files in the libs directory, promoting reusability and type safety across different NextJS apps.


1-1: LGTM! Verify the new import path.

The simplified import path aligns with good practices for module organization and potentially improves tree-shaking. This change appears to be part of a module restructuring.

Please run the following script to ensure the new import path is correct and the file exists:

libs/portals/shared-modules/delegations/src/components/delegations/incoming/DelegationIncoming.graphql (1)

25-37: Excellent additions to the AuthDelegationsIncoming query!

The new fields referenceId, to, and createdBy align perfectly with the PR objectives. These additions enhance the query's functionality by providing more detailed information about delegations, specifically:

  1. The referenceId field allows for unique identification of general mandate delegations.
  2. The to field provides clear information about the delegation recipient.
  3. The createdBy field indicates who created the general mandate delegations, as specified in the PR objectives.

These changes improve the component's reusability across different NextJS apps and support the enhanced functionality of the AccessCard component mentioned in the PR summary.

libs/portals/shared-modules/delegations/src/components/delegations/outgoing/DelegationsOutgoing.graphql (1)

27-40: LGTM! Changes align well with PR objectives.

The additions to the AuthDelegationsOutgoing query (validTo, referenceId, from, and createdBy fields) are consistent with the PR objectives. These changes enhance the query's functionality by providing more detailed information about delegations, particularly the createdBy field for general mandate delegations.

The modifications maintain the query's reusability across different NextJS apps and adhere to the coding guidelines for libs/**/* files.

libs/api/domains/auth/src/lib/models/delegation.model.ts (1)

Line range hint 1-124: Overall assessment: Code meets guidelines and PR objectives.

The changes in this file adhere to the coding guidelines for libs/**/* files:

  1. The code maintains reusability across different NextJS apps.
  2. TypeScript is used effectively for defining props and exporting types.
  3. The change supports effective tree-shaking and bundling practices.

The addition of the createdBy field to the Delegation abstract class aligns with the PR objectives and is well-implemented.

libs/auth-api-lib/src/lib/delegations/dto/delegation.dto.ts (2)

71-74: LGTM: New property aligns with PR objectives and follows best practices.

The addition of the createdByNationalId property to the DelegationDTO class is well-implemented:

  • It uses TypeScript for type definition (string | null).
  • The @IsOptional() and @IsString() decorators ensure proper validation.
  • The @ApiPropertyOptional() decorator provides correct API documentation.

This change aligns with the PR objective to introduce a createdBy field for Delegations, enhancing the data structure without altering existing properties.


Line range hint 1-138: Excellent: File adheres to coding guidelines for libs directory.

This file demonstrates good practices for code in the libs directory:

  1. Reusability: The DTO classes defined here can be easily used across different NextJS apps for handling delegation data.
  2. TypeScript usage: Props are well-defined using TypeScript, and types are properly exported.
  3. Tree-shaking and bundling: The file contains only type definitions and decorators, which allows for effective tree-shaking and bundling.

The use of decorators from class-validator and @nestjs/swagger enhances the reusability of these DTOs for both backend validation and API documentation.

libs/auth-api-lib/src/lib/delegations/models/delegation.model.ts (1)

144-144: LGTM: Addition of createdByNationalId aligns with PR objectives

The addition of createdByNationalId to the toDTO method's return object is correct and aligns with the PR objective of introducing a createdBy field to Delegations. This change enhances the DTO representation without affecting the overall structure or logic of the method.

The modification adheres to the coding guidelines for libs/**/* files:

  1. It maintains reusability across NextJS apps.
  2. It uses TypeScript consistently with the rest of the code.
  3. It doesn't introduce any issues for tree-shaking or bundling.

To ensure this change is reflected in the DelegationDTO type, let's verify its definition:

libs/portals/shared-modules/delegations/src/lib/messages.ts (1)

Line range hint 1-241: Overall, the changes align well with coding guidelines and PR objectives.

The additions to this file (createdBy, noValidToDate, and referenceId messages) contribute to the internationalization setup and support the new features described in the PR objectives. The file structure adheres to the coding guidelines for libs/**/*:

  1. It supports reusability of components across different NextJS apps by providing centralized message definitions.
  2. It implicitly uses TypeScript through the defineMessages function from react-intl.
  3. The structure of the file supports effective tree-shaking and bundling practices.
libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx (5)

51-54: LGTM: Improved flexibility in action handling

The changes to the AccessCardProps interface enhance the component's flexibility by making action callbacks optional and allowing them to be explicitly disabled. This aligns well with the PR objective of refactoring the AccessCard to display specific actions based on provided functions.


65-66: LGTM: Component props aligned with interface updates

The destructuring of onEdit and onRenew props in the AccessCard component correctly aligns with the updates made to the AccessCardProps interface. This change supports the new functionality for editing and renewing delegations as intended in the PR objectives.


162-162: LGTM: Simplified and improved action visibility logic

The hasActions logic has been streamlined to include the new onEdit action. This change ensures that the actions section is rendered when any of the action callbacks are provided, aligning with the PR objective of improving the logic governing the visibility of different actions.


263-270: LGTM: Enhanced action button rendering logic

The changes to the action button rendering logic significantly improve the component's flexibility and contextual appropriateness:

  1. The onDelete button is now conditionally rendered with proper optional chaining.
  2. The onView button rendering has been updated for consistency.
  3. New conditional rendering for onEdit and onRenew buttons has been added, taking into account the isExpired state.

These improvements align well with the PR objective of ensuring that the actions displayed on the AccessCard are contextually appropriate and match the design specifications.

Also applies to: 277-285, 286-309


Line range hint 1-324: Overall assessment: Well-implemented refactoring

The changes to the AccessCard component successfully achieve the PR objectives:

  1. The refactoring enhances the component's flexibility in displaying specific actions.
  2. The logic for action visibility has been streamlined.
  3. The component now handles the new createdBy field for general mandate delegations (although not directly visible in this file).

The implementation adheres to the coding guidelines for reusability and TypeScript usage. The component is well-structured for potential use across different NextJS apps within the project.

Great job on this refactoring! The changes improve the component's functionality and maintainability.

libs/portals/shared-modules/delegations/src/components/delegations/incoming/DelegationsIncoming.tsx (3)

16-16: Ensure consistent import paths for generated hooks

The import path for DelegationViewModal is updated correctly. However, please ensure that the import paths for all generated hooks (useAuthDelegationsIncomingQuery) are consistent and accurately reflect their locations after any refactoring.


114-119: ⚠️ Potential issue

Ensure DelegationViewModal handles multiple delegation types

The DelegationViewModal component receives delegation cast as AuthCustomDelegationIncoming, but it may also receive a GeneralMandate delegation. Ensure that DelegationViewModal correctly handles all delegation types being passed to it.

Review the DelegationViewModal component to confirm it supports AuthGeneralMandateDelegationIncoming.

Run the following script to verify the props of DelegationViewModal:

#!/bin/bash
# Description: Check the `DelegationViewModal` component's `delegation` prop type

rg 'DelegationViewModal' -A 10 | rg 'delegation'

This will display where the component is defined and how the delegation prop is typed.


16-17: Confirm effective tree-shaking with updated imports

The import statement for DelegationViewModal has been updated. Please ensure that this change does not impact tree-shaking and bundling practices, keeping the build efficient.

Run the following script to analyze the bundle size impact:

I can help draft configurations or scripts for bundle analysis if needed.

libs/portals/shared-modules/delegations/src/components/delegations/outgoing/DelegationsOutgoing.tsx (2)

132-145: onEdit and onRenew handlers navigate to the same route

Both the onEdit and onRenew handlers navigate to the same path:

navigate(`${DelegationPaths.Delegations}/${delegation.id}`)

If the intent is for these actions to perform different functions, consider updating the navigation paths or handler logic to reflect their distinct purposes.


36-37: ⚠️ Potential issue

Potential type mismatch in delegationView state

The delegationView state is initialized with the type AuthCustomDelegationIncoming | null in an outgoing delegations component. Since this component handles outgoing delegations, using the incoming delegation type may be incorrect. Please verify that the correct delegation type is being used to prevent potential type errors.

@magnearun magnearun marked this pull request as draft October 3, 2024 10:45
@magnearun magnearun marked this pull request as ready for review October 3, 2024 15:39
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (3)
libs/portals/shared-modules/delegations/src/components/delegations/incoming/DelegationsIncoming.tsx (3)

59-62: LGTM: Improved type checking, consider further enhancement

The introduction of isCustom and isGeneralMandate constants improves code readability and type safety. This aligns well with the PR objectives for refactoring the AccessCard component.

However, consider implementing a type guard function as suggested in a previous review to further enhance type safety:

const isDelegationType = (delegation: AuthCustomDelegationIncoming, type: AuthDelegationType): boolean => {
  return delegation.type === type;
};

const isCustom = isDelegationType(delegation, AuthDelegationType.Custom);
const isGeneralMandate = isDelegationType(delegation, AuthDelegationType.GeneralMandate);

This approach would provide better type inference and make the code more maintainable.


115-119: LGTM: Updated modal component, consider type-safe approach

The replacement of DelegationIncomingModal with DelegationViewModal and the addition of the direction prop align well with the PR objectives. This change enhances the flexibility of the modal component.

However, the unsafe type casting to AuthCustomDelegationIncoming persists. Consider implementing a type-safe approach to handle different delegation types. For example:

delegation={delegationView as AuthCustomDelegationIncoming | AuthGeneralMandateDelegationIncoming}

This approach allows the modal to handle both custom and general mandate delegations safely.


Line range hint 1-122: Overall assessment: Good improvements with room for enhancement

The changes in this file align well with the PR objectives, particularly in refactoring the AccessCard component and updating the View modal. The introduction of type checks and conditional rendering enhances the component's flexibility and functionality.

However, there are several areas where the code could be further improved:

  1. Type safety: Implement type guards or use union types to avoid unsafe type castings throughout the component.
  2. Code simplification: Simplify the onDelete and onView handlers as suggested in the review comments.
  3. Consistency: Ensure consistent handling of different delegation types across the component.

Addressing these points will significantly improve the code's robustness, maintainability, and adherence to TypeScript best practices.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e91f452 and caedd71.

📒 Files selected for processing (8)
  • libs/portals/admin/delegation-admin/src/components/DelegationList.tsx (1 hunks)
  • libs/portals/admin/delegation-admin/src/lib/messages.ts (1 hunks)
  • libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx (7 hunks)
  • libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx (3 hunks)
  • libs/portals/shared-modules/delegations/src/components/delegations/incoming/DelegationsIncoming.tsx (4 hunks)
  • libs/portals/shared-modules/delegations/src/components/delegations/outgoing/DelegationsOutgoing.tsx (5 hunks)
  • libs/portals/shared-modules/delegations/src/lib/messages.ts (2 hunks)
  • libs/portals/shared-modules/delegations/src/types/customDelegation.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • libs/portals/admin/delegation-admin/src/lib/messages.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • libs/portals/admin/delegation-admin/src/components/DelegationList.tsx
  • libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx
  • libs/portals/shared-modules/delegations/src/lib/messages.ts
  • libs/portals/shared-modules/delegations/src/types/customDelegation.ts
🧰 Additional context used
📓 Path-based instructions (3)
libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.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."
libs/portals/shared-modules/delegations/src/components/delegations/incoming/DelegationsIncoming.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."
libs/portals/shared-modules/delegations/src/components/delegations/outgoing/DelegationsOutgoing.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 (4)
libs/portals/shared-modules/delegations/src/components/delegations/incoming/DelegationsIncoming.tsx (1)

15-16: LGTM: Import changes align with PR objectives

The import changes reflect the refactoring mentioned in the PR objectives. The DelegationViewModal import and the updated path for useAuthDelegationsIncomingQuery are consistent with the described changes.

libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx (1)

20-22: Props definition aligns with TypeScript best practices

The DelegationViewModalProps type correctly defines the component's props using TypeScript, enhancing type safety and maintainability across different NextJS apps.

libs/portals/shared-modules/delegations/src/components/delegations/outgoing/DelegationsOutgoing.tsx (2)

127-130: Avoid explicit type casting by refining delegation types

In the onDelete handler, delegation is explicitly cast to AuthCustomDelegationOutgoing. This suggests that the delegation variable may not have a precise type. To improve type safety and maintainability, consider refining the delegation type or implementing type guards instead of using explicit casting.


152-155: Type casting delegation to AuthCustomDelegationIncoming may be unsafe

In the onView handler, delegation is cast to AuthCustomDelegationIncoming before setting delegationView. Since delegation originates from outgoing delegations, casting it to an incoming type might lead to runtime errors or unexpected behavior. Consider checking the delegation type and using appropriate type guards to ensure type safety.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (3)
libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx (2)

25-57: LGTM with a minor suggestion: Component declaration and initial logic

The component declaration and initial logic are well-structured. Good use of hooks and proper handling of props. The Modal 'id' now correctly reflects the delegation direction, addressing the previous comment.

A minor suggestion for improvement:

Consider using optional chaining in the useEffect hook's condition:

- if (delegation && delegation.domain) {
+ if (delegation?.domain) {

This change would make the code more concise and consistent with modern JavaScript practices.

🧰 Tools
🪛 Biome

[error] 38-38: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


98-151: LGTM with a suggestion: GeneralMandate render logic

The render logic for GeneralMandate delegations is well-implemented with proper conditional rendering and localization. The responsive layout using Box components is a good approach.

However, there's room for improvement in the date validation:

While you've added a check for date validity using isValid, it's better to handle potential undefined values explicitly. Consider updating the date formatting logic as follows:

- delegation?.validTo && isValid(delegation.validTo)
-   ? format(new Date(delegation?.validTo), 'dd.MM.yyyy')
-   : formatMessage(m.noValidToDate)
+ delegation?.validTo && isValid(new Date(delegation.validTo))
+   ? format(new Date(delegation.validTo), 'dd.MM.yyyy')
+   : formatMessage(m.noValidToDate)

This change ensures that both undefined values and invalid dates are handled correctly.

libs/portals/shared-modules/delegations/src/components/delegations/outgoing/DelegationsOutgoing.tsx (1)

182-187: LGTM: DelegationViewModal added with minor suggestion

The addition of the DelegationViewModal component aligns well with the PR objectives for handling general mandate delegations. The component props are correctly typed and used.

Consider simplifying the delegation prop:

- delegation={delegationView || undefined}
+ delegation={delegationView}

This change is possible because null is a valid value for an optional prop in React, and it simplifies the code slightly.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between caedd71 and 64a1340.

📒 Files selected for processing (2)
  • libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx (1 hunks)
  • libs/portals/shared-modules/delegations/src/components/delegations/outgoing/DelegationsOutgoing.tsx (5 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.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."
libs/portals/shared-modules/delegations/src/components/delegations/outgoing/DelegationsOutgoing.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."
🪛 Biome
libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx

[error] 38-38: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (6)
libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx (2)

1-23: LGTM: Imports and type definitions are well-structured

The imports cover all necessary dependencies for the component's functionality. The DelegationViewModalProps type is correctly defined to handle both incoming and outgoing delegations. Good job addressing the previous comment about renaming the props type.


152-163: LGTM: AccessListContainer rendering

The conditional rendering of the AccessListContainer for non-GeneralMandate type delegations is well-implemented. All necessary props are correctly passed to the component. Good job on using the AuthDelegationType enum consistently for the type comparison, addressing the previous comment.

libs/portals/shared-modules/delegations/src/components/delegations/outgoing/DelegationsOutgoing.tsx (4)

9-9: LGTM: New imports align with PR objectives

The added imports for AuthDelegationType, AuthCustomDelegationIncoming, AuthCustomDelegationOutgoing, useNavigate, and DelegationViewModal are consistent with the PR objectives. They support the new functionality for handling different delegation types and the introduction of the view modal.

Also applies to: 18-21, 25-26


36-37: LGTM: New state variable for delegation view

The addition of the delegationView state variable of type AuthCustomDelegationIncoming | null is in line with the PR objectives. It provides the necessary state management for handling general mandate delegations and displaying them in the view modal.


39-39: LGTM: Added useNavigate hook for navigation

The addition of the useNavigate hook from react-router-dom is appropriate for handling navigation to edit and renew delegations. This change aligns with React best practices for navigation in functional components.


Line range hint 1-190: Overall: Good refactor with room for minor improvements

The changes in this file successfully meet the PR objectives of refactoring the AccessCard component and handling general mandate delegations. The code adheres to the coding guidelines, effectively using TypeScript for props and types, and maintaining a structure that supports reusability across different NextJS apps.

Key improvements:

  1. Proper handling of different delegation types, particularly general mandates.
  2. Introduction of the DelegationViewModal for viewing general mandate delegations.
  3. Conditional rendering of AccessCard props based on delegation type.

Suggestions for further improvement:

  1. Enhance type safety by using type guards instead of explicit type casting.
  2. Simplify the conditional logic for AccessCard props using a helper function.
  3. Minor simplification of the DelegationViewModal delegation prop.

These changes have significantly improved the component's functionality while maintaining good coding practices. Implementing the suggested improvements will further enhance the code's robustness and maintainability.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (12)
libs/portals/shared-modules/delegations/src/index.ts (1)

Line range hint 1-15: Confirm compliance with coding guidelines

The file structure and export statements comply with the coding guidelines for libs/**/* files:

  • Supports reusability across different NextJS apps
  • Uses TypeScript for exporting (implicit in export statements)
  • Enables effective tree-shaking through granular exports

For improved consistency and maintainability, consider grouping related exports together (e.g., all delegation-related components).

Here's a suggested reorganization of the exports:

// Core module
export { delegationsModule } from './module'

// Utilities
export * from './lib/paths'
export * from './lib/navigation'

// Hooks
export * from './hooks/useDynamicShadow'

// Components
export * from './components/access/AccessCard'
export * from './components/IdentityCard/IdentityCard'

// Delegation-specific components
export * from './components/delegations/DelegationsEmptyState'
export * from './components/delegations/DelegationsFormFooter'
export * from './components/delegations/DelegationViewModal'
libs/portals/admin/delegation-admin/src/components/DelegationList.tsx (4)

15-21: LGTM: New state variables enhance functionality

The introduction of delegationToDelete and delegationView state variables aligns with the PR objectives of improving delegation management. The use of TypeScript for type safety is commendable.

Consider using more descriptive names for the state variables, such as selectedDelegationForDeletion and selectedDelegationForView, to enhance code readability.


23-33: LGTM: Effective deletion handler implementation

The deleteHandler function is well-implemented, aligning with the PR objectives of improving delegation management. It correctly uses the mutation and updates the state accordingly.

Consider adding error handling to the deleteHandler function. For example:

const deleteHandler = async (id: string) => {
  try {
    const { data } = await deleteCustomDelegationAdminMutation({
      variables: { id },
    });
    if (data) {
      revalidate();
      setDelegationToDelete(null);
    }
  } catch (error) {
    console.error('Error deleting delegation:', error);
    // Consider adding user feedback for the error case
  }
};

This will improve the robustness of the function and provide better feedback in case of errors.


57-68: LGTM: DelegationDeleteModal enhances user interaction

The introduction of the DelegationDeleteModal component aligns well with the PR objectives of improving delegation management. It provides a clear user interface for confirming deletion actions.

Consider extracting the onDelete logic into a separate function for better readability:

const handleDelete = () => {
  if (delegationToDelete) {
    deleteHandler(delegationToDelete.id as string);
  }
};

// Then in the component props:
onDelete={handleDelete}

This would make the component props more concise and easier to read.


Line range hint 1-82: Overall: Excellent refactoring and feature enhancement

The changes in this file significantly improve the delegation management functionality, aligning well with the PR objectives. The introduction of new components (DelegationDeleteModal and DelegationViewModal) and state variables enhances the user experience for viewing and deleting delegations.

Key improvements:

  1. Refactored AccessCard component for better flexibility and reusability.
  2. Added robust deletion handling with confirmation modal.
  3. Implemented viewing functionality for delegation details.
  4. Effective use of TypeScript for type safety.

These changes contribute to a more maintainable and user-friendly delegation management system in the admin portal.

Consider creating a custom hook (e.g., useDelegationManagement) to encapsulate the deletion and viewing logic. This would further improve the component's reusability and make it easier to test the business logic independently of the UI components.

libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx (1)

20-24: Consider renaming the props type for consistency

The props type DelegationViewModalProps is well-defined, but it could be more consistent with the component name. Consider renaming it to DelegationViewModalProps to match the component name exactly.

libs/portals/shared-modules/delegations/src/lib/messages.ts (4)

117-120: Consider adding a description for the createdBy message.

The createdBy message is correctly structured and aligns with the PR objectives. To enhance clarity for translators, consider adding a description. For example:

createdBy: {
  id: 'sp.access-control-delegations:created-by',
  defaultMessage: 'Skráð af',
  description: 'Label indicating who created the delegation',
},

This addition will improve the context for translators and maintain consistency with other message definitions in the file.


234-237: LGTM! Consider adding a description.

The noValidToDate message is correctly structured and the typo has been fixed as per the previous review comment. To further improve clarity for translators, consider adding a description. For example:

noValidToDate: {
  id: 'sp.access-control-delegations:no-valid-to-date',
  defaultMessage: 'Gildistími óendanlegur',
  description: 'Message indicating that the validity period is indefinite',
},

This addition will provide better context for translators and maintain consistency with other message definitions in the file.


238-241: Consider adding a description for the referenceId message.

The referenceId message is correctly structured and aligns with the PR objectives. To enhance clarity for translators, consider adding a description. For example:

referenceId: {
  id: 'sp.access-control-delegations:reference-id',
  defaultMessage: 'Númer máls í Zendesk',
  description: 'Label for the Zendesk case number associated with the delegation',
},

This addition will improve the context for translators and maintain consistency with other message definitions in the file.


246-249: Consider adding a description for the viewDelegationModalTitle message.

The viewDelegationModalTitle message is correctly structured and aligns with the PR objectives. To enhance clarity for translators, consider adding a description. For example:

viewDelegationModalTitle: {
  id: 'sp.access-control-delegations:view-delegation-modal-title',
  defaultMessage: 'Upplýsingar um umboð',
  description: 'Title for the modal displaying delegation information',
},

This addition will provide better context for translators and maintain consistency with other message definitions in the file.

libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx (2)

52-55: LGTM: Improved flexibility with optional callbacks

The changes to AccessCardProps align with the PR objectives and improve the component's flexibility. Consider using a consistent style for optional props:

onDelete?: (delegation: AuthCustomDelegation) => void;
onEdit?: (delegation: AuthCustomDelegation) => void;
onView?: (delegation: AuthCustomDelegation) => void;
onRenew?: (delegation: AuthCustomDelegation) => void;

This style (with semicolons) is more common in TypeScript interfaces.


163-163: LGTM: Improved logic and type safety

The changes improve the component's logic and type safety:

  1. The hasActions condition simplifies action visibility logic.
  2. The access holder's name rendering is now more type-safe.
  3. The marginTop adjustment ensures proper spacing.

Consider using nullish coalescing for the access holder's name:

{isOutgoing
  ? (delegation as AuthCustomDelegationOutgoing)?.to?.name ?? 'Unknown'
  : (delegation as AuthCustomDelegationIncoming)?.from?.name ?? 'Unknown'
}

This would handle cases where the name might be undefined or null.

Also applies to: 208-210, 232-232

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 338d608 and c4f800b.

📒 Files selected for processing (7)
  • libs/portals/admin/delegation-admin/src/components/DelegationList.tsx (1 hunks)
  • libs/portals/admin/delegation-admin/src/screens/DelegationAdminDetails/DelegationAdmin.graphql (2 hunks)
  • libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx (8 hunks)
  • libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx (1 hunks)
  • libs/portals/shared-modules/delegations/src/components/delegations/incoming/DelegationsIncoming.tsx (4 hunks)
  • libs/portals/shared-modules/delegations/src/index.ts (1 hunks)
  • libs/portals/shared-modules/delegations/src/lib/messages.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/portals/shared-modules/delegations/src/components/delegations/incoming/DelegationsIncoming.tsx
🧰 Additional context used
📓 Path-based instructions (6)
libs/portals/admin/delegation-admin/src/components/DelegationList.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."
libs/portals/admin/delegation-admin/src/screens/DelegationAdminDetails/DelegationAdmin.graphql (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/portals/shared-modules/delegations/src/components/access/AccessCard.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."
libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.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."
libs/portals/shared-modules/delegations/src/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/portals/shared-modules/delegations/src/lib/messages.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."
🪛 Biome
libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx

[error] 40-40: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (13)
libs/portals/shared-modules/delegations/src/index.ts (1)

15-15: LGTM: New export enhances module functionality

The addition of the DelegationViewModal export aligns with the existing structure and enhances the module's capabilities. This change supports the PR's objectives by making the new component available for use across the application.

To ensure the new component is properly integrated, please run the following script:

libs/portals/admin/delegation-admin/src/screens/DelegationAdminDetails/DelegationAdmin.graphql (3)

25-28: LGTM: Addition of createdBy field enhances delegation information.

The introduction of the createdBy field with name and nationalId subfields aligns well with the PR objectives. This addition provides valuable context about who created the delegations, enhancing the overall functionality of the delegation management system.


56-59: LGTM: Consistent implementation of createdBy field in outgoing delegations.

The addition of the createdBy field to the outgoing section maintains consistency with the incoming section. This ensures that creator information is available for both incoming and outgoing delegations, providing a comprehensive view of delegation data.


Line range hint 1-79: Overall assessment: Changes align with coding guidelines and enhance functionality.

The modifications to the getCustomDelegationsAdmin query, specifically the addition of the createdBy field to both incoming and outgoing sections, adhere to the coding guidelines for files in the libs directory:

  1. These changes enhance the reusability of the query across different NextJS apps by providing more comprehensive delegation data.
  2. The structured nature of the GraphQL query supports strong typing when used with TypeScript in consuming components.
  3. The additions don't negatively impact tree-shaking or bundling practices.

The changes successfully implement the PR objectives by introducing the createdBy field to Delegations, improving the overall functionality of the delegation management system.

libs/portals/admin/delegation-admin/src/components/DelegationList.tsx (3)

3-3: LGTM: New imports align with PR objectives

The addition of DelegationViewModal, useState, and DelegationDeleteModal imports aligns well with the PR objectives of enhancing the delegation management functionality. These changes adhere to the coding guidelines for TypeScript usage and component reusability.

Also applies to: 6-7


41-52: LGTM: AccessCard refactor improves flexibility

The refactoring of the AccessCard component aligns well with the PR objectives. The new props and conditional rendering of onView and onDelete enhance the component's flexibility and reusability.

As per the previous review comment by saevarma, the DelegationViewModal is now being reused in the admin portal for viewing delegation details, which is a good implementation of the suggested improvement.


69-75: LGTM: DelegationViewModal improves user experience

The addition of the DelegationViewModal component aligns perfectly with the PR objectives of enhancing the view functionality for delegations. It provides a clear interface for users to view delegation details, improving the overall user experience.

The component follows good practices for modal implementation and prop passing, enhancing the reusability and maintainability of the code.

libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx (1)

1-164: Overall assessment: Well-structured and reusable component

The DelegationViewModal component is well-implemented and adheres to the coding guidelines:

  1. Reusability: The component is designed to be reusable across different NextJS apps within the Island.is ecosystem.
  2. TypeScript usage: Props and types are well-defined using TypeScript, enhancing type safety.
  3. Effective tree-shaking: The component structure allows for efficient tree-shaking and bundling.

The component effectively uses the Island.is design system and follows React best practices. The suggested improvements in previous comments will further enhance its quality, particularly in terms of optimization, accessibility, and error handling.

🧰 Tools
🪛 Biome

[error] 40-40: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

libs/portals/shared-modules/delegations/src/lib/messages.ts (1)

Line range hint 117-249: LGTM! The changes align with coding guidelines and PR objectives.

The new message entries (createdBy, noValidToDate, referenceId, and viewDelegationModalTitle) have been correctly implemented and contribute to the reusability of components across different NextJS apps. The changes adhere to TypeScript usage for defining props and align with the PR objectives, particularly in enhancing the delegation information display.

To further improve the file:

  1. Consider adding descriptions to all new message entries for better context for translators.
  2. Ensure consistent formatting across all message entries (some have trailing commas, others don't).

These changes effectively support the internationalization setup and enhance the overall functionality of the delegation management system.

libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx (4)

27-27: LGTM: Import and type safety improvements

The import of AuthCustomDelegation and the changes to the getTags function improve type safety and align with TypeScript best practices.

Also applies to: 39-41


66-67: LGTM: Destructuring new optional props

The addition of onEdit and onRenew to the destructured props is consistent with the interface changes and allows the component to use these new optional callbacks.


278-286: LGTM: Improved view button rendering

The updated rendering logic for the view button aligns with the PR objectives and ensures the button is only displayed when the onView callback is provided. This change improves the component's flexibility and adheres to the principle of conditional rendering based on prop availability.


Line range hint 1-321: Overall assessment: Successful refactoring with minor improvements needed

The refactoring of the AccessCard component has significantly improved its flexibility and functionality, aligning well with the PR objectives. Key improvements include:

  1. More flexible prop structure with optional callbacks.
  2. Enhanced type safety throughout the component.
  3. Improved conditional rendering of action buttons.
  4. Better handling of different delegation types.

These changes contribute to a more maintainable and reusable component. The suggested minor improvements, mainly removing unnecessary optional chaining, will further refine the code quality.

Great job on this refactoring! Once the minor issues are addressed, this PR will be ready for merge.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (3)
libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx (3)

39-41: LGTM: Improved type safety in tag name retrieval

The update enhances type safety by using optional chaining to handle potential undefined values. This change aligns with TypeScript best practices.

Consider using nullish coalescing for a more concise expression:

name: scope?.apiScope
  ? getTagName(scope.apiScope as AuthApiScope)
  : scope.displayName ?? '',

This ensures a fallback to an empty string if both apiScope and displayName are null or undefined.


Line range hint 163-232: LGTM: Improved action availability check and delegation holder rendering

The changes in this segment improve the component in two ways:

  1. The action availability check is now more concise and readable.
  2. The rendering of the delegation holder's name now correctly handles both incoming and outgoing delegations.

These updates align with the PR objectives to refactor the AccessCard component for better functionality.

Consider using optional chaining for accessing nested properties to further improve type safety:

{isOutgoing
  ? delegation.to?.name
  : delegation.from?.name}

This change would handle cases where to or from might be undefined.


Line range hint 256-310: LGTM: Updated rendering logic for action buttons

The changes to the action button rendering logic align well with the PR objectives:

  1. Buttons are only rendered when their corresponding callback functions are provided, improving flexibility.
  2. The conditional rendering based on the isExpired state enhances contextual appropriateness.

These updates significantly improve the component's ability to display specific actions based on the provided functions, as intended in the PR objectives.

However, there are two instances of unnecessary optional chaining that should be removed:

  1. Line 271:
- onClick={() => onDelete?.(delegation)}
+ onClick={() => onDelete(delegation)}
  1. Line 305:
- onClick={() => onRenew?.(delegation)}
+ onClick={() => onRenew(delegation)}

These changes maintain the intended functionality while removing redundant code, as onDelete and onRenew are already checked in their respective conditions.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c4f800b and 33d0b14.

📒 Files selected for processing (1)
  • libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx (9 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/portals/shared-modules/delegations/src/components/access/AccessCard.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 (4)
libs/portals/shared-modules/delegations/src/components/access/AccessCard.tsx (4)

27-27: LGTM: Import statement added for better type safety

The addition of the AuthCustomDelegation import from @island.is/api/schema enhances type safety and aligns with our TypeScript usage guidelines.


52-55: LGTM: AccessCardProps interface updated with new optional properties

The changes to the AccessCardProps interface align well with the PR objectives:

  1. onDelete is now optional, allowing more flexible usage.
  2. New optional properties onEdit and onRenew have been added, enhancing the component's functionality.

These updates improve the reusability of the component across different NextJS apps, as specified in the coding guidelines.


66-67: LGTM: New props added to AccessCard component

The addition of onEdit and onRenew to the component's prop destructuring is consistent with the updates to the AccessCardProps interface. This change enables the component to utilize the new optional callback functions, enhancing its flexibility and functionality as intended in the PR objectives.


Line range hint 1-324: Overall assessment: Approved with minor suggestions

The refactoring of the AccessCard component has been successfully implemented, aligning well with the PR objectives and coding guidelines. Key improvements include:

  1. Enhanced flexibility through new optional properties and conditional rendering.
  2. Improved type safety with better handling of potential undefined values.
  3. More concise and readable code for action availability checks.
  4. Better handling of different delegation types.

The changes contribute to the reusability of the component across different NextJS apps, as specified in the coding guidelines.

Minor suggestions have been made to further improve type safety and remove unnecessary optional chaining. Once these small issues are addressed, the code will be ready for merging.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (3)
libs/portals/admin/delegation-admin/src/components/DelegationList.tsx (3)

26-36: LGTM! Deletion logic encapsulated in a separate function.

The deleteHandler function effectively manages the deletion process, including state revalidation. This promotes cleaner code organization and aligns with the PR objectives.

Consider adding error handling to manage potential failures in the deletion process:

 const deleteHandler = async (id: string) => {
-  const { data } = await deleteCustomDelegationAdminMutation({
-    variables: {
-      id,
-    },
-  })
-  if (data) {
-    revalidate()
-    setDelegationToDelete(null)
-  }
+  try {
+    const { data } = await deleteCustomDelegationAdminMutation({
+      variables: { id },
+    })
+    if (data) {
+      revalidate()
+      setDelegationToDelete(null)
+    }
+  } catch (error) {
+    console.error('Failed to delete delegation:', error)
+    // Consider adding user feedback for the error case
+  }
 }

44-59: LGTM! AccessCard component refactored as per PR objectives.

The changes to the AccessCard component, including the new variant prop and conditional handlers, align well with the PR objectives. The refactoring improves the component's flexibility and type safety.

Consider extracting the conditional logic for onView and onDelete into separate variables to improve readability:

+ const canPerformActions = !!delegation.referenceId;
+ const viewHandler = canPerformActions ? (d) => setDelegationView(d) : undefined;
+ const deleteHandler = canPerformActions ? () => setDelegationToDelete(delegation) : undefined;

 <AccessCard
   key={delegation.id}
   delegation={delegation}
   isAdminView
   variant={direction}
-  onView={
-    delegation.referenceId
-      ? (d) => setDelegationView(d)
-      : undefined
-  }
-  onDelete={
-    delegation.referenceId
-      ? () => setDelegationToDelete(delegation)
-      : undefined
-  }
+  onView={viewHandler}
+  onDelete={deleteHandler}
 />

64-75: LGTM! DelegationDeleteModal added for improved user interaction.

The addition of the DelegationDeleteModal component enhances the user interface for delegation actions, aligning with the PR objectives. The reuse of the deleteHandler function promotes code efficiency.

Consider using a type assertion for delegationToDelete to avoid the use of as and improve type safety:

 <DelegationDeleteModal
   id={`${direction}-delegation-delete-modal`}
-  delegation={delegationToDelete as AuthCustomDelegation}
+  delegation={delegationToDelete!}
   loading={loading}
   onClose={() => setDelegationToDelete(null)}
   onDelete={() => {
     if (delegationToDelete) {
       deleteHandler(delegationToDelete.id as string)
     }
   }}
   isVisible={!!delegationToDelete}
 />
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 33d0b14 and 09f8e28.

📒 Files selected for processing (4)
  • libs/portals/admin/delegation-admin/src/components/DelegationList.tsx (1 hunks)
  • libs/portals/admin/delegation-admin/src/lib/messages.ts (3 hunks)
  • libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx (1 hunks)
  • libs/portals/shared-modules/delegations/src/lib/messages.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • libs/portals/admin/delegation-admin/src/lib/messages.ts
  • libs/portals/shared-modules/delegations/src/lib/messages.ts
🧰 Additional context used
📓 Path-based instructions (2)
libs/portals/admin/delegation-admin/src/components/DelegationList.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."
libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.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."
🪛 Biome
libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx

[error] 40-40: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (6)
libs/portals/admin/delegation-admin/src/components/DelegationList.tsx (4)

3-6: LGTM! Imports updated to include shared components.

The addition of DelegationViewModal from the shared modules addresses the previous review comment and promotes reusability across different NextJS apps. This change aligns well with our coding guidelines for libs.


9-10: LGTM! Imports updated for new functionality.

The explicit import of useState and the new DelegationDeleteModal component align with the PR objectives and support effective tree-shaking. These changes contribute to better code organization and functionality.


18-24: LGTM! New state variables added with proper TypeScript typing.

The introduction of delegationToDelete and delegationView state variables supports the new view and delete functionalities mentioned in the PR objectives. The use of TypeScript for typing these variables (AuthCustomDelegation | null) aligns well with our coding guidelines for libs.


76-82: LGTM! DelegationViewModal added as suggested in the past review.

The addition of the DelegationViewModal component addresses the past review comment and enhances the user interface for viewing delegation details. This change aligns well with the PR objectives and improves the overall functionality of the component.

Great job on implementing the suggested improvement!

libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx (2)

1-165: LGTM with minor suggestions for improvement

The implementation of the DelegationViewModal component is well-structured and follows good practices. It makes appropriate use of island.is ecosystem components and hooks, and adheres to the coding guidelines for reusability and TypeScript usage. The component effectively handles both incoming and outgoing delegations, with conditional rendering based on delegation type and admin view.

Consider implementing the suggested improvements to enhance maintainability, accessibility, and error handling. These changes will further improve the component's robustness and usability across different NextJS apps.

🧰 Tools
🪛 Biome

[error] 40-40: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


121-121: 🛠️ Refactor suggestion

Consider importing the image asset to ensure correct path resolution in reusable components

In reusable components, referencing images via a relative path like "./assets/images/skjaldarmerki.svg" can lead to issues when the component is used across different NextJS apps. Importing the image directly ensures correct path resolution and enhances the reusability of the component.

Apply this diff to import the image asset:

+ import skjaldarmerki from '../../assets/images/skjaldarmerki.svg';

...

- imgSrc="./assets/images/skjaldarmerki.svg"
+ imgSrc={skjaldarmerki}

Likely invalid or redundant comment.

Copy link
Member

@saevarma saevarma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@magnearun magnearun added the automerge Merge this PR as soon as all checks pass label Oct 9, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (1)
libs/portals/shared-modules/delegations/src/components/access/AccessList/AccessListContainer/AccessListContainer.tsx (1)

18-21: Improved type definition for delegation prop

The changes to the AccessListContainerProps type enhance type safety and clarity. By explicitly defining the structure of the delegation prop, you've improved the component's API and made it easier for consumers to understand what data is expected.

This change aligns well with TypeScript best practices and may contribute to better tree-shaking by allowing unused properties to be removed more easily.

Consider extracting this type definition into a separate interface if it's used in multiple places throughout the codebase. This would further improve reusability and maintainability.

interface DelegationType {
  validTo?: string | null;
  scopes?: AuthDelegationScope[];
}

type AccessListContainerProps = {
  delegation?: DelegationType;
  // ... other props
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 09f8e28 and 31fd8d9.

📒 Files selected for processing (6)
  • libs/portals/shared-modules/delegations/src/components/access/AccessList/AccessListContainer/AccessListContainer.tsx (1 hunks)
  • libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx (1 hunks)
  • libs/portals/shared-modules/delegations/src/components/delegations/incoming/DelegationIncoming.graphql (1 hunks)
  • libs/portals/shared-modules/delegations/src/components/delegations/incoming/DelegationsIncoming.tsx (4 hunks)
  • libs/portals/shared-modules/delegations/src/components/delegations/outgoing/DelegationsOutgoing.graphql (2 hunks)
  • libs/portals/shared-modules/delegations/src/components/delegations/outgoing/DelegationsOutgoing.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • libs/portals/shared-modules/delegations/src/components/delegations/incoming/DelegationIncoming.graphql
  • libs/portals/shared-modules/delegations/src/components/delegations/incoming/DelegationsIncoming.tsx
  • libs/portals/shared-modules/delegations/src/components/delegations/outgoing/DelegationsOutgoing.graphql
  • libs/portals/shared-modules/delegations/src/components/delegations/outgoing/DelegationsOutgoing.tsx
🧰 Additional context used
📓 Path-based instructions (2)
libs/portals/shared-modules/delegations/src/components/access/AccessList/AccessListContainer/AccessListContainer.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."
libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.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."
🪛 Biome
libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx

[error] 47-47: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (1)
libs/portals/shared-modules/delegations/src/components/access/AccessList/AccessListContainer/AccessListContainer.tsx (1)

Line range hint 1-67: Well-structured and reusable component implementation

The AccessListContainer component is well-implemented and adheres to best practices for shared modules:

  1. It uses TypeScript effectively for prop definitions and type safety.
  2. The component logic is generic and doesn't contain app-specific code, making it reusable across different NextJS apps.
  3. The use of shared UI components from @island.is/island-ui/core promotes consistency.
  4. The component structure allows for effective tree-shaking and bundling.

Great job on maintaining a clean and reusable component structure!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 31fd8d9 and 1d9272b.

📒 Files selected for processing (1)
  • libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.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."
🪛 Biome
libs/portals/shared-modules/delegations/src/components/delegations/DelegationViewModal.tsx

[error] 54-54: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

@saevarma saevarma removed the automerge Merge this PR as soon as all checks pass label Oct 9, 2024
@saevarma saevarma added the automerge Merge this PR as soon as all checks pass label Oct 9, 2024
@kodiakhq kodiakhq bot merged commit acd65c3 into main Oct 9, 2024
87 checks passed
@kodiakhq kodiakhq bot deleted the feat/view-delegation-and-refactor-access-card branch October 9, 2024 13:45
busla pushed a commit that referenced this pull request Oct 10, 2024
* refactor AccessCard component and make change to modal to view delegation in access control

* remove unused createdBy

* chore: nx format:write update dirty files

* refactor

* fix typo

* chore: nx format:write update dirty files

* fix type

* small refactor

* fix delete function

* chore: nx format:write update dirty files

* Adds delete modal

* chore: nx format:write update dirty files

* Update DelegationDeleteModal.tsx

* adds loading to create modal

* chore: nx format:write update dirty files

* small fixes and use view delegation modal in admin portal

* Update AccessCard.tsx

* chore: nx format:write update dirty files

* fix query and types

* 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>
GunnlaugurG pushed a commit that referenced this pull request Oct 10, 2024
* refactor AccessCard component and make change to modal to view delegation in access control

* remove unused createdBy

* chore: nx format:write update dirty files

* refactor

* fix typo

* chore: nx format:write update dirty files

* fix type

* small refactor

* fix delete function

* chore: nx format:write update dirty files

* Adds delete modal

* chore: nx format:write update dirty files

* Update DelegationDeleteModal.tsx

* adds loading to create modal

* chore: nx format:write update dirty files

* small fixes and use view delegation modal in admin portal

* Update AccessCard.tsx

* chore: nx format:write update dirty files

* fix query and types

* 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>
kodiakhq bot added a commit that referenced this pull request Oct 10, 2024
* feat(auth-admin): View delegation and refactor access card (#16243)

* refactor AccessCard component and make change to modal to view delegation in access control

* remove unused createdBy

* chore: nx format:write update dirty files

* refactor

* fix typo

* chore: nx format:write update dirty files

* fix type

* small refactor

* fix delete function

* chore: nx format:write update dirty files

* Adds delete modal

* chore: nx format:write update dirty files

* Update DelegationDeleteModal.tsx

* adds loading to create modal

* chore: nx format:write update dirty files

* small fixes and use view delegation modal in admin portal

* Update AccessCard.tsx

* chore: nx format:write update dirty files

* fix query and types

* 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>

* fix:(auth-admin): Adds nationalId to IdentityCard for createdBy in DelegationViewModal (#16347)

* adds nationalId to IdentityCard for createdBy in DelegationViewModal

* 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: Magnea Rún Vignisdóttir <[email protected]>
Co-authored-by: andes-it <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants