Skip to content

Conversation

Innocent-Akim
Copy link
Contributor

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

  • Create new ProductivityApplicationPDF component for report generation
  • Implement ExportDialog with PDF and XLSX export options
  • Add PDF report layout with proper data grouping by application
  • Configure web-hosted Helvetica font for reliable rendering
  • Optimize table layout for better data presentation
  • Include report header with title and generation date

#3416

This change introduces a complete PDF export feature for productivity reports, allowing users to download well-formatted activity summaries grouped by application.

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

    • Introduced a PDF report that presents detailed productivity activities.
  • Enhancements

    • Upgraded the export dialog to offer dynamic report titles and clear export options (PDF and XLSX).
    • Improved the dashboard export selector to allow only valid export types.
    • Adjusted task view so that empty state messaging appears only when appropriate.

- Create new ProductivityApplicationPDF component for report generation
- Implement ExportDialog with PDF and XLSX export options
- Add PDF report layout with proper data grouping by application
- Configure web-hosted Helvetica font for reliable rendering
- Optimize table layout for better data presentation
- Include report header with title and generation date

This change introduces a complete PDF export feature for
productivity reports, allowing users to download well-formatted
activity summaries grouped by application.
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Akim seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

coderabbitai bot commented Mar 11, 2025

Walkthrough

This pull request introduces a new React component for generating PDF reports of productivity activities and updates export-related functionality. A new file implements a PDF generator using the @react-pdf/renderer library. The export dialog is refactored to extract button rendering logic, and state management is updated in the dashboard header with stricter export type definitions. Additionally, the duration formatting function is made exportable, and the conditional rendering of empty task messages is refined based on the current tab state.

Changes

