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(meetings): add month sorting | fix #3239 #3282

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

FussuChalice
Copy link
Contributor

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own 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
  • Any dependent changes have been merged and published in downstream modules

@rhahao
Copy link
Member

rhahao commented Dec 23, 2024

Task linked: CU-86c1br7q3 [FEAT] Add month sorting

Copy link

vercel bot commented Dec 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
organized-app ✅ Ready (Inspect) Visit Preview Dec 23, 2024 8:57pm

Copy link
Contributor

coderabbitai bot commented Dec 23, 2024

Walkthrough

This pull request introduces new icon components (IconSortDown and IconSortUp) and enhances the week selector functionality in the meetings feature. The changes include adding new SVG icons to the icon library, updating the CustomTabProps interface with additional properties, and implementing a sorting mechanism for the months display in the week selector. The modifications aim to improve the user interface and provide more customization options for tabs and week selection.

Changes

File Change Summary
src/components/icons/IconSortDown.tsx New React functional component for a sort down icon using Material-UI's SvgIcon
src/components/icons/IconSortUp.tsx New React functional component for a sort up icon using Material-UI's SvgIcon
src/components/icons/index.ts Added exports for IconSortDown and IconSortUp
src/components/tabs/index.types.ts Extended CustomTabProps interface with new properties: onChange, className, variant, minHeight, and sx
src/features/meetings/week_selector/index.tsx Added sorting icons and functionality to toggle sorting order
src/features/meetings/week_selector/months_container/index.tsx Added reverse prop to conditionally reverse months display
src/features/meetings/week_selector/months_container/index.types.ts Updated MonthsContainerType to include optional reverse property
src/features/meetings/week_selector/useWeekSelector.tsx Introduced sortDown state and handleToggleSort method

Sequence Diagram

sequenceDiagram
    participant User
    participant WeekSelector
    participant MonthsContainer
    
    User->>WeekSelector: Click sort icon
    WeekSelector->>WeekSelector: Toggle sortDown state
    WeekSelector->>MonthsContainer: Pass reverse={sortDown}
    MonthsContainer->>MonthsContainer: Conditionally reverse months
    MonthsContainer-->>User: Display months in new order
Loading

Possibly related PRs

Suggested reviewers

  • rhahao

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

🧹 Nitpick comments (11)
src/features/meetings/week_selector/months_container/index.types.ts (1)

5-5: Clarify the usage of the "reverse" property for improved maintainability.

Consider adding a short JSDoc or inline comment to explain how this property affects the ordering of months.

src/components/icons/IconSortUp.tsx (2)

3-9: Consider reusing a shared icon prop type.

You might centralize and reuse the prop type definition (IconProps) across multiple icon components to maintain consistency and reduce duplication.


11-41: Inline usage inside .

Although wrapping an in works, removing the nested tag and passing its paths directly to is a recommended MUI practice and can simplify the DOM structure.

-<SvgIcon
-  className={`organized-icon-sort-up ${className}`}
-  sx={{ width: `${width}px`, height: `${height}px`, ...sx }}
->
-  <svg
-    width="24"
-    height="24"
-    viewBox="0 0 24 24"
-    fill="none"
-    xmlns="http://www.w3.org/2000/svg"
-  >
-    <path d="..." fill={color} />
-    <path d="..." fill={color} />
-  </svg>
-</SvgIcon>

+<SvgIcon
+  className={`organized-icon-sort-up ${className}`}
+  sx={{ width: `${width}px`, height: `${height}px`, ...sx }}
+  viewBox="0 0 24 24"
+>
+  <path d="..." fill={color} />
+  <path d="..." fill={color} />
+</SvgIcon>
src/components/icons/IconSortDown.tsx (2)

3-9: Leverage a shared icon prop type for consistency.

Similar to IconSortUp, consider centralizing the prop type definition (IconProps) to improve consistency and scalability across your icon components.


11-41: Avoid nesting within .

Following MUI recommendations, inline the paths directly in the to simplify the DOM and keep your SVGs consistent across components.

-<SvgIcon
-  className={`organized-icon-sort-down ${className}`}
-  sx={{ width: `${width}px`, height: `${height}px`, ...sx }}
->
-  <svg
-    width="24"
-    height="24"
-    viewBox="0 0 24 24"
-    fill="none"
-    xmlns="http://www.w3.org/2000/svg"
-  >
-    <path d="..." fill={color} />
-    <path d="..." fill={color} />
-  </svg>
-</SvgIcon>

+<SvgIcon
+  className={`organized-icon-sort-down ${className}`}
+  sx={{ width: `${width}px`, height: `${height}px`, ...sx }}
+  viewBox="0 0 24 24"
+>
+  <path d="..." fill={color} />
+  <path d="..." fill={color} />
+</SvgIcon>
src/components/tabs/index.types.ts (4)

