I am so new to this, I still haven't figured how to do this one. I have been trying to search for some tutorials since im new to this, I also tried following this: https://appwrite.io/docs/products/auth/labels, but i ended quite alot of errors. The picture here is my appwrite config right now. All the things made here are basically just me following tutorials but not actually quite understand them.
I asked this before on general, but I still can't figure it out. At this point, I may be asking for a code. But i just want someone to give me a step by step guide on how to actually implement labels on my sidebar
Where is the real issue happening?
me not understanding how to make it work
trying to hide 1 element
https://www.youtube.com/watch?v=E7xjuKJl7Ac watching this as well, but his doing databases which I don't need for now
I won't give you exact code, but I'll get you something to go off of.
const NAV_ITEMS = [
{
title: "Something",
label: "admin"
}
]
async function Sidebar() {
const user = await account.get();
const visibleItems = useMemo(() => {
return filterSidebarItems(NAV_ITEMS, user.labels);
}, [user]);
return (
<div>
{visibleItems.map(item => (
<div key={item.id}>{item.name}</div>
))}
</div>
);
}
function filterSidebarItems(sidebarItems, userLabels) {
return sidebarItems.filter(item =>
item.labels.some(label => userLabels.includes(label))
);
}
Really all you should have to do is get the current user, check their labels, and see if the label for the sidebar is contained in the labels the user has.
Recommended threads
- Help Needed: "The current user has been ...
Facing a 403 Forbidden error with the message "The current user has been blocked" while trying to log in via GitHub and Email/Password. This is happening on a ...
- Unable to signup to appwrite cloud
When attempting to create an online cloud account on appwrite.io, I get the following message : "This email address must already be in its canonical form. Pleas...
- Email address must be in its canonical f...
Hello, Recently I was trying to signup with my GitHub account with appwrite account for availing the student benifits but while trying to signup I saw such erro...