Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR refactors the user UI to work with groups containing nested categories instead of flat group categories. The main changes include updating the data structure in the store, adding a new API endpoint, and enhancing the navigation menu with dropdown functionality for categories.
- Replaces
groupCategorieswith hierarchicalgroupsstructure containing nested categories - Adds dropdown menu to display categories under each group
- Updates footer copyright year to be dynamic
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/stores/user-store/UserStore.js | Adds groups state and getAllGroups method to fetch hierarchical group data with categories |
| src/services/userServices/groupServices.js | Implements getAllGroups API method to fetch all groups from /user/group endpoint |
| src/layouts/app-layouts/user-layouts/HeaderNav/GroupCategoryMenu.jsx | Refactors component to display groups with dropdown menus for nested categories using hover interactions |
| src/layouts/app-layouts/user-layouts/FooterNav.jsx | Updates copyright year to dynamically use current year with useMemo |
| src/components/PopularPost/Popular.jsx | Removes unnecessary React fragment wrapper |
| google6ea4f563230cd745.html | Adds Google site verification file |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| useEffect(() => { | ||
| getGroupCategories(); | ||
| getAllGroups(); | ||
| }, []); |
There was a problem hiding this comment.
The useEffect hook is missing getAllGroups in its dependency array. This violates the React Hook rules and could lead to stale closures or unexpected behavior if the function reference changes.
Add getAllGroups to the dependency array:
useEffect(() => {
getAllGroups();
}, [getAllGroups]);| }, []); | |
| }, [getAllGroups]); |
| set({ groups: response }); | ||
| } catch (error) { | ||
| console.log(error); | ||
| } |
There was a problem hiding this comment.
The getAllGroups method does not return a value when an error occurs, which could lead to the store state being set to undefined. Consider returning an empty array or rethrowing the error for proper error handling.
getAllGroups: async () => {
try {
const response = await groupServices.getAllGroups();
set({ groups: response });
} catch (error) {
console.log(error);
set({ groups: [] }); // Set to empty array on error
}
},| } | |
| set({ groups: [] }); // Set to empty array on error |
| const data = response.data; | ||
| return data; | ||
| } catch (error) { | ||
| console.log(error); |
There was a problem hiding this comment.
The getAllGroups method does not return a value when an error occurs. This could result in undefined being returned to the caller. Consider returning an empty array or a default value for consistent error handling.
static async getAllGroups() {
try {
const response = await axiosInstance.get(`/user/group`);
const data = response.data;
return data;
} catch (error) {
console.log(error);
return []; // Return empty array on error
}
}| console.log(error); | |
| console.log(error); | |
| return []; |
| {hasCategories && openDropdown === group?.id && ( | ||
| <div className="absolute top-full left-0 w-full bg-white shadow-lg rounded-md py-2 z-50 border border-gray-200"> | ||
| {group.categories.map((category) => ( | ||
| <Link | ||
| key={category?.id} | ||
| to={`/category/${category?.slug}`} | ||
| className="block text-black hover:bg-gray-100 hover:text-orange-400 transition-all" | ||
| > | ||
| {category?.name} | ||
| </Link> | ||
| ))} | ||
| </div> | ||
| )} |
There was a problem hiding this comment.
The dropdown menu lacks keyboard navigation support and proper accessibility attributes. Users navigating with keyboards cannot access the category dropdown menu.
Consider adding:
role="navigation"to the menu containeraria-labelfor screen readers- Keyboard event handlers (onKeyDown) to allow opening/closing with Enter/Escape
tabIndexattributes for keyboard focus management
| {val?.name} | ||
| <Flex justify="center" align="center" gap="small"> | ||
| <span>{group?.name}</span> | ||
| {hasCategories && <DownOutlined style={{ fontSize: '10px' }} />} |
There was a problem hiding this comment.
[nitpick] The dropdown menu uses inline styles for the font size which is inconsistent with the Tailwind CSS classes used elsewhere in the component. Consider using Tailwind's text-xs class instead of inline styles for consistency.
{hasCategories && <DownOutlined className="text-xs" />}| {hasCategories && <DownOutlined style={{ fontSize: '10px' }} />} | |
| {hasCategories && <DownOutlined className="text-xs" />} |
| <Link | ||
| key={category?.id} | ||
| to={`/category/${category?.slug}`} | ||
| className="block text-black hover:bg-gray-100 hover:text-orange-400 transition-all" |
There was a problem hiding this comment.
The dropdown category links are missing padding, which could make them difficult to click and inconsistent with the parent link styling.
Add padding to match the parent link:
<Link
key={category?.id}
to={`/category/${category?.slug}`}
className="block px-4 py-2 text-black hover:bg-gray-100 hover:text-orange-400 transition-all"
>
{category?.name}
</Link>| className="block text-black hover:bg-gray-100 hover:text-orange-400 transition-all" | |
| className="block px-4 py-2 text-black hover:bg-gray-100 hover:text-orange-400 transition-all" |
e9196d7 to
d0009e9
Compare
No description provided.