68-70: Enforce consistent naming conventions for className.

Proactively align naming across components (e.g., "className", "containerClassName", etc.) to keep your props uniform.


73-76: Document permissible "variant" values for clarity.

Though referencing MUI's TabsOwnProps['variant'], you could list acceptable variants like "scrollable" or "standard" to help developers avoid guesswork.


79-82: Consider setting a default minimum height.

A default minHeight might help maintain uniform visuals across tabs when the property is not specified by the consumer.


85-87: Use "sx" consistently with other MUI-based components.

Ensure that using the sx prop here aligns with your styling approach for tabs. Optionally, override top-level styling with a theme-based approach for a unified design system.

src/features/meetings/week_selector/useWeekSelector.tsx (1)

22-22: Consider naming consistency for clarity.
While "sortDown" is functional, consider naming it “isDescending” or something more descriptive to align with typical naming conventions.

src/features/meetings/week_selector/index.tsx (1)

30-31: Keep descriptive naming for better readability.
“sortDown” indicates descending order, which might be better named “isDescending” or “descendingOrderEnabled.”

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 33b36e4 and e92a207.

⛔ Files ignored due to path filters (2)
  • converter/svg/sources/name=sort-down.svg is excluded by !**/*.svg, !**/*.svg
  • converter/svg/sources/name=sort-up.svg is excluded by !**/*.svg, !**/*.svg
📒 Files selected for processing (8)
  • src/components/icons/IconSortDown.tsx (1 hunks)
  • src/components/icons/IconSortUp.tsx (1 hunks)
  • src/components/icons/index.ts (1 hunks)
  • src/components/tabs/index.types.ts (1 hunks)
  • src/features/meetings/week_selector/index.tsx (3 hunks)
  • src/features/meetings/week_selector/months_container/index.tsx (2 hunks)
  • src/features/meetings/week_selector/months_container/index.types.ts (1 hunks)
  • src/features/meetings/week_selector/useWeekSelector.tsx (3 hunks)
🔇 Additional comments (9)
src/components/tabs/index.types.ts (1)

60-65: Validate the "activeTab" index before invoking the callback.

Ensure callers correctly handle the case when an unexpected or out-of-range tab index gets passed to the onChange callback.

src/features/meetings/week_selector/useWeekSelector.tsx (3)

29-29: Great integration of the new “reverse” prop.
This enables a clean, easily maintainable approach to controlling month order.


75-76: Well-exposed hook state and toggle function.
Exporting both the state and method ensures flexible usage in the parent component.


45-47: Ensure consistent UI updates when toggling.
Double-check that all dependencies on “sortDown” properly re-render after toggling.

✅ Verification successful

Let me search for any dependencies on the sortDown state to verify its impact on UI updates.


Let me check the MonthsContainer component since it's the one that receives the sortDown state as a prop.


Let me try a different approach to find the MonthsContainer implementation.


Based on the gathered information, I can now provide a final response:

The sortDown toggle implementation is properly handled and safe.
The sortDown state is only used in one place to reverse the order of months in the MonthsContainer component, which performs a simple array reversal using the spread operator. The UI updates are properly managed through React's state management and prop system:

  • The state is toggled in useWeekSelector hook
  • Passed as a prop to MonthsContainer
  • MonthsContainer creates a new array on each render when the prop changes
  • Each MonthItem is properly keyed for React reconciliation
🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for usages of sortDown in the component and its dependencies
rg "sortDown" -A 3 -B 3

Length of output: 2714


Script:

#!/bin/bash
# Look for the component implementation to understand the context
ast-grep --pattern 'const useWeekSelector = () => {
  $$$
}'

Length of output: 5822


Script:

#!/bin/bash
# Find the component that uses this hook
rg "useWeekSelector" -A 3 -B 3

Length of output: 4112


Script:

#!/bin/bash
# Look for MonthsContainer implementation
ast-grep --pattern 'const MonthsContainer = ({ months, reverse }: MonthsContainerProps) => {
  $$$
}'

Length of output: 103


Script:

#!/bin/bash
# Search for any other components that might use sortDown or reverse prop
rg "reverse={" -A 3 -B 3

Length of output: 108


Script:

#!/bin/bash
# Look for MonthsContainer implementation with a simpler pattern
ast-grep --pattern 'const MonthsContainer = $_'

Length of output: 1889


Script:

#!/bin/bash
# Search for the file content directly
rg -l "MonthsContainer" | xargs cat

Length of output: 3020


Script:

#!/bin/bash
# Search for reverse prop usage with proper escaping
rg "reverse=\{" -A 3 -B 3

Length of output: 600

src/features/meetings/week_selector/index.tsx (2)

2-7: Good addition of sorting icons.
These icons make the UI more intuitive. Just ensure that size and color remain consistent across different themes or display modes.


68-97: Ensure minimal friction in user interactions.
While clicking the sort icon stops event propagation, ensure that this doesn’t prevent other crucial event handlers (e.g., tooltip, analytics) from firing if needed.

✅ Verification successful

Let me search for any event handlers or related functionality around this component.


Let me try a different search approach without specifying the file type.


Let me check if there are any tooltip or analytics-related components being used in this file.


Based on the findings, I can now generate the final response:

Event propagation implementation is appropriate
The current implementation of stopPropagation() is correct and safe. The component doesn't use any tooltips or analytics tracking that could be affected by stopping event propagation. The sort icon's click handler is properly isolated while maintaining the component's functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for the component file and its usage
rg -l "WeekSelector|week_selector" --type tsx

# Look for any tooltip or analytics related code in the week selector
rg -A 5 "tooltip|analytics|track" src/features/meetings/week_selector/

Length of output: 148


Script:

#!/bin/bash
# Search for the component file and its usage
rg -l "WeekSelector|week_selector"

# Look for event handlers, tooltips, or analytics in the week selector component
rg -A 5 "onClick|onHover|tooltip|analytics|track" src/features/meetings/week_selector/index.tsx

# Search for the handleToggleSort implementation
ast-grep --pattern 'const handleToggleSort = $_'

Length of output: 1452


Script:

#!/bin/bash
# Check for imports and component usage in the week selector
rg -A 3 "import.*from" src/features/meetings/week_selector/index.tsx

# Look for any tooltip components in the codebase
rg -l "Tooltip|tooltip" src/components/

# Check if there are any analytics utilities being imported
rg -l "analytics|track" src/utils/

Length of output: 701

src/components/icons/index.ts (1)

296-297: Icons successfully added.
They’re consistent with naming conventions and complement the existing library. No action needed.

src/features/meetings/week_selector/months_container/index.tsx (2)

5-7: Elegant condition for reversing the months.
Destructuring and reversing the array inline keeps the code concise.


19-19: Map key usage is correct.
Using the month’s “value” as the key is a reasonable approach to avoid potential duplicates.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 23, 2024
@ux-git
Copy link
Member

ux-git commented Dec 23, 2024

I'm sorry @FussuChalice but I mixed up the icons in Figma. Could you re-import the updated ones?

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

🧹 Nitpick comments (2)
src/components/icons/IconSortUp.tsx (2)

3-9: Consider improving type safety for className prop

The type definition is well-structured, but could be more specific about className expectations.

 type IconProps = {
   color?: string;
   width?: number;
   height?: number;
   sx?: SxProps<Theme>;
-  className?: string;
+  className?: string | undefined;
 };

19-22: Handle undefined className gracefully

The className concatenation could throw if className is undefined.

-      className={`organized-icon-sort-up ${className}`}
+      className={`organized-icon-sort-up${className ? ` ${className}` : ''}`}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e92a207 and e0cfb3e.

⛔ Files ignored due to path filters (2)
  • converter/svg/sources/name=sort-down.svg is excluded by !**/*.svg, !**/*.svg
  • converter/svg/sources/name=sort-up.svg is excluded by !**/*.svg, !**/*.svg
📒 Files selected for processing (2)
  • src/components/icons/IconSortDown.tsx (1 hunks)
  • src/components/icons/IconSortUp.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/icons/IconSortDown.tsx
🔇 Additional comments (2)
src/components/icons/IconSortUp.tsx (2)

43-43: LGTM!

The export statement follows the project's conventions.


1-43: Verify integration with sorting feature

Let's verify the integration of this icon with the sorting functionality mentioned in PR #3239.

✅ Verification successful

Based on the results, I can generate the final response as we have sufficient information about the integration.

Icon is properly integrated with week selector component

The IconSortUp component is correctly integrated:

  • Imported and used in the week selector component (src/features/meetings/week_selector/index.tsx)
  • Properly exported alongside IconSortDown in the icons index file
  • Used with the correct color prop matching the design system (color="var(--black)")
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of IconSortUp in the week selector component

# Check usage in week selector component
rg -A 5 "IconSortUp" "src/features/meetings"

# Verify if both sort icons are exported together
rg "IconSort(Up|Down)" "src/components/icons/index.ts"

Length of output: 1187

src/components/icons/IconSortUp.tsx Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

@FussuChalice: could you please add the functionality to store the sorting preference in localStorage and initially load that value when opening this form? Thank you.

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.

3 participants