frontend: createServer moved to useServer

This commit is contained in:
Frank Agerholm 2026-01-25 20:15:58 +01:00
commit 6a78f8b1ec
No known key found for this signature in database
2 changed files with 37 additions and 13 deletions

View file

@ -24,10 +24,37 @@ export function useServers() {
return result
}
async function createServer(hostname: string, description: string, owner_id: number | null) {
const payload = {
hostname: hostname,
description: description,
owner_id: owner_id
}
loading.value = true
error.value = ""
const result = await apiFetch("/servers", {
method: "POST",
body: payload
})
if (isUnauthorized(result)) {
loading.value = false
return result
}
// Optional: direkt in die Liste einfügen
servers.value.push(result)
loading.value = false
return result
}
return {
servers,
loading,
error,
loadServers
loadServers,
createServer
}
}