Skip to content

Conversation

Innocent-Akim
Copy link
Contributor

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

  • Enhance productivity PDF report:

    • Fix employee name display using user.firstName and user.lastName
    • Use projectName instead of project for project display
    • Add detailed table with date, project, activity and duration
    • Implement visual progress bar for duration display
  • Update activity components:

    • ActivityTable.tsx: enhance data display
    • ViewSelect.tsx: optimize view selection
    • card-time-and-activity.tsx: update activity card
    • page-component.tsx: improve page structure
    • time-activity-header.tsx: update header component
    • time-activityFilterPopover.tsx: optimize filter options
    • page.tsx: enhance main page layout
    • export-dialog.tsx: update export dialog

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 an employee productivity report available as a downloadable PDF with organized data presentation.
  • Style

    • Enhanced visual components with refined dark mode styling, improved table layouts, progress bar colors, and updated dropdown, header, and popover designs.
  • Refactor

    • Streamlined the export dialog into a modern modal layout for a more intuitive export process.

- Enhance productivity PDF report:
  - Fix employee name display using user.firstName and user.lastName
  - Use projectName instead of project for project display
  - Add detailed table with date, project, activity and duration
  - Implement visual progress bar for duration display

- Update activity components:
  - ActivityTable.tsx: enhance data display
  - ViewSelect.tsx: optimize view selection
  - card-time-and-activity.tsx: update activity card
  - page-component.tsx: improve page structure
  - time-activity-header.tsx: update header component
  - time-activityFilterPopover.tsx: optimize filter options
  - page.tsx: enhance main page layout
  - export-dialog.tsx: update export dialog
@CLAassistant
Copy link

CLAassistant commented Mar 13, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

coderabbitai bot commented Mar 13, 2025

Walkthrough

This pull request introduces a new React component, ProductivityEmployeePDF, which generates employee productivity reports as PDFs using the @react-pdf/renderer library. The changes include several UI updates to enhance dark mode styling across different components, a new client directive in one page, and a significant refactor of the export dialog by replacing the previous Dialog implementation with a Modal component. Additional layout adjustments such as wrapping the ProgressBar in a dedicated container have also been applied.

Changes

Files Summary
apps/web/app/[locale]/dashboard/app-url/components/productivity-employee/Productivity-employeePDF.tsx Introduces the new ProductivityEmployeePDF component for generating PDF reports, including data validation, custom font registration, and structured table layout.
apps/web/app/[locale]/time-and-activity/Components/ActivityTable.tsx Adds className="w-full" to Table, updates TableRow with additional dark mode styling, and changes the ProgressBar color from bg-primary to bg-[#0088CC].
apps/web/app/[locale]/time-and-activity/Components/ViewSelect.tsx
apps/web/app/[locale]/time-and-activity/Components/time-activity-header.tsx
apps/web/app/[locale]/time-and-activity/Components/time-activityFilterPopover.tsx
apps/web/app/[locale]/time-and-activity/Components/page-component.tsx
Adjusts class names and styling for various components to improve dark mode support, updating elements such as buttons, dropdown menus, headers, and popover backgrounds.
apps/web/app/[locale]/time-and-activity/Components/card-time-and-activity.tsx Wraps the ProgressBar component within a <div className='w-28'> to modify layout without affecting functionality.
apps/web/app/[locale]/time-and-activity/page.tsx Introduces a new 'use client' directive to designate the file as a client component in the application.
apps/web/components/ui/export-dialog.tsx Refactors the export dialog by replacing the previous Dialog implementation with a consolidated Modal component, updating the structure and button styling.

Sequence Diagram(s)

sequenceDiagram
    participant Parent as Parent Component
    participant PDFComp as ProductivityEmployeePDF
    participant ReactPDF as @react-pdf/renderer
    participant PDFOut as PDF Document

    Parent->>PDFComp: Pass productivity data & title
    PDFComp->>PDFComp: Validate data & register custom font
    PDFComp->>PDFComp: Render layout (header, table, etc.)
    PDFComp->>ReactPDF: Generate PDF content components
    ReactPDF->>PDFOut: Create structured PDF
    PDFComp-->>Parent: Return generated PDF document
Loading
sequenceDiagram
    participant U as User
    participant ED as ExportDialog
    participant M as Modal

    U->>ED: Initiate export action
    ED->>M: Open modal with export completion message
    M-->>U: Display export dialog with download and cancel options
    U->>M: Click on Download or Cancel
    M-->>ED: Process user interaction and complete action
Loading

Possibly related PRs

Suggested labels

feature, WEB, Improvement, Ever Teams

Suggested reviewers

  • evereq

Poem

I'm a code rabbit on a daring spree,
Hopping through changes so brisk and free.
With PDFs and modals that gleam so bright,
My little paws work deep into the night.
Carrots and code, a joyful delight!
🐰
Keep hopping on, making our project shine!

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-employee/Productivity-employeePDF.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]/time-and-activity/Components/ActivityTable.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]/time-and-activity/Components/ViewSelect.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.

  • 6 others

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

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

🧹 Nitpick comments (7)
apps/web/app/[locale]/time-and-activity/Components/ActivityTable.tsx (1)

187-187: Changed progress bar color from variable to specific hex value.

Replacing bg-primary with bg-[#0088CC] changes the progress bar's color from a theme variable to a specific hex value. This ensures visual consistency but might make future theme updates more difficult.

Consider using a theme variable instead of a hardcoded color value to maintain consistency with the design system and facilitate future theme changes:

-color="bg-[#0088CC]"
+color="bg-primary"

If a different shade is needed specifically for this component, consider adding it to your theme variables.

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

85-87: Code formatting inconsistency.

The indentation of the Button element is inconsistent with the surrounding JSX structure.

Improve code readability by fixing the indentation:

<div className="flex flex-col gap-3 sm:flex-row sm:gap-2 w-full justify-end">
-<Button variant="outline" onClick={onClose} className='bg-light--theme-light dark:bg-dark-high'>
-	Cancel
-</Button>
+  <Button variant="outline" onClick={onClose} className='bg-light--theme-light dark:bg-dark-high'>
+    Cancel
+  </Button>
  <ExportButtons reportData={reportData} exportType={exportType} groupByType={groupByType} />
</div>
apps/web/app/[locale]/dashboard/app-url/components/productivity-employee/Productivity-employeePDF.tsx (5)

16-19: Consider adding a fallback font mechanism.

The external font URL might be unavailable in some scenarios, which could affect the PDF rendering. Consider adding a fallback font or caching the font locally.

Font.register({
	family: 'Helvetica',
	src: 'https://fonts.gstatic.com/s/helveticaneue/v70/1Ptsg8zYS_SKggPNyC0IT0kLW-43aMEzIO6XUTLjad8.ttf'
+	, fallback: true
});

118-122: Add more informative error handling.

Currently, when validation fails, the component silently returns null after logging an error. Consider adding a simple error PDF or more descriptive error handling.

// Validate data structure
if (!Array.isArray(data) || !data.length) {
	console.error('Data is not a valid array:', data);
-	return null;
+	return (
+		<Document>
+			<Page size="A4" style={styles.page}>
+				<View style={styles.header}>
+					<Text style={styles.title}>Error generating {title}</Text>
+					<Text style={styles.subtitle}>No valid data was provided to generate the report.</Text>
+				</View>
+			</Page>
+		</Document>
+	);
}

148-177: Simplify the nested mapping structure.

The triple-nested mapping is complex and could be hard to maintain. Consider extracting this logic into a separate component or helper function.

- {employeeGroup.dates.map((dateGroup, dateIndex) => (
-   dateGroup.projects.map((project, projectIndex) => (
-     project.activity.map((activity, activityIndex) => (
-       <View
-         key={`${dateIndex}-${projectIndex}-${activityIndex}`}
-         style={styles.tableRow}
-       >
-         <Text style={[styles.tableCell, styles.col1]}>
-           {format(new Date(dateGroup.date), 'dd MMM yyyy')}
-         </Text>
-         <Text style={[styles.tableCell, styles.col2]}>
-           {activity.projectName || 'N/A'}
-         </Text>
-         <Text style={[styles.tableCell, styles.col3]}>
-           {activity.title}
-         </Text>
-         <View style={[styles.projectCell, styles.col4]}>
-           <View style={styles.percentageBar}>
-             <View
-               style={[styles.percentageFill, { width: `${activity.duration}%` }]}
-             />
-           </View>
-           <Text style={styles.percentageText}>
-             {activity.duration}%
-           </Text>
-         </View>
-       </View>
-     ))
-   ))
- ))}
+ {employeeGroup.dates.flatMap((dateGroup, dateIndex) => 
+   dateGroup.projects.flatMap((project, projectIndex) => 
+     project.activity.map((activity, activityIndex) => (
+       <View
+         key={`${dateIndex}-${projectIndex}-${activityIndex}`}
+         style={styles.tableRow}
+       >
+         {/* Rest of the content remains the same */}
+         <Text style={[styles.tableCell, styles.col1]}>
+           {format(new Date(dateGroup.date), 'dd MMM yyyy')}
+         </Text>
+         <Text style={[styles.tableCell, styles.col2]}>
+           {activity.projectName || 'N/A'}
+         </Text>
+         <Text style={[styles.tableCell, styles.col3]}>
+           {activity.title}
+         </Text>
+         <View style={[styles.projectCell, styles.col4]}>
+           <View style={styles.percentageBar}>
+             <View
+               style={[styles.percentageFill, { width: `${activity.duration}%` }]}
+             />
+           </View>
+           <Text style={styles.percentageText}>
+             {activity.duration}%
+           </Text>
+         </View>
+       </View>
+     ))
+   )
+ )}

156-157: Add error handling for date formatting.

If dateGroup.date isn't a valid date, the format function will throw an error. Consider adding error handling.

<Text style={[styles.tableCell, styles.col1]}>
-	{format(new Date(dateGroup.date), 'dd MMM yyyy')}
+	{(() => {
+		try {
+			return format(new Date(dateGroup.date), 'dd MMM yyyy');
+		} catch (e) {
+			console.error('Invalid date format:', dateGroup.date);
+			return 'Invalid date';
+		}
+	})()}
</Text>

166-167: Validate duration value before using it in percentage calculation.

Currently, there's no validation that activity.duration is a valid percentage number. Consider adding validation to prevent rendering issues.

<View
-	style={[styles.percentageFill, { width: `${activity.duration}%` }]}
+	style={[
+		styles.percentageFill, 
+		{ width: `${typeof activity.duration === 'number' && !isNaN(activity.duration) ? 
+			Math.min(Math.max(activity.duration, 0), 100) : 0}%` }
+	]}
/>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 86a9290 and 6e3b349.

📒 Files selected for processing (9)
  • apps/web/app/[locale]/dashboard/app-url/components/productivity-employee/Productivity-employeePDF.tsx (1 hunks)
  • apps/web/app/[locale]/time-and-activity/Components/ActivityTable.tsx (2 hunks)
  • apps/web/app/[locale]/time-and-activity/Components/ViewSelect.tsx (3 hunks)
  • apps/web/app/[locale]/time-and-activity/Components/card-time-and-activity.tsx (1 hunks)
  • apps/web/app/[locale]/time-and-activity/Components/page-component.tsx (1 hunks)
  • apps/web/app/[locale]/time-and-activity/Components/time-activity-header.tsx (1 hunks)
  • apps/web/app/[locale]/time-and-activity/Components/time-activityFilterPopover.tsx (1 hunks)
  • apps/web/app/[locale]/time-and-activity/page.tsx (1 hunks)
  • apps/web/components/ui/export-dialog.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: deploy
🔇 Additional comments (12)
apps/web/app/[locale]/time-and-activity/page.tsx (1)

1-1: Added client directive to top-level component

Adding the 'use client' directive converts this component from a server component (default in Next.js) to a client component that executes in the browser. This is appropriate since you're using TimeActivityComponents which may contain client-side logic.

apps/web/app/[locale]/time-and-activity/Components/card-time-and-activity.tsx (1)

36-42: Added fixed-width container for ProgressBar

The addition of a fixed-width container (w-28 = 7rem/112px) for the ProgressBar creates a more consistent UI layout regardless of content length. This is a good improvement for visual consistency.

apps/web/app/[locale]/time-and-activity/Components/page-component.tsx (1)

70-70: Updated dark mode background styling

Changed the dark mode background from dark:bg-dark--theme to dark:bg-dark-high for better consistency with the overall dark theme styling across the application.

apps/web/app/[locale]/time-and-activity/Components/time-activityFilterPopover.tsx (1)

100-100: Dark mode styling added to popover content.

The addition of dark:bg-dark-high provides proper background styling for the popover in dark mode, ensuring consistent user experience when switching between themes.

apps/web/app/[locale]/time-and-activity/Components/ActivityTable.tsx (2)

100-100: Added width class for better table layout.

The addition of the w-full class ensures the table properly fills its container, maintaining a consistent layout.


103-104: Enhanced hover styling for dark mode.

Adding dark:hover:bg-dark--theme-light improves the user experience by providing appropriate hover feedback when in dark mode.

apps/web/app/[locale]/time-and-activity/Components/ViewSelect.tsx (2)

53-53: Dark mode styling added to dropdown menu content.

The addition of dark:bg-dark-high provides proper background styling for the dropdown in dark mode, ensuring consistent user experience.


64-64: Improved text color for dark mode.

Changing from text-primary to text-gray-700 dark:text-white improves readability in both light and dark modes by ensuring appropriate contrast.

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

5-10: Modal component import added for dialog refactoring.

The import statement changes support the refactoring from Dialog to Modal component, which aligns with the PR objectives.


54-56: Consistent button styling added for light and dark themes.

Adding bg-light--theme-light dark:bg-dark-high to button classes ensures proper background styling in both light and dark modes.

Also applies to: 61-63


79-90: Improved dialog content structure and styling.

The new Modal implementation provides better organization of content with appropriate spacing and alignment. The use of flex layouts and responsive behavior improves the user experience across different screen sizes.

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

1-184: Overall, excellent implementation of the PDF report component.

The component is well-structured and addresses the PR objectives by displaying employee names, project information, activities, and durations with a visual progress bar. The styling is comprehensive and the layout is clear and professional.

@evereq
Copy link
Member

evereq commented Mar 13, 2025

@Innocent-Akim can you check #3662 (comment) please?

@evereq evereq merged commit 2f7e3bd into develop Mar 13, 2025
11 of 13 checks passed
@evereq evereq deleted the feat/improve-productivity-pdf-report branch March 13, 2025 16:47
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.

4 participants