chore: clean unused
This commit is contained in:
parent
1e9a5abc1c
commit
3646956038
1 changed files with 26 additions and 198 deletions
|
|
@ -15,12 +15,10 @@ import {
|
|||
import axios from 'axios';
|
||||
import useBranchStore from '../branch';
|
||||
import { Branch } from '../branch/types';
|
||||
import useFlowStore from '../flow';
|
||||
|
||||
const branchStore = useBranchStore();
|
||||
|
||||
const useUserStore = defineStore('api-user', () => {
|
||||
const flowStore = useFlowStore();
|
||||
const userOption = ref<UserOption>({
|
||||
hqOpts: [],
|
||||
brOpts: [],
|
||||
|
|
@ -95,37 +93,15 @@ const useUserStore = defineStore('api-user', () => {
|
|||
});
|
||||
}
|
||||
|
||||
async function fetchAttachment(
|
||||
userId: string,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const res = await api.get<UserAttachment[]>(`/user/${userId}/attachment`, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
});
|
||||
|
||||
async function fetchAttachment(userId: string) {
|
||||
const res = await api.get<UserAttachment[]>(`/user/${userId}/attachment`);
|
||||
if (res && res.status === 200) {
|
||||
return res.data;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async function addAttachment(
|
||||
userId: string,
|
||||
payload: UserAttachmentCreate,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
async function addAttachment(userId: string, payload: UserAttachmentCreate) {
|
||||
const list: { name: string; file: File }[] = [];
|
||||
|
||||
payload.file.forEach((v) => {
|
||||
|
|
@ -156,13 +132,6 @@ const useUserStore = defineStore('api-user', () => {
|
|||
const res = await api.post<(UserAttachment & { uploadUrl: string })[]>(
|
||||
`/user/${userId}/attachment`,
|
||||
{ file: list.map((v) => v.name) },
|
||||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
|
|
@ -182,19 +151,9 @@ const useUserStore = defineStore('api-user', () => {
|
|||
async function deleteAttachment(
|
||||
userId: string,
|
||||
payload: UserAttachmentDelete,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
await api.delete(`/user/${userId}/attachment`, {
|
||||
data: payload,
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -217,21 +176,8 @@ const useUserStore = defineStore('api-user', () => {
|
|||
return false;
|
||||
}
|
||||
|
||||
async function fetchById(
|
||||
id: string,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const res = await api.get<User>(`/user/${id}`, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
});
|
||||
async function fetchById(id: string) {
|
||||
const res = await api.get<User>(`/user/${id}`);
|
||||
|
||||
if (!res) return false;
|
||||
if (res.status === 200) return res.data;
|
||||
|
|
@ -240,21 +186,8 @@ const useUserStore = defineStore('api-user', () => {
|
|||
return false;
|
||||
}
|
||||
|
||||
async function fetchImageListById(
|
||||
id: string,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const res = await api.get(`/user/${id}/profile-image`, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
});
|
||||
async function fetchImageListById(id: string) {
|
||||
const res = await api.get(`/user/${id}/profile-image`);
|
||||
|
||||
if (!res) return false;
|
||||
if (res.status === 200) return res.data;
|
||||
|
|
@ -274,22 +207,8 @@ const useUserStore = defineStore('api-user', () => {
|
|||
return name;
|
||||
}
|
||||
|
||||
async function deleteImageByName(
|
||||
id: string,
|
||||
name: string,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const res = await api.delete(`/user/${id}/profile-image/${name}`, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
});
|
||||
async function deleteImageByName(id: string, name: string) {
|
||||
const res = await api.delete(`/user/${id}/profile-image/${name}`);
|
||||
|
||||
if (!res) return false;
|
||||
}
|
||||
|
|
@ -300,27 +219,12 @@ const useUserStore = defineStore('api-user', () => {
|
|||
selectedImage: string;
|
||||
list: { url: string; imgFile: File | null; name: string }[];
|
||||
},
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const { zipCode, ...payload } = data;
|
||||
const res = await api.post<User>(
|
||||
'/user',
|
||||
{
|
||||
...payload,
|
||||
selectedImage: imgList.selectedImage || '',
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
},
|
||||
);
|
||||
const res = await api.post<User>('/user', {
|
||||
...payload,
|
||||
selectedImage: imgList.selectedImage || '',
|
||||
});
|
||||
|
||||
if (imgList.list.length > 0 && res.data.id) {
|
||||
for (let index = 0; index < imgList.list.length; index++) {
|
||||
|
|
@ -338,42 +242,18 @@ const useUserStore = defineStore('api-user', () => {
|
|||
async function editById(
|
||||
id: string,
|
||||
data: Partial<UserCreate & { status?: 'ACTIVE' | 'INACTIVE' }>,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const { zipCode, ...paylond } = data;
|
||||
const { zipCode, ...payload } = data;
|
||||
|
||||
const res = await api.put<User>(`/user/${id}`, paylond, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
});
|
||||
const res = await api.put<User>(`/user/${id}`, payload);
|
||||
|
||||
if (!res) return false;
|
||||
|
||||
return res.data;
|
||||
}
|
||||
|
||||
async function deleteById(
|
||||
id: string,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const res = await api.delete<User>(`/user/${id}`, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
});
|
||||
async function deleteById(id: string) {
|
||||
const res = await api.delete<User>(`/user/${id}`);
|
||||
|
||||
if (!res) return false;
|
||||
if (res.status === 200) return res.data;
|
||||
|
|
@ -381,21 +261,8 @@ const useUserStore = defineStore('api-user', () => {
|
|||
return false;
|
||||
}
|
||||
|
||||
async function getBranch(
|
||||
userId: string,
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const res = await api.get<Pagination<Branch[]>>(`/user/${userId}/branch`, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
});
|
||||
async function getBranch(userId: string) {
|
||||
const res = await api.get<Pagination<Branch[]>>(`/user/${userId}/branch`);
|
||||
|
||||
if (!res) return false;
|
||||
if (res.status === 200) return res.data;
|
||||
|
|
@ -403,26 +270,10 @@ const useUserStore = defineStore('api-user', () => {
|
|||
return false;
|
||||
}
|
||||
|
||||
async function addBranch(
|
||||
userId: string,
|
||||
branchId: string | string[],
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
const res = await api.post(
|
||||
`/user/${userId}/branch`,
|
||||
{ branch: ([] as string[]).concat(branchId) },
|
||||
{
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
},
|
||||
);
|
||||
async function addBranch(userId: string, branchId: string | string[]) {
|
||||
const res = await api.post(`/user/${userId}/branch`, {
|
||||
branch: ([] as string[]).concat(branchId),
|
||||
});
|
||||
|
||||
if (!res) return false;
|
||||
if (res.status >= 400) return false;
|
||||
|
|
@ -430,21 +281,8 @@ const useUserStore = defineStore('api-user', () => {
|
|||
return res.data || true;
|
||||
}
|
||||
|
||||
async function removeBranch(
|
||||
userId: string,
|
||||
branchId: string | string[],
|
||||
flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
},
|
||||
) {
|
||||
async function removeBranch(userId: string, branchId: string | string[]) {
|
||||
const res = await api.delete(`/user/${userId}/branch`, {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
data: { branch: ([] as string[]).concat(branchId) },
|
||||
});
|
||||
|
||||
|
|
@ -454,18 +292,8 @@ const useUserStore = defineStore('api-user', () => {
|
|||
return res.data || true;
|
||||
}
|
||||
|
||||
async function typeStats(flow?: {
|
||||
sessionId?: string;
|
||||
refTransactionId?: string;
|
||||
transactionId?: string;
|
||||
}) {
|
||||
const res = await api.get('/user/type-stats', {
|
||||
headers: {
|
||||
'X-Session-Id': flow?.sessionId,
|
||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
||||
'X-Tid': flow?.transactionId,
|
||||
},
|
||||
});
|
||||
async function typeStats() {
|
||||
const res = await api.get('/user/type-stats');
|
||||
if (!res) return false;
|
||||
if (res.status === 200) return res.data;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue