fix: แก้ function การสร้าง
This commit is contained in:
parent
17b9450b47
commit
0458c33266
3 changed files with 17 additions and 15 deletions
|
|
@ -64,18 +64,15 @@ const useBranchContactStore = defineStore('api-branch-contact', () => {
|
|||
async function create(
|
||||
branchId: string,
|
||||
data: BranchContactCreate,
|
||||
qrCodeImage?: File | null, // required but not strict
|
||||
flow?: {
|
||||
sessionId: string;
|
||||
refTransactionId: string;
|
||||
transactionId: string;
|
||||
},
|
||||
) {
|
||||
const { ...payload } = data;
|
||||
|
||||
const res = await api.post<
|
||||
BranchContact & { qrCodeImageUploadUrl: string }
|
||||
>(`/branch/${branchId}/contact`, payload, {
|
||||
>(`/branch/${branchId}/contact`, data, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId,
|
||||
|
|
@ -83,14 +80,6 @@ const useBranchContactStore = defineStore('api-branch-contact', () => {
|
|||
},
|
||||
});
|
||||
|
||||
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;
|
||||
|
||||
return res.data;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { Pagination } from '../types';
|
|||
import { api } from 'src/boot/axios';
|
||||
import { Branch, BranchCreate } from './types';
|
||||
import { BranchContact } from '../branch-contact/types';
|
||||
import axios from 'axios';
|
||||
|
||||
type BranchId = string;
|
||||
|
||||
|
|
@ -123,9 +124,11 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
transactionId: string;
|
||||
},
|
||||
) {
|
||||
const { qrCodeImage, ...payload } = branch;
|
||||
|
||||
const res = await api.post<
|
||||
Branch & { qrCodeImageUrl: string; qrCodeImageUploadUrl: string }
|
||||
>('/branch', branch, {
|
||||
>('/branch', payload, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId,
|
||||
|
|
@ -133,6 +136,13 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
},
|
||||
});
|
||||
|
||||
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;
|
||||
|
||||
return res.data;
|
||||
|
|
|
|||
|
|
@ -42,14 +42,17 @@ export type BranchCreate = {
|
|||
address: string;
|
||||
zipCode: string;
|
||||
email: string;
|
||||
contactName: string;
|
||||
telephoneNo: string | string[];
|
||||
longitude: string;
|
||||
latitude: string;
|
||||
subDistrictId?: string | null;
|
||||
districtId?: string | null;
|
||||
provinceId?: string | null;
|
||||
headOfficeId?: string | null;
|
||||
telephoneNo: string;
|
||||
contactName: string;
|
||||
contact: string;
|
||||
qrCodeImage: File;
|
||||
lineId: string;
|
||||
};
|
||||
|
||||
export type BranchUserStats = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue