Complete rename

This commit is contained in:
Paulo Gustavo Veiga 2021-02-07 00:02:16 -08:00
parent ce05cc3d18
commit b67e88f3dc

View File

@ -34,8 +34,7 @@ export default class RestClient implements Client {
// All was ok, let's sent to success page ...; // All was ok, let's sent to success page ...;
success(); success();
}).catch(error => { }).catch(error => {
const response = error.response; const errorInfo = this.parseResponseOnError(error.response);
const errorInfo = this.parseResponseOnError(response);
reject(errorInfo); reject(errorInfo);
}); });
} }
@ -62,7 +61,25 @@ export default class RestClient implements Client {
} }
renameMap(id: number, basicInfo: BasicMapInfo): Promise<void> { renameMap(id: number, basicInfo: BasicMapInfo): Promise<void> {
throw "Method not implemented yet"; const handler = (success: () => void, reject: (error: ErrorInfo) => void) => {
axios.put(`${this.baseUrl}/c/restful/maps/${id}/title`,
basicInfo.title,
{ headers: { 'Content-Type': 'text/plain' } }
).then(() => {
return axios.put(`${this.baseUrl}/c/restful/maps/${id}/description`,
basicInfo.description,
{ headers: { 'Content-Type': 'text/plain' } }
)
}).then(() => {
// All was ok, let's sent to success page ...;
success();
}).catch(error => {
const response = error.response;
const errorInfo = this.parseResponseOnError(response);
reject(errorInfo);
});
}
return new Promise(handler);
} }
createMap(model: BasicMapInfo): Promise<number> { createMap(model: BasicMapInfo): Promise<number> {
@ -254,7 +271,7 @@ export default class RestClient implements Client {
case 401: case 401:
case 302: case 302:
this.sessionExpired(); this.sessionExpired();
result = { msg: "Your current session has expired. Please, sign in and try again." }; result = { msg: "Your current session has expired. Please, sign in and try again." };
break; break;
default: default:
if (data) { if (data) {