import { api } from '@/core/services/api' import type { ExternalSystem, ExternalSystemListResponse, ExternalSystemResponse, ExternalSystemSsoLaunchResponse, } from '../types/external-system.types' export async function listExternalSystems(): Promise { const { data } = await api.get('/v1/external-systems') if (!data.success) { throw new Error(data.message ?? 'Gagal memuatkan senarai sistem luaran.') } return data.data } export async function getExternalSystem(id: string): Promise { const { data } = await api.get(`/v1/external-systems/${id}`) if (!data.success) { throw new Error(data.message ?? 'Sistem luaran tidak dijumpai.') } return data.data } export async function launchExternalSystemSso( systemCode: string, ): Promise { const { data } = await api.post( `/v1/external-systems/${systemCode}/sso/launch`, ) if (!data.success) { throw new Error(data.message ?? 'Gagal membuka sistem.') } return data }