refactor: create fetch office by id

This commit is contained in:
Thanaphon Frappet 2024-11-14 17:51:38 +07:00
parent b1d08b19ee
commit fda0d581ae

View file

@ -55,6 +55,12 @@ const useAddressStore = defineStore('api-address', () => {
if (res.status >= 400) return null; if (res.status >= 400) return null;
return res.data; return res.data;
} }
async function fetchOfficeById(id: string) {
const res = await api.get<Office>(`/employment-office/${id}`);
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;
@ -98,6 +104,7 @@ const useAddressStore = defineStore('api-address', () => {
return { return {
fetchOffice, fetchOffice,
fetchOfficeById,
fetchProvince, fetchProvince,
fetchDistrictByProvinceId, fetchDistrictByProvinceId,
fetchSubDistrictByProvinceId, fetchSubDistrictByProvinceId,