frontend: createServer moved to useServer
This commit is contained in:
parent
43de7bc9b5
commit
6a78f8b1ec
2 changed files with 37 additions and 13 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue