parent
f59ed30ff6
commit
bd6bc7f7f6
3 changed files with 54 additions and 0 deletions
@ -0,0 +1,37 @@ |
||||
const toAnvilDetail = (data: AnvilListItem): APIAnvilDetail => { |
||||
const { |
||||
anvil_name: anvilName, |
||||
anvil_state: anvilState, |
||||
anvil_uuid: anvilUuid, |
||||
hosts: rHosts, |
||||
} = data; |
||||
|
||||
const hosts = rHosts.reduce<APIAnvilDetail['hosts']>((previous, current) => { |
||||
const { |
||||
host_name: hostName, |
||||
host_uuid: hostUuid, |
||||
maintenance_mode: maintenance, |
||||
state, |
||||
state_percent: stateProgress, |
||||
} = current; |
||||
|
||||
previous[hostUuid] = { |
||||
name: hostName, |
||||
maintenance, |
||||
state, |
||||
stateProgress, |
||||
uuid: hostUuid, |
||||
}; |
||||
|
||||
return previous; |
||||
}, {}); |
||||
|
||||
return { |
||||
hosts, |
||||
name: anvilName, |
||||
state: anvilState, |
||||
uuid: anvilUuid, |
||||
}; |
||||
}; |
||||
|
||||
export default toAnvilDetail; |
Loading…
Reference in new issue