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

fix(service-portal): petitions - export list #16850

Merged
merged 11 commits into from
Nov 14, 2024
Merged

Conversation

albinagu
Copy link
Member

@albinagu albinagu commented Nov 13, 2024

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

  • New Features

    • Enhanced PDF document layout for endorsement lists, improving visual presentation.
    • Added national ID formatting for better display in PDF documents.
    • Updated date formatting for document creation timestamps.
  • Bug Fixes

    • Improved error handling for missing endorsement lists, with appropriate warnings.
    • Validation added for file export types, restricting to 'pdf' or 'csv'.
  • Access Control

    • Implemented user permission checks for accessing endorsement lists, limiting access to admins or list owners.

@albinagu albinagu requested a review from a team as a code owner November 13, 2024 13:39
Copy link
Contributor

coderabbitai bot commented Nov 13, 2024

Walkthrough

The changes in this pull request focus on the EndorsementListService class within the endorsementList.service.ts file. Key modifications include the addition of imports for handling national ID formatting and date formatting. The createDocumentBuffer method has been updated to enhance PDF layout and formatting, including adjustments to text positioning and content. Error handling improvements have been made in the emailPDF and emailLock methods, and the exportList method now validates file types. Additionally, user permission checks have been added to the fetchEndorsementList method.

Changes

File Path Change Summary
apps/services/endorsements/api/src/app/modules/endorsementList/endorsementList.service.ts - Added imports for nationalId and format.
- Updated createDocumentBuffer for PDF layout.
- Enhanced error handling in emailPDF and emailLock.
- Added file type validation in exportList.
- Implemented user permission checks in fetchEndorsementList.

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • kksteini
  • thordurhhh

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.

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: 3

🧹 Outside diff range and nitpick comments (4)
libs/service-portal/petitions/src/screens/PetitionsTable/ExportPetition/index.tsx (4)

Line range hint 16-31: Unused petition prop in DropdownExport component

The petition prop is defined in the Props interface but is not utilized within the DropdownExport component. Including unused props can lead to confusion and unnecessarily complicates the code.

Consider removing the petition prop from the Props interface to simplify the component and improve code clarity.


38-38: Direct use of window and document may affect component reusability

The component directly accesses document.location.origin and window.open, which can cause issues in environments where window and document are not available, such as server-side rendering (SSR) or during static site generation (SSG).

To enhance reusability across different NextJS apps and prevent potential runtime errors, consider:

  • Checking if window and document are defined before use.
  • Moving the code that uses window and document into useEffect hooks to ensure they run only on the client side.
  • Abstracting these calls into utility functions that handle environment checks.

Also applies to: 49-49, 61-61


41-51: Specify TypeScript types for mutation results

The useMutation hooks for exportPdf and exportCsv do not explicitly specify TypeScript types for the mutation results and variables. Explicit types enhance type safety, improve code readability, and help prevent runtime errors.

Consider defining the types for the mutation results and variables:

const [exportPdf, { loading: loadingPdf }] = useMutation<ExportListResponse, ExportListVariables>(ExportList, { ... })

Replace ExportListResponse and ExportListVariables with the appropriate types from your GraphQL schema.

Also applies to: 53-63


15-15: Consider using absolute imports for better maintainability and reusability

Importing modules using relative paths like '../../queries' can make the codebase harder to maintain and may hinder reusability across different projects or apps.

Consider configuring the project to use absolute imports or path aliases. This can be set up in your tsconfig.json:

{
  "compilerOptions": {
    "baseUrl": "src",
    "paths": {
      "@your-alias/*": ["*"]
    }
  }
}

Then, you can import using:

import { ExportList } from '@your-alias/queries'

This approach improves code readability and makes module paths more manageable.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2401e53 and da0ee5a.

📒 Files selected for processing (3)
  • libs/service-portal/petitions/src/screens/PetitionsTable/ExportPetition/index.tsx (3 hunks)
  • libs/service-portal/petitions/src/screens/PetitionsTable/styles.css.ts (1 hunks)
  • libs/service-portal/petitions/src/screens/queries.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
