import{r as g}from"./index-DiwDH9aE.js";import{a as c}from"./multiUserApiClient-CKPzIhIr.js";import{E as n}from"./endpoints-BUXROgJ9.js";class E{async getDistricts(t={}){try{return await c.get(n.SHARED.DISTRICTS,{params:t})}catch(s){throw console.error("Error en getDistricts:",s),s}}async getDistrict(t,s={}){try{const e=n.SHARED.DISTRICT_BY_ID.replace(":district_id",t);return await c.get(e,{params:s})}catch(e){throw console.error("Error en getDistrictById:",e),e}}async getSchools(t={}){try{return await c.get(n.SHARED.SCHOOLS,{params:t})}catch(s){throw console.error("Error en getSchools:",s),s}}async getSchool(t,s={}){try{const e=n.SHARED.SCHOOL_BY_ID.replace(":school_id",t);return await c.get(e,{params:s})}catch(e){throw console.error("Error en getSchoolById:",e),e}}async getCareers(t={}){try{return await c.get(n.SHARED.CAREERS,{params:t})}catch(s){throw console.error("Error en getCareers:",s),s}}async getCareer(t,s={}){try{const e=n.SHARED.CAREERS_BY_ID.replace(":career_id",t);return await c.get(e,{params:s})}catch(e){throw console.error("Error en getCareerById:",e),e}}async showDocument(t,s="local",e=1){try{return await c.post(n.SHARED.SHOW_FILE,{path:t,disk:s,minutes:e})}catch(l){throw console.error("Error en showDocument:",l),l}}async getStudentEnrollmentDetail(t){try{const s=n.SHARED.STUDENT_ENROLLMENT_DETAIL.replace(":student_id",t);return await c.get(s)}catch(s){throw console.error("Error en getStudentEnrollmentDetail:",s),s}}async getDiscountTypes(t={}){try{return await c.get(n.SHARED.DISCOUNTS_TYPES,{params:t})}catch(s){throw console.error("Error en getDiscountTypes:",s),s}}async getDiscountTypesActive(){try{return await c.get(n.SHARED.DISCOUNTS_TYPES,{params:{"filter[active]":1}})}catch(t){throw console.error("Error en getDiscountTypesActive:",t),t}}}const a=new E,_=()=>{const[u,t]=g.useState(!1),[s,e]=g.useState(null);return{loading:u,error:s,fetchDistricts:async(o={})=>{t(!0),e(null);try{const r=await a.getDistricts(o);return r.success||e(r.message),r}catch(r){throw e(r.message||"Error al cargar fetchDistricts"),console.error("Error en fetchDistricts:",r),r}finally{t(!1)}},getDistrict:async o=>{t(!0),e(null);try{const r=await a.getDistrict(o);return r.success||e(r.message),r}catch(r){throw e(r.message||"Error al cargar getDistrict"),console.error("Error en getDistrict:",r),r}finally{t(!1)}},fetchSchools:async(o={})=>{t(!0),e(null);try{const r=await a.getSchools(o);return r.success||e(r.message),r}catch(r){throw e(r.message||"Error al cargar fetchSchools"),console.error("Error en fetchSchools:",r),r}finally{t(!1)}},getSchool:async o=>{t(!0),e(null);try{const r=await a.getSchool(o);return r.success||e(r.message),r}catch(r){throw e(r.message||"Error al cargar getSchool"),console.error("Error en getSchool:",r),r}finally{t(!1)}},fetchCareers:async(o={})=>{t(!0),e(null);try{const r=await a.getCareers(o);return r.success||e(r.message),r}catch(r){throw e(r.message||"Error al cargar fetchCareers"),console.error("Error en fetchCareers:",r),r}finally{t(!1)}},getCareer:async o=>{t(!0),e(null);try{const r=await a.getCareer(o);return r.success||e(r.message),r}catch(r){throw e(r.message||"Error al cargar getCareer"),console.error("Error en getCareer:",r),r}finally{t(!1)}},showDocument:async(o,r="local",h=1)=>{try{const i=await a.showDocument(o,r,h);return i.success||e(i.message),i}catch(i){throw console.error("Error en showDocument:",i),i}},getStudentEnrollmentDetail:async o=>{e(null),t(!0);try{const r=await a.getStudentEnrollmentDetail(o);return r.success||e(r.message),r}catch(r){throw e(r.message||"Error al cargar getStudentEnrollmentDetail"),console.error("Error en getStudentEnrollmentDetail:",r),r}finally{t(!1)}},fetchDiscountTypesActive:async()=>{e(null),t(!0);try{const o=await a.getDiscountTypesActive();return o.success||e(o.message),o}catch(o){throw e(o.message||"Error al cargar tipos de descuento"),console.error("Error en fetchDiscountTypes:",o),o}finally{t(!1)}},clearError:()=>{e(null)},reset:()=>{t(!1),e(null)}}};export{_ as u};
