Skip to content

Conversation

Innocent-Akim
Copy link
Contributor

@Innocent-Akim Innocent-Akim commented Mar 1, 2025

  • Add PDF export with enhanced summary section and visual grouping
  • Implement export dialog for different file formats (PDF, CSV, XLSX)
  • Improve PDF report layout with better organization and styling
  • Add progress indicators for export operations
  • Centralize export functionality in reusable dialog component
  • Handle different report types in export process

Description

Please include a summary of the changes and the related issues.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Previous screenshots

Please add here videos or images of the previous status

Current screenshots

Please add here videos or images of the current (new) status

Summary by CodeRabbit

  • New Features

    • Improved dashboard header now accepts enhanced activity report data, enriching on-screen reporting.
    • Introduced a new PDF report generation feature that provides detailed performance metrics and visual summaries.
    • Enhanced export functionality with an interactive dialog, streamlining the process for downloading reports.
  • Chores

    • Integrated a new PDF rendering library to support the enhanced report download feature.

- Add PDF export with enhanced summary section and visual grouping
- Implement export dialog for different file formats (PDF, CSV, XLSX)
- Improve PDF report layout with better organization and styling
- Add progress indicators for export operations
- Centralize export functionality in reusable dialog component
- Handle different report types in export process
Copy link
Contributor

coderabbitai bot commented Mar 1, 2025

Warning

Rate limit exceeded

@Innocent-Akim has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 4 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 69ccb34 and 0a4b3a2.

📒 Files selected for processing (1)
  • apps/web/app/[locale]/dashboard/app-url/components/ProductivityPDF.tsx (1 hunks)

Walkthrough

The pull request introduces a new reportData prop across DashboardHeader components to pass activity report information. It adds a new ProductivityPDF component that renders a formatted PDF using @react-pdf/renderer. The export functionality is enhanced by updating the DashboardHeader to manage export states and integrating an ExportDialog that conditionally renders a PDF download link. Additionally, the dependency @react-pdf/renderer is added to support PDF generation.

Changes

File(s) Change Summary
apps/web/app/[locale]/dashboard/app-url/[teamId]/page.tsx,
apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/dashboard-header.tsx
Added new reportData prop to the DashboardHeader component. In the team-dashboard version, export functionality was integrated with state management and the conditional rendering of the ExportDialog.
apps/web/app/[locale]/dashboard/app-url/components/ProductivityPDF.tsx Introduced the new ProductivityPDF component. It generates a PDF report using @react-pdf/renderer and includes utility functions for formatting data and calculating summary statistics.
apps/web/components/ui/export-dialog.tsx Modified the ExportDialog component by removing the onDownload prop and adding exportType and reportData properties. It now conditionally renders a PDF download link that uses the ProductivityPDF component.
apps/web/package.json Added a new dependency: "@react-pdf/renderer": "^4.2.2".

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant DH as DashboardHeader
    participant ED as ExportDialog
    participant PP as ProductivityPDF
    participant PDF as PDFDownloadLink

    U->>DH: Select export option
    DH->>DH: Execute handleExportSelect()
    DH->>ED: Open ExportDialog with reportData and exportType
    ED->>ED: Check if reportData exists
    ED->>PDF: Render PDFDownloadLink
    PDF->>PP: Generate PDF document
    PP->>U: Provide downloadable PDF
Loading

Possibly related PRs

Suggested labels

feature, WEB, Improvement, Ever Teams, UI/UX

Suggested reviewers

  • evereq

Poem

Oh, what a change, so spry and neat!
As a rabbit I hop with glee, 🐇
New props and PDFs now complete,
Export dialogs set data free,
Code dances in the springtime beat!
Hoppity, happy code – oh, joy to see!


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 generate docstrings to generate docstrings for this 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

socket-security bot commented Mar 1, 2025

New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@electron/notarize@2.5.0 filesystem, shell Transitive: environment +1 105 kB electron-cfa
npm/@electron/rebuild@3.7.1 environment, filesystem, network, shell +3 262 kB electron-cfa
npm/@pmmmwh/react-refresh-webpack-plugin@0.5.15 environment, filesystem +2 1.28 MB pmmmwh
npm/@radix-ui/react-switch@1.1.3 None +13 652 kB andy-hook, benoitgrelard, chancestrickland, ...3 more
npm/@teamsupercell/typings-for-css-modules-loader@2.5.2 filesystem Transitive: eval +5 2.21 MB dannsam
npm/@testing-library/jest-dom@6.6.3 None +5 962 kB testing-library-bot
npm/@testing-library/react@14.3.1 environment +14 9.76 MB testing-library-bot
npm/@types/jest@29.5.14 None 0 78.8 kB types
npm/@types/react-test-renderer@18.3.1 None +2 455 kB types
npm/@types/terser-webpack-plugin@5.2.0 None 0 1.74 kB types
npm/@types/webpack-bundle-analyzer@4.7.0 None +1 2.06 MB types
npm/browserslist-config-erb@0.0.3 Transitive: environment, filesystem, shell +2 2.93 MB amilajack
npm/custom-electron-titlebar@4.2.8 Transitive: environment, filesystem, shell +2 3.46 MB alextorresdev
npm/electron-builder@24.13.3 Transitive: environment, eval, filesystem, shell +40 149 MB onegoldfishh
npm/electron-debug@3.2.0 Transitive: environment +4 80.6 kB sindresorhus
npm/electron-devtools-installer@3.2.1 filesystem, network +1 43.1 kB marshallofsound
npm/electron-log@4.4.8 environment, filesystem, network 0 103 kB megahertz
npm/electron-store@8.2.0 Transitive: environment, filesystem +4 180 kB sindresorhus
npm/electron-updater@6.6.0 environment, filesystem, network, shell +2 682 kB onegoldfishh
npm/electronmon@2.0.3 environment, shell +1 48.9 kB kirilv

