diff --git a/src/stores/branch-contact/index.ts b/src/stores/branch-contact/index.ts index b852a784..91742da1 100644 --- a/src/stores/branch-contact/index.ts +++ b/src/stores/branch-contact/index.ts @@ -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; diff --git a/src/stores/branch/index.ts b/src/stores/branch/index.ts index 338e37c8..4a851ba2 100644 --- a/src/stores/branch/index.ts +++ b/src/stores/branch/index.ts @@ -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; diff --git a/src/stores/branch/types.ts b/src/stores/branch/types.ts index 26695817..003961ca 100644 --- a/src/stores/branch/types.ts +++ b/src/stores/branch/types.ts @@ -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 = {