diff --git a/src/stores/customer/index.ts b/src/stores/customer/index.ts index 13b98568..61da20fb 100644 --- a/src/stores/customer/index.ts +++ b/src/stores/customer/index.ts @@ -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>( - `/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 { - 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( - `/customer-branch${(params && '?'.concat(query)) || ''}`, - ); + const res = await api.get(`/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 { - 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( - `/customer${(params && '?'.concat(query)) || ''}`, - ); + const res = await api.get(`/customer`, { params: opts }); if (!res) return false; if (res.status === 200) { diff --git a/src/stores/employee/index.ts b/src/stores/employee/index.ts index bc56ad51..594066dc 100644 --- a/src/stores/employee/index.ts +++ b/src/stores/employee/index.ts @@ -379,17 +379,7 @@ const useEmployeeStore = defineStore('api-employee', () => { status?: 'CREATED' | 'ACTIVE' | 'INACTIVE'; query?: string; }) { - 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( - `/employee/stats/gender${(params && '?'.concat(query)) || ''}`, - ); + const res = await api.get(`/employee/stats/gender`, { params: opts }); if (res && res.status === 200) { return res.data; } diff --git a/src/stores/my-branch/index.ts b/src/stores/my-branch/index.ts index 8b2cd671..776fc758 100644 --- a/src/stores/my-branch/index.ts +++ b/src/stores/my-branch/index.ts @@ -5,13 +5,10 @@ import { defineStore } from 'pinia'; import { Pagination } from '../types'; import { Branch } from '../branch/types'; -import useFlowStore from '../flow'; - const useMyBranch = defineStore('useMyBranchStore', () => { const myBranch = ref(); const currentMyBranch = ref(); - const flowStore = useFlowStore(); async function fetchListOptionBranch< Options extends { page?: number; @@ -23,20 +20,9 @@ const useMyBranch = defineStore('useMyBranchStore', () => { }, Data extends Pagination, >(opts?: Options): Promise { - 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( - `/branch${(params && '?'.concat(query)) || ''}`, - { - headers: { 'X-Rtid': flowStore.rtid }, - }, - ); + const res = await api.get(`/branch`, { + params: opts, + }); if (res && res.status === 200) { return res.data; @@ -45,11 +31,7 @@ const useMyBranch = defineStore('useMyBranchStore', () => { } async function fetchListMyBranch(userId: string) { - const res = await api.get>(`/branch`, { - headers: { - 'X-Rtid': flowStore.rtid, - }, - }); + const res = await api.get>(`/branch`); if (!res) return false; if (res.status === 200) {