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

763-refactor: Display mentorship dates #789

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

Conversation

karlovich
Copy link
Collaborator

@karlovich karlovich commented Feb 10, 2025

What type of PR is this? (select all that apply)

  • πŸ• Feature
  • πŸ› Bug Fix
  • 🚧 Breaking Change
  • πŸ§‘β€πŸ’» Code Refactor
  • πŸ“ Documentation Update

Description

  • Add personal mentoring dates configured in RS App Admin panel as
    "Mentor activities" Start Date - End Date.
  • Refactor component logic
    • Add separate component DateSimple for rendering dates in the app, covered with tests
    • Rename and refactor DateLang component which purpose is more wide than only date lang to ShortInfoPanel, add test for the new scenario

Related Tickets & Documents

Screenshots, Recordings

Desktop
image

Mobile
image

Tablet (from 810 px to 1080) dates look like below, not an ideal, but fitting. Rework is suggested as a minor issue in the separate ticket:
image

Added/updated tests?

  • πŸ‘Œ Yes
  • πŸ™…β€β™‚οΈ No, because they aren't needed
  • πŸ™‹β€β™‚οΈ No, because I need help

[optional] Are there any post deployment tasks we need to perform?

[optional] What gif best describes this PR or how it makes you feel?

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added personal mentoring start and end dates to courses, enabling enhanced display of mentoring information.
    • Introduced standardized labels and separators for mentorship details in the user interface.
    • Added a new DateSimple component for improved date display functionality.
    • Introduced a new ShortInfoPanel component to replace legacy date display components.
    • Updated CourseCard and HeroCourse components to utilize new mentoring display features.
  • Style

    • Refined layout and spacing for course information panels for improved visual clarity.
  • Tests & Refactor

    • Updated test suites to verify and support the new mentoring and date display functionality.

@karlovich karlovich self-assigned this Feb 10, 2025
@github-actions github-actions bot changed the title feat: Display mentorship dates 763-refactor: Display mentorship dates Feb 10, 2025
@karlovich karlovich marked this pull request as draft February 10, 2025 15:15
Copy link
Contributor

coderabbitai bot commented Feb 10, 2025

πŸ“ Walkthrough

Walkthrough

The changes enhance the course data model by adding two new nullable properties, personalMentoringStartDate and personalMentoringEndDate, across multiple modules. These updates affect data definitions, type declarations, API synchronization (using DayJS for formatting), and UI components. New components such as DateSimple and ShortInfoPanel have been introduced to conditionally render mentoring dates, while deprecated components like DateLang and DateStart have been removed. Additionally, associated tests, styling, and constants have been updated to support displaying mentorship dates when enabled.

Changes

File(s) Change Summary
dev-data/courses.data.ts, src/entities/course/types.ts, src/shared/__tests__/constants.ts, src/shared/helpers/getActualData.test.ts Added personalMentoringStartDate and personalMentoringEndDate properties to course objects and test mocks.
src/entities/course/helpers/sync-with-api-data.ts Updated sync function to format and include new mentoring date fields using DayJS.
src/entities/course/ui/course-card/course-card.tsx, src/entities/course/ui/course-card/course-card.test.tsx, src/views/mentorship/ui/mentorship-courses/mentorship-courses.tsx Extended CourseCard component with new mentoring date props and added a showMentoringStartDate flag for conditional rendering.
src/entities/course/ui/course-item/course-item.tsx, src/entities/course/ui/course-item/course-item.test.tsx, src/entities/course/ui/course-item/course-item.module.scss Replaced DateStart with ShortInfoPanel for displaying dates; updated test identifiers and layout styling.
src/shared/helpers/getCourseDate.ts, src/shared/ui/date-simple/date-simple.tsx, src/shared/ui/date-simple/date-simple.test.tsx, src/shared/ui/date-simple/date-simple.module.scss, src/shared/ui/date-simple/index.ts Introduced calculateFreshDate helper and new DateSimple component for formatted date display.
src/shared/ui/date-lang/date-lang.tsx, src/shared/ui/date-lang/index.ts, src/shared/ui/date-start/index.ts, src/shared/ui/date-start/ui/date-start.tsx Removed deprecated date components (DateLang, DateStart) and their exports.
src/shared/ui/short-info-panel/short-info-panel.tsx, src/shared/ui/short-info-panel/short-info-panel.test.tsx, src/shared/ui/short-info-panel/short-info-panel.module.scss, src/shared/ui/short-info-panel/index.ts Added new ShortInfoPanel component for conditional date and language display with updated tests and styles.
src/shared/constants.ts, src/widgets/hero-course/ui/hero-course.tsx Added new LABELS constant for mentorship labels and updated HeroCourse to use ShortInfoPanel instead of DateLang.

