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
- Unauthorized Charge After Appwrite Pro F...
I was using Appwrite Pro credits worth $100, which were valid until November. During this period, I was exploring Appwrite's services. However, I recently notic...
- Realtime with multiple connections
I need the Realtime on multiple Collections for diffrent applicational logic. So my question is: Is there a way to have only 1 Websocket connection or do I need...
- Can't login or deploy functions in Appwr...
Hello, since i updatet to the appwrite cli 6.1.0 i can't login or deploy functions with the cli. When i call the command: "appwrite get account --verbose" i ge...