From e19a15eaeb592f503b41da565ecd1cbd407325a8 Mon Sep 17 00:00:00 2001 From: Thanaphon Frappet Date: Thu, 14 Nov 2024 15:50:23 +0700 Subject: [PATCH] refactor: fetch office --- src/stores/address/index.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/stores/address/index.ts b/src/stores/address/index.ts index 6688eeda..c2b1f654 100644 --- a/src/stores/address/index.ts +++ b/src/stores/address/index.ts @@ -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(); const district = ref>({}); const subDistrict = ref>({}); + async function fetchOffice(opts?: { districtId?: string; query?: string }) { + const res = await api.get('/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,