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

Refactor UI in restaurant detail page #27

Merged
merged 1 commit into from
Jun 5, 2024
Merged

Conversation

cp-dharti-r
Copy link
Collaborator

@cp-dharti-r cp-dharti-r commented Jun 5, 2024

Summary by CodeRabbit

  • Bug Fixes

    • Fixed record deletion to correctly use the id parameter in the AdminsPage.
  • Improvements

    • Updated email subject for invited members to be more concise.
    • Enhanced BottomSheet component to check history state before closing.
    • Improved rendering logic in Reels component based on loading state.
    • Added style customization to MenuDishSkeleton component.
    • Removed unnecessary imports and adjusted styling in restaurant category page.
  • UI Updates

    • Simplified text in the BottomSheet header.
    • Removed the word "dishes" from category and menu names for cleaner display.

Copy link

coderabbitai bot commented Jun 5, 2024

Walkthrough

The recent updates encompass various functional and stylistic adjustments across multiple components and pages. Key changes include modifying the deleteRecord function in the AdminsPage, updating the email subject in InvitedMemberPage, introducing a handleClose function in the BottomSheet component, and altering rendering logic in the Reels component. Additionally, there are minor textual and import adjustments in several pages to improve consistency and user experience.

Changes

Files Change Summary
admin/pages/admins/index.tsx Updated deleteRecord function to use id parameter and modified order method call.
admin/pages/invited-members/add/index.tsx Changed email subject text in InvitedMemberPage component.
website/components/BottomSheet/index.tsx Added handleClose function and updated onClick event for header button.
website/components/Reel/index.tsx Adjusted rendering logic based on loading state and added conditional styles.
website/components/SkeletonPlaceholders/MenuDish.tsx Added style prop to MenuDishSkeleton component.
website/pages/category/restaurant.tsx Removed useAppSelector and swiper/modules imports, adjusted paragraph styling.
website/pages/restaurants/[restaurant]/categories/[category].tsx Removed the word "dishes" from displayed text related to the category name.
website/pages/restaurants/[restaurant]/menus/[menu].tsx Removed the word "dishes" from displayed text related to the menu name in RestaurantMenu component.

Poem

In lines of code, the changes flow,
To make our app a place to grow.
With emails bright and buttons neat,
And menus trimmed, a tasty feat.
The rabbit hops with joyful cheer,
For better code is always near! 🐇✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@cp-dharti-r cp-dharti-r merged commit 59c64cc into main Jun 5, 2024
2 checks passed
Copy link

@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 (9)
website/pages/category/restaurant.tsx (1)

Line range hint 51-134: Add keyboard event handlers to complement the onClick events for better accessibility.

- <div onClick={() => openBottomSheet(item.name, data.dishes)} className="sm:hidden cursor-pointer">
+ <div onClick={() => openBottomSheet(item.name, data.dishes)} onKeyPress={() => openBottomSheet(item.name, data.dishes)} tabIndex="0" className="sm:hidden cursor-pointer">
admin/pages/invited-members/add/index.tsx (1)

Line range hint 126-132: Add alternative text to SVG elements to enhance accessibility.

- <svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg" aria-label="Error Icon">

Also applies to: 215-221

website/pages/restaurants/[restaurant]/menus/[menu].tsx (4)

Line range hint 37-37: Simplify the conditional expression for clarity.

- const [isDishesLoading, setIsDishesLoading] = useState<boolean>(menus ? false : true);
+ const [isDishesLoading, setIsDishesLoading] = useState<boolean>(!!menus);

Line range hint 103-110: Consider using for...of for better performance and readability.

- entries.forEach((entry) => {
+ for (const entry of entries) {
    if (entry.isIntersecting) {
      setNumDivsToRender((prevNumDivs) =>
        Math.min(prevNumDivs + 1, menusData?.length)
      );
    }
- });
+ }

Line range hint 42-42: Remove unnecessary dependencies from useEffect hooks.

- }, [suffix, menuSuffix, menusData, menus, isDishesLoading, menuDishesState]);
+ }, [suffix, menuSuffix, menusData, menus, menuDishesState]);

- }, [carouselRef, numDivsToRender, menusData?.length]);
+ }, [numDivsToRender, menusData?.length]);

Also applies to: 95-95


