feat(fer-19) : composable usePontBascule
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
23
frontend/composables/usePontBascule.ts
Normal file
23
frontend/composables/usePontBascule.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
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 }
|
||||
}
|
||||
Reference in New Issue
Block a user