diff --git a/src/stores/customer/index.ts b/src/stores/customer/index.ts index 2232722f..d2f6828e 100644 --- a/src/stores/customer/index.ts +++ b/src/stores/customer/index.ts @@ -8,12 +8,40 @@ import { CustomerUpdate, BranchAttachmentCreate, BranchAttachment, + CustomerStats, CustomerBranch, } from './types'; import axios from 'axios'; const useCustomerStore = defineStore('api-customer', () => { const data = ref>(); + + async function fetchListById( + customerId: string, + flow?: { + sessionId: string; + refTransactionId: string; + transactionId: string; + }, + ) { + const res = await api.get( + `/customer/${customerId}`, + { + headers: { + 'X-Session-Id': flow?.sessionId, + 'X-Rtid': flow?.refTransactionId, + 'X-Tid': flow?.transactionId, + }, + }, + ); + + ifres: if (res && res.status === 200) { + return res.data; + } + + return false; + } + async function fetchList( opts?: { page?: number; @@ -54,6 +82,23 @@ const useCustomerStore = defineStore('api-customer', () => { return false; } + async function getStatsCustomer(flow?: { + sessionId: string; + refTransactionId: string; + transactionId: string; + }) { + const res = await api.get('/customer/type-stats', { + headers: { + 'X-Session-Id': flow?.sessionId, + 'X-Rtid': flow?.refTransactionId, + 'X-Tid': flow?.transactionId, + }, + }); + + if (!res) return false; + + return res.data; + } async function create( data: CustomerCreate, flow?: { @@ -243,6 +288,9 @@ const useCustomerStore = defineStore('api-customer', () => { return { data, + getStatsCustomer, + + fetchListById, fetchList, create, editById,