UI: Use new `/api/clear-simulation-data` endpoint

This commit is contained in:
Mike Salvatore 2022-06-30 14:50:25 -04:00
parent 9ece3c100b
commit e8f76f39e1
1 changed files with 4 additions and 6 deletions

View File

@ -54,8 +54,7 @@ const IslandResetModal = (props: Props) => {
<button type='button' className='btn btn-danger btn-lg' style={{margin: '5px'}}
onClick={() => {
setDeleteStatus(Loading);
resetIsland('/api?action=delete-agent-data',
() => {
clearSimulationData(() => {
setDeleteStatus(Done)
})
}}>
@ -91,11 +90,10 @@ const IslandResetModal = (props: Props) => {
}
}
function resetIsland(url: string, callback: () => void) {
auth.authFetch(url)
.then(res => res.json())
function clearSimulationData(callback: () => void) {
auth.authFetch('/api/clear-simulation-data', {method: 'POST'})
.then(res => {
if (res['status'] === 'OK') {
if (res.status === 200) {
callback()
}
})