UI: Use new reset endpoints to reset all data

This commit is contained in:
Mike Salvatore 2022-06-30 14:50:44 -04:00
parent e8f76f39e1
commit ddc3f2012d
1 changed files with 19 additions and 2 deletions

View File

@ -74,8 +74,7 @@ const IslandResetModal = (props: Props) => {
<button type='button' className='btn btn-danger btn-lg' style={{margin: '5px'}}
onClick={() => {
setResetAll(Loading);
resetIsland('/api?action=reset',
() => {
resetAll(() => {
setResetAll(Done);
props.onClose();
})
@ -98,6 +97,24 @@ const IslandResetModal = (props: Props) => {
}
})
}
function resetAll(callback: () => void) {
auth.authFetch('/api/reset-agent-configuration', {method: 'POST'})
.then(res => {
if (res.status === 200) {
auth.authFetch('/api/clear-simulation-data', {method: 'POST'})
.then(res => {
if (res.status === 200) {
auth.authFetch('/api/island-mode', {method: 'POST', body: '{"mode": "unset"}'})
.then(res => {
if (res.status === 200) {
callback()
}
})
}
})
}
})
}
function showModalButtons() {
return (<Container className={`text-left island-reset-modal`}>