Skip to content

[Feature(pdf)]: Team Dashboard | Export URL APP Data PDF #3673

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

Merged
merged 2 commits into from
Mar 17, 2025

Conversation

Innocent-Akim
Copy link
Contributor

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

  • Add detailed JSDoc comments for ExportMenu component
  • Document all props with descriptive comments
  • Include usage example in component documentation
  • Add type descriptions for each prop in the interface

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

    • Enhanced dashboard interactions with integrated modal management for smoother report export workflows.
    • Improved export functionality now displays dynamic date ranges in PDF titles and filenames.
    • Dashboard headers and export menus have been updated for consistent team naming and clearer date displays.
    • Productivity reports feature a refreshed layout with organized summaries for an improved viewing experience.
    • New components introduced for better modularity in productivity reporting.
  • Bug Fixes

    • Improved error handling for date formatting in reports.

- Add detailed JSDoc comments for ExportMenu component
- Document all props with descriptive comments
- Include usage example in component documentation
- Add type descriptions for each prop in the interface
Copy link
Contributor

coderabbitai bot commented Mar 17, 2025

Walkthrough

The changes introduce modal management by integrating the useModal hook into the AppUrls and DashboardHeader components. Additionally, new props and stricter typing for date handling and team naming have been added across the dashboard components. The ProductivityPDF component is refactored into smaller, more maintainable components, and the export functionality is enhanced by updating both the ExportMenu and ExportDialog interfaces to use dynamic date ranges and modal controls.

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
apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/page.tsx
Integrated the useModal hook; DashboardHeader now receives modal control props (closeModal, openModal, isOpen), a utility formatDate is added, and teamName is standardized to uppercase.
apps/web/app/[locale]/dashboard/app-url/components/ProductivityPDF.tsx Refactored PDF generation by extracting inline JSX into new functional components (TableHeader, ActivityRow, SummaryRow, SummaryGroup), updated the interface to include optional startDate and endDate, and streamlined styles.
apps/web/components/export-menu/index.tsx
apps/web/components/ui/export-dialog.tsx
Enhanced export functionality by expanding prop interfaces with showModal, startDate, endDate, groupByType, reportData, and openModal. Conditional rendering now controls the display of PDF links and modal dialogs, with filenames reflecting the selected date range.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant AU as AppUrls
    participant M as useModal
    participant DH as DashboardHeader
    participant ED as ExportDialog
    U->>AU: Trigger modal action
    AU->>M: Call openModal()
    M-->>AU: Modal state set to open
    AU->>DH: Pass modal props & date values
    DH->>ED: Render ExportDialog if isOpen true
    U->>ED: Confirm export action
    ED->>M: Call closeModal()
    M-->>AU: Modal state set to closed
Loading
sequenceDiagram
    participant U as User
    participant EM as ExportMenu
    participant ED as ExportDialog
    participant PDF as ProductivityPDF
    U->>EM: Click "Export PDF" button
    alt showModal enabled
      EM->>ED: Invoke openModal()
      ED->>U: Display modal with date range info
      U->>ED: Confirm export
      ED->>PDF: Generate PDF with start/end dates
    else Direct export
      EM->>PDF: Generate PDF with start/end dates
    end
    PDF-->>U: Provide PDF download
Loading

Possibly related PRs

Suggested labels

feature, WEB, Improvement, Ever Teams, Apps & URLs Dashboard

Suggested reviewers

  • evereq

Poem

I'm a hopping rabbit, coding with delight,
New modals and dates make my day so bright.
Dashboard headers and PDFs now sing in tune,
Export menus dance beneath a coding moon.
With each fresh change, I wiggle my ears—oh, what a boon!
🥕🐇

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/components/export-menu/index.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/ProductivityPDF.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.

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 changed the title Feat(pdf): add date range display to ProductivityPDF [Feature(pdf)]: Team Dashboard | Export Team Dashboard Data PDF Mar 17, 2025
@Innocent-Akim Innocent-Akim changed the title [Feature(pdf)]: Team Dashboard | Export Team Dashboard Data PDF [Feature(pdf)]: Team Dashboard | Export URL APP Data PDF Mar 17, 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: 1

🧹 Nitpick comments (3)
apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/dashboard-header.tsx (3)

69-79: Avoid non-null assertion operator.

Line 72 uses a non-null assertion operator (!) on the isOpen prop, which could lead to runtime errors if isOpen is undefined.

-					isOpen={isOpen!}
+					isOpen={!!isOpen}

89-99: Unnecessary Fragment can be removed.

The Fragment wrapper is redundant as it contains only one child element and doesn't provide any additional value.

