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

It uses SignalR to install WebSockets: 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

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

default is true.

The component will take care of:

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

Data Provided with useCronoUser hook:

  • setLanguage
  • userLanguage
  • isWebsocketReady
  • connection
  • 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)