libs/service-portal/petitions/src/screens/PetitionsTable/ExportPetition/index.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/service-portal/petitions/src/screens/PetitionsTable/styles.css.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/service-portal/petitions/src/screens/queries.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (2)
libs/service-portal/petitions/src/screens/PetitionsTable/styles.css.ts (1)

6-6: LGTM! Well-structured style definition.

The addition of paddingBottom creates symmetric vertical spacing for menu items. The code demonstrates good practices:

  • Uses theme tokens for consistent styling
  • Properly exports typed styles for reuse
  • Follows tree-shakeable pattern with individual exports
libs/service-portal/petitions/src/screens/queries.ts (1)

174-177: Verify the removal of list management mutations

The AI summary indicates that LockList, UnlockList, and UpdateList mutations were removed. Let's verify if these operations are now handled differently or if they're still needed.

@albinagu albinagu added the automerge Merge this PR as soon as all checks pass label Nov 13, 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: 0

🧹 Outside diff range and nitpick comments (8)
libs/service-portal/petitions/src/screens/PetitionsTable/ExportPetition/index.tsx (4)

Line range hint 17-30: Consider extracting shared types for better reusability.

Since this component is in the libs directory, consider extracting the dropdown item type into a separate types file for reuse across different components.

+// types.ts
+export interface DropdownItem {
+  href?: string
+  onClick?: () => void
+  title: string
+  render?: (
+    element: ReactElement,
+    index: number,
+    className: string,
+  ) => ReactElement
+}

