From 0458c332666e0efee251989a8b5f2d82f05a4087 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:56:22 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20=E0=B9=81=E0=B8=81=E0=B9=89=20function?= =?UTF-8?q?=20=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=AA=E0=B8=A3=E0=B9=89?= =?UTF-8?q?=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/branch-contact/index.ts | 13 +------------ src/stores/branch/index.ts | 12 +++++++++++- src/stores/branch/types.ts | 7 +++++-- 3 files changed, 17 insertions(+), 15 deletions(-) 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 = {