Cleaned up validators and browser-side ajax utils
This commit is contained in:
parent
8a4a21cff0
commit
cf55be21eb
8 changed files with 79 additions and 35 deletions
|
|
@ -137,6 +137,8 @@ class canopyAjaxUtils{
|
|||
|
||||
if(response.status == 200){
|
||||
location = "/";
|
||||
}else{
|
||||
utils.ux.displayResponseError(await response.json());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -151,6 +153,8 @@ class canopyAjaxUtils{
|
|||
|
||||
if(response.status == 200){
|
||||
location.reload();
|
||||
}else{
|
||||
utils.ux.displayResponseError(await response.json());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -161,27 +165,42 @@ class canopyAjaxUtils{
|
|||
|
||||
if(response.status == 200){
|
||||
location.reload();
|
||||
}else{
|
||||
utils.ux.displayResponseError(await response.json());
|
||||
}
|
||||
}
|
||||
|
||||
//We need to fix this one to use displayResponseError function
|
||||
async updateProfile(update){
|
||||
return await fetch(`/api/account/update`,{
|
||||
const response = await fetch(`/api/account/update`,{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(update)
|
||||
});
|
||||
|
||||
if(response.status == 200){
|
||||
return await response.json();
|
||||
}else{
|
||||
utils.ux.displayResponseError(await response.json());
|
||||
}
|
||||
}
|
||||
|
||||
async deleteAccount(pass){
|
||||
return await fetch(`/api/account/delete`,{
|
||||
const response = await fetch(`/api/account/delete`,{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({pass})
|
||||
});
|
||||
|
||||
if(response.status == 200){
|
||||
window.location.pathname = '/';
|
||||
}else{
|
||||
utils.ux.displayResponseError(await response.json());
|
||||
}
|
||||
}
|
||||
|
||||
async newChannel(name, description, thumbnail){
|
||||
|
|
@ -195,6 +214,8 @@ class canopyAjaxUtils{
|
|||
|
||||
if(response.status == 200){
|
||||
location = "/";
|
||||
}else{
|
||||
utils.ux.displayResponseError(await response.json());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -210,6 +231,8 @@ class canopyAjaxUtils{
|
|||
|
||||
if(response.status == 200){
|
||||
return await response.json();
|
||||
}else{
|
||||
utils.ux.displayResponseError(await response.json());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -224,6 +247,8 @@ class canopyAjaxUtils{
|
|||
|
||||
if(response.status == 200){
|
||||
location = "/";
|
||||
}else{
|
||||
utils.ux.displayResponseError(await response.json());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue