refactor: fetch office
This commit is contained in:
parent
6bfd88c305
commit
e19a15eaeb
1 changed files with 17 additions and 0 deletions
|
|
@ -35,11 +35,27 @@ export interface Province {
|
||||||
id: string;
|
id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Office {
|
||||||
|
provinceId: string;
|
||||||
|
nameEN: string;
|
||||||
|
name: string;
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
|
||||||
const useAddressStore = defineStore('api-address', () => {
|
const useAddressStore = defineStore('api-address', () => {
|
||||||
const province = ref<Province[]>();
|
const province = ref<Province[]>();
|
||||||
const district = ref<Record<Province['id'], District[]>>({});
|
const district = ref<Record<Province['id'], District[]>>({});
|
||||||
const subDistrict = ref<Record<District['id'], SubDistrict[]>>({});
|
const subDistrict = ref<Record<District['id'], SubDistrict[]>>({});
|
||||||
|
|
||||||
|
async function fetchOffice(opts?: { districtId?: string; query?: string }) {
|
||||||
|
const res = await api.get<Office[]>('/employment-office', {
|
||||||
|
params: opts,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.status >= 400) return null;
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchProvince() {
|
async function fetchProvince() {
|
||||||
if (province.value) return province.value;
|
if (province.value) return province.value;
|
||||||
|
|
||||||
|
|
@ -81,6 +97,7 @@ const useAddressStore = defineStore('api-address', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
fetchOffice,
|
||||||
fetchProvince,
|
fetchProvince,
|
||||||
fetchDistrictByProvinceId,
|
fetchDistrictByProvinceId,
|
||||||
fetchSubDistrictByProvinceId,
|
fetchSubDistrictByProvinceId,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue