-
Notifications
You must be signed in to change notification settings - Fork 74
Feat: Implement multi-format report export functionality #3629
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
Conversation
- 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
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 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. 📒 Files selected for processing (1)
WalkthroughThe pull request introduces a new Changes
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
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎ To accept the risk, merge this PR and you will not be notified again.
Next stepsWhat 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 dependencyTake 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 packageIf 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 riskTo ignore an alert, reply with a comment starting with
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
🧹 Nitpick comments (5)
apps/web/components/ui/export-dialog.tsx (2)
29-34
: Update success message timingThe 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 dynamicCurrently, 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:
- Extracting common styles into reusable variables
- Grouping related styles (header, table, summary, etc.)
- 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
⛔ 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 addedThe
@react-pdf/renderer
package has been added to support the new PDF export functionality. This package is used by the newProductivityPDF
component to render PDF reports.apps/web/app/[locale]/dashboard/app-url/[teamId]/page.tsx (1)
118-118
: LGTM - Report data passed to DashboardHeaderThe
reportData
prop is correctly passed to theDashboardHeader
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 componentAppropriate import for the export dialog component.
21-21
: Updated interface to include reportData propertyThe DashboardHeaderProps interface has been updated to include the reportData property which is necessary for the export functionality.
35-43
: State management for export functionality addedGood implementation of state management for tracking the export dialog state and selected export type.
57-69
: Enhanced UI with export options dropdownThe 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-caseLength 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 asexportType
andreportData
. 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 addedAppropriate imports for PDF generation functionality.
17-22
: Updated ExportDialog props interfaceThe 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.
apps/web/app/[locale]/dashboard/app-url/components/ProductivityPDF.tsx
Outdated
Show resolved
Hide resolved
apps/web/app/[locale]/dashboard/app-url/components/ProductivityPDF.tsx
Outdated
Show resolved
Hide resolved
apps/web/app/[locale]/dashboard/app-url/components/ProductivityPDF.tsx
Outdated
Show resolved
Hide resolved
apps/web/app/[locale]/dashboard/app-url/components/ProductivityPDF.tsx
Outdated
Show resolved
Hide resolved
apps/web/app/[locale]/dashboard/app-url/components/ProductivityPDF.tsx
Outdated
Show resolved
Hide resolved
apps/web/app/[locale]/dashboard/app-url/components/ProductivityPDF.tsx
Outdated
Show resolved
Hide resolved
apps/web/app/[locale]/dashboard/app-url/components/ProductivityPDF.tsx
Outdated
Show resolved
Hide resolved
apps/web/app/[locale]/dashboard/app-url/components/ProductivityPDF.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (2)
apps/web/components/ui/export-dialog.tsx (2)
39-55
:⚠️ Potential issueMissing 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 issueXLSX 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 forreportData
The
reportData
property is typed asany[] | 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 dynamicThe 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 forexportType
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
📒 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 goodThe 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.
Description
Please include a summary of the changes and the related issues.
Type of Change
Checklist
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
Chores