From 05bc85b840ae9216b3994b18e91b09a306472de4 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Tue, 9 Apr 2024 16:59:42 +0700 Subject: [PATCH] refactor: update user image --- src/stores/user/index.ts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/stores/user/index.ts b/src/stores/user/index.ts index fc03bc55..06c66e6d 100644 --- a/src/stores/user/index.ts +++ b/src/stores/user/index.ts @@ -115,13 +115,25 @@ const useUserStore = defineStore('api-user', () => { transactionId: string; }, ) { - const res = await api.put(`/user/${id}`, data, { - headers: { - 'X-Session-Id': flow?.sessionId, - 'X-Rtid': flow?.refTransactionId, - 'X-Tid': flow?.transactionId, + const res = await api.put( + `/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;