Line range hint 225-229: Specify the button type to avoid unexpected form submissions.

- <button onClick={goBack} className="...">
+ <button type="button" onClick={goBack} className="...">
admin/pages/admins/index.tsx (3)

Line range hint 98-104: Add alternative text to SVG elements for accessibility.

- <svg ...>
+ <svg ... aria-label="Edit">
- <svg ...>
+ <svg ... aria-label="Delete">
- <svg ...>
+ <svg ... aria-label="Delete">

Also applies to: 167-174, 194-201


Line range hint 62-62: Include all dependencies in useEffect to ensure correct behavior.

- }, [currentPage]);
+ }, [currentPage, fetchAdmins, fetchCountAdmins]);

Line range hint 186-193: Ensure the button type is explicitly defined to prevent form submission.

- <button onClick={() => confirm("Are you sure you want to delete this admin?") ? deleteRecord(admin.id) : ""}>
+ <button type="button" onClick={() => confirm("Are you sure you want to delete this admin?") ? deleteRecord(admin.id) : ""}>
Tools
Biome

[error] 186-193: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 265f285 and cb1ee25.

Files selected for processing (8)
  • admin/pages/admins/index.tsx (3 hunks)
  • admin/pages/invited-members/add/index.tsx (1 hunks)
  • website/components/BottomSheet/index.tsx (1 hunks)
  • website/components/Reel/index.tsx (2 hunks)
  • website/components/SkeletonPlaceholders/MenuDish.tsx (1 hunks)
  • website/pages/category/restaurant.tsx (5 hunks)
  • website/pages/restaurants/[restaurant]/categories/[category].tsx (1 hunks)
  • website/pages/restaurants/[restaurant]/menus/[menu].tsx (1 hunks)
Additional context used
Biome
website/components/BottomSheet/index.tsx

[error] 50-53: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset

website/components/Reel/index.tsx

[error] 50-57: Prefer for...of instead of forEach. (lint/complexity/noForEach)

forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.


[error] 26-26: This hook specifies more dependencies than necessary: dishesData (lint/correctness/useExhaustiveDependencies)

Outer scope values aren't valid dependencies because mutating them doesn't re-render the component.


[error] 38-38: This hook specifies more dependencies than necessary: carouselRef (lint/correctness/useExhaustiveDependencies)

This dependency can be removed from the list.

website/pages/category/restaurant.tsx

[error] 118-123: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event. (lint/a11y/useKeyWithClickEvents)

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

admin/pages/invited-members/add/index.tsx

[error] 75-75: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)

The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.


[error] 126-132: Alternative text title element cannot be empty (lint/a11y/noSvgWithoutTitle)

For accessibility purposes, SVGs should have an alternative text, provided via title element. If the svg element has role="img", you should add the aria-label or aria-labelledby attribute.


[error] 215-221: Alternative text title element cannot be empty (lint/a11y/noSvgWithoutTitle)

For accessibility purposes, SVGs should have an alternative text, provided via title element. If the svg element has role="img", you should add the aria-label or aria-labelledby attribute.

website/pages/restaurants/[restaurant]/categories/[category].tsx

[error] 48-48: Unnecessary use of boolean literals in conditional expression. (lint/complexity/noUselessTernary)

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with


[error] 53-53: This hook does not specify all of its dependencies: categoriesState.filter (lint/correctness/useExhaustiveDependencies)

This dependency is not specified in the hook dependency list.


[error] 53-53: This hook does not specify all of its dependencies: categoriesState.some (lint/correctness/useExhaustiveDependencies)

This dependency is not specified in the hook dependency list.


[error] 53-53: This hook does not specify all of its dependencies: dispatch (lint/correctness/useExhaustiveDependencies)

This dependency is not specified in the hook dependency list.

This dependency is not specified in the hook dependency list.


[error] 53-53: This hook does not specify all of its dependencies: dishesData (lint/correctness/useExhaustiveDependencies)

This dependency is not specified in the hook dependency list.


[error] 53-53: This hook does not specify all of its dependencies: categoriesState.length (lint/correctness/useExhaustiveDependencies)

This dependency is not specified in the hook dependency list.

This dependency is not specified in the hook dependency list.


[error] 53-53: This hook does not specify all of its dependencies: categoryDishesState.filter (lint/correctness/useExhaustiveDependencies)

