Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yusufgns/privileges-managment-example

Privileges Managment Example
https://github.com/yusufgns/privileges-managment-example

permission-managment privileges privileges-management privileges-model react team-manag

Last synced: about 1 month ago
JSON representation

Privileges Managment Example

Awesome Lists containing this project

README

        

# Privileges

Allows you to control the components on the page by privileges in a simple way.

## Custom privileges component

By creating a custom privileges component, you can ensure faster and cleaner development

```ts
//custom-privileges.tsx
import { PrivilegesContainer } from "./container";
import { Button } from "../ui/button";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../ui/tooltip";
import WarningSVG from "@/components/icons/warning";

export type Privilege = {
[key: string]: string;
}

export const moderator: Readonly = Object.freeze({
ADMIN: 'admin',
});

export const CustomPrivilegesComponent = ({ children, userPrivileges, componentPrivileges, active, not_privileges = "component" }: {
children: React.ReactNode;
userPrivileges: string[];
// moderator: string[];
componentPrivileges: string | string[];
active: "button" | "tooltip" | "not_privileges";
not_privileges?: "pages" | "component";
}) => {
return (

You are not privileges for this

}
not_privileges_container={
not_privileges === "component"
? (



You are not privileges for component

)
: (


You are not privileges for pages



Go to home


)
}
tooltip_container={



{children}


You are not privileges for this



}
/>
)
}

//index.tsx

TEST PRIVILEGES

```