feat(kol-web): add updateProfile and uploadAvatar to kolManageApi
This commit is contained in:
@@ -271,6 +271,41 @@ export const kolManageApi = {
|
||||
profile() {
|
||||
return apiClient.get<KolProfile>("/api/tenant/kol/manage/profile");
|
||||
},
|
||||
updateProfile(body: {
|
||||
display_name: string;
|
||||
bio?: string | null;
|
||||
avatar_url?: string | null;
|
||||
}) {
|
||||
return apiClient.put<KolProfile, typeof body>(
|
||||
"/api/tenant/kol/manage/profile",
|
||||
body,
|
||||
);
|
||||
},
|
||||
async uploadAvatar(file: File) {
|
||||
const normalizedFile = await convertImageFileToWebp(file);
|
||||
const progressToken = markImageUploadRequestStarted(normalizedFile.name);
|
||||
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append("file", normalizedFile, normalizedFile.name);
|
||||
|
||||
const response = await apiClient.raw.post<ApiEnvelope<{
|
||||
url: string;
|
||||
object_key: string;
|
||||
content_type: string;
|
||||
size_bytes: number;
|
||||
}>>("/api/tenant/kol/manage/profile/avatar", formData);
|
||||
|
||||
markImageUploadRequestFinished(progressToken);
|
||||
return {
|
||||
...response.data.data,
|
||||
url: resolveApiURL(response.data.data.url),
|
||||
};
|
||||
} catch (error) {
|
||||
markImageUploadRequestFailed(progressToken);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
listPackages() {
|
||||
return apiClient.get<KolPackageSummary[]>("/api/tenant/kol/manage/packages");
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user