-interface Props {
+type Props = {
   petition?: EndorsementList
   petitionId: string
-  dropdownItems?: {
-    href?: string
-    onClick?: () => void
-    title: string
-    render?: (
-      element: ReactElement,
-      index: number,
-      className: string,
-    ) => ReactElement
-  }[]
+  dropdownItems?: DropdownItem[]
 }

41-63: Refactor mutation setup to reduce duplication.

The PDF and CSV export mutations share similar configuration. Consider creating a custom hook to encapsulate the export logic:

const useExportMutation = (fileType: 'pdf' | 'csv') => {
  return useMutation(ExportList, {
    variables: {
      input: {
        listId: petitionId,
        fileType,
      },
    },
    onCompleted: (data) => {
      const url = data.endorsementSystemExportList.url;
      fileType === 'pdf' ? window.open(url, '_blank') : window.location.href = url;
    },
    onError: (error) => {
      toast.error(formatMessage(m.exportError));
    }
  });
};

// Usage:
const [exportPdf, { loading: loadingPdf }] = useExportMutation('pdf');
const [exportCsv, { loading: loadingCsv }] = useExportMutation('csv');

Line range hint 67-81: Extract copy link functionality to reduce code duplication.

The copy link logic is duplicated between desktop and mobile views. Consider extracting it into a reusable handler:

const handleCopyLink = () => {
  const copied = copyToClipboard(baseUrl + petitionId);
  if (!copied) {
    return toast.error(formatMessage(m.copyLinkError.defaultMessage));
  }
  toast.success(formatMessage(m.copyLinkSuccess.defaultMessage));
};

// Usage in both desktop and mobile buttons:
onClick={handleCopyLink}

Also applies to: 90-107


Line range hint 31-150: Consider adding ARIA attributes for better accessibility.

The component could benefit from improved accessibility:

  • Add aria-label to buttons
  • Include role="menu" and role="menuitem" attributes
  • Add keyboard navigation support

Example:

 <Button
+  aria-label={formatMessage(m.copyLinkToList)}
   onClick={handleCopyLink}
   variant="utility"
   icon="link"
 >
   {formatMessage(m.copyLinkToList)}
 </Button>
apps/services/endorsements/api/src/app/modules/endorsementList/endorsementList.service.ts (4)

362-386: Refactor Suggestion: Reduce code duplication in PDF text rendering

The PDF generation code contains repetitive patterns for setting fonts and adding text. Consider creating helper functions to streamline the code and enhance maintainability.

For example, you could define a helper function:

function addText(doc, font, fontSize, text, x, y, options = {}) {
  doc.font(font).fontSize(fontSize).text(text, x, y, options)
}

And refactor the code as:

addText(doc, 'Bold', 12, 'Þetta skjal var framkallað sjálfvirkt þann: ', 60, currentYPosition, { align: 'left' })

422-424: Typographical Correction: Update label to reflect correct language gender

The label 'Opinn til: ' should be gender-neutral or match the context appropriately. In Icelandic, consider using 'Opin til: ' if referring to a feminine noun.

Apply this diff to correct the label:

-.text('Opinn til: ', 60, currentYPosition, { align: 'left' })
+.text('Opin til: ', 60, currentYPosition, { align: 'left' })

Line range hint 691-742: Security Issue: Sanitize 'listId' when generating filenames

The listId is directly used in the filename, which could pose a security risk if it contains special characters. Ensure that listId is sanitized to prevent potential directory traversal or injection attacks.

Apply this diff to sanitize listId:

-const filename = `undirskriftalisti-${listId}-${new Date()
+const safeListId = listId.replace(/[^a-zA-Z0-9_-]/g, '')
+const filename = `undirskriftalisti-${safeListId}-${new Date()
   .toISOString()
   .replace(/[:.]/g, '-')}.${fileType}`

Line range hint 777-785: Error Handling Improvement: Provide specific error messages

In the createPdfBuffer method, errors are caught and rethrown with a generic message. Consider providing more specific error messages to aid in debugging.

Apply this diff to include the original error message:

-throw new Error(
-  \`Error generating PDF for endorsement list \${endorsementList.id}\`,
-)
+throw new Error(
+  \`Error generating PDF for endorsement list \${endorsementList.id}: \${error.message}\`,
+)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between da0ee5a and e60eaa9.

📒 Files selected for processing (4)
  • apps/services/endorsements/api/src/app/modules/endorsementList/endorsementList.service.ts (10 hunks)
  • libs/service-portal/petitions/src/screens/PetitionsTable/ExportPetition/DownloadPdf/index.tsx (0 hunks)
  • libs/service-portal/petitions/src/screens/PetitionsTable/ExportPetition/downloadCSV.ts (0 hunks)
  • libs/service-portal/petitions/src/screens/PetitionsTable/ExportPetition/index.tsx (3 hunks)
💤 Files with no reviewable changes (2)
  • libs/service-portal/petitions/src/screens/PetitionsTable/ExportPetition/DownloadPdf/index.tsx
  • libs/service-portal/petitions/src/screens/PetitionsTable/ExportPetition/downloadCSV.ts
🧰 Additional context used
📓 Path-based instructions (2)
apps/services/endorsements/api/src/app/modules/endorsementList/endorsementList.service.ts (2)

Pattern apps/services/**/*: "Confirm that the code adheres to the following:

  • NestJS architecture, including modules, services, and controllers.
  • Dependency injection patterns and service encapsulation.
  • Integration and unit testing coverage and practices."

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
libs/service-portal/petitions/src/screens/PetitionsTable/ExportPetition/index.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 (12)
libs/service-portal/petitions/src/screens/PetitionsTable/ExportPetition/index.tsx (2)

1-16: LGTM! Well-structured imports following TypeScript guidelines.

The imports are properly organized and typed, adhering to the library code guidelines for TypeScript usage.


82-148: LGTM! Well-implemented dropdown menu with proper loading states.

The dropdown menu implementation is clean with:

  • Consistent onClick handling
  • Clear loading indicators
  • Good user feedback
apps/services/endorsements/api/src/app/modules/endorsementList/endorsementList.service.ts (10)

32-33: Approved: New imports are correctly added and used

The new imports for kennitala and date-fns/format are appropriately added and utilized in the code.


351-353: Approved: Header image placement and initial Y-coordinate calculation

The header image is correctly positioned, and currentYPosition is accurately calculated to ensure proper spacing for subsequent content.


395-395: Approved: Display of endorsement list title is correct

The endorsement list title is correctly displayed using the appropriate font settings.


410-410: Approved: Display of endorsement list description is correct

The description is rendered properly, maintaining consistency in styling.


441-441: Approved: Correct display of endorsement count

The endorsement count is displayed accurately with proper formatting.


455-455: Approved: Owner's name displayed correctly

The owner's name is rendered properly in the document.


532-532: Approved: Footer image is added correctly

The footer image is correctly placed at the bottom of the page.


Line range hint 760-766: Security Advisory: Ensure CSV fields are properly escaped

When generating CSV files, verify that all fields are properly escaped to prevent CSV injection attacks. Confirm that the csvStringify library securely handles data that may contain malicious content.

To ensure csvStringify is used securely, review its documentation and update to the latest version if necessary.


Line range hint 805-820: Approved: Proper content type set when uploading files to S3

The content type is correctly set based on the file type during the S3 upload.


469-476: Verify: Ensure 'endorsementList.owner' contains a valid national ID

When formatting the owner's national ID using nationalId.format, confirm that endorsementList.owner is a valid national ID to prevent any formatting errors.

To verify that all endorsement lists have valid owner national IDs, run the following script:

@datadog-island-is
Copy link

datadog-island-is bot commented Nov 13, 2024

Datadog Report

All test runs d3109b1 🔗

7 Total Test Services: 0 Failed, 7 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.03%), 15 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 3.08s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 14.14s 1 no change Link
application-system-api 0 0 0 112 2 3m 44.05s 1 no change Link
application-template-api-modules 0 0 0 113 0 2m 34.54s 1 no change Link
portals-admin-ids-admin 0 0 0 2 0 8.97s 1 no change Link
services-auth-admin-api 0 0 0 130 0 3m 49.87s 1 no change Link
services-endorsements-api 0 0 0 42 0 44.42s 1 decreased (-0.03%) Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • services-endorsements-api - jest 51.4% (-0.03%) - Details

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: 1

🧹 Outside diff range and nitpick comments (2)
apps/services/endorsements/api/src/app/modules/endorsementList/endorsementList.service.ts (2)

364-383: Improve code maintainability with constants

The positioning calculations use magic numbers. Consider extracting these values into named constants for better maintainability.

+  private readonly PDF_MARGINS = {
+    top: 40,
+    left: 60,
+    right: 60,
+    bottom: 60
+  };
+  private readonly SPACING = {
+    paragraph: 15,
+    line: 5
+  };

   doc
     .font('Bold')
     .fontSize(12)
-    .text('Þetta skjal var framkallað sjálfvirkt þann: ', 60, currentYPosition)
+    .text('Þetta skjal var framkallað sjálfvirkt þann: ', 
+      this.PDF_MARGINS.left, 
+      currentYPosition
+    )

Line range hint 766-803: Consider implementing file management strategy

The S3 upload implementation is good, but consider adding:

  1. File size limits to prevent excessive resource usage
  2. A cleanup strategy for exported files (e.g., TTL policy)
  3. Rate limiting for export requests
 private async uploadFileToS3(
   fileBuffer: Buffer,
   filename: string,
   fileType: 'pdf' | 'csv',
 ): Promise<void> {
+  const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB
+  if (fileBuffer.length > MAX_FILE_SIZE) {
+    throw new BadRequestException('File size exceeds maximum limit');
+  }
   try {
     await this.s3Service.uploadFile(
       fileBuffer,
       { bucket: environment.exportsBucketName, key: filename },
       {
         ContentType: fileType === 'pdf' ? 'application/pdf' : 'text/csv',
+        Metadata: {
+          'expiry-date': new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString() // 24 hours
+        }
       },
     )
   } catch (error) {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e60eaa9 and a6c017e.

📒 Files selected for processing (1)
  • apps/services/endorsements/api/src/app/modules/endorsementList/endorsementList.service.ts (10 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
apps/services/endorsements/api/src/app/modules/endorsementList/endorsementList.service.ts (2)

Pattern apps/services/**/*: "Confirm that the code adheres to the following:

  • NestJS architecture, including modules, services, and controllers.
  • Dependency injection patterns and service encapsulation.
  • Integration and unit testing coverage and practices."

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (1)
apps/services/endorsements/api/src/app/modules/endorsementList/endorsementList.service.ts (1)

32-33: LGTM: Appropriate imports added

The new imports for national ID formatting and date formatting are well-chosen for the enhanced PDF generation functionality.

Copy link

codecov bot commented Nov 13, 2024

Codecov Report

Attention: Patch coverage is 18.18182% with 9 lines in your changes missing coverage. Please review.

Project coverage is 36.43%. Comparing base (537618d) to head (ae9b823).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...modules/endorsementList/endorsementList.service.ts 18.18% 9 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16850      +/-   ##
==========================================
- Coverage   36.45%   36.43%   -0.02%     
==========================================
  Files        6852     6852              
  Lines      143561   143522      -39     
  Branches    40973    40977       +4     
==========================================
- Hits        52328    52295      -33     
+ Misses      91233    91227       -6     
Flag Coverage Δ
api 3.34% <ø> (ø)
api-domains-auth-admin 48.48% <ø> (ø)
application-system-api 40.98% <ø> (ø)
application-template-api-modules 27.65% <ø> (ø)
services-auth-admin-api 52.49% <ø> (ø)
services-endorsements-api 53.23% <18.18%> (-0.04%) ⬇️

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

Files with missing lines Coverage Δ
...modules/endorsementList/endorsementList.service.ts 30.03% <18.18%> (+0.06%) ⬆️

... and 12 files 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 537618d...ae9b823. Read the comment docs.

@kodiakhq kodiakhq bot removed the automerge Merge this PR as soon as all checks pass label Nov 13, 2024
Copy link
Contributor

kodiakhq bot commented Nov 13, 2024

This PR currently has a merge conflict. Please resolve this and then re-add the automerge label.

@albinagu albinagu added the automerge Merge this PR as soon as all checks pass label Nov 14, 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: 0

🧹 Outside diff range and nitpick comments (1)
apps/services/endorsements/api/src/app/modules/endorsementList/endorsementList.service.ts (1)

Line range hint 815-835: Consider implementing rate limiting for export operations

The fetchEndorsementList method has good permission checks, but consider adding rate limiting to prevent potential abuse of the export functionality, especially since it involves resource-intensive operations like PDF generation and S3 uploads.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a6c017e and 67c8d44.

📒 Files selected for processing (1)
  • apps/services/endorsements/api/src/app/modules/endorsementList/endorsementList.service.ts (10 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
apps/services/endorsements/api/src/app/modules/endorsementList/endorsementList.service.ts (2)

Pattern apps/services/**/*: "Confirm that the code adheres to the following:

  • NestJS architecture, including modules, services, and controllers.
  • Dependency injection patterns and service encapsulation.
  • Integration and unit testing coverage and practices."

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (4)
apps/services/endorsements/api/src/app/modules/endorsementList/endorsementList.service.ts (4)

33-34: LGTM! Good choice of libraries

The addition of kennitala for national ID formatting and date-fns for date formatting improves code maintainability and standardization.


359-359: Consider environment-independent asset loading

The hard-coded paths to assets (images) might cause issues in different deployment environments. Consider implementing proper error handling for missing assets.

Also applies to: 537-538


478-480: LGTM! Proper formatting of national ID

The use of nationalId.format ensures consistent formatting of national IDs in the PDF output.


372-391: LGTM! Clear and consistent date formatting

The use of format from date-fns ensures consistent date formatting throughout the document. The positioning and styling are well-organized.

@kodiakhq kodiakhq bot merged commit b141441 into main Nov 14, 2024
48 checks passed
@kodiakhq kodiakhq bot deleted the sp_petitions_exportlist branch November 14, 2024 11:01
jonnigs pushed a commit that referenced this pull request Nov 26, 2024
* fix(service-portal): petitions - export list

* chore: nx format:write update dirty files

* tweaks

* final tweak

* aaand clean

* tiny

* one more clean up

* 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>
@coderabbitai coderabbitai bot mentioned this pull request Jan 7, 2025
6 tasks
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