open-index/open-npm huggingface dataset:
npm package: @reminnor/kollega
Description: This repo contains the frontend client for Remin Kollega.
Latest version: 1.5.0

# Kollega Client
### Secure Chat for Health Personell

This repo contains the frontend client for Remin Kollega.


## Get Started

The main starting point is to include the KollegaButton to your application.
```
import { KollegaButton } from '@reminnor/kollega'

...
<KollegaButton/>
```

In principle this is all you need to do as long as your users are already logged in with HelseID.


## Authentication

Kollega uses HelseID to authenticate users and will by default automatically re-direct the user through our authentication flow the first time it is rendered on the a page. This process will authenticate the current session with Kollega and will only be required to do once.

The consequence of this process is that you will get a double render in your application. After the user has been redirected through your own login flow Kollega will start a new one on first render.

To prevent this double render, it's possible for you to tap into Kollega's authentication flow by redirecting the user directly to it after they come back from your flow.

``` login => your backend => HelseID => yourBackend => kollega => HelseID => kollega => logged in ```

You can access our authentication flow from the `getAuthUrl(method:'helseid' | 'idporten', returnUrl: string)` function

``` 
import { getAuthUrl, KollegaAuthProvider } from '@reminnor/kollega'


const authUrl = `http://your.auth.url?=redirect_url=${getAuthUrl('helseid', yourRedirectUrl)}`
 ```


## Exports

### Authentication Context

Kollega exports an authentication context that provides information regarding the users' logged in state. This information is polled in the background automatically if the context is in use.

```
import { KollegaAuthContext, KollegaAuthProvider } from '@reminnor/kollega'

ReactDom.render(
	....
	<KollegaAuthProvider>
	....
	</KollegaAuthProvider>
	....
)

....

const { isSignedIn, isLoading, me } = useContext(KollegaAuthContext)
```

### Kollega Components

Kollega exports two main components.

KollegaButton - This component should be used if you want Kollega as an integrated service with a 'Kollega' button in the right hand corner.

Kollega - This component is the main Kollega component and renderes the full Kollega chat.

### Interaction

Kollega exports `kollegaSettings` which exposes a few methods to interact with Kollega and the KollegaButton.
`kollegaSettings.button` includes hide and minimize methods for the KollegaButton.


## PDF Preview Support

Kollega uses pdf.js for previewing PDFs inline in the app. This is a massive library, which is why we've opted to require it to be included separately from the rest of the application.

To support PDF preview `libs/pdf.worker.2.10.337.min.js` must be served relative to your root folder.