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(
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;