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;
|
||||
}
|
||||
|
||||
export interface Office {
|
||||
provinceId: string;
|
||||
nameEN: string;
|
||||
name: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
const useAddressStore = defineStore('api-address', () => {
|
||||
const province = ref<Province[]>();
|
||||
const district = ref<Record<Province['id'], District[]>>({});
|
||||
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() {
|
||||
if (province.value) return province.value;
|
||||
|
||||
|
|
@ -81,6 +97,7 @@ const useAddressStore = defineStore('api-address', () => {
|
|||
}
|
||||
|
||||
return {
|
||||
fetchOffice,
|
||||
fetchProvince,
|
||||
fetchDistrictByProvinceId,
|
||||
fetchSubDistrictByProvinceId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue