Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
| Numéro du ticket | Titre du ticket | |------------------|-----------------| | | | ## Description de la PR ## Modification du .env ## Check list - [x] Pas de régression - [x] TU/TI/TF rédigée - [x] TU/TI/TF OK - [x] CHANGELOG modifié Reviewed-on: #58 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
24 lines
669 B
TypeScript
24 lines
669 B
TypeScript
import { ref } from 'vue'
|
|
import { useApi } from '~/composables/useApi'
|
|
|
|
export type PontBasculeStatus = 'checking' | 'connected' | 'disconnected'
|
|
|
|
export const usePontBascule = () => {
|
|
const api = useApi()
|
|
const status = ref<PontBasculeStatus>('checking')
|
|
|
|
const checkHealth = async () => {
|
|
status.value = 'checking'
|
|
try {
|
|
const res = await api.get<{ healthy: boolean }>('pont_bascule/health', {}, {
|
|
toast: false
|
|
})
|
|
status.value = res.healthy ? 'connected' : 'disconnected'
|
|
} catch {
|
|
status.value = 'disconnected'
|
|
}
|
|
}
|
|
|
|
return { status, checkHealth }
|
|
}
|