-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
50 lines (38 loc) · 1.51 KB
/
index.js
File metadata and controls
50 lines (38 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import IOBrowser from '@interopio/browser';
import IOWorkspaces from '@interopio/workspaces-api';
const setFields = (client) => {
const elementName = document.querySelectorAll("[data-name]")[0];
elementName.innerText = client.name;
const elementAddress = document.querySelectorAll("[data-address]")[0];
elementAddress.innerText = client.address;
const elementPhone = document.querySelectorAll("[data-phone]")[0];
elementPhone.innerText = client.contactNumbers;
const elementOccupation = document.querySelectorAll("[data-email]")[0];
elementOccupation.innerText = client.email;
const elementManager = document.querySelectorAll("[data-manager]")[0];
elementManager.innerText = client.accountManager;
};
const toggleIOAvailable = () => {
const span = document.getElementById("ioConnectSpan");
span.classList.remove("label-warning");
span.classList.add("label-success");
span.textContent = "io.Connect is available";
};
const start = async () => {
const config = {
libraries: [IOWorkspaces]
};
const io = await IOBrowser(config);
window.io = io;
toggleIOAvailable();
const myWorkspace = await io.workspaces.getMyWorkspace();
if (myWorkspace) {
myWorkspace.onContextUpdated((context) => {
if (context.client) {
setFields(context.client);
myWorkspace.setTitle(context.client.name);
};
});
};
};
start().catch(console.error);