Possibly related PRs

  • 535-refactor: Widget School CoursesΒ #572: The changes in the main PR, which involve adding personalMentoringStartDate and personalMentoringEndDate properties to course objects, are related to the modifications in the retrieved PR that also involve the CourseCard component.
  • 471-refactor: Entity courseΒ #503: The changes in the main PR, which add new properties to course objects, are related to the modifications in the retrieved PR that also involve the Course type and its usage in the courses.data.ts file.

Suggested labels

refactor, feature

Suggested reviewers

  • andron13
  • dzmitry-varabei
  • natanchik
  • Quiddlee
  • ansivgit
  • SpaNb4
✨ Finishing Touches
  • πŸ“ Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❀️ Share
πŸͺ§ Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

🧹 Nitpick comments (7)
src/views/mentorship/ui/mentorship-courses/mentorship-courses.tsx (1)

23-28: Make mentoring date display configurable.

Consider deriving showMentoringStartDate from course data instead of hardcoding it to true.

 <CourseCard
   key={course.id}
   className={cx('mentorship-course-card')}
   {...course}
-  showMentoringStartDate={true}
+  showMentoringStartDate={Boolean(course.personalMentoringStartDate)}
 />
src/shared/constants.ts (1)

7-12: Add internationalization support for labels.

The app supports multiple languages, but the new labels are only in English.

 export const LABELS = {
   START_DATE: 'Start:',
+  START_DATE_RU: 'Начало:',
   MENTOR_ACTIVITIES: 'Mentor activities:',
+  MENTOR_ACTIVITIES_RU: 'ΠœΠ΅Π½Ρ‚ΠΎΡ€ΡΠΊΠ°Ρ Π°ΠΊΡ‚ΠΈΠ²Π½ΠΎΡΡ‚ΡŒ:',
   MENTORING_DATES_SEPARATOR: '-',
   SHORT_INFO_SEPARATOR: 'β€’',
 };
src/shared/ui/date-simple/date-simple.tsx (1)

21-27: Consider memoizing the component for better performance.

Since this component might be rendered frequently in lists, consider using React.memo to prevent unnecessary re-renders.