File(s) Change Summary
apps/web/app/[locale]/dashboard/app-url/components/.../Productivity-applicationPDF.tsx Introduces a new React component (ProductivityApplicationPDF) for generating PDF reports, including custom fonts, layout styles, and data grouping for productivity activities.
apps/web/app/[locale]/dashboard/app-url/components/.../ProductivityApplicationTable.tsx Updates the formatDuration function to be exported, making it reusable across different modules.
apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/dashboard-header.tsx Modifies state management and function parameter types for export selection, restricting values to `'export'
apps/web/components/ui/export-dialog.tsx Refactors the export dialog by extracting export buttons into a new ExportButtons component, updating the props interface to use specific union types, and adding a function (getReportTitle) for dynamic titles.
apps/web/lib/features/user-profile-tasks.tsx Adjusts the conditional rendering logic for the EmptyPlans component to display only when the current tab is not 'stats', enhancing control flow based on state.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant DH as DashboardHeader
    participant ED as ExportDialog
    participant EB as ExportButtons
    participant PDF as PDF Component

    U->>DH: Select export type ('pdf')
    DH->>ED: Update state & open export dialog with type 'pdf'
    ED->>EB: Render export buttons based on exportType and groupByType
    EB->>PDF: Conditionally render ProductivityApplicationPDF
    PDF-->>ED: Return generated PDF document
    ED->>U: Provide PDF download link
Loading

Possibly related PRs

Suggested labels

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

Suggested reviewers

  • evereq
  • Cedric921

Poem

I'm a little rabbit, hopping through the code,
With PDFs and exports lightening every node.
My ears perk up at union types so neat,
And export buttons making our code complete.
In a land of functions and structured reports so fine,
I celebrate these changes with a joyful bunny sign!
🐰💻

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/web/app/[locale]/dashboard/app-url/components/productivity-application/Productivity-applicationPDF.tsx

Oops! Something went wrong! :(

ESLint: 8.46.0

ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.

The config "next/core-web-vitals" was referenced from the config file in "/apps/web/.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

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

Oops! Something went wrong! :(

ESLint: 8.46.0

ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.

The config "next/core-web-vitals" was referenced from the config file in "/apps/web/.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

apps/web/app/[locale]/dashboard/app-url/components/productivity-application/ProductivityApplicationTable.tsx

Oops! Something went wrong! :(

ESLint: 8.46.0

ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.

The config "next/core-web-vitals" was referenced from the config file in "/apps/web/.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

  • 2 others
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.

@Innocent-Akim Innocent-Akim self-assigned this Mar 11, 2025
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

🧹 Nitpick comments (3)
apps/web/app/[locale]/dashboard/app-url/components/productivity-application/Productivity-applicationPDF.tsx (3)

13-16: Consider bundling the font or using a fallback strategy.

Relying on an external font URL creates a dependency that could fail if the URL becomes unavailable.

Consider one of these approaches:

  1. Bundle the font with your application
  2. Implement a fallback mechanism:
Font.register({
	family: 'Helvetica',
	src: 'https://fonts.gstatic.com/s/helveticaneue/v70/1Ptsg8zYS_SKggPNyC0IT0kLW-43aMEzIO6XUTLjad8.ttf',
+	fallback: 'Helvetica'
});

1-1: File naming inconsistency.

The filename "Productivity-applicationPDF.tsx" uses inconsistent capitalization. React component files typically use PascalCase throughout.

Consider renaming the file to "ProductivityApplicationPDF.tsx" for consistency with naming conventions.


134-138: Use a more consistent date formatting approach.

You're using two different date formatting methods in the same component: here with toLocaleDateString() and elsewhere with the format() function from date-fns.

For consistency, consider using date-fns throughout:

-	const today = new Date().toLocaleDateString('en-US', {
-		year: 'numeric',
-		month: 'long',
-		day: 'numeric'
-	});
+	const today = format(new Date(), 'MMMM dd, yyyy');
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2b68443 and 7658e97.

📒 Files selected for processing (5)
  • apps/web/app/[locale]/dashboard/app-url/components/productivity-application/Productivity-applicationPDF.tsx (1 hunks)
  • apps/web/app/[locale]/dashboard/app-url/components/productivity-application/ProductivityApplicationTable.tsx (1 hunks)
  • apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/dashboard-header.tsx (1 hunks)
  • apps/web/components/ui/export-dialog.tsx (1 hunks)
  • apps/web/lib/features/user-profile-tasks.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: deploy
🔇 Additional comments (9)
apps/web/lib/features/user-profile-tasks.tsx (1)

132-132: Improved conditional rendering for empty state.

This change properly handles the empty state by showing the EmptyPlans component only when there are no tasks to display and the current tab is not the 'stats' tab. This ensures that the stats tab won't display the empty tasks message, which makes sense since that tab is meant to show statistics rather than tasks.

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

205-205: Good refactoring to export the formatDuration function.

Making this function exportable allows it to be reused in other components, specifically in the new ProductivityApplicationPDF component. This promotes code reuse and maintains consistency in duration formatting across the application.

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

36-36: Improved type safety for export type state.

Changing from a generic string to a specific union type improves type safety by restricting the possible values to only valid export types.


38-38: Improved type safety for handleExportSelect parameter.

Using the union type for the function parameter ensures that only valid export types can be passed to the function, which aligns with the state type and prevents potential errors.

apps/web/app/[locale]/dashboard/app-url/components/productivity-application/Productivity-applicationPDF.tsx (1)

1-216: Well-structured PDF export implementation for productivity reports.

The component successfully implements PDF export functionality using @react-pdf/renderer, with good organization of data by application and clear visual presentation.

apps/web/components/ui/export-dialog.tsx (4)

16-17: LGTM: Appropriate import additions

The imports for GroupByType and ProductivityApplicationPDF are correctly added to support the new PDF export functionality.


21-22: LGTM: Improved type safety in ExportDialogProps

Good improvements to the interface:

  • Making onClose optional provides more flexibility
  • Using a union type for exportType ensures type safety
  • Adding the optional groupByType prop supports the new report grouping functionality

Also applies to: 24-24


27-38: LGTM: Well-structured report title mapping

The getReportTitle function is well-implemented with:

  • A default parameter value
  • Type-safe mapping using Record
  • A fallback return value for unexpected cases

76-95: LGTM: Clean component refactoring

The ExportDialog component has been nicely refactored to:

  • Use the new ExportButtons component
  • Pass all necessary props correctly
  • Maintain a clean and readable structure

@evereq
Copy link
Member

evereq commented Mar 12, 2025

@Innocent-Akim can you check why it suggest that CAA not signed? #3659 (comment)

@evereq evereq merged commit 2277b7a into develop Mar 12, 2025
12 of 13 checks passed
@evereq evereq deleted the feat/productivity--pdf-export branch March 12, 2025 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants