fix:แก้ editById ให้ แก้ไขรูปได้

This commit is contained in:
Net 2024-04-18 14:57:01 +07:00
parent 049a0406e1
commit ceb39828ee

View file

@ -150,20 +150,35 @@ const useBranchStore = defineStore('api-branch', () => {
async function editById( async function editById(
id: string, id: string,
branch: Partial<BranchCreate & { status: 'ACTIVE' | 'INACTIVE' }>, data: Partial<BranchCreate & { status: 'ACTIVE' | 'INACTIVE' }>,
qrCodeImage?: File,
flow?: { flow?: {
sessionId: string; sessionId: string;
refTransactionId: string; refTransactionId: string;
transactionId: string; transactionId: string;
}, },
) { ) {
const res = await api.put<Branch>(`/branch/${id}`, branch, { const { ...payload } = data;
headers: { const res = await api.put<Branch & { qrCodeImageUploadUrl: string }>(
'X-Session-Id': flow?.sessionId, `/branch/${id}`,
'X-Rtid': flow?.refTransactionId, payload,
'X-Tid': flow?.transactionId, {
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; if (!res) return false;