-export const DateSimple = ({
+export const DateSimple = React.memo(({
   startDate,
   endDate,
   label,
   labelSeparator,
   children,
-}: DateStartProps) => {
+}: DateStartProps) => {
src/entities/course/ui/course-item/course-item.test.tsx (1)

26-36: Add test cases for edge scenarios.

Consider adding tests for:

  • Null dates
  • TO_BE_DETERMINED dates
  • Invalid date strings
+  it('handles null dates gracefully', () => {
+    renderWithRouter(<CourseItem {...mockedProps} startDate={null} />);
+    expect(screen.queryByTestId('date-time-start')).not.toBeInTheDocument();
+  });
src/shared/ui/short-info-panel/short-info-panel.tsx (1)

59-59: Add null check for mode prop.

The mode prop is optional but used directly in JSX without a null check.

-          <span className={cx('mode')}>{mode}</span>
+          <span className={cx('mode')}>{mode || ''}</span>
src/shared/ui/short-info-panel/short-info-panel.test.tsx (1)

10-60: Add test for withMargin prop.

The test suite is comprehensive but missing coverage for the withMargin prop's effect on styling.

Consider adding:

it('applies margin class when withMargin is true', () => {
  render(
    <ShortInfoPanel
      startDate=""
      registrationEndDate=""
      language="en"
      withMargin={true}
    />
  );
  expect(screen.getByRole('region')).toHaveClass('margin');
});
src/shared/ui/date-simple/date-simple.test.tsx (1)

60-62: Remove unnecessary Fragment.

The Fragment is redundant as it wraps only a single span element.

-        <>
          <span>{additionalInfoText}</span>
-        </>
+        <span>{additionalInfoText}</span>
🧰 Tools
πŸͺ› Biome (1.9.4)

[error] 60-62: 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)

πŸ“œ Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 78db4a9 and 8333b42.

πŸ“’ Files selected for processing (26)
  • dev-data/courses.data.ts (9 hunks)
  • src/entities/course/helpers/sync-with-api-data.ts (1 hunks)
  • src/entities/course/types.ts (2 hunks)
  • src/entities/course/ui/course-card/course-card.test.tsx (1 hunks)
  • src/entities/course/ui/course-card/course-card.tsx (4 hunks)
  • src/entities/course/ui/course-item/course-item.module.scss (1 hunks)
  • src/entities/course/ui/course-item/course-item.test.tsx (1 hunks)
  • src/entities/course/ui/course-item/course-item.tsx (1 hunks)
  • src/shared/__tests__/constants.ts (8 hunks)
  • src/shared/constants.ts (1 hunks)
  • src/shared/helpers/getActualData.test.ts (1 hunks)
  • src/shared/helpers/getCourseDate.ts (1 hunks)
  • src/shared/ui/date-lang/date-lang.tsx (0 hunks)
  • src/shared/ui/date-lang/index.ts (0 hunks)
  • src/shared/ui/date-simple/date-simple.module.scss (1 hunks)
  • src/shared/ui/date-simple/date-simple.test.tsx (1 hunks)
  • src/shared/ui/date-simple/date-simple.tsx (1 hunks)
  • src/shared/ui/date-simple/index.ts (1 hunks)
  • src/shared/ui/date-start/index.ts (0 hunks)
  • src/shared/ui/date-start/ui/date-start.tsx (0 hunks)
  • src/shared/ui/short-info-panel/index.ts (1 hunks)
  • src/shared/ui/short-info-panel/short-info-panel.module.scss (0 hunks)
  • src/shared/ui/short-info-panel/short-info-panel.test.tsx (1 hunks)
  • src/shared/ui/short-info-panel/short-info-panel.tsx (1 hunks)
  • src/views/mentorship/ui/mentorship-courses/mentorship-courses.tsx (1 hunks)
  • src/widgets/hero-course/ui/hero-course.tsx (2 hunks)
πŸ’€ Files with no reviewable changes (5)
  • src/shared/ui/date-lang/index.ts
  • src/shared/ui/date-start/index.ts
  • src/shared/ui/short-info-panel/short-info-panel.module.scss
  • src/shared/ui/date-lang/date-lang.tsx
  • src/shared/ui/date-start/ui/date-start.tsx
βœ… Files skipped from review due to trivial changes (2)
  • src/shared/ui/short-info-panel/index.ts
  • src/shared/ui/date-simple/index.ts
🧰 Additional context used
πŸͺ› Biome (1.9.4)
src/shared/ui/date-simple/date-simple.test.tsx

[error] 60-62: 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)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: CI
πŸ”‡ Additional comments (12)
src/entities/course/ui/course-item/course-item.tsx (1)

36-42: LGTM! Clean implementation of ShortInfoPanel.

The component maintains good accessibility with proper ARIA attributes and follows React best practices.

src/entities/course/ui/course-card/course-card.test.tsx (1)

23-24: Add test cases for mentoring dates.

While the new properties are added to mockProps, there are no test cases verifying the rendering of mentoring dates when they are present.

Consider adding test cases for:

  • When both mentoring dates are present
  • When only start date is present
  • When only end date is present
src/shared/ui/short-info-panel/short-info-panel.tsx (1)

14-22: LGTM! Well-structured props interface.

The props interface is clear and properly typed.

src/widgets/hero-course/ui/hero-course.tsx (1)

57-63: LGTM! Clean migration to ShortInfoPanel.

The replacement of DateLang with ShortInfoPanel is well-implemented with all necessary props.

src/shared/ui/date-simple/date-simple.test.tsx (1)

1-69: LGTM! Comprehensive test coverage.

The test suite thoroughly covers all essential scenarios for the DateSimple component.

🧰 Tools
πŸͺ› Biome (1.9.4)

[error] 60-62: 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)

src/entities/course/ui/course-card/course-card.tsx (2)

26-30: LGTM! Well-structured type definition.

The CourseCardProps type is properly extended with new optional properties.


60-87: LGTM! Clean conditional rendering implementation.

The component elegantly handles both mentoring and non-mentoring display modes.

src/shared/helpers/getActualData.test.ts (1)

19-122: LGTM! Thorough test data setup.

The mock data correctly includes the new mentoring date properties.

dev-data/courses.data.ts (1)

43-44: LGTM! Consistent data model extension.

The new mentoring date properties are consistently added across all course objects.

Also applies to: 65-66, 87-88, 108-109, 129-130, 150-151, 171-172, 193-194, 214-215

src/shared/__tests__/constants.ts (1)

47-48: LGTM! Consistent addition of mentoring date properties.

The new properties personalMentoringStartDate and personalMentoringEndDate are consistently added across all course objects with appropriate null initialization.

Also applies to: 69-70, 91-92, 112-113, 133-134, 154-155, 175-176, 196-197

src/shared/ui/date-simple/date-simple.module.scss (1)

1-16: LGTM! Clean and consistent styling.

The styles follow best practices with proper use of flexbox, consistent spacing, and design system variables.

src/entities/course/ui/course-item/course-item.module.scss (1)

