Skip to content

835-fix: Stale data on the website #843

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

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

Conversation

Quiddlee
Copy link
Member

@Quiddlee Quiddlee commented Apr 6, 2025

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

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

Description

Related Tickets & Documents

Screenshots, Recordings

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

  • New Features
    • Introduced new components for displaying fresh courses, course menu items, course start labels, course availability status, and registration links.
    • Added dedicated components for rendering fresh course lists in various contexts, including mentorship and upcoming courses.
  • Refactor
    • Simplified and centralized course rendering logic across the header, footer, mobile view, and course-related widgets by delegating to new reusable components.
    • Replaced inline course item mapping and date handling with specialized components for improved maintainability and consistency.
  • Bug Fixes
    • Enhanced date and staleness handling for mentorship courses, ensuring accurate display of course availability.
  • Tests
    • Improved test reliability for course widgets by mocking date calculations for consistent test results.

@Quiddlee Quiddlee self-assigned this Apr 6, 2025
@github-actions github-actions bot changed the title Fix/835 stale data on the website 835-fix: Stale data on the website Apr 6, 2025
@Quiddlee Quiddlee changed the title 835-fix: Stale data on the website draft-835-fix: Stale data on the website Apr 7, 2025
Copy link

github-actions bot commented Apr 7, 2025

Lighthouse Report:

  • Performance: 75 / 100
  • Accessibility: 96 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link

github-actions bot commented Apr 7, 2025

Lighthouse Report:

  • Performance: 72 / 100
  • Accessibility: 96 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

@Quiddlee Quiddlee changed the title draft-835-fix: Stale data on the website 835-fix: Stale data on the website Apr 7, 2025
Copy link

github-actions bot commented Apr 7, 2025

Lighthouse Report:

  • Performance: 97 / 100
  • Accessibility: 96 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link

github-actions bot commented Apr 7, 2025

Lighthouse Report:

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

View detailed report

Copy link

github-actions bot commented Apr 7, 2025

Lighthouse Report:

  • Performance: 77 / 100
  • Accessibility: 96 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

@Quiddlee Quiddlee added the bug Something isn't working label Apr 19, 2025
Copy link

Lighthouse Report:

  • Performance: 92 / 100
  • Accessibility: 96 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link

Lighthouse Report:

  • Performance: 70 / 100
  • Accessibility: 96 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link

github-actions bot commented May 8, 2025

Lighthouse Report:

  • Performance: 71 / 100
  • Accessibility: 96 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link

Lighthouse Report:

  • Performance: 82 / 100
  • Accessibility: 96 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link

Lighthouse Report:

  • Performance: 51 / 100
  • Accessibility: 96 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link

Lighthouse Report:

  • Performance: 70 / 100
  • Accessibility: 96 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

@KristiBo KristiBo marked this pull request as ready for review June 2, 2025 08:40
Copy link
Contributor

coderabbitai bot commented Jun 2, 2025

πŸ“ Walkthrough

Walkthrough

This change introduces new React components for rendering course lists, refactors course menu and card rendering to use these components, and enhances stale data handling with mentorship-specific logic in the getActualData helper. Date label rendering is centralized, and stale course filtering is delegated to reusable components, with updates across widgets and UI panels.

Changes

File(s) Change Summary
src/shared/helpers/get-actual-data.ts Extended getActualData with mentorship and sorting options; added mentorship-specific staleness logic.
src/shared/ui/course-menu-items-fresh/, src/shared/ui/fresh-courses/ Added new reusable components for rendering fresh course menus and lists.
src/shared/ui/short-info-panel/course-start-label.tsx Added CourseStartLabel component for date label rendering.
src/shared/ui/short-info-panel/short-info-panel.tsx Switched to using CourseStartLabel for course date display.
src/widgets/courses/ui/course-items-fresh.tsx, src/widgets/mentorship-courses/course-items-fresh.tsx New components for rendering fresh/mentorship course cards.
src/widgets/courses/ui/courses.tsx, src/widgets/mentorship-courses/mentorship-courses.tsx Refactored to use new course items components, removed direct filtering/mapping.
src/widgets/footer/ui/desktop-view.tsx, src/widgets/header/header.tsx, src/widgets/mobile-view/ui/mobile-view.tsx Replaced manual course menu rendering with new menu items component.
src/widgets/hero-course/ui/availability-status.tsx, src/widgets/hero-course/ui/registration-link.tsx Added components for course availability status and registration link.
src/widgets/hero-course/ui/hero-course.tsx, src/widgets/hero-course/ui/hero-course.test.tsx Refactored to use new status/link components; updated tests for date logic.
src/widgets/upcoming-courses/ui/course-items.tsx, src/widgets/upcoming-courses/ui/upcoming-courses.tsx Introduced new course items component; delegated filtering and rendering.

