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-#178: added admin UI to frontend #369

Merged

Conversation

devsharmagit
Copy link
Contributor

@devsharmagit devsharmagit commented May 28, 2024

Summary

Added admin UI to frontend

Description

This PR adds all the admin functionality and UI to the frontend.
Checkout by logging in as admin.
/admin/user and /admin/blog route is implemented correctly.
A button in the header layout is also added to navigate to the admin dash board.

2024-06-13.08-50-00.mp4

Issue(s) Addressed

Closes #178

Prerequisites

Copy link

vercel bot commented May 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
wanderlust ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 17, 2024 6:31am
wanderlust-backend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 17, 2024 6:31am

Copy link

Hey @devsharmagit! Thanks for sticking to the guidelines! High five! 🙌🏻

@krishnaacharyaa
Copy link
Owner

@devsharmagit can you kindly rebase to upstream's main

1 similar comment
@krishnaacharyaa
Copy link
Owner

@devsharmagit can you kindly rebase to upstream's main

@krishnaacharyaa
Copy link
Owner

@devsharmagit kindly finish this

@devsharmagit
Copy link
Contributor Author

@krishnaacharyaa
I am back to normal. I will commit the changes today night.

Copy link
Owner

@krishnaacharyaa krishnaacharyaa left a comment

Choose a reason for hiding this comment

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

Please just have a video in PR description showcasing the functionality

_id: string;
fullName: string;
role: 'ADMIN' | 'USER';
email: string;
Copy link
Owner

Choose a reason for hiding this comment

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

This guy shouldn't he use the enum defined below?

Can you kindly replace all the interface to types

</p>
</div>
{user.role === 'ADMIN' && (
<button
Copy link
Owner

Choose a reason for hiding this comment

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

Use enum instead, kindly replace all the places this is used to use enum

Copy link

Hey @devsharmagit! Thanks for sticking to the guidelines! High five! 🙌🏻

Copy link
Owner

@krishnaacharyaa krishnaacharyaa left a comment

Choose a reason for hiding this comment

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

  1. The enum role as far as I know, he is been used everywhere, Can we lift it up
    And the User type isn't it already defined? I feel it should go to its proper types folder,
    Because it is not specific to only admin-users right?

  2. And we need to call the clean redis function as well, when ever any post is deleted or edited.

  3. I guess editing is not functional, if it is not create an issue so that someone else can work on this, so that we don't miss.

I can get this in, if you can raise another PR for the refactoring (1)
We need (2) changes and (3) to get this in, meaning merge, (1) we can take it seperately

cc: @devsharmagit
Thank you for all the support :)

@devsharmagit
Copy link
Contributor Author

@krishnaacharyaa
I have never used Redis. I will first go through some resources on YouTube to understand.
I will commit the required changes tomorrow (Saturday).

I will raise an issue related to editing the place and eventually work on it and complete it.
I will also raise the issue of refactoring the code as mentioned in 1.

@krishnaacharyaa
Copy link
Owner

I have never used Redis. I will first go through some resources on YouTube to understand.

Just use the existing util function @devsharmagit to clean up the redis

@devsharmagit
Copy link
Contributor Author

@krishnaacharyaa
i will use it and push the changes in few hours.

apart from that everything is fine from your side?

@devsharmagit
Copy link
Contributor Author

image
is this the function that i need to call?

and what is the argument that i need to pass?

@krishnaacharyaa

@krishnaacharyaa
Copy link
Owner

image is this the function that i need to call?

and what is the argument that i need to pass?

@krishnaacharyaa

Yes. Figure out from other places it is being used
@devsharmagit

@devsharmagit
Copy link
Contributor Author

okay @krishnaacharyaa !

@devsharmagit
Copy link
Contributor Author

@krishnaacharyaa
I have pushed the code.

@krishnaacharyaa
Copy link
Owner

@devsharmagit kindly raise 1 and 3 and comment here, so that i close this

res.status(HTTP_STATUS.OK).json(updatedPost);
// invalidate the redis cache
await deleteDataFromCache(REDIS_KEYS.ALL_POSTS),
await deleteDataFromCache(REDIS_KEYS.FEATURED_POSTS),
Copy link
Owner

Choose a reason for hiding this comment

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

It should ideally format, I'm confused, why isn't it working for you !!
we have a husky hook which actually formats the code,
Isn't it working for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i guess its not working for me.
i will manually do "npm run format" in both frontend and backend and push the code

Copy link
Owner

Choose a reason for hiding this comment

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

@@ -152,7 +155,11 @@ export const deletePostByIdHandler = async (req, res) => {
}
await User.findByIdAndUpdate(post.authorId, { $pull: { posts: req.params.id } });

res.status(HTTP_STATUS.OK).json({ message: RESPONSE_MESSAGES.POSTS.DELETED });
// invalidate the redis cache
await deleteDataFromCache(REDIS_KEYS.ALL_POSTS),
Copy link
Owner

Choose a reason for hiding this comment

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

Same here

@devsharmagit
Copy link
Contributor Author

@krishnaacharyaa

global user type in frontend folder - #418 #418
editing the posts - #419 #419

Copy link
Owner

@krishnaacharyaa krishnaacharyaa left a comment

Choose a reason for hiding this comment

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

LGTM, thank you @devsharmag99 for the efforts

@krishnaacharyaa krishnaacharyaa merged commit d90c7eb into krishnaacharyaa:main Jun 18, 2024
3 checks passed
@devsharmagit
Copy link
Contributor Author

@krishnaacharyaa
actually @devsharmag99 is my company's github account. I forgot to switch before contributing

@krishnaacharyaa
Copy link
Owner

Oooh okay cool hai no problem @devsharmagit

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.

[FEATURE] Adding admin functionality to the frontend
3 participants