Improved functionlity of messages page

This commit is contained in:
Keannu Christian Bernasol 2023-10-01 00:54:31 +08:00
parent 63f863fa1e
commit 2cd770e5e1
7 changed files with 414 additions and 96 deletions

View file

@ -4,6 +4,7 @@ import {
ActivationType,
LocationType,
LoginType,
MessagePostType,
OnboardingType,
PatchUserInfoType,
RegistrationType,
@ -311,7 +312,6 @@ export async function GetStudyGroupListFiltered() {
return instance
.get("/api/v1/study_groups/near/", config)
.then((response) => {
console.log("DEBUGGG", response.data);
return [true, response.data];
})
.catch((error) => {
@ -346,3 +346,56 @@ export async function CreateStudyGroup(info: StudyGroupCreateType) {
return [false, error_message];
});
}
export async function GetStudyGroup(name: string) {
const config = await GetConfig();
return instance
.get(`/api/v1/study_groups/${name}`, config)
.then((response) => {
return [true, response.data];
})
.catch((error) => {
let error_message = ParseError(error);
return [false, error_message];
});
}
export async function GetStudyGroupMessages() {
const config = await GetConfig();
return instance
.get(`/api/v1/messages/`, config)
.then((response) => {
return [true, response.data];
})
.catch((error) => {
let error_message = ParseError(error);
return [false, error_message];
});
}
export async function GetStudyGroupMemberAvatars() {
const config = await GetConfig();
return instance
.get(`/api/v1/study_groups/member_avatars`, config)
.then((response) => {
return [true, response.data];
})
.catch((error) => {
let error_message = ParseError(error);
return [false, error_message];
});
}
export async function PostMessage(info: MessagePostType) {
const config = await GetConfig();
return instance
.post(`/api/v1/messages/`, info, config)
.then((response) => {
return [true, response.data];
})
.catch((error) => {
console.log("Error:", error.response.data);
let error_message = ParseError(error);
return [false, error_message];
});
}