feat: add flow store

This commit is contained in:
Methapon2001 2024-06-25 16:05:42 +07:00
parent 02c5aa2a1c
commit 44ae39907e
7 changed files with 83 additions and 55 deletions

View file

@ -14,8 +14,10 @@ import {
CustomerType,
} from './types';
import axios from 'axios';
import useFlowStore from '../flow';
const useCustomerStore = defineStore('api-customer', () => {
const flowStore = useFlowStore();
const data = ref<Pagination<Customer[]>>();
async function fetchListById(
@ -31,7 +33,7 @@ const useCustomerStore = defineStore('api-customer', () => {
{
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
},
@ -81,7 +83,7 @@ const useCustomerStore = defineStore('api-customer', () => {
{
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
},
@ -131,7 +133,7 @@ const useCustomerStore = defineStore('api-customer', () => {
{
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
},
@ -153,7 +155,7 @@ const useCustomerStore = defineStore('api-customer', () => {
const res = await api.get<CustomerStats>('/customer/type-stats', {
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
});
@ -188,7 +190,7 @@ const useCustomerStore = defineStore('api-customer', () => {
>('/customer', payload, {
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
});
@ -240,7 +242,7 @@ const useCustomerStore = defineStore('api-customer', () => {
>(`/customer/${id}`, payload, {
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
});
@ -276,7 +278,7 @@ const useCustomerStore = defineStore('api-customer', () => {
const res = await api.delete<Customer>(`/customer/${id}`, {
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
});
@ -304,7 +306,7 @@ const useCustomerStore = defineStore('api-customer', () => {
>('/customer-branch', data, {
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
});
@ -329,7 +331,7 @@ const useCustomerStore = defineStore('api-customer', () => {
>(`/customer-branch/${id}`, data, {
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
});
@ -349,7 +351,7 @@ const useCustomerStore = defineStore('api-customer', () => {
const res = await api.delete<Customer>(`/customer-branch/${id}`, {
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
});
@ -402,7 +404,7 @@ const useCustomerStore = defineStore('api-customer', () => {
{
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
},
@ -433,7 +435,7 @@ const useCustomerStore = defineStore('api-customer', () => {
const res = await api.get(`/customer-branch/${branchId}`, {
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
});