refactor: update user image

This commit is contained in:
Methapon2001 2024-04-09 16:59:42 +07:00
parent e6052e087b
commit 05bc85b840

View file

@ -115,13 +115,25 @@ const useUserStore = defineStore('api-user', () => {
transactionId: string;
},
) {
const res = await api.put<User>(`/user/${id}`, data, {
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Tid': flow?.transactionId,
const res = await api.put<User & { profileImageUploadUrl: string }>(
`/user/${id}`,
data,
{
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Tid': flow?.transactionId,
},
},
});
);
if (data.profileImage)
await axios
.put(res.data.profileImageUploadUrl, data.profileImage, {
headers: { 'Content-Type': data.profileImage.type },
onUploadProgress: (e) => console.log(e),
})
.catch((e) => console.error(e));
if (!res) return false;