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]: Set Working Hours #3501

Merged
merged 4 commits into from
Jan 10, 2025
Merged

[Feat]: Set Working Hours #3501

merged 4 commits into from
Jan 10, 2025

Conversation

Innocent-Akim
Copy link
Contributor

@Innocent-Akim Innocent-Akim commented Jan 9, 2025

Description

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

    • Added a new "Working Hours" section in personal settings
    • Introduced a customizable work schedule with timezone support
    • Implemented a new time picker component for precise time selection
  • Improvements

    • Enhanced timesheet view with conditional rendering of selected timesheets
    • Updated settings navigation to include working hours option
  • UI Updates

    • Added toggle functionality for workdays
    • Improved component styling and interaction

@Innocent-Akim Innocent-Akim self-assigned this Jan 9, 2025
Copy link
Contributor

coderabbitai bot commented Jan 9, 2025

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]/settings/personal/page.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

This pull request introduces a comprehensive working hours feature for the Ever Teams platform. The changes span multiple files to implement a new WorkingHours component that allows users to customize their work schedule. The implementation includes a time picker, timezone selection, and the ability to enable or disable work hours for different days of the week. The feature is integrated into the personal settings page and includes supporting components and hooks to manage the new functionality.

Changes

File Change Summary
apps/web/app/[locale]/settings/personal/page.tsx Added WorkingHours component to the personal settings page
apps/web/app/[locale]/timesheet/[memberId]/page.tsx Modified CalendarView rendering with conditional SelectedTimesheet display
apps/web/app/hooks/useLeftSettingData.ts Added new entry for 'Working hours' in PersonalAccordianData
apps/web/components/ui/time-picker.tsx New TimePicker component for time selection
apps/web/lib/components/toggler.tsx Minor styling adjustments to button class names
apps/web/lib/settings/working-hours.tsx New WorkingHours component with work schedule management

Possibly related issues

  • [Feature] Setting | Set Working Hours #3171: Directly addresses the "Set Working Hours" feature request, providing a comprehensive implementation of the user story to set daily work hours with detailed customization options.

Possibly related PRs

Suggested labels

feature, WEB, Improvement, Timesheets, Ever Teams

Suggested reviewers

  • evereq

Poem

🐰 A rabbit's tale of working hours so bright,
Ticking clocks and schedules set just right,
Timezone dancing, minutes in a row,
Flexibility blooms where work hours grow!
Time to hop into productivity's embrace! 🕰️

Finishing Touches

  • 📝 Generate Docstrings

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.

@Innocent-Akim Innocent-Akim linked an issue Jan 9, 2025 that may be closed by this pull request
Copy link

Report too large to display inline

View full report↗︎

Copy link

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSourceCI
Critical CVE npm/@babel/[email protected] ⚠︎

View full report↗︎

Next steps

What is a critical CVE?

Contains a Critical Common Vulnerability and Exposure (CVE).

Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/[email protected] or ignore all packages with @SocketSecurity ignore-all

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

🧹 Nitpick comments (4)
apps/web/components/ui/time-picker.tsx (2)

11-21: Optimize time options generation

The generateTimeOptions function is called on every render. Consider memoizing the result or moving it outside the component.

+const TIME_OPTIONS = generateTimeOptions();
+
 export const TimePicker: React.FC<TimePickerProps> = ({ value, onChange, disabled }) => {
     const [inputValue, setInputValue] = useState(value);
     const [isEditing, setIsEditing] = useState(false);
-    const timeOptions = generateTimeOptions();

5-9: Add error handling to props interface

The component lacks error state handling. Consider adding error-related props to handle and display validation errors.

 interface TimePickerProps {
     value: string;
     onChange: (value: string) => void;
     disabled?: boolean;
+    error?: boolean;
+    errorMessage?: string;
 }
apps/web/lib/settings/working-hours.tsx (1)

155-159: Move inline styles to CSS classes

The ToggleSwitch component uses inline styles. Consider moving these to CSS classes for better maintainability.

 <div
-    className={`w-14 h-6 flex items-center rounded-full p-1 cursor-pointer transition-colors`}
+    className={`w-14 h-6 flex items-center rounded-full p-1 cursor-pointer transition-colors ${
+        enabled ? 'bg-success-light' : 'bg-danger-gradient'
+    }`}
     onClick={onToggle}
-    style={
-        enabled
-            ? { background: '#2ead805b' }
-            : { background: 'linear-gradient(to right, #ea31244d, #ea312479)' }
-    }>
apps/web/app/[locale]/timesheet/[memberId]/page.tsx (1)

270-288: LGTM! Consider memoizing the data prop calculation.

The conditional rendering logic and component composition look good. The SelectedTimesheet component is properly shown only when timesheets are selected.

Consider memoizing the data prop calculation to prevent unnecessary recalculations:

+const calendarData = useMemo(() => 
+  shouldRenderPagination ? paginatedGroups : filterDataTimesheet,
+  [shouldRenderPagination, paginatedGroups, filterDataTimesheet]
+);

<CalendarView
  user={user}
-  data={shouldRenderPagination ? paginatedGroups : filterDataTimesheet}
+  data={calendarData}
  loading={loadingTimesheet}
/>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2da1192 and 04fe54f.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (6)
  • apps/web/app/[locale]/settings/personal/page.tsx (2 hunks)
  • apps/web/app/[locale]/timesheet/[memberId]/page.tsx (2 hunks)
  • apps/web/app/hooks/useLeftSettingData.ts (1 hunks)
  • apps/web/components/ui/time-picker.tsx (1 hunks)
  • apps/web/lib/components/toggler.tsx (7 hunks)
  • apps/web/lib/settings/working-hours.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/web/lib/components/toggler.tsx
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: deploy
  • GitHub Check: deploy
🔇 Additional comments (2)
apps/web/lib/settings/working-hours.tsx (1)

31-39: 🛠️ Refactor suggestion

Add form submission handling

The component uses useForm but doesn't implement form submission. Consider adding a submit handler to save the working hours configuration.

 export const WorkingHours: React.FC<WorkScheduleProps> = ({ initialSchedule }) => {
     const [currentTimezone, setCurrentTimezone] = React.useState('');
     const [user] = useAtom(userState);
 
-    const { setValue } = useForm();
+    const { setValue, handleSubmit } = useForm();
     const [schedule, setSchedule] = React.useState<WorkDay[]>(
         initialSchedule || defaultWorkDays
     );
+
+    const onSubmit = async (data: any) => {
+        // TODO: Implement save functionality
+    };
apps/web/app/[locale]/timesheet/[memberId]/page.tsx (1)

305-305: Formatting change

apps/web/app/hooks/useLeftSettingData.ts Show resolved Hide resolved
apps/web/components/ui/time-picker.tsx Show resolved Hide resolved
apps/web/components/ui/time-picker.tsx Show resolved Hide resolved
apps/web/lib/settings/working-hours.tsx Show resolved Hide resolved
apps/web/lib/settings/working-hours.tsx Show resolved Hide resolved
apps/web/lib/settings/working-hours.tsx Show resolved Hide resolved
@Innocent-Akim Innocent-Akim requested a review from evereq January 9, 2025 18:33
@evereq evereq merged commit eb05f70 into develop Jan 10, 2025
14 checks passed
@evereq evereq deleted the feat/set-working-hours branch January 10, 2025 07:23
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