Complete duplicate action for rest.

This commit is contained in:
Paulo Gustavo Veiga 2021-02-04 10:23:58 -08:00
parent 86d78935f0
commit 0d7cf3e5b1
2 changed files with 27 additions and 9 deletions

View File

@ -160,5 +160,23 @@ export default class RestClient extends MockClient {
}
return new Promise(handler);
}
duplicateMap(id: number, basicInfo: BasicMapInfo): Promise<number> {
const handler = (success: (mapId: number) => void, reject: (error: ErrorInfo) => void) => {
axios.post(this.baseUrl + `/c/restful/maps/${id}`,
JSON.stringify(basicInfo),
{ headers: { 'Content-Type': 'application/json' } }
).then(response => {
const mapId = response.headers.resourceid;
success(mapId);
}).catch(error => {
const response = error.response;
const errorInfo = this.parseResponseOnError(response);
reject(errorInfo);
});
}
return new Promise(handler);
}
}

View File

@ -31,8 +31,8 @@ const DuplicateDialog = (props: DialogProps) => {
return service.duplicateMap(id, rest);
},
{
onSuccess: () => {
handleOnMutationSuccess(props.onClose, queryClient);
onSuccess: (mapId) => {
window.location.href = `/c/maps/${mapId}/edit`;
},
onError: (error) => {
setError(error);