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

@ -15,10 +15,12 @@ import axios from 'axios';
import useBranchStore from '../branch';
import { Branch } from '../branch/types';
import { useI18n } from 'vue-i18n';
import useFlowStore from '../flow';
const branchStore = useBranchStore();
const useUserStore = defineStore('api-user', () => {
const flowStore = useFlowStore();
const userOption = ref<UserOption>({
hqOpts: [],
brOpts: [],
@ -145,7 +147,7 @@ const useUserStore = defineStore('api-user', () => {
const res = await api.get<UserAttachment[]>(`/user/${userId}/attachment`, {
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
});
@ -198,7 +200,7 @@ const useUserStore = defineStore('api-user', () => {
{
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
},
@ -231,7 +233,7 @@ const useUserStore = defineStore('api-user', () => {
data: payload,
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
});
@ -270,7 +272,7 @@ const useUserStore = defineStore('api-user', () => {
{
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
},
@ -294,7 +296,7 @@ const useUserStore = defineStore('api-user', () => {
const res = await api.get<User>(`/user/${id}`, {
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
});
@ -321,7 +323,7 @@ const useUserStore = defineStore('api-user', () => {
{
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
},
@ -356,7 +358,7 @@ const useUserStore = defineStore('api-user', () => {
{
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
},
@ -386,7 +388,7 @@ const useUserStore = defineStore('api-user', () => {
const res = await api.delete<User>(`/user/${id}`, {
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
});
@ -408,7 +410,7 @@ const useUserStore = defineStore('api-user', () => {
const res = await api.get<Pagination<Branch[]>>(`/user/${userId}/branch`, {
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
});
@ -434,7 +436,7 @@ const useUserStore = defineStore('api-user', () => {
{
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
},
@ -458,7 +460,7 @@ const useUserStore = defineStore('api-user', () => {
const res = await api.delete(`/user/${userId}/branch`, {
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
data: { branch: ([] as string[]).concat(branchId) },
@ -478,7 +480,7 @@ const useUserStore = defineStore('api-user', () => {
const res = await api.get('/user/type-stats', {
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
});