Changin to material icons
This commit is contained in:
37
API.js
37
API.js
@@ -17,6 +17,23 @@ let getCall = async (path = "", params = {}) => {
|
||||
})
|
||||
}
|
||||
|
||||
let deleteCall = async (path = "", params = {}) => {
|
||||
let queryParams = "?";
|
||||
Object.keys(params).forEach(p => {
|
||||
queryParams += p + "=" + params[p] + "&"
|
||||
});
|
||||
return fetch(baseUrl + path + queryParams, {
|
||||
method: 'DELETE',
|
||||
mode: 'cors',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
}).then(response => response.json()).catch((error) => {
|
||||
console.error(error);
|
||||
})
|
||||
}
|
||||
|
||||
let postCall = async (path, params) => {
|
||||
return fetch(baseUrl + path, {
|
||||
method: 'POST',
|
||||
@@ -112,9 +129,13 @@ const API = {
|
||||
if (userid) return getCall("/post/usr/" + userid);
|
||||
return getCall("/post/");
|
||||
},
|
||||
newPost(content, toProfile) {
|
||||
deletePost(postid){
|
||||
return deleteCall("/post/" + postid);
|
||||
},
|
||||
newPost(content, toProfile, isNews) {
|
||||
//Content is expected to be a string.
|
||||
let params = { content };
|
||||
if(isNews) params.nonOrganicType = "News"
|
||||
if (toProfile && CurrentUserId !== toProfile)
|
||||
params.toProfile = toProfile;
|
||||
return postCall("/post/", params);
|
||||
@@ -157,8 +178,8 @@ const API = {
|
||||
getMyProfile() {
|
||||
return getCall("/user/" + CurrentProfile);
|
||||
},
|
||||
updateMyProfile(profile) {
|
||||
return postCall("/user/myProfile", profile);
|
||||
updateMyProfile(profile, data) {
|
||||
return postCall("/user/myProfile", {profile, data});
|
||||
},
|
||||
searchProfiles(query){
|
||||
return getCall("/user/search", query ? {query} : {}).then((data)=>{
|
||||
@@ -180,6 +201,9 @@ const API = {
|
||||
getUserProfile(profileid, refresh=false) {
|
||||
return getProfileFromCache(profileid, refresh);
|
||||
},
|
||||
deleteProfile(profileid){
|
||||
return deleteCall("/user/" + profileid);
|
||||
},
|
||||
currentProfileId() {
|
||||
if (!CurrentProfile) this.isLoggedIn(); //replace with cookie
|
||||
return CurrentProfile;
|
||||
@@ -245,6 +269,13 @@ const API = {
|
||||
},
|
||||
unsubscribeToGroup(groupid){
|
||||
return getCall("/user/groups/" + groupid + "/unsubscribe");
|
||||
},
|
||||
//Payments
|
||||
paymentIntent(userid, price, description){
|
||||
return postCall("/payments/intent", {userid, price, description});
|
||||
},
|
||||
paymentRegister(userid, result){
|
||||
return postCall("/payments/register/", {userid, result});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user