This dependency is not specified in the hook dependency list.


[error] 207-211: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset

website/pages/restaurants/[restaurant]/menus/[menu].tsx

[error] 37-37: Unnecessary use of boolean literals in conditional expression. (lint/complexity/noUselessTernary)

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with


[error] 103-110: Prefer for...of instead of forEach. (lint/complexity/noForEach)

forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.


[error] 42-42: This hook specifies more dependencies than necessary: isDishesLoading (lint/correctness/useExhaustiveDependencies)

This dependency can be removed from the list.


[error] 95-95: This hook specifies more dependencies than necessary: carouselRef (lint/correctness/useExhaustiveDependencies)

This dependency can be removed from the list.


[error] 225-229: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset

admin/pages/admins/index.tsx

[error] 98-104: Alternative text title element cannot be empty (lint/a11y/noSvgWithoutTitle)

For accessibility purposes, SVGs should have an alternative text, provided via title element. If the svg element has role="img", you should add the aria-label or aria-labelledby attribute.


[error] 167-174: Alternative text title element cannot be empty (lint/a11y/noSvgWithoutTitle)

For accessibility purposes, SVGs should have an alternative text, provided via title element. If the svg element has role="img", you should add the aria-label or aria-labelledby attribute.


[error] 194-201: Alternative text title element cannot be empty (lint/a11y/noSvgWithoutTitle)

For accessibility purposes, SVGs should have an alternative text, provided via title element. If the svg element has role="img", you should add the aria-label or aria-labelledby attribute.


[error] 62-62: This hook does not specify all of its dependencies: fetchAdmins (lint/correctness/useExhaustiveDependencies)

This dependency is not specified in the hook dependency list.


[error] 62-62: This hook does not specify all of its dependencies: fetchCountAdmins (lint/correctness/useExhaustiveDependencies)

This dependency is not specified in the hook dependency list.


[error] 186-193: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset

Additional comments not posted (6)
website/components/SkeletonPlaceholders/MenuDish.tsx (1)

1-1: LGTM! The addition of the style prop enhances the flexibility of the MenuDishSkeleton component.

Also applies to: 5-5

website/components/BottomSheet/index.tsx (1)

34-40: The handleClose function and its integration in the onClick handler are well-implemented, enhancing the component's functionality.

Also applies to: 51-51

website/components/Reel/index.tsx (1)

86-95: The conditional rendering and style adjustments based on the screen height are well-implemented, enhancing the responsiveness of the Reels component.

Also applies to: 118-129

website/pages/category/restaurant.tsx (1)

Line range hint 51-134: The changes in the rendering logic and the removal of unused imports are well-handled, improving the code quality and performance.

admin/pages/invited-members/add/index.tsx (1)

99-99: The simplification of the email subject is a good improvement for clarity.

website/pages/restaurants/[restaurant]/categories/[category].tsx (1)

215-215: The removal of the word "dishes" simplifies the display text, aligning it with the intended changes.

Comment on lines +34 to +40
const handleClose = () => {
if (window.history.state?.bottomSheetOpen) {
window.history.back();
} else {
onClose();
}
};
Copy link

Choose a reason for hiding this comment

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

Ensure to specify the button type to prevent unintended form submissions.

- <button onClick={handleClose} className="...">
+ <button type="button" onClick={handleClose} className="...">

Also applies to: 51-51

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.

Suggested change
const handleClose = () => {
if (window.history.state?.bottomSheetOpen) {
window.history.back();
} else {
onClose();
}
};
const handleClose = () => {
if (window.history.state?.bottomSheetOpen) {
window.history.back();
} else {
onClose();
}
};
// Assuming this is the button element in the component
<button type="button" onClick={handleClose} className="...">

Comment on lines +86 to +95
{isLoading ? (
<MenuDishSkeleton
classes="reel"
style={{
height: screenHeight != 0 ? screenHeight + "px" : "100vh",
}}
/>
) : (
""
)}
Copy link

Choose a reason for hiding this comment

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

Optimize the iteration by replacing forEach with for...of for better performance.

- entries.forEach((entry) => {
+ for (const entry of entries) {

Also applies to: 118-129

Committable suggestion was skipped due to low confidence.

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.

1 participant