-
Notifications
You must be signed in to change notification settings - Fork 74
[Feat:] improve PDF report and activity components #3662
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
- 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
WalkthroughThis pull request introduces a new React component, ProductivityEmployeePDF, which generates employee productivity reports as PDFs using the Changes
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
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
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
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
apps/web/app/[locale]/dashboard/app-url/components/productivity-employee/Productivity-employeePDF.tsxOops! 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.tsxOops! 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.tsxOops! 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)
✨ Finishing Touches
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. 🪧 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 (
|
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: 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
withbg-[#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, theformat
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
📒 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 componentAdding 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 ProgressBarThe 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 stylingChanged the dark mode background from
dark:bg-dark--theme
todark: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
totext-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.
apps/web/app/[locale]/time-and-activity/Components/time-activity-header.tsx
Show resolved
Hide resolved
@Innocent-Akim can you check #3662 (comment) please? |
Enhance productivity PDF report:
Update activity components:
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
Style
Refactor