Skip to content

Conversation

Innocent-Akim
Copy link
Contributor

@Innocent-Akim Innocent-Akim commented Feb 5, 2025

  • Enhance date handling in useTimesheet hook
  • Fix dependency array in useTimelogFilterOptions
  • Update team dashboard components for better activity tracking
  • Improve chart visualization and filtering options
  • Update timer log interfaces
  • Update yarn dependencies

Components affected:

  • activity-modal
  • team-dashboard-filter
  • team-stats-chart
  • useReportActivity
  • useTimelogFilterOptions
  • useTimesheet
  • ITimerLog 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

  • Style
    • Enhanced visual elements with smoother animations, refined text sizing, and updated color schemes for improved clarity and dark mode support.
  • New Features
    • Updated filter components now display clear counts of selected teams and employees, offering better user feedback.
  • Refactor
    • Streamlined date management and reporting logic to ensure reliable and up-to-date timesheet and activity displays.
  • Enhancements
    • Added optional properties for filtering time log reports by team and user identifiers, expanding reporting capabilities.

- Enhance date handling in useTimesheet hook
- Fix dependency array in useTimelogFilterOptions
- Update team dashboard components for better activity tracking
- Improve chart visualization and filtering options
- Update timer log interfaces
- Update yarn dependencies

Components affected:
- activity-modal
- team-dashboard-filter
- team-stats-chart
- useReportActivity
- useTimelogFilterOptions
- useTimesheet
- ITimerLog interface
@Innocent-Akim Innocent-Akim self-assigned this Feb 5, 2025
Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

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/team-dashboard/[teamId]/components/team-stats-chart.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/hooks/features/useTimesheet.ts

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.

Walkthrough

This pull request applies styling updates and code refinements across several team dashboard components and hooks. The UI changes include modifications to font sizes, colors, transitions, and dark mode classes. Hooks have been updated with additional filtering properties, dependency adjustments, and improved date handling using moment.js. Additionally, an interface has been extended with extra optional identifier fields. Overall, these changes focus on visual and code structure enhancements without modifying the core component functionality.

Changes

Files Change Summary
apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/{activity-modal.tsx, team-dashboard-filter.tsx, team-stats-chart.tsx} Styling updates: transition improvements, updated font sizes/colors, dark mode class additions, and button reformatting.
apps/web/app/hooks/features/{useReportActivity.ts, useTimelogFilterOptions.ts, useTimesheet.ts} Hook enhancements: added filter properties, adjusted effect dependencies, code refactoring, and improved date handling via moment.js.
apps/web/app/interfaces/timer/ITimerLog.ts Extended interface by adding optional teamId and userId properties for enhanced filtering.

Possibly related PRs

  • [Fea]: Activity Modal #3551: Addresses styling updates in the ActivityModal component, which aligns with the visual enhancements introduced in this PR.

Suggested labels

feature, WEB, Improvement, Timesheets, Ever Teams

Suggested reviewers

  • evereq
  • Cedric921

Poem

I'm a rabbit in a code-filled glen,
Hopping through updates again and again.
Styles refined with every little tweak,
Hooks enhanced, making data fetch sleek.
I nibble on bugs and cheer each change—
A digital dance in a forest so strange!
🐰 Hop, hop, hooray!

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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?

❤️ 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. (Beta)
  • @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.

Copy link

socket-security bot commented Feb 5, 2025

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSourceCI
HTTP dependency npm/@electron/rebuild@3.7.1 ⚠︎

View full report↗︎

Next steps

What 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 dependency

Take 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 package

If 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 risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all

  • @SocketSecurity ignore npm/@electron/rebuild@3.7.1

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 (3)
apps/web/app/hooks/features/useTimesheet.ts (2)

18-23: Add JSDoc documentation for the TimesheetParams interface.

Consider adding JSDoc documentation to improve code maintainability and IDE support.

+/**
+ * Interface for timesheet parameters
+ * @interface TimesheetParams
+ * @property {Date | string} [startDate] - Start date for the timesheet period
+ * @property {Date | string} [endDate] - End date for the timesheet period
+ * @property {'ListView' | 'CalendarView'} [timesheetViewMode] - View mode for displaying timesheet
+ * @property {string} [inputSearch] - Search string to filter timesheet entries
+ */
 interface TimesheetParams {
   startDate?: Date | string;
   endDate?: Date | string;
   timesheetViewMode?: 'ListView' | 'CalendarView';
   inputSearch?: string;
 }

298-298: Translate French comment to English for consistency.

The codebase should maintain consistent language usage in comments.

-// Effet pour déclencher la requête quand les dates changent
+// Effect to trigger the request when dates change
🧰 Tools
🪛 GitHub Check: Cspell

[warning] 298-298:
Unknown word (Effet)


[warning] 298-298:
Unknown word (déclencher)


[warning] 298-298:
Unknown word (requête)


[warning] 298-298:
Unknown word (quand)


[warning] 298-298:
Unknown word (changent)

🪛 GitHub Actions: Check Spelling and Typos with cspell

[warning] 298-298: Unknown word (Effet)


[warning] 298-298: Unknown word (déclencher)


[warning] 298-298: Unknown word (requête)


[warning] 298-298: Unknown word (quand)


[warning] 298-298: Unknown word (changent)

apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/activity-modal.tsx (1)

107-107: Consider a more moderate font size for the modal header.

The 28px font size for the employee name might be too large for a modal header, potentially causing layout issues on smaller screens. Consider using a more moderate size (e.g., 24px) that maintains hierarchy while ensuring better responsiveness.

-<h3 className="text-xl font-medium text-gray-900 dark:text-gray-100 text-[28px]">
+<h3 className="text-xl font-medium text-gray-900 dark:text-gray-100 text-[24px]">
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 796a9b8 and b1b84b9.

⛔ Files ignored due to path filters (2)
  • apps/server-web/release/app/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (7)
  • apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/activity-modal.tsx (3 hunks)
  • apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/team-dashboard-filter.tsx (3 hunks)
  • apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/team-stats-chart.tsx (2 hunks)
  • apps/web/app/hooks/features/useReportActivity.ts (1 hunks)
  • apps/web/app/hooks/features/useTimelogFilterOptions.ts (1 hunks)
  • apps/web/app/hooks/features/useTimesheet.ts (2 hunks)
  • apps/web/app/interfaces/timer/ITimerLog.ts (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
apps/web/app/hooks/features/useTimesheet.ts

[error] 118-118: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)

🪛 GitHub Check: Cspell
apps/web/app/hooks/features/useTimesheet.ts

[warning] 298-298:
Unknown word (Effet)


[warning] 298-298:
Unknown word (déclencher)


[warning] 298-298:
Unknown word (requête)


[warning] 298-298:
Unknown word (quand)


[warning] 298-298:
Unknown word (changent)

🪛 GitHub Actions: Check Spelling and Typos with cspell
apps/web/app/hooks/features/useTimesheet.ts

[warning] 298-298: Unknown word (Effet)


[warning] 298-298: Unknown word (déclencher)


[warning] 298-298: Unknown word (requête)


[warning] 298-298: Unknown word (quand)


[warning] 298-298: Unknown word (changent)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: deploy
  • GitHub Check: deploy
🔇 Additional comments (12)
apps/web/app/hooks/features/useTimelogFilterOptions.ts (1)

72-74: LGTM! Dependency array correctly updated.

The addition of setSelectTimesheetId to the dependency array is correct as it's used in the cleanup function. This prevents potential stale closure issues.

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

50-50: LGTM! Dark mode styling added.

The addition of dark:bg-dark--theme-light class improves accessibility in dark mode.


64-66: LGTM! Enhanced UX with selection counts.

Adding the count of selected items to the clear button labels improves user feedback.

Also applies to: 89-90


69-69: LGTM! More descriptive localStorage keys.

The localStorage keys have been updated to be more specific and descriptive:

  • team-dashboard-select-filter-team
  • team-dashboard-select-filter-employee

Also applies to: 93-93

apps/web/app/interfaces/timer/ITimerLog.ts (1)

182-183: LGTM! Interface extended with optional identifiers.

The addition of optional teamId and userId properties enhances filtering capabilities while maintaining backward compatibility.

apps/web/app/hooks/features/useReportActivity.ts (3)

15-27: LGTM! Interface extended with filtering properties.

The UseReportActivityProps interface has been enhanced with additional filtering capabilities:

  • projectIds
  • employeeIds
  • teamIds

29-57: LGTM! Default props properly initialized.

The defaultProps object correctly initializes the new filtering arrays as empty:

employeeIds: [],
projectIds: [],
teamIds: []

95-96: LGTM! Efficient mapping of filter IDs.

The getMergedProps function efficiently maps team and user IDs:

employeeIds: alluserState?.map(({ employee: { id } }) => id).filter(Boolean),
teamIds: allteamsState?.map(({ id }) => id).filter(Boolean),
apps/web/app/hooks/features/useTimesheet.ts (1)

406-410: Well-implemented type guard for TimesheetStatus.

The type guard implementation is clean and ensures type safety when working with timesheet statuses.

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

31-31: LGTM! Smooth transition effect added.

The addition of the transition class with ease-in-out timing provides a smooth animation effect when the circle's properties change.


46-54: Verify color contrast accessibility.

While the styling changes provide consistent text sizes and dark mode support, please verify that the text color #60646C meets WCAG color contrast requirements, especially for the 14px font size.

✅ Verification successful

🌐 Web query:

Does text color #60646C on white background meet WCAG 2.1 AA requirements for 14px text?

Length of output: 3420


Color Contrast Compliance Verified

The text color #60646C on a white background meets the WCAG 2.1 AA requirements for 14px non-bold text. The contrast ratio exceeds the minimum 4.5:1 threshold, ensuring sufficient readability.

  • Contrast Ratio: The contrast ratio for #60646C against white is inferred to be greater than 4.5:1.
  • Text Size: At 14px and non-bold, the text qualifies as normal text under WCAG guidelines.
  • Dark Mode Consideration: The presence of dark mode support doesn't affect this specific evaluation.
apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/team-stats-chart.tsx (1)

51-51: LGTM!

The formatting change improves code readability and follows TypeScript conventions.

Copy link

Report too large to display inline

View full report↗︎

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

♻️ Duplicate comments (1)
apps/web/app/hooks/features/useTimesheet.ts (1)

298-302: ⚠️ Potential issue

Remove duplicate useEffect for getTaskTimesheet.

There are two useEffect hooks that trigger getTaskTimesheet with similar dependencies. This could cause duplicate API calls and unnecessary re-renders.

Combine the effects into a single useEffect:

-useEffect(() => {
-  if (startDate || endDate) {
-    getTaskTimesheet({ startDate, endDate });
-  }
-}, [startDate, endDate, getTaskTimesheet]);

 useEffect(() => {
   getTaskTimesheet({ startDate, endDate });
-}, [getTaskTimesheet, startDate, endDate, timesheetGroupByDays, inputSearch]);
+}, [getTaskTimesheet, startDate, endDate, timesheetGroupByDays, inputSearch, user]);

Also applies to: 518-520

🧹 Nitpick comments (1)
apps/web/app/hooks/features/useTimesheet.ts (1)

105-159: Consider optimizing the grouping function.

The current implementation creates intermediate objects that could be memory-intensive for large datasets. Consider using Map for better performance.

 const createGroupingFunction =
   (getKey: GroupingKeyFunction) =>
   (items: TimesheetLog[]): GroupedTimesheet[] => {
     if (!items?.length) return [];
-    const groupedByDate = items.reduce(
+    const groupedByDate = new Map();
+    items.forEach(item => {
       // ... existing validation ...
-      const key = getKey(date);
-      if (!acc[key]) {
-        acc[key] = {
+      const key = getKey(date);
+      if (!groupedByDate.has(key)) {
+        groupedByDate.set(key, {
           date: key,
           timesheets: {}
-        };
+        });
       }
       // ... rest of the logic ...
-    }, {});
🧰 Tools
🪛 Biome (1.9.4)

[error] 118-118: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b1b84b9 and 6a9e0ec.

📒 Files selected for processing (2)
  • apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/team-stats-chart.tsx (3 hunks)
  • apps/web/app/hooks/features/useTimesheet.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/app/[locale]/dashboard/team-dashboard/[teamId]/components/team-stats-chart.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
apps/web/app/hooks/features/useTimesheet.ts

[error] 118-118: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: deploy
  • GitHub Check: deploy
🔇 Additional comments (3)
apps/web/app/hooks/features/useTimesheet.ts (3)

18-28: Interface definitions look good!

The interfaces are well-defined with proper optional fields and clear type definitions.


224-239: Well-implemented date handling with proper error handling!

The date handling implementation is robust with:

  • Proper fallback to defaults
  • Comprehensive error handling
  • Clear validation of date formats

Also applies to: 246-266


118-118: ⚠️ Potential issue

Replace unsafe isNaN with Number.isNaN.

The global isNaN function performs type coercion which can lead to unexpected results.

-    if (isNaN(date.getTime())) {
+    if (Number.isNaN(date.getTime())) {

Likely invalid or redundant comment.

🧰 Tools
🪛 Biome (1.9.4)

[error] 118-118: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)

@evereq evereq changed the title [Feat]: Improve Iimesheet and Activity reporting [Feat]: Improve timesheet and Activity reporting Feb 6, 2025
@evereq evereq merged commit 87fcf36 into develop Feb 6, 2025
14 checks passed
@evereq evereq deleted the feat/improve-team-dashboard-date-handling branch February 6, 2025 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants