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]:Timesheet Skeleton Calendar-View #3419

Merged
merged 5 commits into from
Dec 12, 2024

Conversation

Innocent-Akim
Copy link
Contributor

@Innocent-Akim Innocent-Akim commented Dec 12, 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

  • New Features

    • Introduced a loading state with a skeleton loader in the CalendarView component.
    • Added an Accordion structure in TimesheetCardDetail for better task organization by status.
    • Implemented a new SelectionBar component for managing selections in the timesheet application.
    • Added a ViewToggleButton to switch between ListView and CalendarView modes.
    • Enhanced TimesheetFilter with a search input for filtering tasks.
  • Bug Fixes

    • Updated className in TimesheetCard to improve layout behavior.
  • Refactor

    • Simplified rendering logic in CalendarView for improved readability and structure.
    • Enhanced state management for timesheet view mode with local storage persistence.

Copy link
Contributor

coderabbitai bot commented Dec 12, 2024

Warning

Rate limit exceeded

@Innocent-Akim has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 45 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between b743c96 and e94e699.

📒 Files selected for processing (1)
  • apps/web/app/[locale]/timesheet/[memberId]/components/SelectionBar.tsx (1 hunks)

Walkthrough

The pull request introduces significant modifications to the CalendarView, TimesheetCard, and SelectionBar components. In CalendarView.tsx, a new TimesheetSkeleton import is added to handle loading states more effectively, improving the rendering logic with clearer conditional checks. The TimesheetCard.tsx file sees minor adjustments, including updates to class names and the addition of an Accordion structure for displaying tasks by status. A new SelectionBar component is introduced for managing selections in the timesheet application. Overall, these changes enhance the clarity and functionality of the components without altering their core behavior.

Changes

File Path Change Summary
apps/web/app/[locale]/timesheet/[memberId]/components/CalendarView.tsx - Added import for TimesheetSkeleton.
- Refactored loading and no data handling logic with clearer conditional returns.
- Simplified main return structure for rendering logic.
apps/web/app/[locale]/timesheet/[memberId]/components/TimesheetCard.tsx - Updated TaskNameInfoDisplay className from rounded-sm h-auto to rounded-sm !h-auto.
- Introduced Accordion structure in TimesheetCardDetail for task status display, with conditional rendering for statuses.
apps/web/app/[locale]/timesheet/[memberId]/components/SelectionBar.tsx - Introduced new SelectionBar component for managing selections with buttons for actions.
- Added ActionButton component for rendering buttons with translations.
apps/web/app/[locale]/timesheet/[memberId]/components/index.tsx - Added export for the new SelectionBar component.
apps/web/app/[locale]/timesheet/[memberId]/page.tsx - Added new ViewToggleButton component for switching views.
- Updated TimesheetFilter to include search functionality.
- Enhanced state management for timesheet view mode.

Possibly related PRs

Suggested labels

feature, WEB, Ever Teams

Suggested reviewers

  • evereq

🐰 In the land of code where rabbits play,
The CalendarView shines bright today.
With skeleton loaders to ease the wait,
And timesheets grouped, oh, what a fate!
Hopping through changes, so clear and neat,
A joyful update, oh, what a treat! 🐇


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. (Experiment)
  • @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: 1

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

154-154: Consider alternatives to !important modifier

The use of the Tailwind CSS !important modifier (!h-auto) suggests potential CSS specificity conflicts. While this might fix the immediate issue, it could lead to maintenance challenges and make the styles harder to override when needed.

Consider these alternatives:

  1. Restructure the CSS classes to avoid specificity conflicts
  2. Use more specific selectors in the parent components
  3. Review the CSS architecture to identify the root cause of the specificity issue
apps/web/app/[locale]/timesheet/[memberId]/components/CalendarView.tsx (2)

37-45: Consider making the skeleton count dynamic

While the loading state implementation is good, the hardcoded skeleton count (10) could be made more flexible based on viewport size or typical data length.

Consider this improvement:

