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]: handle February (28/29 days) in calendar and integrate task label translations, update button logic #3397

Merged
merged 1 commit into from
Dec 8, 2024

Conversation

Innocent-Akim
Copy link
Contributor

@Innocent-Akim Innocent-Akim commented Dec 5, 2024

Description

Please include a summary of the changes and the related issue.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Previous screenshots

Please add here videos or images of previous status

Current screenshots

Please add here videos or images of previous status

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced localization support for the calendar and task management components, allowing for dynamic translations of status labels and navigation buttons.
    • Added new task status labels in multiple languages, improving clarity in task management.
  • Bug Fixes

    • Minor adjustments to UI elements for better visual presentation, including text sizes and element heights.
  • Documentation

    • Updated localization files in various languages to include new task statuses and refine user prompts.

@Innocent-Akim Innocent-Akim self-assigned this Dec 5, 2024
Copy link
Contributor

coderabbitai bot commented Dec 5, 2024

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.

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

Oops! Something went wrong! :(

ESLint: 8.46.0

ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.

The config "next/core-web-vitals" was referenced from the config file in "/apps/web/.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

Walkthrough

The changes in this pull request primarily enhance the localization capabilities of the timesheet-related components within the application. Key modifications include the addition of a translation property t across several components such as CalendarView, MonthlyCalendarDataView, and WeeklyCalendarDataView. Additionally, various localization JSON files have been updated to include new keys for task statuses, improving the user interface for task management. Minor visual adjustments have also been made to improve the overall presentation of the components.

Changes

File Path Change Summary
apps/web/app/[locale]/timesheet/[memberId]/components/CalendarView.tsx Added t: TranslationHooks to BaseCalendarDataViewProps; integrated useTranslations hook in CalendarView.
apps/web/app/[locale]/timesheet/[memberId]/components/FilterWithStatus.tsx Added import for useTranslations; updated buttonData to use translation keys instead of hardcoded strings.
apps/web/app/[locale]/timesheet/[memberId]/components/MonthlyTimesheetCalendar.tsx Updated MonthlyCalendarDataViewProps to include t; modified month-end logic for leap years; updated button labels for navigation.
apps/web/app/[locale]/timesheet/[memberId]/components/TimeSheetFilterPopover.tsx Replaced clsxm utility with cn for class name management.
apps/web/app/[locale]/timesheet/[memberId]/components/TimesheetCard.tsx Replaced clsxm with cn for class name management across components.
apps/web/app/[locale]/timesheet/[memberId]/components/WeeklyTimesheetCalendar.tsx Added t: TranslationHooks to WeeklyCalendarProps; updated button labels for week navigation to use translations.
apps/web/locales/ar.json Added new keys for task statuses; minor adjustment to existing key.
apps/web/locales/bg.json Added new keys for task statuses; minor adjustment to existing key.
apps/web/locales/de.json Added new keys for task statuses; minor adjustment to existing key.
apps/web/locales/en.json Added new keys for task statuses; minor adjustment to existing key.
apps/web/locales/es.json Added new keys for task statuses; minor adjustment to existing key.
apps/web/locales/fr.json Added new keys for task statuses; existing key retained.
apps/web/locales/he.json Added new keys for task statuses; modified existing key for consistency.
apps/web/locales/it.json Added new keys for task statuses; modified existing key for consistency.
apps/web/locales/nl.json Added new keys for task statuses; modified existing key for punctuation.
apps/web/locales/pl.json Added new keys for task statuses; existing key retained.
apps/web/locales/pt.json Added new keys for task statuses; modified existing key for punctuation.
apps/web/locales/ru.json Added new keys for task statuses; modified existing key for formatting.
apps/web/locales/zh.json Added new keys for task statuses; minor adjustment to existing key.

Possibly related PRs

Suggested labels

WEB, feature, Timesheets

Suggested reviewers

  • evereq
  • Cedric921

🐇 In the calendar, we hop and play,
With translations brightening the day.
Task statuses clear, in every tongue,
A joyful tune, our praises sung!
From English to French, we share the cheer,
Localization magic, let’s give a cheer! 🎉


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

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (Invoked using PR comments)

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

Other keywords and placeholders

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

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Innocent-Akim Innocent-Akim changed the title [Feat]: handle February (28/29 days) in calendar [Feat]: handle February (28/29 days) in calendar and integrate task label translations, update button logic Dec 5, 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: 2

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

Line range hint 45-54: Remove duplicate text-sm class

The button's className contains a duplicate text-sm class which should be removed for cleaner code.

 className={cn(
     'h-9 px-3 py-2',
     'border border-gray-200 ',
-    'text-[#282048] text-sm',
+    'text-[#282048]',
     'flex items-center',
     'hover:bg-gray-50 hover:dark:bg-primary-light/40 focus:ring-2 focus:ring-offset-2 focus:ring-gray-200 dark:border-gray-600'
 )}

156-157: Fix duplicate text-sm class in TaskNameInfoDisplay

The taskTitleClassName contains a duplicate text-sm class.

 taskTitleClassName={cn(
-    'text-sm !text-ellipsis !overflow-hidden text-sm'
+    'text-sm !text-ellipsis !overflow-hidden'
 )}

Line range hint 82-182: Consider adding error handling and performance optimizations

A few suggestions to improve the component:

  1. Add error handling for cases where data is undefined or network requests fail
  2. Consider memoizing the filtered and transformed data using useMemo to optimize performance, especially for large datasets
  3. Consider memoizing the callback functions using useCallback to prevent unnecessary re-renders

Example implementation:

const TimesheetCardDetail = ({ data }: { data?: Record<TimesheetStatus, TimesheetLog[]> }) => {
    const { getStatusTimesheet, groupByDate } = useTimesheet({});
    const { timesheetGroupByDays } = useTimelogFilterOptions();
    const t = useTranslations();

    // Memoize transformed data
    const timesheetGroupByDate = useMemo(() => 
        groupByDate(data?.PENDING || []),
        [data?.PENDING, groupByDate]
    );

    // Add error handling
    if (!data) {
        return <div className="text-red-500">{t('common.ERROR_LOADING_DATA')}</div>;
    }

    // Rest of the component...
};
apps/web/app/[locale]/timesheet/[memberId]/components/CalendarView.tsx (1)

190-200: Consider removing CSS important flags

While the height and text size adjustments are valid, the use of !important flags (!h-[16px], !text-[13px]) suggests potential CSS specificity issues. Consider restructuring the CSS to avoid specificity conflicts.

Consider using more specific selectors or adjusting the CSS hierarchy instead:

-'flex flex-row-reverse justify-end items-center w-full !h-[16px] rounded-sm gap-x-2 hover:no-underline'
+'flex flex-row-reverse justify-end items-center w-full h-[16px] rounded-sm gap-x-2 hover:no-underline'

-'text-base font-normal text-gray-400 uppercase !text-[13px]'
+'text-base font-normal text-gray-400 uppercase text-[13px]'
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 88fc30c and f2f6f3b.

📒 Files selected for processing (19)
  • apps/web/app/[locale]/timesheet/[memberId]/components/CalendarView.tsx (6 hunks)
  • apps/web/app/[locale]/timesheet/[memberId]/components/FilterWithStatus.tsx (3 hunks)
  • apps/web/app/[locale]/timesheet/[memberId]/components/MonthlyTimesheetCalendar.tsx (5 hunks)
  • apps/web/app/[locale]/timesheet/[memberId]/components/TimeSheetFilterPopover.tsx (5 hunks)
  • apps/web/app/[locale]/timesheet/[memberId]/components/TimesheetCard.tsx (6 hunks)
  • apps/web/app/[locale]/timesheet/[memberId]/components/WeeklyTimesheetCalendar.tsx (4 hunks)
  • apps/web/locales/ar.json (1 hunks)
  • apps/web/locales/bg.json (1 hunks)
  • apps/web/locales/de.json (1 hunks)
  • apps/web/locales/en.json (1 hunks)
  • apps/web/locales/es.json (1 hunks)
  • apps/web/locales/fr.json (1 hunks)
  • apps/web/locales/he.json (1 hunks)
  • apps/web/locales/it.json (1 hunks)
  • apps/web/locales/nl.json (1 hunks)
  • apps/web/locales/pl.json (1 hunks)
  • apps/web/locales/pt.json (1 hunks)
  • apps/web/locales/ru.json (1 hunks)
  • apps/web/locales/zh.json (1 hunks)
👮 Files not reviewed due to content moderation or server errors (1)
  • apps/web/locales/ru.json
🧰 Additional context used
📓 Learnings (1)
apps/web/locales/es.json (1)
Learnt from: CREDO23
PR: ever-co/ever-teams#3309
File: apps/web/locales/es.json:335-337
Timestamp: 2024-11-12T14:06:02.202Z
Learning: When reviewing additions of new translation keys in `apps/web/locales/`, ensure to verify whether the keys have been added to all relevant locale files before suggesting they are missing.
🔇 Additional comments (18)
apps/web/app/[locale]/timesheet/[memberId]/components/TimesheetCard.tsx (2)

14-14: LGTM: Import of cn utility

The addition of the cn utility import aligns with the codebase's standardization of class name management.


Line range hint 62-68: LGTM: Icon container styling

The class names are well-structured and the accessibility attribute is properly implemented.

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

Line range hint 1-168: File changes don't align with PR objectives.

This file contains styling and translation-related changes but lacks any implementation for handling February's 28/29 days in the calendar. Consider:

  1. Are there other files that implement the calendar-related changes?
  2. Was this file included in the PR accidentally?
  3. Should the PR description be updated to reflect these additional changes?

Let's check for calendar-related files that might contain the actual February handling changes:

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

6-6: LGTM: Translation integration looks good

The useTranslations hook is properly imported and initialized.

Also applies to: 21-21

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

8-8: LGTM: Translation integration is properly implemented

The translation hook is correctly typed and navigation buttons are properly localized.

Also applies to: 11-11, 67-67, 80-80

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

31-38: LGTM: February handling logic is robust

The implementation correctly:

  • Handles February's varying days (28/29)
  • Uses isLeapYear for accurate leap year detection
  • Falls back to standard endOfMonth for other months

8-8: LGTM: Translation integration matches weekly view

The translation implementation is consistent with WeeklyTimesheetCalendar.

Also applies to: 11-11, 73-73, 82-82

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

15-15: LGTM: Translation hook properly typed

The addition of the translation hook to the interface is well-structured and follows TypeScript best practices.


39-43: LGTM: Consistent translation prop passing

The translation hook is properly obtained and passed down to child components, ensuring consistent internationalization throughout the calendar views.

apps/web/locales/zh.json (1)

636-642: LGTM: Comprehensive status translations added

The new translation keys for timesheet statuses are well-structured and provide complete coverage for all task states.

apps/web/locales/he.json (1)

636-642: LGTM: Consistent translations across languages

The Hebrew translations for timesheet statuses maintain consistency with other language files while providing proper localization.

apps/web/locales/en.json (1)

636-642: LGTM: Consistent with Arabic translations

The English translations are properly aligned with the Arabic translations.

apps/web/locales/nl.json (2)

636-642: LGTM: Consistent with other language translations

The Dutch translations are properly aligned with other language translations.


Line range hint 1-1: Verify missing calendar-related changes

Let's search for calendar-related files that might need updates for handling February days.

apps/web/locales/pl.json (1)

636-642: Same inconsistency as in bg.json

These changes mirror those in bg.json and are similarly unrelated to the PR's objective.

apps/web/locales/it.json (1)

636-642: Same inconsistency as in bg.json and pl.json

These changes mirror those in bg.json and pl.json and are similarly unrelated to the PR's objective.

apps/web/locales/pt.json (1)

637-643: LGTM! Translations are consistent

The Portuguese translations for timesheet statuses have been properly added and are consistent with other locale files.

apps/web/locales/es.json (1)

636-642: LGTM! Translations are consistent

The Spanish translations for timesheet statuses have been properly added and are consistent with other locale files.

@Innocent-Akim Innocent-Akim requested a review from evereq December 8, 2024 10:23
@evereq evereq merged commit b8bbf86 into develop Dec 8, 2024
13 checks passed
@evereq evereq deleted the feat/integrate-translations-with-buttons branch December 8, 2024 17:25
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