Sequence Diagram(s)

sequenceDiagram
    participant Page as Widget/Page
    participant FreshCourses as FreshCourses
    participant getActualData as getActualData
    participant CourseMenuItemsFresh as CourseMenuItemsFresh

    Page->>FreshCourses: Render with courses, options
    FreshCourses->>getActualData: Filter/sort courses (mentorship, stale, etc.)
    getActualData-->>FreshCourses: Processed courses
    FreshCourses-->>Page: Rendered course nodes

    Page->>CourseMenuItemsFresh: Render with courses
    CourseMenuItemsFresh->>FreshCourses: Render with courses and render prop
    FreshCourses->>getActualData: Filter/sort courses
    getActualData-->>FreshCourses: Processed courses
    FreshCourses-->>CourseMenuItemsFresh: Rendered menu items
    CourseMenuItemsFresh-->>Page: Rendered menu
Loading

Assessment against linked issues

Objective Addressed Explanation
Change date component to be evaluated on the client side (#835) βœ…
Prevent stale courses from being shown (#835) βœ…

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Possibly related PRs

Suggested reviewers

  • andron13
  • dzmitry-varabei
  • ansivgit
  • natanchik
  • Quiddlee
  • SpaNb4

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

πŸ”§ ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-02T08_42_16_682Z-debug-0.log

✨ Finishing Touches
  • πŸ“ Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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 (4)
src/shared/ui/course-menu-items-fresh/course-menu-items-fresh.tsx (1)

8-13: Consider renaming the type for better clarity.

The type name AllCoursesProps doesn't clearly indicate it's for menu items specifically.

-type AllCoursesProps = {
+type CourseMenuItemsFreshProps = {
   courses: Course[];
   icon?: 'iconSmall' | 'iconFooter';
   color?: Color;
   onClose?: () => void;
 };
src/widgets/hero-course/ui/registration-link.tsx (1)

9-14: Rename type to avoid naming conflict.

The type RegistrationLink has the same name as the component, which can cause confusion.

-type RegistrationLink = {
+type RegistrationLinkProps = {
   enrollLink: string | null;
   startDate: string;
   registrationEndDate: string;
   language: Language;
 };

And update the component parameter:

-}: RegistrationLink) => {
+}: RegistrationLinkProps) => {
src/widgets/upcoming-courses/ui/course-items.tsx (1)

15-18: Consider moving empty text outside component.

The emptyText object is recreated on every render. Consider moving it outside the component scope for better performance.

+const emptyText = {
+  part1: `Looks like the course board is empty right now. But don't worry β€” we're cooking up something exciting! Subscribe to our `,
+  part2: ` Announcement channel to be the first to know when fresh courses are served.`,
+};
+
 export const CourseItems = ({ courses }: CourseItems) => {
-  const emptyText = {
-    part1: `Looks like the course board is empty right now. But don't worry β€” we're cooking up something exciting! Subscribe to our `,
-    part2: ` Announcement channel to be the first to know when fresh courses are served.`,
-  };
src/widgets/hero-course/ui/hero-course.test.tsx (1)

1-2: Minor: Consider more specific ESLint disable comment.

The broad import/no-namespace disable could be more targeted to specific imports if only certain namespace imports are needed.

πŸ“œ Review details

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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 8734dfa and 7e24a3c.

πŸ“’ Files selected for processing (20)
  • src/shared/helpers/get-actual-data.ts (2 hunks)
  • src/shared/ui/course-menu-items-fresh/course-menu-items-fresh.tsx (1 hunks)
  • src/shared/ui/course-menu-items-fresh/index.ts (1 hunks)
  • src/shared/ui/fresh-courses/fresh-courses.tsx (1 hunks)
  • src/shared/ui/fresh-courses/index.ts (1 hunks)
  • src/shared/ui/short-info-panel/course-start-label.tsx (1 hunks)
  • src/shared/ui/short-info-panel/short-info-panel.tsx (3 hunks)
  • src/widgets/courses/ui/course-items-fresh.tsx (1 hunks)
  • src/widgets/courses/ui/courses.tsx (2 hunks)
  • src/widgets/footer/ui/desktop-view.tsx (2 hunks)
  • src/widgets/header/header.tsx (2 hunks)
  • src/widgets/hero-course/ui/availability-status.tsx (1 hunks)
  • src/widgets/hero-course/ui/hero-course.test.tsx (5 hunks)
  • src/widgets/hero-course/ui/hero-course.tsx (3 hunks)
  • src/widgets/hero-course/ui/registration-link.tsx (1 hunks)
  • src/widgets/mentorship-courses/course-items-fresh.tsx (1 hunks)
  • src/widgets/mentorship-courses/mentorship-courses.tsx (1 hunks)
  • src/widgets/mobile-view/ui/mobile-view.tsx (2 hunks)
  • src/widgets/upcoming-courses/ui/course-items.tsx (1 hunks)
  • src/widgets/upcoming-courses/ui/upcoming-courses.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (7)
src/widgets/upcoming-courses/ui/upcoming-courses.tsx (1)
Learnt from: Quiddlee
PR: rolling-scopes/site#572
File: src/pages/home.tsx:25-25
Timestamp: 2024-09-30T12:07:39.137Z
Learning: The `Courses` component in `src/widgets/courses/other-courses.test.tsx`, `src/pages/courses.tsx`, and `dev-data/courses-path.data.ts` is a different component from the one replaced in `src/pages/home.tsx`.
src/widgets/footer/ui/desktop-view.tsx (2)
Learnt from: Quiddlee
PR: rolling-scopes/site#659
File: src/core/base-layout/components/footer/desktop-view.tsx:14-22
Timestamp: 2024-12-14T10:58:02.008Z
Learning: In `src/core/base-layout/components/footer/desktop-view.tsx`, the `schoolMenuStaticLinks` array represents a static menu where the order will never change.
Learnt from: Quiddlee
PR: rolling-scopes/site#572
File: src/pages/home.tsx:25-25
Timestamp: 2024-09-30T12:07:39.137Z
Learning: The `Courses` component in `src/widgets/courses/other-courses.test.tsx`, `src/pages/courses.tsx`, and `dev-data/courses-path.data.ts` is a different component from the one replaced in `src/pages/home.tsx`.
src/widgets/header/header.tsx (1)
Learnt from: Quiddlee
PR: rolling-scopes/site#572
File: src/pages/home.tsx:25-25
Timestamp: 2024-09-30T12:07:39.137Z
Learning: The `Courses` component in `src/widgets/courses/other-courses.test.tsx`, `src/pages/courses.tsx`, and `dev-data/courses-path.data.ts` is a different component from the one replaced in `src/pages/home.tsx`.
src/widgets/courses/ui/course-items-fresh.tsx (1)
Learnt from: Quiddlee
PR: rolling-scopes/site#572
File: src/pages/home.tsx:25-25
Timestamp: 2024-09-30T12:07:39.137Z
Learning: The `Courses` component in `src/widgets/courses/other-courses.test.tsx`, `src/pages/courses.tsx`, and `dev-data/courses-path.data.ts` is a different component from the one replaced in `src/pages/home.tsx`.
src/widgets/mentorship-courses/mentorship-courses.tsx (1)
Learnt from: Quiddlee
PR: rolling-scopes/site#572
File: src/pages/home.tsx:25-25
Timestamp: 2024-09-30T12:07:39.137Z
Learning: The `Courses` component in `src/widgets/courses/other-courses.test.tsx`, `src/pages/courses.tsx`, and `dev-data/courses-path.data.ts` is a different component from the one replaced in `src/pages/home.tsx`.
src/widgets/courses/ui/courses.tsx (1)
Learnt from: Quiddlee
PR: rolling-scopes/site#572
File: src/pages/home.tsx:25-25
Timestamp: 2024-09-30T12:07:39.137Z
Learning: The `Courses` component in `src/widgets/courses/other-courses.test.tsx`, `src/pages/courses.tsx`, and `dev-data/courses-path.data.ts` is a different component from the one replaced in `src/pages/home.tsx`.
src/widgets/upcoming-courses/ui/course-items.tsx (1)
Learnt from: Quiddlee
PR: rolling-scopes/site#572
File: src/pages/home.tsx:25-25
Timestamp: 2024-09-30T12:07:39.137Z
Learning: The `Courses` component in `src/widgets/courses/other-courses.test.tsx`, `src/pages/courses.tsx`, and `dev-data/courses-path.data.ts` is a different component from the one replaced in `src/pages/home.tsx`.
🧬 Code Graph Analysis (10)
src/widgets/courses/ui/course-items-fresh.tsx (1)
src/shared/ui/fresh-courses/fresh-courses.tsx (1)
  • FreshCourses (19-38)
src/widgets/mentorship-courses/mentorship-courses.tsx (2)
src/entities/course/model/store.ts (1)
  • courseStore (32-32)
src/widgets/courses/ui/course-items-fresh.tsx (1)
  • CourseItemsFresh (10-18)
src/widgets/hero-course/ui/availability-status.tsx (3)
src/widgets/hero-course/helpers/get-course-status.ts (1)
  • getCourseStatus (7-38)
src/shared/helpers/day-js.ts (1)
  • dayJS (8-8)
src/shared/ui/section-label/section-label.tsx (1)
  • SectionLabel (14-20)
src/widgets/courses/ui/courses.tsx (1)
src/widgets/courses/ui/course-items-fresh.tsx (1)
  • CourseItemsFresh (10-18)
src/shared/ui/short-info-panel/short-info-panel.tsx (2)
src/shared/ui/short-info-panel/course-start-label.tsx (1)
  • CourseStartLabel (16-39)
src/shared/constants.ts (1)
  • LABELS (17-25)
src/shared/ui/short-info-panel/course-start-label.tsx (1)
src/shared/helpers/get-course-date.ts (1)
  • calculateFreshDate (13-18)
src/widgets/hero-course/ui/hero-course.test.tsx (4)
src/shared/helpers/get-course-date.ts (1)
  • getCourseDate (5-11)
src/widgets/hero-course/ui/hero-course.tsx (1)
  • HeroCourse (20-67)
src/shared/__tests__/utils/render-with-router/render-with-router.tsx (1)
  • renderWithRouter (38-49)
src/shared/constants.ts (1)
  • TO_BE_DETERMINED (6-6)
src/widgets/hero-course/ui/registration-link.tsx (3)
src/shared/helpers/get-course-date.ts (1)
  • calculateFreshDate (13-18)
src/shared/constants.ts (1)
  • TO_BE_DETERMINED (6-6)
src/shared/ui/link-custom/link-custom.tsx (1)
  • LinkCustom (45-91)
src/shared/helpers/get-actual-data.ts (3)
src/shared/helpers/day-js.ts (1)
  • dayJS (8-8)
src/shared/helpers/get-course-date.ts (1)
  • getCourseDate (5-11)
src/shared/constants.ts (1)
  • TO_BE_DETERMINED (6-6)
src/widgets/hero-course/ui/hero-course.tsx (2)
src/widgets/hero-course/ui/availability-status.tsx (1)
  • AvailabilityStatus (12-16)
src/widgets/hero-course/ui/registration-link.tsx (1)
  • RegistrationLink (16-37)
πŸ”‡ Additional comments (39)
src/shared/ui/course-menu-items-fresh/index.ts (1)

1-1: Standard export pattern - looks good.

Clean barrel export following TypeScript conventions.

src/shared/ui/fresh-courses/index.ts (1)

1-1: Standard export pattern - looks good.

Clean barrel export following TypeScript conventions.

src/widgets/footer/ui/desktop-view.tsx (2)

3-3: Import added for centralized component.

Good addition supporting the course rendering refactoring.


31-31: Centralized course rendering - excellent refactoring.

Replacing manual mapping with CourseMenuItemsFresh component centralizes course data handling, which should help address the stale data issues mentioned in the PR objectives.

src/widgets/header/header.tsx (2)

10-10: Import added for centralized component.

Good addition supporting the course rendering refactoring.


91-91: Consistent centralized course rendering.

Replacing manual course mapping with CourseMenuItemsFresh follows the same pattern as other components, ensuring consistent course data handling across the application.

src/widgets/mobile-view/ui/mobile-view.tsx (1)

6-6: LGTM! Good refactoring for consistency.

The replacement of inline course mapping with the centralized CourseMenuItemsFresh component improves maintainability and ensures consistent course data handling across the application.

Also applies to: 62-62

src/widgets/courses/ui/course-items-fresh.tsx (1)

1-18: Well-structured wrapper component.

Clean implementation that effectively wraps FreshCourses with sensible defaults. The render prop pattern for CourseCard rendering is appropriate and maintains flexibility.

src/widgets/mentorship-courses/mentorship-courses.tsx (1)

3-3: Effective simplification through delegation.

The refactoring successfully delegates course rendering to the specialized CourseItemsFresh component while maintaining the mentorship-specific functionality. Using courseStore.loadCourses() directly simplifies the data flow.

Also applies to: 5-5, 12-12, 19-19

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

1-16: Clean encapsulation of status logic.

Well-implemented component that correctly calculates course status using the day difference between registration end and start dates. The integration with getCourseStatus helper and SectionLabel rendering is appropriate.

src/widgets/mentorship-courses/course-items-fresh.tsx (1)

1-28: LGTM! Clean wrapper component for mentorship course rendering.

The component properly delegates to FreshCourses with mentorship-specific configuration and correctly shows the mentoring start date for mentorship courses.

src/widgets/courses/ui/courses.tsx (2)

3-5: Good refactoring to centralize course rendering logic.

The import changes properly reflect the delegation of course rendering to the specialized CourseItemsFresh component.


19-19: Proper delegation to CourseItemsFresh component.

The raw courses array is correctly passed to CourseItemsFresh, which will handle filtering stale data and rendering individual course cards.

src/widgets/upcoming-courses/ui/upcoming-courses.tsx (2)

4-7: Clean import refactoring for simplified component structure.

The import changes properly reflect the delegation to the CourseItems component.


22-22:

βœ… Verification successful

Verify CourseItems vs CourseItemsFresh component choice.

The component uses CourseItems while other widgets use CourseItemsFresh. Ensure this difference is intentional and that CourseItems provides the appropriate filtering and rendering logic for upcoming courses.


🏁 Script executed:

#!/bin/bash
# Description: Verify the CourseItems component exists and understand its implementation
# Expected: CourseItems component should handle upcoming course filtering and rendering

# Search for CourseItems component definition
ast-grep --pattern 'export const CourseItems = $_'

# Search for its import and usage
rg -A 5 "CourseItems"

Length of output: 8347


Component choice confirmed: CourseItems is intentional and correct.

CourseItems applies getActualData({ filterStale: true }) and enforces the upcoming‐courses limit, whereas CourseItemsFresh delegates to FreshCourses for general listings. No change needed here.

src/shared/ui/course-menu-items-fresh/course-menu-items-fresh.tsx (1)

15-36: Excellent reusable component for course menu items.

The component properly handles optional props with sensible defaults, uses dynamic icon selection, and delegates to FreshCourses for consistent data handling. This should help ensure stale course data is properly filtered in menu items.

src/shared/ui/short-info-panel/short-info-panel.tsx (3)

8-8: Good refactoring to use specialized component.

Nice addition of the CourseStartLabel import to support the component refactoring.


50-56: Clean delegation to CourseStartLabel component.

The refactoring properly delegates date label rendering to the specialized component with appropriate props.


74-84: Verify conditional registrationEndDate logic.

The upcoming view conditionally passes registrationEndDate only when startDate exists. This could potentially hide registration end dates when start date is missing.

registrationEndDate={startDate ? registrationEndDate : null}

Consider if this behavior is intentional or if registrationEndDate should always be passed when available.

src/widgets/hero-course/ui/registration-link.tsx (2)

22-31: Solid stale course detection logic.

The implementation correctly calculates fresh dates and determines staleness using the TO_BE_DETERMINED constant. The conditional text logic properly handles both disabled states.


32-36: Clean LinkCustom integration.

The component properly passes all necessary props to LinkCustom with appropriate disabled state and styling.

src/shared/ui/fresh-courses/fresh-courses.tsx (2)

11-17: Well-designed component interface.

The props interface is clean and provides good flexibility with optional filtering, sorting, and mentorship modes. The render prop pattern enables reusable course rendering logic.


19-38: Excellent centralization of course filtering logic.

The component properly delegates to getActualData for filtering/sorting and handles mentorship transformation appropriately. This centralizes stale data handling across the application.

src/widgets/upcoming-courses/ui/course-items.tsx (2)

20-38: Solid course filtering and rendering logic.

The implementation properly filters stale courses and limits the display quantity. The destructuring and key assignment in the map function is clean and efficient.


40-60: Excellent empty state handling.

The conditional rendering provides a user-friendly empty state with helpful guidance and a call-to-action link to the Telegram channel.

src/widgets/hero-course/ui/hero-course.test.tsx (4)

9-14: Good addition of test dependencies.

The new imports properly support the enhanced testing approach with date mocking capabilities.


45-56: Test logic enhancement with proper mocking.

The test now properly controls date-dependent behavior by mocking calculateFreshDate. This ensures deterministic test results regardless of when tests run.


80-80: Consistent mock usage for stale date scenarios.

Good use of TO_BE_DETERMINED mock return value to test the "registration will open soon" behavior consistently.

Also applies to: 94-94


23-23:

βœ… Verification successful

Verify mock spy setup correctness.

The mock spy for calculateFreshDate looks correct, but ensure this function exists in the getCourseDate module.


🏁 Script executed:

#!/bin/bash
# Description: Verify calculateFreshDate function exists in get-course-date module
# Expected: Function should be exported from the module

ast-grep --pattern 'export const calculateFreshDate = $_'

Length of output: 564


βœ… Mock Spy Verified for calculateFreshDate
calculateFreshDate is exported from src/shared/helpers/get-course-date.ts, so the vi.spyOn(getCourseDate, 'calculateFreshDate') setup in your test is correct.

src/shared/ui/short-info-panel/course-start-label.tsx (3)

8-14: Well-defined TypeScript interface.

The props interface properly extends PropsWithChildren and includes appropriate nullable types for dates.


24-26: Robust null handling for fresh date calculation.

The component correctly handles cases where either startDate or registrationEndDate might be null, preventing runtime errors.


28-38: Clean component rendering with proper prop delegation.

The component effectively wraps DateSimple with computed values while maintaining flexibility through children and optional props.

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

9-10: Good modular imports for specialized components.

The new imports support the refactored architecture with dedicated components for availability status and registration links.


43-43: Excellent separation of concerns with AvailabilityStatus.

Replacing inline status logic with a dedicated component improves maintainability and reusability.


57-62: Clean delegation to RegistrationLink component.

The registration link rendering is now properly encapsulated in a dedicated component with all necessary props passed through.

src/shared/helpers/get-actual-data.ts (4)

14-15: Well-designed optional parameters with sensible defaults.

The new parameters provide flexibility while maintaining backward compatibility through appropriate default values.


20-26: Clean conditional logic for mentorship and sorting.

The function properly handles the new parameters with clear conditional branches for mentorship mapping and optional sorting.

Also applies to: 29-31, 37-39


64-68: Robust type checking for mentorship data.

The early return for Event data prevents incorrect processing when the function receives non-Course data.


69-95:

βœ… Verification successful

Verify mentorship date field handling logic.

The mentorship mapping logic processes personalMentoringStartDate and personalMentoringEndDate, but ensure these fields exist on the Course type and the staleness calculation is correct.


🏁 Script executed:

#!/bin/bash
# Description: Verify Course type includes personalMentoringStartDate and personalMentoringEndDate fields
# Expected: Course interface should include these optional date fields

ast-grep --pattern 'interface Course {
  $$$
  personalMentoringStartDate$_
  $$$
}'

ast-grep --pattern 'type Course = {
  $$$
  personalMentoringStartDate$_
  $$$
}'

Length of output: 170


🏁 Script executed:

#!/bin/bash
# Locate Course type/interface declarations
rg -n "interface Course"
rg -n "type Course"

# Find any references to the mentoring date fields
rg -n "personalMentoringStartDate"
rg -n "personalMentoringEndDate"

Length of output: 8019


No action needed on mentorship date handling
The Course type in src/entities/course/types.ts does include both personalMentoringStartDate and personalMentoringEndDate as string | null, and the Day.js diff call correctly calculates days between end and start dates. Staleness logic in getCourseDate aligns with expectations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority preview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stale data on the website
5 participants