Skip to content

Commit

Permalink
Merge branch dev
Browse files Browse the repository at this point in the history
  • Loading branch information
yoryer committed Apr 18, 2022
2 parents ef8755e + ff4eceb commit 29050be
Show file tree
Hide file tree
Showing 7 changed files with 540 additions and 514 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
// 'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
'plugin:jsdoc/recommended',
'prettier',
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v12
68 changes: 52 additions & 16 deletions example/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ const accessTokenSso = document.getElementById('access-token-sso')
const accessTokenAppId = document.getElementById('access-token-app-id')
const transferToAgentList = document.getElementById('transfer-to-agent-list')
const transferToAgentIcon = document.getElementById('transfer-to-agent-icon')
const transferToAgentStatus = document.getElementById('transfer-to-agent-status')
const transferToAgentStatus = document.getElementById(
'transfer-to-agent-status'
)

/**
* Call details
Expand Down Expand Up @@ -411,7 +413,7 @@ function createDeviceOptions(inputs, outputs) {
/**
* Notes
*/
function createNotesList(notesList) {
function createNotesList(notesList) {
callNotesList.textContent = ''
if (notesList) {
notesList.result.forEach((e) => {
Expand Down Expand Up @@ -561,15 +563,14 @@ function addTag() {
addTagBtn.addEventListener('click', addTag)

function updateAgentsList(agents) {
const agentId = getItem(AGENT_ID_KEY)
transferToAgentSelect.options.length = 0

if (agents?.data) {
agents.data.forEach((agent) => {
if (!agent.self) {
const option = document.createElement('option')
option.value = agent.email
option.text = `${agent.info?.fullname} [${agent.email}]`
option.value = agent.email
option.text = `${agent.info?.fullname} [${agent.email}]`
let agentStatus = 'offline'
if (agent.online) {
agentStatus = 'online'
Expand All @@ -580,7 +581,7 @@ function updateAgentsList(agents) {
if (agent.busy) {
agentStatus = 'busy'
}
option.setAttribute('data-status', agentStatus)
option.setAttribute('data-status', agentStatus)
transferToAgentSelect.appendChild(option)
}
})
Expand All @@ -595,7 +596,7 @@ function getAgentsList() {
const accessToken = getItem(ACCESS_TOKEN_KEY)

/**
* ref: https://toky-js-sdk.toky.co/reference/agents
* ref: https://toky-js-sdk.toky.co/reference/agents
*/
fetch(`${tokyApiUrl}/v1/sdk/agents?agent_id=${agentId}`, {
method: 'GET',
Expand All @@ -604,7 +605,7 @@ function getAgentsList() {
.then((response) => response.json())
.then((result) => {
if (result.success) {
updateAgentsList(result)
updateAgentsList(result)
}
})
.catch((err) => console.error(err))
Expand All @@ -624,8 +625,18 @@ const transferOptionsDisabled = (disabled) => {
makeTransferBtn.disabled = disabled
makeTransferBtn.style.display = 'block'
completeTransferBtn.style.display = 'none'
transferToAgentList.classList.remove('is-primary', 'is-info', 'is-warning', 'is-danger')
transferToAgentIcon.classList.remove('has-text-success', 'has-text-info', 'has-text-warning', 'has-text-danger')
transferToAgentList.classList.remove(
'is-primary',
'is-info',
'is-warning',
'is-danger'
)
transferToAgentIcon.classList.remove(
'has-text-success',
'has-text-info',
'has-text-warning',
'has-text-danger'
)
transferToAgentSelect.options.selectedIndex = -1
if (disabled) {
makeTransferBtn.classList.remove('is-success')
Expand Down Expand Up @@ -1129,8 +1140,18 @@ function firstRun() {
})

transferToSelect.addEventListener('change', () => {
transferToAgentList.classList.remove('is-primary', 'is-info', 'is-warning', 'is-danger')
transferToAgentIcon.classList.remove('has-text-success', 'has-text-info', 'has-text-warning', 'has-text-danger')
transferToAgentList.classList.remove(
'is-primary',
'is-info',
'is-warning',
'is-danger'
)
transferToAgentIcon.classList.remove(
'has-text-success',
'has-text-info',
'has-text-warning',
'has-text-danger'
)
transferToAgentStatus.textContent = ''
transferToAgentSelect.options.selectedIndex = -1
if (transferToSelect.value === 'agent') {
Expand All @@ -1145,9 +1166,22 @@ function firstRun() {
})

transferToAgentSelect.addEventListener('change', () => {
const agentStatus = transferToAgentSelect.options[transferToAgentSelect.selectedIndex].getAttribute('data-status')
transferToAgentList.classList.remove('is-primary', 'is-info', 'is-warning', 'is-danger')
transferToAgentIcon.classList.remove('has-text-success', 'has-text-info', 'has-text-warning', 'has-text-danger')
const agentStatus =
transferToAgentSelect.options[
transferToAgentSelect.selectedIndex
].getAttribute('data-status')
transferToAgentList.classList.remove(
'is-primary',
'is-info',
'is-warning',
'is-danger'
)
transferToAgentIcon.classList.remove(
'has-text-success',
'has-text-info',
'has-text-warning',
'has-text-danger'
)
makeTransferBtn.disabled = false
if (agentStatus === 'online') {
transferToAgentList.classList.add('is-primary')
Expand Down Expand Up @@ -1238,7 +1272,9 @@ callOptionsTabs.querySelectorAll('li > a').forEach((e, i) => {
notesTagsBox.style.display = 'none'
dtfmBox.style.display = 'none'

callOptionsTabs.querySelectorAll('li').forEach(li => li.classList.remove('is-active'))
callOptionsTabs
.querySelectorAll('li')
.forEach((li) => li.classList.remove('is-active'))

switch (i) {
case 1:
Expand Down
Loading

0 comments on commit 29050be

Please sign in to comment.