🚮 Removed packages: npm/@ampproject/remapping@2.2.1, npm/@babel/code-frame@7.10.4, npm/@babel/compat-data@7.23.3, npm/@babel/core@7.23.3, npm/@babel/generator@7.23.4, npm/@babel/helper-annotate-as-pure@7.22.5, npm/@babel/helper-builder-binary-assignment-operator-visitor@7.22.15, npm/@babel/helper-compilation-targets@7.22.15, npm/@babel/helper-create-class-features-plugin@7.22.15, npm/@babel/helper-create-regexp-features-plugin@7.22.15, npm/@babel/helper-define-polyfill-provider@0.4.3, npm/@babel/helper-member-expression-to-functions@7.23.0, npm/@babel/helper-module-imports@7.22.15, npm/@babel/helper-optimise-call-expression@7.22.5, npm/@babel/helper-plugin-utils@7.22.5, npm/@babel/helper-remap-async-to-generator@7.22.20, npm/@babel/helper-skip-transparent-expression-wrappers@7.22.5, npm/@babel/helper-string-parser@7.23.4, npm/@babel/helper-validator-option@7.22.15, npm/@babel/helper-wrap-function@7.22.20, npm/@babel/helpers@7.23.4, npm/@babel/highlight@7.23.4, npm/@babel/parser@7.23.4, npm/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@7.23.3, npm/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@7.23.3, npm/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly@7.23.3, npm/@babel/plugin-proposal-async-generator-functions@7.20.7, npm/@babel/plugin-proposal-class-properties@7.18.6, npm/@babel/plugin-proposal-decorators@7.23.3, npm/@babel/plugin-proposal-export-default-from@7.23.3, npm/@babel/plugin-proposal-nullish-coalescing-operator@7.18.6, npm/@babel/plugin-proposal-numeric-separator@7.18.6, npm/@babel/plugin-proposal-object-rest-spread@7.20.7, npm/@babel/plugin-proposal-optional-catch-binding@7.18.6, npm/@babel/plugin-proposal-optional-chaining@7.21.0, npm/@babel/plugin-proposal-private-property-in-object@7.21.0-placeholder-for-preset-env.2, npm/@babel/plugin-syntax-async-generators@7.8.4, npm/@babel/plugin-syntax-bigint@7.8.3, npm/@babel/plugin-syntax-class-properties@7.12.13, npm/@babel/plugin-syntax-class-static-block@7.14.5, npm/@babel/plugin-syntax-decorators@7.23.3, npm/@babel/plugin-syntax-dynamic-import@7.8.3, npm/@babel/plugin-syntax-export-namespace-from@7.8.3, npm/@babel/plugin-syntax-flow@7.23.3, npm/@babel/plugin-syntax-import-assertions@7.23.3, npm/@babel/plugin-syntax-import-attributes@7.23.3, npm/@babel/plugin-syntax-import-meta@7.10.4, npm/@babel/plugin-syntax-json-strings@7.8.3, npm/@babel/plugin-syntax-jsx@7.23.3, npm/@babel/plugin-syntax-logical-assignment-operators@7.10.4, npm/@babel/plugin-syntax-nullish-coalescing-operator@7.8.3, npm/@babel/plugin-syntax-numeric-separator@7.10.4, npm/@babel/plugin-syntax-object-rest-spread@7.8.3, npm/@babel/plugin-syntax-optional-catch-binding@7.8.3, npm/@babel/plugin-syntax-optional-chaining@7.8.3, npm/@babel/plugin-syntax-private-property-in-object@7.14.5, npm/@babel/plugin-syntax-top-level-await@7.14.5, npm/@babel/plugin-syntax-typescript@7.23.3, npm/@babel/plugin-syntax-unicode-sets-regex@7.18.6, npm/@babel/plugin-transform-arrow-functions@7.23.3, npm/@babel/plugin-transform-async-generator-functions@7.23.4, npm/@babel/plugin-transform-async-to-generator@7.23.3, npm/@babel/plugin-transform-block-scoped-functions@7.23.3, npm/@babel/plugin-transform-block-scoping@7.23.4, npm/@babel/plugin-transform-class-properties@7.23.3, npm/@babel/plugin-transform-class-static-block@7.23.4, npm/@babel/plugin-transform-classes@7.23.3, npm/@babel/plugin-transform-computed-properties@7.23.3, npm/@babel/plugin-transform-destructuring@7.23.3, npm/@babel/plugin-transform-dotall-regex@7.23.3, npm/@babel/plugin-transform-duplicate-keys@7.23.3, npm/@babel/plugin-transform-dynamic-import@7.23.4, npm/@babel/plugin-transform-exponentiation-operator@7.23.3, npm/@babel/plugin-transform-export-namespace-from@7.23.4, npm/@babel/plugin-transform-flow-strip-types@7.23.3, npm/@babel/plugin-transform-for-of@7.23.3, npm/@babel/plugin-transform-function-name@7.23.3, npm/@babel/plugin-transform-json-strings@7.23.4, npm/@babel/plugin-transform-literals@7.23.3, npm/@babel/plugin-transform-logical-assignment-operators@7.23.4, npm/@babel/plugin-transform-member-expression-literals@7.23.3, npm/@babel/plugin-transform-modules-amd@7.23.3, npm/@babel/plugin-transform-modules-commonjs@7.23.3, npm/@babel/plugin-transform-modules-systemjs@7.23.3, npm/@babel/plugin-transform-modules-umd@7.23.3, npm/@babel/plugin-transform-named-capturing-groups-regex@7.22.5, npm/@babel/plugin-transform-new-target@7.23.3, npm/@babel/plugin-transform-nullish-coalescing-operator@7.23.4, npm/@babel/plugin-transform-numeric-separator@7.23.4, npm/@babel/plugin-transform-object-assign@7.23.3, npm/@babel/plugin-transform-object-rest-spread@7.23.4, npm/@babel/plugin-transform-object-super@7.23.3, npm/@babel/plugin-transform-optional-catch-binding@7.23.4, npm/@babel/plugin-transform-optional-chaining@7.23.4, npm/@babel/plugin-transform-parameters@7.23.3, npm/@babel/plugin-transform-private-methods@7.23.3, npm/@babel/plugin-transform-private-property-in-object@7.23.4, npm/sharp@0.33.5

View full report↗︎

Copy link

socket-security bot commented Mar 1, 2025

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSourceCI
HTTP dependency npm/@electron/rebuild@3.7.1 ⚠︎

View full report↗︎

Next steps

What are http dependencies?

Contains a dependency which resolves to a remote HTTP URL which could be used to inject untrusted code and reduce overall package reliability.

Publish the HTTP URL dependency to npm or a private package repository and consume it from there.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all

  • @SocketSecurity ignore npm/@electron/rebuild@3.7.1

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

🧹 Nitpick comments (5)
apps/web/components/ui/export-dialog.tsx (2)