22-30: LGTM! Improved layout structure.

The update to use flexbox with consistent gap spacing improves maintainability and follows modern CSS best practices.

Comment on lines 23 to 28
clonedCourse.personalMentoringStartDate = dayJS(
currApiCourse.personalMentoringStartDate,
).format(COURSE_DATE_FORMAT);
clonedCourse.personalMentoringEndDate = dayJS(currApiCourse.personalMentoringEndDate).format(
COURSE_DATE_FORMAT,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add validation for mentoring dates.

The current implementation might format invalid dates if the API returns null or undefined values.

-    clonedCourse.personalMentoringStartDate = dayJS(
-      currApiCourse.personalMentoringStartDate,
-    ).format(COURSE_DATE_FORMAT);
-    clonedCourse.personalMentoringEndDate = dayJS(currApiCourse.personalMentoringEndDate).format(
-      COURSE_DATE_FORMAT,
-    );
+    clonedCourse.personalMentoringStartDate = currApiCourse.personalMentoringStartDate
+      ? dayJS(currApiCourse.personalMentoringStartDate).format(COURSE_DATE_FORMAT)
+      : null;
+    clonedCourse.personalMentoringEndDate = currApiCourse.personalMentoringEndDate
+      ? dayJS(currApiCourse.personalMentoringEndDate).format(COURSE_DATE_FORMAT)
+      : null;
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
clonedCourse.personalMentoringStartDate = dayJS(
currApiCourse.personalMentoringStartDate,
).format(COURSE_DATE_FORMAT);
clonedCourse.personalMentoringEndDate = dayJS(currApiCourse.personalMentoringEndDate).format(
COURSE_DATE_FORMAT,
);
clonedCourse.personalMentoringStartDate = currApiCourse.personalMentoringStartDate
? dayJS(currApiCourse.personalMentoringStartDate).format(COURSE_DATE_FORMAT)
: null;
clonedCourse.personalMentoringEndDate = currApiCourse.personalMentoringEndDate
? dayJS(currApiCourse.personalMentoringEndDate).format(COURSE_DATE_FORMAT)
: null;

@karlovich karlovich marked this pull request as ready for review February 10, 2025 15:50
@karlovich karlovich marked this pull request as draft February 10, 2025 15:56
@karlovich karlovich added preview and removed preview labels Feb 10, 2025
Copy link

Lighthouse Report:

  • Performance: 69 / 100
  • Accessibility: 100 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

@karlovich karlovich marked this pull request as ready for review February 12, 2025 08:38
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 (3)
src/shared/ui/short-info-panel/short-info-panel.test.tsx (1)

42-59: Consider adding tests for edge cases.

While the current test coverage is good, consider adding tests for:

  • Empty or invalid dates
  • Error states
  • Different language codes
  • Various combinations of optional props

Would you like me to help generate additional test cases for these scenarios?

src/shared/ui/date-simple/date-simple.test.tsx (2)

11-11: Consider adding edge cases and using more realistic test data.

  1. The test dates use year 2088, which is far in the future. Consider using more realistic dates.
  2. Consider adding test cases for:
    • Invalid date formats
    • Empty strings
    • Null values
    • End date before start date

Also applies to: 21-21, 41-41, 55-55


58-64: Remove unnecessary Fragment wrapper.

The Fragment is redundant as it wraps a single child element.

    render(
      <DateSimple startDate={startDate}>
-        <>
          <span>{additionalInfoText}</span>
-        </>
      </DateSimple>,
    );
🧰 Tools
πŸͺ› Biome (1.9.4)

[error] 60-62: 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)

πŸ“œ Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 8333b42 and bcee5ef.

πŸ“’ Files selected for processing (7)
  • src/entities/course/ui/course-item/course-item.test.tsx (1 hunks)
  • src/shared/helpers/getActualData.test.ts (3 hunks)
  • src/shared/helpers/getCourseDate.ts (1 hunks)
  • src/shared/ui/date-simple/date-simple.test.tsx (1 hunks)
  • src/shared/ui/short-info-panel/index.ts (1 hunks)
  • src/shared/ui/short-info-panel/short-info-panel.test.tsx (2 hunks)
  • src/shared/ui/short-info-panel/short-info-panel.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/shared/ui/short-info-panel/index.ts
  • src/entities/course/ui/course-item/course-item.test.tsx
  • src/shared/helpers/getCourseDate.ts
  • src/shared/ui/short-info-panel/short-info-panel.tsx
  • src/shared/helpers/getActualData.test.ts
🧰 Additional context used
πŸͺ› Biome (1.9.4)
src/shared/ui/date-simple/date-simple.test.tsx

