fix:แก้ editById ให้ แก้ไขรูปได้
This commit is contained in:
parent
049a0406e1
commit
ceb39828ee
1 changed files with 22 additions and 7 deletions
|
|
@ -150,20 +150,35 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
|
||||
async function editById(
|
||||
id: string,
|
||||
branch: Partial<BranchCreate & { status: 'ACTIVE' | 'INACTIVE' }>,
|
||||
data: Partial<BranchCreate & { status: 'ACTIVE' | 'INACTIVE' }>,
|
||||
qrCodeImage?: File,
|
||||
flow?: {
|
||||
sessionId: string;
|
||||
refTransactionId: string;
|
||||
transactionId: string;
|
||||
},
|
||||
) {
|
||||
const res = await api.put<Branch>(`/branch/${id}`, branch, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId,
|
||||
'X-Tid': flow?.transactionId,
|
||||
const { ...payload } = data;
|
||||
const res = await api.put<Branch & { qrCodeImageUploadUrl: string }>(
|
||||
`/branch/${id}`,
|
||||
payload,
|
||||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
|
||||
if (qrCodeImage) {
|
||||
await axios
|
||||
.put(res.data.qrCodeImageUploadUrl, qrCodeImage, {
|
||||
headers: { 'Content-Type': qrCodeImage.type },
|
||||
onUploadProgress: (e) => console.log(e),
|
||||
})
|
||||
.catch((e) => console.error(e));
|
||||
}
|
||||
|
||||
if (!res) return false;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue