Practice list <dokicasa-practices> beta
This component shows the list of your account's practices on your website, just like the Dokicasa private area. Your customer opens a practice, sees its status, downloads the documents and answers Dokicasa's requests without leaving your site.
Beta: activation on request
It uses the same activation as the form: if your domains are already enabled for the form, the list works too.
What it shows
- List of practices: name, service, date, status and step progress. There are three filters: All, Need your action and In progress. There is also a search (by name, property, landlord or tenant) and pagination.
- Practice detail: the steps with their status and the documents to download, that is contract PDFs and closing attachments.
- Requests to complete: the tasks Dokicasa assigns to your account, with reply and attachments. After sending, the request moves to Sent, under review until the back office closes it.
It only shows the practices of the account the API key belongs to, the same ones returned by GET /api/v3/user/me/services. It does not create, edit or delete practices.
1. The token
As with the form, your server requests a short-lived token with your API key and passes it to the page. Only the scope changes:
curl -X POST https://app.dokicasa.it/api/v3/sdk/token \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{"scope": "practices"}'{ "user_token": "dksdk.eyJpdiI6...", "expires_in": 3600, "scope": "practices" }The token lasts one hour and only works on your enabled domains. It only opens these operations:
| Method | Path | Purpose |
|---|---|---|
GET | /api/v3/user/me/services | Practice list |
GET | /api/v3/practices/{id} | Practice detail |
GET | /api/v3/practices/{id}/tasks | Practice requests (tasks) |
GET | /api/v3/contract/{id}/pdf | Contract PDF |
POST | /api/v3/tasks/{task}/comments | Reply to a request |
The form token does not open the list, and the list token does not open the form. If you need both on the same page, request two tokens.
Do not call this endpoint from the browser
Otherwise your API key ends up in the page, and anyone could use it on your account.
$token = Http::withToken(env('DOKICASA_API_KEY'))
->acceptJson()
->post('https://app.dokicasa.it/api/v3/sdk/token', ['scope' => 'practices'])
->json('user_token');const res = await fetch('https://app.dokicasa.it/api/v3/sdk/token', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.DOKICASA_API_KEY}`,
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({ scope: 'practices' }),
})
const { user_token } = await res.json()2. The component in the page
<script src="https://app.dokicasa.it/contract-form-v2-sdk/practices-v1.js"></script>
<dokicasa-practices user-token="dksdk.eyJpdiI6..."></dokicasa-practices>Only show the list to users who are logged in to your site: whoever sees the page sees all the practices of your account.
Attributes
| Attribute | Required | Description |
|---|---|---|
user-token | yes | The token with scope: practices |
heading | no | Title above the list. Default: Le tue pratiche |
api-base | no | Only for staging: https://testing.dokicasa.it/api |
When the token expires you can replace it without reloading the page: update the user-token attribute and the component reloads its data.
Events
const el = document.querySelector('dokicasa-practices')
el.addEventListener('error', (e) => {
if (e.detail.status === 401) {
// token expired: ask your server for a new one
fetch('/my-server/dokicasa-token').then((r) => r.json())
.then(({ user_token }) => el.setAttribute('user-token', user_token))
}
})| Event | detail | When |
|---|---|---|
load | { total, page } | List loaded |
open | { practiceId, name } | A practice is opened |
task-replied | { practiceId, taskId } | A reply to a request was sent |
error | { message, status } | A call failed. 401: token expired or invalid. 403: domain not enabled or operation not allowed |
Colours and fonts
They are the same variables as the form:
dokicasa-practices {
--primary: #7a1fa2;
--primary-600: #5e1680;
--primary-50: #f3e5f7;
--secondary: #ff6f00;
--secondary-600: #e65f00;
font-family: 'Your font', sans-serif;
}The full list of variables is in the form guide. The component is isolated with Shadow DOM: your site's CSS does not affect it.
Errors
| Status | Message | What to do |
|---|---|---|
401 | Token SDK non valido o scaduto. | Request a new token |
403 | Dominio non abilitato per questo token. | Ask Dokicasa to enable the domain |
403 | Questa operazione non e' disponibile con questo token SDK. | You are using the form token: request one with scope: practices |
403 | SDK non abilitato: nessun dominio configurato per questo account. | Activation is required |