feat: avatar edition & new avatar component

This commit is contained in:
swve 2024-01-20 02:27:09 +01:00
parent a51a128fcb
commit 9b8ec34bba
12 changed files with 260 additions and 98 deletions

View file

@ -1,8 +1,16 @@
import { getAPIUrl } from "@services/config/config";
import { RequestBody, errorHandling } from "@services/utils/ts/requests";
import { RequestBody, RequestBodyForm, errorHandling, getResponseMetadata } from "@services/utils/ts/requests";
export async function getUser(user_id: string) {
const result = await fetch(`${getAPIUrl()}users/user_id/${user_id}`, RequestBody("GET", null, null));
const res = await errorHandling(result);
return res;
}
export async function updateUserAvatar(user_uuid: any, avatar_file: any) {
const formData = new FormData();
formData.append("avatar_file", avatar_file);
const result: any = await fetch(`${getAPIUrl()}users/update_avatar/${user_uuid}`, RequestBodyForm("PUT", formData, null));
const res = await getResponseMetadata(result);
return res;
}