29-34: Update success message timing

The dialog shows a success message before the user has actually downloaded the file, which could be confusing. Consider showing a progress indicator during export preparation and only showing the success message after the download has completed.


41-41: Make the report title dynamic

Currently, the PDF is always titled "Productivity Report by Date" regardless of the actual content or grouping of the report. Consider making this title dynamic based on the groupByType or other relevant parameters.

apps/web/app/[locale]/dashboard/app-url/components/ProductivityPDF.tsx (3)

12-195: Consider refactoring styles for better maintainability.

The styles object is quite large and could benefit from being broken down into smaller, more manageable sections. Consider:

  1. Extracting common styles into reusable variables
  2. Grouping related styles (header, table, summary, etc.)
  3. Moving styles to a separate file

This would improve code readability and maintainability.


296-297: Remove unnecessary empty lines.

These empty lines don't serve any purpose and should be removed.

  };

-

-
  return (

334-366: Use more reliable unique keys for list items.

The current key generation might not guarantee uniqueness in all cases. Consider using more reliable unique identifiers if available in the data.

If the activity objects have unique IDs, consider using those instead:

-                    <View style={styles.memberRow} key={`${index}-${empIndex}-${projIndex}-${actIndex}`}>
+                    <View style={styles.memberRow} key={activity.id || `${index}-${empIndex}-${projIndex}-${actIndex}`}>

If activity IDs aren't available, the current approach is acceptable but keep in mind potential issues with very large datasets.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0e21eb7 and d533be2.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • apps/web/app/[locale]/dashboard/app-url/[teamId]/page.tsx (1 hunks)
  • apps/web/app/[locale]/dashboard/app-url/components/ProductivityPDF.tsx (1 hunks)
  • apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/dashboard-header.tsx (4 hunks)
  • apps/web/components/ui/export-dialog.tsx (1 hunks)
  • apps/web/package.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: deploy
  • GitHub Check: deploy
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (10)
apps/web/package.json (1)

73-73: New dependency for PDF export added

The @react-pdf/renderer package has been added to support the new PDF export functionality. This package is used by the new ProductivityPDF component to render PDF reports.

apps/web/app/[locale]/dashboard/app-url/[teamId]/page.tsx (1)

118-118: LGTM - Report data passed to DashboardHeader

The reportData prop is correctly passed to the DashboardHeader component, providing the necessary data for export functionality.

apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/dashboard-header.tsx (5)

11-11: Added import for ExportDialog component

Appropriate import for the export dialog component.


21-21: Updated interface to include reportData property

The DashboardHeaderProps interface has been updated to include the reportData property which is necessary for the export functionality.


35-43: State management for export functionality added

Good implementation of state management for tracking the export dialog state and selected export type.


57-69: Enhanced UI with export options dropdown

The dropdown implementation for export options is well-structured and correctly wired to the handler function.


70-75:

❓ Verification inconclusive

Implement handling for all export types

Currently, the implementation only supports PDF exports as seen in the ExportDialog component. The UI suggests that CSV and XLSX exports are also available, but the functionality to handle these formats is missing.


🏁 Script executed:

#!/bin/bash
# Check if there's any implementation for CSV or XLSX export in the codebase
echo "Searching for CSV export implementation..."
rg -g "*.tsx" -g "*.ts" "csv.*export" --ignore-case

echo "Searching for XLSX export implementation..."
rg -g "*.tsx" -g "*.ts" "xlsx.*export" --ignore-case

Length of output: 300


Attention: Missing CSV & XLSX Export Functionality

In the file
apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/dashboard-header.tsx (lines 70–75), the <ExportDialog> is configured with props such as exportType and reportData. However, our verification (via codebase search patterns for identifiers like "csv.*export" and "xlsx.*export") did not reveal any handling logic for CSV or XLSX exports—only the PDF export functionality appears to be implemented. This creates a discrepancy between the UI, which suggests multiple export options, and the underlying functionality.

Action Items:

  • Implement CSV and XLSX export handling: Add the necessary logic to enable these export types in the ExportDialog (or in a dedicated module) if they are intended to be supported.
  • Or, update the UI: If only PDF exports are meant to be supported, remove or adjust the UI options for CSV and XLSX to reflect the actual functionality.
apps/web/components/ui/export-dialog.tsx (2)

14-15: PDF export dependencies added

Appropriate imports for PDF generation functionality.


17-22: Updated ExportDialog props interface

The interface has been appropriately updated to include the exportType and reportData properties.

apps/web/app/[locale]/dashboard/app-url/components/ProductivityPDF.tsx (1)

1-421: Overall well-structured PDF generation component.

The ProductivityPDF component is comprehensive and well-designed, with good organization of different report sections (header, daily activities, and summary statistics). The styling creates a professional-looking report with clear visual hierarchy.

Some minor improvements have been suggested, but overall this is a solid implementation that meets the requirements for multi-format export functionality.

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

♻️ Duplicate comments (2)
apps/web/components/ui/export-dialog.tsx (2)

39-55: ⚠️ Potential issue

Missing CSV export implementation

According to the PR objectives, the export functionality should support CSV format, but there's no implementation for it in the code.

Add support for CSV export:

         {reportData && exportType === 'xlsx' && (
           <Button variant="outline" size="sm" >
             Download XLSX
           </Button>
         )}
+         {reportData && exportType === 'csv' && (
+           <Button 
+             variant="outline" 
+             size="sm" 
+             onClick={() => handleCSVExport(reportData)}
+           >
+             Download CSV
+           </Button>
+         )}

You'll need to implement the handleCSVExport function to process the report data and generate the CSV file.


51-55: ⚠️ Potential issue

XLSX download button is missing an onClick handler

The XLSX download button is present but doesn't have any functionality attached to it. You need to implement the XLSX export handler to make this work.

-         {reportData && exportType === 'xlsx' && (
-           <Button variant="outline" size="sm" >
-             Download XLSX
-           </Button>
-         )}
+         {reportData && exportType === 'xlsx' && (
+           <Button 
+             variant="outline" 
+             size="sm" 
+             onClick={() => handleXLSXExport(reportData)}
+           >
+             Download XLSX
+           </Button>
+         )}

You'll need to implement the handleXLSXExport function to process the report data and generate the XLSX file.

🧹 Nitpick comments (3)
apps/web/components/ui/export-dialog.tsx (3)

20-21: Consider using a more specific type for reportData

The reportData property is typed as any[] | undefined, which loses type safety. Consider defining a more specific interface or type for your report data to ensure type checking and better IDE support.

-	reportData?: any[] | undefined;
+	reportData?: ReportDataItem[] | undefined;

You could define a ReportDataItem interface that matches the expected structure of your report data.


41-41: Consider making the PDF title dynamic

The title for the PDF is hardcoded as 'Productivity Report by Date'. Consider making it dynamic based on the report type or adding it as a prop to the ExportDialog component.

-              document={<ProductivityPDF data={reportData} title={'Productivity Report by Date'} />}
+              document={<ProductivityPDF data={reportData} title={title || 'Productivity Report by Date'} />}

You would need to update the ExportDialogProps interface to include a title property:

interface ExportDialogProps {
  isOpen: boolean;
  onClose: () => void;
  exportType?: string;
  reportData?: any[] | undefined;
  title?: string;
}

24-24: Consider using an enum for exportType

Using a string for exportType might lead to errors if a typo is made. Consider using an enum to ensure type safety.

+enum ExportType {
+  PDF = 'pdf',
+  CSV = 'csv',
+  XLSX = 'xlsx'
+}
+
 interface ExportDialogProps {
 	isOpen: boolean;
 	onClose: () => void;
-	exportType?: string;
+	exportType?: ExportType;
 	reportData?: any[] | undefined;
 }

Then update the conditions accordingly:

-       {reportData && exportType === 'pdf' && (
+       {reportData && exportType === ExportType.PDF && (
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d533be2 and 69ccb34.

📒 Files selected for processing (2)
  • apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/dashboard-header.tsx (4 hunks)
  • apps/web/components/ui/export-dialog.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/dashboard-header.tsx
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: deploy
  • GitHub Check: deploy
🔇 Additional comments (1)
apps/web/components/ui/export-dialog.tsx (1)

39-50: The PDF export implementation looks good

The PDF export implementation with loading state feedback is well done. The PDFDownloadLink component correctly renders a button with loading state while the PDF is being prepared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants