Skip to content
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

Feat: Add grouped display for timesheet data by date #3266

Merged
merged 1 commit into from
Nov 9, 2024

Conversation

Innocent-Akim
Copy link
Contributor

@Innocent-Akim Innocent-Akim commented Nov 8, 2024

Description

Please include a summary of the changes and the related issue.

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 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 previous status

Current screenshots

Please add here videos or images of previous status

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced timesheet filtering with specific date properties.
    • Improved timesheet data management by utilizing a new data structure.
    • Added functionality to group timesheet items by date for better organization.
    • Introduced interactive components for task management, including TaskActionMenu, TaskDetails, and StatusTask.
  • Bug Fixes

    • Resolved issues with task status handling in the timesheet display.
  • Documentation

    • Updated user interface components for improved usability and clarity.

@Innocent-Akim Innocent-Akim added the Don't Merge Do not merge this PR until label not removed label Nov 8, 2024
@Innocent-Akim Innocent-Akim self-assigned this Nov 8, 2024
Copy link
Contributor

coderabbitai bot commented Nov 8, 2024

Walkthrough

The pull request introduces several modifications across multiple files related to the timesheet feature. Key changes include the refinement of the ITimesheetFilter interface to specify the initDate property, the transition from useDailyPlan to useTimesheet for data management in the page.tsx file, and the enhancement of the useTimesheet hook to include a new groupByDate function. Additionally, the DataTableTimeSheet component is updated to improve rendering and interactivity, incorporating new components and modifying existing functionalities.

Changes

File Change Summary
apps/web/app/[locale]/timesheet/[memberId]/components/TimesheetFilter.tsx Updated ITimesheetFilter interface; changed initDate from optional TimesheetFilterDateProps to a Pick type with specific properties.
apps/web/app/[locale]/timesheet/[memberId]/page.tsx Removed useDailyPlan import; added useTimesheet import; changed TimesheetView data prop from sortedPlans to timesheet; initialized dateRange state with current date.
apps/web/app/hooks/features/useTimesheet.ts Added groupByDate function to group timesheet items by date; modified return type of timesheet to be processed through groupByDate.
apps/web/lib/features/integrations/calendar/table-time-sheet.tsx Updated DataTableTimeSheet component to enhance rendering; modified column definitions; added TaskActionMenu, TaskDetails, and StatusTask components; improved modal handling logic.

Possibly related PRs

Suggested labels

feature, WEB, Ever Teams

Suggested reviewers

  • evereq
  • Cedric921
  • EverTechDevOps

🐰 In the meadow, where timesheets play,
A filter was crafted in a new way.
With dates now picked, and tasks aligned,
The rabbits rejoice, their work well-defined.
Hopping through code, with joy we embrace,
A cleaner flow in our happy workspace! 🌼


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

🧹 Outside diff range and nitpick comments (7)
apps/web/app/[locale]/timesheet/[memberId]/components/TimesheetFilter.tsx (2)

Line range hint 31-33: Implement proper logging or remove the comment.

The empty callback with a TODO-like comment should either be implemented with proper logging or removed if not needed.

Consider implementing proper logging:

-                        onToggle={(label) => {
-                            // If logging is needed, use proper logging service
-                        }}
+                        onToggle={(label) => {
+                            console.debug('Status filter toggled:', label);
+                        }}

Line range hint 39-39: Consider explicit prop passing instead of spreading.

Using the spread operator ({...initDate}) with TypeScript can bypass type checking. Consider passing props explicitly for better type safety and code clarity.

-                    <TimesheetFilterDate t={t} {...initDate} />
+                    <TimesheetFilterDate
+                        t={t}
+                        initialRange={initDate?.initialRange}
+                        onChange={initDate?.onChange}
+                        maxDate={initDate?.maxDate}
+                        minDate={initDate?.minDate}
+                    />
apps/web/app/hooks/features/useTimesheet.ts (2)

15-16: Remove consecutive empty lines

Consider removing one of the consecutive empty lines to maintain consistent spacing throughout the file.


67-67: Consider memoizing grouped timesheet data

The groupByDate function is called on every render. Consider memoizing the result using useMemo to prevent unnecessary recalculations.

+    const groupedTimesheet = useMemo(() => groupByDate(timesheet), [timesheet]);
+
     return {
         loadingTimesheet,
-        timesheet: groupByDate(timesheet),
+        timesheet: groupedTimesheet,
         getTaskTimesheet,
     };

Don't forget to add useMemo to the React imports:

-import { useCallback, useEffect } from 'react';
+import { useCallback, useEffect, useMemo } from 'react';
apps/web/app/[locale]/timesheet/[memberId]/page.tsx (3)

Line range hint 95-112: Replace hardcoded values with dynamic data.

The TimesheetCard components contain hardcoded values for counts, hours, and dates.

Consider fetching these statistics from the timesheet data:

  • Pending tasks count
  • Total hours worked
  • Number of active members

Line range hint 134-146: Implement search functionality.

The search input is currently non-functional. Consider implementing the search feature to filter timesheet entries.

Would you like me to help implement the search functionality for the timesheet data?


Line range hint 182-196: Improve accessibility in ViewToggleButton.

The toggle button component needs accessibility improvements.

Consider these enhancements:

 <button
     onClick={onClick}
+    role="tab"
+    aria-selected={active}
+    aria-controls={`${mode.toLowerCase()}-panel`}
     className={clsxm(
         'text-[#7E7991]  font-medium w-[191px] h-[40px] flex items-center gap-x-4 text-[14px] px-2 rounded',
         active && 'border-b-primary text-primary border-b-2 dark:text-primary-light dark:border-b-primary-light bg-[#F1F5F9] dark:bg-gray-800 font-bold'
     )}>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d5a4eeb and 7876fcc.

📒 Files selected for processing (4)
  • apps/web/app/[locale]/timesheet/[memberId]/components/TimesheetFilter.tsx (1 hunks)
  • apps/web/app/[locale]/timesheet/[memberId]/page.tsx (3 hunks)
  • apps/web/app/hooks/features/useTimesheet.ts (2 hunks)
  • apps/web/lib/features/integrations/calendar/table-time-sheet.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • apps/web/lib/features/integrations/calendar/table-time-sheet.tsx
🔇 Additional comments (3)
apps/web/app/[locale]/timesheet/[memberId]/components/TimesheetFilter.tsx (1)

12-12: LGTM! Type narrowing improves interface clarity.

The change to use Pick type makes the interface more precise by explicitly declaring required properties. This follows the interface segregation principle and reduces unnecessary prop drilling.

Let's verify no other properties from TimesheetFilterDateProps are being used:

✅ Verification successful

The previous regex was too complex. Let's simplify our approach by:

  1. Finding where TimesheetFilterDateProps is defined
  2. Understanding what properties it has
  3. Looking at how initDate is actually used in the codebase

This will help us verify if the type narrowing is safe and doesn't break existing code.


Type narrowing is correct and safe to use

The verification confirms that:

  1. TimesheetFilterDateProps interface only has 5 properties: onChange, initialRange, minDate, maxDate, and t
  2. The Pick type correctly includes all properties being used (initialRange, onChange, maxDate, minDate)
  3. The actual usage in the codebase only uses these picked properties when spreading initDate into TimesheetFilterDate component
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any usage of TimesheetFilterDateProps properties other than the picked ones
rg -l 'TimesheetFilterDateProps' | xargs rg -A 5 -B 5 '\b(?!initialRange|onChange|maxDate|minDate\b)[a-zA-Z]+(?=\s*[=:])'

Length of output: 392


Script:

#!/bin/bash
# First, let's find all files containing TimesheetFilterDateProps
rg -l "TimesheetFilterDateProps"

# Then, let's examine the interface definition
rg -A 5 "interface TimesheetFilterDateProps" 

# Finally, let's look at actual usage of initDate
rg -B 3 -A 3 "initDate"

Length of output: 3640

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

Line range hint 39-41: Improve error handling in getTaskTimesheet

Currently, errors are only logged to the console, which doesn't provide feedback to the user. Consider implementing proper error handling and user notification.

             }).catch((error) => {
-                console.error('Error fetching timesheet:', error);
+                const errorMessage = error?.response?.data?.message || 'Failed to fetch timesheet data';
+                console.error('Error fetching timesheet:', errorMessage);
+                // Assuming you have a notification system
+                notify({
+                    type: 'error',
+                    message: errorMessage
+                });
             });
#!/bin/bash
# Check if notification system is available in the codebase
rg -l "notify.*error" --type ts
apps/web/app/[locale]/timesheet/[memberId]/page.tsx (1)

11-11: Verify the removal of useDailyPlan dependency.

The transition from useDailyPlan to useTimesheet represents a significant architectural change. Let's ensure all daily plan functionalities are properly migrated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Ever Teams feature WEB Web app
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants