Files
My-KOPKB/fe/src/modules/external-system/composables/useExternalSystemDetail.ts
T
ismailmasseran d06c4701a4
Build Docker Image / build-backend (push) Successful in 1m56s
Build Docker Image / build-frontend (push) Successful in 1m55s
Dev/v1.2 (#4)
Co-authored-by: ISMAIL MASSERAN <topaz@Mac.dlinkrouter.local>
Reviewed-on: #4
2026-07-06 12:50:55 +08:00

42 lines
1022 B
TypeScript

import { computed, ref, watch } from 'vue'
import { useRoute } from 'vue-router'
import { useExternalSystemList } from './useExternalSystemList'
import {
getExternalSystemStatus,
isExternalSystemAccessible,
} from '../utils/external-system.utils'
export function useExternalSystemDetail() {
const route = useRoute()
const { getSystemById } = useExternalSystemList()
const loading = ref(false)
const error = ref<string | null>(null)
const systemId = computed(() => String(route.params.id ?? ''))
const system = computed(() => getSystemById(systemId.value) ?? null)
const status = computed(() => (system.value ? getExternalSystemStatus(system.value) : null))
const isAccessible = computed(() =>
system.value ? isExternalSystemAccessible(system.value) : false,
)
watch(
systemId,
() => {
error.value = system.value ? null : 'Sistem luaran tidak dijumpai.'
},
{ immediate: true },
)
return {
system,
loading,
error,
status,
isAccessible,
}
}