Skip to content

added admin controllerwhere admin can delete user id#99

Open
Dynamic-Aryan wants to merge 8 commits intoalvarotorrestx:devfrom
Dynamic-Aryan:adminpart
Open

added admin controllerwhere admin can delete user id#99
Dynamic-Aryan wants to merge 8 commits intoalvarotorrestx:devfrom
Dynamic-Aryan:adminpart

Conversation

@Dynamic-Aryan
Copy link

Here as i created one path for admin and owner ,like where this both can delete the existing user by their ID ,,this is how ,,when the admin or owner will login to website , their in navbar their are 5 components for them ,,the 5th one is likely for them ,from where they will navigate to page and can delete the user , furthermore new changes will be added to it ,Thank you!!

Copy link
Owner

@alvarotorrestx alvarotorrestx left a comment

Choose a reason for hiding this comment

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

Overall, great job.

I can see where you are going with this and it's going well!

Further feedback to where I can't comment on in the actual code:

  • I can access the adminpage as a normal user by going to /adminpage
  • This needs to be resolved in the backend

I know you said there's more features to come so I'm excited to see where that goes! Can't wait to see it.

Please let me know if you need help in the Discord channel! 😄

import { HiNewspaper } from "react-icons/hi2";
import { IoMdPeople } from "react-icons/io";
import { GiSuitcase } from "react-icons/gi";
import { GiAbstract021, GiSuitcase } from "react-icons/gi";
Copy link
Owner

Choose a reason for hiding this comment

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

Not the biggest fan of the Icon, but not a priority. Perhaps a config, controller, debug or something similar icon might suffice.

Comment on lines +16 to +17
import useAuth from "../../../auth/useAuth";
import { axiosPrivate } from "../../../api/axios";
Copy link
Owner

Choose a reason for hiding this comment

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

Layout.jsx is already sharing auth with the NavBar, passing as a prop.

This would be redundant code.

Comment on lines +28 to +42
useEffect(() => {
const fetchUsers = async () => {
setLoading(true);
try {
const response = await axiosPrivate.get("/api/users", {
headers: {
Authorization: `Bearer ${auth?.accessToken}`,
},
});
setUsers(response.data);
} catch (err) {
console.log(err);
} finally {
setLoading(false);
}
Copy link
Owner

Choose a reason for hiding this comment

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

Although, I do see why you did this, but I would prefer for this to be a separate call inside your admin page as you did. Not needed to be ran within the navbar.

Comment on lines +111 to +118
{(auth?.role === "admin" || auth?.role === "user") && (
<li>
<NavLink to="/adminpage" className="flex items-center">
<span className="text-2xl text-primary">
<GiSuitcase />
</span>
Adminarea
</NavLink>
Copy link
Owner

Choose a reason for hiding this comment

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

role of "user" should not be able to access this page

Also the icon isn't matching the desktop one.

Comment on lines +136 to +141
<button
onClick={() => setShowModal(false)}
className="px-4 py-2 bg-gray-200 rounded hover:bg-gray-300"
>
Cancel
</button>
Copy link
Owner

Choose a reason for hiding this comment

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

Button is hard to read in dark theme

@Dynamic-Aryan
Copy link
Author

Did all changes as per your requirement ,,please check again and sorry for this small mistakes which i made ,,but i resolved those all,, latest pr is raised, please check it ,,and still working on new things to be added ,,and resolve the current issues

Copy link
Owner

@alvarotorrestx alvarotorrestx left a comment

Choose a reason for hiding this comment

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

Will talk to you on Discord to realign

import Network from './assets/components/network/Network';
import Adminpage from './assets/components/Admin/Adminpage';
import Usersprofile from './assets/components/Admin/Usersprofile';
import EditUsersprofile from './assets/components/Admin/EditUsersprofile';
Copy link
Owner

Choose a reason for hiding this comment

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

This is redundant as well, the EditProfile page currently knows when the User or an Admin/Owner roles are viewing and will allow changes to happen. This seems to be a duplicate of Edit Profile and does not need to be added.

Furthermore, EditProfile is also being redesigned by another contribute in issue #86

Please remove this.

Comment on lines +79 to +81
<Route path="/admin/profile/:username" element={<ProfileProvider />} >
<Route index element={<Usersprofile />} />
<Route path="editbyadmin" element={<EditUsersprofile/>}/>
Copy link
Owner

Choose a reason for hiding this comment

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

See above comment

Copy link
Owner

Choose a reason for hiding this comment

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

Can be removed as mentioned earlier

Copy link
Owner

Choose a reason for hiding this comment

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

Can be removed as mentioned earlier

Copy link
Owner

Choose a reason for hiding this comment

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

Can be removed as mentioned earlier

@alvarotorrestx
Copy link
Owner

@Dynamic-Aryan Great work on this! It's come out really well and you've followed requests persistently. Thanks so much for this.

Keep continuing to work on this.

Keep making the theme match accordingly. I love the role colors, and a lot of the input fields, etc.

Just keep working on matching and as well add more logic.

Ensure certain roles can only edit other certain roles such as:
Owner can edit admin, moderator and user
Admin can edit moderator and user - but not other admins

Keep coming up with features for this.

Great work! 😀

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.

3 participants