Files
libredesk/frontend/apps/main/src/composables/useSla.js
Abhinav Raut 5b6a58fba0 wip: intercom like live chat with chat widget
- 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
2025-06-29 04:59:55 +05:30

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
}