refactor: project structure (3)
This commit is contained in:
parent
61ab59e027
commit
c0fefa4211
3 changed files with 9 additions and 63 deletions
|
|
@ -61,15 +61,9 @@ const useCustomerStore = defineStore('api-customer', () => {
|
||||||
passport?: boolean;
|
passport?: boolean;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const params = new URLSearchParams();
|
|
||||||
for (const [k, v] of Object.entries(opts || {})) {
|
|
||||||
v !== undefined && params.append(k, v.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
const query = params.toString();
|
|
||||||
|
|
||||||
const res = await api.get<Pagination<Employee[]>>(
|
const res = await api.get<Pagination<Employee[]>>(
|
||||||
`/customer-branch/${idBranch}/employee${(params && '?'.concat(query)) || ''}`,
|
`/customer-branch/${idBranch}/employee`,
|
||||||
|
{ params: opts },
|
||||||
);
|
);
|
||||||
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
|
|
@ -96,17 +90,7 @@ const useCustomerStore = defineStore('api-customer', () => {
|
||||||
: unknown))[]
|
: unknown))[]
|
||||||
>,
|
>,
|
||||||
>(opts?: Options): Promise<Data | false> {
|
>(opts?: Options): Promise<Data | false> {
|
||||||
const params = new URLSearchParams();
|
const res = await api.get<Data>(`/customer-branch`, { params: opts });
|
||||||
|
|
||||||
for (const [k, v] of Object.entries(opts || {})) {
|
|
||||||
v !== undefined && params.append(k, v.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
const query = params.toString();
|
|
||||||
|
|
||||||
const res = await api.get<Data>(
|
|
||||||
`/customer-branch${(params && '?'.concat(query)) || ''}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!res) return false;
|
if (!res) return false;
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
|
|
@ -133,17 +117,7 @@ const useCustomerStore = defineStore('api-customer', () => {
|
||||||
: unknown))[]
|
: unknown))[]
|
||||||
>,
|
>,
|
||||||
>(opts?: Options): Promise<Data | false> {
|
>(opts?: Options): Promise<Data | false> {
|
||||||
const params = new URLSearchParams();
|
const res = await api.get<Data>(`/customer`, { params: opts });
|
||||||
|
|
||||||
for (const [k, v] of Object.entries(opts || {})) {
|
|
||||||
v !== undefined && params.append(k, v.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
const query = params.toString();
|
|
||||||
|
|
||||||
const res = await api.get<Data>(
|
|
||||||
`/customer${(params && '?'.concat(query)) || ''}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!res) return false;
|
if (!res) return false;
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
|
|
|
||||||
|
|
@ -379,17 +379,7 @@ const useEmployeeStore = defineStore('api-employee', () => {
|
||||||
status?: 'CREATED' | 'ACTIVE' | 'INACTIVE';
|
status?: 'CREATED' | 'ACTIVE' | 'INACTIVE';
|
||||||
query?: string;
|
query?: string;
|
||||||
}) {
|
}) {
|
||||||
const params = new URLSearchParams();
|
const res = await api.get(`/employee/stats/gender`, { params: opts });
|
||||||
|
|
||||||
for (const [k, v] of Object.entries(opts || {})) {
|
|
||||||
v !== undefined && params.append(k, v.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
const query = params.toString();
|
|
||||||
|
|
||||||
const res = await api.get(
|
|
||||||
`/employee/stats/gender${(params && '?'.concat(query)) || ''}`,
|
|
||||||
);
|
|
||||||
if (res && res.status === 200) {
|
if (res && res.status === 200) {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,10 @@ import { defineStore } from 'pinia';
|
||||||
import { Pagination } from '../types';
|
import { Pagination } from '../types';
|
||||||
import { Branch } from '../branch/types';
|
import { Branch } from '../branch/types';
|
||||||
|
|
||||||
import useFlowStore from '../flow';
|
|
||||||
|
|
||||||
const useMyBranch = defineStore('useMyBranchStore', () => {
|
const useMyBranch = defineStore('useMyBranchStore', () => {
|
||||||
const myBranch = ref<Branch[]>();
|
const myBranch = ref<Branch[]>();
|
||||||
const currentMyBranch = ref<Branch>();
|
const currentMyBranch = ref<Branch>();
|
||||||
|
|
||||||
const flowStore = useFlowStore();
|
|
||||||
async function fetchListOptionBranch<
|
async function fetchListOptionBranch<
|
||||||
Options extends {
|
Options extends {
|
||||||
page?: number;
|
page?: number;
|
||||||
|
|
@ -23,20 +20,9 @@ const useMyBranch = defineStore('useMyBranchStore', () => {
|
||||||
},
|
},
|
||||||
Data extends Pagination<Branch[]>,
|
Data extends Pagination<Branch[]>,
|
||||||
>(opts?: Options): Promise<Data | false> {
|
>(opts?: Options): Promise<Data | false> {
|
||||||
const params = new URLSearchParams();
|
const res = await api.get<Data>(`/branch`, {
|
||||||
|
params: opts,
|
||||||
for (const [k, v] of Object.entries(opts || {})) {
|
});
|
||||||
v !== undefined && params.append(k, v.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
const query = params.toString();
|
|
||||||
|
|
||||||
const res = await api.get<Data>(
|
|
||||||
`/branch${(params && '?'.concat(query)) || ''}`,
|
|
||||||
{
|
|
||||||
headers: { 'X-Rtid': flowStore.rtid },
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (res && res.status === 200) {
|
if (res && res.status === 200) {
|
||||||
return res.data;
|
return res.data;
|
||||||
|
|
@ -45,11 +31,7 @@ const useMyBranch = defineStore('useMyBranchStore', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchListMyBranch(userId: string) {
|
async function fetchListMyBranch(userId: string) {
|
||||||
const res = await api.get<Pagination<Branch[]>>(`/branch`, {
|
const res = await api.get<Pagination<Branch[]>>(`/branch`);
|
||||||
headers: {
|
|
||||||
'X-Rtid': flowStore.rtid,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!res) return false;
|
if (!res) return false;
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue