Skip to main content

Roles

What Is this?

Utilities to manage the display of components within Matchplat applications based on the user roles.

info

You need CronoUser installed to use this component

CronoRole

Install

Install CronoRole into your components to manage the display of components:

import { CronoRole } from "@matchplat/crono";

Use

Test the role with the role prop.


const Container = () => {
return (
...
<CronoRole role="RoleString">
<RoleNeeded />
</CronoRole>
);
};

useCronoRole

Install

Import useCronoRole into your components to test if the user has a certain role.
This can also be useful for testing logical conditions and not just the visibility of components:

import { useCronoRole } from "@matchplat/crono";

Use


const MyComponent = () => {

const hasRole = useCronoRole('RoleString')

//used for logical conditions
const showData = hasRole ? 'show' : null;

//used for conditional display of components
return (
...
<ContainerComponent>
{hasRole && <RoleNeeded />}
</ContainerComponent>
);
};