feat: add flow store
This commit is contained in:
parent
02c5aa2a1c
commit
44ae39907e
7 changed files with 83 additions and 55 deletions
|
|
@ -5,10 +5,12 @@ import { api } from 'src/boot/axios';
|
|||
import { Branch, BranchCreate } from './types';
|
||||
import { BranchContact } from '../branch-contact/types';
|
||||
import axios from 'axios';
|
||||
import useFlowStore from '../flow';
|
||||
|
||||
type BranchId = string;
|
||||
|
||||
const useBranchStore = defineStore('api-branch', () => {
|
||||
const flowStore = useFlowStore();
|
||||
const data = ref<Pagination<Branch[]>>({
|
||||
result: [],
|
||||
page: 0,
|
||||
|
|
@ -60,7 +62,7 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
},
|
||||
|
|
@ -104,7 +106,7 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
},
|
||||
|
|
@ -135,7 +137,7 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
>('/branch', payload, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
});
|
||||
|
|
@ -179,7 +181,7 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
>(`/branch/${id}`, payload, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
});
|
||||
|
|
@ -218,7 +220,7 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
const res = await api.delete<Branch>(`/branch/${id}`, {
|
||||
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 useBranchStore = defineStore('api-branch', () => {
|
|||
const res = await api.get(`/branch/${branchId}/user`, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
});
|
||||
|
|
@ -266,7 +268,7 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
},
|
||||
|
|
@ -290,7 +292,7 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
const res = await api.delete(`/branch/${branchId}/user`, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
data: { user: ([] as string[]).concat(userId) },
|
||||
|
|
@ -313,7 +315,7 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
}>('/branch/stats', {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
});
|
||||
|
|
@ -337,7 +339,7 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue