Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/yusufgns/privileges-managment-example
- Owner: yusufgns
- Created: 2024-05-03T23:49:40.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-04T13:47:05.000Z (8 months ago)
- Last Synced: 2024-10-15T03:30:58.793Z (3 months ago)
- Topics: permission-managment, privileges, privileges-management, privileges-model, react, team-manag
- Language: TypeScript
- Homepage: https://privileges-react-example.vercel.app/
- Size: 74.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```