mirror of
https://github.com/abhinavxd/libredesk.git
synced 2025-11-02 04:53:41 +00:00
- new vue app for serving live chat widget, created subdirectories inside frontend dir `main` and `widget` - vite changes for both main app and widget app. - new backend live chat channel - apis for live chat widget
23 lines
590 B
JavaScript
23 lines
590 B
JavaScript
import { ref, onMounted, onUnmounted } from 'vue'
|
|
import { calculateSla } from '../utils/sla'
|
|
|
|
export function useSla (dueAt, actualAt) {
|
|
const sla = ref(null)
|
|
function updateSla () {
|
|
if (!dueAt.value) {
|
|
sla.value = null
|
|
return
|
|
}
|
|
sla.value = calculateSla(dueAt.value, actualAt.value)
|
|
}
|
|
onMounted(() => {
|
|
updateSla()
|
|
// Update the SLA every 30 seconds.
|
|
const intervalId = setInterval(updateSla, 30000)
|
|
onUnmounted(() => {
|
|
clearInterval(intervalId)
|
|
})
|
|
})
|
|
return sla
|
|
}
|