-
Notifications
You must be signed in to change notification settings - Fork 314
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
fix: Showing by default 2-options added in options adding feature in Admin Dashboard Fixed #1016
base: main
Are you sure you want to change the base?
fix: Showing by default 2-options added in options adding feature in Admin Dashboard Fixed #1016
Conversation
…a new store created
WalkthroughThe update modifies the data processing for options displayed in the table. The component now filters out options with titles "7up" and "Pepsi" from the restaurant's options before applying a reverse operation. Additionally, when data is loading, the component now returns an empty array instead of using dummy data. The import for Changes
Sequence Diagram(s)sequenceDiagram
participant Data as Data Source
participant Comp as Options Component
participant Table as Table Component
Data->>Comp: Provide restaurant options
alt Data Loading
Comp->>Table: Provide empty array
else Data Loaded
Comp->>Comp: Filter out options ("7up", "Pepsi")
Comp->>Comp: Reverse the filtered options array
Comp->>Table: Pass processed options
end
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for cheery-zabaione-34f12e ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for polite-fairy-234917 canceled.
|
There was a problem hiding this 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 (2)
enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/options/view/main/index.tsx (2)
134-137
: Improve the filtering implementation for better maintainability.The filtering logic correctly implements the requirement, but could be enhanced for better maintainability.
Consider these improvements:
- (data?.restaurant?.options || []) - .filter(option => option.title !== '7up' && option.title !== 'Pepsi') // Filter out default options cpming from the backend - .slice() - .reverse()|| [] + const DEFAULT_OPTIONS = ['7up', 'Pepsi']; + (data?.restaurant?.options || []) + .filter(option => !DEFAULT_OPTIONS.includes(option.title?.toLowerCase())) + .reverse() || []Changes:
- Extracted default options into a constant for better maintainability
- Added case-insensitive comparison to prevent issues
- Removed unnecessary
slice()
asreverse()
already creates a new array- Fixed typo in the comment ("cpming" → "coming")
134-137
: Consider implementing the suggested backend fix.While this frontend filtering works, implementing the suggested backend fix would be more robust. This would prevent default options from being created during store setup, reducing unnecessary data transfer and providing a more permanent solution.
Consider:
- Removing the logic that creates default options in the backend when setting up new stores
- Adding a migration script to clean up existing default options from the database
- Making the default options configurable through admin settings if they're still needed for some stores
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
enatega-multivendor-admin/lib/ui/screen-components/protected/restaurant/options/view/main/index.tsx
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Redirect rules - cheery-zabaione-34f12e
- GitHub Check: Header rules - cheery-zabaione-34f12e
- GitHub Check: Pages changed - cheery-zabaione-34f12e
Filtered/Remove the default options of 7up & Pepsi that were coming from backend data so that the options list should be empty by default, allowing the user to add options manually hence fixing [/issues/910]
Potential Backend Recommendation for permanent fix of this issue:
Screenshot of the fix added below: