feat: branch admin

This commit is contained in:
Methapon2001 2024-08-14 15:30:01 +07:00
parent dcdaa17983
commit 5bfab54120
3 changed files with 101 additions and 0 deletions

View file

@ -6,6 +6,7 @@ import { BankBook, Branch, BranchCreate } from './types';
import { BranchContact } from '../branch-contact/types';
import axios from 'axios';
import useFlowStore from '../flow';
import { User } from '../user/types';
type BranchId = string;
@ -263,6 +264,29 @@ const useBranchStore = defineStore('api-branch', () => {
return false;
}
async function getAdmin(
branchId: string | string[],
flow?: {
sessionId?: string;
refTransactionId?: string;
transactionId?: string;
},
) {
const res = await api.get<User>(`/branch/${branchId}/admin`, {
headers: {
'X-Session-Id': flow?.sessionId,
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
'X-Tid': flow?.transactionId,
},
});
if (!res) return false;
if (res.status === 200) return res.data;
if (res.status === 204) return null;
return false;
}
async function addUser(
branchId: string,
userId: string | string[],
@ -392,6 +416,7 @@ const useBranchStore = defineStore('api-branch', () => {
editById,
deleteById,
getAdmin,
getUser,
addUser,
removeUser,