
I will just be straight on.

did this to fetch the label

if (!item.hidden) {
return (
<div key={item.path} className="text-white">
{item.submenu ? (
<>
<button
//Sub Menus
onClick={toggleSubMenu}
className={`flex flex-row items-center p-2 rounded-lg w-full justify-between hover:bg-white hover:text-black ${
pathname.includes(item.path) ? 'bg-white text-black ' : ''
}`}
>
<div className="flex flex-row space-x-4 items-center">
{item.icon}
<span className="font-semibold text-xl flex">{item.title}</span>
</div>
<div className={`${subMenuOpen ? 'rotate-180' : ''} flex`}>
<Icon icon="lucide:chevron-down" width="24" height="24" />
</div>
</button>
{subMenuOpen && (
<div className="my-2 ml-12 flex flex-col space-y-4">
{item.subMenuItems?.map((subItem, idx) => {
return (
<Link
key={idx}
href={subItem.path}
className={`${
subItem.path === pathname ? 'font-bold' : ''
}`}
>
<span>{subItem.title}</span>
</Link>
);
})}
</div>
)}
</>
) : (
//Menus
<Link
href={item.path}
className={`flex flex-row space-x-4 items-center p-2 rounded-lg hover:bg-zinc-100 hover:text-black ${
item.path === pathname ? 'bg-zinc-100 text-black' : ''
}`}
>
{item.icon}
<span className="font-semibold text-xl flex">{item.title}</span>
</Link>
)}
</div>
);
}
This is Sidebar.tsx, currently hides items that has the hidden variable in my constants which is:
import { Icon } from '@iconify/react';
import { SideNavItem } from './types';
import appwriteService from "@/appwrite/config";
const userLabel = appwriteService.getCurrentUserLabel();
export const SIDENAV_ITEMS: SideNavItem[] = [
{
title: 'Home',
path: '/dashboard/home',
icon: <Icon icon="lucide:home" width="24" height="24" />,
},
{
title: 'Controls',
path: '/dashboard/controls',
icon: <Icon icon="lucide:folder" width="24" height="24" />,
hidden: true,
},
{
title: 'Messages',
path: '/dashboard/messages',
icon: <Icon icon="lucide:mail" width="24" height="24" />,
},
{
title: 'Settings',
path: '/dashboard/settings',
icon: <Icon icon="lucide:settings" width="24" height="24" />,
submenu: true,
subMenuItems: [
{ title: 'Account', path: '/dashboard/settings/account' },
{ title: 'Privacy', path: '/dashboard/settings/privacy' },
],
},

now i'm stuck not knowing what to do

I gave up on this before, but came back in order to finish it. I'm lost

No worries. We all start somewhere!

But if you dont mind, how would i exactly going to test account.get to be shown in the logs

Do you know how to log things?

That should be the console in the site itself

Yes. Do you know how to log things there?

Not sure though. The only thing that comes in my mind is running it and just checking the console

Yes but how to do make stuff show up in the console?

That i do not know

Have you used console.log()
?
Have you done any courses or tutorials on JavaScript?

Forgot about that, and as for js. I haven't actually. Only watched a few and know how some of the function works when i look at it but can't really do it when i try to implement it, i really have no knowledge on making websites. Its just that my professor gave me this without him teaching us basic java or javascript properly

console.log()
is used to log things. So you can call account.get()
and then log the result to see the details about it.
Anyways, you should probably learn some more programming or JavaScript basics before trying to learn react

apologies for not replying for like a week. Homeworks and tp's are a hassle. Just got back on this project again, it does show the user having the label ['admin']. Now I tried a couple of things so that it will actually be only shown if the user is an admin. But still couldn't work it around.

now I was wondering whether i have to do something with this, cause I am sure that im lacking something. Its just basically checking for the label only

tried playing around with useEffect but I still can't find a solution

Wait. I might have actually done it. But its late to appear? on the console, its printing "User is an admin" 12 times

How is setUserRole()
related to item
?

i used a useState so i can set a boolean whether the user does or does not have the label admin. I managed to make it work but its mapping through every single item slowly. Its printing 12 times and the controls element will show at around the 5th print

Please share your of your code

Mapping through? Where are you fetching the user?

Sorry for not replying for a couple of days. Do you mind setting this as solved? I managed to make things work now
Recommended threads
- Is my approach for deleting registered u...
A few weeks ago, I was advised not to use the registered users' id in my web app. Instead, I store the publicly viewable information such as username and email ...
- Stuck in "deleting"
my parent element have relationship that doesnt exist and its stuck in "deleting", i cant delete it gives me error: Collection with the requested ID could not b...
- Help with 409 Error on Relationship Setu...
I ran into a 409 document_already_exists issue. with AppWrite so I tried to debug. Here's what I've set up: Collection A has 3 attributes and a two-way 1-to-m...