[error] 60-62: 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 (4)
src/shared/ui/short-info-panel/short-info-panel.test.tsx (2)

1-9: LGTM! Import statements are well-organized.

The imports are logically grouped and include all necessary dependencies for the test suite.


10-40: LGTM! Test cases are well-structured and focused.

Each test case verifies a specific aspect of the component with clear assertions.

src/shared/ui/date-simple/date-simple.test.tsx (2)

1-8: LGTM! Well-organized imports.

All necessary testing libraries and dependencies are properly imported.


9-69: LGTM! Comprehensive test coverage.

The test cases effectively cover the main component scenarios including basic rendering, full props, TBD cases, and children rendering.

🧰 Tools
πŸͺ› Biome (1.9.4)

[error] 60-62: 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)

Copy link

Lighthouse Report:

  • Performance: 99 / 100
  • Accessibility: 100 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link

Lighthouse Report:

  • Performance: 76 / 100
  • Accessibility: 100 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/shared/ui/short-info-panel/short-info-panel.test.tsx (1)

10-67: Add test coverage for missing scenarios.

Consider adding tests for:

  • The withMargin prop to verify margin styling
  • Null values for startDate and registrationEndDate
πŸ“œ Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 1d5d9d0 and fe797a7.

πŸ“’ Files selected for processing (9)
  • src/entities/course/constants.ts (1 hunks)
  • src/entities/course/helpers/sync-with-api-data.ts (2 hunks)
  • src/entities/course/ui/course-card/course-card.tsx (4 hunks)
  • src/entities/course/ui/course-item/course-item.tsx (2 hunks)
  • src/shared/ui/date-simple/date-simple.test.tsx (1 hunks)
  • src/shared/ui/date-simple/date-simple.tsx (1 hunks)
  • src/shared/ui/short-info-panel/short-info-panel.test.tsx (2 hunks)
  • src/shared/ui/short-info-panel/short-info-panel.tsx (1 hunks)
  • src/widgets/hero-course/ui/hero-course.tsx (2 hunks)
βœ… Files skipped from review due to trivial changes (1)
  • src/entities/course/constants.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/entities/course/helpers/sync-with-api-data.ts
  • src/entities/course/ui/course-card/course-card.tsx
  • src/widgets/hero-course/ui/hero-course.tsx
  • src/entities/course/ui/course-item/course-item.tsx
  • src/shared/ui/date-simple/date-simple.tsx
🧰 Additional context used
πŸͺ› Biome (1.9.4)
src/shared/ui/date-simple/date-simple.test.tsx

[error] 99-101: 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 (1)
src/shared/ui/short-info-panel/short-info-panel.tsx (1)

14-22: Consider making the label prop optional without default value.

As suggested in the previous review, we could remove the default label value and update the type to label?: string.

Comment on lines +37 to +41
startDate={
startDate && registrationEndDate
? calculateFreshDate(startDate, registrationEndDate)
: null
}
Copy link
Contributor

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Add null check for calculateFreshDate arguments.

The null check should be moved inside the ternary to prevent potential issues:

-startDate && registrationEndDate
-  ? calculateFreshDate(startDate, registrationEndDate)
-  : null
+startDate && registrationEndDate && calculateFreshDate(startDate, registrationEndDate) || null
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
startDate={
startDate && registrationEndDate
? calculateFreshDate(startDate, registrationEndDate)
: null
}
startDate={
startDate && registrationEndDate && calculateFreshDate(startDate, registrationEndDate) || null
}

Comment on lines +98 to +103
<DateSimple startDate={startDate}>
<>
<span>{additionalInfoText}</span>
</>
</DateSimple>,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Remove unnecessary Fragment wrapper.

The Fragment wrapper is redundant as it contains only one child element.

render(
  <DateSimple startDate={startDate}>
-    <>
      <span>{additionalInfoText}</span>
-    </>
  </DateSimple>,
);
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<DateSimple startDate={startDate}>
<>
<span>{additionalInfoText}</span>
</>
</DateSimple>,
);
<DateSimple startDate={startDate}>
<span>{additionalInfoText}</span>
</DateSimple>,
🧰 Tools
πŸͺ› Biome (1.9.4)

[error] 99-101: 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)

endDate={personalMentoringEndDate}
labelSeparator={LABELS.MENTORING_DATES_SEPARATOR}
startDate={personalMentoringStartDate || TO_BE_DETERMINED}
endDate={personalMentoringStartDate ? personalMentoringEndDate : null}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should it be endDate={personalMentoringEndDate ? personalMentoringEndDate : null}?

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.

Display mentorship dates correctly
4 participants