-						pdfDocument={
-							<>
-								{teamName === 'TEAM-DASHBOARD' && (
-									<TeamStatsPDF
-										rapportDailyActivity={reportData || []}
-										title={`${teamName.toLowerCase() || 'Team'} Activity Report for ${formatDate(startDate)} - ${formatDate(endDate)}`}
-										startDate={formatDate(startDate)}
-										endDate={formatDate(endDate)}
-									/>
-								)}
-							</>
-						}
+						pdfDocument={
+							teamName === 'TEAM-DASHBOARD' && (
+								<TeamStatsPDF
+									rapportDailyActivity={reportData || []}
+									title={`${teamName.toLowerCase() || 'Team'} Activity Report for ${formatDate(startDate)} - ${formatDate(endDate)}`}
+									startDate={formatDate(startDate)}
+									endDate={formatDate(endDate)}
+								/>
+							)
+						}
🧰 Tools
🪛 Biome (1.9.4)

[error] 89-98: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)


103-103: Simplify boolean expression.

The ternary operator for a boolean result can be simplified.

-						showModal={teamName === 'APPS-URLS' ? false : true}
+						showModal={teamName !== 'APPS-URLS'}
🧰 Tools
🪛 Biome (1.9.4)

[error] 103-103: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c7f8b83 and b14063d.

📒 Files selected for processing (6)
  • apps/web/app/[locale]/dashboard/app-url/[teamId]/page.tsx (4 hunks)
  • apps/web/app/[locale]/dashboard/app-url/components/ProductivityPDF.tsx (9 hunks)
  • apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/dashboard-header.tsx (5 hunks)
  • apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/page.tsx (2 hunks)
  • apps/web/components/export-menu/index.tsx (1 hunks)
  • apps/web/components/ui/export-dialog.tsx (3 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/dashboard-header.tsx

[error] 103-103: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)


[error] 89-98: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: deploy
🔇 Additional comments (31)
apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/page.tsx (3)

77-78: Consistent team name identification updates.

The change from a generic string "Team Dashboard" to the specific identifier "TEAM-DASHBOARD" aligns with type constraints in the DashboardHeaderProps interface, which restricts teamName to specific values: 'TEAM-DASHBOARD', 'APPS-URLS', or 'TIME-AND-ACTIVITY'. This ensures consistency in team identification across the dashboard components.


95-97: Formatting improvement for readability.

The ChevronUpIcon component is now formatted with better spacing for improved code readability. This is a good practice for maintaining clean and maintainable JSX.


103-103: Simplified div structure.

The container div for the TeamStatsChart now has a cleaner, more concise structure while maintaining the same functionality.

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

18-19: Enhanced date range support for exports.

Adding startDate and endDate props enables the component to generate reports with specific date ranges, which is essential for the new date range display feature in ProductivityPDF.


38-41: Complete date range prop forwarding.

The ExportButtons component now receives the date range parameters, allowing proper date context to be passed down to the PDF generation components.


49-55: Improved PDF title with date context.

The conditional rendering now includes date range information in the PDF title, making the reports more descriptive and user-friendly.


60-60: More descriptive PDF filename.

The PDF filename now includes the date range, making it easier for users to identify reports in their downloaded files.


63-104: Consistent styling and improved modal structure.

The button and modal components now have consistent styling with the rest of the application, with appropriate dark mode support.

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

21-21: Added modal management capability.

Including the useModal hook enables the component to control modal dialogs for exporting data, enhancing the user experience when generating reports.


38-39: Integrated modal state management.

The component now properly manages modal state using the useModal hook, allowing for a more interactive export experience.


47-47: Access to current filter state.

Destructuring currentFilters provides access to the date range values needed for reporting functionality.


118-126: Complete props configuration for DashboardHeader.

The DashboardHeader now receives all necessary props for handling dates and modal interactions, with the teamName updated to use the type-safe "APPS-URLS" identifier. This ensures proper typing and functionality across the dashboard components.


156-162: Improved JSX formatting for conditional rendering.

The table component rendering is now formatted with better readability, making the code easier to maintain while preserving the same functionality.

apps/web/components/export-menu/index.tsx (4)

12-37: Comprehensive JSDoc documentation added.

Excellent addition of detailed JSDoc comments for each prop in the ExportMenuProps interface. This improves developer experience and code maintainability by clearly describing the purpose and type of each property.


39-54: Added usage example in component documentation.

The detailed component documentation with a usage example is a great practice that helps other developers understand how to properly implement the ExportMenu component.


55-63: Modal integration for export workflow.

The component now supports both direct export and modal-based confirmation workflows, providing flexibility in how exports are handled. The default showModal=true ensures backward compatibility.


88-111: Conditional PDF export handling.

The PDF export button now intelligently handles direct downloads or modal-based workflows based on the showModal prop. This maintains a consistent user experience while adding flexibility.

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

15-22: Well-implemented date formatting utility function.

The formatDate utility function is a good addition that provides consistent date formatting throughout the component and properly handles undefined dates.


32-32: Good type safety improvement for teamName property.

Restricting teamName to specific string values ('TEAM-DASHBOARD', 'APPS-URLS', 'TIME-AND-ACTIVITY') improves type safety and prevents potential errors from mismatched string values.


36-38: Appropriate modal management props added.

The addition of modal management props (closeModal, openModal, isOpen) aligns with the PR objective of enhancing the export functionality with modal controls.


104-108: Good implementation of passing date information to ExportMenu.

The addition of date range information and other props to the ExportMenu component aligns well with the PR objective of enhancing export functionality.

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

12-17: Well-organized style improvements.

The styles have been consolidated and simplified, making the stylesheet more maintainable. The new styles like titleSection and dateRange properly support the added date range display functionality.


116-117: Good addition of date range props to interface.

The addition of startDate and endDate to the ProductivityPDFProps interface supports the PR objective of adding date range display to the PDF export.


142-160: Well-implemented TableHeader component.

Extracting the table header rendering into a separate component improves code organization and makes the main component more maintainable.


162-195: Excellent component extraction for ActivityRow.

The ActivityRow component appropriately encapsulates the row rendering logic with well-typed props, making the code more modular and easier to maintain.


197-210: Good reusable SummaryRow component.

The SummaryRow component is well-designed with appropriate props, including the optional highlight flag for emphasizing important metrics.


212-217: Well-structured SummaryGroup component.

The SummaryGroup component provides a clean way to organize related summary information with appropriate styling and title handling.


219-219: Updated component signature with date range parameters.

The ProductivityPDF component signature has been updated to include the new date range parameters, aligning with the PR objective.


305-316: Great implementation of the date range display.

The conditional rendering of the date range in the PDF title section is well-implemented, showing the date range information only when available and formatting it appropriately.


327-327: Effective use of extracted components.

The code now uses the extracted TableHeader and ActivityRow components, making the main component's return statement cleaner and more maintainable.

Also applies to: 333-340


351-361: Well-structured summary section using the new components.

The summary section has been refactored to use the new SummaryGroup and SummaryRow components, which improves readability and makes the code more maintainable.

Also applies to: 364-371, 374-386

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

🧹 Nitpick comments (1)
apps/web/components/export-menu/index.tsx (1)

15-37: Interface extensions look good, but consider typing reportData more strictly.

The new props enhance the component's flexibility for export functionality, however:

-	reportData?: any[];
+	reportData?: Array<Record<string, unknown>>;

Using a more specific type instead of any[] would improve type safety while maintaining flexibility.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b14063d and cac3a91.

📒 Files selected for processing (2)
  • apps/web/app/[locale]/dashboard/app-url/components/ProductivityPDF.tsx (9 hunks)
  • apps/web/components/export-menu/index.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: deploy
🔇 Additional comments (11)
apps/web/components/export-menu/index.tsx (4)

12-54: Great documentation improvements!

The JSDoc comments enhance the component's understandability with thorough documentation of both the component itself and its props. The usage example is especially valuable for developers new to this component.


89-91: Modal opening logic is correct.

The condition properly checks both flags before triggering the modal open function.


94-110: Improved PDF download implementation with conditional rendering.

The conditional rendering based on showModal provides flexibility in how the PDF is generated and downloaded. The implementation ensures that the PDF document is only rendered when needed.


117-119: CSV export handler bug fixed.

You've correctly fixed the CSV export handler logic that was flagged in a previous review. This ensures the callback is actually executed when the condition is met.

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

12-17: Style improvements for better visual hierarchy.

The new styles (titleSection and dateRange) enhance the PDF's readability and information hierarchy, particularly for the title and date range sections.


113-118: Good extension of the props interface for date handling.

Adding optional startDate and endDate properties allows for more detailed reporting and better integration with the ExportMenu component.


142-160: Excellent component extraction for TableHeader.

Breaking out the table header into a separate component improves code organization and maintainability.


162-195: Well-structured ActivityRow component with proper typing.

The ActivityRow component extracts complex rendering logic into a reusable unit with clear props typing. This is a good application of the Single Responsibility Principle.


197-217: Good component extraction for summary sections.

Creating the SummaryRow and SummaryGroup components makes the code more maintainable and follows the DRY principle by eliminating repetitive markup.


304-310: Well-implemented conditional date range display.

The conditional rendering for the date range in the PDF title is properly implemented and handles all scenarios: both dates present, only start date, only end date, or no dates.


346-381: Clean refactoring of summary sections using new components.

The summary section now uses the new SummaryGroup and SummaryRow components, which makes the code more readable and maintainable.

@evereq evereq merged commit 1ff9626 into develop Mar 17, 2025
12 of 13 checks passed
@evereq evereq deleted the feat/reusable-export-menu-app-url branch March 17, 2025 19:28
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.

2 participants