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: Implement Timesheet Filter Component With Status, Date Filters #3208

Merged
merged 5 commits into from
Oct 30, 2024

Conversation

Innocent-Akim
Copy link
Contributor

@Innocent-Akim Innocent-Akim commented Oct 30, 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

    • Introduced a DynamicDatePicker for enhanced date selection.
    • Added a TimeSheetFilterPopover component for filtering tasks by various criteria.
  • Improvements

    • Updated layout and styling for the FilterWithStatus, TimesheetCard, and TimesheetFilter components for a more compact design.
    • Enhanced icon presentation in the TimesheetPage component.
    • Streamlined styling and structure in the DataTableTimeSheet and calendar components.
    • Enhanced user interaction in the TimesheetFilter with new filtering options.
    • Improved overall component structure and consistency across various components.
  • Bug Fixes

    • Minor adjustments and formatting changes across various components for consistency.

Copy link
Contributor

coderabbitai bot commented Oct 30, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes in this pull request involve various components within the web application, primarily focusing on formatting, layout adjustments, and the introduction of new functionality. Key modifications include the addition of a DynamicDatePicker component, structural changes to the TimesheetFilter, and the introduction of a new TimeSheetFilterPopover component. Several components underwent styling updates, particularly with layout adjustments to enhance user interaction. Import statements were also streamlined across multiple files, contributing to a cleaner codebase without altering the core functionality of the components.

Changes

File Path Change Summary
apps/web/app/[locale]/calendar/component.tsx Updated import statement for Select component; minor formatting adjustments.
apps/web/app/[locale]/timesheet/components/FilterWithStatus.tsx Changed layout from grid to flex; updated button classes for full width and reduced height.
apps/web/app/[locale]/timesheet/components/FrequencySelect.tsx Added DynamicDatePicker component; updated CustomDateRange for state management; refined DropdownMenu structure and adjusted SelectTrigger width.
apps/web/app/[locale]/timesheet/components/TimesheetCard.tsx Simplified import of React; replaced Card with a div and updated class names for layout changes.
apps/web/app/[locale]/timesheet/components/TimesheetFilter.tsx Altered return structure to use a fragment; updated activeStatus for FilterWithStatus; added FilterTaskActionMenu and TimeSheetFilterPopover.
apps/web/app/[locale]/timesheet/components/TimesheetView.tsx Removed import statement for React; no changes to component structure or functionality.
apps/web/app/[locale]/timesheet/components/time-sheet-filter-popover.tsx Introduced new TimeSheetFilterPopover component for filtering tasks by various criteria using MultiSelect.
apps/web/app/[locale]/timesheet/page.tsx Updated icon props for TimesheetCard components to simplify styling; enhanced search input field styling.
apps/web/lib/features/integrations/calendar/setup-full-calendar.tsx Simplified React import; structural changes to SetupFullCalendar component; added multiple functions for rendering event details.
apps/web/lib/features/integrations/calendar/table-time-sheet.tsx Updated import statements for consistency; modified Table and TableHeader components for styling; ensured core functionality remains unchanged.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • Cedric921

Poem

🐇 In the fields where changes bloom,
Components dance, dispelling gloom.
With filters bright and calendars clear,
Our code now sings, for all to cheer!
A rabbit's hop, a joyful leap,
In every line, new dreams we keep! 🌼


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.

@Innocent-Akim Innocent-Akim self-assigned this Oct 30, 2024
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: 15

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

Line range hint 15-22: Hardcoded counts should be dynamic

The buttonData array contains hardcoded counts which should ideally be derived from actual data.

Consider modifying the component to accept counts as props:

type FilterCounts = {
  allTasks: number;
  pending: number;
  approved: number;
  rejected: number;
}

interface FilterWithStatusProps {
  activeStatus: FilterStatus;
  onToggle: (status: FilterStatus) => void;
  counts: FilterCounts;
  className?: HTMLAttributes<HTMLDivElement>;
}

Line range hint 1-34: Consider accessibility improvements

The component could benefit from some accessibility enhancements:

  1. Missing ARIA labels for the filter buttons
  2. No keyboard navigation support for the filter group

Consider these improvements:

 <div 
+  role="radiogroup"
+  aria-label="Timesheet status filter"
   className={clsxm('flex flex-nowrap h-[2.2rem] items-center bg-[#e2e8f0aa] rounded-xl w-full', className)}>
   {buttonData.map(({ label, count, icon }, index) => (
     <Button
       key={index}
+      role="radio"
+      aria-checked={activeStatus === label}
       className={/*...*/}
       onClick={() => onToggle(label)}>
apps/web/app/[locale]/timesheet/components/TimesheetFilter.tsx (1)

22-30: Consider adding loading and error states

The filter components lack loading and error states, which could lead to poor user experience when data is being fetched or when errors occur.

Consider:

  1. Adding loading spinners during data fetching
  2. Implementing error boundaries or error states
  3. Disabling filters when data is not available
apps/web/app/[locale]/timesheet/components/TimesheetCard.tsx (2)

Line range hint 24-63: Consider enhancing accessibility for interactive elements

While the card has good accessibility features like aria-label on the parent and button, the icon section might need improvement:

  1. Using aria-hidden="true" on the icon container is correct if it's purely decorative
  2. However, if the entire card is clickable (since there's an onClick prop), we should ensure proper keyboard navigation

Consider these improvements:

 <Card
     aria-label={`Timesheet card for ${title}`}
+    role="article"
+    tabIndex={onClick ? 0 : undefined}
+    onKeyDown={(e) => {
+      if (onClick && (e.key === 'Enter' || e.key === ' ')) {
+        e.preventDefault();
+        onClick();
+      }
+    }}
     shadow='custom'
-    className='w-full h-[175px] rounded-md border border-gray-200 flex  gap-8 shadow shadow-gray-100 p-3'>
+    className={clsxm(
+      'w-full h-[175px] rounded-md border border-gray-200 flex gap-8 shadow shadow-gray-100 p-3',
+      onClick && 'cursor-pointer hover:border-gray-300'
+    )}>

Line range hint 28-29: Clean up class string formatting

There's an extra space in the flex class string: flex gap-8

-    className='w-full h-[175px] rounded-md border border-gray-200 flex  gap-8 shadow shadow-gray-100 p-3'>
+    className='w-full h-[175px] rounded-md border border-gray-200 flex gap-8 shadow shadow-gray-100 p-3'>
apps/web/app/[locale]/timesheet/components/time-sheet-filter-popover.tsx (1)

1-103: Consider implementing filter persistence.

The current implementation doesn't persist filter selections across sessions or page reloads.

Consider these improvements:

  1. Use URL query parameters to persist filter selections
  2. Implement a filter context to share filter state across components
  3. Add local storage backup for filter preferences

Would you like me to provide implementation examples for any of these approaches?

apps/web/app/[locale]/timesheet/page.tsx (1)

Line range hint 63-64: Address hardcoded values and improve type safety.

Several improvements could enhance the code quality:

  1. The greeting message contains a hardcoded name "Ruslan". Consider using the authenticated user's name.
  2. Add proper aria-labels to interactive elements for better accessibility.
  3. Consider adding TypeScript types for the card metrics (count, hours) to ensure type safety.

Example implementation for the greeting:

- <h1 className='!text-[23px] font-bold text-[#282048]'>Good morning, Ruslan !</h1>
+ <h1 className='!text-[23px] font-bold text-[#282048]'>
+   Good morning, {user?.firstName || 'Guest'}!
+ </h1>
apps/web/lib/features/integrations/calendar/setup-full-calendar.tsx (7)

Line range hint 39-67: Replace hardcoded events with dynamic data.

The events array contains hardcoded dates set to August 2024. This could cause issues as these events might not be visible in the current calendar view.

Consider fetching events dynamically or using current date-relative values for testing:

- start: '2024-08-01',
+ start: new Date().toISOString().split('T')[0],

Line range hint 91-111: Replace 'any' types with proper TypeScript interfaces.

Several functions use the any type, which defeats TypeScript's type checking benefits.

Define proper interfaces for the calendar event info:

interface CalendarDayCellInfo {
  date: Date;
}

interface CalendarEventInfo {
  event: {
    title: string;
    extendedProps: {
      icon: JSX.Element;
    };
  };
}

Line range hint 113-121: Remove commented code.

There's commented out code for handleEventClick that should be either implemented or removed.

Remove the commented code block if it's not needed, or implement the functionality if it's required.


Line range hint 159-185: Remove debug styling and implement proper data flow.

The component has several issues:

  1. Debug styling (bg-red-400) is present
  2. Component contains hardcoded data instead of receiving it through props

Consider these improvements:

- <div className='flex flex-col w-full bg-red-400 md:h-[50vh] lg:h-[90vh] xl:h-[95vh] sticky top-0'>
+ <div className='flex flex-col w-full md:h-[50vh] lg:h-[90vh] xl:h-[95vh] sticky top-0'>

- <CardItemsProjects logo="https://dummyimage.com/330x300/0ecc9D/ffffff.jpg&text=N" title='Ever teams projects' totalHours='Total hours 52h' />
+ <CardItemsProjects projects={selectedDateProjects} />

Line range hint 187-203: Improve image handling and accessibility.

The component needs improvements in error handling and accessibility:

  1. Missing fallback for image loading errors
  2. Interactive element lacks keyboard accessibility

Apply these improvements:

- <div className='w-full flex items-center space-x-2 p-1 cursor-pointer hover:bg-gray-100 rounded dark:hover:bg-gray-700'>
+ <button 
+   className='w-full flex items-center space-x-2 p-1 hover:bg-gray-100 rounded dark:hover:bg-gray-700'
+   onClick={() => onMemberClick?.(name)}
+   aria-label={`View ${name}'s details`}
+ >
  <Image 
    className='text-white p-1 rounded-full flex items-center justify-center h-8 w-8' 
    src={imageUrl ? imageUrl : ''} 
+   alt={`${name}'s avatar`}
+   onError={(e) => {
+     e.currentTarget.src = '/default-avatar.png'
+   }}
    width={90} 
    height={90} 
  />

Line range hint 205-221: Add ARIA labels and improve image handling.

The component needs accessibility improvements and better image error handling.

Apply these improvements:

- <div className='flex items-center justify-start space-x-2 w-full pb-2'>
+ <button 
+   className='flex items-center justify-start space-x-2 w-full pb-2'
+   aria-expanded="false"
+   aria-label={`Toggle ${title} details`}
+ >
  <Image 
    src={logo ? logo : ''} 
    alt='logos' 
+   alt={`${title} logo`}
+   onError={(e) => {
+     e.currentTarget.src = '/default-project-logo.png'
+   }}
    width={100} 
    height={100} 
    className='h-8 w-8 bg-cover rounded-lg flex items-center justify-center' 
  />

Line range hint 224-233: Make total hours configurable via props.

The component uses a hardcoded value for total hours instead of receiving it as a prop.

Implement proper prop handling:

- export function TotalHours() {
+ export function TotalHours({ total }: { total: number }) {
  return (
    <div className="w-[200px] flex items-center !text-gray-800 dark:!text-slate-200 justify-between text-left font-normal h-10 border border-slate-200 rounded-lg px-2">
      <div className="flex items-center">
        <IoTimeSharp className="mr-2 h-5 w-5" />
-       <span>Total Hours 240</span>
+       <span>Total Hours {total}</span>
      </div>
    </div>
  )
}
apps/web/app/[locale]/timesheet/components/FrequencySelect.tsx (2)

38-38: Consider using relative units for width

Using fixed pixel values like w-[170px] may affect responsiveness on different screen sizes. Consider using relative units (e.g., w-full, max-w-sm) or responsive design utilities to enhance adaptability.


90-90: Initialize 'isDropdownOpen' to false for expected behavior

Setting isDropdownOpen to true will make the CustomDateRange dropdown open by default, which may not be intended.

Initialize the state as:

- const [isDropdownOpen, setDropdownOpen] = React.useState(true);
+ const [isDropdownOpen, setDropdownOpen] = React.useState(false);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7fce0f9 and ab254cc.

📒 Files selected for processing (10)
  • apps/web/app/[locale]/calendar/component.tsx (1 hunks)
  • apps/web/app/[locale]/timesheet/components/FilterWithStatus.tsx (1 hunks)
  • apps/web/app/[locale]/timesheet/components/FrequencySelect.tsx (4 hunks)
  • apps/web/app/[locale]/timesheet/components/TimesheetCard.tsx (2 hunks)
  • apps/web/app/[locale]/timesheet/components/TimesheetFilter.tsx (1 hunks)
  • apps/web/app/[locale]/timesheet/components/TimesheetView.tsx (0 hunks)
  • apps/web/app/[locale]/timesheet/components/time-sheet-filter-popover.tsx (1 hunks)
  • apps/web/app/[locale]/timesheet/page.tsx (3 hunks)
  • apps/web/lib/features/integrations/calendar/setup-full-calendar.tsx (1 hunks)
  • apps/web/lib/features/integrations/calendar/table-time-sheet.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • apps/web/app/[locale]/timesheet/components/TimesheetView.tsx
✅ Files skipped from review due to trivial changes (2)
  • apps/web/app/[locale]/calendar/component.tsx
  • apps/web/lib/features/integrations/calendar/table-time-sheet.tsx
🔇 Additional comments (9)
apps/web/app/[locale]/timesheet/components/FilterWithStatus.tsx (1)

23-23: LGTM: Layout change improves flexibility

The switch from grid to flex layout with flex-nowrap is a good choice as it ensures buttons stay in a single row and maintain consistent spacing.

apps/web/app/[locale]/timesheet/components/TimesheetFilter.tsx (2)

1-5: LGTM: Imports are well-organized

The imports are properly structured, separating local components from external library imports.


7-42: Verify integration with parent components

The TimesheetFilter component contains multiple filter sub-components that might affect the parent component's state and performance.

Let's check the component's usage and data flow:

#!/bin/bash
# Search for TimesheetFilter usage
rg -A 5 "TimesheetFilter" --type tsx

# Check for related state management
ast-grep --pattern 'const [$_] = useState<{ status?: string, date?: $_}>($$$)'
apps/web/app/[locale]/timesheet/components/TimesheetCard.tsx (1)

Line range hint 7-64: Overall implementation looks good!

The TimesheetCard component is well-structured with:

  • Clear prop interface
  • Good use of semantic HTML
  • Responsive text sizing
  • Proper event handling
apps/web/app/[locale]/timesheet/components/time-sheet-filter-popover.tsx (2)

1-11: LGTM! Clean import organization.

The imports are well-organized and properly grouped by their sources.


1-103: ⚠️ Potential issue

Missing date filter implementation.

According to the PR objectives, the component should include date filters, but they are not implemented.

Let's verify if date filters are implemented elsewhere:

Please add the date filter section to meet the PR requirements:

<div className="">
    <label className="flex justify-between text-gray-600 mb-1 text-sm">
        <span className="text-[12px]">Date Range</span>
        <span className="text-primary/10">Clear</span>
    </label>
    <DynamicDatePicker
        onChange={handleDateRangeChange}
        value={dateRange}
        selectsRange
        startDate={dateRange.start}
        endDate={dateRange.end}
    />
</div>
apps/web/app/[locale]/timesheet/page.tsx (1)

74-74: Verify icon sizing implementation.

The removal of explicit size classes from icons suggests that sizing is now handled elsewhere. Please ensure this aligns with the design system and that icons maintain consistent sizing across different screen sizes.

Also applies to: 81-81, 88-88

apps/web/app/[locale]/timesheet/components/FrequencySelect.tsx (2)

21-24: Imports are appropriate for new functionality

The added imports (DatePicker, cn, format, PiCalendarDotsThin) are necessary for the new components and features introduced.


170-170: Ensure 'DatePicker' handles null 'selected' value

The selected prop is set using date!, asserting that date is not null. Since date can be null, ensure that the DatePicker component gracefully handles a null value for selected.

Please confirm that DatePicker accepts null or undefined for the selected prop without errors. If not, consider providing a default value or adjusting the component to handle null.

Comment on lines +31 to +36
<Button
onClick={() => null}
variant='outline'
className='bg-primary/5 dark:bg-primary-light h-10 w-[2.5rem] font-medium'>
Add Time
</Button>
Copy link
Contributor

@coderabbitai coderabbitai bot Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Based on the search results, I can see that there's an existing implementation of the Add Time functionality in the codebase. The AddManualTimeModal component from lib/features/manual-time/add-manual-time-modal.tsx is used for this purpose, and it's already being used in other parts of the application.

The Add Time button should use the existing AddManualTimeModal component

The button's onClick handler should open the AddManualTimeModal component. Here are the specific changes needed:

  • Import the AddManualTimeModal component from 'lib/features/manual-time/add-manual-time-modal'
  • Add state management for the modal's open/close status
  • Connect the button's onClick handler to open the modal

Example implementation found in apps/web/lib/features/task/task-filters.tsx:

<AddManualTimeModal closeModal={closeManualTimeModal} isOpen={isManualTimeModalOpen} params="AddTime" />
🔗 Analysis chain

Implement Add Time button functionality

The Add Time button has an empty onClick handler. This seems to be incomplete implementation.

Let's check if there are any existing implementations we should use:

Would you like me to help implement the Add Time functionality or create a GitHub issue to track this task?


Let me search for implementations using different patterns to ensure we don't miss anything. The previous command failed because of incorrect file type specification, so I've corrected that and added more comprehensive searches.


Let me try different search patterns and commands since the previous ones had issues with file type recognition. I'll also check the timesheet directory structure to understand the context better.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for existing Add Time implementations
rg -i "add.*time" --type tsx

Length of output: 247


Script:

#!/bin/bash
# Search for existing Add Time implementations with ripgrep, using correct file type
rg -i "add.*time" -t ts -t tsx

# Look for any modal or form components related to time entry
rg -i "(timeentry|addtime|timeinput)" -t ts -t tsx

# Search for any state management or handlers related to time
ast-grep --pattern 'const [$_] = useState($$$)'
ast-grep --pattern 'function handle[$_]Time($$$) { $$$ }'

Length of output: 697


Script:

#!/bin/bash
# Try searching with just 't' type for TypeScript files
rg -i "add.*time" -t ts
rg -i "(timesheet|timelog)" -t ts

# Look for any timesheet-related components or handlers
fd -e tsx -e ts | grep -i "time"

# Check the specific directory for related components
ls -R apps/web/app/*/timesheet/

Length of output: 39438

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Innocent-Akim, understood.

(A small rabbit looks down sadly.)


✏️ Learnings added
Learnt from: Innocent-Akim
PR: ever-co/ever-teams#3208
File: apps/web/app/[locale]/timesheet/components/TimesheetFilter.tsx:30-35
Timestamp: 2024-10-30T16:31:00.562Z
Learning: In the `TimesheetFilter` component, the `Add Time` button does not need to use the `AddManualTimeModal` component, as per the user's decision.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

apps/web/app/[locale]/timesheet/page.tsx Show resolved Hide resolved
Comment on lines +67 to 79
<DropdownMenuItem onClick={(e) => e.preventDefault()} className="cursor-pointer hover:bg-primary" >
Today
</DropdownMenuItem>
<DropdownMenuItem className="cursor-pointer" >
<DropdownMenuItem onClick={(e) => e.preventDefault()} className="cursor-pointer hover:bg-primary" >
Last 7 days
</DropdownMenuItem>
<DropdownMenuItem className="cursor-pointer" >
<DropdownMenuItem onClick={(e) => e.preventDefault()} className="cursor-pointer hover:bg-primary" >
Last 30 days
</DropdownMenuItem>
<DropdownMenuItem className="cursor-pointer" >
This year (2024)
{/* ({new Date().getFullYear()}) */}
<DropdownMenuItem onClick={(e) => e.preventDefault()} className="cursor-pointer hover:bg-primary" >
This year ({new Date().getFullYear()})
</DropdownMenuItem>
{/* <DropdownMenuSeparator /> */}
<CustomDateRange />
Copy link
Contributor

@coderabbitai coderabbitai bot Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Implement functionality for date range selection

The onClick handlers for the date range options currently prevent default behavior but do not update any state. To make the menu functional, these handlers should update the component's state to reflect the selected date range.

For example:

<DropdownMenuItem
-  onClick={(e) => e.preventDefault()}
+  onClick={() => handleDateRangeSelect('today')}
   className="cursor-pointer hover:bg-primary" >
   Today
</DropdownMenuItem>

Define the handleDateRangeSelect function to update the state based on the selected range.

Committable suggestion was skipped due to low confidence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes here because I’ll add some modifications in the last PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Innocent-Akim, understood. Thank you for letting me know. I'll note that you'll be adding these modifications in a future PR.

(_/)
(•‿•)
( 📝)


✏️ Learnings added
Learnt from: Innocent-Akim
PR: ever-co/ever-teams#3208
File: apps/web/app/[locale]/timesheet/components/FrequencySelect.tsx:67-79
Timestamp: 2024-10-30T16:25:19.660Z
Learning: The date range selection functionality for the date range options in the `FilterTaskActionMenu` component will be implemented in a future PR.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Comment on lines +62 to +63
<span className="">20-10-20</span>
</Button>
Copy link
Contributor

@coderabbitai coderabbitai bot Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Replace hard-coded date with dynamic value

The date displayed is hard-coded as "20-10-20". This should be dynamic to reflect the selected date range or the current date for better user experience.

Consider updating the code to use a state variable that holds the selected date:

- <span className="">20-10-20</span>
+ <span className="">{selectedDate ? format(selectedDate, 'dd-MM-yy') : 'Select Date'}</span>

Ensure selectedDate is managed via React.useState and updated appropriately.

Committable suggestion was skipped due to low confidence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes here because I’ll add some modifications in the last PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Innocent-Akim, understood.

(_/)
(..)
(")
(")


🧠 Learnings used
Learnt from: Innocent-Akim
PR: ever-co/ever-teams#3208
File: apps/web/app/[locale]/timesheet/components/FrequencySelect.tsx:67-79
Timestamp: 2024-10-30T16:25:19.910Z
Learning: The date range selection functionality for the date range options in the `FilterTaskActionMenu` component will be implemented in a future PR.

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ab254cc and 78560c3.

📒 Files selected for processing (4)
  • apps/web/app/[locale]/timesheet/components/FilterWithStatus.tsx (1 hunks)
  • apps/web/app/[locale]/timesheet/components/FrequencySelect.tsx (4 hunks)
  • apps/web/app/[locale]/timesheet/components/TimesheetCard.tsx (2 hunks)
  • apps/web/app/[locale]/timesheet/components/TimesheetFilter.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/web/app/[locale]/timesheet/components/FilterWithStatus.tsx
  • apps/web/app/[locale]/timesheet/components/TimesheetCard.tsx
🔇 Additional comments (2)
apps/web/app/[locale]/timesheet/components/TimesheetFilter.tsx (2)

11-12: LGTM! Responsive layout implemented correctly.

The layout implementation follows best practices with:

  • Flexible container using flex-col/flex-row for responsive design
  • Appropriate breakpoints for mobile adaptation
  • Proper spacing using gap utilities

15-17: Implement the filter toggle handler and add type safety.

The TODO comment should be addressed with proper implementation. Consider:

  1. Adding proper TypeScript types for the label parameter
  2. Implementing the toggle handler to update the filter state

Would you like help implementing the toggle handler with proper type safety?

@@ -30,7 +35,7 @@
<Select
value={selectedValue}
onValueChange={handleSelectChange}>
<SelectTrigger className="w-[180px] border border-gray-200 dark:border-gray-700 bg-white dark:bg-dark--theme-light focus:ring-2 focus:ring-transparent">
<SelectTrigger className="w-[170px] border border-gray-200 dark:border-gray-700 bg-white dark:bg-dark--theme-light focus:ring-2 focus:ring-transparent">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Width change appears inconsistent with similar components

The width reduction from 180px to 170px creates an inconsistency with the calendar component that uses the same select pattern. The calendar component at apps/web/app/[locale]/calendar/component.tsx maintains a width of 180px for its SelectTrigger, which suggests this width reduction might be unintentional.

  • calendar/component.tsx: Uses w-[180px]
  • timesheet/components/FrequencySelect.tsx: Changed to w-[170px]

Both components appear to serve similar purposes with the same placeholder "Select a daily", so they should maintain consistent widths for a uniform UI experience.

🔗 Analysis chain

Verify the impact of width reduction.

The SelectTrigger width has been reduced from 180px to 170px. Please ensure this change doesn't cause content truncation or layout shifts in the UI.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other instances of similar width classes to verify consistency
rg -l 'w-\[1[7-8]0px\]' --type tsx

Length of output: 64


Script:

#!/bin/bash
# Search for width classes with proper file type
rg -l 'w-\[1[7-8]0px\]' --type ts --type tsx --type jsx --type js

# Also search for SelectTrigger components to understand the width patterns
rg -l 'SelectTrigger' --type ts --type tsx --type jsx --type js

Length of output: 187


Script:

#!/bin/bash
# Search for width classes without file type restrictions
rg -l 'w-\[1[7-8]0px\]'

# Search for SelectTrigger components without file type restrictions
rg 'SelectTrigger.*w-\[' -A 1 -B 1

Length of output: 2085

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

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

7-45: Consider implementing centralized filter state management.

The component handles multiple filter types (status, frequency, task filters). Consider implementing a centralized state management solution (e.g., React Context, Zustand, or Redux) to:

  1. Manage filter states cohesively
  2. Share filter states across components
  3. Implement filter reset functionality
  4. Persist filter preferences

This would make the component more maintainable and easier to extend with future filter requirements.

apps/web/app/[locale]/timesheet/components/FrequencySelect.tsx (1)

113-134: Enhance accessibility of the date range selector.

Consider the following accessibility improvements:

  • Add aria-label to buttons for better screen reader support
  • Include role="dialog" and aria-labelledby attributes on the date range selector

Apply these improvements:

-<button className="text-primary" onClick={cancelChanges}>Cancel</button>
-<button className="text-primary" onClick={applyChanges}>Apply</button>
+<button 
+  className="text-primary" 
+  onClick={cancelChanges}
+  aria-label="Cancel date range selection"
+>
+  Cancel
+</button>
+<button 
+  className="text-primary" 
+  onClick={applyChanges}
+  aria-label="Apply date range selection"
+>
+  Apply
+</button>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 78560c3 and aaa1fa2.

📒 Files selected for processing (2)
  • apps/web/app/[locale]/timesheet/components/FrequencySelect.tsx (4 hunks)
  • apps/web/app/[locale]/timesheet/components/TimesheetFilter.tsx (1 hunks)
🧰 Additional context used
📓 Learnings (2)
apps/web/app/[locale]/timesheet/components/FrequencySelect.tsx (1)
Learnt from: Innocent-Akim
PR: ever-co/ever-teams#3208
File: apps/web/app/[locale]/timesheet/components/FrequencySelect.tsx:67-79
Timestamp: 2024-10-30T16:25:19.910Z
Learning: The date range selection functionality for the date range options in the `FilterTaskActionMenu` component will be implemented in a future PR.
apps/web/app/[locale]/timesheet/components/TimesheetFilter.tsx (2)
Learnt from: Innocent-Akim
PR: ever-co/ever-teams#3208
File: apps/web/app/[locale]/timesheet/components/TimesheetFilter.tsx:30-35
Timestamp: 2024-10-30T16:31:01.294Z
Learning: In the `TimesheetFilter` component, the `Add Time` button does not need to use the `AddManualTimeModal` component, as per the user's decision.
Learnt from: Innocent-Akim
PR: ever-co/ever-teams#3208
File: apps/web/app/[locale]/timesheet/components/FrequencySelect.tsx:67-79
Timestamp: 2024-10-30T16:25:19.910Z
Learning: The date range selection functionality for the date range options in the `FilterTaskActionMenu` component will be implemented in a future PR.
🔇 Additional comments (5)
apps/web/app/[locale]/timesheet/components/TimesheetFilter.tsx (3)

11-12: LGTM! Responsive layout implementation.

The flex layout with responsive breakpoints is well-implemented, providing a good mobile-first approach with the flex-col md:flex-row classes.


35-40: ⚠️ Potential issue

Implement the Add Time button handler.

The onClick handler is currently set to null. Please implement the appropriate handler for the Add Time functionality.

Let's check for existing Add Time implementations that don't use AddManualTimeModal:

#!/bin/bash
# Search for Add Time button implementations
rg -A 5 "onClick.*[Aa]dd[Tt]ime"

13-18: ⚠️ Potential issue

Implement the filter toggle handler.

The onToggle handler contains a TODO comment. Please implement the handler to manage filter state changes.

Let's check for any existing filter state management implementations:

apps/web/app/[locale]/timesheet/components/FrequencySelect.tsx (2)

Line range hint 9-24: LGTM! Well-organized imports and interface definition.

The new imports are properly organized and the DatePickerInputProps interface is well-defined with clear type definitions.

Also applies to: 26-29


143-156: LGTM! Well-structured presentational component.

The DatePickerInput component is well-implemented with proper typing and conditional rendering.

Comment on lines +158 to +183
export function DynamicDatePicker({
label,
date,
setDate,
}: {
label: string;
date: Date | null;
setDate: (date: Date | null) => void;
}) {
return (
<div>
<DatePicker
buttonVariant={'link'}
className="dark:bg-dark--theme-light rounded-lg bg-white"
buttonClassName={'decoration-transparent flex items-center w-full bg-white dark:bg-dark--theme-light border-gray-300 justify-start text-left font-normal text-black h-10 border dark:border-slate-600 rounded-md'}
customInput={<DatePickerInput date={date} label={label} />}
mode="single"
numberOfMonths={1}
initialFocus
defaultMonth={date ?? new Date()}
selected={date ?? new Date()}
onSelect={(selectedDate) => selectedDate && setDate(selectedDate)}
/>
</div>
);
}
Copy link
Contributor

@coderabbitai coderabbitai bot Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider adding error boundary protection.

The DynamicDatePicker component handles dates well but could benefit from error boundary protection for robust error handling.

Consider wrapping the component with an error boundary:

class DatePickerErrorBoundary extends React.Component {
  state = { hasError: false };
  
  static getDerivedStateFromError() {
    return { hasError: true };
  }
  
  render() {
    if (this.state.hasError) {
      return <div>Error loading date picker. Please try again.</div>;
    }
    return this.props.children;
  }
}

// Usage
export function DynamicDatePicker({...props}) {
  return (
    <DatePickerErrorBoundary>
      <div>
        <DatePicker {...existing props} />
      </div>
    </DatePickerErrorBoundary>
  );
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skip

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Innocent-Akim, understood, I'll skip this suggestion.

(_/)
(;_;)


🧠 Learnings used
Learnt from: Innocent-Akim
PR: ever-co/ever-teams#3208
File: apps/web/app/[locale]/timesheet/components/FrequencySelect.tsx:67-79
Timestamp: 2024-10-30T16:25:19.910Z
Learning: The date range selection functionality for the date range options in the `FilterTaskActionMenu` component will be implemented in a future PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants