refactor: project structure (3)

This commit is contained in:
Methapon Metanipat 2024-10-30 10:42:12 +07:00
parent 61ab59e027
commit c0fefa4211
3 changed files with 9 additions and 63 deletions

View file

@ -61,15 +61,9 @@ const useCustomerStore = defineStore('api-customer', () => {
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[]>>(
`/customer-branch/${idBranch}/employee${(params && '?'.concat(query)) || ''}`,
`/customer-branch/${idBranch}/employee`,
{ params: opts },
);
if (res.status === 200) {
@ -96,17 +90,7 @@ const useCustomerStore = defineStore('api-customer', () => {
: unknown))[]
>,
>(opts?: Options): Promise<Data | false> {
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<Data>(
`/customer-branch${(params && '?'.concat(query)) || ''}`,
);
const res = await api.get<Data>(`/customer-branch`, { params: opts });
if (!res) return false;
if (res.status === 200) {
@ -133,17 +117,7 @@ const useCustomerStore = defineStore('api-customer', () => {
: unknown))[]
>,
>(opts?: Options): Promise<Data | false> {
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<Data>(
`/customer${(params && '?'.concat(query)) || ''}`,
);
const res = await api.get<Data>(`/customer`, { params: opts });
if (!res) return false;
if (res.status === 200) {