-{Array.from({ length: 10 }).map((_, index) => (
+const skeletonCount = Math.min(Math.floor(window.innerHeight / 100), 15); // Adjust divisor based on skeleton height
+{Array.from({ length: skeletonCount }).map((_, index) => (

Line range hint 182-288: Consider splitting BaseCalendarDataView for better maintainability

The BaseCalendarDataView component is quite large and shares similar rendering logic with CalendarDataView. Consider extracting the task rendering logic into a separate reusable component to reduce code duplication and improve maintainability.

Suggested structure:

  1. Create a TaskCard component for the individual task rendering
  2. Create a TaskGroupAccordion component for the status-grouped tasks
  3. Use these components in both CalendarDataView and BaseCalendarDataView

Would you like me to help create these component extractions?

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b6cded9 and 2d275d3.

📒 Files selected for processing (2)
  • apps/web/app/[locale]/timesheet/[memberId]/components/CalendarView.tsx (2 hunks)
  • apps/web/app/[locale]/timesheet/[memberId]/components/TimesheetCard.tsx (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
apps/web/app/[locale]/timesheet/[memberId]/components/CalendarView.tsx

[error] 57-65: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)

🔇 Additional comments (3)
apps/web/app/[locale]/timesheet/[memberId]/components/TimesheetCard.tsx (1)

154-157: Verify layout behavior across different states

The height modification could affect the component's layout behavior. Please verify:

  1. Task names with varying lengths (short, long, multi-line)
  2. Different viewport sizes
  3. Dark/light theme transitions
  4. Different task statuses and their associated styling
✅ Verification successful

Based on the search results, I can see that the h-auto class is used consistently across the codebase for the TaskNameInfoDisplay component in different views (TimesheetCard, CalendarView, EditTaskModal) with similar styling patterns. The height modification is part of a consistent design pattern where:

  1. The container elements have fixed heights (h-[100px], h-[110px]) to maintain layout stability
  2. The task name display uses h-auto with specific padding (!px-[0.3312rem] py-[0.2875rem]) to allow content to flow naturally
  3. The shadow and theme transitions are handled consistently across all instances
  4. The text styling (text-sm !text-ellipsis !overflow-hidden) ensures proper text truncation

Let me generate the final response:

Height modification follows established pattern and is safe

The h-auto class is used consistently across all task display instances in the codebase, with proper container constraints and text overflow handling. The implementation follows the established pattern for:

  • Task containers with fixed heights
  • Flexible task name display with consistent padding
  • Proper theme transitions
  • Text overflow handling
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other height-related styles that might conflict
rg -A 2 'h-\[.*?\]|h-auto' apps/web/app/

# Look for related TaskNameInfoDisplay usage
ast-grep --pattern 'TaskNameInfoDisplay className={$_}'

Length of output: 25639

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

15-15: LGTM! Good addition of loading skeleton

The addition of TimesheetSkeleton improves user experience by providing visual feedback during data loading.


47-53: LGTM! Well-implemented empty state

The empty state handling is clean, properly translated, and maintains consistent styling with dark mode support.

@Innocent-Akim Innocent-Akim self-assigned this Dec 12, 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: 0

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

37-45: Consider memoizing the skeleton array

The skeleton array is recreated on every render. Consider memoizing it for better performance.

+const SKELETON_COUNT = 10;
+const skeletonArray = Array.from({ length: SKELETON_COUNT });

 if (loading || !data) {
     return (
         <div className="grow h-full w-full bg-[#FFFFFF] dark:bg-dark--theme">
-            {Array.from({ length: 10 }).map((_, index) => (
+            {skeletonArray.map((_, index) => (
                 <TimesheetSkeleton key={index} />
             ))}
         </div>
     );
 }

Line range hint 71-266: Consider extracting shared task card components

There's significant duplication in the task card rendering logic between CalendarDataView and BaseCalendarDataView. Consider extracting this into a shared component to improve maintainability.

Example approach:

// TaskCard.tsx
interface TaskCardProps {
  task: any; // Replace with proper type
  status: string;
}

export const TaskCard: React.FC<TaskCardProps> = ({ task, status }) => {
  return (
    <div
      style={{
        backgroundColor: statusColor(status).bgOpacity,
        borderLeftColor: statusColor(status).border
      }}
      className={cn(
        'border-l-4 rounded-l flex flex-col p-2 gap-2 items-start space-x-4 h-[100px]',
      )}
    >
      {/* Move the shared card content here */}
    </div>
  );
};

// StatusAccordion.tsx
interface StatusAccordionProps {
  status: string;
  rows: any[]; // Replace with proper type
  renderTask: (task: any) => React.ReactNode;
}

export const StatusAccordion: React.FC<StatusAccordionProps> = ({ status, rows, renderTask }) => {
  return (
    <AccordionItem value={status === 'DENIED' ? 'REJECTED' : status} className="p-1 rounded">
      {/* Move the shared accordion content here */}
    </AccordionItem>
  );
};
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2d275d3 and 01b0655.

📒 Files selected for processing (1)
  • apps/web/app/[locale]/timesheet/[memberId]/components/CalendarView.tsx (2 hunks)
🔇 Additional comments (3)
apps/web/app/[locale]/timesheet/[memberId]/components/CalendarView.tsx (3)

15-15: LGTM: Clean skeleton loader import

The addition of TimesheetSkeleton import follows the project's import structure and improves the loading state UX.


47-53: LGTM: Clean empty state implementation

The empty state implementation is well-structured with proper translations and styling.


57-66: Improved conditional rendering with switch statement

The refactoring from nested ternaries to a switch statement improves code readability and maintainability.

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

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

Line range hint 224-241: Fix inconsistent border styling

The border property usage is inconsistent.

-<div className="flex flex-col w-full border-1 rounded-lg bg-[#FFFFFF] dark:bg-dark--theme px-4">
+<div className="flex flex-col w-full border rounded-lg bg-[#FFFFFF] dark:bg-dark--theme px-4">

Line range hint 249-262: Consider moving ViewToggleButton to a separate file

The ViewToggleButton component should be moved to its own file in the components directory for better maintainability and reusability.

Create a new file components/ViewToggleButton.tsx:

import { clsxm } from '@app/utils';
import { TranslationHooks } from 'next-intl';

interface ViewToggleButtonProps {
    mode: 'ListView' | 'CalendarView';
    active: boolean;
    icon: React.ReactNode;
    onClick: () => void;
    t: TranslationHooks;
}

export const ViewToggleButton: React.FC<ViewToggleButtonProps> = //... existing implementation
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 01b0655 and d86b995.

📒 Files selected for processing (3)
  • apps/web/app/[locale]/timesheet/[memberId]/components/SelectionBar.tsx (1 hunks)
  • apps/web/app/[locale]/timesheet/[memberId]/components/index.tsx (1 hunks)
  • apps/web/app/[locale]/timesheet/[memberId]/page.tsx (2 hunks)
🧰 Additional context used
📓 Learnings (1)
apps/web/app/[locale]/timesheet/[memberId]/page.tsx (1)
Learnt from: Innocent-Akim
PR: ever-co/ever-teams#3208
File: apps/web/app/[locale]/timesheet/components/TimesheetFilter.tsx:30-35
Timestamp: 2024-11-12T14:06:02.202Z
Learning: In the `TimesheetFilter` component, the `Add Time` button does not need to use the `AddManualTimeModal` component, as per the user's decision.
🔇 Additional comments (1)
apps/web/app/[locale]/timesheet/[memberId]/components/index.tsx (1)

14-14: LGTM! Export follows consistent pattern

The new export for SelectionBar follows the established barrel file pattern.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d86b995 and b743c96.

📒 Files selected for processing (1)
  • apps/web/app/[locale]/timesheet/[memberId]/components/SelectionBar.tsx (1 hunks)
🔇 Additional comments (4)
apps/web/app/[locale]/timesheet/[memberId]/components/SelectionBar.tsx (4)

1-8: LGTM! Well-structured type definition and appropriate imports.

The ActionButtonProps type properly includes React.MouseEvent typing for the onClick handler, which is a good practice for type safety.


29-33: ⚠️ Potential issue

Replace hardcoded selection count with dynamic value

The selection count "2" and "selected" text are hardcoded values that should be dynamic and translated.

 <div className="bg-primary dark:bg-primary-light text-white rounded-full h-7 w-7 flex items-center justify-center font-bold">
-    <span>2</span>
+    <span>{selectedCount}</span>
 </div>
-<span>selected</span>
+<span>{t('pages.timesheet.SELECTED_ITEMS', { count: selectedCount })}</span>

38-43: ⚠️ Potential issue

Translate "Clear Selection" text and add onClick handler

The "Clear Selection" text should use the translation system and have a proper onClick handler.

 <button
     className="font-semibold h-8 px-3 rounded-lg text-[#3826A6] dark:text-primary-light"
-    aria-label="Clear Selection"
+    aria-label={t("pages.timesheet.CLEAR_SELECTION")}
+    onClick={onClearSelection}
 >
-    Clear Selection
+    {t("pages.timesheet.CLEAR_SELECTION")}
 </button>

9-16: 🛠️ Refactor suggestion

Add accessibility attributes to ActionButton

The button needs proper accessibility attributes for better screen reader support.

 const ActionButton = ({ label, onClick }: ActionButtonProps) => (
     <button
         className="bg-white font-semibold h-8 px-3 rounded-lg text-[#282048] dark:text-white dark:bg-primary-light"
         onClick={onClick}
+        aria-label={label}
+        role="button"
     >
         {label}
     </button>
 );

Likely invalid or redundant comment.

@evereq evereq merged commit 1bbb370 into develop Dec 12, 2024
12 checks passed
@evereq evereq deleted the feat/timesheet-skeleton-calendar-view branch December 12, 2024 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants