Skip to main content

Crono User

What Is this?

This component manages the user of Matchplat applications. Its installation allows the application to access the user's information through a Provider present in it, so you can access the user's preferences and roles in Matchplat.

It uses i18next as a library to manage languages: i18next-react

caution

This Component needs CronoBoost to work!

Crono User

Install CronoUser:

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

Use it after CronoBoost and before your App:

const Wrapper = () => {
return (
<CronoBoost uri="...">
<CronoUser>
<MyApp />
</CronoUser>
</CronoBoost>
);
};

You can stop the notifications by passing the prop notifications as false

warning

notifications are currently not working anymore

const Wrapper = () => {
return (
<Cronouser notifications={false}>
<MyApp />
</Cronouser>
);
};

default is true.

You can create a custom query for user data in customUserQuery

const Wrapper = () => {
return (
<Cronouser customUserQuery={"... your query ..."}>
<MyApp />
</Cronouser>
);
};

the standard query name for user's query is getLoggedUser if you change the value for the query name, you must use userQueryName as prop:

const Wrapper = () => {
return (
<Cronouser
customUserQuery={"... your query ..."}
userQueryName="custom name"
>
<MyApp />
</Cronouser>
);
};

Must be a type of DocumentNode from graph-ql.

The component will take care of:

  • Create a Loading for languages
  • Save the language choice
  • Load the language choice
  • Create a custom Hook useCronoUser to access data

Data Provided with useCronoUser hook:

  • setLanguage
  • userLanguage
  • userID
  • name
  • surname
  • email
  • phone
  • licenses
  • roles
  • activities
  • refetchLoggedUser
  • loadingLoggedUser

Is also possible to call the refetchLoggedUser query from the hook itself and use the loadingLoggedUser for the async data loading.

(In the DEV environment, this component sets debug=true into i18next options and SignalR console.log, so you can debug languages and websockets into your browser console)